Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/WebKit/Source/core/dom/StyleEngineTest.cpp

Issue 2884993002: Don't trigger full active style update on styleSheets access. (Closed)
Patch Set: Not clearing document_scope_dirty_ flag in import styleSheets anymore. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/dom/StyleEngine.h" 5 #include "core/dom/StyleEngine.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/V8BindingForCore.h" 8 #include "bindings/core/v8/V8BindingForCore.h"
9 #include "core/css/CSSRuleList.h" 9 #include "core/css/CSSRuleList.h"
10 #include "core/css/CSSStyleRule.h" 10 #include "core/css/CSSStyleRule.h"
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 Element* container = GetDocument().getElementById("container"); 567 Element* container = GetDocument().getElementById("container");
568 ASSERT_TRUE(container); 568 ASSERT_TRUE(container);
569 container->setInnerHTML("<meta http-equiv='default-style' content=''>"); 569 container->setInnerHTML("<meta http-equiv='default-style' content=''>");
570 EXPECT_FALSE(GetStyleEngine().NeedsActiveStyleUpdate()); 570 EXPECT_FALSE(GetStyleEngine().NeedsActiveStyleUpdate());
571 571
572 container->setInnerHTML( 572 container->setInnerHTML(
573 "<meta http-equiv='default-style' content='preferred'>"); 573 "<meta http-equiv='default-style' content='preferred'>");
574 EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate()); 574 EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
575 } 575 }
576 576
577 TEST_F(StyleEngineTest, StyleSheetsForStyleSheetList_Document) {
578 GetDocument().body()->setInnerHTML("<style>span { color: green }</style>");
579 EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
580
581 const auto& sheet_list =
582 GetStyleEngine().StyleSheetsForStyleSheetList(GetDocument());
583 EXPECT_EQ(1u, sheet_list.size());
584 EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
585
586 GetDocument().body()->setInnerHTML(
587 "<style>span { color: green }</style><style>div { color: pink }</style>");
588 EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
589
590 const auto& second_sheet_list =
591 GetStyleEngine().StyleSheetsForStyleSheetList(GetDocument());
592 EXPECT_EQ(2u, second_sheet_list.size());
593 EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
594
595 GetStyleEngine().MarkAllTreeScopesDirty();
596 GetStyleEngine().StyleSheetsForStyleSheetList(GetDocument());
597 EXPECT_FALSE(GetStyleEngine().NeedsActiveStyleUpdate());
598 }
599
600 TEST_F(StyleEngineTest, StyleSheetsForStyleSheetList_ShadowRoot) {
601 GetDocument().body()->setInnerHTML("<div id='host'></div>");
602 Element* host = GetDocument().getElementById("host");
603 ASSERT_TRUE(host);
604
605 GetDocument().View()->UpdateAllLifecyclePhases();
606 ShadowRootInit init;
607 init.setMode("open");
608 ShadowRoot* shadow_root =
609 host->attachShadow(ToScriptStateForMainWorld(GetDocument().GetFrame()),
610 init, ASSERT_NO_EXCEPTION);
611 ASSERT_TRUE(shadow_root);
612
613 shadow_root->setInnerHTML("<style>span { color: green }</style>");
614 EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
615
616 const auto& sheet_list =
617 GetStyleEngine().StyleSheetsForStyleSheetList(*shadow_root);
618 EXPECT_EQ(1u, sheet_list.size());
619 EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
620
621 shadow_root->setInnerHTML(
622 "<style>span { color: green }</style><style>div { color: pink }</style>");
623 EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
624
625 const auto& second_sheet_list =
626 GetStyleEngine().StyleSheetsForStyleSheetList(*shadow_root);
627 EXPECT_EQ(2u, second_sheet_list.size());
628 EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
629
630 GetStyleEngine().MarkAllTreeScopesDirty();
631 GetStyleEngine().StyleSheetsForStyleSheetList(*shadow_root);
632 EXPECT_FALSE(GetStyleEngine().NeedsActiveStyleUpdate());
633 }
634
577 } // namespace blink 635 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.cpp ('k') | third_party/WebKit/Source/core/dom/StyleSheetCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698