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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp b/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
index d6979b2c8da494b263afc2928dbcbfbce2a69cec..1a427519e28259852bfe01db1cc5734f097b53bd 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
@@ -574,4 +574,62 @@ TEST_F(StyleEngineTest, EmptyHttpEquivDefaultStyle) {
EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
}
+TEST_F(StyleEngineTest, StyleSheetsForStyleSheetList_Document) {
+ GetDocument().body()->setInnerHTML("<style>span { color: green }</style>");
+ EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
+
+ const auto& sheet_list =
+ GetStyleEngine().StyleSheetsForStyleSheetList(GetDocument());
+ EXPECT_EQ(1u, sheet_list.size());
+ EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
+
+ GetDocument().body()->setInnerHTML(
+ "<style>span { color: green }</style><style>div { color: pink }</style>");
+ EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
+
+ const auto& second_sheet_list =
+ GetStyleEngine().StyleSheetsForStyleSheetList(GetDocument());
+ EXPECT_EQ(2u, second_sheet_list.size());
+ EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
+
+ GetStyleEngine().MarkAllTreeScopesDirty();
+ GetStyleEngine().StyleSheetsForStyleSheetList(GetDocument());
+ EXPECT_FALSE(GetStyleEngine().NeedsActiveStyleUpdate());
+}
+
+TEST_F(StyleEngineTest, StyleSheetsForStyleSheetList_ShadowRoot) {
+ GetDocument().body()->setInnerHTML("<div id='host'></div>");
+ Element* host = GetDocument().getElementById("host");
+ ASSERT_TRUE(host);
+
+ GetDocument().View()->UpdateAllLifecyclePhases();
+ ShadowRootInit init;
+ init.setMode("open");
+ ShadowRoot* shadow_root =
+ host->attachShadow(ToScriptStateForMainWorld(GetDocument().GetFrame()),
+ init, ASSERT_NO_EXCEPTION);
+ ASSERT_TRUE(shadow_root);
+
+ shadow_root->setInnerHTML("<style>span { color: green }</style>");
+ EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
+
+ const auto& sheet_list =
+ GetStyleEngine().StyleSheetsForStyleSheetList(*shadow_root);
+ EXPECT_EQ(1u, sheet_list.size());
+ EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
+
+ shadow_root->setInnerHTML(
+ "<style>span { color: green }</style><style>div { color: pink }</style>");
+ EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
+
+ const auto& second_sheet_list =
+ GetStyleEngine().StyleSheetsForStyleSheetList(*shadow_root);
+ EXPECT_EQ(2u, second_sheet_list.size());
+ EXPECT_TRUE(GetStyleEngine().NeedsActiveStyleUpdate());
+
+ GetStyleEngine().MarkAllTreeScopesDirty();
+ GetStyleEngine().StyleSheetsForStyleSheetList(*shadow_root);
+ EXPECT_FALSE(GetStyleEngine().NeedsActiveStyleUpdate());
+}
+
} // namespace blink
« 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