| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 const CSSParserToken& token = range.Peek(); | 435 const CSSParserToken& token = range.Peek(); |
| 436 if (token.GetType() != kIdentToken && token.GetType() != kFunctionToken) | 436 if (token.GetType() != kIdentToken && token.GetType() != kFunctionToken) |
| 437 return nullptr; | 437 return nullptr; |
| 438 | 438 |
| 439 std::unique_ptr<CSSParserSelector> selector = CSSParserSelector::Create(); | 439 std::unique_ptr<CSSParserSelector> selector = CSSParserSelector::Create(); |
| 440 selector->SetMatch(colons == 1 ? CSSSelector::kPseudoClass | 440 selector->SetMatch(colons == 1 ? CSSSelector::kPseudoClass |
| 441 : CSSSelector::kPseudoElement); | 441 : CSSSelector::kPseudoElement); |
| 442 | 442 |
| 443 AtomicString value = token.Value().ToAtomicString().LowerASCII(); | 443 AtomicString value = token.Value().ToAtomicString().LowerASCII(); |
| 444 bool has_arguments = token.GetType() == kFunctionToken; | 444 bool has_arguments = token.GetType() == kFunctionToken; |
| 445 selector->UpdatePseudoType(value, has_arguments); | 445 selector->UpdatePseudoType(value, *context_, has_arguments); |
| 446 | 446 |
| 447 if (!RuntimeEnabledFeatures::cssSelectorsFocusWithinEnabled() && | 447 if (!RuntimeEnabledFeatures::cssSelectorsFocusWithinEnabled() && |
| 448 selector->GetPseudoType() == CSSSelector::kPseudoFocusWithin) | 448 selector->GetPseudoType() == CSSSelector::kPseudoFocusWithin) |
| 449 return nullptr; | 449 return nullptr; |
| 450 | 450 |
| 451 if (selector->Match() == CSSSelector::kPseudoElement && | 451 if (selector->Match() == CSSSelector::kPseudoElement && |
| 452 disallow_pseudo_elements_) | 452 disallow_pseudo_elements_) |
| 453 return nullptr; | 453 return nullptr; |
| 454 | 454 |
| 455 if (token.GetType() == kIdentToken) { | 455 if (token.GetType() == kIdentToken) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 case '/': { | 575 case '/': { |
| 576 // Match /deep/ | 576 // Match /deep/ |
| 577 range.Consume(); | 577 range.Consume(); |
| 578 const CSSParserToken& ident = range.Consume(); | 578 const CSSParserToken& ident = range.Consume(); |
| 579 if (ident.GetType() != kIdentToken || | 579 if (ident.GetType() != kIdentToken || |
| 580 !EqualIgnoringASCIICase(ident.Value(), "deep")) | 580 !EqualIgnoringASCIICase(ident.Value(), "deep")) |
| 581 failed_parsing_ = true; | 581 failed_parsing_ = true; |
| 582 const CSSParserToken& slash = range.ConsumeIncludingWhitespace(); | 582 const CSSParserToken& slash = range.ConsumeIncludingWhitespace(); |
| 583 if (slash.GetType() != kDelimiterToken || slash.Delimiter() != '/') | 583 if (slash.GetType() != kDelimiterToken || slash.Delimiter() != '/') |
| 584 failed_parsing_ = true; | 584 failed_parsing_ = true; |
| 585 return CSSSelector::kShadowDeep; | 585 return context_->IsDynamicProfile() ? CSSSelector::kShadowDeepAsDescendant |
| 586 : CSSSelector::kShadowDeep; |
| 586 } | 587 } |
| 587 | 588 |
| 588 default: | 589 default: |
| 589 break; | 590 break; |
| 590 } | 591 } |
| 591 return fallback_result; | 592 return fallback_result; |
| 592 } | 593 } |
| 593 | 594 |
| 594 CSSSelector::MatchType CSSSelectorParser::ConsumeAttributeMatch( | 595 CSSSelector::MatchType CSSSelectorParser::ConsumeAttributeMatch( |
| 595 CSSParserTokenRange& range) { | 596 CSSParserTokenRange& range) { |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 } | 904 } |
| 904 if (current->Relation() == CSSSelector::kIndirectAdjacent) | 905 if (current->Relation() == CSSSelector::kIndirectAdjacent) |
| 905 context_->Count(UseCounter::kCSSSelectorIndirectAdjacent); | 906 context_->Count(UseCounter::kCSSSelectorIndirectAdjacent); |
| 906 if (current->SelectorList()) | 907 if (current->SelectorList()) |
| 907 RecordUsageAndDeprecations(*current->SelectorList()); | 908 RecordUsageAndDeprecations(*current->SelectorList()); |
| 908 } | 909 } |
| 909 } | 910 } |
| 910 } | 911 } |
| 911 | 912 |
| 912 } // namespace blink | 913 } // namespace blink |
| OLD | NEW |