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

Unified Diff: third_party/WebKit/Source/core/dom/DocumentTest.cpp

Issue 2825343003: Clean compositing inputs for location APIs for sticky-affected elements. (Closed)
Patch Set: Rebase 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/dom/Element.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/DocumentTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/DocumentTest.cpp b/third_party/WebKit/Source/core/dom/DocumentTest.cpp
index c79b959aa029ba666b3cc04033426a54c150dbec..9240fb505bf53ae15f9b6c5e43252a3836ce05de 100644
--- a/third_party/WebKit/Source/core/dom/DocumentTest.cpp
+++ b/third_party/WebKit/Source/core/dom/DocumentTest.cpp
@@ -797,4 +797,49 @@ TEST_F(DocumentTest, SuboriginDisablesAppCache) {
EXPECT_TRUE(mock_web_host->without_manifest_was_called_);
}
+// Verifies that calling EnsurePaintLocationDataValidForNode cleans compositor
+// inputs only when necessary. We generally want to avoid cleaning the inputs,
+// as it is more expensive than just doing layout.
+TEST_F(DocumentTest,
+ EnsurePaintLocationDataValidForNodeCompositingInputsOnlyWhenNecessary) {
+ GetDocument().body()->setInnerHTML(
+ "<div id='ancestor'>"
+ " <div id='sticky' style='position:sticky;'>"
+ " <div id='stickyChild'></div>"
+ " </div>"
+ " <div id='nonSticky'></div>"
+ "</div>");
+ EXPECT_EQ(DocumentLifecycle::kStyleClean,
+ GetDocument().Lifecycle().GetState());
+
+ // Asking for any element that is not affected by a sticky element should only
+ // advance the lifecycle to layout clean.
+ GetDocument().EnsurePaintLocationDataValidForNode(
+ GetDocument().getElementById("ancestor"));
+ EXPECT_EQ(DocumentLifecycle::kLayoutClean,
+ GetDocument().Lifecycle().GetState());
+
+ GetDocument().EnsurePaintLocationDataValidForNode(
+ GetDocument().getElementById("nonSticky"));
+ EXPECT_EQ(DocumentLifecycle::kLayoutClean,
+ GetDocument().Lifecycle().GetState());
+
+ // However, asking for either the sticky element or it's descendents should
+ // clean compositing inputs as well.
+ GetDocument().EnsurePaintLocationDataValidForNode(
+ GetDocument().getElementById("sticky"));
+ EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
+ GetDocument().Lifecycle().GetState());
+
+ // Dirty layout.
+ GetDocument().body()->setAttribute("style", "background: red;");
+ EXPECT_EQ(DocumentLifecycle::kVisualUpdatePending,
+ GetDocument().Lifecycle().GetState());
+
+ GetDocument().EnsurePaintLocationDataValidForNode(
+ GetDocument().getElementById("stickyChild"));
+ EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
+ GetDocument().Lifecycle().GetState());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698