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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
804 | 805 |
805 while (split_after->TagHistory() && | 806 while (split_after->TagHistory() && |
806 !split_after->TagHistory()->NeedsImplicitShadowCombinatorForMatching()) | 807 !split_after->TagHistory()->NeedsImplicitShadowCombinatorForMatching()) |
807 split_after = split_after->TagHistory(); | 808 split_after = split_after->TagHistory(); |
808 | 809 |
809 if (!split_after || !split_after->TagHistory()) | 810 if (!split_after || !split_after->TagHistory()) |
810 return compound_selector; | 811 return compound_selector; |
811 | 812 |
812 std::unique_ptr<CSSParserSelector> second_compound = | 813 std::unique_ptr<CSSParserSelector> second_compound = |
813 split_after->ReleaseTagHistory(); | 814 split_after->ReleaseTagHistory(); |
815 // TODO: Check second_compound->GetPseudoType() | |
kochi
2017/05/09 14:29:38
What does this mean?
hayato
2017/05/10 06:57:04
This was my private TODO which I forgot to remove.
kochi
2017/05/11 02:29:07
Acknowledged.
| |
814 second_compound->AppendTagHistory( | 816 second_compound->AppendTagHistory( |
815 second_compound->GetPseudoType() == CSSSelector::kPseudoSlotted | 817 second_compound->GetPseudoType() == CSSSelector::kPseudoSlotted |
816 ? CSSSelector::kShadowSlot | 818 ? CSSSelector::kShadowSlot |
817 : CSSSelector::kShadowPseudo, | 819 : CSSSelector::kShadowPseudo, |
818 std::move(compound_selector)); | 820 std::move(compound_selector)); |
819 return second_compound; | 821 return second_compound; |
820 } | 822 } |
821 | 823 |
822 void CSSSelectorParser::RecordUsageAndDeprecations( | 824 void CSSSelectorParser::RecordUsageAndDeprecations( |
823 const CSSSelectorList& selector_list) { | 825 const CSSSelectorList& selector_list) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
898 } | 900 } |
899 if (current->Relation() == CSSSelector::kIndirectAdjacent) | 901 if (current->Relation() == CSSSelector::kIndirectAdjacent) |
900 context_->Count(UseCounter::kCSSSelectorIndirectAdjacent); | 902 context_->Count(UseCounter::kCSSSelectorIndirectAdjacent); |
901 if (current->SelectorList()) | 903 if (current->SelectorList()) |
902 RecordUsageAndDeprecations(*current->SelectorList()); | 904 RecordUsageAndDeprecations(*current->SelectorList()); |
903 } | 905 } |
904 } | 906 } |
905 } | 907 } |
906 | 908 |
907 } // namespace blink | 909 } // namespace blink |
OLD | NEW |