| 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 void updateInvalidationSets(const String& selectorText) | 38 void updateInvalidationSets(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 m_ruleFeatureSet.updateInvalidationSets(ruleData); | 44 m_ruleFeatureSet.updateInvalidationSets(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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 DEFINE_INLINE_TRACE() | 173 DEFINE_INLINE_TRACE() |
| 174 { | 174 { |
| 175 #if ENABLE(OILPAN) | 175 #if ENABLE(OILPAN) |
| 176 visitor->trace(m_ruleFeatureSet); | 176 visitor->trace(m_ruleFeatureSet); |
| 177 visitor->trace(m_document); | 177 visitor->trace(m_document); |
| 178 #endif | 178 #endif |
| 179 } | 179 } |
| 180 | 180 |
| 181 private: | 181 private: |
| 182 RuleFeatureSet m_ruleFeatureSet; | 182 RuleFeatureSet m_ruleFeatureSet; |
| 183 RefPtrWillBePersistent<Document> m_document; | 183 Persistent<Document> m_document; |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 TEST_F(RuleFeatureSetTest, interleavedDescendantSibling1) | 186 TEST_F(RuleFeatureSetTest, interleavedDescendantSibling1) |
| 187 { | 187 { |
| 188 updateInvalidationSets(".p"); | 188 updateInvalidationSets(".p"); |
| 189 | 189 |
| 190 InvalidationLists invalidationLists; | 190 InvalidationLists invalidationLists; |
| 191 collectInvalidationSetsForClass(invalidationLists, "p"); | 191 collectInvalidationSetsForClass(invalidationLists, "p"); |
| 192 expectSelfInvalidation(invalidationLists.descendants); | 192 expectSelfInvalidation(invalidationLists.descendants); |
| 193 expectNoInvalidation(invalidationLists.siblings); | 193 expectNoInvalidation(invalidationLists.siblings); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 expectClassInvalidation("c", invalidationLists.descendants); | 331 expectClassInvalidation("c", invalidationLists.descendants); |
| 332 | 332 |
| 333 updateInvalidationSets(".a .b"); | 333 updateInvalidationSets(".a .b"); |
| 334 | 334 |
| 335 invalidationLists.descendants.clear(); | 335 invalidationLists.descendants.clear(); |
| 336 collectInvalidationSetsForClass(invalidationLists, "a"); | 336 collectInvalidationSetsForClass(invalidationLists, "a"); |
| 337 expectClassesInvalidation("b", "c", invalidationLists.descendants); | 337 expectClassesInvalidation("b", "c", invalidationLists.descendants); |
| 338 } | 338 } |
| 339 | 339 |
| 340 } // namespace blink | 340 } // namespace blink |
| OLD | NEW |