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

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

Issue 2239443004: Add more unittesting for GeometryMapper+PaintPropertyTrreBuilde integration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/paint/PaintPropertyTreePrinter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // target1 is a fixed-position element inside an absolute-position scrolling element. 78 // target1 is a fixed-position element inside an absolute-position scrolling element.
79 // It should be attached under the viewport to skip scrolling and offset of the parent. 79 // It should be attached under the viewport to skip scrolling and offset of the parent.
80 Element* target1 = document().getElementById("target1"); 80 Element* target1 = document().getElementById("target1");
81 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob jectPaintProperties(); 81 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob jectPaintProperties();
82 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai ntOffsetTranslation()->matrix()); 82 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai ntOffsetTranslation()->matrix());
83 EXPECT_EQ(frameView->preTranslation(), target1Properties->paintOffsetTransla tion()->parent()); 83 EXPECT_EQ(frameView->preTranslation(), target1Properties->paintOffsetTransla tion()->parent());
84 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov erflowClip()->localTransformSpace()); 84 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov erflowClip()->localTransformSpace());
85 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip( )->clipRect()); 85 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip( )->clipRect());
86 // Likewise, it inherits clip from the viewport, skipping overflow clip of t he scroller. 86 // Likewise, it inherits clip from the viewport, skipping overflow clip of t he scroller.
87 EXPECT_EQ(frameView->contentClip(), target1Properties->overflowClip()->paren t()); 87 EXPECT_EQ(frameView->contentClip(), target1Properties->overflowClip()->paren t());
88 CHECK_VISUAL_RECT(target1->layoutObject(), frameView->layoutView());
88 89
89 // target2 is a fixed-position element inside a transformed scrolling elemen t. 90 // target2 is a fixed-position element inside a transformed scrolling elemen t.
90 // It should be attached under the scrolled box of the transformed element. 91 // It should be attached under the scrolled box of the transformed element.
91 Element* target2 = document().getElementById("target2"); 92 Element* target2 = document().getElementById("target2");
92 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob jectPaintProperties(); 93 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob jectPaintProperties();
93 Element* scroller = document().getElementById("scroller"); 94 Element* scroller = document().getElementById("scroller");
94 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties(); 95 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties();
95 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai ntOffsetTranslation()->matrix()); 96 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai ntOffsetTranslation()->matrix());
96 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO ffsetTranslation()->parent()); 97 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO ffsetTranslation()->parent());
97 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov erflowClip()->localTransformSpace()); 98 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov erflowClip()->localTransformSpace());
98 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip( )->clipRect()); 99 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip( )->clipRect());
99 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli p()->parent()); 100 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli p()->parent());
100
101 CHECK_VISUAL_RECT(target1->layoutObject(), frameView->layoutView());
102 CHECK_VISUAL_RECT(target2->layoutObject(), frameView->layoutView()); 101 CHECK_VISUAL_RECT(target2->layoutObject(), frameView->layoutView());
103 } 102 }
104 103
105 TEST_F(PaintPropertyTreeBuilderTest, PositionAndScroll) 104 TEST_F(PaintPropertyTreeBuilderTest, PositionAndScroll)
106 { 105 {
107 loadTestData("position-and-scroll.html"); 106 loadTestData("position-and-scroll.html");
108 107
109 Element* scroller = document().getElementById("scroller"); 108 Element* scroller = document().getElementById("scroller");
110 scroller->scrollTo(0, 100); 109 scroller->scrollTo(0, 100);
111 FrameView* frameView = document().view(); 110 FrameView* frameView = document().view();
112 frameView->updateAllLifecyclePhases(); 111 frameView->updateAllLifecyclePhases();
113 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties(); 112 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties();
114 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr ollTranslation()->matrix()); 113 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr ollTranslation()->matrix());
115 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat ion()->parent()); 114 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat ion()->parent());
116 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->overflowClip() ->localTransformSpace()); 115 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->overflowClip() ->localTransformSpace());
117 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow Clip()->clipRect()); 116 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow Clip()->clipRect());
118 EXPECT_EQ(frameView->contentClip(), scrollerProperties->overflowClip()->pare nt()); 117 EXPECT_EQ(frameView->contentClip(), scrollerProperties->overflowClip()->pare nt());
118 CHECK_VISUAL_RECT(scroller->layoutObject(), frameView->layoutView());
119 119
120 // The relative-positioned element should have accumulated box offset (exclu de scrolling), 120 // The relative-positioned element should have accumulated box offset (exclu de scrolling),
121 // and should be affected by ancestor scroll transforms. 121 // and should be affected by ancestor scroll transforms.
122 Element* relPos = document().getElementById("rel-pos"); 122 Element* relPos = document().getElementById("rel-pos");
123 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje ctPaintProperties(); 123 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje ctPaintProperties();
124 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai ntOffsetTranslation()->matrix()); 124 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai ntOffsetTranslation()->matrix());
125 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf fsetTranslation()->parent()); 125 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf fsetTranslation()->parent());
126 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l ocalTransformSpace()); 126 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l ocalTransformSpace());
127 EXPECT_EQ(FloatRoundedRect(0, 0, 400, 0), relPosProperties->overflowClip()-> clipRect()); 127 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), relPosProperties->overflowClip() ->clipRect());
128 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip ()->parent()); 128 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip ()->parent());
129 CHECK_VISUAL_RECT(relPos->layoutObject(), frameView->layoutView());
129 130
130 // The absolute-positioned element should not be affected by non-positioned scroller at all. 131 // The absolute-positioned element should not be affected by non-positioned scroller at all.
131 Element* absPos = document().getElementById("abs-pos"); 132 Element* absPos = document().getElementById("abs-pos");
132 const ObjectPaintProperties* absPosProperties = absPos->layoutObject()->obje ctPaintProperties(); 133 const ObjectPaintProperties* absPosProperties = absPos->layoutObject()->obje ctPaintProperties();
133 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain tOffsetTranslation()->matrix()); 134 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain tOffsetTranslation()->matrix());
134 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans lation()->parent()); 135 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans lation()->parent());
135 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l ocalTransformSpace()); 136 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l ocalTransformSpace());
136 EXPECT_EQ(FloatRoundedRect(), absPosProperties->overflowClip()->clipRect()); 137 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), absPosProperties->overflowClip() ->clipRect());
137 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent ()); 138 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent ());
139 CHECK_VISUAL_RECT(absPos->layoutObject(), frameView->layoutView());
138 } 140 }
139 141
140 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) 142 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional)
141 { 143 {
142 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); 144 setBodyInnerHTML("<style> body { height: 10000px; } </style>");
143 145
144 document().domWindow()->scrollTo(0, 100); 146 document().domWindow()->scrollTo(0, 100);
145 147
146 FrameView* frameView = document().view(); 148 FrameView* frameView = document().view();
147 frameView->updateAllLifecyclePhases(); 149 frameView->updateAllLifecyclePhases();
148 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); 150 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix());
149 EXPECT_EQ(frameView->rootTransform(), frameView->preTranslation()->parent()) ; 151 EXPECT_EQ(frameView->rootTransform(), frameView->preTranslation()->parent()) ;
150 EXPECT_EQ(nullptr, frameView->rootTransform()->parent()); 152 EXPECT_EQ(nullptr, frameView->rootTransform()->parent());
151 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl ation()->matrix()); 153 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl ation()->matrix());
152 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t()); 154 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t());
153 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf ormSpace()); 155 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf ormSpace());
154 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe ct()); 156 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe ct());
155 EXPECT_EQ(frameView->rootClip(), frameView->contentClip()->parent()); 157 EXPECT_EQ(frameView->rootClip(), frameView->contentClip()->parent());
156 EXPECT_EQ(nullptr, frameView->rootClip()->parent()); 158 EXPECT_EQ(nullptr, frameView->rootClip()->parent());
157 159
158 LayoutViewItem layoutViewItem = document().layoutViewItem(); 160 LayoutViewItem layoutViewItem = document().layoutViewItem();
159 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai ntProperties(); 161 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai ntProperties();
160 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); 162 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation());
163 CHECK_VISUAL_RECT(document().body()->layoutObject(), frameView->layoutView() );
161 } 164 }
162 165
163 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame being created. 166 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame being created.
164 // Need to set it during test setup. Besides that, the test still won't work bec ause 167 // Need to set it during test setup. Besides that, the test still won't work bec ause
165 // root layer scrolling mode is not compatible with SPv2 at this moment. 168 // root layer scrolling mode is not compatible with SPv2 at this moment.
166 // (Duplicate display item ID for FrameView and LayoutView.) 169 // (Duplicate display item ID for FrameView and LayoutView.)
167 TEST_F(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls) 170 TEST_F(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls)
168 { 171 {
169 document().settings()->setRootLayerScrolls(true); 172 document().settings()->setRootLayerScrolls(true);
170 173
171 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); 174 setBodyInnerHTML("<style> body { height: 10000px; } </style>");
172 175
173 document().domWindow()->scrollTo(0, 100); 176 document().domWindow()->scrollTo(0, 100);
174 177
175 FrameView* frameView = document().view(); 178 FrameView* frameView = document().view();
176 frameView->updateAllLifecyclePhases(); 179 frameView->updateAllLifecyclePhases();
177 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); 180 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix());
178 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); 181 EXPECT_EQ(nullptr, frameView->preTranslation()->parent());
179 EXPECT_EQ(TransformationMatrix(), frameView->scrollTranslation()->matrix()); 182 EXPECT_EQ(TransformationMatrix(), frameView->scrollTranslation()->matrix());
180 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t()); 183 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t());
181 184
182 LayoutViewItem layoutViewItem = document().layoutViewItem(); 185 LayoutViewItem layoutViewItem = document().layoutViewItem();
183 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai ntProperties(); 186 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai ntProperties();
184 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s crollTranslation()->matrix()); 187 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s crollTranslation()->matrix());
185 EXPECT_EQ(frameView->scrollTranslation(), layoutViewProperties->scrollTransl ation()->parent()); 188 EXPECT_EQ(frameView->scrollTranslation(), layoutViewProperties->scrollTransl ation()->parent());
189 CHECK_VISUAL_RECT(document().body()->layoutObject(), frameView->layoutView() );
186 } 190 }
187 191
188 TEST_F(PaintPropertyTreeBuilderTest, Perspective) 192 TEST_F(PaintPropertyTreeBuilderTest, Perspective)
189 { 193 {
190 loadTestData("perspective.html"); 194 loadTestData("perspective.html");
191 195
192 Element* perspective = document().getElementById("perspective"); 196 Element* perspective = document().getElementById("perspective");
193 const ObjectPaintProperties* perspectiveProperties = perspective->layoutObje ct()->objectPaintProperties(); 197 const ObjectPaintProperties* perspectiveProperties = perspective->layoutObje ct()->objectPaintProperties();
194 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie s->perspective()->matrix()); 198 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie s->perspective()->matrix());
195 // The perspective origin is the center of the border box plus accumulated p aint offset. 199 // The perspective origin is the center of the border box plus accumulated p aint offset.
196 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o rigin()); 200 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o rigin());
197 EXPECT_EQ(document().view()->scrollTranslation(), perspectiveProperties->per spective()->parent()); 201 EXPECT_EQ(document().view()->scrollTranslation(), perspectiveProperties->per spective()->parent());
198 202
199 // Adding perspective doesn't clear paint offset. The paint offset will be p assed down to children. 203 // Adding perspective doesn't clear paint offset. The paint offset will be p assed down to children.
200 Element* inner = document().getElementById("inner"); 204 Element* inner = document().getElementById("inner");
201 const ObjectPaintProperties* innerProperties = inner->layoutObject()->object PaintProperties(); 205 const ObjectPaintProperties* innerProperties = inner->layoutObject()->object PaintProperties();
202 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO ffsetTranslation()->matrix()); 206 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO ffsetTranslation()->matrix());
203 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset Translation()->parent()); 207 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset Translation()->parent());
208 CHECK_VISUAL_RECT(inner->layoutObject(), document().view()->layoutView());
204 } 209 }
205 210
206 TEST_F(PaintPropertyTreeBuilderTest, Transform) 211 TEST_F(PaintPropertyTreeBuilderTest, Transform)
207 { 212 {
208 loadTestData("transform.html"); 213 loadTestData("transform.html");
209 214
210 Element* transform = document().getElementById("transform"); 215 Element* transform = document().getElementById("transform");
211 const ObjectPaintProperties* transformProperties = transform->layoutObject() ->objectPaintProperties(); 216 const ObjectPaintProperties* transformProperties = transform->layoutObject() ->objectPaintProperties();
212 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper ties->transform()->matrix()); 217 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper ties->transform()->matrix());
213 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi n()); 218 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi n());
214 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties ->transform()->parent()); 219 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties ->transform()->parent());
215 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa intOffsetTranslation()->matrix()); 220 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa intOffsetTranslation()->matrix());
216 EXPECT_EQ(document().view()->scrollTranslation(), transformProperties->paint OffsetTranslation()->parent()); 221 EXPECT_EQ(document().view()->scrollTranslation(), transformProperties->paint OffsetTranslation()->parent());
222 CHECK_VISUAL_RECT(transform->layoutObject(), document().view()->layoutView() );
217 } 223 }
218 224
219 TEST_F(PaintPropertyTreeBuilderTest, RelativePositionInline) 225 TEST_F(PaintPropertyTreeBuilderTest, RelativePositionInline)
220 { 226 {
221 loadTestData("relative-position-inline.html"); 227 loadTestData("relative-position-inline.html");
222 228
223 Element* inlineBlock = document().getElementById("inline-block"); 229 Element* inlineBlock = document().getElementById("inline-block");
224 const ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObje ct()->objectPaintProperties(); 230 const ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObje ct()->objectPaintProperties();
225 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties- >paintOffsetTranslation()->matrix()); 231 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties- >paintOffsetTranslation()->matrix());
226 EXPECT_EQ(document().view()->scrollTranslation(), inlineBlockProperties->pai ntOffsetTranslation()->parent()); 232 EXPECT_EQ(document().view()->scrollTranslation(), inlineBlockProperties->pai ntOffsetTranslation()->parent());
233 CHECK_VISUAL_RECT(inlineBlock->layoutObject(), document().view()->layoutView ());
227 } 234 }
228 235
229 TEST_F(PaintPropertyTreeBuilderTest, NestedOpacityEffect) 236 TEST_F(PaintPropertyTreeBuilderTest, NestedOpacityEffect)
230 { 237 {
231 setBodyInnerHTML( 238 setBodyInnerHTML(
232 "<div id='nodeWithoutOpacity'>" 239 "<div id='nodeWithoutOpacity' style='width: 100px; height: 200px'>"
233 " <div id='childWithOpacity' style='opacity: 0.5'>" 240 " <div id='childWithOpacity' style='opacity: 0.5; width: 50px; height: 60px;'>"
234 " <div id='grandChildWithoutOpacity'>" 241 " <div id='grandChildWithoutOpacity' style='width: 20px; height: 30px '>"
235 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2'/>" 242 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2; width: 10px; height: 15px'/>"
236 " </div>" 243 " </div>"
237 " </div>" 244 " </div>"
238 "</div>"); 245 "</div>");
239 246
240 LayoutObject& nodeWithoutOpacity = *document().getElementById("nodeWithoutOp acity")->layoutObject(); 247 LayoutObject* nodeWithoutOpacity = document().getElementById("nodeWithoutOpa city")->layoutObject();
241 const ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpaci ty.objectPaintProperties(); 248 const ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpaci ty->objectPaintProperties();
242 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); 249 EXPECT_NE(nullptr, nodeWithoutOpacityProperties);
250 CHECK_VISUAL_RECT(nodeWithoutOpacity, document().view()->layoutView());
243 251
244 LayoutObject& childWithOpacity = *document().getElementById("childWithOpacit y")->layoutObject(); 252 LayoutObject* childWithOpacity = document().getElementById("childWithOpacity ")->layoutObject();
245 const ObjectPaintProperties* childWithOpacityProperties = childWithOpacity.o bjectPaintProperties(); 253 const ObjectPaintProperties* childWithOpacityProperties = childWithOpacity-> objectPaintProperties();
246 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); 254 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity());
247 // childWithOpacity is the root effect node. 255 // childWithOpacity is the root effect node.
248 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); 256 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent());
257 CHECK_VISUAL_RECT(childWithOpacity, document().view()->layoutView());
249 258
250 LayoutObject& grandChildWithoutOpacity = *document().getElementById("grandCh ildWithoutOpacity")->layoutObject(); 259 LayoutObject* grandChildWithoutOpacity = document().getElementById("grandChi ldWithoutOpacity")->layoutObject();
251 EXPECT_NE(nullptr, grandChildWithoutOpacity.objectPaintProperties()); 260 EXPECT_NE(nullptr, grandChildWithoutOpacity->objectPaintProperties());
261 CHECK_VISUAL_RECT(grandChildWithoutOpacity, document().view()->layoutView()) ;
252 262
253 LayoutObject& greatGrandChildWithOpacity = *document().getElementById("great GrandChildWithOpacity")->layoutObject(); 263 LayoutObject* greatGrandChildWithOpacity = document().getElementById("greatG randChildWithOpacity")->layoutObject();
254 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGra ndChildWithOpacity.objectPaintProperties(); 264 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGra ndChildWithOpacity->objectPaintProperties();
255 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); 265 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity());
256 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr operties->effect()->parent()); 266 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr operties->effect()->parent());
267 CHECK_VISUAL_RECT(greatGrandChildWithOpacity, document().view()->layoutView( ));
257 } 268 }
258 269
259 TEST_F(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) 270 TEST_F(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes)
260 { 271 {
261 setBodyInnerHTML( 272 setBodyInnerHTML(
262 "<div id='nodeWithOpacity' style='opacity: 0.6'>" 273 "<div id='nodeWithOpacity' style='opacity: 0.6' style='width: 100px; hei ght: 200px'>"
263 " <div id='childWithTransform' style='transform: translate3d(10px, 10px , 0px);'>" 274 " <div id='childWithTransform' style='transform: translate3d(10px, 10px , 0px); width: 50px; height: 60px;'>"
264 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" 275 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h eight: 30px'/>"
265 " </div>" 276 " </div>"
266 "</div>"); 277 "</div>");
267 278
268 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity" )->layoutObject(); 279 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity") ->layoutObject();
269 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.obj ectPaintProperties(); 280 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob jectPaintProperties();
270 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); 281 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity());
271 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); 282 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent());
272 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); 283 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform());
284 CHECK_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView());
273 285
274 LayoutObject& childWithTransform = *document().getElementById("childWithTran sform")->layoutObject(); 286 LayoutObject* childWithTransform = document().getElementById("childWithTrans form")->layoutObject();
275 const ObjectPaintProperties* childWithTransformProperties = childWithTransfo rm.objectPaintProperties(); 287 const ObjectPaintProperties* childWithTransformProperties = childWithTransfo rm->objectPaintProperties();
276 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); 288 EXPECT_EQ(nullptr, childWithTransformProperties->effect());
277 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper ties->transform()->matrix()); 289 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper ties->transform()->matrix());
290 CHECK_VISUAL_RECT(childWithTransform, document().view()->layoutView());
278 291
279 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild WithOpacity")->layoutObject(); 292 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW ithOpacity")->layoutObject();
280 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit hOpacity.objectPaintProperties(); 293 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit hOpacity->objectPaintProperties();
281 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); 294 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity());
282 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent()); 295 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent());
283 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); 296 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform());
297 CHECK_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView());
284 } 298 }
285 299
286 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) 300 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext)
287 { 301 {
288 setBodyInnerHTML( 302 setBodyInnerHTML(
289 "<div id='nodeWithOpacity' style='opacity: 0.6'>" 303 "<div id='nodeWithOpacity' style='opacity: 0.6; width: 100px; height: 20 0px'>"
290 " <div id='childWithStackingContext' style='position:absolute;'>" 304 " <div id='childWithStackingContext' style='position:absolute; width: 5 0px; height: 60px;'>"
291 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" 305 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h eight: 30px'/>"
292 " </div>" 306 " </div>"
293 "</div>"); 307 "</div>");
294 308
295 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity" )->layoutObject(); 309 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity") ->layoutObject();
296 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.obj ectPaintProperties(); 310 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob jectPaintProperties();
297 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); 311 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity());
298 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); 312 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent());
299 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); 313 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform());
314 CHECK_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView());
300 315
301 LayoutObject& childWithStackingContext = *document().getElementById("childWi thStackingContext")->layoutObject(); 316 LayoutObject* childWithStackingContext = document().getElementById("childWit hStackingContext")->layoutObject();
302 const ObjectPaintProperties* childWithStackingContextProperties = childWithS tackingContext.objectPaintProperties(); 317 const ObjectPaintProperties* childWithStackingContextProperties = childWithS tackingContext->objectPaintProperties();
303 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); 318 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect());
304 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); 319 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform());
320 CHECK_VISUAL_RECT(childWithStackingContext, document().view()->layoutView()) ;
305 321
306 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild WithOpacity")->layoutObject(); 322 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW ithOpacity")->layoutObject();
307 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit hOpacity.objectPaintProperties(); 323 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit hOpacity->objectPaintProperties();
308 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); 324 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity());
309 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent()); 325 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent());
310 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); 326 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform());
327 CHECK_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView());
311 } 328 }
312 329
313 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG) 330 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG)
314 { 331 {
315 setBodyInnerHTML( 332 setBodyInnerHTML(
316 "<svg id='svgRoot'>" 333 "<svg id='svgRoot'>"
317 " <g id='groupWithOpacity' opacity='0.6'>" 334 " <g id='groupWithOpacity' opacity='0.6'>"
318 " <rect id='rectWithoutOpacity' />" 335 " <rect id='rectWithoutOpacity' />"
319 " <rect id='rectWithOpacity' opacity='0.4' />" 336 " <rect id='rectWithOpacity' opacity='0.4' />"
320 " <text id='textWithOpacity' opacity='0.2'>" 337 " <text id='textWithOpacity' opacity='0.2'>"
321 " <tspan id='tspanWithOpacity' opacity='0.1' />" 338 " <tspan id='tspanWithOpacity' opacity='0.1' />"
322 " </text>" 339 " </text>"
323 " </g>" 340 " </g>"
324 "</svg>"); 341 "</svg>");
325 342
326 LayoutObject& groupWithOpacity = *document().getElementById("groupWithOpacit y")->layoutObject(); 343 LayoutObject* groupWithOpacity = document().getElementById("groupWithOpacity ")->layoutObject();
327 const ObjectPaintProperties* groupWithOpacityProperties = groupWithOpacity.o bjectPaintProperties(); 344 const ObjectPaintProperties* groupWithOpacityProperties = groupWithOpacity-> objectPaintProperties();
328 EXPECT_EQ(0.6f, groupWithOpacityProperties->effect()->opacity()); 345 EXPECT_EQ(0.6f, groupWithOpacityProperties->effect()->opacity());
329 EXPECT_NE(nullptr, groupWithOpacityProperties->effect()->parent()); 346 EXPECT_NE(nullptr, groupWithOpacityProperties->effect()->parent());
330 347
331 LayoutObject& rectWithoutOpacity = *document().getElementById("rectWithoutOp acity")->layoutObject(); 348 LayoutObject& rectWithoutOpacity = *document().getElementById("rectWithoutOp acity")->layoutObject();
332 const ObjectPaintProperties* rectWithoutOpacityProperties = rectWithoutOpaci ty.objectPaintProperties(); 349 const ObjectPaintProperties* rectWithoutOpacityProperties = rectWithoutOpaci ty.objectPaintProperties();
333 EXPECT_EQ(nullptr, rectWithoutOpacityProperties); 350 EXPECT_EQ(nullptr, rectWithoutOpacityProperties);
334 351
335 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity" )->layoutObject(); 352 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity" )->layoutObject();
336 const ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.obj ectPaintProperties(); 353 const ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.obj ectPaintProperties();
337 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); 354 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity());
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 " margin: 0;" 622 " margin: 0;"
606 " }" 623 " }"
607 " input {" 624 " input {"
608 " border-width: 5px;" 625 " border-width: 5px;"
609 " padding: 0;" 626 " padding: 0;"
610 " }" 627 " }"
611 "</style>" 628 "</style>"
612 "<input id='button' type='button' style='width:345px; height:123px' valu e='some text'/>"); 629 "<input id='button' type='button' style='width:345px; height:123px' valu e='some text'/>");
613 630
614 FrameView* frameView = document().view(); 631 FrameView* frameView = document().view();
615 LayoutObject& button = *document().getElementById("button")->layoutObject(); 632 LayoutObject* button = document().getElementById("button")->layoutObject();
616 const ObjectPaintProperties* buttonProperties = button.objectPaintProperties (); 633 const ObjectPaintProperties* buttonProperties = button->objectPaintPropertie s();
617 EXPECT_EQ(frameView->scrollTranslation(), buttonProperties->overflowClip()-> localTransformSpace()); 634 EXPECT_EQ(frameView->scrollTranslation(), buttonProperties->overflowClip()-> localTransformSpace());
618 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip() ->clipRect()); 635 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip() ->clipRect());
619 EXPECT_EQ(frameView->contentClip(), buttonProperties->overflowClip()->parent ()); 636 EXPECT_EQ(frameView->contentClip(), buttonProperties->overflowClip()->parent ());
637 CHECK_VISUAL_RECT(button, frameView->layoutView());
620 } 638 }
621 639
622 TEST_F(PaintPropertyTreeBuilderTest, BorderRadiusClip) 640 TEST_F(PaintPropertyTreeBuilderTest, BorderRadiusClip)
623 { 641 {
624 setBodyInnerHTML( 642 setBodyInnerHTML(
625 "<style>" 643 "<style>"
626 " body {" 644 " body {"
627 " margin: 0px;" 645 " margin: 0px;"
628 " }" 646 " }"
629 " #div {" 647 " #div {"
630 " border-radius: 12px 34px 56px 78px;" 648 " border-radius: 12px 34px 56px 78px;"
631 " border-top: 45px solid;" 649 " border-top: 45px solid;"
632 " border-right: 50px solid;" 650 " border-right: 50px solid;"
633 " border-bottom: 55px solid;" 651 " border-bottom: 55px solid;"
634 " border-left: 60px solid;" 652 " border-left: 60px solid;"
635 " width: 500px;" 653 " width: 500px;"
636 " height: 400px;" 654 " height: 400px;"
637 " overflow: scroll;" 655 " overflow: scroll;"
638 " }" 656 " }"
639 "</style>" 657 "</style>"
640 "<div id='div'></div>"); 658 "<div id='div'></div>");
641 659
642 FrameView* frameView = document().view(); 660 FrameView* frameView = document().view();
643 LayoutObject& div = *document().getElementById("div")->layoutObject(); 661 LayoutObject* div = document().getElementById("div")->layoutObject();
644 const ObjectPaintProperties* divProperties = div.objectPaintProperties(); 662 const ObjectPaintProperties* divProperties = div->objectPaintProperties();
645 EXPECT_EQ(frameView->scrollTranslation(), divProperties->overflowClip()->loc alTransformSpace()); 663 EXPECT_EQ(frameView->scrollTranslation(), divProperties->overflowClip()->loc alTransformSpace());
646 // The overflow clip rect includes only the padding box. 664 // The overflow clip rect includes only the padding box.
647 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, 45+ 55) - scrollbars(15, 15) 665 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, 45+ 55) - scrollbars(15, 15)
648 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), divProperties->overflowClip()- >clipRect()); 666 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), divProperties->overflowClip()- >clipRect());
649 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip( )->parent(); 667 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip( )->parent();
650 EXPECT_EQ(frameView->scrollTranslation(), borderRadiusClip->localTransformSp ace()); 668 EXPECT_EQ(frameView->scrollTranslation(), borderRadiusClip->localTransformSp ace());
651 // The border radius clip is the area enclosed by inner border edge, includi ng the scrollbars. 669 // The border radius clip is the area enclosed by inner border edge, includi ng the scrollbars.
652 // As the border-radius is specified in outer radius, the inner radius is ca lculated by: 670 // As the border-radius is specified in outer radius, the inner radius is ca lculated by:
653 // inner radius = max(outer radius - border width, 0) 671 // inner radius = max(outer radius - border width, 0)
654 // In the case that two adjacent borders have different width, the inner rad ius of the corner 672 // In the case that two adjacent borders have different width, the inner rad ius of the corner
655 // may transition from one value to the other. i.e. being an ellipse. 673 // may transition from one value to the other. i.e. being an ellipse.
656 EXPECT_EQ( 674 EXPECT_EQ(
657 FloatRoundedRect( 675 FloatRoundedRect(
658 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs et(110, 100) 676 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs et(110, 100)
659 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0, 0)) 677 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0, 0))
660 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0, 0)) 678 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0, 0))
661 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0, 0)) 679 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0, 0))
662 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0, 0)) 680 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0, 0))
663 borderRadiusClip->clipRect()); 681 borderRadiusClip->clipRect());
664 EXPECT_EQ(frameView->contentClip(), borderRadiusClip->parent()); 682 EXPECT_EQ(frameView->contentClip(), borderRadiusClip->parent());
683 CHECK_VISUAL_RECT(div, frameView->layoutView());
665 } 684 }
666 685
667 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) 686 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes)
668 { 687 {
669 setBodyInnerHTML( 688 setBodyInnerHTML(
670 "<style>body { margin: 0; }</style>" 689 "<style>body { margin: 0; }</style>"
671 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>" 690 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>"
672 " <iframe id='frame'></iframe>" 691 " <iframe id='frame'></iframe>"
673 "</div>"); 692 "</div>");
674 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0 ; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px);'></ div>"); 693 Document& frameDocument = setupChildIframe("frame",
675 document().view()->updateAllLifecyclePhases(); 694 "<style>body { margin: 0; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>");
695 FrameView* frameView = document().view();
696 frameView->updateAllLifecyclePhases();
676 697
677 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject(); 698 LayoutObject* divWithTransform = document().getElementById("divWithTransform ")->layoutObject();
678 const ObjectPaintProperties* divWithTransformProperties = divWithTransform.o bjectPaintProperties(); 699 const ObjectPaintProperties* divWithTransformProperties = divWithTransform-> objectPaintProperties();
679 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope rties->transform()->matrix()); 700 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope rties->transform()->matrix());
701 CHECK_VISUAL_RECT(divWithTransform, frameView->layoutView());
680 702
681 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor m")->layoutObject(); 703 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor m")->layoutObject();
682 const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithT ransform->objectPaintProperties(); 704 const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithT ransform->objectPaintProperties();
683 auto* innerDivTransform = innerDivWithTransformProperties->transform(); 705 auto* innerDivTransform = innerDivWithTransformProperties->transform();
684 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma trix()); 706 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma trix());
707 CHECK_VISUAL_RECT(innerDivWithTransform, frameView->layoutView());
685 708
686 // Ensure that the inner div's transform is correctly rooted in the root fra me's transform tree. 709 // Ensure that the inner div's transform is correctly rooted in the root fra me's transform tree.
687 // This asserts that we have the following tree structure: 710 // This asserts that we have the following tree structure:
688 // ... 711 // ...
689 // Transform transform=translation=1.000000,2.000000,3.000000 712 // Transform transform=translation=1.000000,2.000000,3.000000
690 // PreTranslation transform=translation=2.000000,2.000000,0.000000 713 // PreTranslation transform=translation=2.000000,2.000000,0.000000
691 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 714 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000
692 // Transform transform=translation=4.000000,5.000000,6.000000 715 // Transform transform=translation=4.000000,5.000000,6.000000
693 auto* innerDocumentScrollTranslation = innerDivTransform->parent(); 716 auto* innerDocumentScrollTranslation = innerDivTransform->parent();
694 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr anslation->matrix()); 717 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr anslation->matrix());
695 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); 718 auto* iframePreTranslation = innerDocumentScrollTranslation->parent();
696 EXPECT_EQ(TransformationMatrix().translate3d(2, 2, 0), iframePreTranslation- >matrix()); 719 EXPECT_EQ(TransformationMatrix().translate3d(2, 2, 0), iframePreTranslation- >matrix());
697 EXPECT_EQ(divWithTransformProperties->transform(), iframePreTranslation->par ent()); 720 EXPECT_EQ(divWithTransformProperties->transform(), iframePreTranslation->par ent());
698 } 721 }
699 722
700 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes) 723 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes)
701 { 724 {
702 setBodyInnerHTML( 725 setBodyInnerHTML(
703 "<style>body { margin: 0; }</style>" 726 "<style>body { margin: 0; }</style>"
704 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>" 727 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>"
705 " <iframe id='frame' style='transform: translate3d(4px, 5px, 6px); bord er: 42px solid; margin: 7px;'></iframe>" 728 " <iframe id='frame' style='transform: translate3d(4px, 5px, 6px); bord er: 42px solid; margin: 7px;'></iframe>"
706 "</div>"); 729 "</div>");
707 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 3 1px; }</style><div id='transform' style='transform: translate3d(7px, 8px, 9px);' ></div>"); 730 Document& frameDocument = setupChildIframe("frame",
708 document().view()->updateAllLifecyclePhases(); 731 "<style>body { margin: 31px; }</style><div id='transform' style='transfo rm: translate3d(7px, 8px, 9px); width: 100px; height: 200px'></div>");
732 FrameView* frameView = document().view();
733 frameView->updateAllLifecyclePhases();
709 734
710 // Assert that we have the following tree structure: 735 // Assert that we have the following tree structure:
711 // ... 736 // ...
712 // Transform transform=translation=1.000000,2.000000,3.000000 737 // Transform transform=translation=1.000000,2.000000,3.000000
713 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.0000 00 738 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.0000 00
714 // Transform transform=translation=4.000000,5.000000,6.000000 739 // Transform transform=translation=4.000000,5.000000,6.000000
715 // PreTranslation transform=translation=42.000000,42.000000,0.000000 740 // PreTranslation transform=translation=42.000000,42.000000,0.000000
716 // ScrollTranslation transform=translation=0.000000,0.000000,0.000 000 741 // ScrollTranslation transform=translation=0.000000,0.000000,0.000 000
717 // PaintOffsetTranslation transform=translation=31.000000,31.000 000,0.000000 742 // PaintOffsetTranslation transform=translation=31.000000,31.000 000,0.000000
718 // Transform transform=translation=7.000000,8.000000,9.000000 743 // Transform transform=translation=7.000000,8.000000,9.000000
719 744
720 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor m")->layoutObject(); 745 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor m")->layoutObject();
721 auto* innerDivTransform = innerDivWithTransform->objectPaintProperties()->tr ansform(); 746 auto* innerDivTransform = innerDivWithTransform->objectPaintProperties()->tr ansform();
722 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), innerDivTransform->ma trix()); 747 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), innerDivTransform->ma trix());
748 CHECK_VISUAL_RECT(innerDivWithTransform, frameView->layoutView());
723 749
724 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent(); 750 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent();
725 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0), innerDocumentPaintO ffsetTranslation->matrix()); 751 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0), innerDocumentPaintO ffsetTranslation->matrix());
726 auto* innerDocumentScrollTranslation = innerDocumentPaintOffsetTranslation-> parent(); 752 auto* innerDocumentScrollTranslation = innerDocumentPaintOffsetTranslation-> parent();
727 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr anslation->matrix()); 753 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr anslation->matrix());
728 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); 754 auto* iframePreTranslation = innerDocumentScrollTranslation->parent();
729 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), iframePreTranslatio n->matrix()); 755 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), iframePreTranslatio n->matrix());
730 auto* iframeTransform = iframePreTranslation->parent(); 756 auto* iframeTransform = iframePreTranslation->parent();
731 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr ix()); 757 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr ix());
732 auto* iframePaintOffsetTranslation = iframeTransform->parent(); 758 auto* iframePaintOffsetTranslation = iframeTransform->parent();
733 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran slation->matrix()); 759 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran slation->matrix());
734 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); 760 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent();
735 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans form->matrix()); 761 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans form->matrix());
736 762
737 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject(); 763 LayoutObject* divWithTransform = document().getElementById("divWithTransform ")->layoutObject();
738 EXPECT_EQ(divWithTransformTransform, divWithTransform.objectPaintProperties( )->transform()); 764 EXPECT_EQ(divWithTransformTransform, divWithTransform->objectPaintProperties ()->transform());
765 CHECK_VISUAL_RECT(divWithTransform, frameView->layoutView());
739 } 766 }
740 767
741 TEST_F(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) 768 TEST_F(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext)
742 { 769 {
743 // This test verifies the tree builder correctly computes and records the pr operty tree context 770 // This test verifies the tree builder correctly computes and records the pr operty tree context
744 // for a (pseudo) stacking context that is scrolled by a containing block th at is not one of 771 // for a (pseudo) stacking context that is scrolled by a containing block th at is not one of
745 // the painting ancestors. 772 // the painting ancestors.
746 setBodyInnerHTML( 773 setBodyInnerHTML(
747 "<style>body { margin: 0; }</style>" 774 "<style>body { margin: 0; }</style>"
748 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'> " 775 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'> "
749 " <div id='child' style='position:relative;'></div>" 776 " <div id='child' style='position:relative; width:100px; height: 200px; '></div>"
750 " <div style='height:10000px;'></div>" 777 " <div style='height:10000px;'></div>"
751 "</div>" 778 "</div>"
752 ); 779 );
780 FrameView* frameView = document().view();
753 781
754 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec t(); 782 LayoutObject* scroller = document().getElementById("scroller")->layoutObject ();
755 const ObjectPaintProperties* scrollerProperties = scroller.objectPaintProper ties(); 783 const ObjectPaintProperties* scrollerProperties = scroller->objectPaintPrope rties();
756 LayoutObject& child = *document().getElementById("child")->layoutObject(); 784 LayoutObject* child = document().getElementById("child")->layoutObject();
757 const ObjectPaintProperties* childProperties = child.objectPaintProperties() ; 785 const ObjectPaintProperties* childProperties = child->objectPaintProperties( );
758 786
759 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo xProperties()->propertyTreeState.clip); 787 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo xProperties()->propertyTreeState.clip);
760 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor derBoxProperties()->propertyTreeState.transform); 788 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor derBoxProperties()->propertyTreeState.transform);
761 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree State.effect); 789 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree State.effect);
790 CHECK_VISUAL_RECT(scroller, frameView->layoutView());
791 CHECK_VISUAL_RECT(child, frameView->layoutView());
762 } 792 }
763 793
764 TEST_F(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext) 794 TEST_F(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext)
765 { 795 {
766 // This test verifies the tree builder correctly computes and records the pr operty tree context 796 // This test verifies the tree builder correctly computes and records the pr operty tree context
767 // for a (pseudo) stacking context that has a scrolling painting ancestor th at is not its 797 // for a (pseudo) stacking context that has a scrolling painting ancestor th at is not its
768 // containing block (thus should not be scrolled by it). 798 // containing block (thus should not be scrolled by it).
769 799
770 setBodyInnerHTML( 800 setBodyInnerHTML(
771 "<style>body { margin: 0; }</style>" 801 "<style>body { margin: 0; }</style>"
772 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" 802 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>"
773 " <div id='child' style='position:absolute; left:0; top:0;'></div>" 803 " <div id='child' style='position:absolute; left:0; top:0; width: 100px ; height: 200px'></div>"
774 " <div style='height:10000px;'></div>" 804 " <div style='height:10000px;'></div>"
775 "</div>" 805 "</div>"
776 ); 806 );
777 807
778 FrameView* frameView = document().view(); 808 FrameView* frameView = document().view();
779 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec t(); 809 LayoutObject* scroller = document().getElementById("scroller")->layoutObject ();
780 const ObjectPaintProperties* scrollerProperties = scroller.objectPaintProper ties(); 810 const ObjectPaintProperties* scrollerProperties = scroller->objectPaintPrope rties();
781 LayoutObject& child = *document().getElementById("child")->layoutObject(); 811 LayoutObject* child = document().getElementById("child")->layoutObject();
782 const ObjectPaintProperties* childProperties = child.objectPaintProperties() ; 812 const ObjectPaintProperties* childProperties = child->objectPaintProperties( );
783 813
784 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie s()->propertyTreeState.clip); 814 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie s()->propertyTreeState.clip);
785 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro perties()->propertyTreeState.transform); 815 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro perties()->propertyTreeState.transform);
786 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope rties()->propertyTreeState.effect); 816 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope rties()->propertyTreeState.effect);
817 CHECK_VISUAL_RECT(scroller, frameView->layoutView());
818 CHECK_VISUAL_RECT(child, frameView->layoutView());
787 } 819 }
788 820
789 TEST_F(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) 821 TEST_F(PaintPropertyTreeBuilderTest, TableCellLayoutLocation)
790 { 822 {
791 // This test verifies that the border box space of a table cell is being cor rectly computed. 823 // This test verifies that the border box space of a table cell is being cor rectly computed.
792 // Table cells have weird location adjustment in our layout/paint implementa tion. 824 // Table cells have weird location adjustment in our layout/paint implementa tion.
793 setBodyInnerHTML( 825 setBodyInnerHTML(
794 "<style>" 826 "<style>"
795 " body {" 827 " body {"
796 " margin: 0;" 828 " margin: 0;"
(...skipping 15 matching lines...) Expand all
812 " height: 100px;" 844 " height: 100px;"
813 " }" 845 " }"
814 "</style>" 846 "</style>"
815 "<table>" 847 "<table>"
816 " <tr><td></td><td></td></tr>" 848 " <tr><td></td><td></td></tr>"
817 " <tr><td></td><td><div id='target'></div></td></tr>" 849 " <tr><td></td><td><div id='target'></div></td></tr>"
818 "</table>" 850 "</table>"
819 ); 851 );
820 852
821 FrameView* frameView = document().view(); 853 FrameView* frameView = document().view();
822 LayoutObject& target = *document().getElementById("target")->layoutObject(); 854 LayoutObject* target = document().getElementById("target")->layoutObject();
823 const ObjectPaintProperties* targetProperties = target.objectPaintProperties (); 855 const ObjectPaintProperties* targetProperties = target->objectPaintPropertie s();
824 856
825 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties( )->paintOffset); 857 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties( )->paintOffset);
826 EXPECT_EQ(frameView->scrollTranslation(), targetProperties->localBorderBoxPr operties()->propertyTreeState.transform); 858 EXPECT_EQ(frameView->scrollTranslation(), targetProperties->localBorderBoxPr operties()->propertyTreeState.transform);
859 CHECK_VISUAL_RECT(target, frameView->layoutView());
827 } 860 }
828 861
829 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) 862 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant)
830 { 863 {
831 // This test verifies that clip tree hierarchy being generated correctly for the hard case 864 // This test verifies that clip tree hierarchy being generated correctly for the hard case
832 // such that a fixed position element getting clipped by an absolute positio n CSS clip. 865 // such that a fixed position element getting clipped by an absolute positio n CSS clip.
833 setBodyInnerHTML( 866 setBodyInnerHTML(
834 "<style>" 867 "<style>"
835 " #clip {" 868 " #clip {"
836 " position: absolute;" 869 " position: absolute;"
837 " left: 123px;" 870 " left: 123px;"
838 " top: 456px;" 871 " top: 456px;"
839 " clip: rect(10px, 80px, 70px, 40px);" 872 " clip: rect(10px, 80px, 70px, 40px);"
840 " width: 100px;" 873 " width: 100px;"
841 " height: 100px;" 874 " height: 100px;"
842 " }" 875 " }"
843 " #fixed {" 876 " #fixed {"
844 " position: fixed;" 877 " position: fixed;"
845 " left: 654px;" 878 " left: 654px;"
846 " top: 321px;" 879 " top: 321px;"
880 " width: 10px;"
881 " heght: 20px"
847 " }" 882 " }"
848 "</style>" 883 "</style>"
849 "<div id='clip'><div id='fixed'></div></div>" 884 "<div id='clip'><div id='fixed'></div></div>"
850 ); 885 );
851 LayoutRect localClipRect(40, 10, 40, 60); 886 LayoutRect localClipRect(40, 10, 40, 60);
852 LayoutRect absoluteClipRect = localClipRect; 887 LayoutRect absoluteClipRect = localClipRect;
853 absoluteClipRect.move(123, 456); 888 absoluteClipRect.move(123, 456);
854 889
855 FrameView* frameView = document().view(); 890 FrameView* frameView = document().view();
856 891
857 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); 892 LayoutObject* clip = document().getElementById("clip")->layoutObject();
858 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); 893 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties();
859 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); 894 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent());
860 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr ansformSpace()); 895 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr ansformSpace());
861 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect()); 896 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect());
897 // TODO(chrishtr): GeomeryMapper rports 40x60 size (i.e. including clip), wh ereas the old code reports 100x100 (unclipped).
898 // Fix.
899 // CHECK_VISUAL_RECT(clip, frameView->layoutView());
862 900
863 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); 901 LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
864 const ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties() ; 902 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties( );
865 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti es()->propertyTreeState.clip); 903 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti es()->propertyTreeState.clip);
866 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper ties()->propertyTreeState.transform->parent()); 904 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper ties()->propertyTreeState.transform->parent());
867 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->propertyTreeState.transform->matrix()); 905 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->propertyTreeState.transform->matrix());
868 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset); 906 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset);
907 CHECK_VISUAL_RECT(fixed, frameView->layoutView());
869 } 908 }
870 909
871 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) 910 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared)
872 { 911 {
873 // This test is similar to CSSClipFixedPositionDescendant above, except that 912 // This test is similar to CSSClipFixedPositionDescendant above, except that
874 // now we have a parent overflow clip that should be escaped by the fixed de scendant. 913 // now we have a parent overflow clip that should be escaped by the fixed de scendant.
875 setBodyInnerHTML( 914 setBodyInnerHTML(
876 "<style>" 915 "<style>"
877 " body {" 916 " body {"
878 " margin: 0;" 917 " margin: 0;"
(...skipping 19 matching lines...) Expand all
898 " }" 937 " }"
899 "</style>" 938 "</style>"
900 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>" 939 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>"
901 ); 940 );
902 LayoutRect localClipRect(40, 10, 40, 60); 941 LayoutRect localClipRect(40, 10, 40, 60);
903 LayoutRect absoluteClipRect = localClipRect; 942 LayoutRect absoluteClipRect = localClipRect;
904 absoluteClipRect.move(123, 456); 943 absoluteClipRect.move(123, 456);
905 944
906 FrameView* frameView = document().view(); 945 FrameView* frameView = document().view();
907 946
908 LayoutObject& overflow = *document().getElementById("overflow")->layoutObjec t(); 947 LayoutObject* overflow = document().getElementById("overflow")->layoutObject ();
909 const ObjectPaintProperties* overflowProperties = overflow.objectPaintProper ties(); 948 const ObjectPaintProperties* overflowProperties = overflow->objectPaintPrope rties();
910 EXPECT_EQ(frameView->contentClip(), overflowProperties->overflowClip()->pare nt()); 949 EXPECT_EQ(frameView->contentClip(), overflowProperties->overflowClip()->pare nt());
911 EXPECT_EQ(frameView->scrollTranslation(), overflowProperties->scrollTranslat ion()->parent()); 950 EXPECT_EQ(frameView->scrollTranslation(), overflowProperties->scrollTranslat ion()->parent());
951 CHECK_VISUAL_RECT(overflow, frameView->layoutView());
912 952
913 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); 953 LayoutObject* clip = document().getElementById("clip")->layoutObject();
914 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); 954 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties();
915 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par ent()); 955 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par ent());
916 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip() ->localTransformSpace()); 956 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip() ->localTransformSpace());
917 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect()); 957 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect());
918 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClipFixedPosition()-> parent()); 958 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClipFixedPosition()-> parent());
919 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi xedPosition()->localTransformSpace()); 959 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi xedPosition()->localTransformSpace());
920 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css ClipFixedPosition()->clipRect()); 960 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css ClipFixedPosition()->clipRect());
961 CHECK_VISUAL_RECT(clip, frameView->layoutView());
921 962
922 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); 963 LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
923 const ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties() ; 964 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties( );
924 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord erBoxProperties()->propertyTreeState.clip); 965 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord erBoxProperties()->propertyTreeState.clip);
925 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper ties()->propertyTreeState.transform->parent()); 966 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper ties()->propertyTreeState.transform->parent());
926 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->propertyTreeState.transform->matrix()); 967 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->propertyTreeState.transform->matrix());
927 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset); 968 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset);
969 CHECK_VISUAL_RECT(fixed, frameView->layoutView());
928 } 970 }
929 971
930 TEST_F(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) 972 TEST_F(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned)
931 { 973 {
932 setBodyInnerHTML( 974 setBodyInnerHTML(
933 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" 975 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>"
934 " <div style='position: relative; top: 100px; left: 100px'>" 976 " <div style='position: relative; top: 100px; left: 100px'>"
935 " <div id='spanner' style='column-span: all; opacity: 0.5; width: 100 px; height: 100px;'></div>" 977 " <div id='spanner' style='column-span: all; opacity: 0.5; width: 100 px; height: 100px;'></div>"
936 " </div>" 978 " </div>"
937 "</div>" 979 "</div>"
938 ); 980 );
939 981
940 LayoutObject& spanner = *getLayoutObjectByElementId("spanner"); 982 LayoutObject* spanner = getLayoutObjectByElementId("spanner");
941 EXPECT_EQ(LayoutPoint(55, 44), spanner.objectPaintProperties()->localBorderB oxProperties()->paintOffset); 983 EXPECT_EQ(LayoutPoint(55, 44), spanner->objectPaintProperties()->localBorder BoxProperties()->paintOffset);
984 CHECK_VISUAL_RECT(spanner, document().view()->layoutView());
942 } 985 }
943 986
944 TEST_F(PaintPropertyTreeBuilderTest, FractionalPaintOffset) 987 TEST_F(PaintPropertyTreeBuilderTest, FractionalPaintOffset)
945 { 988 {
946 setBodyInnerHTML( 989 setBodyInnerHTML(
947 "<style>" 990 "<style>"
948 " * { margin: 0; }" 991 " * { margin: 0; }"
949 " div { position: absolute; }" 992 " div { position: absolute; }"
950 "</style>" 993 "</style>"
951 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;' >" 994 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;' >"
952 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p x;'></div>" 995 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p x;'></div>"
953 "</div>" 996 "</div>"
954 ); 997 );
998 FrameView* frameView = document().view();
955 999
956 const ObjectPaintProperties* aProperties = document().getElementById("a")->l ayoutObject()->objectPaintProperties(); 1000 LayoutObject* a = document().getElementById("a")->layoutObject();
1001 const ObjectPaintProperties* aProperties = a->objectPaintProperties();
957 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); 1002 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3));
958 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset ); 1003 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset );
1004 CHECK_VISUAL_RECT(a, frameView->layoutView());
959 1005
960 const ObjectPaintProperties* bProperties = document().getElementById("b")->l ayoutObject()->objectPaintProperties(); 1006 LayoutObject* b = document().getElementById("b")->layoutObject();
1007 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
961 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1)) ; 1008 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1)) ;
962 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset ); 1009 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset );
1010 CHECK_VISUAL_RECT(a, frameView->layoutView());
963 } 1011 }
964 1012
965 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) 1013 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping)
966 { 1014 {
967 setBodyInnerHTML( 1015 setBodyInnerHTML(
968 "<style>" 1016 "<style>"
969 " * { margin: 0; }" 1017 " * { margin: 0; }"
970 " div { position: relative; }" 1018 " div { position: relative; }"
971 "</style>" 1019 "</style>"
972 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;' >" 1020 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;' >"
973 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 );'>" 1021 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 );'>"
974 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1 px;'></div>" 1022 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1 px;'></div>"
975 " </div>" 1023 " </div>"
976 "</div>" 1024 "</div>"
977 ); 1025 );
1026 FrameView* frameView = document().view();
978 1027
979 const ObjectPaintProperties* bProperties = document().getElementById("b")->l ayoutObject()->objectPaintProperties(); 1028 LayoutObject* b = document().getElementById("b")->layoutObject();
1029 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
980 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor m()->matrix()); 1030 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor m()->matrix());
981 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). 1031 // The paint offset transform should be snapped from (0.3,0.3) to (0,0).
982 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()-> parent()->matrix()); 1032 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()-> parent()->matrix());
983 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). 1033 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3).
984 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); 1034 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3));
985 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai ntOffset); 1035 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai ntOffset);
1036 CHECK_VISUAL_RECT(b, frameView->layoutView());
986 1037
987 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = (0.4,0 .4). 1038 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = (0.4,0 .4).
1039 LayoutObject* c = document().getElementById("c")->layoutObject();
988 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1 , 0.1)); 1040 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1 , 0.1));
989 const ObjectPaintProperties* cProperties = document().getElementById("c")->l ayoutObject()->objectPaintProperties(); 1041 const ObjectPaintProperties* cProperties = c->objectPaintProperties();
990 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset ); 1042 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset );
1043 // TODO(chrishtr): results differ by pixel snapping
1044 // CHECK_VISUAL_RECT(c, frameView->layoutView());
991 } 1045 }
992 1046
993 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor m) 1047 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor m)
994 { 1048 {
995 setBodyInnerHTML( 1049 setBodyInnerHTML(
996 "<style>" 1050 "<style>"
997 " * { margin: 0; }" 1051 " * { margin: 0; }"
998 " div { position: relative; }" 1052 " div { position: relative; }"
999 "</style>" 1053 "</style>"
1000 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;' >" 1054 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;' >"
1001 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 );'>" 1055 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 );'>"
1002 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7 px;'></div>" 1056 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7 px;'></div>"
1003 " </div>" 1057 " </div>"
1004 "</div>" 1058 "</div>"
1005 ); 1059 );
1060 FrameView* frameView = document().view();
1006 1061
1007 const ObjectPaintProperties* bProperties = document().getElementById("b")->l ayoutObject()->objectPaintProperties(); 1062 LayoutObject* b = document().getElementById("b")->layoutObject();
1063 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1008 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor m()->matrix()); 1064 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor m()->matrix());
1009 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). 1065 // The paint offset transform should be snapped from (0.7,0.7) to (1,1).
1010 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()-> parent()->matrix()); 1066 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()-> parent()->matrix());
1011 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3 ). 1067 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3 ).
1012 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0 .7)) - LayoutPoint(1, 1)); 1068 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0 .7)) - LayoutPoint(1, 1));
1013 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai ntOffset); 1069 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai ntOffset);
1070 CHECK_VISUAL_RECT(b, frameView->layoutView());
1014 1071
1015 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0 .4). 1072 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0 .4).
1073 LayoutObject* c = document().getElementById("c")->layoutObject();
1016 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0.7)); 1074 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0.7));
1017 const ObjectPaintProperties* cProperties = document().getElementById("c")->l ayoutObject()->objectPaintProperties(); 1075 const ObjectPaintProperties* cProperties = c->objectPaintProperties();
1018 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset ); 1076 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset );
1077 // TODO(chrishtr): results differ by pixel snapping
1078 // CHECK_VISUAL_RECT(c, frameView->layoutView());
1019 } 1079 }
1020 1080
1021 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple Transforms) 1081 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple Transforms)
1022 { 1082 {
1023 setBodyInnerHTML( 1083 setBodyInnerHTML(
1024 "<style>" 1084 "<style>"
1025 " * { margin: 0; }" 1085 " * { margin: 0; }"
1026 " div { position: relative; }" 1086 " div { position: relative; }"
1027 "</style>" 1087 "</style>"
1028 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;' >" 1088 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;' >"
1029 " <div id='b' style='width: 40px; height: 40px; transform: translate3d( 5px, 7px, 0);'>" 1089 " <div id='b' style='width: 40px; height: 40px; transform: translate3d( 5px, 7px, 0);'>"
1030 " <div id='c' style='width: 40px; height: 40px; transform: translate3 d(11px, 13px, 0);'>" 1090 " <div id='c' style='width: 40px; height: 40px; transform: translate3 d(11px, 13px, 0);'>"
1031 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0 .7px;'></div>" 1091 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0 .7px;'></div>"
1032 " </div>" 1092 " </div>"
1033 " </div>" 1093 " </div>"
1034 "</div>" 1094 "</div>"
1035 ); 1095 );
1096 FrameView* frameView = document().view();
1036 1097
1037 const ObjectPaintProperties* bProperties = document().getElementById("b")->l ayoutObject()->objectPaintProperties(); 1098 LayoutObject* b = document().getElementById("b")->layoutObject();
1099 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1038 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0), bProperties->transfor m()->matrix()); 1100 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0), bProperties->transfor m()->matrix());
1039 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). 1101 // The paint offset transform should be snapped from (0.7,0.7) to (1,1).
1040 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()-> parent()->matrix()); 1102 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()-> parent()->matrix());
1041 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3 ). 1103 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3 ).
1042 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0 .7)) - LayoutPoint(1, 1)); 1104 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0 .7)) - LayoutPoint(1, 1));
1043 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai ntOffset); 1105 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai ntOffset);
1106 CHECK_VISUAL_RECT(b, frameView->layoutView());
1044 1107
1045 const ObjectPaintProperties* cProperties = document().getElementById("c")->l ayoutObject()->objectPaintProperties(); 1108 LayoutObject* c = document().getElementById("c")->layoutObject();
1109 const ObjectPaintProperties* cProperties = c->objectPaintProperties();
1046 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), cProperties->transf orm()->matrix()); 1110 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), cProperties->transf orm()->matrix());
1047 // The paint offset should be (-0.3,-0.3) but the paint offset transform sho uld still be at 1111 // The paint offset should be (-0.3,-0.3) but the paint offset transform sho uld still be at
1048 // (0,0) because it should be snapped. 1112 // (0,0) because it should be snapped.
1049 EXPECT_EQ(TransformationMatrix().translate(0, 0), cProperties->transform()-> parent()->matrix()); 1113 EXPECT_EQ(TransformationMatrix().translate(0, 0), cProperties->transform()-> parent()->matrix());
1050 // The residual subpixel adjustment should still be (-0.3,-0.3). 1114 // The residual subpixel adjustment should still be (-0.3,-0.3).
1051 EXPECT_EQ(subpixelAccumulation, cProperties->localBorderBoxProperties()->pai ntOffset); 1115 EXPECT_EQ(subpixelAccumulation, cProperties->localBorderBoxProperties()->pai ntOffset);
1116 CHECK_VISUAL_RECT(c, frameView->layoutView());
1052 1117
1053 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0 .4). 1118 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0 .4).
1119 LayoutObject* d = document().getElementById("d")->layoutObject();
1054 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0.7)); 1120 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0.7));
1055 const ObjectPaintProperties* dProperties = document().getElementById("d")->l ayoutObject()->objectPaintProperties(); 1121 const ObjectPaintProperties* dProperties = d->objectPaintProperties();
1056 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset ); 1122 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset );
1123 // TODO(chrishtr): results differ by pixel snapping
1124 // CHECK_VISUAL_RECT(d, frameView->layoutView());
1057 } 1125 }
1058 1126
1059 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) 1127 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos)
1060 { 1128 {
1061 setBodyInnerHTML( 1129 setBodyInnerHTML(
1062 "<style>" 1130 "<style>"
1063 " * { margin: 0; }" 1131 " * { margin: 0; }"
1064 "</style>" 1132 "</style>"
1065 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re lative;'>" 1133 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re lative;'>"
1066 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 ); position: relative;'>" 1134 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0 ); position: relative;'>"
1067 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;' >" 1135 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;' >"
1068 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi on: relative;'></div>" 1136 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi on: relative;'></div>"
1069 " </div>" 1137 " </div>"
1070 " </div>" 1138 " </div>"
1071 "</div>" 1139 "</div>"
1072 ); 1140 );
1141 FrameView* frameView = document().view();
1073 1142
1074 const ObjectPaintProperties* bProperties = document().getElementById("b")->l ayoutObject()->objectPaintProperties(); 1143 LayoutObject* b = document().getElementById("b")->layoutObject();
1144 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1075 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()-> matrix()); 1145 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()-> matrix());
1076 // The paint offset transform should be snapped from (0.7,0) to (1,0). 1146 // The paint offset transform should be snapped from (0.7,0) to (1,0).
1077 EXPECT_EQ(TransformationMatrix().translate(1, 0), bProperties->transform()-> parent()->matrix()); 1147 EXPECT_EQ(TransformationMatrix().translate(1, 0), bProperties->transform()-> parent()->matrix());
1078 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0). 1148 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0).
1079 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0 )) - LayoutPoint(1, 0)); 1149 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0 )) - LayoutPoint(1, 0));
1080 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai ntOffset); 1150 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai ntOffset);
1151 CHECK_VISUAL_RECT(b, frameView->layoutView());
1081 1152
1082 const ObjectPaintProperties* fixedProperties = document().getElementById("fi xed")->layoutObject()->objectPaintProperties(); 1153 LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
1154 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties( );
1083 // The residual subpixel adjustment should still be (-0.3,0). 1155 // The residual subpixel adjustment should still be (-0.3,0).
1084 EXPECT_EQ(subpixelAccumulation, fixedProperties->localBorderBoxProperties()- >paintOffset); 1156 EXPECT_EQ(subpixelAccumulation, fixedProperties->localBorderBoxProperties()- >paintOffset);
1157 CHECK_VISUAL_RECT(fixed, frameView->layoutView());
1085 1158
1086 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). 1159 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0).
1160 LayoutObject* d = document().getElementById("d")->layoutObject();
1087 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0)); 1161 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7 , 0));
1088 const ObjectPaintProperties* dProperties = document().getElementById("d")->l ayoutObject()->objectPaintProperties(); 1162 const ObjectPaintProperties* dProperties = d->objectPaintProperties();
1089 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset ); 1163 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset );
1164 // TODO(chrishtr): results differ by pixel snapping
1165 // CHECK_VISUAL_RECT(d, frameView->layoutView());
1090 } 1166 }
1091 1167
1092 TEST_F(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) 1168 TEST_F(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset)
1093 { 1169 {
1094 setBodyInnerHTML( 1170 setBodyInnerHTML(
1095 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix (1, 0, 0, 1, 0, 0);'>" 1171 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix (1, 0, 0, 1, 0, 0);'>"
1096 " <rect id='rect' transform='translate(1, 1)'/>" 1172 " <rect id='rect' transform='translate(1, 1)'/>"
1097 "</svg>"); 1173 "</svg>");
1098 1174
1099 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb ject(); 1175 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb ject();
1100 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o bjectPaintProperties(); 1176 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o bjectPaintProperties();
1101 EXPECT_EQ(TransformationMatrix(), svgWithTransformProperties->transform()->m atrix()); 1177 EXPECT_EQ(TransformationMatrix(), svgWithTransformProperties->transform()->m atrix());
1102 EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), svgWithTransformProperties->local BorderBoxProperties()->paintOffset); 1178 EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), svgWithTransformProperties->local BorderBoxProperties()->paintOffset);
1103 EXPECT_EQ(nullptr, svgWithTransformProperties->svgLocalToBorderBoxTransform( )); 1179 EXPECT_EQ(nullptr, svgWithTransformProperties->svgLocalToBorderBoxTransform( ));
1104 1180
1105 LayoutObject& rectWithTransform = *document().getElementById("rect")->layout Object(); 1181 LayoutObject& rectWithTransform = *document().getElementById("rect")->layout Object();
1106 const ObjectPaintProperties* rectWithTransformProperties = rectWithTransform .objectPaintProperties(); 1182 const ObjectPaintProperties* rectWithTransformProperties = rectWithTransform .objectPaintProperties();
1107 EXPECT_EQ(TransformationMatrix().translate(1, 1), rectWithTransformPropertie s->transform()->matrix()); 1183 EXPECT_EQ(TransformationMatrix().translate(1, 1), rectWithTransformPropertie s->transform()->matrix());
1108 1184
1109 // Ensure there is no PaintOffset transform between the rect and the svg's t ransform. 1185 // Ensure there is no PaintOffset transform between the rect and the svg's t ransform.
1110 EXPECT_EQ(svgWithTransformProperties->transform(), rectWithTransformProperti es->transform()->parent()); 1186 EXPECT_EQ(svgWithTransformProperties->transform(), rectWithTransformProperti es->transform()->parent());
1111 } 1187 }
1112 1188
1113 TEST_F(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) 1189 TEST_F(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault)
1114 { 1190 {
1115 setBodyInnerHTML("<div style=\"transform: translateZ(0)\"></div>"); 1191 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>");
1116 1192
1117 const ObjectPaintProperties* properties = document().body()->firstChild()->l ayoutObject()->objectPaintProperties(); 1193 const ObjectPaintProperties* properties = document().body()->firstChild()->l ayoutObject()->objectPaintProperties();
1118 ASSERT_TRUE(properties->transform()); 1194 ASSERT_TRUE(properties->transform());
1119 EXPECT_FALSE(properties->transform()->hasRenderingContext()); 1195 EXPECT_FALSE(properties->transform()->hasRenderingContext());
1120 } 1196 }
1121 1197
1122 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext) 1198 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext)
1123 { 1199 {
1124 setBodyInnerHTML( 1200 setBodyInnerHTML(
1125 "<div style=\"transform-style: preserve-3d\">" 1201 "<div style='transform-style: preserve-3d'>"
1126 " <div id=\"a\" style=\"transform: translateZ(0)\"></div>" 1202 " <div id='a' style='transform: translateZ(0); width: 30px; height: 40p x'></div>"
1127 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" 1203 " <div id='b' style='transform: translateZ(0); width: 20px; height: 10p x'></div>"
1128 "</div>"); 1204 "</div>");
1205 FrameView* frameView = document().view();
1129 1206
1130 const ObjectPaintProperties* aProperties = document().getElementById("a")->l ayoutObject()->objectPaintProperties(); 1207 LayoutObject* a = document().getElementById("a")->layoutObject();
1131 const ObjectPaintProperties* bProperties = document().getElementById("b")->l ayoutObject()->objectPaintProperties(); 1208 const ObjectPaintProperties* aProperties = a->objectPaintProperties();
1209 LayoutObject* b = document().getElementById("b")->layoutObject();
1210 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1132 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); 1211 ASSERT_TRUE(aProperties->transform() && bProperties->transform());
1133 EXPECT_NE(aProperties->transform(), bProperties->transform()); 1212 EXPECT_NE(aProperties->transform(), bProperties->transform());
1134 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); 1213 EXPECT_TRUE(aProperties->transform()->hasRenderingContext());
1135 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); 1214 EXPECT_TRUE(bProperties->transform()->hasRenderingContext());
1136 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans form()->renderingContextID()); 1215 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans form()->renderingContextID());
1216 CHECK_VISUAL_RECT(a, frameView->layoutView());
1217 CHECK_VISUAL_RECT(b, frameView->layoutView());
1137 } 1218 }
1138 1219
1139 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) 1220 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext)
1140 { 1221 {
1141 setBodyInnerHTML( 1222 setBodyInnerHTML(
1142 "<div style=\"transform-style: preserve-3d\">" 1223 "<div style='transform-style: preserve-3d'>"
1143 " <div id=\"a\" style=\"transform: translateZ(0)\">" 1224 " <div id='a' style='transform: translateZ(0); width: 30px; height: 40p x'>"
1144 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" 1225 " <div id='b' style='transform: translateZ(0); width: 10px; height: 2 0px'></div>"
1145 " </div>" 1226 " </div>"
1146 "</div>"); 1227 "</div>");
1228 FrameView* frameView = document().view();
1147 1229
1148 ASSERT_FALSE(document().getElementById("a")->layoutObject()->styleRef().pres erves3D()); 1230 LayoutObject* a = document().getElementById("a")->layoutObject();
1149 const ObjectPaintProperties* aProperties = document().getElementById("a")->l ayoutObject()->objectPaintProperties(); 1231 const ObjectPaintProperties* aProperties = a->objectPaintProperties();
1150 const ObjectPaintProperties* bProperties = document().getElementById("b")->l ayoutObject()->objectPaintProperties(); 1232 LayoutObject* b = document().getElementById("b")->layoutObject();
1233 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1234 ASSERT_FALSE(a->styleRef().preserves3D());
1235
1151 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); 1236 ASSERT_TRUE(aProperties->transform() && bProperties->transform());
1152 1237
1153 // #a should participate in a rendering context (due to its parent), but its 1238 // #a should participate in a rendering context (due to its parent), but its
1154 // child #b should not. 1239 // child #b should not.
1155 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); 1240 EXPECT_TRUE(aProperties->transform()->hasRenderingContext());
1156 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); 1241 EXPECT_FALSE(bProperties->transform()->hasRenderingContext());
1242 CHECK_VISUAL_RECT(a, frameView->layoutView());
1243 CHECK_VISUAL_RECT(b, frameView->layoutView());
1157 } 1244 }
1158 1245
1159 TEST_F(PaintPropertyTreeBuilderTest, NestedRenderingContexts) 1246 TEST_F(PaintPropertyTreeBuilderTest, NestedRenderingContexts)
1160 { 1247 {
1161 setBodyInnerHTML( 1248 setBodyInnerHTML(
1162 "<div style=\"transform-style: preserve-3d\">" 1249 "<div style='transform-style: preserve-3d'>"
1163 " <div id=\"a\" style=\"transform: translateZ(0)\">" 1250 " <div id='a' style='transform: translateZ(0); width: 50px; height: 60p x'>"
1164 " <div style=\"transform-style: preserve-3d\">" 1251 " <div style='transform-style: preserve-3d; width: 30px; height: 40px '>"
1165 " <div id=\"b\" style=\"transform: translateZ(0)\">" 1252 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20px'>"
1166 " </div>" 1253 " </div>"
1167 " </div>" 1254 " </div>"
1168 "</div>"); 1255 "</div>");
1256 FrameView* frameView = document().view();
1169 1257
1170 ASSERT_FALSE(document().getElementById("a")->layoutObject()->styleRef().pres erves3D()); 1258 LayoutObject* a = document().getElementById("a")->layoutObject();
1171 const ObjectPaintProperties* aProperties = document().getElementById("a")->l ayoutObject()->objectPaintProperties(); 1259 const ObjectPaintProperties* aProperties = a->objectPaintProperties();
1172 const ObjectPaintProperties* bProperties = document().getElementById("b")->l ayoutObject()->objectPaintProperties(); 1260 LayoutObject* b = document().getElementById("b")->layoutObject();
1261 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1262 ASSERT_FALSE(a->styleRef().preserves3D());
1173 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); 1263 ASSERT_TRUE(aProperties->transform() && bProperties->transform());
1174 1264
1175 // #a should participate in a rendering context (due to its parent). Its 1265 // #a should participate in a rendering context (due to its parent). Its
1176 // child does preserve 3D, but since #a does not, #a's rendering context is 1266 // child does preserve 3D, but since #a does not, #a's rendering context is
1177 // not passed on to its children. Thus #b ends up in a separate rendering 1267 // not passed on to its children. Thus #b ends up in a separate rendering
1178 // context rooted at its parent. 1268 // context rooted at its parent.
1179 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); 1269 EXPECT_TRUE(aProperties->transform()->hasRenderingContext());
1180 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); 1270 EXPECT_TRUE(bProperties->transform()->hasRenderingContext());
1181 EXPECT_NE(aProperties->transform()->renderingContextID(), bProperties->trans form()->renderingContextID()); 1271 EXPECT_NE(aProperties->transform()->renderingContextID(), bProperties->trans form()->renderingContextID());
1272 CHECK_VISUAL_RECT(a, frameView->layoutView());
1273 CHECK_VISUAL_RECT(b, frameView->layoutView());
1182 } 1274 }
1183 1275
1184 // Returns true if the first node has the second as an ancestor. 1276 // Returns true if the first node has the second as an ancestor.
1185 static bool nodeHasAncestor(const TransformPaintPropertyNode* node, const Transf ormPaintPropertyNode* ancestor) 1277 static bool nodeHasAncestor(const TransformPaintPropertyNode* node, const Transf ormPaintPropertyNode* ancestor)
1186 { 1278 {
1187 while (node) { 1279 while (node) {
1188 if (node == ancestor) 1280 if (node == ancestor)
1189 return true; 1281 return true;
1190 node = node->parent(); 1282 node = node->parent();
1191 } 1283 }
1192 return false; 1284 return false;
1193 } 1285 }
1194 1286
1195 // Returns true if some node will flatten the transform due to |node| before it 1287 // Returns true if some node will flatten the transform due to |node| before it
1196 // is inherited by |node| (including if node->flattensInheritedTransform()). 1288 // is inherited by |node| (including if node->flattensInheritedTransform()).
1197 static bool someNodeFlattensTransform(const TransformPaintPropertyNode* node, co nst TransformPaintPropertyNode* ancestor) 1289 static bool someNodeFlattensTransform(const TransformPaintPropertyNode* node, co nst TransformPaintPropertyNode* ancestor)
1198 { 1290 {
1199 while (node != ancestor) { 1291 while (node != ancestor) {
1200 if (node->flattensInheritedTransform()) 1292 if (node->flattensInheritedTransform())
1201 return true; 1293 return true;
1202 node = node->parent(); 1294 node = node->parent();
1203 } 1295 }
1204 return false; 1296 return false;
1205 } 1297 }
1206 1298
1207 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStylePropagatesToChildren) 1299 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStylePropagatesToChildren)
1208 { 1300 {
1209 setBodyInnerHTML( 1301 setBodyInnerHTML(
1210 "<div id=\"a\" style=\"transform: translateZ(0); transform-style: flat\" >" 1302 "<div id='a' style='transform: translateZ(0); transform-style: flat; wid th: 30px; height: 40px'>"
1211 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" 1303 " <div id='b' style='transform: translateZ(0); width: 10px; height: 10p x'></div>"
1212 "</div>"); 1304 "</div>");
1305 FrameView* frameView = document().view();
1213 1306
1214 const auto* aTransform = document().getElementById("a")->layoutObject()->obj ectPaintProperties()->transform(); 1307 LayoutObject* a = document().getElementById("a")->layoutObject();
1308 LayoutObject* b = document().getElementById("b")->layoutObject();
1309 const auto* aTransform = a->objectPaintProperties()->transform();
1215 ASSERT_TRUE(aTransform); 1310 ASSERT_TRUE(aTransform);
1216 const auto* bTransform = document().getElementById("b")->layoutObject()->obj ectPaintProperties()->transform(); 1311 const auto* bTransform = b->objectPaintProperties()->transform();
1217 ASSERT_TRUE(bTransform); 1312 ASSERT_TRUE(bTransform);
1218 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); 1313 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform));
1219 1314
1220 // Some node must flatten the inherited transform from #a before it reaches 1315 // Some node must flatten the inherited transform from #a before it reaches
1221 // #b's transform. 1316 // #b's transform.
1222 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform)); 1317 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform));
1318 CHECK_VISUAL_RECT(a, frameView->layoutView());
1319 CHECK_VISUAL_RECT(b, frameView->layoutView());
1223 } 1320 }
1224 1321
1225 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DTransformStylePropagatesToChildre n) 1322 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DTransformStylePropagatesToChildre n)
1226 { 1323 {
1227 setBodyInnerHTML( 1324 setBodyInnerHTML(
1228 "<div id=\"a\" style=\"transform: translateZ(0); transform-style: preser ve-3d\">" 1325 "<div id='a' style='transform: translateZ(0); transform-style: preserve- 3d; width: 30px; height: 40px'>"
1229 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" 1326 " <div id='b' style='transform: translateZ(0); width: 10px; height: 10p x'></div>"
1230 "</div>"); 1327 "</div>");
1328 FrameView* frameView = document().view();
1231 1329
1232 const auto* aTransform = document().getElementById("a")->layoutObject()->obj ectPaintProperties()->transform(); 1330 LayoutObject* a = document().getElementById("a")->layoutObject();
1331 LayoutObject* b = document().getElementById("b")->layoutObject();
1332 const auto* aTransform = a->objectPaintProperties()->transform();
1233 ASSERT_TRUE(aTransform); 1333 ASSERT_TRUE(aTransform);
1234 const auto* bTransform = document().getElementById("b")->layoutObject()->obj ectPaintProperties()->transform(); 1334 const auto* bTransform = b->objectPaintProperties()->transform();
1235 ASSERT_TRUE(bTransform); 1335 ASSERT_TRUE(bTransform);
1236 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); 1336 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform));
1237 1337
1238 // No node may flatten the inherited transform from #a before it reaches 1338 // No node may flatten the inherited transform from #a before it reaches
1239 // #b's transform. 1339 // #b's transform.
1240 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform)); 1340 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform));
1341 CHECK_VISUAL_RECT(a, frameView->layoutView());
1342 CHECK_VISUAL_RECT(b, frameView->layoutView());
1241 } 1343 }
1242 1344
1243 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) 1345 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened)
1244 { 1346 {
1245 // It's necessary to make nodes from the one that applies perspective to 1347 // It's necessary to make nodes from the one that applies perspective to
1246 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't 1348 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't
1247 // do anything. 1349 // do anything.
1248 setBodyInnerHTML( 1350 setBodyInnerHTML(
1249 "<div id=\"a\" style=\"perspective: 800px\">" 1351 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>"
1250 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" 1352 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p x'></div>"
1251 "</div>"); 1353 "</div>");
1354 FrameView* frameView = document().view();
1252 1355
1253 const ObjectPaintProperties* aProperties = document().getElementById("a")->l ayoutObject()->objectPaintProperties(); 1356 LayoutObject* a = document().getElementById("a")->layoutObject();
1254 const ObjectPaintProperties* bProperties = document().getElementById("b")->l ayoutObject()->objectPaintProperties(); 1357 LayoutObject* b = document().getElementById("b")->layoutObject();
1358 const ObjectPaintProperties* aProperties = a->objectPaintProperties();
1359 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1255 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); 1360 const TransformPaintPropertyNode* aPerspective = aProperties->perspective();
1256 ASSERT_TRUE(aPerspective); 1361 ASSERT_TRUE(aPerspective);
1257 const TransformPaintPropertyNode* bTransform = bProperties->transform(); 1362 const TransformPaintPropertyNode* bTransform = bProperties->transform();
1258 ASSERT_TRUE(bTransform); 1363 ASSERT_TRUE(bTransform);
1259 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); 1364 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective));
1260 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); 1365 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective));
1366 CHECK_VISUAL_RECT(a, frameView->layoutView());
1367 CHECK_VISUAL_RECT(b, frameView->layoutView());
1261 } 1368 }
1262 1369
1263 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext ) 1370 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext )
1264 { 1371 {
1265 // It's necessary to make nodes from the one that applies perspective to 1372 // It's necessary to make nodes from the one that applies perspective to
1266 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't 1373 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't
1267 // do anything. 1374 // do anything.
1268 setBodyInnerHTML( 1375 setBodyInnerHTML(
1269 "<div id=\"a\" style=\"perspective: 800px\">" 1376 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>"
1270 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" 1377 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p x'></div>"
1271 "</div>"); 1378 "</div>");
1379 FrameView* frameView = document().view();
1272 1380
1273 const ObjectPaintProperties* aProperties = document().getElementById("a")->l ayoutObject()->objectPaintProperties(); 1381 LayoutObject* a = document().getElementById("a")->layoutObject();
1274 const ObjectPaintProperties* bProperties = document().getElementById("b")->l ayoutObject()->objectPaintProperties(); 1382 LayoutObject* b = document().getElementById("b")->layoutObject();
1383 const ObjectPaintProperties* aProperties = a->objectPaintProperties();
1384 const ObjectPaintProperties* bProperties = b->objectPaintProperties();
1275 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); 1385 const TransformPaintPropertyNode* aPerspective = aProperties->perspective();
1276 ASSERT_TRUE(aPerspective); 1386 ASSERT_TRUE(aPerspective);
1277 EXPECT_FALSE(aPerspective->hasRenderingContext()); 1387 EXPECT_FALSE(aPerspective->hasRenderingContext());
1278 const TransformPaintPropertyNode* bTransform = bProperties->transform(); 1388 const TransformPaintPropertyNode* bTransform = bProperties->transform();
1279 ASSERT_TRUE(bTransform); 1389 ASSERT_TRUE(bTransform);
1280 EXPECT_FALSE(bTransform->hasRenderingContext()); 1390 EXPECT_FALSE(bTransform->hasRenderingContext());
1391 CHECK_VISUAL_RECT(a, frameView->layoutView());
1392 CHECK_VISUAL_RECT(b, frameView->layoutView());
1281 } 1393 }
1282 1394
1283 TEST_F(PaintPropertyTreeBuilderTest, CachedProperties) 1395 TEST_F(PaintPropertyTreeBuilderTest, CachedProperties)
1284 { 1396 {
1285 setBodyInnerHTML( 1397 setBodyInnerHTML(
1286 "<div id='a' style='transform: translate(33px, 44px)'>" 1398 "<div id='a' style='transform: translate(33px, 44px); width: 50px; heigh t: 60px'>"
1287 " <div id='b' style='transform: translate(55px, 66px)'>" 1399 " <div id='b' style='transform: translate(55px, 66px); width: 30px; hei ght: 40px'>"
1288 " <div id='c' style='transform: translate(77px, 88px)'>C<div>" 1400 " <div id='c' style='transform: translate(77px, 88px); width: 10px; h eight: 20px'>C<div>"
1289 " </div>" 1401 " </div>"
1290 "</div>"); 1402 "</div>");
1403 FrameView* frameView = document().view();
1291 1404
1292 Element* a = document().getElementById("a"); 1405 Element* a = document().getElementById("a");
1293 const ObjectPaintProperties* aProperties = a->layoutObject()->objectPaintPro perties(); 1406 const ObjectPaintProperties* aProperties = a->layoutObject()->objectPaintPro perties();
1294 const TransformPaintPropertyNode* aTransformNode = aProperties->transform(); 1407 const TransformPaintPropertyNode* aTransformNode = aProperties->transform();
1295 EXPECT_EQ(TransformationMatrix().translate(33, 44), aTransformNode->matrix() ); 1408 EXPECT_EQ(TransformationMatrix().translate(33, 44), aTransformNode->matrix() );
1296 1409
1297 Element* b = document().getElementById("b"); 1410 Element* b = document().getElementById("b");
1298 const ObjectPaintProperties* bProperties = b->layoutObject()->objectPaintPro perties(); 1411 const ObjectPaintProperties* bProperties = b->layoutObject()->objectPaintPro perties();
1299 const TransformPaintPropertyNode* bTransformNode = bProperties->transform(); 1412 const TransformPaintPropertyNode* bTransformNode = bProperties->transform();
1300 EXPECT_EQ(TransformationMatrix().translate(55, 66), bTransformNode->matrix() ); 1413 EXPECT_EQ(TransformationMatrix().translate(55, 66), bTransformNode->matrix() );
1301 1414
1302 Element* c = document().getElementById("c"); 1415 Element* c = document().getElementById("c");
1303 const ObjectPaintProperties* cProperties = c->layoutObject()->objectPaintPro perties(); 1416 const ObjectPaintProperties* cProperties = c->layoutObject()->objectPaintPro perties();
1304 const TransformPaintPropertyNode* cTransformNode = cProperties->transform(); 1417 const TransformPaintPropertyNode* cTransformNode = cProperties->transform();
1305 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix() ); 1418 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix() );
1306 1419
1420 CHECK_VISUAL_RECT(a->layoutObject(), frameView->layoutView());
1421 CHECK_VISUAL_RECT(b->layoutObject(), frameView->layoutView());
1422 CHECK_VISUAL_RECT(c->layoutObject(), frameView->layoutView());
1423
1307 // Change transform of b. B's transform node should be a new node with the n ew value, 1424 // Change transform of b. B's transform node should be a new node with the n ew value,
1308 // and a and c's transform nodes should be unchanged (with c's parent adjust ed). 1425 // and a and c's transform nodes should be unchanged (with c's parent adjust ed).
1309 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)"); 1426 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)");
1310 document().view()->updateAllLifecyclePhases(); 1427 document().view()->updateAllLifecyclePhases();
1311 1428
1312 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); 1429 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties());
1313 EXPECT_EQ(aTransformNode, aProperties->transform()); 1430 EXPECT_EQ(aTransformNode, aProperties->transform());
1314 1431
1315 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); 1432 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties());
1316 bTransformNode = bProperties->transform(); 1433 bTransformNode = bProperties->transform();
1317 EXPECT_EQ(TransformationMatrix().translate(111, 222), bTransformNode->matrix ()); 1434 EXPECT_EQ(TransformationMatrix().translate(111, 222), bTransformNode->matrix ());
1318 EXPECT_EQ(aTransformNode, bTransformNode->parent()); 1435 EXPECT_EQ(aTransformNode, bTransformNode->parent());
1319 1436
1320 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); 1437 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties());
1321 EXPECT_EQ(cTransformNode, cProperties->transform()); 1438 EXPECT_EQ(cTransformNode, cProperties->transform());
1322 EXPECT_EQ(bTransformNode, cTransformNode->parent()); 1439 EXPECT_EQ(bTransformNode, cTransformNode->parent());
1323 1440
1441 CHECK_VISUAL_RECT(a->layoutObject(), frameView->layoutView());
1442 CHECK_VISUAL_RECT(b->layoutObject(), frameView->layoutView());
1443 CHECK_VISUAL_RECT(c->layoutObject(), frameView->layoutView());
1444
1324 // Remove transform from b. B's transform node should be removed from the tr ee, 1445 // Remove transform from b. B's transform node should be removed from the tr ee,
1325 // and a and c's transform nodes should be unchanged (with c's parent adjust ed). 1446 // and a and c's transform nodes should be unchanged (with c's parent adjust ed).
1326 b->setAttribute(HTMLNames::styleAttr, ""); 1447 b->setAttribute(HTMLNames::styleAttr, "");
1327 document().view()->updateAllLifecyclePhases(); 1448 document().view()->updateAllLifecyclePhases();
1328 1449
1329 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); 1450 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties());
1330 EXPECT_EQ(aTransformNode, aProperties->transform()); 1451 EXPECT_EQ(aTransformNode, aProperties->transform());
1331 1452
1332 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); 1453 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties());
1333 EXPECT_EQ(nullptr, bProperties->transform()); 1454 EXPECT_EQ(nullptr, bProperties->transform());
1334 1455
1335 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); 1456 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties());
1336 EXPECT_EQ(cTransformNode, cProperties->transform()); 1457 EXPECT_EQ(cTransformNode, cProperties->transform());
1337 EXPECT_EQ(aTransformNode, cTransformNode->parent()); 1458 EXPECT_EQ(aTransformNode, cTransformNode->parent());
1338 1459
1460 CHECK_VISUAL_RECT(a->layoutObject(), frameView->layoutView());
1461 CHECK_VISUAL_RECT(b->layoutObject(), frameView->layoutView());
1462 CHECK_VISUAL_RECT(c->layoutObject(), frameView->layoutView());
1463
1339 // Re-add transform to b. B's transform node should be inserted into the tre e, 1464 // Re-add transform to b. B's transform node should be inserted into the tre e,
1340 // and a and c's transform nodes should be unchanged (with c's parent adjust ed). 1465 // and a and c's transform nodes should be unchanged (with c's parent adjust ed).
1341 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)"); 1466 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)");
1342 document().view()->updateAllLifecyclePhases(); 1467 document().view()->updateAllLifecyclePhases();
1343 1468
1344 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); 1469 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties());
1345 EXPECT_EQ(aTransformNode, aProperties->transform()); 1470 EXPECT_EQ(aTransformNode, aProperties->transform());
1346 1471
1347 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); 1472 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties());
1348 bTransformNode = bProperties->transform(); 1473 bTransformNode = bProperties->transform();
1349 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); 1474 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix());
1350 EXPECT_EQ(aTransformNode, bTransformNode->parent()); 1475 EXPECT_EQ(aTransformNode, bTransformNode->parent());
1351 1476
1352 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); 1477 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties());
1353 EXPECT_EQ(cTransformNode, cProperties->transform()); 1478 EXPECT_EQ(cTransformNode, cProperties->transform());
1354 EXPECT_EQ(bTransformNode, cTransformNode->parent()); 1479 EXPECT_EQ(bTransformNode, cTransformNode->parent());
1480
1481 CHECK_VISUAL_RECT(a->layoutObject(), frameView->layoutView());
1482 CHECK_VISUAL_RECT(b->layoutObject(), frameView->layoutView());
1483 CHECK_VISUAL_RECT(c->layoutObject(), frameView->layoutView());
1355 } 1484 }
1356 1485
1357 } // namespace blink 1486 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/paint/PaintPropertyTreePrinter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698