| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/css/parser/CSSSelectorParser.h" | 6 #include "core/css/parser/CSSSelectorParser.h" |
| 7 | 7 |
| 8 #include "core/css/CSSSelectorList.h" | 8 #include "core/css/CSSSelectorList.h" |
| 9 #include "core/css/StyleSheetContents.h" | 9 #include "core/css/StyleSheetContents.h" |
| 10 #include "core/frame/UseCounter.h" | 10 #include "core/frame/UseCounter.h" |
| 11 #include "platform/RuntimeEnabledFeatures.h" | 11 #include "platform/RuntimeEnabledFeatures.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 static void recordSelectorStats(const CSSParserContext& context, const CSSSelect
orList& selectorList) | 15 static void recordSelectorStats(const CSSParserContext& context, const CSSSelect
orList& selectorList) |
| 16 { | 16 { |
| 17 if (!context.useCounter()) | 17 if (!context.useCounter()) |
| 18 return; | 18 return; |
| 19 | 19 |
| 20 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(*selector)) { | 20 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(*selector)) { |
| 21 for (const CSSSelector* current = selector; current ; current = current-
>tagHistory()) { | 21 for (const CSSSelector* current = selector; current ; current = current-
>tagHistory()) { |
| 22 UseCounter::Feature feature = UseCounter::NumberOfFeatures; | 22 UseCounter::Feature feature = UseCounter::NumberOfFeatures; |
| 23 switch (current->pseudoType()) { | 23 switch (current->pseudoType()) { |
| 24 case CSSSelector::PseudoUnresolved: | 24 case CSSSelector::PseudoUnresolved: |
| 25 feature = UseCounter::CSSSelectorPseudoUnresolved; | 25 feature = UseCounter::CSSSelectorPseudoUnresolved; |
| 26 break; | 26 break; |
| 27 case CSSSelector::PseudoShadow: | |
| 28 feature = UseCounter::CSSSelectorPseudoShadow; | |
| 29 break; | |
| 30 case CSSSelector::PseudoContent: | 27 case CSSSelector::PseudoContent: |
| 31 feature = UseCounter::CSSSelectorPseudoContent; | 28 feature = UseCounter::CSSSelectorPseudoContent; |
| 32 break; | 29 break; |
| 33 case CSSSelector::PseudoHost: | 30 case CSSSelector::PseudoHost: |
| 34 feature = UseCounter::CSSSelectorPseudoHost; | 31 feature = UseCounter::CSSSelectorPseudoHost; |
| 35 break; | 32 break; |
| 36 case CSSSelector::PseudoHostContext: | 33 case CSSSelector::PseudoHostContext: |
| 37 feature = UseCounter::CSSSelectorPseudoHostContext; | 34 feature = UseCounter::CSSSelectorPseudoHostContext; |
| 38 break; | 35 break; |
| 39 case CSSSelector::PseudoFullScreenDocument: | 36 case CSSSelector::PseudoFullScreenDocument: |
| 40 feature = UseCounter::CSSSelectorPseudoFullScreenDocument; | 37 feature = UseCounter::CSSSelectorPseudoFullScreenDocument; |
| 41 break; | 38 break; |
| 42 case CSSSelector::PseudoFullScreenAncestor: | 39 case CSSSelector::PseudoFullScreenAncestor: |
| 43 feature = UseCounter::CSSSelectorPseudoFullScreenAncestor; | 40 feature = UseCounter::CSSSelectorPseudoFullScreenAncestor; |
| 44 break; | 41 break; |
| 45 case CSSSelector::PseudoFullScreen: | 42 case CSSSelector::PseudoFullScreen: |
| 46 feature = UseCounter::CSSSelectorPseudoFullScreen; | 43 feature = UseCounter::CSSSelectorPseudoFullScreen; |
| 47 break; | 44 break; |
| 48 default: | 45 default: |
| 49 break; | 46 break; |
| 50 } | 47 } |
| 51 if (feature != UseCounter::NumberOfFeatures) | 48 if (feature != UseCounter::NumberOfFeatures) |
| 52 context.useCounter()->count(feature); | 49 context.useCounter()->count(feature); |
| 53 if (current->relation() == CSSSelector::ShadowDeep) | |
| 54 context.useCounter()->count(UseCounter::CSSDeepCombinator); | |
| 55 if (current->selectorList()) | 50 if (current->selectorList()) |
| 56 recordSelectorStats(context, *current->selectorList()); | 51 recordSelectorStats(context, *current->selectorList()); |
| 57 } | 52 } |
| 58 } | 53 } |
| 59 } | 54 } |
| 60 | 55 |
| 61 void CSSSelectorParser::parseSelector(CSSParserTokenRange range, const CSSParser
Context& context, const AtomicString& defaultNamespace, StyleSheetContents* styl
eSheet, CSSSelectorList& output) | 56 void CSSSelectorParser::parseSelector(CSSParserTokenRange range, const CSSParser
Context& context, const AtomicString& defaultNamespace, StyleSheetContents* styl
eSheet, CSSSelectorList& output) |
| 62 { | 57 { |
| 63 CSSSelectorParser parser(context, defaultNamespace, styleSheet); | 58 CSSSelectorParser parser(context, defaultNamespace, styleSheet); |
| 64 range.consumeWhitespace(); | 59 range.consumeWhitespace(); |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 compoundSelector->insertTagHistory(CSSSelector::SubSelector, simpleSelec
tor, relation); | 657 compoundSelector->insertTagHistory(CSSSelector::SubSelector, simpleSelec
tor, relation); |
| 663 return compoundSelector; | 658 return compoundSelector; |
| 664 } | 659 } |
| 665 | 660 |
| 666 // All other simple selectors are added to the end of the compound. | 661 // All other simple selectors are added to the end of the compound. |
| 667 compoundSelector->appendTagHistory(CSSSelector::SubSelector, simpleSelector)
; | 662 compoundSelector->appendTagHistory(CSSSelector::SubSelector, simpleSelector)
; |
| 668 return compoundSelector; | 663 return compoundSelector; |
| 669 } | 664 } |
| 670 | 665 |
| 671 } // namespace blink | 666 } // namespace blink |
| OLD | NEW |