| 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/ActiveStyleSheets.h" | 5 #include "core/css/ActiveStyleSheets.h" |
| 6 | 6 |
| 7 #include "core/css/CSSStyleSheet.h" | 7 #include "core/css/CSSStyleSheet.h" |
| 8 #include "core/css/MediaQueryEvaluator.h" | 8 #include "core/css/MediaQueryEvaluator.h" |
| 9 #include "core/css/StyleSheetContents.h" | 9 #include "core/css/StyleSheetContents.h" |
| 10 #include "core/css/StyleSheetList.h" |
| 10 #include "core/css/parser/CSSParserMode.h" | 11 #include "core/css/parser/CSSParserMode.h" |
| 12 #include "core/dom/StyleEngine.h" |
| 11 #include "core/dom/shadow/ShadowRoot.h" | 13 #include "core/dom/shadow/ShadowRoot.h" |
| 12 #include "core/dom/shadow/ShadowRootInit.h" | 14 #include "core/dom/shadow/ShadowRootInit.h" |
| 13 #include "core/frame/FrameView.h" | 15 #include "core/frame/FrameView.h" |
| 14 #include "core/html/HTMLElement.h" | 16 #include "core/html/HTMLElement.h" |
| 15 #include "core/testing/DummyPageHolder.h" | 17 #include "core/testing/DummyPageHolder.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 19 |
| 18 namespace blink { | 20 namespace blink { |
| 19 | 21 |
| 20 class ActiveStyleSheetsTest : public ::testing::Test { | 22 class ActiveStyleSheetsTest : public ::testing::Test { |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 398 |
| 397 ActiveStyleSheetVector newStyleSheets; | 399 ActiveStyleSheetVector newStyleSheets; |
| 398 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); | 400 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); |
| 399 | 401 |
| 400 applyRuleSetChanges(styleEngine(), shadowRoot, ActiveStyleSheetVector(), | 402 applyRuleSetChanges(styleEngine(), shadowRoot, ActiveStyleSheetVector(), |
| 401 newStyleSheets); | 403 newStyleSheets); |
| 402 | 404 |
| 403 EXPECT_FALSE(document().needsLayoutTreeUpdate()); | 405 EXPECT_FALSE(document().needsLayoutTreeUpdate()); |
| 404 } | 406 } |
| 405 | 407 |
| 408 TEST_F(ApplyRulesetsTest, RemoveSheetFromShadowTree) { |
| 409 document().body()->setInnerHTML("<div id=host></div>", ASSERT_NO_EXCEPTION); |
| 410 Element* host = document().getElementById("host"); |
| 411 ASSERT_TRUE(host); |
| 412 |
| 413 ShadowRoot& shadowRoot = attachShadow(*host); |
| 414 shadowRoot.setInnerHTML("<style>::slotted(#dummy){color:pink}</style>", |
| 415 ASSERT_NO_EXCEPTION); |
| 416 document().view()->updateAllLifecyclePhases(); |
| 417 |
| 418 EXPECT_EQ(1u, styleEngine().treeBoundaryCrossingScopes().size()); |
| 419 ASSERT_EQ(1u, shadowRoot.styleSheets().length()); |
| 420 |
| 421 StyleSheet* sheet = shadowRoot.styleSheets().item(0); |
| 422 ASSERT_TRUE(sheet); |
| 423 ASSERT_TRUE(sheet->isCSSStyleSheet()); |
| 424 |
| 425 CSSStyleSheet* cssSheet = toCSSStyleSheet(sheet); |
| 426 ActiveStyleSheetVector oldStyleSheets; |
| 427 oldStyleSheets.append( |
| 428 std::make_pair(cssSheet, &cssSheet->contents()->ruleSet())); |
| 429 applyRuleSetChanges(styleEngine(), shadowRoot, oldStyleSheets, |
| 430 ActiveStyleSheetVector()); |
| 431 |
| 432 EXPECT_TRUE(styleEngine().treeBoundaryCrossingScopes().isEmpty()); |
| 433 } |
| 434 |
| 406 } // namespace blink | 435 } // namespace blink |
| OLD | NEW |