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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBoxTest.cpp

Issue 2068723002: Paint local attachment backgrounds into composited scrolling contents layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 years, 4 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/layout/LayoutBoxTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBoxTest.cpp b/third_party/WebKit/Source/core/layout/LayoutBoxTest.cpp
index e89af5b107787ae323f747ebc74f500f58fcfcd8..b9e0594fea9ce6443fe887d85c683c5804e638e8 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBoxTest.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBoxTest.cpp
@@ -24,4 +24,47 @@ TEST_F(LayoutBoxTest, BackgroundObscuredInRect)
ASSERT_TRUE(layoutObject->backgroundIsKnownToBeObscured());
}
+TEST_F(LayoutBoxTest, BackgroundRect)
+{
+ setBodyInnerHTML("<style>div { position: absolute; width: 100px; height: 100px; padding: 10px; border: 10px solid black; overflow: scroll; }"
+ "#target1 { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUg) border-box, green content-box;}"
+ "#target2 { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUg) content-box, green local border-box;}"
+ "#target3 { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUg) content-box, rgba(0, 255, 0, 0.5) border-box;}"
+ "#target4 { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUg) content-box, green border-box multiply;}"
trchen 2016/08/17 01:22:55 The shorthand form doesn't seem to support backgro
+ "#target5 { background: none border-box, green content-box;}"
+ "</style>"
+ "<div id='target1'></div>"
+ "<div id='target2'></div>"
+ "<div id='target3'></div>"
+ "<div id='target4'></div>"
+ "<div id='target5'></div>");
+
+ // #target1's opaque background color only fills the content box but its translucent image extends to the borders.
+ LayoutBox* layoutBox = toLayoutBox(getLayoutObjectByElementId("target1"));
+ EXPECT_EQ(LayoutRect(20, 20, 100, 100), layoutBox->backgroundRect(BackgroundKnownOpaqueRect));
+ EXPECT_EQ(LayoutRect(0, 0, 140, 140), layoutBox->backgroundRect(BackgroundClipRect));
+
+ // #target2's background color is opaque but only fills the padding-box because it has local attachment.
+ // This eclipses the content-box image.
+ layoutBox = toLayoutBox(getLayoutObjectByElementId("target2"));
+ EXPECT_EQ(LayoutRect(10, 10, 120, 120), layoutBox->backgroundRect(BackgroundKnownOpaqueRect));
+ EXPECT_EQ(LayoutRect(10, 10, 120, 120), layoutBox->backgroundRect(BackgroundClipRect));
+
+ // #target3's background color is not opaque so we only have a clip rect.
+ layoutBox = toLayoutBox(getLayoutObjectByElementId("target3"));
+ EXPECT_TRUE(layoutBox->backgroundRect(BackgroundKnownOpaqueRect).isEmpty());
+ EXPECT_EQ(LayoutRect(0, 0, 140, 140), layoutBox->backgroundRect(BackgroundClipRect));
+
+ // #target4's background color has a blend mode so it isn't opaque.
trchen 2016/08/17 01:22:55 Note: CSS backgrounds always create an isolated gr
+ layoutBox = toLayoutBox(getLayoutObjectByElementId("target4"));
+ EXPECT_TRUE(layoutBox->backgroundRect(BackgroundKnownOpaqueRect).isEmpty());
+ EXPECT_EQ(LayoutRect(0, 0, 140, 140), layoutBox->backgroundRect(BackgroundClipRect));
+
+ // #target5's solid background only covers the content-box but it has a "none" background
+ // covering the border box.
+ layoutBox = toLayoutBox(getLayoutObjectByElementId("target5"));
+ EXPECT_EQ(LayoutRect(20, 20, 100, 100), layoutBox->backgroundRect(BackgroundKnownOpaqueRect));
+ EXPECT_EQ(LayoutRect(0, 0, 140, 140), layoutBox->backgroundRect(BackgroundClipRect));
trchen 2016/08/17 01:22:55 This is surprising to me. I think it relies on the
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698