| 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 RefPtrWillBeRawPtr<HTMLHtmlElement> html = HTMLHtmlElement::create(*m_do
cument); | 31 RawPtr<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.release()); |
| 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 RefPtrWillBeRawPtr<StyleRule> styleRule = StyleRule::create(std::move(se
lectorList), MutableStylePropertySet::create(HTMLStandardMode)); | 42 RawPtr<StyleRule> styleRule = StyleRule::create(std::move(selectorList),
MutableStylePropertySet::create(HTMLStandardMode)); |
| 43 RuleData ruleData(styleRule.get(), 0, 0, RuleHasNoSpecialState); | 43 RuleData ruleData(styleRule.get(), 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 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 DEFINE_INLINE_TRACE() | 183 DEFINE_INLINE_TRACE() |
| 184 { | 184 { |
| 185 #if ENABLE(OILPAN) | 185 #if ENABLE(OILPAN) |
| 186 visitor->trace(m_ruleFeatureSet); | 186 visitor->trace(m_ruleFeatureSet); |
| 187 visitor->trace(m_document); | 187 visitor->trace(m_document); |
| 188 #endif | 188 #endif |
| 189 } | 189 } |
| 190 | 190 |
| 191 private: | 191 private: |
| 192 RuleFeatureSet m_ruleFeatureSet; | 192 RuleFeatureSet m_ruleFeatureSet; |
| 193 RefPtrWillBePersistent<Document> m_document; | 193 Persistent<Document> m_document; |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 TEST_F(RuleFeatureSetTest, interleavedDescendantSibling1) | 196 TEST_F(RuleFeatureSetTest, interleavedDescendantSibling1) |
| 197 { | 197 { |
| 198 EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".p")); | 198 EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".p")); |
| 199 | 199 |
| 200 InvalidationLists invalidationLists; | 200 InvalidationLists invalidationLists; |
| 201 collectInvalidationSetsForClass(invalidationLists, "p"); | 201 collectInvalidationSetsForClass(invalidationLists, "p"); |
| 202 expectSelfInvalidation(invalidationLists.descendants); | 202 expectSelfInvalidation(invalidationLists.descendants); |
| 203 expectNoInvalidation(invalidationLists.siblings); | 203 expectNoInvalidation(invalidationLists.siblings); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 expectUncommonAttributeRuleCount(1); | 529 expectUncommonAttributeRuleCount(1); |
| 530 } | 530 } |
| 531 | 531 |
| 532 TEST_F(RuleFeatureSetTest, uncommonAttributeRulesAfterHostContextBeforePseudo) | 532 TEST_F(RuleFeatureSetTest, uncommonAttributeRulesAfterHostContextBeforePseudo) |
| 533 { | 533 { |
| 534 EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":host-context([
attr])::before")); | 534 EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":host-context([
attr])::before")); |
| 535 expectUncommonAttributeRuleCount(1); | 535 expectUncommonAttributeRuleCount(1); |
| 536 } | 536 } |
| 537 | 537 |
| 538 } // namespace blink | 538 } // namespace blink |
| OLD | NEW |