예제 #1
0
void CSSSelectorParser::parseSelector(CSSParserTokenRange range, const CSSParserContext& context, const AtomicString& defaultNamespace, StyleSheetContents* styleSheet, CSSSelectorList& output)
{
    CSSSelectorParser parser(context, defaultNamespace, styleSheet);
    range.consumeWhitespace();
    CSSSelectorList result;
    parser.consumeComplexSelectorList(range, result);
    if (range.atEnd()) {
        output.adopt(result);
        recordSelectorStats(context, output);
    }
    ASSERT(!(output.isValid() && parser.m_failedParsing));
}
예제 #2
0
CSSSelectorList CSSSelectorParser::parseSelector(
    CSSParserTokenRange range,
    const CSSParserContext& context,
    StyleSheetContents* styleSheet) {
  CSSSelectorParser parser(context, styleSheet);
  range.consumeWhitespace();
  CSSSelectorList result = parser.consumeComplexSelectorList(range);
  if (!range.atEnd())
    return CSSSelectorList();

  recordSelectorStats(context, result);
  return result;
}
예제 #3
0
StyleRuleBase* BisonCSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors)
{
    StyleRule* result = 0;
    if (selectors) {
        m_allowImportRules = m_allowNamespaceDeclarations = false;
        RefPtrWillBeRawPtr<StyleRule> rule = StyleRule::create();
        rule->parserAdoptSelectorVector(*selectors);
        rule->setProperties(createStylePropertySet());
        result = rule.get();
        m_parsedRules.append(rule.release());
        recordSelectorStats(m_context, result->selectorList());
    }
    clearProperties();
    return result;
}
예제 #4
0
static void recordSelectorStats(const CSSParserContext& context, const CSSSelectorList& selectorList)
{
    if (!context.useCounter())
        return;

    for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(*selector)) {
        for (const CSSSelector* current = selector; current ; current = current->tagHistory()) {
            UseCounter::Feature feature = UseCounter::NumberOfFeatures;
            switch (current->pseudoType()) {
            case CSSSelector::PseudoUnresolved:
                feature = UseCounter::CSSSelectorPseudoUnresolved;
                break;
            case CSSSelector::PseudoShadow:
                feature = UseCounter::CSSSelectorPseudoShadow;
                break;
            case CSSSelector::PseudoContent:
                feature = UseCounter::CSSSelectorPseudoContent;
                break;
            case CSSSelector::PseudoHost:
                feature = UseCounter::CSSSelectorPseudoHost;
                break;
            case CSSSelector::PseudoHostContext:
                feature = UseCounter::CSSSelectorPseudoHostContext;
                break;
            case CSSSelector::PseudoFullScreenDocument:
                feature = UseCounter::CSSSelectorPseudoFullScreenDocument;
                break;
            case CSSSelector::PseudoFullScreenAncestor:
                feature = UseCounter::CSSSelectorPseudoFullScreenAncestor;
                break;
            case CSSSelector::PseudoFullScreen:
                feature = UseCounter::CSSSelectorPseudoFullScreen;
                break;
            default:
                break;
            }
            if (feature != UseCounter::NumberOfFeatures)
                context.useCounter()->count(feature);
            if (current->relation() == CSSSelector::ShadowDeep)
                context.useCounter()->count(UseCounter::CSSDeepCombinator);
            if (current->selectorList())
                recordSelectorStats(context, *current->selectorList());
        }
    }
}
예제 #5
0
static void recordSelectorStats(const CSSParserContext& context,
                                const CSSSelectorList& selectorList) {
  if (!context.useCounter())
    return;

  for (const CSSSelector* selector = selectorList.first(); selector;
       selector = CSSSelectorList::next(*selector)) {
    for (const CSSSelector* current = selector; current;
         current = current->tagHistory()) {
      UseCounter::Feature feature = UseCounter::NumberOfFeatures;
      switch (current->getPseudoType()) {
        case CSSSelector::PseudoAny:
          feature = UseCounter::CSSSelectorPseudoAny;
          break;
        case CSSSelector::PseudoUnresolved:
          feature = UseCounter::CSSSelectorPseudoUnresolved;
          break;
        case CSSSelector::PseudoDefined:
          feature = UseCounter::CSSSelectorPseudoDefined;
          break;
        case CSSSelector::PseudoSlotted:
          feature = UseCounter::CSSSelectorPseudoSlotted;
          break;
        case CSSSelector::PseudoContent:
          feature = UseCounter::CSSSelectorPseudoContent;
          break;
        case CSSSelector::PseudoHost:
          feature = UseCounter::CSSSelectorPseudoHost;
          break;
        case CSSSelector::PseudoHostContext:
          feature = UseCounter::CSSSelectorPseudoHostContext;
          break;
        case CSSSelector::PseudoFullScreenAncestor:
          feature = UseCounter::CSSSelectorPseudoFullScreenAncestor;
          break;
        case CSSSelector::PseudoFullScreen:
          feature = UseCounter::CSSSelectorPseudoFullScreen;
          break;
        case CSSSelector::PseudoListBox:
          if (context.mode() != UASheetMode)
            feature = UseCounter::CSSSelectorInternalPseudoListBox;
          break;
        case CSSSelector::PseudoWebKitCustomElement:
          if (context.mode() != UASheetMode) {
            if (current->value() == "-internal-media-controls-cast-button")
              feature = UseCounter::CSSSelectorInternalMediaControlsCastButton;
            else if (current->value() ==
                     "-internal-media-controls-overlay-cast-button")
              feature =
                  UseCounter::CSSSelectorInternalMediaControlsOverlayCastButton;
          }
          break;
        case CSSSelector::PseudoSpatialNavigationFocus:
          if (context.mode() != UASheetMode)
            feature =
                UseCounter::CSSSelectorInternalPseudoSpatialNavigationFocus;
          break;
        case CSSSelector::PseudoReadOnly:
          if (context.mode() != UASheetMode)
            feature = UseCounter::CSSSelectorPseudoReadOnly;
          break;
        case CSSSelector::PseudoReadWrite:
          if (context.mode() != UASheetMode)
            feature = UseCounter::CSSSelectorPseudoReadWrite;
          break;
        default:
          break;
      }
      if (feature != UseCounter::NumberOfFeatures)
        context.useCounter()->count(feature);
      if (current->relation() == CSSSelector::IndirectAdjacent)
        context.useCounter()->count(UseCounter::CSSSelectorIndirectAdjacent);
      if (current->selectorList())
        recordSelectorStats(context, *current->selectorList());
    }
  }
}