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, *context_, has_arguments); | 445 selector->UpdatePseudoType(value, 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 context_->IsDynamicProfile() ? CSSSelector::kShadowDeepAsDescendant | 585 return CSSSelector::kShadowDeep; |
586 : CSSSelector::kShadowDeep; | |
587 } | 586 } |
588 | 587 |
589 default: | 588 default: |
590 break; | 589 break; |
591 } | 590 } |
592 return fallback_result; | 591 return fallback_result; |
593 } | 592 } |
594 | 593 |
595 CSSSelector::MatchType CSSSelectorParser::ConsumeAttributeMatch( | 594 CSSSelector::MatchType CSSSelectorParser::ConsumeAttributeMatch( |
596 CSSParserTokenRange& range) { | 595 CSSParserTokenRange& range) { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 } | 903 } |
905 if (current->Relation() == CSSSelector::kIndirectAdjacent) | 904 if (current->Relation() == CSSSelector::kIndirectAdjacent) |
906 context_->Count(UseCounter::kCSSSelectorIndirectAdjacent); | 905 context_->Count(UseCounter::kCSSSelectorIndirectAdjacent); |
907 if (current->SelectorList()) | 906 if (current->SelectorList()) |
908 RecordUsageAndDeprecations(*current->SelectorList()); | 907 RecordUsageAndDeprecations(*current->SelectorList()); |
909 } | 908 } |
910 } | 909 } |
911 } | 910 } |
912 | 911 |
913 } // namespace blink | 912 } // namespace blink |
OLD | NEW |