| 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 "core/css/parser/CSSSelectorParser.h" | 5 #include "core/css/parser/CSSSelectorParser.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 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/css/parser/CSSParserContext.h" | 10 #include "core/css/parser/CSSParserContext.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 unsigned previous_compound_flags = 0; | 115 unsigned previous_compound_flags = 0; |
| 116 | 116 |
| 117 for (CSSParserSelector* simple = selector.get(); | 117 for (CSSParserSelector* simple = selector.get(); |
| 118 simple && !previous_compound_flags; simple = simple->TagHistory()) | 118 simple && !previous_compound_flags; simple = simple->TagHistory()) |
| 119 previous_compound_flags |= ExtractCompoundFlags(*simple, context_->Mode()); | 119 previous_compound_flags |= ExtractCompoundFlags(*simple, context_->Mode()); |
| 120 | 120 |
| 121 while (CSSSelector::RelationType combinator = ConsumeCombinator(range)) { | 121 while (CSSSelector::RelationType combinator = ConsumeCombinator(range)) { |
| 122 std::unique_ptr<CSSParserSelector> next_selector = | 122 std::unique_ptr<CSSParserSelector> next_selector = |
| 123 ConsumeCompoundSelector(range); | 123 ConsumeCompoundSelector(range); |
| 124 if (!next_selector) | 124 if (!next_selector) { |
| 125 return combinator == CSSSelector::kDescendant ? std::move(selector) | 125 return combinator == CSSSelector::kDescendant ? std::move(selector) |
| 126 : nullptr; | 126 : nullptr; |
| 127 } |
| 127 if (previous_compound_flags & kHasPseudoElementForRightmostCompound) | 128 if (previous_compound_flags & kHasPseudoElementForRightmostCompound) |
| 128 return nullptr; | 129 return nullptr; |
| 129 CSSParserSelector* end = next_selector.get(); | 130 CSSParserSelector* end = next_selector.get(); |
| 130 unsigned compound_flags = ExtractCompoundFlags(*end, context_->Mode()); | 131 unsigned compound_flags = ExtractCompoundFlags(*end, context_->Mode()); |
| 131 while (end->TagHistory()) { | 132 while (end->TagHistory()) { |
| 132 end = end->TagHistory(); | 133 end = end->TagHistory(); |
| 133 compound_flags |= ExtractCompoundFlags(*end, context_->Mode()); | 134 compound_flags |= ExtractCompoundFlags(*end, context_->Mode()); |
| 134 } | 135 } |
| 135 end->SetRelation(combinator); | 136 end->SetRelation(combinator); |
| 136 if (previous_compound_flags & kHasContentPseudoElement) | 137 if (previous_compound_flags & kHasContentPseudoElement) |
| 137 end->SetRelationIsAffectedByPseudoContent(); | 138 end->SetRelationIsAffectedByPseudoContent(); |
| 138 previous_compound_flags = compound_flags; | 139 previous_compound_flags = compound_flags; |
| 139 end->SetTagHistory(std::move(selector)); | 140 end->SetTagHistory(std::move(selector)); |
| 140 | 141 |
| 141 selector = std::move(next_selector); | 142 selector = std::move(next_selector); |
| 142 } | 143 } |
| 143 | 144 |
| 145 selector->UpdateLinkMatchType(); |
| 144 return selector; | 146 return selector; |
| 145 } | 147 } |
| 146 | 148 |
| 147 namespace { | 149 namespace { |
| 148 | 150 |
| 149 bool IsScrollbarPseudoClass(CSSSelector::PseudoType pseudo) { | 151 bool IsScrollbarPseudoClass(CSSSelector::PseudoType pseudo) { |
| 150 switch (pseudo) { | 152 switch (pseudo) { |
| 151 case CSSSelector::kPseudoEnabled: | 153 case CSSSelector::kPseudoEnabled: |
| 152 case CSSSelector::kPseudoDisabled: | 154 case CSSSelector::kPseudoDisabled: |
| 153 case CSSSelector::kPseudoHover: | 155 case CSSSelector::kPseudoHover: |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 } | 952 } |
| 951 if (current->Relation() == CSSSelector::kIndirectAdjacent) | 953 if (current->Relation() == CSSSelector::kIndirectAdjacent) |
| 952 context_->Count(WebFeature::kCSSSelectorIndirectAdjacent); | 954 context_->Count(WebFeature::kCSSSelectorIndirectAdjacent); |
| 953 if (current->SelectorList()) | 955 if (current->SelectorList()) |
| 954 RecordUsageAndDeprecations(*current->SelectorList()); | 956 RecordUsageAndDeprecations(*current->SelectorList()); |
| 955 } | 957 } |
| 956 } | 958 } |
| 957 } | 959 } |
| 958 | 960 |
| 959 } // namespace blink | 961 } // namespace blink |
| OLD | NEW |