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

Side by Side 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: Merge allLayersAreLocal and ComputedStyle::hasEntirelyLocalBackground 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/LayoutBox.h" 5 #include "core/layout/LayoutBox.h"
6 6
7 #include "core/html/HTMLElement.h" 7 #include "core/html/HTMLElement.h"
8 #include "core/layout/ImageQualityController.h" 8 #include "core/layout/ImageQualityController.h"
9 #include "core/layout/LayoutTestHelper.h" 9 #include "core/layout/LayoutTestHelper.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class LayoutBoxTest : public RenderingTest { 14 class LayoutBoxTest : public RenderingTest {
15 }; 15 };
16 16
17 TEST_F(LayoutBoxTest, BackgroundObscuredInRect) 17 TEST_F(LayoutBoxTest, BackgroundObscuredInRect)
18 { 18 {
19 setBodyInnerHTML("<style>.column { width: 295.4px; padding-left: 10.4px; } . white-background { background: red; position: relative; overflow: hidden; border -radius: 1px; }" 19 setBodyInnerHTML("<style>.column { width: 295.4px; padding-left: 10.4px; } . white-background { background: red; position: relative; overflow: hidden; border -radius: 1px; }"
20 ".black-background { height: 100px; background: black; color: white; } < /style>" 20 ".black-background { height: 100px; background: black; color: white; } < /style>"
21 "<div class='column'> <div> <div id='target' class='white-background'> < div class='black-background'></div> </div> </div> </div>"); 21 "<div class='column'> <div> <div id='target' class='white-background'> < div class='black-background'></div> </div> </div> </div>");
22 LayoutObject* layoutObject = getLayoutObjectByElementId("target"); 22 LayoutObject* layoutObject = getLayoutObjectByElementId("target");
23 ASSERT_TRUE(layoutObject); 23 ASSERT_TRUE(layoutObject);
24 ASSERT_TRUE(layoutObject->backgroundIsKnownToBeObscured()); 24 ASSERT_TRUE(layoutObject->backgroundIsKnownToBeObscured());
25 } 25 }
26 26
27 TEST_F(LayoutBoxTest, BackgroundRect)
28 {
29 setBodyInnerHTML("<style>div { position: absolute; width: 100px; height: 100 px; padding: 10px; border: 10px solid black; overflow: scroll; }"
30 "#target1 { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUg ) border-box, green content-box;}"
31 "#target2 { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUg ) content-box, green local border-box;}"
32 "#target3 { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUg ) content-box, rgba(0, 255, 0, 0.5) border-box;}"
33 "#target4 { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUg ) content-box, green border-box multiply;}"
trchen 2016/08/19 22:49:14 The shorthand form doesn't support background-blen
flackr 2016/08/22 15:12:39 Done.
34 "#target5 { background: none border-box, green content-box;}"
35 "#target6 { background: green content-box local; }"
36 "</style>"
37 "<div id='target1'></div>"
38 "<div id='target2'></div>"
39 "<div id='target3'></div>"
40 "<div id='target4'></div>"
41 "<div id='target5'></div>"
42 "<div id='target6'></div>");
43
44 // #target1's opaque background color only fills the content box but its tra nslucent image extends to the borders.
45 LayoutBox* layoutBox = toLayoutBox(getLayoutObjectByElementId("target1"));
46 EXPECT_EQ(LayoutRect(20, 20, 100, 100), layoutBox->backgroundRect(Background KnownOpaqueRect));
47 EXPECT_EQ(LayoutRect(0, 0, 140, 140), layoutBox->backgroundRect(BackgroundCl ipRect));
48
49 // #target2's background color is opaque but only fills the padding-box beca use it has local attachment.
50 // This eclipses the content-box image.
51 layoutBox = toLayoutBox(getLayoutObjectByElementId("target2"));
52 EXPECT_EQ(LayoutRect(10, 10, 120, 120), layoutBox->backgroundRect(Background KnownOpaqueRect));
53 EXPECT_EQ(LayoutRect(10, 10, 120, 120), layoutBox->backgroundRect(Background ClipRect));
54
55 // #target3's background color is not opaque so we only have a clip rect.
56 layoutBox = toLayoutBox(getLayoutObjectByElementId("target3"));
57 EXPECT_TRUE(layoutBox->backgroundRect(BackgroundKnownOpaqueRect).isEmpty());
58 EXPECT_EQ(LayoutRect(0, 0, 140, 140), layoutBox->backgroundRect(BackgroundCl ipRect));
59
60 // #target4's background color has a blend mode so it isn't opaque.
61 layoutBox = toLayoutBox(getLayoutObjectByElementId("target4"));
62 EXPECT_TRUE(layoutBox->backgroundRect(BackgroundKnownOpaqueRect).isEmpty());
63 EXPECT_EQ(LayoutRect(0, 0, 140, 140), layoutBox->backgroundRect(BackgroundCl ipRect));
64
65 // #target5's solid background only covers the content-box but it has a "non e" background
66 // covering the border box.
67 layoutBox = toLayoutBox(getLayoutObjectByElementId("target5"));
68 EXPECT_EQ(LayoutRect(20, 20, 100, 100), layoutBox->backgroundRect(Background KnownOpaqueRect));
69 EXPECT_EQ(LayoutRect(0, 0, 140, 140), layoutBox->backgroundRect(BackgroundCl ipRect));
70
71 // Because it can scroll due to local attachment, the opaque local backgroun d in #target6
72 // is treated as padding box for the clip rect, but remains the content box for the known
73 // opaque rect.
74 layoutBox = toLayoutBox(getLayoutObjectByElementId("target6"));
75 EXPECT_EQ(LayoutRect(20, 20, 100, 100), layoutBox->backgroundRect(Background KnownOpaqueRect));
76 EXPECT_EQ(LayoutRect(10, 10, 120, 120), layoutBox->backgroundRect(Background ClipRect));
77 }
78
27 } // namespace blink 79 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698