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

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: Rename EnsureLifecycleValidForLocationAPIsForNode Created 3 years, 8 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/DocumentTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/DocumentTest.cpp b/third_party/WebKit/Source/core/dom/DocumentTest.cpp
index 43b0c0164ea6e3174bbf897cbac0461f2d0d91e5..33cb5239d6a27ff8035e96c568558bed3540bbec 100644
--- a/third_party/WebKit/Source/core/dom/DocumentTest.cpp
+++ b/third_party/WebKit/Source/core/dom/DocumentTest.cpp
@@ -797,4 +797,50 @@ TEST_F(DocumentTest, SuboriginDisablesAppCache) {
EXPECT_TRUE(mock_web_host->without_manifest_was_called_);
}
+// Verifies that calling EnsureAuxiliaryLocationDataValidForNode cleans
+// compositor inputs only when necessary. We generally want to avoid cleaning
+// the compositing inputs, as it is more expensive than just doing layout.
+TEST_F(
+ DocumentTest,
+ EnsureAuxiliaryLocationDataValidForNodeCompositingInputsOnlyWhenNecessary) {
+ 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().EnsureAuxiliaryLocationDataValidForNode(
+ GetDocument().getElementById("ancestor"));
+ EXPECT_EQ(DocumentLifecycle::kLayoutClean,
+ GetDocument().Lifecycle().GetState());
+
+ GetDocument().EnsureAuxiliaryLocationDataValidForNode(
+ 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().EnsureAuxiliaryLocationDataValidForNode(
+ 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().EnsureAuxiliaryLocationDataValidForNode(
+ GetDocument().getElementById("stickyChild"));
+ EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
+ GetDocument().Lifecycle().GetState());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698