| 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/StyleSheetList.h" |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 395 |
| 396 CSSStyleSheet* sheet = | 396 CSSStyleSheet* sheet = |
| 397 createSheet("@font-face { font-family: ahum; src: url(ahum.ttf) }"); | 397 createSheet("@font-face { font-family: ahum; src: url(ahum.ttf) }"); |
| 398 | 398 |
| 399 ActiveStyleSheetVector newStyleSheets; | 399 ActiveStyleSheetVector newStyleSheets; |
| 400 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); | 400 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); |
| 401 | 401 |
| 402 styleEngine().applyRuleSetChanges(shadowRoot, ActiveStyleSheetVector(), | 402 styleEngine().applyRuleSetChanges(shadowRoot, ActiveStyleSheetVector(), |
| 403 newStyleSheets); | 403 newStyleSheets); |
| 404 | 404 |
| 405 EXPECT_FALSE(document().needsLayoutTreeUpdate()); | 405 EXPECT_FALSE(document().needsStyleRecalc()); |
| 406 EXPECT_FALSE(document().childNeedsStyleRecalc()); |
| 407 EXPECT_FALSE(document().needsStyleInvalidation()); |
| 408 EXPECT_FALSE(document().childNeedsStyleInvalidation()); |
| 406 } | 409 } |
| 407 | 410 |
| 408 TEST_F(ApplyRulesetsTest, RemoveSheetFromShadowTree) { | 411 TEST_F(ApplyRulesetsTest, RemoveSheetFromShadowTree) { |
| 409 document().body()->setInnerHTML("<div id=host></div>"); | 412 document().body()->setInnerHTML("<div id=host></div>"); |
| 410 Element* host = document().getElementById("host"); | 413 Element* host = document().getElementById("host"); |
| 411 ASSERT_TRUE(host); | 414 ASSERT_TRUE(host); |
| 412 | 415 |
| 413 ShadowRoot& shadowRoot = attachShadow(*host); | 416 ShadowRoot& shadowRoot = attachShadow(*host); |
| 414 shadowRoot.setInnerHTML("<style>::slotted(#dummy){color:pink}</style>"); | 417 shadowRoot.setInnerHTML("<style>::slotted(#dummy){color:pink}</style>"); |
| 415 document().view()->updateAllLifecyclePhases(); | 418 document().view()->updateAllLifecyclePhases(); |
| 416 | 419 |
| 417 EXPECT_EQ(1u, styleEngine().treeBoundaryCrossingScopes().size()); | 420 EXPECT_EQ(1u, styleEngine().treeBoundaryCrossingScopes().size()); |
| 418 ASSERT_EQ(1u, shadowRoot.styleSheets().length()); | 421 ASSERT_EQ(1u, shadowRoot.styleSheets().length()); |
| 419 | 422 |
| 420 StyleSheet* sheet = shadowRoot.styleSheets().item(0); | 423 StyleSheet* sheet = shadowRoot.styleSheets().item(0); |
| 421 ASSERT_TRUE(sheet); | 424 ASSERT_TRUE(sheet); |
| 422 ASSERT_TRUE(sheet->isCSSStyleSheet()); | 425 ASSERT_TRUE(sheet->isCSSStyleSheet()); |
| 423 | 426 |
| 424 CSSStyleSheet* cssSheet = toCSSStyleSheet(sheet); | 427 CSSStyleSheet* cssSheet = toCSSStyleSheet(sheet); |
| 425 ActiveStyleSheetVector oldStyleSheets; | 428 ActiveStyleSheetVector oldStyleSheets; |
| 426 oldStyleSheets.append( | 429 oldStyleSheets.append( |
| 427 std::make_pair(cssSheet, &cssSheet->contents()->ruleSet())); | 430 std::make_pair(cssSheet, &cssSheet->contents()->ruleSet())); |
| 428 styleEngine().applyRuleSetChanges(shadowRoot, oldStyleSheets, | 431 styleEngine().applyRuleSetChanges(shadowRoot, oldStyleSheets, |
| 429 ActiveStyleSheetVector()); | 432 ActiveStyleSheetVector()); |
| 430 | 433 |
| 431 EXPECT_TRUE(styleEngine().treeBoundaryCrossingScopes().isEmpty()); | 434 EXPECT_TRUE(styleEngine().treeBoundaryCrossingScopes().isEmpty()); |
| 432 } | 435 } |
| 433 | 436 |
| 434 } // namespace blink | 437 } // namespace blink |
| OLD | NEW |