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

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: Add intermediate sticky in StickySubtreesAreTrackedCorrectly test 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/DocumentTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/DocumentTest.cpp b/third_party/WebKit/Source/core/dom/DocumentTest.cpp
index c79b959aa029ba666b3cc04033426a54c150dbec..3edf8ca902d6d13f9cde4b8172776a40b871aedd 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