| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/RuleFeature.h" | 5 #include "core/css/RuleFeature.h" |
| 6 | 6 |
| 7 #include "core/css/CSSSelectorList.h" | 7 #include "core/css/CSSSelectorList.h" |
| 8 #include "core/css/RuleSet.h" | 8 #include "core/css/RuleSet.h" |
| 9 #include "core/css/StylePropertySet.h" | 9 #include "core/css/StylePropertySet.h" |
| 10 #include "core/css/StyleRule.h" | 10 #include "core/css/StyleRule.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 class RuleFeatureSetTest : public ::testing::Test { | 22 class RuleFeatureSetTest : public ::testing::Test { |
| 23 public: | 23 public: |
| 24 RuleFeatureSetTest() | 24 RuleFeatureSetTest() |
| 25 { | 25 { |
| 26 } | 26 } |
| 27 | 27 |
| 28 void SetUp() | 28 void SetUp() |
| 29 { | 29 { |
| 30 m_document = HTMLDocument::create(); | 30 m_document = HTMLDocument::create(); |
| 31 RawPtr<HTMLHtmlElement> html = HTMLHtmlElement::create(*m_document); | 31 HTMLHtmlElement* html = HTMLHtmlElement::create(*m_document); |
| 32 html->appendChild(HTMLBodyElement::create(*m_document)); | 32 html->appendChild(HTMLBodyElement::create(*m_document)); |
| 33 m_document->appendChild(html.release()); | 33 m_document->appendChild(html); |
| 34 | 34 |
| 35 m_document->body()->setInnerHTML("<b><i></i></b>", ASSERT_NO_EXCEPTION); | 35 m_document->body()->setInnerHTML("<b><i></i></b>", ASSERT_NO_EXCEPTION); |
| 36 } | 36 } |
| 37 | 37 |
| 38 RuleFeatureSet::SelectorPreMatch collectFeatures(const String& selectorText) | 38 RuleFeatureSet::SelectorPreMatch collectFeatures(const String& selectorText) |
| 39 { | 39 { |
| 40 CSSSelectorList selectorList = CSSParser::parseSelector(strictCSSParserC
ontext(), nullptr, selectorText); | 40 CSSSelectorList selectorList = CSSParser::parseSelector(strictCSSParserC
ontext(), nullptr, selectorText); |
| 41 | 41 |
| 42 RawPtr<StyleRule> styleRule = StyleRule::create(std::move(selectorList),
MutableStylePropertySet::create(HTMLStandardMode)); | 42 StyleRule* styleRule = StyleRule::create(std::move(selectorList), Mutabl
eStylePropertySet::create(HTMLStandardMode)); |
| 43 RuleData ruleData(styleRule.get(), 0, 0, RuleHasNoSpecialState); | 43 RuleData ruleData(styleRule, 0, 0, RuleHasNoSpecialState); |
| 44 return m_ruleFeatureSet.collectFeaturesFromRuleData(ruleData); | 44 return m_ruleFeatureSet.collectFeaturesFromRuleData(ruleData); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void collectInvalidationSetsForClass(InvalidationLists& invalidationLists, c
onst AtomicString& className) const | 47 void collectInvalidationSetsForClass(InvalidationLists& invalidationLists, c
onst AtomicString& className) const |
| 48 { | 48 { |
| 49 Element* element = Traversal<HTMLElement>::firstChild(*Traversal<HTMLEle
ment>::firstChild(*m_document->body())); | 49 Element* element = Traversal<HTMLElement>::firstChild(*Traversal<HTMLEle
ment>::firstChild(*m_document->body())); |
| 50 m_ruleFeatureSet.collectInvalidationSetsForClass(invalidationLists, *ele
ment, className); | 50 m_ruleFeatureSet.collectInvalidationSetsForClass(invalidationLists, *ele
ment, className); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void collectInvalidationSetsForId(InvalidationLists& invalidationLists, cons
t AtomicString& id) const | 53 void collectInvalidationSetsForId(InvalidationLists& invalidationLists, cons
t AtomicString& id) const |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 expectUncommonAttributeRuleCount(1); | 527 expectUncommonAttributeRuleCount(1); |
| 528 } | 528 } |
| 529 | 529 |
| 530 TEST_F(RuleFeatureSetTest, uncommonAttributeRulesAfterHostContextBeforePseudo) | 530 TEST_F(RuleFeatureSetTest, uncommonAttributeRulesAfterHostContextBeforePseudo) |
| 531 { | 531 { |
| 532 EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":host-context([
attr])::before")); | 532 EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":host-context([
attr])::before")); |
| 533 expectUncommonAttributeRuleCount(1); | 533 expectUncommonAttributeRuleCount(1); |
| 534 } | 534 } |
| 535 | 535 |
| 536 } // namespace blink | 536 } // namespace blink |
| OLD | NEW |