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

Unified Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp

Issue 2584653002: Force subtree paint property updates on local border box changes (Closed)
Patch Set: fix bugs Created 4 years 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/paint/PaintPropertyTreeBuilderTest.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
index c5b5f979fe69e30528d669d964492e8869bcf052..bc8c7417b3371b349ccb416d4148488888764847 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
@@ -3231,4 +3231,96 @@ TEST_P(PaintPropertyTreeBuilderTest, NoPaintPropertyUpdateOnBackgroundChange) {
EXPECT_FALSE(div->layoutObject()->needsPaintPropertyUpdate());
}
+TEST_P(PaintPropertyTreeBuilderTest, AbsoluteLocalBorderBoxChanges) {
+ setBodyInnerHTML(
+ "<style>"
+ " body { margin: 0 }"
+ " #scroller { width: 3px; height: 5px; overflow: scroll; }"
+ " #child { top: 0; left: 0; }"
+ "</style>"
+ "<div id='scroller'>"
+ " <div id='child'>"
+ " <div id='grandChild'></div>"
+ " </div>"
+ " <div style='height: 100px;'></div>"
+ "</div>");
+ document().view()->updateAllLifecyclePhases();
+ auto* scroller = document().getElementById("scroller");
+ auto* scrollerProperties = scroller->layoutObject()->paintProperties();
+ auto* child = document().getElementById("child");
+ auto* childProperties = child->layoutObject()->paintProperties();
+ auto* childLocalBorderBox = childProperties->localBorderBoxProperties();
+ EXPECT_EQ(childLocalBorderBox->propertyTreeState.scroll(),
+ scrollerProperties->scroll());
+ EXPECT_EQ(LayoutPoint(0, 0), childLocalBorderBox->paintOffset);
+ auto* grandChild = document().getElementById("grandChild");
+ auto* grandChildProperties = grandChild->layoutObject()->paintProperties();
+ auto* grandChildLocalBorderBox =
+ grandChildProperties->localBorderBoxProperties();
+ EXPECT_EQ(LayoutPoint(0, 0), grandChildLocalBorderBox->paintOffset);
+ EXPECT_EQ(
+ FloatRect(0, 0, 3, 5),
+ grandChildLocalBorderBox->propertyTreeState.clip()->clipRect().rect());
+
+ // Update the scroller's transform value but ensure the child's paint offset
+ // is unchanged so subtree updates are not forced by paint offset changes.
+ scroller->setScrollTop(7);
+ child->setAttribute(HTMLNames::styleAttr, "position: absolute");
+ document().view()->updateAllLifecyclePhases();
+ EXPECT_EQ(LayoutPoint(0, 0), childLocalBorderBox->paintOffset);
+ EXPECT_EQ(LayoutPoint(0, 0), grandChildLocalBorderBox->paintOffset);
+ EXPECT_NE(childLocalBorderBox->propertyTreeState.scroll(),
+ scrollerProperties->scroll());
+ EXPECT_TRUE(childLocalBorderBox->propertyTreeState.scroll()->isRoot());
+ EXPECT_EQ(
+ FloatRect(0, 0, 800, 600),
+ grandChildLocalBorderBox->propertyTreeState.clip()->clipRect().rect());
+}
+
+TEST_P(PaintPropertyTreeBuilderTest, FixedLocalBorderBoxChanges) {
+ setBodyInnerHTML(
+ "<style>"
+ " body { margin: 0 }"
+ " #scroller { width: 3px; height: 5px; overflow: scroll; }"
+ " #child { top: 0; left: 0; }"
+ "</style>"
+ "<div id='scroller'>"
+ " <div id='child'>"
+ " <div id='grandChild'></div>"
+ " </div>"
+ " <div style='height: 100px;'></div>"
+ "</div>");
+ document().view()->updateAllLifecyclePhases();
+ auto* scroller = document().getElementById("scroller");
+ auto* scrollerProperties = scroller->layoutObject()->paintProperties();
+ auto* child = document().getElementById("child");
+ auto* childProperties = child->layoutObject()->paintProperties();
+ auto* childLocalBorderBox = childProperties->localBorderBoxProperties();
+ EXPECT_EQ(childLocalBorderBox->propertyTreeState.scroll(),
+ scrollerProperties->scroll());
+ EXPECT_EQ(LayoutPoint(0, 0), childLocalBorderBox->paintOffset);
+ auto* grandChild = document().getElementById("grandChild");
+ auto* grandChildProperties = grandChild->layoutObject()->paintProperties();
+ auto* grandChildLocalBorderBox =
+ grandChildProperties->localBorderBoxProperties();
+ EXPECT_EQ(LayoutPoint(0, 0), grandChildLocalBorderBox->paintOffset);
+ EXPECT_EQ(
+ FloatRect(0, 0, 3, 5),
+ grandChildLocalBorderBox->propertyTreeState.clip()->clipRect().rect());
+
+ // Update the scroller's transform value but ensure the child's paint offset
+ // is unchanged so subtree updates are not forced by paint offset changes.
+ scroller->setScrollTop(7);
+ child->setAttribute(HTMLNames::styleAttr, "position: fixed");
+ document().view()->updateAllLifecyclePhases();
+ EXPECT_EQ(LayoutPoint(0, 0), childLocalBorderBox->paintOffset);
+ EXPECT_EQ(LayoutPoint(0, 0), grandChildLocalBorderBox->paintOffset);
+ EXPECT_NE(childLocalBorderBox->propertyTreeState.scroll(),
+ scrollerProperties->scroll());
+ EXPECT_TRUE(childLocalBorderBox->propertyTreeState.scroll()->isRoot());
+ EXPECT_EQ(
+ FloatRect(0, 0, 800, 600),
+ grandChildLocalBorderBox->propertyTreeState.clip()->clipRect().rect());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698