OLD | NEW |
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 | 103 |
104 TEST_F(PaintPropertyTreeBuilderTest, PositionAndScroll) | 104 TEST_F(PaintPropertyTreeBuilderTest, PositionAndScroll) |
105 { | 105 { |
106 loadTestData("position-and-scroll.html"); | 106 loadTestData("position-and-scroll.html"); |
107 | 107 |
108 Element* scroller = document().getElementById("scroller"); | 108 Element* scroller = document().getElementById("scroller"); |
109 scroller->scrollTo(0, 100); | 109 scroller->scrollTo(0, 100); |
110 FrameView* frameView = document().view(); | 110 FrameView* frameView = document().view(); |
111 frameView->updateAllLifecyclePhases(); | 111 frameView->updateAllLifecyclePhases(); |
| 112 ObjectPaintProperties* htmlProperties = document().documentElement()->layout
Object()->objectPaintProperties(); |
| 113 |
112 ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->object
PaintProperties(); | 114 ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->object
PaintProperties(); |
113 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); | 115 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); |
114 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat
ion()->parent()); | 116 EXPECT_EQ(htmlProperties->paintOffsetTranslation(), scrollerProperties->scro
llTranslation()->parent()); |
115 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->overflowClip()
->localTransformSpace()); | 117 EXPECT_EQ(htmlProperties->paintOffsetTranslation(), scrollerProperties->over
flowClip()->localTransformSpace()); |
116 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow
Clip()->clipRect()); | 118 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow
Clip()->clipRect()); |
117 EXPECT_EQ(frameView->contentClip(), scrollerProperties->overflowClip()->pare
nt()); | 119 EXPECT_EQ(htmlProperties->overflowClip(), scrollerProperties->overflowClip()
->parent()); |
118 | 120 |
119 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), | 121 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), |
120 // and should be affected by ancestor scroll transforms. | 122 // and should be affected by ancestor scroll transforms. |
121 Element* relPos = document().getElementById("rel-pos"); | 123 Element* relPos = document().getElementById("rel-pos"); |
122 ObjectPaintProperties* relPosProperties = relPos->layoutObject()->objectPain
tProperties(); | 124 ObjectPaintProperties* relPosProperties = relPos->layoutObject()->objectPain
tProperties(); |
123 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); | 125 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); |
124 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); | 126 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); |
125 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); | 127 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); |
126 EXPECT_EQ(FloatRoundedRect(0, 0, 400, 0), relPosProperties->overflowClip()->
clipRect()); | 128 EXPECT_EQ(FloatRoundedRect(0, 0, 400, 0), relPosProperties->overflowClip()->
clipRect()); |
127 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); | 129 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); |
128 | 130 |
129 // 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. |
130 Element* absPos = document().getElementById("abs-pos"); | 132 Element* absPos = document().getElementById("abs-pos"); |
131 ObjectPaintProperties* absPosProperties = absPos->layoutObject()->objectPain
tProperties(); | 133 ObjectPaintProperties* absPosProperties = absPos->layoutObject()->objectPain
tProperties(); |
132 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); | 134 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); |
133 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans
lation()->parent()); | 135 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans
lation()->parent()); |
134 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); | 136 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); |
135 EXPECT_EQ(FloatRoundedRect(), absPosProperties->overflowClip()->clipRect()); | 137 EXPECT_EQ(FloatRoundedRect(), absPosProperties->overflowClip()->clipRect()); |
136 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent
()); | 138 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent
()); |
137 } | 139 } |
138 | 140 |
139 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) | 141 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) |
140 { | 142 { |
141 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); | 143 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); |
142 | 144 |
143 document().domWindow()->scrollTo(0, 100); | 145 document().domWindow()->scrollTo(0, 100); |
144 | 146 |
145 FrameView* frameView = document().view(); | 147 FrameView* frameView = document().view(); |
146 frameView->updateAllLifecyclePhases(); | 148 frameView->updateAllLifecyclePhases(); |
| 149 |
147 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); | 150 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); |
148 EXPECT_EQ(frameView->rootTransform(), frameView->preTranslation()->parent())
; | 151 EXPECT_EQ(frameView->rootTransform(), frameView->preTranslation()->parent())
; |
149 EXPECT_EQ(nullptr, frameView->rootTransform()->parent()); | 152 EXPECT_EQ(nullptr, frameView->rootTransform()->parent()); |
150 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl
ation()->matrix()); | 153 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl
ation()->matrix()); |
151 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); | 154 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); |
152 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf
ormSpace()); | 155 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf
ormSpace()); |
153 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe
ct()); | 156 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe
ct()); |
154 EXPECT_EQ(frameView->rootClip(), frameView->contentClip()->parent()); | 157 EXPECT_EQ(frameView->rootClip(), frameView->contentClip()->parent()); |
155 EXPECT_EQ(nullptr, frameView->rootClip()->parent()); | 158 EXPECT_EQ(nullptr, frameView->rootClip()->parent()); |
156 | 159 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 Element* inner = document().getElementById("inner"); | 202 Element* inner = document().getElementById("inner"); |
200 ObjectPaintProperties* innerProperties = inner->layoutObject()->objectPaintP
roperties(); | 203 ObjectPaintProperties* innerProperties = inner->layoutObject()->objectPaintP
roperties(); |
201 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO
ffsetTranslation()->matrix()); | 204 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO
ffsetTranslation()->matrix()); |
202 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset
Translation()->parent()); | 205 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset
Translation()->parent()); |
203 } | 206 } |
204 | 207 |
205 TEST_F(PaintPropertyTreeBuilderTest, Transform) | 208 TEST_F(PaintPropertyTreeBuilderTest, Transform) |
206 { | 209 { |
207 loadTestData("transform.html"); | 210 loadTestData("transform.html"); |
208 | 211 |
| 212 ObjectPaintProperties* htmlProperties = document().documentElement()->layout
Object()->objectPaintProperties(); |
209 Element* transform = document().getElementById("transform"); | 213 Element* transform = document().getElementById("transform"); |
210 ObjectPaintProperties* transformProperties = transform->layoutObject()->obje
ctPaintProperties(); | 214 ObjectPaintProperties* transformProperties = transform->layoutObject()->obje
ctPaintProperties(); |
211 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper
ties->transform()->matrix()); | 215 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper
ties->transform()->matrix()); |
212 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi
n()); | 216 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi
n()); |
213 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties
->transform()->parent()); | 217 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties
->transform()->parent()); |
214 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa
intOffsetTranslation()->matrix()); | 218 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa
intOffsetTranslation()->matrix()); |
215 EXPECT_EQ(document().view()->scrollTranslation(), transformProperties->paint
OffsetTranslation()->parent()); | 219 EXPECT_EQ(htmlProperties->paintOffsetTranslation(), transformProperties->pai
ntOffsetTranslation()->parent()); |
216 } | 220 } |
217 | 221 |
218 TEST_F(PaintPropertyTreeBuilderTest, RelativePositionInline) | 222 TEST_F(PaintPropertyTreeBuilderTest, RelativePositionInline) |
219 { | 223 { |
220 loadTestData("relative-position-inline.html"); | 224 loadTestData("relative-position-inline.html"); |
221 | 225 |
| 226 ObjectPaintProperties* htmlProperties = document().documentElement()->layout
Object()->objectPaintProperties(); |
222 Element* inlineBlock = document().getElementById("inline-block"); | 227 Element* inlineBlock = document().getElementById("inline-block"); |
223 ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObject()->
objectPaintProperties(); | 228 ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObject()->
objectPaintProperties(); |
224 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties-
>paintOffsetTranslation()->matrix()); | 229 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties-
>paintOffsetTranslation()->matrix()); |
225 EXPECT_EQ(document().view()->scrollTranslation(), inlineBlockProperties->pai
ntOffsetTranslation()->parent()); | 230 EXPECT_EQ(htmlProperties->paintOffsetTranslation(), inlineBlockProperties->p
aintOffsetTranslation()->parent()); |
226 } | 231 } |
227 | 232 |
228 TEST_F(PaintPropertyTreeBuilderTest, NestedOpacityEffect) | 233 TEST_F(PaintPropertyTreeBuilderTest, NestedOpacityEffect) |
229 { | 234 { |
230 setBodyInnerHTML( | 235 setBodyInnerHTML( |
231 "<div id='nodeWithoutOpacity'>" | 236 "<div id='nodeWithoutOpacity'>" |
232 " <div id='childWithOpacity' style='opacity: 0.5'>" | 237 " <div id='childWithOpacity' style='opacity: 0.5'>" |
233 " <div id='grandChildWithoutOpacity'>" | 238 " <div id='grandChildWithoutOpacity'>" |
234 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2'/>" | 239 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2'/>" |
235 " </div>" | 240 " </div>" |
236 " </div>" | 241 " </div>" |
237 "</div>"); | 242 "</div>"); |
238 | 243 |
239 LayoutObject& nodeWithoutOpacity = *document().getElementById("nodeWithoutOp
acity")->layoutObject(); | 244 LayoutObject& nodeWithoutOpacity = *document().getElementById("nodeWithoutOp
acity")->layoutObject(); |
240 ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpacity.obj
ectPaintProperties(); | 245 ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpacity.obj
ectPaintProperties(); |
241 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); | 246 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); |
242 | 247 |
243 LayoutObject& childWithOpacity = *document().getElementById("childWithOpacit
y")->layoutObject(); | 248 LayoutObject& childWithOpacity = *document().getElementById("childWithOpacit
y")->layoutObject(); |
244 ObjectPaintProperties* childWithOpacityProperties = childWithOpacity.objectP
aintProperties(); | 249 ObjectPaintProperties* childWithOpacityProperties = childWithOpacity.objectP
aintProperties(); |
245 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); | 250 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); |
246 // childWithOpacity is the root effect node. | |
247 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); | 251 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); |
248 | 252 |
249 LayoutObject& grandChildWithoutOpacity = *document().getElementById("grandCh
ildWithoutOpacity")->layoutObject(); | 253 LayoutObject& grandChildWithoutOpacity = *document().getElementById("grandCh
ildWithoutOpacity")->layoutObject(); |
250 EXPECT_NE(nullptr, grandChildWithoutOpacity.objectPaintProperties()); | 254 EXPECT_NE(nullptr, grandChildWithoutOpacity.objectPaintProperties()); |
251 | 255 |
252 LayoutObject& greatGrandChildWithOpacity = *document().getElementById("great
GrandChildWithOpacity")->layoutObject(); | 256 LayoutObject& greatGrandChildWithOpacity = *document().getElementById("great
GrandChildWithOpacity")->layoutObject(); |
253 ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGrandChil
dWithOpacity.objectPaintProperties(); | 257 ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGrandChil
dWithOpacity.objectPaintProperties(); |
254 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); | 258 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); |
255 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr
operties->effect()->parent()); | 259 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr
operties->effect()->parent()); |
256 } | 260 } |
257 | 261 |
258 TEST_F(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) | 262 TEST_F(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) |
259 { | 263 { |
260 setBodyInnerHTML( | 264 setBodyInnerHTML( |
261 "<div id='nodeWithOpacity' style='opacity: 0.6'>" | 265 "<div id='nodeWithOpacity' style='opacity: 0.6'>" |
262 " <div id='childWithTransform' style='transform: translate3d(10px, 10px
, 0px);'>" | 266 " <div id='childWithTransform' style='transform: translate3d(10px, 10px
, 0px);'>" |
263 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" | 267 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" |
264 " </div>" | 268 " </div>" |
265 "</div>"); | 269 "</div>"); |
266 | 270 |
267 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); | 271 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); |
268 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai
ntProperties(); | 272 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai
ntProperties(); |
269 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 273 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
270 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 274 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); |
271 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 275 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
272 | 276 |
273 LayoutObject& childWithTransform = *document().getElementById("childWithTran
sform")->layoutObject(); | 277 LayoutObject& childWithTransform = *document().getElementById("childWithTran
sform")->layoutObject(); |
274 ObjectPaintProperties* childWithTransformProperties = childWithTransform.obj
ectPaintProperties(); | 278 ObjectPaintProperties* childWithTransformProperties = childWithTransform.obj
ectPaintProperties(); |
275 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); | 279 EXPECT_TRUE(childWithTransformProperties->effect()->isIsolationNode()); |
| 280 EXPECT_EQ(nodeWithOpacityProperties->effect(), childWithTransformProperties-
>effect()->parent()); |
276 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper
ties->transform()->matrix()); | 281 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper
ties->transform()->matrix()); |
277 | 282 |
278 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); | 283 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); |
279 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci
ty.objectPaintProperties(); | 284 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci
ty.objectPaintProperties(); |
280 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 285 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
281 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); | 286 EXPECT_EQ(childWithTransformProperties->effect(), grandChildWithOpacityPrope
rties->effect()->parent()); |
282 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 287 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
283 } | 288 } |
284 | 289 |
285 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) | 290 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) |
286 { | 291 { |
287 setBodyInnerHTML( | 292 setBodyInnerHTML( |
288 "<div id='nodeWithOpacity' style='opacity: 0.6'>" | 293 "<div id='nodeWithOpacity' style='opacity: 0.6'>" |
289 " <div id='childWithStackingContext' style='position:absolute;'>" | 294 " <div id='childWithStackingContext' style='position:absolute;'>" |
290 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" | 295 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" |
291 " </div>" | 296 " </div>" |
292 "</div>"); | 297 "</div>"); |
293 | 298 |
| 299 ObjectPaintProperties* htmlProperties = document().documentElement()->layout
Object()->objectPaintProperties(); |
294 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); | 300 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); |
295 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai
ntProperties(); | 301 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai
ntProperties(); |
296 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 302 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
297 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 303 EXPECT_EQ(htmlProperties->effect(), nodeWithOpacityProperties->effect()->par
ent()); |
298 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 304 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
299 | 305 |
300 LayoutObject& childWithStackingContext = *document().getElementById("childWi
thStackingContext")->layoutObject(); | 306 LayoutObject& childWithStackingContext = *document().getElementById("childWi
thStackingContext")->layoutObject(); |
301 ObjectPaintProperties* childWithStackingContextProperties = childWithStackin
gContext.objectPaintProperties(); | 307 ObjectPaintProperties* childWithStackingContextProperties = childWithStackin
gContext.objectPaintProperties(); |
302 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); | 308 EXPECT_TRUE(childWithStackingContextProperties->effect()->isIsolationNode())
; |
| 309 EXPECT_EQ(nodeWithOpacityProperties->effect(), childWithStackingContextPrope
rties->effect()->parent()); |
303 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); | 310 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); |
304 | 311 |
305 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); | 312 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); |
306 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci
ty.objectPaintProperties(); | 313 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci
ty.objectPaintProperties(); |
307 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 314 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
308 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); | 315 EXPECT_EQ(childWithStackingContextProperties->effect(), grandChildWithOpacit
yProperties->effect()->parent()); |
309 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 316 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
310 } | 317 } |
311 | 318 |
312 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG) | 319 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG) |
313 { | 320 { |
314 setBodyInnerHTML( | 321 setBodyInnerHTML( |
315 "<svg id='svgRoot'>" | 322 "<svg id='svgRoot'>" |
316 " <g id='groupWithOpacity' opacity='0.6'>" | 323 " <g id='groupWithOpacity' opacity='0.6'>" |
317 " <rect id='rectWithoutOpacity' />" | 324 " <rect id='rectWithoutOpacity' />" |
318 " <rect id='rectWithOpacity' opacity='0.4' />" | 325 " <rect id='rectWithOpacity' opacity='0.4' />" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), rectProp
erties->transform()->parent()); | 483 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), rectProp
erties->transform()->parent()); |
477 } | 484 } |
478 | 485 |
479 TEST_F(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode) | 486 TEST_F(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode) |
480 { | 487 { |
481 setBodyInnerHTML( | 488 setBodyInnerHTML( |
482 "<style>body { margin: 0px; } </style>" | 489 "<style>body { margin: 0px; } </style>" |
483 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px;
height: 100px;' />"); | 490 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px;
height: 100px;' />"); |
484 | 491 |
485 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 492 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
| 493 ObjectPaintProperties* htmlProperties = document().documentElement()->layout
Object()->objectPaintProperties(); |
486 ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 494 ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); |
487 // Ensure that a paint offset transform is not unnecessarily emitted. | 495 // Ensure that a paint offset transform is not unnecessarily emitted. |
488 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); | 496 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); |
489 EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->svgLocalT
oBorderBoxTransform()->matrix()); | 497 EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->svgLocalT
oBorderBoxTransform()->matrix()); |
490 EXPECT_EQ(document().view()->scrollTranslation(), svgProperties->svgLocalToB
orderBoxTransform()->parent()); | 498 EXPECT_EQ(htmlProperties->paintOffsetTranslation(), svgProperties->svgLocalT
oBorderBoxTransform()->parent()); |
491 } | 499 } |
492 | 500 |
493 TEST_F(PaintPropertyTreeBuilderTest, SVGRootLocalToBorderBoxTransformNode) | 501 TEST_F(PaintPropertyTreeBuilderTest, SVGRootLocalToBorderBoxTransformNode) |
494 { | 502 { |
495 setBodyInnerHTML( | 503 setBodyInnerHTML( |
496 "<style>" | 504 "<style>" |
497 " body { margin: 0px; }" | 505 " body { margin: 0px; }" |
498 " svg { margin-left: 2px; margin-top: 3px; transform: translate(5px, 7p
x); border: 11px solid green; }" | 506 " svg { margin-left: 2px; margin-top: 3px; transform: translate(5px, 7p
x); border: 11px solid green; }" |
499 "</style>" | 507 "</style>" |
500 "<svg id='svg' width='100px' height='100px' viewBox='0 0 13 13'>" | 508 "<svg id='svg' width='100px' height='100px' viewBox='0 0 13 13'>" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 " body {" | 611 " body {" |
604 " margin: 0;" | 612 " margin: 0;" |
605 " }" | 613 " }" |
606 " input {" | 614 " input {" |
607 " border-width: 5px;" | 615 " border-width: 5px;" |
608 " padding: 0;" | 616 " padding: 0;" |
609 " }" | 617 " }" |
610 "</style>" | 618 "</style>" |
611 "<input id='button' type='button' style='width:345px; height:123px' valu
e='some text'/>"); | 619 "<input id='button' type='button' style='width:345px; height:123px' valu
e='some text'/>"); |
612 | 620 |
613 FrameView* frameView = document().view(); | 621 ObjectPaintProperties* htmlProperties = document().documentElement()->layout
Object()->objectPaintProperties(); |
614 LayoutObject& button = *document().getElementById("button")->layoutObject(); | 622 LayoutObject& button = *document().getElementById("button")->layoutObject(); |
615 ObjectPaintProperties* buttonProperties = button.objectPaintProperties(); | 623 ObjectPaintProperties* buttonProperties = button.objectPaintProperties(); |
616 EXPECT_EQ(frameView->scrollTranslation(), buttonProperties->overflowClip()->
localTransformSpace()); | 624 EXPECT_EQ(htmlProperties->paintOffsetTranslation(), buttonProperties->overfl
owClip()->localTransformSpace()); |
617 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip()
->clipRect()); | 625 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip()
->clipRect()); |
618 EXPECT_EQ(frameView->contentClip(), buttonProperties->overflowClip()->parent
()); | 626 EXPECT_EQ(htmlProperties->overflowClip(), buttonProperties->overflowClip()->
parent()); |
619 } | 627 } |
620 | 628 |
621 TEST_F(PaintPropertyTreeBuilderTest, BorderRadiusClip) | 629 TEST_F(PaintPropertyTreeBuilderTest, BorderRadiusClip) |
622 { | 630 { |
623 setBodyInnerHTML( | 631 setBodyInnerHTML( |
624 "<style>" | 632 "<style>" |
625 " body {" | 633 " body {" |
626 " margin: 0px;" | 634 " margin: 0px;" |
627 " }" | 635 " }" |
628 " #div {" | 636 " #div {" |
629 " border-radius: 12px 34px 56px 78px;" | 637 " border-radius: 12px 34px 56px 78px;" |
630 " border-top: 45px solid;" | 638 " border-top: 45px solid;" |
631 " border-right: 50px solid;" | 639 " border-right: 50px solid;" |
632 " border-bottom: 55px solid;" | 640 " border-bottom: 55px solid;" |
633 " border-left: 60px solid;" | 641 " border-left: 60px solid;" |
634 " width: 500px;" | 642 " width: 500px;" |
635 " height: 400px;" | 643 " height: 400px;" |
636 " overflow: scroll;" | 644 " overflow: scroll;" |
637 " }" | 645 " }" |
638 "</style>" | 646 "</style>" |
639 "<div id='div'></div>"); | 647 "<div id='div'></div>"); |
640 | 648 |
641 FrameView* frameView = document().view(); | 649 ObjectPaintProperties* htmlProperties = document().documentElement()->layout
Object()->objectPaintProperties(); |
642 LayoutObject& div = *document().getElementById("div")->layoutObject(); | 650 LayoutObject& div = *document().getElementById("div")->layoutObject(); |
643 ObjectPaintProperties* divProperties = div.objectPaintProperties(); | 651 ObjectPaintProperties* divProperties = div.objectPaintProperties(); |
644 EXPECT_EQ(frameView->scrollTranslation(), divProperties->overflowClip()->loc
alTransformSpace()); | 652 EXPECT_EQ(htmlProperties->paintOffsetTranslation(), divProperties->overflowC
lip()->localTransformSpace()); |
645 // The overflow clip rect includes only the padding box. | 653 // The overflow clip rect includes only the padding box. |
646 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, 45+
55) - scrollbars(15, 15) | 654 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, 45+
55) - scrollbars(15, 15) |
647 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), divProperties->overflowClip()-
>clipRect()); | 655 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), divProperties->overflowClip()-
>clipRect()); |
648 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip(
)->parent(); | 656 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip(
)->parent(); |
649 EXPECT_EQ(frameView->scrollTranslation(), borderRadiusClip->localTransformSp
ace()); | 657 EXPECT_EQ(htmlProperties->paintOffsetTranslation(), borderRadiusClip->localT
ransformSpace()); |
650 // The border radius clip is the area enclosed by inner border edge, includi
ng the scrollbars. | 658 // The border radius clip is the area enclosed by inner border edge, includi
ng the scrollbars. |
651 // As the border-radius is specified in outer radius, the inner radius is ca
lculated by: | 659 // As the border-radius is specified in outer radius, the inner radius is ca
lculated by: |
652 // inner radius = max(outer radius - border width, 0) | 660 // inner radius = max(outer radius - border width, 0) |
653 // In the case that two adjacent borders have different width, the inner rad
ius of the corner | 661 // In the case that two adjacent borders have different width, the inner rad
ius of the corner |
654 // may transition from one value to the other. i.e. being an ellipse. | 662 // may transition from one value to the other. i.e. being an ellipse. |
655 EXPECT_EQ( | 663 EXPECT_EQ( |
656 FloatRoundedRect( | 664 FloatRoundedRect( |
657 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs
et(110, 100) | 665 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs
et(110, 100) |
658 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0,
0)) | 666 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0,
0)) |
659 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0,
0)) | 667 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0,
0)) |
660 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0,
0)) | 668 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0,
0)) |
661 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0,
0)) | 669 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0,
0)) |
662 borderRadiusClip->clipRect()); | 670 borderRadiusClip->clipRect()); |
663 EXPECT_EQ(frameView->contentClip(), borderRadiusClip->parent()); | 671 EXPECT_EQ(htmlProperties->overflowClip(), borderRadiusClip->parent()); |
664 } | 672 } |
665 | 673 |
666 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) | 674 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) |
667 { | 675 { |
668 setBodyInnerHTML( | 676 setBodyInnerHTML( |
669 "<style>body { margin: 0; }</style>" | 677 "<style>body { margin: 0; }</style>" |
670 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" | 678 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" |
671 " <iframe id='frame'></iframe>" | 679 " <iframe id='frame'></iframe>" |
672 "</div>"); | 680 "</div>"); |
673 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0
; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px);'></
div>"); | 681 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0
; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px);'></
div>"); |
674 document().view()->updateAllLifecyclePhases(); | 682 document().view()->updateAllLifecyclePhases(); |
675 | 683 |
676 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); | 684 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); |
677 ObjectPaintProperties* divWithTransformProperties = divWithTransform.objectP
aintProperties(); | 685 ObjectPaintProperties* divWithTransformProperties = divWithTransform.objectP
aintProperties(); |
678 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope
rties->transform()->matrix()); | 686 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope
rties->transform()->matrix()); |
679 | 687 |
680 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); | 688 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); |
681 ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithTransfo
rm->objectPaintProperties(); | 689 ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithTransfo
rm->objectPaintProperties(); |
682 auto* innerDivTransform = innerDivWithTransformProperties->transform(); | 690 auto* innerDivTransform = innerDivWithTransformProperties->transform(); |
683 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma
trix()); | 691 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma
trix()); |
684 | 692 |
685 // Ensure that the inner div's transform is correctly rooted in the root fra
me's transform tree. | 693 // Ensure that the inner div's transform is correctly rooted in the root fra
me's transform tree. |
686 // This asserts that we have the following tree structure: | 694 // This asserts that we have the following tree structure: |
687 // ... | 695 // ... |
688 // Transform transform=translation=1.000000,2.000000,3.000000 | 696 // Transform transform=translation=1.000000,2.000000,3.000000 |
689 // PreTranslation transform=translation=2.000000,2.000000,0.000000 | 697 // PreTranslation transform=translation=2.000000,2.000000,0.000000 |
690 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 | 698 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 |
691 // Transform transform=translation=4.000000,5.000000,6.000000 | 699 // PaintOffsetTransform transform=translation=0.000000,0.000000,0.00
0000 |
692 auto* innerDocumentScrollTranslation = innerDivTransform->parent(); | 700 // Transform transform=translation=4.000000,5.000000,6.000000 |
| 701 auto* innerDocumentHtmlTranslation = innerDivTransform->parent(); |
| 702 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentHtmlTran
slation->matrix()); |
| 703 auto* innerDocumentScrollTranslation = innerDocumentHtmlTranslation->parent(
); |
693 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); | 704 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); |
694 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); | 705 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); |
695 EXPECT_EQ(TransformationMatrix().translate3d(2, 2, 0), iframePreTranslation-
>matrix()); | 706 EXPECT_EQ(TransformationMatrix().translate3d(2, 2, 0), iframePreTranslation-
>matrix()); |
696 EXPECT_EQ(divWithTransformProperties->transform(), iframePreTranslation->par
ent()); | 707 EXPECT_EQ(divWithTransformProperties->transform(), iframePreTranslation->par
ent()); |
697 } | 708 } |
698 | 709 |
699 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes) | 710 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes) |
700 { | 711 { |
701 setBodyInnerHTML( | 712 setBodyInnerHTML( |
702 "<style>body { margin: 0; }</style>" | 713 "<style>body { margin: 0; }</style>" |
703 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" | 714 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" |
704 " <iframe id='frame' style='transform: translate3d(4px, 5px, 6px); bord
er: 42px solid; margin: 7px;'></iframe>" | 715 " <iframe id='frame' style='transform: translate3d(4px, 5px, 6px); bord
er: 42px solid; margin: 7px;'></iframe>" |
705 "</div>"); | 716 "</div>"); |
706 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 3
1px; }</style><div id='transform' style='transform: translate3d(7px, 8px, 9px);'
></div>"); | 717 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 3
1px; }</style><div id='transform' style='transform: translate3d(7px, 8px, 9px);'
></div>"); |
707 document().view()->updateAllLifecyclePhases(); | 718 document().view()->updateAllLifecyclePhases(); |
708 | 719 |
709 // Assert that we have the following tree structure: | 720 // Assert that we have the following tree structure: |
710 // ... | 721 // ... |
711 // Transform transform=translation=1.000000,2.000000,3.000000 | 722 // Transform transform=translation=1.000000,2.000000,3.000000 |
712 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.0000
00 | 723 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.0000
00 |
713 // Transform transform=translation=4.000000,5.000000,6.000000 | 724 // Transform transform=translation=4.000000,5.000000,6.000000 |
714 // PreTranslation transform=translation=42.000000,42.000000,0.000000 | 725 // PreTranslation transform=translation=42.000000,42.000000,0.000000 |
715 // ScrollTranslation transform=translation=0.000000,0.000000,0.000
000 | 726 // ScrollTranslation transform=translation=0.000000,0.000000,0.000
000 |
716 // PaintOffsetTranslation transform=translation=31.000000,31.000
000,0.000000 | 727 // PaintOffssetTransform transform=0.000000,0.000000,0.000000 |
717 // Transform transform=translation=7.000000,8.000000,9.000000 | 728 // PaintOffsetTranslation transform=translation=31.000000,31.0
00000,0.000000 |
| 729 // Transform transform=translation=7.000000,8.000000,9.00000
0 |
718 | 730 |
719 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); | 731 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); |
720 auto* innerDivTransform = innerDivWithTransform->objectPaintProperties()->tr
ansform(); | 732 auto* innerDivTransform = innerDivWithTransform->objectPaintProperties()->tr
ansform(); |
721 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), innerDivTransform->ma
trix()); | 733 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), innerDivTransform->ma
trix()); |
722 | 734 |
723 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent(); | 735 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent(); |
724 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0), innerDocumentPaintO
ffsetTranslation->matrix()); | 736 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0), innerDocumentPaintO
ffsetTranslation->matrix()); |
725 auto* innerDocumentScrollTranslation = innerDocumentPaintOffsetTranslation->
parent(); | 737 auto* innerDocumentHtmlTranslation = innerDocumentPaintOffsetTranslation->pa
rent(); |
| 738 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentHtmlTran
slation->matrix()); |
| 739 auto* innerDocumentScrollTranslation = innerDocumentHtmlTranslation->parent(
); |
726 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); | 740 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); |
727 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); | 741 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); |
728 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), iframePreTranslatio
n->matrix()); | 742 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), iframePreTranslatio
n->matrix()); |
729 auto* iframeTransform = iframePreTranslation->parent(); | 743 auto* iframeTransform = iframePreTranslation->parent(); |
730 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr
ix()); | 744 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr
ix()); |
731 auto* iframePaintOffsetTranslation = iframeTransform->parent(); | 745 auto* iframePaintOffsetTranslation = iframeTransform->parent(); |
732 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran
slation->matrix()); | 746 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran
slation->matrix()); |
733 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); | 747 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); |
734 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans
form->matrix()); | 748 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans
form->matrix()); |
735 | 749 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 "</div>" | 788 "</div>" |
775 ); | 789 ); |
776 | 790 |
777 FrameView* frameView = document().view(); | 791 FrameView* frameView = document().view(); |
778 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); | 792 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); |
779 ObjectPaintProperties* scrollerProperties = scroller.objectPaintProperties()
; | 793 ObjectPaintProperties* scrollerProperties = scroller.objectPaintProperties()
; |
780 LayoutObject& child = *document().getElementById("child")->layoutObject(); | 794 LayoutObject& child = *document().getElementById("child")->layoutObject(); |
781 ObjectPaintProperties* childProperties = child.objectPaintProperties(); | 795 ObjectPaintProperties* childProperties = child.objectPaintProperties(); |
782 | 796 |
783 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie
s()->propertyTreeState.clip); | 797 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie
s()->propertyTreeState.clip); |
784 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro
perties()->propertyTreeState.transform); | 798 |
785 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope
rties()->propertyTreeState.effect); | 799 EXPECT_EQ(childProperties->paintOffsetTranslation(), childProperties->localB
orderBoxProperties()->propertyTreeState.transform); |
| 800 EXPECT_TRUE(childProperties->paintOffsetTranslation()->isIsolationNode()); |
| 801 EXPECT_EQ(frameView->scrollTranslation(), childProperties->paintOffsetTransl
ation()->parent()); |
| 802 |
| 803 EXPECT_EQ(childProperties->effect(), childProperties->localBorderBoxProperti
es()->propertyTreeState.effect); |
| 804 EXPECT_TRUE(childProperties->effect()->isIsolationNode()); |
| 805 EXPECT_EQ(scrollerProperties->effect(), childProperties->effect()->parent())
; |
786 } | 806 } |
787 | 807 |
788 TEST_F(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) | 808 TEST_F(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) |
789 { | 809 { |
790 // This test verifies that the border box space of a table cell is being cor
rectly computed. | 810 // This test verifies that the border box space of a table cell is being cor
rectly computed. |
791 // Table cells have weird location adjustment in our layout/paint implementa
tion. | 811 // Table cells have weird location adjustment in our layout/paint implementa
tion. |
792 setBodyInnerHTML( | 812 setBodyInnerHTML( |
793 "<style>" | 813 "<style>" |
794 " body {" | 814 " body {" |
795 " margin: 0;" | 815 " margin: 0;" |
(...skipping 14 matching lines...) Expand all Loading... |
810 " width: 100px;" | 830 " width: 100px;" |
811 " height: 100px;" | 831 " height: 100px;" |
812 " }" | 832 " }" |
813 "</style>" | 833 "</style>" |
814 "<table>" | 834 "<table>" |
815 " <tr><td></td><td></td></tr>" | 835 " <tr><td></td><td></td></tr>" |
816 " <tr><td></td><td><div id='target'></div></td></tr>" | 836 " <tr><td></td><td><div id='target'></div></td></tr>" |
817 "</table>" | 837 "</table>" |
818 ); | 838 ); |
819 | 839 |
820 FrameView* frameView = document().view(); | 840 ObjectPaintProperties* htmlProperties = document().documentElement()->layout
Object()->objectPaintProperties(); |
821 LayoutObject& target = *document().getElementById("target")->layoutObject(); | 841 LayoutObject& target = *document().getElementById("target")->layoutObject(); |
822 ObjectPaintProperties* targetProperties = target.objectPaintProperties(); | 842 ObjectPaintProperties* targetProperties = target.objectPaintProperties(); |
823 | 843 |
824 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties(
)->paintOffset); | 844 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties(
)->paintOffset); |
825 EXPECT_EQ(frameView->scrollTranslation(), targetProperties->localBorderBoxPr
operties()->propertyTreeState.transform); | 845 EXPECT_EQ(htmlProperties->paintOffsetTranslation(), targetProperties->localB
orderBoxProperties()->propertyTreeState.transform); |
826 } | 846 } |
827 | 847 |
828 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) | 848 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) |
829 { | 849 { |
830 // This test verifies that clip tree hierarchy being generated correctly for
the hard case | 850 // This test verifies that clip tree hierarchy being generated correctly for
the hard case |
831 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. | 851 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. |
832 setBodyInnerHTML( | 852 setBodyInnerHTML( |
833 "<style>" | 853 "<style>" |
834 " #clip {" | 854 " #clip {" |
835 " position: absolute;" | 855 " position: absolute;" |
836 " left: 123px;" | 856 " left: 123px;" |
837 " top: 456px;" | 857 " top: 456px;" |
838 " clip: rect(10px, 80px, 70px, 40px);" | 858 " clip: rect(10px, 80px, 70px, 40px);" |
839 " width: 100px;" | 859 " width: 100px;" |
840 " height: 100px;" | 860 " height: 100px;" |
841 " }" | 861 " }" |
842 " #fixed {" | 862 " #fixed {" |
843 " position: fixed;" | 863 " position: fixed;" |
844 " left: 654px;" | 864 " left: 654px;" |
845 " top: 321px;" | 865 " top: 321px;" |
846 " }" | 866 " }" |
847 "</style>" | 867 "</style>" |
848 "<div id='clip'><div id='fixed'></div></div>" | 868 "<div id='clip'><div id='fixed'></div></div>" |
849 ); | 869 ); |
850 LayoutRect localClipRect(40, 10, 40, 60); | 870 LayoutRect localClipRect(40, 10, 40, 60); |
851 LayoutRect absoluteClipRect = localClipRect; | 871 LayoutRect absoluteClipRect = localClipRect; |
852 absoluteClipRect.move(123, 456); | 872 absoluteClipRect.move(123, 456); |
853 | 873 |
854 FrameView* frameView = document().view(); | 874 FrameView* frameView = document().view(); |
855 | |
856 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); | 875 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); |
857 ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); | 876 ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); |
858 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); | 877 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); |
859 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); | 878 EXPECT_EQ(clipProperties->paintOffsetTranslation(), clipProperties->cssClip(
)->localTransformSpace()); |
| 879 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->paintOffsetTransla
tion()->parent()); |
860 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 880 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
861 | 881 |
862 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); | 882 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); |
863 ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties(); | 883 ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties(); |
864 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); | 884 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); |
865 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); | 885 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); |
866 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 886 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
867 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 887 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
868 } | 888 } |
869 | 889 |
(...skipping 26 matching lines...) Expand all Loading... |
896 " top: 321px;" | 916 " top: 321px;" |
897 " }" | 917 " }" |
898 "</style>" | 918 "</style>" |
899 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>" | 919 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>" |
900 ); | 920 ); |
901 LayoutRect localClipRect(40, 10, 40, 60); | 921 LayoutRect localClipRect(40, 10, 40, 60); |
902 LayoutRect absoluteClipRect = localClipRect; | 922 LayoutRect absoluteClipRect = localClipRect; |
903 absoluteClipRect.move(123, 456); | 923 absoluteClipRect.move(123, 456); |
904 | 924 |
905 FrameView* frameView = document().view(); | 925 FrameView* frameView = document().view(); |
| 926 ObjectPaintProperties* htmlProperties = document().documentElement()->layout
Object()->objectPaintProperties(); |
906 | 927 |
907 LayoutObject& overflow = *document().getElementById("overflow")->layoutObjec
t(); | 928 LayoutObject& overflow = *document().getElementById("overflow")->layoutObjec
t(); |
908 ObjectPaintProperties* overflowProperties = overflow.objectPaintProperties()
; | 929 ObjectPaintProperties* overflowProperties = overflow.objectPaintProperties()
; |
909 EXPECT_EQ(frameView->contentClip(), overflowProperties->overflowClip()->pare
nt()); | 930 EXPECT_EQ(htmlProperties->overflowClip(), overflowProperties->overflowClip()
->parent()); |
910 EXPECT_EQ(frameView->scrollTranslation(), overflowProperties->scrollTranslat
ion()->parent()); | 931 EXPECT_EQ(htmlProperties->paintOffsetTranslation(), overflowProperties->scro
llTranslation()->parent()); |
911 | 932 |
912 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); | 933 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); |
913 ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); | 934 ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); |
914 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par
ent()); | 935 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par
ent()); |
915 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip()
->localTransformSpace()); | 936 EXPECT_EQ(clipProperties->paintOffsetTranslation(), clipProperties->cssClip(
)->localTransformSpace()); |
| 937 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->paintOffs
etTranslation()->parent()); |
916 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 938 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
917 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClipFixedPosition()->
parent()); | 939 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClipFixedPosition()->
parent()); |
918 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi
xedPosition()->localTransformSpace()); | 940 EXPECT_EQ(clipProperties->paintOffsetTranslation(), clipProperties->cssClipF
ixedPosition()->localTransformSpace()); |
| 941 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->paintOffs
etTranslation()->parent()); |
919 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
ClipFixedPosition()->clipRect()); | 942 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
ClipFixedPosition()->clipRect()); |
920 | 943 |
921 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); | 944 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); |
922 ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties(); | 945 ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties(); |
923 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord
erBoxProperties()->propertyTreeState.clip); | 946 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord
erBoxProperties()->propertyTreeState.clip); |
924 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); | 947 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); |
925 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 948 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
926 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 949 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
927 } | 950 } |
928 | 951 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); | 1200 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); |
1178 bTransformNode = bProperties->transform(); | 1201 bTransformNode = bProperties->transform(); |
1179 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); | 1202 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); |
1180 EXPECT_EQ(aTransformNode, bTransformNode->parent()); | 1203 EXPECT_EQ(aTransformNode, bTransformNode->parent()); |
1181 | 1204 |
1182 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1205 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); |
1183 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1206 EXPECT_EQ(cTransformNode, cProperties->transform()); |
1184 EXPECT_EQ(bTransformNode, cTransformNode->parent()); | 1207 EXPECT_EQ(bTransformNode, cTransformNode->parent()); |
1185 } | 1208 } |
1186 | 1209 |
| 1210 TEST_F(PaintPropertyTreeBuilderTest, CachedPropertiesStackingContext) |
| 1211 { |
| 1212 setBodyInnerHTML( |
| 1213 "<div id='transform' style='transform: translate(33px, 44px)'>" |
| 1214 " <div id='stacking-context' style='position: absolute; z-index: 0'>Sta
cking-context</div>" |
| 1215 "</div>"); |
| 1216 |
| 1217 Element* transform = document().getElementById("transform"); |
| 1218 ObjectPaintProperties* transformProperties = transform->layoutObject()->obje
ctPaintProperties(); |
| 1219 TransformPaintPropertyNode* transformTransformNode = transformProperties->tr
ansform(); |
| 1220 ASSERT_TRUE(transformTransformNode); |
| 1221 EXPECT_EQ(TransformationMatrix().translate(33, 44), transformTransformNode->
matrix()); |
| 1222 |
| 1223 ClipPaintPropertyNode* transformClipNode = transformProperties->overflowClip
(); |
| 1224 ASSERT_TRUE(transformClipNode); |
| 1225 EXPECT_TRUE(transformClipNode->isIsolationNode()); |
| 1226 |
| 1227 EffectPaintPropertyNode* transformEffectNode = transformProperties->effect()
; |
| 1228 ASSERT_TRUE(transformEffectNode); |
| 1229 EXPECT_EQ(1.0, transformEffectNode->opacity()); |
| 1230 |
| 1231 // The stacking context should have no-op isolation paint property nodes. |
| 1232 Element* stackingContext = document().getElementById("stacking-context"); |
| 1233 ObjectPaintProperties* stackingContextProperties = stackingContext->layoutOb
ject()->objectPaintProperties(); |
| 1234 TransformPaintPropertyNode* stackingContextPaintOffsetTranslationNode = stac
kingContextProperties->paintOffsetTranslation(); |
| 1235 ASSERT_TRUE(stackingContextPaintOffsetTranslationNode); |
| 1236 EXPECT_EQ(transformTransformNode, stackingContextPaintOffsetTranslationNode-
>parent()); |
| 1237 EXPECT_TRUE(stackingContextPaintOffsetTranslationNode->isIsolationNode()); |
| 1238 |
| 1239 EffectPaintPropertyNode* stackingContextEffectNode = stackingContextProperti
es->effect(); |
| 1240 ASSERT_TRUE(stackingContextEffectNode); |
| 1241 EXPECT_EQ(transformEffectNode, stackingContextEffectNode->parent()); |
| 1242 EXPECT_EQ(1.0, stackingContextEffectNode->opacity()); |
| 1243 |
| 1244 ClipPaintPropertyNode* stackingContextClipNode = stackingContextProperties->
overflowClip(); |
| 1245 ASSERT_TRUE(stackingContextClipNode); |
| 1246 EXPECT_EQ(transformClipNode, stackingContextClipNode->parent()); |
| 1247 EXPECT_TRUE(stackingContextClipNode->isIsolationNode()); |
| 1248 |
| 1249 // Change transform. The 'transform' element's transform node should be a ne
w node with the new value, |
| 1250 // and 'stacking-context's nodes should be unchanged (with parent adjusted). |
| 1251 transform->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 2
22px)"); |
| 1252 document().view()->updateAllLifecyclePhases(); |
| 1253 |
| 1254 EXPECT_EQ(transformProperties, transform->layoutObject()->objectPaintPropert
ies()); |
| 1255 EXPECT_NE(transformTransformNode, transformProperties->transform()); |
| 1256 transformTransformNode = transformProperties->transform(); |
| 1257 EXPECT_EQ(TransformationMatrix().translate(111, 222), transformTransformNode
->matrix()); |
| 1258 EXPECT_EQ(transformClipNode, transformProperties->overflowClip()); |
| 1259 EXPECT_EQ(transformEffectNode, transformProperties->effect()); |
| 1260 |
| 1261 EXPECT_EQ(stackingContextProperties, stackingContext->layoutObject()->object
PaintProperties()); |
| 1262 EXPECT_EQ(stackingContextPaintOffsetTranslationNode, stackingContextProperti
es->paintOffsetTranslation()); |
| 1263 EXPECT_EQ(transformTransformNode, stackingContextPaintOffsetTranslationNode-
>parent()); |
| 1264 EXPECT_EQ(stackingContextClipNode, stackingContextProperties->overflowClip()
); |
| 1265 EXPECT_EQ(transformClipNode, stackingContextClipNode->parent()); |
| 1266 EXPECT_EQ(stackingContextEffectNode, stackingContextProperties->effect()); |
| 1267 EXPECT_EQ(transformEffectNode, stackingContextEffectNode->parent()); |
| 1268 } |
| 1269 |
1187 } // namespace blink | 1270 } // namespace blink |
OLD | NEW |