| 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 "core/css/CSSSelectorList.h" | 7 #include "core/css/CSSSelectorList.h" |
| 8 #include "core/css/StyleSheetContents.h" | 8 #include "core/css/StyleSheetContents.h" |
| 9 #include "core/css/parser/CSSParserContext.h" | 9 #include "core/css/parser/CSSParserContext.h" |
| 10 #include "core/frame/Deprecation.h" | 10 #include "core/frame/Deprecation.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return true; | 166 return true; |
| 167 default: | 167 default: |
| 168 return false; | 168 return false; |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool IsUserActionPseudoClass(CSSSelector::PseudoType pseudo) { | 172 bool IsUserActionPseudoClass(CSSSelector::PseudoType pseudo) { |
| 173 switch (pseudo) { | 173 switch (pseudo) { |
| 174 case CSSSelector::kPseudoHover: | 174 case CSSSelector::kPseudoHover: |
| 175 case CSSSelector::kPseudoFocus: | 175 case CSSSelector::kPseudoFocus: |
| 176 case CSSSelector::kPseudoFocusWithin: |
| 176 case CSSSelector::kPseudoActive: | 177 case CSSSelector::kPseudoActive: |
| 177 return true; | 178 return true; |
| 178 default: | 179 default: |
| 179 return false; | 180 return false; |
| 180 } | 181 } |
| 181 } | 182 } |
| 182 | 183 |
| 183 bool IsPseudoClassValidAfterPseudoElement( | 184 bool IsPseudoClassValidAfterPseudoElement( |
| 184 CSSSelector::PseudoType pseudo_class, | 185 CSSSelector::PseudoType pseudo_class, |
| 185 CSSSelector::PseudoType compound_pseudo_element) { | 186 CSSSelector::PseudoType compound_pseudo_element) { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 return nullptr; | 437 return nullptr; |
| 437 | 438 |
| 438 std::unique_ptr<CSSParserSelector> selector = CSSParserSelector::Create(); | 439 std::unique_ptr<CSSParserSelector> selector = CSSParserSelector::Create(); |
| 439 selector->SetMatch(colons == 1 ? CSSSelector::kPseudoClass | 440 selector->SetMatch(colons == 1 ? CSSSelector::kPseudoClass |
| 440 : CSSSelector::kPseudoElement); | 441 : CSSSelector::kPseudoElement); |
| 441 | 442 |
| 442 AtomicString value = token.Value().ToAtomicString().LowerASCII(); | 443 AtomicString value = token.Value().ToAtomicString().LowerASCII(); |
| 443 bool has_arguments = token.GetType() == kFunctionToken; | 444 bool has_arguments = token.GetType() == kFunctionToken; |
| 444 selector->UpdatePseudoType(value, has_arguments); | 445 selector->UpdatePseudoType(value, has_arguments); |
| 445 | 446 |
| 447 if (!RuntimeEnabledFeatures::cssSelectorsFocusWithinEnabled() && |
| 448 selector->GetPseudoType() == CSSSelector::kPseudoFocusWithin) |
| 449 return nullptr; |
| 450 |
| 446 if (selector->Match() == CSSSelector::kPseudoElement && | 451 if (selector->Match() == CSSSelector::kPseudoElement && |
| 447 disallow_pseudo_elements_) | 452 disallow_pseudo_elements_) |
| 448 return nullptr; | 453 return nullptr; |
| 449 | 454 |
| 450 if (token.GetType() == kIdentToken) { | 455 if (token.GetType() == kIdentToken) { |
| 451 range.Consume(); | 456 range.Consume(); |
| 452 if (selector->GetPseudoType() == CSSSelector::kPseudoUnknown) | 457 if (selector->GetPseudoType() == CSSSelector::kPseudoUnknown) |
| 453 return nullptr; | 458 return nullptr; |
| 454 return selector; | 459 return selector; |
| 455 } | 460 } |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 } | 898 } |
| 894 if (current->Relation() == CSSSelector::kIndirectAdjacent) | 899 if (current->Relation() == CSSSelector::kIndirectAdjacent) |
| 895 context_->Count(UseCounter::kCSSSelectorIndirectAdjacent); | 900 context_->Count(UseCounter::kCSSSelectorIndirectAdjacent); |
| 896 if (current->SelectorList()) | 901 if (current->SelectorList()) |
| 897 RecordUsageAndDeprecations(*current->SelectorList()); | 902 RecordUsageAndDeprecations(*current->SelectorList()); |
| 898 } | 903 } |
| 899 } | 904 } |
| 900 } | 905 } |
| 901 | 906 |
| 902 } // namespace blink | 907 } // namespace blink |
| OLD | NEW |