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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp

Issue 2244873002: Fix PaintPropertyTreeBuilder for root layer scrolling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@rls-enable
Patch Set: Disabled exact geometry checks when RLS is enabled 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/LayoutTestHelper.h" 5 #include "core/layout/LayoutTestHelper.h"
6 #include "core/layout/LayoutTreeAsText.h" 6 #include "core/layout/LayoutTreeAsText.h"
7 #include "core/layout/api/LayoutViewItem.h" 7 #include "core/layout/api/LayoutViewItem.h"
8 #include "core/paint/ObjectPaintProperties.h" 8 #include "core/paint/ObjectPaintProperties.h"
9 #include "platform/graphics/paint/GeometryMapper.h" 9 #include "platform/graphics/paint/GeometryMapper.h"
10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
11 #include "platform/testing/UnitTestHelpers.h" 11 #include "platform/testing/UnitTestHelpers.h"
12 #include "platform/text/TextStream.h" 12 #include "platform/text/TextStream.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "wtf/HashMap.h" 14 #include "wtf/HashMap.h"
15 #include "wtf/Vector.h" 15 #include "wtf/Vector.h"
16 16
17 namespace blink { 17 namespace blink {
pdr. 2016/08/17 04:30:41 This patch fails about 900 new LayoutTests when ru
pdr. 2016/08/17 06:35:43 I debugged the first issue down a bit. Because we'
18 18
19 class PaintPropertyTreeBuilderTest : public RenderingTest { 19 class PaintPropertyTreeBuilderTest
20 : public RenderingTest
21 , public ::testing::WithParamInterface<FrameSettingOverrideFunction> {
pdr. 2016/08/17 04:30:41 This approach of reusing the existing tests and ad
20 public: 22 public:
21 PaintPropertyTreeBuilderTest() 23 PaintPropertyTreeBuilderTest()
22 : RenderingTest(SingleChildFrameLoaderClient::create()) 24 : RenderingTest(SingleChildFrameLoaderClient::create())
23 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { } 25 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { }
24 26
25 void loadTestData(const char* fileName) 27 void loadTestData(const char* fileName)
26 { 28 {
27 String fullPath = testing::blinkRootDir(); 29 String fullPath = testing::blinkRootDir();
28 fullPath.append("/Source/core/paint/test_data/"); 30 fullPath.append("/Source/core/paint/test_data/");
29 fullPath.append(fileName); 31 fullPath.append(fileName);
30 RefPtr<SharedBuffer> inputBuffer = testing::readFromFile(fullPath); 32 RefPtr<SharedBuffer> inputBuffer = testing::readFromFile(fullPath);
31 setBodyInnerHTML(String(inputBuffer->data(), inputBuffer->size())); 33 setBodyInnerHTML(String(inputBuffer->data(), inputBuffer->size()));
32 } 34 }
33 35
36 bool rootLayerScrolls()
37 {
38 return document().settings() && document().settings()->rootLayerScrolls( );
39 }
40
41 const TransformPaintPropertyNode* rootTransform()
42 {
43 FrameView* frameView = document().view();
44 if (rootLayerScrolls())
45 return frameView->layoutView()->objectPaintProperties()->paintOffset Translation();
46 return frameView->rootTransform();
47 }
48
49 const ClipPaintPropertyNode* rootClip()
50 {
51 return rootLayerScrolls() ? nullptr : document().view()->rootClip();
52 }
53
54 const TransformPaintPropertyNode* framePreTranslation()
55 {
56 FrameView* frameView = document().view();
57 if (rootLayerScrolls())
58 return frameView->layoutView()->objectPaintProperties()->paintOffset Translation();
59 return frameView->preTranslation();
60 }
61
62 const TransformPaintPropertyNode* frameScrollTranslation()
63 {
64 FrameView* frameView = document().view();
65 if (rootLayerScrolls())
66 return frameView->layoutView()->objectPaintProperties()->scrollTrans lation();
67 return frameView->scrollTranslation();
68 }
69
70 const ClipPaintPropertyNode* frameContentClip()
71 {
72 FrameView* frameView = document().view();
73 if (rootLayerScrolls())
74 return frameView->layoutView()->objectPaintProperties()->overflowCli p();
75 return frameView->contentClip();
76 }
77
78 FrameSettingOverrideFunction settingOverrider() const override { return GetP aram(); }
79
34 private: 80 private:
35 void SetUp() override 81 void SetUp() override
36 { 82 {
37 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 83 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
38 Settings::setMockScrollbarsEnabled(true); 84 Settings::setMockScrollbarsEnabled(true);
39 85
40 RenderingTest::SetUp(); 86 RenderingTest::SetUp();
41 enableCompositing(); 87 enableCompositing();
42 } 88 }
43 89
(...skipping 22 matching lines...) Expand all
66 \ 112 \
67 LayoutRect expected = sourceLayoutObject->localOverflowRectForPaintInvalidat ion(); \ 113 LayoutRect expected = sourceLayoutObject->localOverflowRectForPaintInvalidat ion(); \
68 sourceLayoutObject->mapToVisualRectInAncestorSpace(ancestorLayoutObject, exp ected); \ 114 sourceLayoutObject->mapToVisualRectInAncestorSpace(ancestorLayoutObject, exp ected); \
69 EXPECT_TRUE(expected.contains(LayoutRect(actual))); \ 115 EXPECT_TRUE(expected.contains(LayoutRect(actual))); \
70 actual.inflate(slopFactor); \ 116 actual.inflate(slopFactor); \
71 EXPECT_TRUE(LayoutRect(actual).contains(expected)); \ 117 EXPECT_TRUE(LayoutRect(actual).contains(expected)); \
72 } while (0); 118 } while (0);
73 119
74 #define CHECK_EXACT_VISUAL_RECT(sourceLayoutObject, ancestorLayoutObject) CHECK_ VISUAL_RECT(sourceLayoutObject, ancestorLayoutObject, 0) 120 #define CHECK_EXACT_VISUAL_RECT(sourceLayoutObject, ancestorLayoutObject) CHECK_ VISUAL_RECT(sourceLayoutObject, ancestorLayoutObject, 0)
75 121
76 TEST_F(PaintPropertyTreeBuilderTest, FixedPosition) 122 INSTANTIATE_TEST_CASE_P(All, PaintPropertyTreeBuilderTest, ::testing::Values(nul lptr, &RootLayerScrollsFrameSettingOverride));
123
124 TEST_P(PaintPropertyTreeBuilderTest, FixedPosition)
77 { 125 {
78 loadTestData("fixed-position.html"); 126 loadTestData("fixed-position.html");
79 127
80 FrameView* frameView = document().view(); 128 FrameView* frameView = document().view();
81 129
82 // target1 is a fixed-position element inside an absolute-position scrolling element. 130 // target1 is a fixed-position element inside an absolute-position scrolling element.
83 // It should be attached under the viewport to skip scrolling and offset of the parent. 131 // It should be attached under the viewport to skip scrolling and offset of the parent.
84 Element* target1 = document().getElementById("target1"); 132 Element* target1 = document().getElementById("target1");
85 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob jectPaintProperties(); 133 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob jectPaintProperties();
86 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai ntOffsetTranslation()->matrix()); 134 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai ntOffsetTranslation()->matrix());
87 EXPECT_EQ(frameView->preTranslation(), target1Properties->paintOffsetTransla tion()->parent()); 135 EXPECT_EQ(framePreTranslation(), target1Properties->paintOffsetTranslation() ->parent());
88 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov erflowClip()->localTransformSpace()); 136 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov erflowClip()->localTransformSpace());
89 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip( )->clipRect()); 137 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip( )->clipRect());
90 // Likewise, it inherits clip from the viewport, skipping overflow clip of t he scroller. 138 // Likewise, it inherits clip from the viewport, skipping overflow clip of t he scroller.
91 EXPECT_EQ(frameView->contentClip(), target1Properties->overflowClip()->paren t()); 139 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent());
92 CHECK_EXACT_VISUAL_RECT(target1->layoutObject(), frameView->layoutView()); 140 CHECK_EXACT_VISUAL_RECT(target1->layoutObject(), frameView->layoutView());
93 141
94 // target2 is a fixed-position element inside a transformed scrolling elemen t. 142 // target2 is a fixed-position element inside a transformed scrolling elemen t.
95 // It should be attached under the scrolled box of the transformed element. 143 // It should be attached under the scrolled box of the transformed element.
96 Element* target2 = document().getElementById("target2"); 144 Element* target2 = document().getElementById("target2");
97 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob jectPaintProperties(); 145 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob jectPaintProperties();
98 Element* scroller = document().getElementById("scroller"); 146 Element* scroller = document().getElementById("scroller");
99 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties(); 147 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties();
100 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai ntOffsetTranslation()->matrix()); 148 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai ntOffsetTranslation()->matrix());
101 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO ffsetTranslation()->parent()); 149 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO ffsetTranslation()->parent());
102 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov erflowClip()->localTransformSpace()); 150 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov erflowClip()->localTransformSpace());
103 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip( )->clipRect()); 151 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip( )->clipRect());
104 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli p()->parent()); 152 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli p()->parent());
105 CHECK_EXACT_VISUAL_RECT(target2->layoutObject(), frameView->layoutView()); 153 CHECK_EXACT_VISUAL_RECT(target2->layoutObject(), frameView->layoutView());
106 } 154 }
107 155
108 TEST_F(PaintPropertyTreeBuilderTest, PositionAndScroll) 156 TEST_P(PaintPropertyTreeBuilderTest, PositionAndScroll)
109 { 157 {
110 loadTestData("position-and-scroll.html"); 158 loadTestData("position-and-scroll.html");
111 159
112 Element* scroller = document().getElementById("scroller"); 160 Element* scroller = document().getElementById("scroller");
113 scroller->scrollTo(0, 100); 161 scroller->scrollTo(0, 100);
114 FrameView* frameView = document().view(); 162 FrameView* frameView = document().view();
115 frameView->updateAllLifecyclePhases(); 163 frameView->updateAllLifecyclePhases();
116 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties(); 164 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties();
117 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr ollTranslation()->matrix()); 165 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr ollTranslation()->matrix());
118 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat ion()->parent()); 166 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->scrollTranslation()- >parent());
119 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->overflowClip() ->localTransformSpace()); 167 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->overflowClip()->loca lTransformSpace());
120 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow Clip()->clipRect()); 168 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow Clip()->clipRect());
121 EXPECT_EQ(frameView->contentClip(), scrollerProperties->overflowClip()->pare nt()); 169 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent());
122 CHECK_EXACT_VISUAL_RECT(scroller->layoutObject(), frameView->layoutView()); 170 // http://crbug.com/638415
171 if (!rootLayerScrolls()) {
172 CHECK_EXACT_VISUAL_RECT(scroller->layoutObject(), frameView->layoutView( ));
173 }
123 174
124 // The relative-positioned element should have accumulated box offset (exclu de scrolling), 175 // The relative-positioned element should have accumulated box offset (exclu de scrolling),
125 // and should be affected by ancestor scroll transforms. 176 // and should be affected by ancestor scroll transforms.
126 Element* relPos = document().getElementById("rel-pos"); 177 Element* relPos = document().getElementById("rel-pos");
127 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje ctPaintProperties(); 178 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje ctPaintProperties();
128 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai ntOffsetTranslation()->matrix()); 179 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai ntOffsetTranslation()->matrix());
129 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf fsetTranslation()->parent()); 180 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf fsetTranslation()->parent());
130 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l ocalTransformSpace()); 181 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l ocalTransformSpace());
131 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), relPosProperties->overflowClip() ->clipRect()); 182 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), relPosProperties->overflowClip() ->clipRect());
132 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip ()->parent()); 183 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip ()->parent());
133 CHECK_EXACT_VISUAL_RECT(relPos->layoutObject(), frameView->layoutView()); 184 CHECK_EXACT_VISUAL_RECT(relPos->layoutObject(), frameView->layoutView());
134 185
135 // The absolute-positioned element should not be affected by non-positioned scroller at all. 186 // The absolute-positioned element should not be affected by non-positioned scroller at all.
136 Element* absPos = document().getElementById("abs-pos"); 187 Element* absPos = document().getElementById("abs-pos");
137 const ObjectPaintProperties* absPosProperties = absPos->layoutObject()->obje ctPaintProperties(); 188 const ObjectPaintProperties* absPosProperties = absPos->layoutObject()->obje ctPaintProperties();
138 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain tOffsetTranslation()->matrix()); 189 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain tOffsetTranslation()->matrix());
139 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans lation()->parent()); 190 EXPECT_EQ(frameScrollTranslation(), absPosProperties->paintOffsetTranslation ()->parent());
140 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l ocalTransformSpace()); 191 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l ocalTransformSpace());
141 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), absPosProperties->overflowClip() ->clipRect()); 192 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), absPosProperties->overflowClip() ->clipRect());
142 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent ()); 193 EXPECT_EQ(frameContentClip(), absPosProperties->overflowClip()->parent());
143 CHECK_EXACT_VISUAL_RECT(absPos->layoutObject(), frameView->layoutView()); 194 // http://crbug.com/638415
195 if (!rootLayerScrolls()) {
196 CHECK_EXACT_VISUAL_RECT(absPos->layoutObject(), frameView->layoutView()) ;
197 }
144 } 198 }
145 199
146 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) 200 TEST_P(PaintPropertyTreeBuilderTest, FrameScrollingTraditional)
147 { 201 {
148 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); 202 setBodyInnerHTML("<style> body { height: 10000px; } </style>");
149 203
150 document().domWindow()->scrollTo(0, 100); 204 document().domWindow()->scrollTo(0, 100);
151 205
152 FrameView* frameView = document().view(); 206 FrameView* frameView = document().view();
153 frameView->updateAllLifecyclePhases(); 207 frameView->updateAllLifecyclePhases();
154 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); 208 EXPECT_EQ(TransformationMatrix(), framePreTranslation()->matrix());
155 EXPECT_EQ(frameView->rootTransform(), frameView->preTranslation()->parent()) ; 209 if (!rootLayerScrolls())
156 EXPECT_EQ(nullptr, frameView->rootTransform()->parent()); 210 EXPECT_EQ(rootTransform(), framePreTranslation()->parent());
157 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl ation()->matrix()); 211 EXPECT_EQ(nullptr, rootTransform()->parent());
158 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t()); 212 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameScrollTranslation( )->matrix());
159 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf ormSpace()); 213 EXPECT_EQ(framePreTranslation(), frameScrollTranslation()->parent());
160 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe ct()); 214 EXPECT_EQ(framePreTranslation(), frameContentClip()->localTransformSpace());
161 EXPECT_EQ(frameView->rootClip(), frameView->contentClip()->parent()); 215 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect());
162 EXPECT_EQ(nullptr, frameView->rootClip()->parent()); 216 EXPECT_EQ(rootClip(), frameContentClip()->parent());
217 if (!rootLayerScrolls())
218 EXPECT_EQ(nullptr, rootClip()->parent());
163 219
164 LayoutViewItem layoutViewItem = document().layoutViewItem(); 220 LayoutViewItem layoutViewItem = document().layoutViewItem();
165 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai ntProperties(); 221 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai ntProperties();
166 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); 222 if (!rootLayerScrolls()) {
167 CHECK_EXACT_VISUAL_RECT(document().body()->layoutObject(), frameView->layout View()); 223 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation());
224 // http://crbug.com/638415
225 CHECK_EXACT_VISUAL_RECT(document().body()->layoutObject(), frameView->la youtView());
226 }
168 } 227 }
169 228
170 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame being created. 229 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame being created.
171 // Need to set it during test setup. Besides that, the test still won't work bec ause 230 // Need to set it during test setup. Besides that, the test still won't work bec ause
172 // root layer scrolling mode is not compatible with SPv2 at this moment. 231 // root layer scrolling mode is not compatible with SPv2 at this moment.
173 // (Duplicate display item ID for FrameView and LayoutView.) 232 // (Duplicate display item ID for FrameView and LayoutView.)
174 TEST_F(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls) 233 TEST_P(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls)
pdr. 2016/08/17 04:30:41 Can you remove DISABLED_ from this test? I think i
pdr. 2016/08/17 06:35:43 Err, delete this.
175 { 234 {
176 document().settings()->setRootLayerScrolls(true);
177
178 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); 235 setBodyInnerHTML("<style> body { height: 10000px; } </style>");
179 236
180 document().domWindow()->scrollTo(0, 100); 237 document().domWindow()->scrollTo(0, 100);
181 238
182 FrameView* frameView = document().view(); 239 FrameView* frameView = document().view();
183 frameView->updateAllLifecyclePhases(); 240 frameView->updateAllLifecyclePhases();
184 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); 241 EXPECT_EQ(TransformationMatrix(), framePreTranslation()->matrix());
185 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); 242 EXPECT_EQ(nullptr, framePreTranslation()->parent());
186 EXPECT_EQ(TransformationMatrix(), frameView->scrollTranslation()->matrix()); 243 EXPECT_EQ(TransformationMatrix(), frameScrollTranslation()->matrix());
187 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t()); 244 EXPECT_EQ(framePreTranslation(), frameScrollTranslation()->parent());
188 245
189 LayoutViewItem layoutViewItem = document().layoutViewItem(); 246 LayoutViewItem layoutViewItem = document().layoutViewItem();
190 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai ntProperties(); 247 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai ntProperties();
191 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s crollTranslation()->matrix()); 248 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s crollTranslation()->matrix());
192 EXPECT_EQ(frameView->scrollTranslation(), layoutViewProperties->scrollTransl ation()->parent()); 249 EXPECT_EQ(frameScrollTranslation(), layoutViewProperties->scrollTranslation( )->parent());
193 CHECK_EXACT_VISUAL_RECT(document().body()->layoutObject(), frameView->layout View()); 250 CHECK_EXACT_VISUAL_RECT(document().body()->layoutObject(), frameView->layout View());
194 } 251 }
195 252
196 TEST_F(PaintPropertyTreeBuilderTest, Perspective) 253 TEST_P(PaintPropertyTreeBuilderTest, Perspective)
197 { 254 {
198 loadTestData("perspective.html"); 255 loadTestData("perspective.html");
199 256
200 Element* perspective = document().getElementById("perspective"); 257 Element* perspective = document().getElementById("perspective");
201 const ObjectPaintProperties* perspectiveProperties = perspective->layoutObje ct()->objectPaintProperties(); 258 const ObjectPaintProperties* perspectiveProperties = perspective->layoutObje ct()->objectPaintProperties();
202 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie s->perspective()->matrix()); 259 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie s->perspective()->matrix());
203 // The perspective origin is the center of the border box plus accumulated p aint offset. 260 // The perspective origin is the center of the border box plus accumulated p aint offset.
204 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o rigin()); 261 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o rigin());
205 EXPECT_EQ(document().view()->scrollTranslation(), perspectiveProperties->per spective()->parent()); 262 EXPECT_EQ(frameScrollTranslation(), perspectiveProperties->perspective()->pa rent());
206 263
207 // Adding perspective doesn't clear paint offset. The paint offset will be p assed down to children. 264 // Adding perspective doesn't clear paint offset. The paint offset will be p assed down to children.
208 Element* inner = document().getElementById("inner"); 265 Element* inner = document().getElementById("inner");
209 const ObjectPaintProperties* innerProperties = inner->layoutObject()->object PaintProperties(); 266 const ObjectPaintProperties* innerProperties = inner->layoutObject()->object PaintProperties();
210 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO ffsetTranslation()->matrix()); 267 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO ffsetTranslation()->matrix());
211 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset Translation()->parent()); 268 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset Translation()->parent());
212 CHECK_EXACT_VISUAL_RECT(inner->layoutObject(), document().view()->layoutView ()); 269 CHECK_EXACT_VISUAL_RECT(inner->layoutObject(), document().view()->layoutView ());
213 } 270 }
214 271
215 TEST_F(PaintPropertyTreeBuilderTest, Transform) 272 TEST_P(PaintPropertyTreeBuilderTest, Transform)
216 { 273 {
217 loadTestData("transform.html"); 274 loadTestData("transform.html");
218 275
219 Element* transform = document().getElementById("transform"); 276 Element* transform = document().getElementById("transform");
220 const ObjectPaintProperties* transformProperties = transform->layoutObject() ->objectPaintProperties(); 277 const ObjectPaintProperties* transformProperties = transform->layoutObject() ->objectPaintProperties();
221 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper ties->transform()->matrix()); 278 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper ties->transform()->matrix());
222 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi n()); 279 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi n());
223 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties ->transform()->parent()); 280 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties ->transform()->parent());
224 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa intOffsetTranslation()->matrix()); 281 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa intOffsetTranslation()->matrix());
225 EXPECT_EQ(document().view()->scrollTranslation(), transformProperties->paint OffsetTranslation()->parent()); 282 EXPECT_EQ(frameScrollTranslation(), transformProperties->paintOffsetTranslat ion()->parent());
226 CHECK_EXACT_VISUAL_RECT(transform->layoutObject(), document().view()->layout View()); 283 // http://crbug.com/638415
284 if (!rootLayerScrolls()) {
285 CHECK_EXACT_VISUAL_RECT(transform->layoutObject(), document().view()->la youtView());
286 }
227 } 287 }
228 288
229 TEST_F(PaintPropertyTreeBuilderTest, RelativePositionInline) 289 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline)
230 { 290 {
231 loadTestData("relative-position-inline.html"); 291 loadTestData("relative-position-inline.html");
232 292
233 Element* inlineBlock = document().getElementById("inline-block"); 293 Element* inlineBlock = document().getElementById("inline-block");
234 const ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObje ct()->objectPaintProperties(); 294 const ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObje ct()->objectPaintProperties();
235 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties- >paintOffsetTranslation()->matrix()); 295 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties- >paintOffsetTranslation()->matrix());
236 EXPECT_EQ(document().view()->scrollTranslation(), inlineBlockProperties->pai ntOffsetTranslation()->parent()); 296 EXPECT_EQ(frameScrollTranslation(), inlineBlockProperties->paintOffsetTransl ation()->parent());
237 CHECK_EXACT_VISUAL_RECT(inlineBlock->layoutObject(), document().view()->layo utView()); 297 CHECK_EXACT_VISUAL_RECT(inlineBlock->layoutObject(), document().view()->layo utView());
238 } 298 }
239 299
240 TEST_F(PaintPropertyTreeBuilderTest, NestedOpacityEffect) 300 TEST_P(PaintPropertyTreeBuilderTest, NestedOpacityEffect)
241 { 301 {
242 setBodyInnerHTML( 302 setBodyInnerHTML(
243 "<div id='nodeWithoutOpacity' style='width: 100px; height: 200px'>" 303 "<div id='nodeWithoutOpacity' style='width: 100px; height: 200px'>"
244 " <div id='childWithOpacity' style='opacity: 0.5; width: 50px; height: 60px;'>" 304 " <div id='childWithOpacity' style='opacity: 0.5; width: 50px; height: 60px;'>"
245 " <div id='grandChildWithoutOpacity' style='width: 20px; height: 30px '>" 305 " <div id='grandChildWithoutOpacity' style='width: 20px; height: 30px '>"
246 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2; width: 10px; height: 15px'/>" 306 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2; width: 10px; height: 15px'/>"
247 " </div>" 307 " </div>"
248 " </div>" 308 " </div>"
249 "</div>"); 309 "</div>");
250 310
(...skipping 13 matching lines...) Expand all
264 EXPECT_NE(nullptr, grandChildWithoutOpacity->objectPaintProperties()); 324 EXPECT_NE(nullptr, grandChildWithoutOpacity->objectPaintProperties());
265 CHECK_EXACT_VISUAL_RECT(grandChildWithoutOpacity, document().view()->layoutV iew()); 325 CHECK_EXACT_VISUAL_RECT(grandChildWithoutOpacity, document().view()->layoutV iew());
266 326
267 LayoutObject* greatGrandChildWithOpacity = document().getElementById("greatG randChildWithOpacity")->layoutObject(); 327 LayoutObject* greatGrandChildWithOpacity = document().getElementById("greatG randChildWithOpacity")->layoutObject();
268 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGra ndChildWithOpacity->objectPaintProperties(); 328 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGra ndChildWithOpacity->objectPaintProperties();
269 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); 329 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity());
270 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr operties->effect()->parent()); 330 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr operties->effect()->parent());
271 CHECK_EXACT_VISUAL_RECT(greatGrandChildWithOpacity, document().view()->layou tView()); 331 CHECK_EXACT_VISUAL_RECT(greatGrandChildWithOpacity, document().view()->layou tView());
272 } 332 }
273 333
274 TEST_F(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) 334 TEST_P(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes)
275 { 335 {
276 setBodyInnerHTML( 336 setBodyInnerHTML(
277 "<div id='nodeWithOpacity' style='opacity: 0.6' style='width: 100px; hei ght: 200px'>" 337 "<div id='nodeWithOpacity' style='opacity: 0.6' style='width: 100px; hei ght: 200px'>"
278 " <div id='childWithTransform' style='transform: translate3d(10px, 10px , 0px); width: 50px; height: 60px;'>" 338 " <div id='childWithTransform' style='transform: translate3d(10px, 10px , 0px); width: 50px; height: 60px;'>"
279 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h eight: 30px'/>" 339 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h eight: 30px'/>"
280 " </div>" 340 " </div>"
281 "</div>"); 341 "</div>");
282 342
283 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity") ->layoutObject(); 343 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity") ->layoutObject();
284 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob jectPaintProperties(); 344 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob jectPaintProperties();
285 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); 345 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity());
286 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); 346 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent());
287 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); 347 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform());
288 CHECK_EXACT_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView()); 348 CHECK_EXACT_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView());
289 349
290 LayoutObject* childWithTransform = document().getElementById("childWithTrans form")->layoutObject(); 350 LayoutObject* childWithTransform = document().getElementById("childWithTrans form")->layoutObject();
291 const ObjectPaintProperties* childWithTransformProperties = childWithTransfo rm->objectPaintProperties(); 351 const ObjectPaintProperties* childWithTransformProperties = childWithTransfo rm->objectPaintProperties();
292 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); 352 EXPECT_EQ(nullptr, childWithTransformProperties->effect());
293 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper ties->transform()->matrix()); 353 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper ties->transform()->matrix());
294 CHECK_EXACT_VISUAL_RECT(childWithTransform, document().view()->layoutView()) ; 354 CHECK_EXACT_VISUAL_RECT(childWithTransform, document().view()->layoutView()) ;
295 355
296 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW ithOpacity")->layoutObject(); 356 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW ithOpacity")->layoutObject();
297 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit hOpacity->objectPaintProperties(); 357 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit hOpacity->objectPaintProperties();
298 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); 358 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity());
299 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent()); 359 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent());
300 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); 360 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform());
301 CHECK_EXACT_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView ()); 361 CHECK_EXACT_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView ());
302 } 362 }
303 363
304 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) 364 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext)
305 { 365 {
306 setBodyInnerHTML( 366 setBodyInnerHTML(
307 "<div id='nodeWithOpacity' style='opacity: 0.6; width: 100px; height: 20 0px'>" 367 "<div id='nodeWithOpacity' style='opacity: 0.6; width: 100px; height: 20 0px'>"
308 " <div id='childWithStackingContext' style='position:absolute; width: 5 0px; height: 60px;'>" 368 " <div id='childWithStackingContext' style='position:absolute; width: 5 0px; height: 60px;'>"
309 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h eight: 30px'/>" 369 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h eight: 30px'/>"
310 " </div>" 370 " </div>"
311 "</div>"); 371 "</div>");
312 372
313 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity") ->layoutObject(); 373 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity") ->layoutObject();
314 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob jectPaintProperties(); 374 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob jectPaintProperties();
315 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); 375 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity());
316 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); 376 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent());
317 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); 377 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform());
318 CHECK_EXACT_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView()); 378 CHECK_EXACT_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView());
319 379
320 LayoutObject* childWithStackingContext = document().getElementById("childWit hStackingContext")->layoutObject(); 380 LayoutObject* childWithStackingContext = document().getElementById("childWit hStackingContext")->layoutObject();
321 const ObjectPaintProperties* childWithStackingContextProperties = childWithS tackingContext->objectPaintProperties(); 381 const ObjectPaintProperties* childWithStackingContextProperties = childWithS tackingContext->objectPaintProperties();
322 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); 382 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect());
323 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); 383 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform());
324 CHECK_EXACT_VISUAL_RECT(childWithStackingContext, document().view()->layoutV iew()); 384 CHECK_EXACT_VISUAL_RECT(childWithStackingContext, document().view()->layoutV iew());
325 385
326 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW ithOpacity")->layoutObject(); 386 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW ithOpacity")->layoutObject();
327 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit hOpacity->objectPaintProperties(); 387 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit hOpacity->objectPaintProperties();
328 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); 388 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity());
329 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent()); 389 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent());
330 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); 390 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform());
331 CHECK_EXACT_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView ()); 391 CHECK_EXACT_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView ());
332 } 392 }
333 393
334 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG) 394 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesInSVG)
335 { 395 {
336 setBodyInnerHTML( 396 setBodyInnerHTML(
337 "<svg id='svgRoot'>" 397 "<svg id='svgRoot'>"
338 " <g id='groupWithOpacity' opacity='0.6'>" 398 " <g id='groupWithOpacity' opacity='0.6'>"
339 " <rect id='rectWithoutOpacity' />" 399 " <rect id='rectWithoutOpacity' />"
340 " <rect id='rectWithOpacity' opacity='0.4' />" 400 " <rect id='rectWithOpacity' opacity='0.4' />"
341 " <text id='textWithOpacity' opacity='0.2'>" 401 " <text id='textWithOpacity' opacity='0.2'>"
342 " <tspan id='tspanWithOpacity' opacity='0.1' />" 402 " <tspan id='tspanWithOpacity' opacity='0.1' />"
343 " </text>" 403 " </text>"
344 " </g>" 404 " </g>"
(...skipping 19 matching lines...) Expand all
364 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity()); 424 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity());
365 EXPECT_EQ(groupWithOpacityProperties->effect(), textWithOpacityProperties->e ffect()->parent()); 425 EXPECT_EQ(groupWithOpacityProperties->effect(), textWithOpacityProperties->e ffect()->parent());
366 426
367 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits f rom LayoutSVGInline instead of LayoutSVGModelObject. 427 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits f rom LayoutSVGInline instead of LayoutSVGModelObject.
368 LayoutObject& tspanWithOpacity = *document().getElementById("tspanWithOpacit y")->layoutObject(); 428 LayoutObject& tspanWithOpacity = *document().getElementById("tspanWithOpacit y")->layoutObject();
369 const ObjectPaintProperties* tspanWithOpacityProperties = tspanWithOpacity.o bjectPaintProperties(); 429 const ObjectPaintProperties* tspanWithOpacityProperties = tspanWithOpacity.o bjectPaintProperties();
370 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity()); 430 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity());
371 EXPECT_EQ(textWithOpacityProperties->effect(), tspanWithOpacityProperties->e ffect()->parent()); 431 EXPECT_EQ(textWithOpacityProperties->effect(), tspanWithOpacityProperties->e ffect()->parent());
372 } 432 }
373 433
374 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossHTMLSVGBoundary) 434 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossHTMLSVGBoundary)
375 { 435 {
376 setBodyInnerHTML( 436 setBodyInnerHTML(
377 "<div id='divWithOpacity' style='opacity: 0.2;'>" 437 "<div id='divWithOpacity' style='opacity: 0.2;'>"
378 " <svg id='svgRootWithOpacity' style='opacity: 0.3;'>" 438 " <svg id='svgRootWithOpacity' style='opacity: 0.3;'>"
379 " <rect id='rectWithOpacity' opacity='0.4' />" 439 " <rect id='rectWithOpacity' opacity='0.4' />"
380 " </svg>" 440 " </svg>"
381 "</div>"); 441 "</div>");
382 442
383 LayoutObject& divWithOpacity = *document().getElementById("divWithOpacity")- >layoutObject(); 443 LayoutObject& divWithOpacity = *document().getElementById("divWithOpacity")- >layoutObject();
384 const ObjectPaintProperties* divWithOpacityProperties = divWithOpacity.objec tPaintProperties(); 444 const ObjectPaintProperties* divWithOpacityProperties = divWithOpacity.objec tPaintProperties();
385 EXPECT_EQ(0.2f, divWithOpacityProperties->effect()->opacity()); 445 EXPECT_EQ(0.2f, divWithOpacityProperties->effect()->opacity());
386 EXPECT_NE(nullptr, divWithOpacityProperties->effect()->parent()); 446 EXPECT_NE(nullptr, divWithOpacityProperties->effect()->parent());
387 447
388 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp acity")->layoutObject(); 448 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp acity")->layoutObject();
389 const ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpaci ty.objectPaintProperties(); 449 const ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpaci ty.objectPaintProperties();
390 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); 450 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity());
391 EXPECT_EQ(divWithOpacityProperties->effect(), svgRootWithOpacityProperties-> effect()->parent()); 451 EXPECT_EQ(divWithOpacityProperties->effect(), svgRootWithOpacityProperties-> effect()->parent());
392 452
393 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity" )->layoutObject(); 453 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity" )->layoutObject();
394 const ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.obj ectPaintProperties(); 454 const ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.obj ectPaintProperties();
395 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); 455 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity());
396 EXPECT_EQ(svgRootWithOpacityProperties->effect(), rectWithOpacityProperties- >effect()->parent()); 456 EXPECT_EQ(svgRootWithOpacityProperties->effect(), rectWithOpacityProperties- >effect()->parent());
397 } 457 }
398 458
399 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossSVGHTMLBoundary) 459 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossSVGHTMLBoundary)
400 { 460 {
401 setBodyInnerHTML( 461 setBodyInnerHTML(
402 "<svg id='svgRootWithOpacity' style='opacity: 0.3;'>" 462 "<svg id='svgRootWithOpacity' style='opacity: 0.3;'>"
403 " <foreignObject id='foreignObjectWithOpacity' opacity='0.4'>" 463 " <foreignObject id='foreignObjectWithOpacity' opacity='0.4'>"
404 " <body>" 464 " <body>"
405 " <span id='spanWithOpacity' style='opacity: 0.5'/>" 465 " <span id='spanWithOpacity' style='opacity: 0.5'/>"
406 " </body>" 466 " </body>"
407 " </foreignObject>" 467 " </foreignObject>"
408 "</svg>"); 468 "</svg>");
409 469
410 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp acity")->layoutObject(); 470 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp acity")->layoutObject();
411 const ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpaci ty.objectPaintProperties(); 471 const ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpaci ty.objectPaintProperties();
412 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); 472 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity());
413 EXPECT_NE(nullptr, svgRootWithOpacityProperties->effect()->parent()); 473 EXPECT_NE(nullptr, svgRootWithOpacityProperties->effect()->parent());
414 474
415 LayoutObject& foreignObjectWithOpacity = *document().getElementById("foreign ObjectWithOpacity")->layoutObject(); 475 LayoutObject& foreignObjectWithOpacity = *document().getElementById("foreign ObjectWithOpacity")->layoutObject();
416 const ObjectPaintProperties* foreignObjectWithOpacityProperties = foreignObj ectWithOpacity.objectPaintProperties(); 476 const ObjectPaintProperties* foreignObjectWithOpacityProperties = foreignObj ectWithOpacity.objectPaintProperties();
417 EXPECT_EQ(0.4f, foreignObjectWithOpacityProperties->effect()->opacity()); 477 EXPECT_EQ(0.4f, foreignObjectWithOpacityProperties->effect()->opacity());
418 EXPECT_EQ(svgRootWithOpacityProperties->effect(), foreignObjectWithOpacityPr operties->effect()->parent()); 478 EXPECT_EQ(svgRootWithOpacityProperties->effect(), foreignObjectWithOpacityPr operties->effect()->parent());
419 479
420 LayoutObject& spanWithOpacity = *document().getElementById("spanWithOpacity" )->layoutObject(); 480 LayoutObject& spanWithOpacity = *document().getElementById("spanWithOpacity" )->layoutObject();
421 const ObjectPaintProperties* spanWithOpacityProperties = spanWithOpacity.obj ectPaintProperties(); 481 const ObjectPaintProperties* spanWithOpacityProperties = spanWithOpacity.obj ectPaintProperties();
422 EXPECT_EQ(0.5f, spanWithOpacityProperties->effect()->opacity()); 482 EXPECT_EQ(0.5f, spanWithOpacityProperties->effect()->opacity());
423 EXPECT_EQ(foreignObjectWithOpacityProperties->effect(), spanWithOpacityPrope rties->effect()->parent()); 483 EXPECT_EQ(foreignObjectWithOpacityProperties->effect(), spanWithOpacityPrope rties->effect()->parent());
424 } 484 }
425 485
426 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInSVG) 486 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesInSVG)
427 { 487 {
428 setBodyInnerHTML( 488 setBodyInnerHTML(
429 "<style>" 489 "<style>"
430 " body {" 490 " body {"
431 " margin: 0px;" 491 " margin: 0px;"
432 " }" 492 " }"
433 " svg {" 493 " svg {"
434 " margin-left: 50px;" 494 " margin-left: 50px;"
435 " transform: translate3d(1px, 2px, 3px);" 495 " transform: translate3d(1px, 2px, 3px);"
436 " position: absolute;" 496 " position: absolute;"
437 " left: 20px;" 497 " left: 20px;"
438 " top: 25px;" 498 " top: 25px;"
439 " }" 499 " }"
440 " rect {" 500 " rect {"
441 " transform: translate(100px, 100px) rotate(45deg);" 501 " transform: translate(100px, 100px) rotate(45deg);"
442 " transform-origin: 50px 25px;" 502 " transform-origin: 50px 25px;"
443 " }" 503 " }"
444 "</style>" 504 "</style>"
445 "<svg id='svgRootWith3dTransform' width='100px' height='100px'>" 505 "<svg id='svgRootWith3dTransform' width='100px' height='100px'>"
446 " <rect id='rectWith2dTransform' width='100px' height='100px' />" 506 " <rect id='rectWith2dTransform' width='100px' height='100px' />"
447 "</svg>"); 507 "</svg>");
448 508
449 LayoutObject& svgRootWith3dTransform = *document().getElementById("svgRootWi th3dTransform")->layoutObject(); 509 LayoutObject& svgRootWith3dTransform = *document().getElementById("svgRootWi th3dTransform")->layoutObject();
450 const ObjectPaintProperties* svgRootWith3dTransformProperties = svgRootWith3 dTransform.objectPaintProperties(); 510 const ObjectPaintProperties* svgRootWith3dTransformProperties = svgRootWith3 dTransform.objectPaintProperties();
451 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgRootWith3dTransfor mProperties->transform()->matrix()); 511 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgRootWith3dTransfor mProperties->transform()->matrix());
452 EXPECT_EQ(FloatPoint3D(50, 50, 0), svgRootWith3dTransformProperties->transfo rm()->origin()); 512 EXPECT_EQ(FloatPoint3D(50, 50, 0), svgRootWith3dTransformProperties->transfo rm()->origin());
453 EXPECT_EQ(svgRootWith3dTransformProperties->paintOffsetTranslation(), svgRoo tWith3dTransformProperties->transform()->parent()); 513 EXPECT_EQ(svgRootWith3dTransformProperties->paintOffsetTranslation(), svgRoo tWith3dTransformProperties->transform()->parent());
454 EXPECT_EQ(TransformationMatrix().translate(70, 25), svgRootWith3dTransformPr operties->paintOffsetTranslation()->matrix()); 514 EXPECT_EQ(TransformationMatrix().translate(70, 25), svgRootWith3dTransformPr operties->paintOffsetTranslation()->matrix());
455 EXPECT_EQ(document().view()->scrollTranslation(), svgRootWith3dTransformProp erties->paintOffsetTranslation()->parent()); 515 EXPECT_EQ(frameScrollTranslation(), svgRootWith3dTransformProperties->paintO ffsetTranslation()->parent());
456 516
457 LayoutObject& rectWith2dTransform = *document().getElementById("rectWith2dTr ansform")->layoutObject(); 517 LayoutObject& rectWith2dTransform = *document().getElementById("rectWith2dTr ansform")->layoutObject();
458 const ObjectPaintProperties* rectWith2dTransformProperties = rectWith2dTrans form.objectPaintProperties(); 518 const ObjectPaintProperties* rectWith2dTransformProperties = rectWith2dTrans form.objectPaintProperties();
459 TransformationMatrix matrix; 519 TransformationMatrix matrix;
460 matrix.translate(100, 100); 520 matrix.translate(100, 100);
461 matrix.rotate(45); 521 matrix.rotate(45);
462 // SVG's transform origin is baked into the transform. 522 // SVG's transform origin is baked into the transform.
463 matrix.applyTransformOrigin(50, 25, 0); 523 matrix.applyTransformOrigin(50, 25, 0);
464 EXPECT_EQ(matrix, rectWith2dTransformProperties->transform()->matrix()); 524 EXPECT_EQ(matrix, rectWith2dTransformProperties->transform()->matrix());
465 EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->transform()- >origin()); 525 EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->transform()- >origin());
466 // SVG does not use paint offset. 526 // SVG does not use paint offset.
467 EXPECT_EQ(nullptr, rectWith2dTransformProperties->paintOffsetTranslation()); 527 EXPECT_EQ(nullptr, rectWith2dTransformProperties->paintOffsetTranslation());
468 } 528 }
469 529
470 TEST_F(PaintPropertyTreeBuilderTest, SVGViewBoxTransform) 530 TEST_P(PaintPropertyTreeBuilderTest, SVGViewBoxTransform)
471 { 531 {
472 setBodyInnerHTML( 532 setBodyInnerHTML(
473 "<style>" 533 "<style>"
474 " body {" 534 " body {"
475 " margin: 0px;" 535 " margin: 0px;"
476 " }" 536 " }"
477 " svg {" 537 " svg {"
478 " transform: translate3d(1px, 2px, 3px);" 538 " transform: translate3d(1px, 2px, 3px);"
479 " position: absolute;" 539 " position: absolute;"
480 " }" 540 " }"
(...skipping 10 matching lines...) Expand all
491 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithViewBoxPropert ies->transform()->matrix()); 551 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithViewBoxPropert ies->transform()->matrix());
492 EXPECT_EQ(TransformationMatrix().translate(-50, -50), svgWithViewBoxProperti es->svgLocalToBorderBoxTransform()->matrix()); 552 EXPECT_EQ(TransformationMatrix().translate(-50, -50), svgWithViewBoxProperti es->svgLocalToBorderBoxTransform()->matrix());
493 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->parent() , svgWithViewBoxProperties->transform()); 553 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->parent() , svgWithViewBoxProperties->transform());
494 554
495 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); 555 LayoutObject& rect = *document().getElementById("rect")->layoutObject();
496 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); 556 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties();
497 EXPECT_EQ(TransformationMatrix().translate(100, 100), rectProperties->transf orm()->matrix()); 557 EXPECT_EQ(TransformationMatrix().translate(100, 100), rectProperties->transf orm()->matrix());
498 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), rectProp erties->transform()->parent()); 558 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), rectProp erties->transform()->parent());
499 } 559 }
500 560
501 TEST_F(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode) 561 TEST_P(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode)
502 { 562 {
503 setBodyInnerHTML( 563 setBodyInnerHTML(
504 "<style>body { margin: 0px; } </style>" 564 "<style>body { margin: 0px; } </style>"
505 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px; height: 100px;' />"); 565 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px; height: 100px;' />");
506 566
507 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); 567 LayoutObject& svg = *document().getElementById("svg")->layoutObject();
508 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); 568 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties();
509 // Ensure that a paint offset transform is not unnecessarily emitted. 569 // Ensure that a paint offset transform is not unnecessarily emitted.
510 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); 570 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation());
511 EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->svgLocalT oBorderBoxTransform()->matrix()); 571 EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->svgLocalT oBorderBoxTransform()->matrix());
512 EXPECT_EQ(document().view()->scrollTranslation(), svgProperties->svgLocalToB orderBoxTransform()->parent()); 572 EXPECT_EQ(frameScrollTranslation(), svgProperties->svgLocalToBorderBoxTransf orm()->parent());
513 } 573 }
514 574
515 TEST_F(PaintPropertyTreeBuilderTest, SVGRootLocalToBorderBoxTransformNode) 575 TEST_P(PaintPropertyTreeBuilderTest, SVGRootLocalToBorderBoxTransformNode)
516 { 576 {
517 setBodyInnerHTML( 577 setBodyInnerHTML(
518 "<style>" 578 "<style>"
519 " body { margin: 0px; }" 579 " body { margin: 0px; }"
520 " svg { margin-left: 2px; margin-top: 3px; transform: translate(5px, 7p x); border: 11px solid green; }" 580 " svg { margin-left: 2px; margin-top: 3px; transform: translate(5px, 7p x); border: 11px solid green; }"
521 "</style>" 581 "</style>"
522 "<svg id='svg' width='100px' height='100px' viewBox='0 0 13 13'>" 582 "<svg id='svg' width='100px' height='100px' viewBox='0 0 13 13'>"
523 " <rect id='rect' transform='translate(17 19)' />" 583 " <rect id='rect' transform='translate(17 19)' />"
524 "</svg>"); 584 "</svg>");
525 585
526 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); 586 LayoutObject& svg = *document().getElementById("svg")->layoutObject();
527 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); 587 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties();
528 EXPECT_EQ(TransformationMatrix().translate(2, 3), svgProperties->paintOffset Translation()->matrix()); 588 EXPECT_EQ(TransformationMatrix().translate(2, 3), svgProperties->paintOffset Translation()->matrix());
529 EXPECT_EQ(TransformationMatrix().translate(5, 7), svgProperties->transform() ->matrix()); 589 EXPECT_EQ(TransformationMatrix().translate(5, 7), svgProperties->transform() ->matrix());
530 EXPECT_EQ(TransformationMatrix().translate(11, 11).scale(100.0 / 13.0), svgP roperties->svgLocalToBorderBoxTransform()->matrix()); 590 EXPECT_EQ(TransformationMatrix().translate(11, 11).scale(100.0 / 13.0), svgP roperties->svgLocalToBorderBoxTransform()->matrix());
531 EXPECT_EQ(svgProperties->paintOffsetTranslation(), svgProperties->transform( )->parent()); 591 EXPECT_EQ(svgProperties->paintOffsetTranslation(), svgProperties->transform( )->parent());
532 EXPECT_EQ(svgProperties->transform(), svgProperties->svgLocalToBorderBoxTran sform()->parent()); 592 EXPECT_EQ(svgProperties->transform(), svgProperties->svgLocalToBorderBoxTran sform()->parent());
533 593
534 // Ensure the rect's transform is a child of the local to border box transfo rm. 594 // Ensure the rect's transform is a child of the local to border box transfo rm.
535 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); 595 LayoutObject& rect = *document().getElementById("rect")->layoutObject();
536 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); 596 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties();
537 EXPECT_EQ(TransformationMatrix().translate(17, 19), rectProperties->transfor m()->matrix()); 597 EXPECT_EQ(TransformationMatrix().translate(17, 19), rectProperties->transfor m()->matrix());
538 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), rectProperties->tra nsform()->parent()); 598 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), rectProperties->tra nsform()->parent());
539 } 599 }
540 600
541 TEST_F(PaintPropertyTreeBuilderTest, SVGNestedViewboxTransforms) 601 TEST_P(PaintPropertyTreeBuilderTest, SVGNestedViewboxTransforms)
542 { 602 {
543 setBodyInnerHTML( 603 setBodyInnerHTML(
544 "<style>body { margin: 0px; } </style>" 604 "<style>body { margin: 0px; } </style>"
545 "<svg id='svg' width='100px' height='100px' viewBox='0 0 50 50' style='t ransform: translate(11px, 11px);'>" 605 "<svg id='svg' width='100px' height='100px' viewBox='0 0 50 50' style='t ransform: translate(11px, 11px);'>"
546 " <svg id='nestedSvg' width='50px' height='50px' viewBox='0 0 5 5'>" 606 " <svg id='nestedSvg' width='50px' height='50px' viewBox='0 0 5 5'>"
547 " <rect id='rect' transform='translate(13 13)' />" 607 " <rect id='rect' transform='translate(13 13)' />"
548 " </svg>" 608 " </svg>"
549 "</svg>"); 609 "</svg>");
550 610
551 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); 611 LayoutObject& svg = *document().getElementById("svg")->layoutObject();
552 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); 612 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties();
553 EXPECT_EQ(TransformationMatrix().translate(11, 11), svgProperties->transform ()->matrix()); 613 EXPECT_EQ(TransformationMatrix().translate(11, 11), svgProperties->transform ()->matrix());
554 EXPECT_EQ(TransformationMatrix().scale(2), svgProperties->svgLocalToBorderBo xTransform()->matrix()); 614 EXPECT_EQ(TransformationMatrix().scale(2), svgProperties->svgLocalToBorderBo xTransform()->matrix());
555 615
556 LayoutObject& nestedSvg = *document().getElementById("nestedSvg")->layoutObj ect(); 616 LayoutObject& nestedSvg = *document().getElementById("nestedSvg")->layoutObj ect();
557 const ObjectPaintProperties* nestedSvgProperties = nestedSvg.objectPaintProp erties(); 617 const ObjectPaintProperties* nestedSvgProperties = nestedSvg.objectPaintProp erties();
558 EXPECT_EQ(TransformationMatrix().scale(10), nestedSvgProperties->transform() ->matrix()); 618 EXPECT_EQ(TransformationMatrix().scale(10), nestedSvgProperties->transform() ->matrix());
559 EXPECT_EQ(nullptr, nestedSvgProperties->svgLocalToBorderBoxTransform()); 619 EXPECT_EQ(nullptr, nestedSvgProperties->svgLocalToBorderBoxTransform());
560 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), nestedSvgProperties ->transform()->parent()); 620 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), nestedSvgProperties ->transform()->parent());
561 621
562 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); 622 LayoutObject& rect = *document().getElementById("rect")->layoutObject();
563 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); 623 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties();
564 EXPECT_EQ(TransformationMatrix().translate(13, 13), rectProperties->transfor m()->matrix()); 624 EXPECT_EQ(TransformationMatrix().translate(13, 13), rectProperties->transfor m()->matrix());
565 EXPECT_EQ(nestedSvgProperties->transform(), rectProperties->transform()->par ent()); 625 EXPECT_EQ(nestedSvgProperties->transform(), rectProperties->transform()->par ent());
566 } 626 }
567 627
568 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSVGHTMLBoundary) 628 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSVGHTMLBoundary)
569 { 629 {
570 setBodyInnerHTML( 630 setBodyInnerHTML(
571 "<style> body { margin: 0px; } </style>" 631 "<style> body { margin: 0px; } </style>"
572 "<svg id='svgWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>" 632 "<svg id='svgWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>"
573 " <foreignObject>" 633 " <foreignObject>"
574 " <body>" 634 " <body>"
575 " <div id='divWithTransform' style='transform: translate3d(3px, 4px , 5px);'></div>" 635 " <div id='divWithTransform' style='transform: translate3d(3px, 4px , 5px);'></div>"
576 " </body>" 636 " </body>"
577 " </foreignObject>" 637 " </foreignObject>"
578 "</svg>"); 638 "</svg>");
579 639
580 LayoutObject& svgWithTransform = *document().getElementById("svgWithTransfor m")->layoutObject(); 640 LayoutObject& svgWithTransform = *document().getElementById("svgWithTransfor m")->layoutObject();
581 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o bjectPaintProperties(); 641 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o bjectPaintProperties();
582 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithTransformPrope rties->transform()->matrix()); 642 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithTransformPrope rties->transform()->matrix());
583 643
584 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject(); 644 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject();
585 const ObjectPaintProperties* divWithTransformProperties = divWithTransform.o bjectPaintProperties(); 645 const ObjectPaintProperties* divWithTransformProperties = divWithTransform.o bjectPaintProperties();
586 EXPECT_EQ(TransformationMatrix().translate3d(3, 4, 5), divWithTransformPrope rties->transform()->matrix()); 646 EXPECT_EQ(TransformationMatrix().translate3d(3, 4, 5), divWithTransformPrope rties->transform()->matrix());
587 // Ensure the div's transform node is a child of the svg's transform node. 647 // Ensure the div's transform node is a child of the svg's transform node.
588 EXPECT_EQ(svgWithTransformProperties->transform(), divWithTransformPropertie s->transform()->parent()); 648 EXPECT_EQ(svgWithTransformProperties->transform(), divWithTransformPropertie s->transform()->parent());
589 } 649 }
590 650
591 TEST_F(PaintPropertyTreeBuilderTest, FixedTransformAncestorAcrossSVGHTMLBoundary ) 651 TEST_P(PaintPropertyTreeBuilderTest, FixedTransformAncestorAcrossSVGHTMLBoundary )
592 { 652 {
593 setBodyInnerHTML( 653 setBodyInnerHTML(
594 "<style> body { margin: 0px; } </style>" 654 "<style> body { margin: 0px; } </style>"
595 "<svg id='svg' style='transform: translate3d(1px, 2px, 3px);'>" 655 "<svg id='svg' style='transform: translate3d(1px, 2px, 3px);'>"
596 " <g id='container' transform='translate(20 30)'>" 656 " <g id='container' transform='translate(20 30)'>"
597 " <foreignObject>" 657 " <foreignObject>"
598 " <body>" 658 " <body>"
599 " <div id='fixed' style='position: fixed; left: 200px; top: 150px ;'></div>" 659 " <div id='fixed' style='position: fixed; left: 200px; top: 150px ;'></div>"
600 " </body>" 660 " </body>"
601 " </foreignObject>" 661 " </foreignObject>"
602 " </g>" 662 " </g>"
603 "</svg>"); 663 "</svg>");
604 664
605 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); 665 LayoutObject& svg = *document().getElementById("svg")->layoutObject();
606 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); 666 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties();
607 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgProperties->transf orm()->matrix()); 667 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgProperties->transf orm()->matrix());
608 668
609 LayoutObject& container = *document().getElementById("container")->layoutObj ect(); 669 LayoutObject& container = *document().getElementById("container")->layoutObj ect();
610 const ObjectPaintProperties* containerProperties = container.objectPaintProp erties(); 670 const ObjectPaintProperties* containerProperties = container.objectPaintProp erties();
611 EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->tra nsform()->matrix()); 671 EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->tra nsform()->matrix());
612 EXPECT_EQ(svgProperties->transform(), containerProperties->transform()->pare nt()); 672 EXPECT_EQ(svgProperties->transform(), containerProperties->transform()->pare nt());
613 673
614 Element* fixed = document().getElementById("fixed"); 674 Element* fixed = document().getElementById("fixed");
615 const ObjectPaintProperties* fixedProperties = fixed->layoutObject()->object PaintProperties(); 675 const ObjectPaintProperties* fixedProperties = fixed->layoutObject()->object PaintProperties();
616 EXPECT_EQ(TransformationMatrix().translate(200, 150), fixedProperties->paint OffsetTranslation()->matrix()); 676 EXPECT_EQ(TransformationMatrix().translate(200, 150), fixedProperties->paint OffsetTranslation()->matrix());
617 // Ensure the fixed position element is rooted at the nearest transform cont ainer. 677 // Ensure the fixed position element is rooted at the nearest transform cont ainer.
618 EXPECT_EQ(containerProperties->transform(), fixedProperties->paintOffsetTran slation()->parent()); 678 EXPECT_EQ(containerProperties->transform(), fixedProperties->paintOffsetTran slation()->parent());
619 } 679 }
620 680
621 TEST_F(PaintPropertyTreeBuilderTest, ControlClip) 681 TEST_P(PaintPropertyTreeBuilderTest, ControlClip)
622 { 682 {
623 setBodyInnerHTML( 683 setBodyInnerHTML(
624 "<style>" 684 "<style>"
625 " body {" 685 " body {"
626 " margin: 0;" 686 " margin: 0;"
627 " }" 687 " }"
628 " input {" 688 " input {"
629 " border-width: 5px;" 689 " border-width: 5px;"
630 " padding: 0;" 690 " padding: 0;"
631 " }" 691 " }"
632 "</style>" 692 "</style>"
633 "<input id='button' type='button' style='width:345px; height:123px' valu e='some text'/>"); 693 "<input id='button' type='button' style='width:345px; height:123px' valu e='some text'/>");
634 694
635 FrameView* frameView = document().view(); 695 LayoutObject& button = *document().getElementById("button")->layoutObject();
636 LayoutObject* button = document().getElementById("button")->layoutObject(); 696 const ObjectPaintProperties* buttonProperties = button.objectPaintProperties ();
637 const ObjectPaintProperties* buttonProperties = button->objectPaintPropertie s(); 697 EXPECT_EQ(frameScrollTranslation(), buttonProperties->overflowClip()->localT ransformSpace());
638 EXPECT_EQ(frameView->scrollTranslation(), buttonProperties->overflowClip()-> localTransformSpace());
639 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip() ->clipRect()); 698 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip() ->clipRect());
640 EXPECT_EQ(frameView->contentClip(), buttonProperties->overflowClip()->parent ()); 699 EXPECT_EQ(frameContentClip(), buttonProperties->overflowClip()->parent());
641 CHECK_EXACT_VISUAL_RECT(button, frameView->layoutView()); 700 CHECK_EXACT_VISUAL_RECT((&button), document().view()->layoutView());
642 } 701 }
643 702
644 TEST_F(PaintPropertyTreeBuilderTest, BorderRadiusClip) 703 TEST_P(PaintPropertyTreeBuilderTest, BorderRadiusClip)
645 { 704 {
646 setBodyInnerHTML( 705 setBodyInnerHTML(
647 "<style>" 706 "<style>"
648 " body {" 707 " body {"
649 " margin: 0px;" 708 " margin: 0px;"
650 " }" 709 " }"
651 " #div {" 710 " #div {"
652 " border-radius: 12px 34px 56px 78px;" 711 " border-radius: 12px 34px 56px 78px;"
653 " border-top: 45px solid;" 712 " border-top: 45px solid;"
654 " border-right: 50px solid;" 713 " border-right: 50px solid;"
655 " border-bottom: 55px solid;" 714 " border-bottom: 55px solid;"
656 " border-left: 60px solid;" 715 " border-left: 60px solid;"
657 " width: 500px;" 716 " width: 500px;"
658 " height: 400px;" 717 " height: 400px;"
659 " overflow: scroll;" 718 " overflow: scroll;"
660 " }" 719 " }"
661 "</style>" 720 "</style>"
662 "<div id='div'></div>"); 721 "<div id='div'></div>");
663 722
664 FrameView* frameView = document().view(); 723 LayoutObject& div = *document().getElementById("div")->layoutObject();
665 LayoutObject* div = document().getElementById("div")->layoutObject(); 724 const ObjectPaintProperties* divProperties = div.objectPaintProperties();
666 const ObjectPaintProperties* divProperties = div->objectPaintProperties(); 725 EXPECT_EQ(frameScrollTranslation(), divProperties->overflowClip()->localTran sformSpace());
667 EXPECT_EQ(frameView->scrollTranslation(), divProperties->overflowClip()->loc alTransformSpace());
668 // The overflow clip rect includes only the padding box. 726 // The overflow clip rect includes only the padding box.
669 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, 45+ 55) - scrollbars(15, 15) 727 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, 45+ 55) - scrollbars(15, 15)
670 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), divProperties->overflowClip()- >clipRect()); 728 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), divProperties->overflowClip()- >clipRect());
671 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip( )->parent(); 729 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip( )->parent();
672 EXPECT_EQ(frameView->scrollTranslation(), borderRadiusClip->localTransformSp ace()); 730 EXPECT_EQ(frameScrollTranslation(), borderRadiusClip->localTransformSpace()) ;
673 // The border radius clip is the area enclosed by inner border edge, includi ng the scrollbars. 731 // The border radius clip is the area enclosed by inner border edge, includi ng the scrollbars.
674 // As the border-radius is specified in outer radius, the inner radius is ca lculated by: 732 // As the border-radius is specified in outer radius, the inner radius is ca lculated by:
675 // inner radius = max(outer radius - border width, 0) 733 // inner radius = max(outer radius - border width, 0)
676 // In the case that two adjacent borders have different width, the inner rad ius of the corner 734 // In the case that two adjacent borders have different width, the inner rad ius of the corner
677 // may transition from one value to the other. i.e. being an ellipse. 735 // may transition from one value to the other. i.e. being an ellipse.
678 EXPECT_EQ( 736 EXPECT_EQ(
679 FloatRoundedRect( 737 FloatRoundedRect(
680 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs et(110, 100) 738 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs et(110, 100)
681 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0, 0)) 739 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0, 0))
682 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0, 0)) 740 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0, 0))
683 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0, 0)) 741 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0, 0))
684 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0, 0)) 742 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0, 0))
685 borderRadiusClip->clipRect()); 743 borderRadiusClip->clipRect());
686 EXPECT_EQ(frameView->contentClip(), borderRadiusClip->parent()); 744 EXPECT_EQ(frameContentClip(), borderRadiusClip->parent());
687 CHECK_EXACT_VISUAL_RECT(div, frameView->layoutView()); 745 CHECK_EXACT_VISUAL_RECT((&div), document().view()->layoutView());
688 } 746 }
689 747
690 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) 748 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes)
691 { 749 {
692 setBodyInnerHTML( 750 setBodyInnerHTML(
693 "<style>body { margin: 0; }</style>" 751 "<style>body { margin: 0; }</style>"
694 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>" 752 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>"
695 " <iframe id='frame'></iframe>" 753 " <iframe style='border: 7px solid black' id='frame'></iframe>"
696 "</div>"); 754 "</div>");
697 Document& frameDocument = setupChildIframe("frame", 755 Document& frameDocument = setupChildIframe("frame",
698 "<style>body { margin: 0; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>"); 756 "<style>body { margin: 0; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>");
699 FrameView* frameView = document().view(); 757 FrameView* frameView = document().view();
700 frameView->updateAllLifecyclePhases(); 758 frameView->updateAllLifecyclePhases();
701 759
702 LayoutObject* divWithTransform = document().getElementById("divWithTransform ")->layoutObject(); 760 LayoutObject* divWithTransform = document().getElementById("divWithTransform ")->layoutObject();
703 const ObjectPaintProperties* divWithTransformProperties = divWithTransform-> objectPaintProperties(); 761 const ObjectPaintProperties* divWithTransformProperties = divWithTransform-> objectPaintProperties();
704 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope rties->transform()->matrix()); 762 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope rties->transform()->matrix());
705 CHECK_EXACT_VISUAL_RECT(divWithTransform, frameView->layoutView()); 763 // http://crbug.com/638415
764 if (!rootLayerScrolls()) {
765 CHECK_EXACT_VISUAL_RECT(divWithTransform, frameView->layoutView());
766 }
706 767
707 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor m")->layoutObject(); 768 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor m")->layoutObject();
708 const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithT ransform->objectPaintProperties(); 769 const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithT ransform->objectPaintProperties();
709 auto* innerDivTransform = innerDivWithTransformProperties->transform(); 770 auto* innerDivTransform = innerDivWithTransformProperties->transform();
710 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma trix()); 771 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma trix());
711 CHECK_EXACT_VISUAL_RECT(innerDivWithTransform, frameView->layoutView()); 772 CHECK_EXACT_VISUAL_RECT(innerDivWithTransform, frameView->layoutView());
712 773
713 // Ensure that the inner div's transform is correctly rooted in the root fra me's transform tree. 774 // Ensure that the inner div's transform is correctly rooted in the root fra me's transform tree.
714 // This asserts that we have the following tree structure: 775 // This asserts that we have the following tree structure:
715 // ... 776 // ...
716 // Transform transform=translation=1.000000,2.000000,3.000000 777 // Transform transform=translation=1.000000,2.000000,3.000000
717 // PreTranslation transform=translation=2.000000,2.000000,0.000000 778 // PreTranslation transform=translation=7.000000,7.000000,0.000000
718 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 779 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000
719 // Transform transform=translation=4.000000,5.000000,6.000000 780 // Transform transform=translation=4.000000,5.000000,6.000000
720 auto* innerDocumentScrollTranslation = innerDivTransform->parent(); 781 auto* innerDocumentScrollTranslation = innerDivTransform->parent();
721 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr anslation->matrix()); 782 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr anslation->matrix());
722 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); 783 auto* iframePreTranslation = innerDocumentScrollTranslation->parent();
723 EXPECT_EQ(TransformationMatrix().translate3d(2, 2, 0), iframePreTranslation- >matrix()); 784 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePreTranslation- >matrix());
724 EXPECT_EQ(divWithTransformProperties->transform(), iframePreTranslation->par ent()); 785 EXPECT_EQ(divWithTransformProperties->transform(), iframePreTranslation->par ent());
725 } 786 }
726 787
727 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes) 788 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes)
728 { 789 {
729 setBodyInnerHTML( 790 setBodyInnerHTML(
730 "<style>body { margin: 0; }</style>" 791 "<style>body { margin: 0; }</style>"
731 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>" 792 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>"
732 " <iframe id='frame' style='transform: translate3d(4px, 5px, 6px); bord er: 42px solid; margin: 7px;'></iframe>" 793 " <iframe id='frame' style='transform: translate3d(4px, 5px, 6px); bord er: 42px solid; margin: 7px;'></iframe>"
733 "</div>"); 794 "</div>");
734 Document& frameDocument = setupChildIframe("frame", 795 Document& frameDocument = setupChildIframe("frame",
735 "<style>body { margin: 31px; }</style><div id='transform' style='transfo rm: translate3d(7px, 8px, 9px); width: 100px; height: 200px'></div>"); 796 "<style>body { margin: 31px; }</style><div id='transform' style='transfo rm: translate3d(7px, 8px, 9px); width: 100px; height: 200px'></div>");
736 FrameView* frameView = document().view(); 797 FrameView* frameView = document().view();
737 frameView->updateAllLifecyclePhases(); 798 frameView->updateAllLifecyclePhases();
(...skipping 21 matching lines...) Expand all
759 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), iframePreTranslatio n->matrix()); 820 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), iframePreTranslatio n->matrix());
760 auto* iframeTransform = iframePreTranslation->parent(); 821 auto* iframeTransform = iframePreTranslation->parent();
761 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr ix()); 822 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr ix());
762 auto* iframePaintOffsetTranslation = iframeTransform->parent(); 823 auto* iframePaintOffsetTranslation = iframeTransform->parent();
763 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran slation->matrix()); 824 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran slation->matrix());
764 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); 825 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent();
765 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans form->matrix()); 826 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans form->matrix());
766 827
767 LayoutObject* divWithTransform = document().getElementById("divWithTransform ")->layoutObject(); 828 LayoutObject* divWithTransform = document().getElementById("divWithTransform ")->layoutObject();
768 EXPECT_EQ(divWithTransformTransform, divWithTransform->objectPaintProperties ()->transform()); 829 EXPECT_EQ(divWithTransformTransform, divWithTransform->objectPaintProperties ()->transform());
769 CHECK_EXACT_VISUAL_RECT(divWithTransform, frameView->layoutView()); 830 // http://crbug.com/638415
831 if (!rootLayerScrolls()) {
832 CHECK_EXACT_VISUAL_RECT(divWithTransform, frameView->layoutView());
833 }
770 } 834 }
771 835
772 TEST_F(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) 836 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext)
773 { 837 {
774 // This test verifies the tree builder correctly computes and records the pr operty tree context 838 // This test verifies the tree builder correctly computes and records the pr operty tree context
775 // for a (pseudo) stacking context that is scrolled by a containing block th at is not one of 839 // for a (pseudo) stacking context that is scrolled by a containing block th at is not one of
776 // the painting ancestors. 840 // the painting ancestors.
777 setBodyInnerHTML( 841 setBodyInnerHTML(
778 "<style>body { margin: 0; }</style>" 842 "<style>body { margin: 0; }</style>"
779 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'> " 843 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'> "
780 " <div id='child' style='position:relative; width:100px; height: 200px; '></div>" 844 " <div id='child' style='position:relative; width:100px; height: 200px; '></div>"
781 " <div style='height:10000px;'></div>" 845 " <div style='height:10000px;'></div>"
782 "</div>" 846 "</div>"
783 ); 847 );
784 FrameView* frameView = document().view(); 848 FrameView* frameView = document().view();
785 849
786 LayoutObject* scroller = document().getElementById("scroller")->layoutObject (); 850 LayoutObject* scroller = document().getElementById("scroller")->layoutObject ();
787 const ObjectPaintProperties* scrollerProperties = scroller->objectPaintPrope rties(); 851 const ObjectPaintProperties* scrollerProperties = scroller->objectPaintPrope rties();
788 LayoutObject* child = document().getElementById("child")->layoutObject(); 852 LayoutObject* child = document().getElementById("child")->layoutObject();
789 const ObjectPaintProperties* childProperties = child->objectPaintProperties( ); 853 const ObjectPaintProperties* childProperties = child->objectPaintProperties( );
790 854
791 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo xProperties()->propertyTreeState.clip); 855 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo xProperties()->propertyTreeState.clip);
792 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor derBoxProperties()->propertyTreeState.transform); 856 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor derBoxProperties()->propertyTreeState.transform);
793 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree State.effect); 857 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree State.effect);
794 CHECK_EXACT_VISUAL_RECT(scroller, frameView->layoutView()); 858 CHECK_EXACT_VISUAL_RECT(scroller, frameView->layoutView());
795 CHECK_EXACT_VISUAL_RECT(child, frameView->layoutView()); 859 CHECK_EXACT_VISUAL_RECT(child, frameView->layoutView());
796 } 860 }
797 861
798 TEST_F(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext) 862 TEST_P(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext)
799 { 863 {
800 // This test verifies the tree builder correctly computes and records the pr operty tree context 864 // This test verifies the tree builder correctly computes and records the pr operty tree context
801 // for a (pseudo) stacking context that has a scrolling painting ancestor th at is not its 865 // for a (pseudo) stacking context that has a scrolling painting ancestor th at is not its
802 // containing block (thus should not be scrolled by it). 866 // containing block (thus should not be scrolled by it).
803 867
804 setBodyInnerHTML( 868 setBodyInnerHTML(
805 "<style>body { margin: 0; }</style>" 869 "<style>body { margin: 0; }</style>"
806 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" 870 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>"
807 " <div id='child' style='position:absolute; left:0; top:0; width: 100px ; height: 200px'></div>" 871 " <div id='child' style='position:absolute; left:0; top:0; width: 100px ; height: 200px'></div>"
808 " <div style='height:10000px;'></div>" 872 " <div style='height:10000px;'></div>"
809 "</div>" 873 "</div>"
810 ); 874 );
811 875
812 FrameView* frameView = document().view(); 876 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec t();
813 LayoutObject* scroller = document().getElementById("scroller")->layoutObject (); 877 const ObjectPaintProperties* scrollerProperties = scroller.objectPaintProper ties();
814 const ObjectPaintProperties* scrollerProperties = scroller->objectPaintPrope rties(); 878 LayoutObject& child = *document().getElementById("child")->layoutObject();
815 LayoutObject* child = document().getElementById("child")->layoutObject(); 879 const ObjectPaintProperties* childProperties = child.objectPaintProperties() ;
816 const ObjectPaintProperties* childProperties = child->objectPaintProperties( );
817 880
818 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie s()->propertyTreeState.clip); 881 EXPECT_EQ(frameContentClip(), childProperties->localBorderBoxProperties()->p ropertyTreeState.clip);
819 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro perties()->propertyTreeState.transform); 882 EXPECT_EQ(frameScrollTranslation(), childProperties->localBorderBoxPropertie s()->propertyTreeState.transform);
820 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope rties()->propertyTreeState.effect); 883 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope rties()->propertyTreeState.effect);
821 CHECK_EXACT_VISUAL_RECT(scroller, frameView->layoutView()); 884 if (!rootLayerScrolls()) {
822 CHECK_EXACT_VISUAL_RECT(child, frameView->layoutView()); 885 CHECK_EXACT_VISUAL_RECT((&scroller), document().view()->layoutView());
886 }
887 CHECK_EXACT_VISUAL_RECT((&child), document().view()->layoutView());
823 } 888 }
824 889
825 TEST_F(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) 890 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation)
826 { 891 {
827 // This test verifies that the border box space of a table cell is being cor rectly computed. 892 // This test verifies that the border box space of a table cell is being cor rectly computed.
828 // Table cells have weird location adjustment in our layout/paint implementa tion. 893 // Table cells have weird location adjustment in our layout/paint implementa tion.
829 setBodyInnerHTML( 894 setBodyInnerHTML(
830 "<style>" 895 "<style>"
831 " body {" 896 " body {"
832 " margin: 0;" 897 " margin: 0;"
833 " }" 898 " }"
834 " table {" 899 " table {"
835 " border-spacing: 0;" 900 " border-spacing: 0;"
(...skipping 11 matching lines...) Expand all
847 " width: 100px;" 912 " width: 100px;"
848 " height: 100px;" 913 " height: 100px;"
849 " }" 914 " }"
850 "</style>" 915 "</style>"
851 "<table>" 916 "<table>"
852 " <tr><td></td><td></td></tr>" 917 " <tr><td></td><td></td></tr>"
853 " <tr><td></td><td><div id='target'></div></td></tr>" 918 " <tr><td></td><td><div id='target'></div></td></tr>"
854 "</table>" 919 "</table>"
855 ); 920 );
856 921
857 FrameView* frameView = document().view(); 922 LayoutObject& target = *document().getElementById("target")->layoutObject();
858 LayoutObject* target = document().getElementById("target")->layoutObject(); 923 const ObjectPaintProperties* targetProperties = target.objectPaintProperties ();
859 const ObjectPaintProperties* targetProperties = target->objectPaintPropertie s();
860 924
861 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties( )->paintOffset); 925 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties( )->paintOffset);
862 EXPECT_EQ(frameView->scrollTranslation(), targetProperties->localBorderBoxPr operties()->propertyTreeState.transform); 926 EXPECT_EQ(frameScrollTranslation(), targetProperties->localBorderBoxProperti es()->propertyTreeState.transform);
863 CHECK_EXACT_VISUAL_RECT(target, frameView->layoutView()); 927 CHECK_EXACT_VISUAL_RECT((&target), document().view()->layoutView());
864 } 928 }
865 929
866 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) 930 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant)
867 { 931 {
868 // This test verifies that clip tree hierarchy being generated correctly for the hard case 932 // This test verifies that clip tree hierarchy being generated correctly for the hard case
869 // such that a fixed position element getting clipped by an absolute positio n CSS clip. 933 // such that a fixed position element getting clipped by an absolute positio n CSS clip.
870 setBodyInnerHTML( 934 setBodyInnerHTML(
871 "<style>" 935 "<style>"
872 " #clip {" 936 " #clip {"
873 " position: absolute;" 937 " position: absolute;"
874 " left: 123px;" 938 " left: 123px;"
875 " top: 456px;" 939 " top: 456px;"
876 " clip: rect(10px, 80px, 70px, 40px);" 940 " clip: rect(10px, 80px, 70px, 40px);"
877 " width: 100px;" 941 " width: 100px;"
878 " height: 100px;" 942 " height: 100px;"
879 " }" 943 " }"
880 " #fixed {" 944 " #fixed {"
881 " position: fixed;" 945 " position: fixed;"
882 " left: 654px;" 946 " left: 654px;"
883 " top: 321px;" 947 " top: 321px;"
884 " width: 10px;" 948 " width: 10px;"
885 " height: 20px" 949 " height: 20px"
886 " }" 950 " }"
887 "</style>" 951 "</style>"
888 "<div id='clip'><div id='fixed'></div></div>" 952 "<div id='clip'><div id='fixed'></div></div>"
889 ); 953 );
890 LayoutRect localClipRect(40, 10, 40, 60); 954 LayoutRect localClipRect(40, 10, 40, 60);
891 LayoutRect absoluteClipRect = localClipRect; 955 LayoutRect absoluteClipRect = localClipRect;
892 absoluteClipRect.move(123, 456); 956 absoluteClipRect.move(123, 456);
893 957
894 FrameView* frameView = document().view(); 958 LayoutObject& clip = *document().getElementById("clip")->layoutObject();
895 959 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties();
896 LayoutObject* clip = document().getElementById("clip")->layoutObject(); 960 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent());
897 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); 961 EXPECT_EQ(frameScrollTranslation(), clipProperties->cssClip()->localTransfor mSpace());
898 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent());
899 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr ansformSpace());
900 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect()); 962 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect());
901 // TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fix ed-position elements. 963 // TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fix ed-position elements.
902 // CHECK_EXACT_VISUAL_RECT(clip, frameView->layoutView()); 964 // CHECK_EXACT_VISUAL_RECT(clip, frameView->layoutView());
903 965
904 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); 966 LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
905 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties( ); 967 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties( );
906 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti es()->propertyTreeState.clip); 968 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti es()->propertyTreeState.clip);
907 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper ties()->propertyTreeState.transform->parent()); 969 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() ->propertyTreeState.transform->parent());
908 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->propertyTreeState.transform->matrix()); 970 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->propertyTreeState.transform->matrix());
909 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset); 971 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset);
910 CHECK_EXACT_VISUAL_RECT(fixed, frameView->layoutView()); 972 // http://crbug.com/638386
973 if (!rootLayerScrolls()) {
974 CHECK_EXACT_VISUAL_RECT(fixed, document().view()->layoutView());
975 }
911 } 976 }
912 977
913 TEST_F(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) 978 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant)
914 { 979 {
915 // This test verifies that clip tree hierarchy being generated correctly for the hard case 980 // This test verifies that clip tree hierarchy being generated correctly for the hard case
916 // such that a fixed position element getting clipped by an absolute positio n CSS clip. 981 // such that a fixed position element getting clipped by an absolute positio n CSS clip.
917 setBodyInnerHTML( 982 setBodyInnerHTML(
918 "<style>" 983 "<style>"
919 " #clip {" 984 " #clip {"
920 " position: absolute;" 985 " position: absolute;"
921 " left: 123px;" 986 " left: 123px;"
922 " top: 456px;" 987 " top: 456px;"
923 " clip: rect(10px, 80px, 70px, 40px);" 988 " clip: rect(10px, 80px, 70px, 40px);"
(...skipping 11 matching lines...) Expand all
935 "<div id='clip'><div id='absolute'></div></div>" 1000 "<div id='clip'><div id='absolute'></div></div>"
936 ); 1001 );
937 LayoutRect localClipRect(40, 10, 40, 60); 1002 LayoutRect localClipRect(40, 10, 40, 60);
938 LayoutRect absoluteClipRect = localClipRect; 1003 LayoutRect absoluteClipRect = localClipRect;
939 absoluteClipRect.move(123, 456); 1004 absoluteClipRect.move(123, 456);
940 1005
941 FrameView* frameView = document().view(); 1006 FrameView* frameView = document().view();
942 1007
943 LayoutObject* clip = document().getElementById("clip")->layoutObject(); 1008 LayoutObject* clip = document().getElementById("clip")->layoutObject();
944 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); 1009 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties();
945 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); 1010 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent());
946 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr ansformSpace()); 1011 EXPECT_EQ(frameScrollTranslation(), clipProperties->cssClip()->localTransfor mSpace());
947 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect()); 1012 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect());
948 // TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fix ed-position elements. 1013 // TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fix ed-position elements.
949 // CHECK_VISUAL_RECT(clip, frameView->layoutView()); 1014 // CHECK_VISUAL_RECT(clip, frameView->layoutView());
950 1015
951 LayoutObject* absolute = document().getElementById("absolute")->layoutObject (); 1016 LayoutObject* absolute = document().getElementById("absolute")->layoutObject ();
952 const ObjectPaintProperties* absPosProperties = absolute->objectPaintPropert ies(); 1017 const ObjectPaintProperties* absPosProperties = absolute->objectPaintPropert ies();
953 EXPECT_EQ(clipProperties->cssClip(), absPosProperties->localBorderBoxPropert ies()->propertyTreeState.clip); 1018 EXPECT_EQ(clipProperties->cssClip(), absPosProperties->localBorderBoxPropert ies()->propertyTreeState.clip);
954 EXPECT_EQ(frameView->preTranslation(), absPosProperties->localBorderBoxPrope rties()->propertyTreeState.transform->parent()); 1019 EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties( )->propertyTreeState.transform->parent());
955 EXPECT_EQ(LayoutPoint(123, 456), absPosProperties->localBorderBoxProperties( )->paintOffset); 1020 EXPECT_EQ(LayoutPoint(123, 456), absPosProperties->localBorderBoxProperties( )->paintOffset);
956 CHECK_EXACT_VISUAL_RECT(absolute, frameView->layoutView()); 1021 // http://crbug.com/638386
1022 if (!rootLayerScrolls()) {
1023 CHECK_EXACT_VISUAL_RECT(absolute, frameView->layoutView());
1024 }
957 } 1025 }
958 1026
959 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) 1027 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared)
960 { 1028 {
961 // This test is similar to CSSClipFixedPositionDescendant above, except that 1029 // This test is similar to CSSClipFixedPositionDescendant above, except that
962 // now we have a parent overflow clip that should be escaped by the fixed de scendant. 1030 // now we have a parent overflow clip that should be escaped by the fixed de scendant.
963 setBodyInnerHTML( 1031 setBodyInnerHTML(
964 "<style>" 1032 "<style>"
965 " body {" 1033 " body {"
966 " margin: 0;" 1034 " margin: 0;"
967 " }" 1035 " }"
968 " #overflow {" 1036 " #overflow {"
969 " position: relative;" 1037 " position: relative;"
(...skipping 14 matching lines...) Expand all
984 " left: 654px;" 1052 " left: 654px;"
985 " top: 321px;" 1053 " top: 321px;"
986 " }" 1054 " }"
987 "</style>" 1055 "</style>"
988 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>" 1056 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>"
989 ); 1057 );
990 LayoutRect localClipRect(40, 10, 40, 60); 1058 LayoutRect localClipRect(40, 10, 40, 60);
991 LayoutRect absoluteClipRect = localClipRect; 1059 LayoutRect absoluteClipRect = localClipRect;
992 absoluteClipRect.move(123, 456); 1060 absoluteClipRect.move(123, 456);
993 1061
994 FrameView* frameView = document().view(); 1062 LayoutObject& overflow = *document().getElementById("overflow")->layoutObjec t();
995 1063 const ObjectPaintProperties* overflowProperties = overflow.objectPaintProper ties();
996 LayoutObject* overflow = document().getElementById("overflow")->layoutObject (); 1064 EXPECT_EQ(frameContentClip(), overflowProperties->overflowClip()->parent());
997 const ObjectPaintProperties* overflowProperties = overflow->objectPaintPrope rties(); 1065 EXPECT_EQ(frameScrollTranslation(), overflowProperties->scrollTranslation()- >parent());
998 EXPECT_EQ(frameView->contentClip(), overflowProperties->overflowClip()->pare nt()); 1066 CHECK_EXACT_VISUAL_RECT((&overflow), document().view()->layoutView());
999 EXPECT_EQ(frameView->scrollTranslation(), overflowProperties->scrollTranslat ion()->parent());
1000 CHECK_EXACT_VISUAL_RECT(overflow, frameView->layoutView());
1001 1067
1002 LayoutObject* clip = document().getElementById("clip")->layoutObject(); 1068 LayoutObject* clip = document().getElementById("clip")->layoutObject();
1003 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); 1069 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties();
1004 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par ent()); 1070 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par ent());
1005 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip() ->localTransformSpace()); 1071 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip() ->localTransformSpace());
1006 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect()); 1072 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect());
1007 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClipFixedPosition()-> parent()); 1073 EXPECT_EQ(frameContentClip(), clipProperties->cssClipFixedPosition()->parent ());
1008 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi xedPosition()->localTransformSpace()); 1074 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi xedPosition()->localTransformSpace());
1009 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css ClipFixedPosition()->clipRect()); 1075 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css ClipFixedPosition()->clipRect());
1010 CHECK_EXACT_VISUAL_RECT(clip, frameView->layoutView()); 1076 CHECK_EXACT_VISUAL_RECT(clip, document().view()->layoutView());
1011 1077
1012 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); 1078 LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
1013 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties( ); 1079 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties( );
1014 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord erBoxProperties()->propertyTreeState.clip); 1080 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord erBoxProperties()->propertyTreeState.clip);
1015 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper ties()->propertyTreeState.transform->parent()); 1081 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() ->propertyTreeState.transform->parent());
1016 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->propertyTreeState.transform->matrix()); 1082 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->propertyTreeState.transform->matrix());
1017 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset); 1083 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset);
1018 CHECK_EXACT_VISUAL_RECT(fixed, frameView->layoutView()); 1084 // http://crbug.com/638386
1085 if (!rootLayerScrolls()) {
1086 CHECK_EXACT_VISUAL_RECT(fixed, document().view()->layoutView());
1087 }
1019 } 1088 }
1020 1089
1021 TEST_F(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) 1090 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned)
1022 { 1091 {
1023 setBodyInnerHTML( 1092 setBodyInnerHTML(
1024 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" 1093 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>"
1025 " <div style='position: relative; top: 100px; left: 100px'>" 1094 " <div style='position: relative; top: 100px; left: 100px'>"
1026 " <div id='spanner' style='column-span: all; opacity: 0.5; width: 100 px; height: 100px;'></div>" 1095 " <div id='spanner' style='column-span: all; opacity: 0.5; width: 100 px; height: 100px;'></div>"
1027 " </div>" 1096 " </div>"
1028 "</div>" 1097 "</div>"
1029 ); 1098 );
1030 1099
1031 LayoutObject* spanner = getLayoutObjectByElementId("spanner"); 1100 LayoutObject* spanner = getLayoutObjectByElementId("spanner");
1032 EXPECT_EQ(LayoutPoint(55, 44), spanner->objectPaintProperties()->localBorder BoxProperties()->paintOffset); 1101 EXPECT_EQ(LayoutPoint(55, 44), spanner->objectPaintProperties()->localBorder BoxProperties()->paintOffset);
1033 CHECK_EXACT_VISUAL_RECT(spanner, document().view()->layoutView()); 1102 CHECK_EXACT_VISUAL_RECT(spanner, document().view()->layoutView());
1034 } 1103 }
1035 1104
1036 TEST_F(PaintPropertyTreeBuilderTest, FractionalPaintOffset) 1105 TEST_P(PaintPropertyTreeBuilderTest, FractionalPaintOffset)
1037 { 1106 {
1038 setBodyInnerHTML( 1107 setBodyInnerHTML(
1039 "<style>" 1108 "<style>"
1040 " * { margin: 0; }" 1109 " * { margin: 0; }"
1041 " div { position: absolute; }" 1110 " div { position: absolute; }"
1042 "</style>" 1111 "</style>"
1043 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;' >" 1112 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;' >"
1044 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p x;'></div>" 1113 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p x;'></div>"
1045 "</div>" 1114 "</div>"
1046 ); 1115 );
1047 FrameView* frameView = document().view(); 1116 FrameView* frameView = document().view();
1048 1117
1049 LayoutObject* a = document().getElementById("a")->layoutObject(); 1118 LayoutObject* a = document().getElementById("a")->layoutObject();
1050 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); 1119 const ObjectPaintProperties* aProperties = a->objectPaintProperties();
1051 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); 1120 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3));
1052 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset ); 1121 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset );
1053 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); 1122 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView());
1054 1123
1055 LayoutObject* b = document().getElementById("b")->layoutObject(); 1124 LayoutObject* b = document().getElementById("b")->layoutObject();
1056 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); 1125 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1057 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1)) ; 1126 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1)) ;
1058 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset ); 1127 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset );
1059 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); 1128 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView());
1060 } 1129 }
1061 1130
1062 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) 1131 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping)
1063 { 1132 {
1064 setBodyInnerHTML( 1133 setBodyInnerHTML(
1065 "<style>" 1134 "<style>"
1066 " * { margin: 0; }" 1135 " * { margin: 0; }"
1067 " div { position: relative; }" 1136 " div { position: relative; }"
1068 "</style>" 1137 "</style>"
1069 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;' >" 1138 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;' >"
1070 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 );'>" 1139 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 );'>"
1071 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1 px;'></div>" 1140 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1 px;'></div>"
1072 " </div>" 1141 " </div>"
(...skipping 15 matching lines...) Expand all
1088 LayoutObject* c = document().getElementById("c")->layoutObject(); 1157 LayoutObject* c = document().getElementById("c")->layoutObject();
1089 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1 , 0.1)); 1158 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1 , 0.1));
1090 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); 1159 const ObjectPaintProperties* cProperties = c->objectPaintProperties();
1091 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset ); 1160 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset );
1092 // Visual rects via the non-paint properties system use enclosingIntRect bef ore applying transforms, 1161 // Visual rects via the non-paint properties system use enclosingIntRect bef ore applying transforms,
1093 // because they are computed bottom-up and therefore can't apply pixel snapp ing. Therefore apply a 1162 // because they are computed bottom-up and therefore can't apply pixel snapp ing. Therefore apply a
1094 // slop of 1px. 1163 // slop of 1px.
1095 CHECK_VISUAL_RECT(c, frameView->layoutView(), 1); 1164 CHECK_VISUAL_RECT(c, frameView->layoutView(), 1);
1096 } 1165 }
1097 1166
1098 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor m) 1167 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor m)
1099 { 1168 {
1100 setBodyInnerHTML( 1169 setBodyInnerHTML(
1101 "<style>" 1170 "<style>"
1102 " * { margin: 0; }" 1171 " * { margin: 0; }"
1103 " div { position: relative; }" 1172 " div { position: relative; }"
1104 "</style>" 1173 "</style>"
1105 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;' >" 1174 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;' >"
1106 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 );'>" 1175 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 );'>"
1107 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7 px;'></div>" 1176 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7 px;'></div>"
1108 " </div>" 1177 " </div>"
(...skipping 15 matching lines...) Expand all
1124 LayoutObject* c = document().getElementById("c")->layoutObject(); 1193 LayoutObject* c = document().getElementById("c")->layoutObject();
1125 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0.7)); 1194 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0.7));
1126 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); 1195 const ObjectPaintProperties* cProperties = c->objectPaintProperties();
1127 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset ); 1196 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset );
1128 // Visual rects via the non-paint properties system use enclosingIntRect bef ore applying transforms, 1197 // Visual rects via the non-paint properties system use enclosingIntRect bef ore applying transforms,
1129 // because they are computed bottom-up and therefore can't apply pixel snapp ing. Therefore apply a 1198 // because they are computed bottom-up and therefore can't apply pixel snapp ing. Therefore apply a
1130 // slop of 1px. 1199 // slop of 1px.
1131 CHECK_VISUAL_RECT(c, frameView->layoutView(), 1); 1200 CHECK_VISUAL_RECT(c, frameView->layoutView(), 1);
1132 } 1201 }
1133 1202
1134 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple Transforms) 1203 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple Transforms)
1135 { 1204 {
1136 setBodyInnerHTML( 1205 setBodyInnerHTML(
1137 "<style>" 1206 "<style>"
1138 " * { margin: 0; }" 1207 " * { margin: 0; }"
1139 " div { position: relative; }" 1208 " div { position: relative; }"
1140 "</style>" 1209 "</style>"
1141 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;' >" 1210 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;' >"
1142 " <div id='b' style='width: 40px; height: 40px; transform: translate3d( 5px, 7px, 0);'>" 1211 " <div id='b' style='width: 40px; height: 40px; transform: translate3d( 5px, 7px, 0);'>"
1143 " <div id='c' style='width: 40px; height: 40px; transform: translate3 d(11px, 13px, 0);'>" 1212 " <div id='c' style='width: 40px; height: 40px; transform: translate3 d(11px, 13px, 0);'>"
1144 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0 .7px;'></div>" 1213 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0 .7px;'></div>"
(...skipping 27 matching lines...) Expand all
1172 LayoutObject* d = document().getElementById("d")->layoutObject(); 1241 LayoutObject* d = document().getElementById("d")->layoutObject();
1173 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0.7)); 1242 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0.7));
1174 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); 1243 const ObjectPaintProperties* dProperties = d->objectPaintProperties();
1175 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset ); 1244 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset );
1176 // Visual rects via the non-paint properties system use enclosingIntRect bef ore applying transforms, 1245 // Visual rects via the non-paint properties system use enclosingIntRect bef ore applying transforms,
1177 // because they are computed bottom-up and therefore can't apply pixel snapp ing. Therefore apply a 1246 // because they are computed bottom-up and therefore can't apply pixel snapp ing. Therefore apply a
1178 // slop of 1px. 1247 // slop of 1px.
1179 CHECK_VISUAL_RECT(d, frameView->layoutView(), 1); 1248 CHECK_VISUAL_RECT(d, frameView->layoutView(), 1);
1180 } 1249 }
1181 1250
1182 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) 1251 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos)
1183 { 1252 {
1184 setBodyInnerHTML( 1253 setBodyInnerHTML(
1185 "<style>" 1254 "<style>"
1186 " * { margin: 0; }" 1255 " * { margin: 0; }"
1187 "</style>" 1256 "</style>"
1188 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re lative;'>" 1257 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re lative;'>"
1189 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 ); position: relative;'>" 1258 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 ); position: relative;'>"
1190 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;' >" 1259 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;' >"
1191 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi on: relative;'></div>" 1260 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi on: relative;'></div>"
1192 " </div>" 1261 " </div>"
(...skipping 22 matching lines...) Expand all
1215 LayoutObject* d = document().getElementById("d")->layoutObject(); 1284 LayoutObject* d = document().getElementById("d")->layoutObject();
1216 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0)); 1285 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0));
1217 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); 1286 const ObjectPaintProperties* dProperties = d->objectPaintProperties();
1218 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset ); 1287 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset );
1219 // Visual rects via the non-paint properties system use enclosingIntRect bef ore applying transforms, 1288 // Visual rects via the non-paint properties system use enclosingIntRect bef ore applying transforms,
1220 // because they are computed bottom-up and therefore can't apply pixel snapp ing. Therefore apply a 1289 // because they are computed bottom-up and therefore can't apply pixel snapp ing. Therefore apply a
1221 // slop of 1px. 1290 // slop of 1px.
1222 CHECK_VISUAL_RECT(d, frameView->layoutView(), 1); 1291 CHECK_VISUAL_RECT(d, frameView->layoutView(), 1);
1223 } 1292 }
1224 1293
1225 TEST_F(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) 1294 TEST_P(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset)
1226 { 1295 {
1227 setBodyInnerHTML( 1296 setBodyInnerHTML(
1228 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix (1, 0, 0, 1, 0, 0);'>" 1297 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix (1, 0, 0, 1, 0, 0);'>"
1229 " <rect id='rect' transform='translate(1, 1)'/>" 1298 " <rect id='rect' transform='translate(1, 1)'/>"
1230 "</svg>"); 1299 "</svg>");
1231 1300
1232 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb ject(); 1301 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb ject();
1233 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o bjectPaintProperties(); 1302 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o bjectPaintProperties();
1234 EXPECT_EQ(TransformationMatrix(), svgWithTransformProperties->transform()->m atrix()); 1303 EXPECT_EQ(TransformationMatrix(), svgWithTransformProperties->transform()->m atrix());
1235 EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), svgWithTransformProperties->local BorderBoxProperties()->paintOffset); 1304 EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), svgWithTransformProperties->local BorderBoxProperties()->paintOffset);
1236 EXPECT_EQ(nullptr, svgWithTransformProperties->svgLocalToBorderBoxTransform( )); 1305 EXPECT_EQ(nullptr, svgWithTransformProperties->svgLocalToBorderBoxTransform( ));
1237 1306
1238 LayoutObject& rectWithTransform = *document().getElementById("rect")->layout Object(); 1307 LayoutObject& rectWithTransform = *document().getElementById("rect")->layout Object();
1239 const ObjectPaintProperties* rectWithTransformProperties = rectWithTransform .objectPaintProperties(); 1308 const ObjectPaintProperties* rectWithTransformProperties = rectWithTransform .objectPaintProperties();
1240 EXPECT_EQ(TransformationMatrix().translate(1, 1), rectWithTransformPropertie s->transform()->matrix()); 1309 EXPECT_EQ(TransformationMatrix().translate(1, 1), rectWithTransformPropertie s->transform()->matrix());
1241 1310
1242 // Ensure there is no PaintOffset transform between the rect and the svg's t ransform. 1311 // Ensure there is no PaintOffset transform between the rect and the svg's t ransform.
1243 EXPECT_EQ(svgWithTransformProperties->transform(), rectWithTransformProperti es->transform()->parent()); 1312 EXPECT_EQ(svgWithTransformProperties->transform(), rectWithTransformProperti es->transform()->parent());
1244 } 1313 }
1245 1314
1246 TEST_F(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) 1315 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault)
1247 { 1316 {
1248 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>"); 1317 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>");
1249 1318
1250 const ObjectPaintProperties* properties = document().body()->firstChild()->l ayoutObject()->objectPaintProperties(); 1319 const ObjectPaintProperties* properties = document().body()->firstChild()->l ayoutObject()->objectPaintProperties();
1251 ASSERT_TRUE(properties->transform()); 1320 ASSERT_TRUE(properties->transform());
1252 EXPECT_FALSE(properties->transform()->hasRenderingContext()); 1321 EXPECT_FALSE(properties->transform()->hasRenderingContext());
1253 } 1322 }
1254 1323
1255 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext) 1324 TEST_P(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext)
1256 { 1325 {
1257 setBodyInnerHTML( 1326 setBodyInnerHTML(
1258 "<div style='transform-style: preserve-3d'>" 1327 "<div style='transform-style: preserve-3d'>"
1259 " <div id='a' style='transform: translateZ(0); width: 30px; height: 40p x'></div>" 1328 " <div id='a' style='transform: translateZ(0); width: 30px; height: 40p x'></div>"
1260 " <div id='b' style='transform: translateZ(0); width: 20px; height: 10p x'></div>" 1329 " <div id='b' style='transform: translateZ(0); width: 20px; height: 10p x'></div>"
1261 "</div>"); 1330 "</div>");
1262 FrameView* frameView = document().view(); 1331 FrameView* frameView = document().view();
1263 1332
1264 LayoutObject* a = document().getElementById("a")->layoutObject(); 1333 LayoutObject* a = document().getElementById("a")->layoutObject();
1265 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); 1334 const ObjectPaintProperties* aProperties = a->objectPaintProperties();
1266 LayoutObject* b = document().getElementById("b")->layoutObject(); 1335 LayoutObject* b = document().getElementById("b")->layoutObject();
1267 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); 1336 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1268 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); 1337 ASSERT_TRUE(aProperties->transform() && bProperties->transform());
1269 EXPECT_NE(aProperties->transform(), bProperties->transform()); 1338 EXPECT_NE(aProperties->transform(), bProperties->transform());
1270 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); 1339 EXPECT_TRUE(aProperties->transform()->hasRenderingContext());
1271 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); 1340 EXPECT_TRUE(bProperties->transform()->hasRenderingContext());
1272 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans form()->renderingContextID()); 1341 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans form()->renderingContextID());
1273 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); 1342 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView());
1274 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); 1343 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView());
1275 } 1344 }
1276 1345
1277 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) 1346 TEST_P(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext)
1278 { 1347 {
1279 setBodyInnerHTML( 1348 setBodyInnerHTML(
1280 "<div style='transform-style: preserve-3d'>" 1349 "<div style='transform-style: preserve-3d'>"
1281 " <div id='a' style='transform: translateZ(0); width: 30px; height: 40p x'>" 1350 " <div id='a' style='transform: translateZ(0); width: 30px; height: 40p x'>"
1282 " <div id='b' style='transform: translateZ(0); width: 10px; height: 2 0px'></div>" 1351 " <div id='b' style='transform: translateZ(0); width: 10px; height: 2 0px'></div>"
1283 " </div>" 1352 " </div>"
1284 "</div>"); 1353 "</div>");
1285 FrameView* frameView = document().view(); 1354 FrameView* frameView = document().view();
1286 1355
1287 LayoutObject* a = document().getElementById("a")->layoutObject(); 1356 LayoutObject* a = document().getElementById("a")->layoutObject();
1288 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); 1357 const ObjectPaintProperties* aProperties = a->objectPaintProperties();
1289 LayoutObject* b = document().getElementById("b")->layoutObject(); 1358 LayoutObject* b = document().getElementById("b")->layoutObject();
1290 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); 1359 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1291 ASSERT_FALSE(a->styleRef().preserves3D()); 1360 ASSERT_FALSE(a->styleRef().preserves3D());
1292 1361
1293 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); 1362 ASSERT_TRUE(aProperties->transform() && bProperties->transform());
1294 1363
1295 // #a should participate in a rendering context (due to its parent), but its 1364 // #a should participate in a rendering context (due to its parent), but its
1296 // child #b should not. 1365 // child #b should not.
1297 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); 1366 EXPECT_TRUE(aProperties->transform()->hasRenderingContext());
1298 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); 1367 EXPECT_FALSE(bProperties->transform()->hasRenderingContext());
1299 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); 1368 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView());
1300 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); 1369 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView());
1301 } 1370 }
1302 1371
1303 TEST_F(PaintPropertyTreeBuilderTest, NestedRenderingContexts) 1372 TEST_P(PaintPropertyTreeBuilderTest, NestedRenderingContexts)
1304 { 1373 {
1305 setBodyInnerHTML( 1374 setBodyInnerHTML(
1306 "<div style='transform-style: preserve-3d'>" 1375 "<div style='transform-style: preserve-3d'>"
1307 " <div id='a' style='transform: translateZ(0); width: 50px; height: 60p x'>" 1376 " <div id='a' style='transform: translateZ(0); width: 50px; height: 60p x'>"
1308 " <div style='transform-style: preserve-3d; width: 30px; height: 40px '>" 1377 " <div style='transform-style: preserve-3d; width: 30px; height: 40px '>"
1309 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20px'>" 1378 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20px'>"
1310 " </div>" 1379 " </div>"
1311 " </div>" 1380 " </div>"
1312 "</div>"); 1381 "</div>");
1313 FrameView* frameView = document().view(); 1382 FrameView* frameView = document().view();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 static bool someNodeFlattensTransform(const TransformPaintPropertyNode* node, co nst TransformPaintPropertyNode* ancestor) 1415 static bool someNodeFlattensTransform(const TransformPaintPropertyNode* node, co nst TransformPaintPropertyNode* ancestor)
1347 { 1416 {
1348 while (node != ancestor) { 1417 while (node != ancestor) {
1349 if (node->flattensInheritedTransform()) 1418 if (node->flattensInheritedTransform())
1350 return true; 1419 return true;
1351 node = node->parent(); 1420 node = node->parent();
1352 } 1421 }
1353 return false; 1422 return false;
1354 } 1423 }
1355 1424
1356 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStylePropagatesToChildren) 1425 TEST_P(PaintPropertyTreeBuilderTest, FlatTransformStylePropagatesToChildren)
1357 { 1426 {
1358 setBodyInnerHTML( 1427 setBodyInnerHTML(
1359 "<div id='a' style='transform: translateZ(0); transform-style: flat; wid th: 30px; height: 40px'>" 1428 "<div id='a' style='transform: translateZ(0); transform-style: flat; wid th: 30px; height: 40px'>"
1360 " <div id='b' style='transform: translateZ(0); width: 10px; height: 10p x'></div>" 1429 " <div id='b' style='transform: translateZ(0); width: 10px; height: 10p x'></div>"
1361 "</div>"); 1430 "</div>");
1362 FrameView* frameView = document().view(); 1431 FrameView* frameView = document().view();
1363 1432
1364 LayoutObject* a = document().getElementById("a")->layoutObject(); 1433 LayoutObject* a = document().getElementById("a")->layoutObject();
1365 LayoutObject* b = document().getElementById("b")->layoutObject(); 1434 LayoutObject* b = document().getElementById("b")->layoutObject();
1366 const auto* aTransform = a->objectPaintProperties()->transform(); 1435 const auto* aTransform = a->objectPaintProperties()->transform();
1367 ASSERT_TRUE(aTransform); 1436 ASSERT_TRUE(aTransform);
1368 const auto* bTransform = b->objectPaintProperties()->transform(); 1437 const auto* bTransform = b->objectPaintProperties()->transform();
1369 ASSERT_TRUE(bTransform); 1438 ASSERT_TRUE(bTransform);
1370 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); 1439 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform));
1371 1440
1372 // Some node must flatten the inherited transform from #a before it reaches 1441 // Some node must flatten the inherited transform from #a before it reaches
1373 // #b's transform. 1442 // #b's transform.
1374 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform)); 1443 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform));
1375 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); 1444 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView());
1376 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); 1445 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView());
1377 } 1446 }
1378 1447
1379 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DTransformStylePropagatesToChildre n) 1448 TEST_P(PaintPropertyTreeBuilderTest, Preserve3DTransformStylePropagatesToChildre n)
1380 { 1449 {
1381 setBodyInnerHTML( 1450 setBodyInnerHTML(
1382 "<div id='a' style='transform: translateZ(0); transform-style: preserve- 3d; width: 30px; height: 40px'>" 1451 "<div id='a' style='transform: translateZ(0); transform-style: preserve- 3d; width: 30px; height: 40px'>"
1383 " <div id='b' style='transform: translateZ(0); width: 10px; height: 10p x'></div>" 1452 " <div id='b' style='transform: translateZ(0); width: 10px; height: 10p x'></div>"
1384 "</div>"); 1453 "</div>");
1385 FrameView* frameView = document().view(); 1454 FrameView* frameView = document().view();
1386 1455
1387 LayoutObject* a = document().getElementById("a")->layoutObject(); 1456 LayoutObject* a = document().getElementById("a")->layoutObject();
1388 LayoutObject* b = document().getElementById("b")->layoutObject(); 1457 LayoutObject* b = document().getElementById("b")->layoutObject();
1389 const auto* aTransform = a->objectPaintProperties()->transform(); 1458 const auto* aTransform = a->objectPaintProperties()->transform();
1390 ASSERT_TRUE(aTransform); 1459 ASSERT_TRUE(aTransform);
1391 const auto* bTransform = b->objectPaintProperties()->transform(); 1460 const auto* bTransform = b->objectPaintProperties()->transform();
1392 ASSERT_TRUE(bTransform); 1461 ASSERT_TRUE(bTransform);
1393 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); 1462 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform));
1394 1463
1395 // No node may flatten the inherited transform from #a before it reaches 1464 // No node may flatten the inherited transform from #a before it reaches
1396 // #b's transform. 1465 // #b's transform.
1397 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform)); 1466 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform));
1398 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); 1467 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView());
1399 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); 1468 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView());
1400 } 1469 }
1401 1470
1402 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) 1471 TEST_P(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened)
1403 { 1472 {
1404 // It's necessary to make nodes from the one that applies perspective to 1473 // It's necessary to make nodes from the one that applies perspective to
1405 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't 1474 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't
1406 // do anything. 1475 // do anything.
1407 setBodyInnerHTML( 1476 setBodyInnerHTML(
1408 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" 1477 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>"
1409 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p x'></div>" 1478 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p x'></div>"
1410 "</div>"); 1479 "</div>");
1411 FrameView* frameView = document().view(); 1480 FrameView* frameView = document().view();
1412 1481
1413 LayoutObject* a = document().getElementById("a")->layoutObject(); 1482 LayoutObject* a = document().getElementById("a")->layoutObject();
1414 LayoutObject* b = document().getElementById("b")->layoutObject(); 1483 LayoutObject* b = document().getElementById("b")->layoutObject();
1415 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); 1484 const ObjectPaintProperties* aProperties = a->objectPaintProperties();
1416 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); 1485 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1417 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); 1486 const TransformPaintPropertyNode* aPerspective = aProperties->perspective();
1418 ASSERT_TRUE(aPerspective); 1487 ASSERT_TRUE(aPerspective);
1419 const TransformPaintPropertyNode* bTransform = bProperties->transform(); 1488 const TransformPaintPropertyNode* bTransform = bProperties->transform();
1420 ASSERT_TRUE(bTransform); 1489 ASSERT_TRUE(bTransform);
1421 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); 1490 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective));
1422 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); 1491 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective));
1423 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); 1492 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView());
1424 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); 1493 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView());
1425 } 1494 }
1426 1495
1427 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext ) 1496 TEST_P(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext )
1428 { 1497 {
1429 // It's necessary to make nodes from the one that applies perspective to 1498 // It's necessary to make nodes from the one that applies perspective to
1430 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't 1499 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't
1431 // do anything. 1500 // do anything.
1432 setBodyInnerHTML( 1501 setBodyInnerHTML(
1433 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" 1502 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>"
1434 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p x'></div>" 1503 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p x'></div>"
1435 "</div>"); 1504 "</div>");
1436 FrameView* frameView = document().view(); 1505 FrameView* frameView = document().view();
1437 1506
1438 LayoutObject* a = document().getElementById("a")->layoutObject(); 1507 LayoutObject* a = document().getElementById("a")->layoutObject();
1439 LayoutObject* b = document().getElementById("b")->layoutObject(); 1508 LayoutObject* b = document().getElementById("b")->layoutObject();
1440 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); 1509 const ObjectPaintProperties* aProperties = a->objectPaintProperties();
1441 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); 1510 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1442 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); 1511 const TransformPaintPropertyNode* aPerspective = aProperties->perspective();
1443 ASSERT_TRUE(aPerspective); 1512 ASSERT_TRUE(aPerspective);
1444 EXPECT_FALSE(aPerspective->hasRenderingContext()); 1513 EXPECT_FALSE(aPerspective->hasRenderingContext());
1445 const TransformPaintPropertyNode* bTransform = bProperties->transform(); 1514 const TransformPaintPropertyNode* bTransform = bProperties->transform();
1446 ASSERT_TRUE(bTransform); 1515 ASSERT_TRUE(bTransform);
1447 EXPECT_FALSE(bTransform->hasRenderingContext()); 1516 EXPECT_FALSE(bTransform->hasRenderingContext());
1448 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); 1517 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView());
1449 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); 1518 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView());
1450 } 1519 }
1451 1520
1452 TEST_F(PaintPropertyTreeBuilderTest, CachedProperties) 1521 TEST_P(PaintPropertyTreeBuilderTest, CachedProperties)
1453 { 1522 {
1454 setBodyInnerHTML( 1523 setBodyInnerHTML(
1455 "<div id='a' style='transform: translate(33px, 44px); width: 50px; heigh t: 60px'>" 1524 "<div id='a' style='transform: translate(33px, 44px); width: 50px; heigh t: 60px'>"
1456 " <div id='b' style='transform: translate(55px, 66px); width: 30px; hei ght: 40px'>" 1525 " <div id='b' style='transform: translate(55px, 66px); width: 30px; hei ght: 40px'>"
1457 " <div id='c' style='transform: translate(77px, 88px); width: 10px; h eight: 20px'>C<div>" 1526 " <div id='c' style='transform: translate(77px, 88px); width: 10px; h eight: 20px'>C<div>"
1458 " </div>" 1527 " </div>"
1459 "</div>"); 1528 "</div>");
1460 FrameView* frameView = document().view(); 1529 FrameView* frameView = document().view();
1461 1530
1462 Element* a = document().getElementById("a"); 1531 Element* a = document().getElementById("a");
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); 1603 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties());
1535 EXPECT_EQ(cTransformNode, cProperties->transform()); 1604 EXPECT_EQ(cTransformNode, cProperties->transform());
1536 EXPECT_EQ(bTransformNode, cTransformNode->parent()); 1605 EXPECT_EQ(bTransformNode, cTransformNode->parent());
1537 1606
1538 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); 1607 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView());
1539 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); 1608 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView());
1540 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); 1609 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView());
1541 } 1610 }
1542 1611
1543 } // namespace blink 1612 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698