| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/resolver/SharedStyleFinder.h" | 5 #include "core/css/resolver/SharedStyleFinder.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 #include "bindings/core/v8/V8Binding.h" |
| 7 #include "core/css/RuleFeature.h" | 9 #include "core/css/RuleFeature.h" |
| 8 #include "core/css/RuleSet.h" | 10 #include "core/css/RuleSet.h" |
| 9 #include "core/css/parser/CSSParser.h" | 11 #include "core/css/parser/CSSParser.h" |
| 10 #include "core/css/parser/CSSParserContext.h" | 12 #include "core/css/parser/CSSParserContext.h" |
| 11 #include "core/dom/Document.h" | 13 #include "core/dom/Document.h" |
| 12 #include "core/dom/shadow/ShadowRoot.h" | 14 #include "core/dom/shadow/ShadowRoot.h" |
| 13 #include "core/dom/shadow/ShadowRootInit.h" | 15 #include "core/dom/shadow/ShadowRootInit.h" |
| 14 #include "core/frame/FrameView.h" | 16 #include "core/frame/FrameView.h" |
| 15 #include "core/html/HTMLElement.h" | 17 #include "core/html/HTMLElement.h" |
| 16 #include "core/testing/DummyPageHolder.h" | 18 #include "core/testing/DummyPageHolder.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include <memory> | |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 class SharedStyleFinderTest : public ::testing::Test { | 23 class SharedStyleFinderTest : public ::testing::Test { |
| 23 protected: | 24 protected: |
| 24 SharedStyleFinderTest() = default; | 25 SharedStyleFinderTest() = default; |
| 25 ~SharedStyleFinderTest() override = default; | 26 ~SharedStyleFinderTest() override = default; |
| 26 | 27 |
| 27 Document& document() { return m_dummyPageHolder->document(); } | 28 Document& document() { return m_dummyPageHolder->document(); } |
| 28 | 29 |
| 29 void setBodyContent(const String& html) { | 30 void setBodyContent(const String& html) { |
| 30 document().body()->setInnerHTML(html); | 31 document().body()->setInnerHTML(html); |
| 31 document().view()->updateAllLifecyclePhases(); | 32 document().view()->updateAllLifecyclePhases(); |
| 32 } | 33 } |
| 33 | 34 |
| 34 ShadowRoot& attachShadow(Element& host) { | 35 ShadowRoot& attachShadow(Element& host) { |
| 35 ShadowRootInit init; | 36 ShadowRootInit init; |
| 36 init.setMode("open"); | 37 init.setMode("open"); |
| 37 ShadowRoot* shadowRoot = | 38 ShadowRoot* shadowRoot = |
| 38 host.attachShadow(ScriptState::forMainWorld(document().frame()), init, | 39 host.attachShadow(toScriptStateForMainWorld(document().frame()), init, |
| 39 ASSERT_NO_EXCEPTION); | 40 ASSERT_NO_EXCEPTION); |
| 40 EXPECT_TRUE(shadowRoot); | 41 EXPECT_TRUE(shadowRoot); |
| 41 return *shadowRoot; | 42 return *shadowRoot; |
| 42 } | 43 } |
| 43 | 44 |
| 44 void addSelector(const String& selector) { | 45 void addSelector(const String& selector) { |
| 45 StyleRuleBase* newRule = | 46 StyleRuleBase* newRule = |
| 46 CSSParser::parseRule(CSSParserContext::create(HTMLStandardMode), | 47 CSSParser::parseRule(CSSParserContext::create(HTMLStandardMode), |
| 47 nullptr, selector + "{color:pink}"); | 48 nullptr, selector + "{color:pink}"); |
| 48 m_ruleSet->addStyleRule(static_cast<StyleRule*>(newRule), | 49 m_ruleSet->addStyleRule(static_cast<StyleRule*>(newRule), |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 Element* b = document().getElementById("b"); | 209 Element* b = document().getElementById("b"); |
| 209 | 210 |
| 210 EXPECT_TRUE(a->assignedSlot()); | 211 EXPECT_TRUE(a->assignedSlot()); |
| 211 EXPECT_TRUE(b->assignedSlot()); | 212 EXPECT_TRUE(b->assignedSlot()); |
| 212 | 213 |
| 213 EXPECT_FALSE(matchesUncommonAttributeRuleSet(*a)); | 214 EXPECT_FALSE(matchesUncommonAttributeRuleSet(*a)); |
| 214 EXPECT_TRUE(matchesUncommonAttributeRuleSet(*b)); | 215 EXPECT_TRUE(matchesUncommonAttributeRuleSet(*b)); |
| 215 } | 216 } |
| 216 | 217 |
| 217 } // namespace blink | 218 } // namespace blink |
| OLD | NEW |