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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 TEST_F(PaintPropertyTreeBuilderTest, FixedPosition) | 72 TEST_F(PaintPropertyTreeBuilderTest, FixedPosition) |
73 { | 73 { |
74 loadTestData("fixed-position.html"); | 74 loadTestData("fixed-position.html"); |
75 | 75 |
76 FrameView* frameView = document().view(); | 76 FrameView* frameView = document().view(); |
77 | 77 |
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 ObjectPaintProperties* target1Properties = target1->layoutObject()->objectPa
intProperties(); | 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 | 88 |
89 // target2 is a fixed-position element inside a transformed scrolling elemen
t. | 89 // 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. | 90 // It should be attached under the scrolled box of the transformed element. |
91 Element* target2 = document().getElementById("target2"); | 91 Element* target2 = document().getElementById("target2"); |
92 ObjectPaintProperties* target2Properties = target2->layoutObject()->objectPa
intProperties(); | 92 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob
jectPaintProperties(); |
93 Element* scroller = document().getElementById("scroller"); | 93 Element* scroller = document().getElementById("scroller"); |
94 ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->object
PaintProperties(); | 94 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); |
95 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai
ntOffsetTranslation()->matrix()); | 95 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai
ntOffsetTranslation()->matrix()); |
96 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO
ffsetTranslation()->parent()); | 96 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO
ffsetTranslation()->parent()); |
97 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov
erflowClip()->localTransformSpace()); | 97 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov
erflowClip()->localTransformSpace()); |
98 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip(
)->clipRect()); | 98 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip(
)->clipRect()); |
99 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli
p()->parent()); | 99 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli
p()->parent()); |
100 | 100 |
101 CHECK_VISUAL_RECT(target1->layoutObject(), frameView->layoutView()); | 101 CHECK_VISUAL_RECT(target1->layoutObject(), frameView->layoutView()); |
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* scrollerProperties = scroller->layoutObject()->object
PaintProperties(); | 112 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); |
113 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); | 113 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); |
114 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat
ion()->parent()); | 114 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat
ion()->parent()); |
115 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->overflowClip()
->localTransformSpace()); | 115 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->overflowClip()
->localTransformSpace()); |
116 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow
Clip()->clipRect()); | 116 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow
Clip()->clipRect()); |
117 EXPECT_EQ(frameView->contentClip(), scrollerProperties->overflowClip()->pare
nt()); | 117 EXPECT_EQ(frameView->contentClip(), scrollerProperties->overflowClip()->pare
nt()); |
118 | 118 |
119 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), | 119 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), |
120 // and should be affected by ancestor scroll transforms. | 120 // and should be affected by ancestor scroll transforms. |
121 Element* relPos = document().getElementById("rel-pos"); | 121 Element* relPos = document().getElementById("rel-pos"); |
122 ObjectPaintProperties* relPosProperties = relPos->layoutObject()->objectPain
tProperties(); | 122 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje
ctPaintProperties(); |
123 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); | 123 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); |
124 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); | 124 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); |
125 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); | 125 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); |
126 EXPECT_EQ(FloatRoundedRect(0, 0, 400, 0), relPosProperties->overflowClip()->
clipRect()); | 126 EXPECT_EQ(FloatRoundedRect(0, 0, 400, 0), relPosProperties->overflowClip()->
clipRect()); |
127 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); | 127 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); |
128 | 128 |
129 // The absolute-positioned element should not be affected by non-positioned
scroller at all. | 129 // The absolute-positioned element should not be affected by non-positioned
scroller at all. |
130 Element* absPos = document().getElementById("abs-pos"); | 130 Element* absPos = document().getElementById("abs-pos"); |
131 ObjectPaintProperties* absPosProperties = absPos->layoutObject()->objectPain
tProperties(); | 131 const ObjectPaintProperties* absPosProperties = absPos->layoutObject()->obje
ctPaintProperties(); |
132 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); | 132 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); |
133 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans
lation()->parent()); | 133 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans
lation()->parent()); |
134 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); | 134 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); |
135 EXPECT_EQ(FloatRoundedRect(), absPosProperties->overflowClip()->clipRect()); | 135 EXPECT_EQ(FloatRoundedRect(), absPosProperties->overflowClip()->clipRect()); |
136 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent
()); | 136 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent
()); |
137 } | 137 } |
138 | 138 |
139 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) | 139 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) |
140 { | 140 { |
141 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); | 141 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); |
142 | 142 |
143 document().domWindow()->scrollTo(0, 100); | 143 document().domWindow()->scrollTo(0, 100); |
144 | 144 |
145 FrameView* frameView = document().view(); | 145 FrameView* frameView = document().view(); |
146 frameView->updateAllLifecyclePhases(); | 146 frameView->updateAllLifecyclePhases(); |
147 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); | 147 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); |
148 EXPECT_EQ(frameView->rootTransform(), frameView->preTranslation()->parent())
; | 148 EXPECT_EQ(frameView->rootTransform(), frameView->preTranslation()->parent())
; |
149 EXPECT_EQ(nullptr, frameView->rootTransform()->parent()); | 149 EXPECT_EQ(nullptr, frameView->rootTransform()->parent()); |
150 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl
ation()->matrix()); | 150 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl
ation()->matrix()); |
151 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); | 151 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); |
152 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf
ormSpace()); | 152 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf
ormSpace()); |
153 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe
ct()); | 153 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe
ct()); |
154 EXPECT_EQ(frameView->rootClip(), frameView->contentClip()->parent()); | 154 EXPECT_EQ(frameView->rootClip(), frameView->contentClip()->parent()); |
155 EXPECT_EQ(nullptr, frameView->rootClip()->parent()); | 155 EXPECT_EQ(nullptr, frameView->rootClip()->parent()); |
156 | 156 |
157 LayoutViewItem layoutViewItem = document().layoutViewItem(); | 157 LayoutViewItem layoutViewItem = document().layoutViewItem(); |
158 ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPaintProp
erties(); | 158 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); |
159 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); | 159 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); |
160 } | 160 } |
161 | 161 |
162 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame
being created. | 162 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame
being created. |
163 // Need to set it during test setup. Besides that, the test still won't work bec
ause | 163 // Need to set it during test setup. Besides that, the test still won't work bec
ause |
164 // root layer scrolling mode is not compatible with SPv2 at this moment. | 164 // root layer scrolling mode is not compatible with SPv2 at this moment. |
165 // (Duplicate display item ID for FrameView and LayoutView.) | 165 // (Duplicate display item ID for FrameView and LayoutView.) |
166 TEST_F(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls) | 166 TEST_F(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls) |
167 { | 167 { |
168 document().settings()->setRootLayerScrolls(true); | 168 document().settings()->setRootLayerScrolls(true); |
169 | 169 |
170 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); | 170 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); |
171 | 171 |
172 document().domWindow()->scrollTo(0, 100); | 172 document().domWindow()->scrollTo(0, 100); |
173 | 173 |
174 FrameView* frameView = document().view(); | 174 FrameView* frameView = document().view(); |
175 frameView->updateAllLifecyclePhases(); | 175 frameView->updateAllLifecyclePhases(); |
176 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); | 176 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); |
177 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); | 177 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); |
178 EXPECT_EQ(TransformationMatrix(), frameView->scrollTranslation()->matrix()); | 178 EXPECT_EQ(TransformationMatrix(), frameView->scrollTranslation()->matrix()); |
179 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); | 179 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); |
180 | 180 |
181 LayoutViewItem layoutViewItem = document().layoutViewItem(); | 181 LayoutViewItem layoutViewItem = document().layoutViewItem(); |
182 ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPaintProp
erties(); | 182 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); |
183 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s
crollTranslation()->matrix()); | 183 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s
crollTranslation()->matrix()); |
184 EXPECT_EQ(frameView->scrollTranslation(), layoutViewProperties->scrollTransl
ation()->parent()); | 184 EXPECT_EQ(frameView->scrollTranslation(), layoutViewProperties->scrollTransl
ation()->parent()); |
185 } | 185 } |
186 | 186 |
187 TEST_F(PaintPropertyTreeBuilderTest, Perspective) | 187 TEST_F(PaintPropertyTreeBuilderTest, Perspective) |
188 { | 188 { |
189 loadTestData("perspective.html"); | 189 loadTestData("perspective.html"); |
190 | 190 |
191 Element* perspective = document().getElementById("perspective"); | 191 Element* perspective = document().getElementById("perspective"); |
192 ObjectPaintProperties* perspectiveProperties = perspective->layoutObject()->
objectPaintProperties(); | 192 const ObjectPaintProperties* perspectiveProperties = perspective->layoutObje
ct()->objectPaintProperties(); |
193 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie
s->perspective()->matrix()); | 193 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie
s->perspective()->matrix()); |
194 // The perspective origin is the center of the border box plus accumulated p
aint offset. | 194 // The perspective origin is the center of the border box plus accumulated p
aint offset. |
195 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o
rigin()); | 195 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o
rigin()); |
196 EXPECT_EQ(document().view()->scrollTranslation(), perspectiveProperties->per
spective()->parent()); | 196 EXPECT_EQ(document().view()->scrollTranslation(), perspectiveProperties->per
spective()->parent()); |
197 | 197 |
198 // Adding perspective doesn't clear paint offset. The paint offset will be p
assed down to children. | 198 // Adding perspective doesn't clear paint offset. The paint offset will be p
assed down to children. |
199 Element* inner = document().getElementById("inner"); | 199 Element* inner = document().getElementById("inner"); |
200 ObjectPaintProperties* innerProperties = inner->layoutObject()->objectPaintP
roperties(); | 200 const ObjectPaintProperties* innerProperties = inner->layoutObject()->object
PaintProperties(); |
201 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO
ffsetTranslation()->matrix()); | 201 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO
ffsetTranslation()->matrix()); |
202 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset
Translation()->parent()); | 202 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset
Translation()->parent()); |
203 } | 203 } |
204 | 204 |
205 TEST_F(PaintPropertyTreeBuilderTest, Transform) | 205 TEST_F(PaintPropertyTreeBuilderTest, Transform) |
206 { | 206 { |
207 loadTestData("transform.html"); | 207 loadTestData("transform.html"); |
208 | 208 |
209 Element* transform = document().getElementById("transform"); | 209 Element* transform = document().getElementById("transform"); |
210 ObjectPaintProperties* transformProperties = transform->layoutObject()->obje
ctPaintProperties(); | 210 const ObjectPaintProperties* transformProperties = transform->layoutObject()
->objectPaintProperties(); |
211 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper
ties->transform()->matrix()); | 211 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper
ties->transform()->matrix()); |
212 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi
n()); | 212 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi
n()); |
213 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties
->transform()->parent()); | 213 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties
->transform()->parent()); |
214 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa
intOffsetTranslation()->matrix()); | 214 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa
intOffsetTranslation()->matrix()); |
215 EXPECT_EQ(document().view()->scrollTranslation(), transformProperties->paint
OffsetTranslation()->parent()); | 215 EXPECT_EQ(document().view()->scrollTranslation(), transformProperties->paint
OffsetTranslation()->parent()); |
216 } | 216 } |
217 | 217 |
218 TEST_F(PaintPropertyTreeBuilderTest, RelativePositionInline) | 218 TEST_F(PaintPropertyTreeBuilderTest, RelativePositionInline) |
219 { | 219 { |
220 loadTestData("relative-position-inline.html"); | 220 loadTestData("relative-position-inline.html"); |
221 | 221 |
222 Element* inlineBlock = document().getElementById("inline-block"); | 222 Element* inlineBlock = document().getElementById("inline-block"); |
223 ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObject()->
objectPaintProperties(); | 223 const ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObje
ct()->objectPaintProperties(); |
224 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties-
>paintOffsetTranslation()->matrix()); | 224 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties-
>paintOffsetTranslation()->matrix()); |
225 EXPECT_EQ(document().view()->scrollTranslation(), inlineBlockProperties->pai
ntOffsetTranslation()->parent()); | 225 EXPECT_EQ(document().view()->scrollTranslation(), inlineBlockProperties->pai
ntOffsetTranslation()->parent()); |
226 } | 226 } |
227 | 227 |
228 TEST_F(PaintPropertyTreeBuilderTest, NestedOpacityEffect) | 228 TEST_F(PaintPropertyTreeBuilderTest, NestedOpacityEffect) |
229 { | 229 { |
230 setBodyInnerHTML( | 230 setBodyInnerHTML( |
231 "<div id='nodeWithoutOpacity'>" | 231 "<div id='nodeWithoutOpacity'>" |
232 " <div id='childWithOpacity' style='opacity: 0.5'>" | 232 " <div id='childWithOpacity' style='opacity: 0.5'>" |
233 " <div id='grandChildWithoutOpacity'>" | 233 " <div id='grandChildWithoutOpacity'>" |
234 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2'/>" | 234 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2'/>" |
235 " </div>" | 235 " </div>" |
236 " </div>" | 236 " </div>" |
237 "</div>"); | 237 "</div>"); |
238 | 238 |
239 LayoutObject& nodeWithoutOpacity = *document().getElementById("nodeWithoutOp
acity")->layoutObject(); | 239 LayoutObject& nodeWithoutOpacity = *document().getElementById("nodeWithoutOp
acity")->layoutObject(); |
240 ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpacity.obj
ectPaintProperties(); | 240 const ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpaci
ty.objectPaintProperties(); |
241 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); | 241 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); |
242 | 242 |
243 LayoutObject& childWithOpacity = *document().getElementById("childWithOpacit
y")->layoutObject(); | 243 LayoutObject& childWithOpacity = *document().getElementById("childWithOpacit
y")->layoutObject(); |
244 ObjectPaintProperties* childWithOpacityProperties = childWithOpacity.objectP
aintProperties(); | 244 const ObjectPaintProperties* childWithOpacityProperties = childWithOpacity.o
bjectPaintProperties(); |
245 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); | 245 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); |
246 // childWithOpacity is the root effect node. | 246 // childWithOpacity is the root effect node. |
247 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); | 247 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); |
248 | 248 |
249 LayoutObject& grandChildWithoutOpacity = *document().getElementById("grandCh
ildWithoutOpacity")->layoutObject(); | 249 LayoutObject& grandChildWithoutOpacity = *document().getElementById("grandCh
ildWithoutOpacity")->layoutObject(); |
250 EXPECT_NE(nullptr, grandChildWithoutOpacity.objectPaintProperties()); | 250 EXPECT_NE(nullptr, grandChildWithoutOpacity.objectPaintProperties()); |
251 | 251 |
252 LayoutObject& greatGrandChildWithOpacity = *document().getElementById("great
GrandChildWithOpacity")->layoutObject(); | 252 LayoutObject& greatGrandChildWithOpacity = *document().getElementById("great
GrandChildWithOpacity")->layoutObject(); |
253 ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGrandChil
dWithOpacity.objectPaintProperties(); | 253 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGra
ndChildWithOpacity.objectPaintProperties(); |
254 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); | 254 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); |
255 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr
operties->effect()->parent()); | 255 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr
operties->effect()->parent()); |
256 } | 256 } |
257 | 257 |
258 TEST_F(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) | 258 TEST_F(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) |
259 { | 259 { |
260 setBodyInnerHTML( | 260 setBodyInnerHTML( |
261 "<div id='nodeWithOpacity' style='opacity: 0.6'>" | 261 "<div id='nodeWithOpacity' style='opacity: 0.6'>" |
262 " <div id='childWithTransform' style='transform: translate3d(10px, 10px
, 0px);'>" | 262 " <div id='childWithTransform' style='transform: translate3d(10px, 10px
, 0px);'>" |
263 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" | 263 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" |
264 " </div>" | 264 " </div>" |
265 "</div>"); | 265 "</div>"); |
266 | 266 |
267 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); | 267 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); |
268 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai
ntProperties(); | 268 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.obj
ectPaintProperties(); |
269 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 269 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
270 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 270 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); |
271 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 271 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
272 | 272 |
273 LayoutObject& childWithTransform = *document().getElementById("childWithTran
sform")->layoutObject(); | 273 LayoutObject& childWithTransform = *document().getElementById("childWithTran
sform")->layoutObject(); |
274 ObjectPaintProperties* childWithTransformProperties = childWithTransform.obj
ectPaintProperties(); | 274 const ObjectPaintProperties* childWithTransformProperties = childWithTransfo
rm.objectPaintProperties(); |
275 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); | 275 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); |
276 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper
ties->transform()->matrix()); | 276 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper
ties->transform()->matrix()); |
277 | 277 |
278 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); | 278 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); |
279 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci
ty.objectPaintProperties(); | 279 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity.objectPaintProperties(); |
280 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 280 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
281 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); | 281 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); |
282 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 282 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
283 } | 283 } |
284 | 284 |
285 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) | 285 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) |
286 { | 286 { |
287 setBodyInnerHTML( | 287 setBodyInnerHTML( |
288 "<div id='nodeWithOpacity' style='opacity: 0.6'>" | 288 "<div id='nodeWithOpacity' style='opacity: 0.6'>" |
289 " <div id='childWithStackingContext' style='position:absolute;'>" | 289 " <div id='childWithStackingContext' style='position:absolute;'>" |
290 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" | 290 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" |
291 " </div>" | 291 " </div>" |
292 "</div>"); | 292 "</div>"); |
293 | 293 |
294 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); | 294 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); |
295 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai
ntProperties(); | 295 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.obj
ectPaintProperties(); |
296 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 296 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
297 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 297 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); |
298 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 298 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
299 | 299 |
300 LayoutObject& childWithStackingContext = *document().getElementById("childWi
thStackingContext")->layoutObject(); | 300 LayoutObject& childWithStackingContext = *document().getElementById("childWi
thStackingContext")->layoutObject(); |
301 ObjectPaintProperties* childWithStackingContextProperties = childWithStackin
gContext.objectPaintProperties(); | 301 const ObjectPaintProperties* childWithStackingContextProperties = childWithS
tackingContext.objectPaintProperties(); |
302 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); | 302 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); |
303 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); | 303 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); |
304 | 304 |
305 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); | 305 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); |
306 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci
ty.objectPaintProperties(); | 306 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity.objectPaintProperties(); |
307 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 307 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
308 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); | 308 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); |
309 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 309 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
310 } | 310 } |
311 | 311 |
312 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG) | 312 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG) |
313 { | 313 { |
314 setBodyInnerHTML( | 314 setBodyInnerHTML( |
315 "<svg id='svgRoot'>" | 315 "<svg id='svgRoot'>" |
316 " <g id='groupWithOpacity' opacity='0.6'>" | 316 " <g id='groupWithOpacity' opacity='0.6'>" |
317 " <rect id='rectWithoutOpacity' />" | 317 " <rect id='rectWithoutOpacity' />" |
318 " <rect id='rectWithOpacity' opacity='0.4' />" | 318 " <rect id='rectWithOpacity' opacity='0.4' />" |
319 " <text id='textWithOpacity' opacity='0.2'>" | 319 " <text id='textWithOpacity' opacity='0.2'>" |
320 " <tspan id='tspanWithOpacity' opacity='0.1' />" | 320 " <tspan id='tspanWithOpacity' opacity='0.1' />" |
321 " </text>" | 321 " </text>" |
322 " </g>" | 322 " </g>" |
323 "</svg>"); | 323 "</svg>"); |
324 | 324 |
325 LayoutObject& groupWithOpacity = *document().getElementById("groupWithOpacit
y")->layoutObject(); | 325 LayoutObject& groupWithOpacity = *document().getElementById("groupWithOpacit
y")->layoutObject(); |
326 ObjectPaintProperties* groupWithOpacityProperties = groupWithOpacity.objectP
aintProperties(); | 326 const ObjectPaintProperties* groupWithOpacityProperties = groupWithOpacity.o
bjectPaintProperties(); |
327 EXPECT_EQ(0.6f, groupWithOpacityProperties->effect()->opacity()); | 327 EXPECT_EQ(0.6f, groupWithOpacityProperties->effect()->opacity()); |
328 EXPECT_NE(nullptr, groupWithOpacityProperties->effect()->parent()); | 328 EXPECT_NE(nullptr, groupWithOpacityProperties->effect()->parent()); |
329 | 329 |
330 LayoutObject& rectWithoutOpacity = *document().getElementById("rectWithoutOp
acity")->layoutObject(); | 330 LayoutObject& rectWithoutOpacity = *document().getElementById("rectWithoutOp
acity")->layoutObject(); |
331 ObjectPaintProperties* rectWithoutOpacityProperties = rectWithoutOpacity.obj
ectPaintProperties(); | 331 const ObjectPaintProperties* rectWithoutOpacityProperties = rectWithoutOpaci
ty.objectPaintProperties(); |
332 EXPECT_EQ(nullptr, rectWithoutOpacityProperties); | 332 EXPECT_EQ(nullptr, rectWithoutOpacityProperties); |
333 | 333 |
334 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity"
)->layoutObject(); | 334 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity"
)->layoutObject(); |
335 ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.objectPai
ntProperties(); | 335 const ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.obj
ectPaintProperties(); |
336 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); | 336 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); |
337 EXPECT_EQ(groupWithOpacityProperties->effect(), rectWithOpacityProperties->e
ffect()->parent()); | 337 EXPECT_EQ(groupWithOpacityProperties->effect(), rectWithOpacityProperties->e
ffect()->parent()); |
338 | 338 |
339 // Ensure that opacity nodes are created for LayoutSVGText which inherits fr
om LayoutSVGBlock instead of LayoutSVGModelObject. | 339 // Ensure that opacity nodes are created for LayoutSVGText which inherits fr
om LayoutSVGBlock instead of LayoutSVGModelObject. |
340 LayoutObject& textWithOpacity = *document().getElementById("textWithOpacity"
)->layoutObject(); | 340 LayoutObject& textWithOpacity = *document().getElementById("textWithOpacity"
)->layoutObject(); |
341 ObjectPaintProperties* textWithOpacityProperties = textWithOpacity.objectPai
ntProperties(); | 341 const ObjectPaintProperties* textWithOpacityProperties = textWithOpacity.obj
ectPaintProperties(); |
342 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity()); | 342 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity()); |
343 EXPECT_EQ(groupWithOpacityProperties->effect(), textWithOpacityProperties->e
ffect()->parent()); | 343 EXPECT_EQ(groupWithOpacityProperties->effect(), textWithOpacityProperties->e
ffect()->parent()); |
344 | 344 |
345 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits f
rom LayoutSVGInline instead of LayoutSVGModelObject. | 345 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits f
rom LayoutSVGInline instead of LayoutSVGModelObject. |
346 LayoutObject& tspanWithOpacity = *document().getElementById("tspanWithOpacit
y")->layoutObject(); | 346 LayoutObject& tspanWithOpacity = *document().getElementById("tspanWithOpacit
y")->layoutObject(); |
347 ObjectPaintProperties* tspanWithOpacityProperties = tspanWithOpacity.objectP
aintProperties(); | 347 const ObjectPaintProperties* tspanWithOpacityProperties = tspanWithOpacity.o
bjectPaintProperties(); |
348 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity()); | 348 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity()); |
349 EXPECT_EQ(textWithOpacityProperties->effect(), tspanWithOpacityProperties->e
ffect()->parent()); | 349 EXPECT_EQ(textWithOpacityProperties->effect(), tspanWithOpacityProperties->e
ffect()->parent()); |
350 } | 350 } |
351 | 351 |
352 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossHTMLSVGBoundary) | 352 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossHTMLSVGBoundary) |
353 { | 353 { |
354 setBodyInnerHTML( | 354 setBodyInnerHTML( |
355 "<div id='divWithOpacity' style='opacity: 0.2;'>" | 355 "<div id='divWithOpacity' style='opacity: 0.2;'>" |
356 " <svg id='svgRootWithOpacity' style='opacity: 0.3;'>" | 356 " <svg id='svgRootWithOpacity' style='opacity: 0.3;'>" |
357 " <rect id='rectWithOpacity' opacity='0.4' />" | 357 " <rect id='rectWithOpacity' opacity='0.4' />" |
358 " </svg>" | 358 " </svg>" |
359 "</div>"); | 359 "</div>"); |
360 | 360 |
361 LayoutObject& divWithOpacity = *document().getElementById("divWithOpacity")-
>layoutObject(); | 361 LayoutObject& divWithOpacity = *document().getElementById("divWithOpacity")-
>layoutObject(); |
362 ObjectPaintProperties* divWithOpacityProperties = divWithOpacity.objectPaint
Properties(); | 362 const ObjectPaintProperties* divWithOpacityProperties = divWithOpacity.objec
tPaintProperties(); |
363 EXPECT_EQ(0.2f, divWithOpacityProperties->effect()->opacity()); | 363 EXPECT_EQ(0.2f, divWithOpacityProperties->effect()->opacity()); |
364 EXPECT_NE(nullptr, divWithOpacityProperties->effect()->parent()); | 364 EXPECT_NE(nullptr, divWithOpacityProperties->effect()->parent()); |
365 | 365 |
366 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp
acity")->layoutObject(); | 366 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp
acity")->layoutObject(); |
367 ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpacity.obj
ectPaintProperties(); | 367 const ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpaci
ty.objectPaintProperties(); |
368 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); | 368 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); |
369 EXPECT_EQ(divWithOpacityProperties->effect(), svgRootWithOpacityProperties->
effect()->parent()); | 369 EXPECT_EQ(divWithOpacityProperties->effect(), svgRootWithOpacityProperties->
effect()->parent()); |
370 | 370 |
371 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity"
)->layoutObject(); | 371 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity"
)->layoutObject(); |
372 ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.objectPai
ntProperties(); | 372 const ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.obj
ectPaintProperties(); |
373 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); | 373 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); |
374 EXPECT_EQ(svgRootWithOpacityProperties->effect(), rectWithOpacityProperties-
>effect()->parent()); | 374 EXPECT_EQ(svgRootWithOpacityProperties->effect(), rectWithOpacityProperties-
>effect()->parent()); |
375 } | 375 } |
376 | 376 |
377 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossSVGHTMLBoundary) | 377 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossSVGHTMLBoundary) |
378 { | 378 { |
379 setBodyInnerHTML( | 379 setBodyInnerHTML( |
380 "<svg id='svgRootWithOpacity' style='opacity: 0.3;'>" | 380 "<svg id='svgRootWithOpacity' style='opacity: 0.3;'>" |
381 " <foreignObject id='foreignObjectWithOpacity' opacity='0.4'>" | 381 " <foreignObject id='foreignObjectWithOpacity' opacity='0.4'>" |
382 " <body>" | 382 " <body>" |
383 " <span id='spanWithOpacity' style='opacity: 0.5'/>" | 383 " <span id='spanWithOpacity' style='opacity: 0.5'/>" |
384 " </body>" | 384 " </body>" |
385 " </foreignObject>" | 385 " </foreignObject>" |
386 "</svg>"); | 386 "</svg>"); |
387 | 387 |
388 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp
acity")->layoutObject(); | 388 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp
acity")->layoutObject(); |
389 ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpacity.obj
ectPaintProperties(); | 389 const ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpaci
ty.objectPaintProperties(); |
390 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); | 390 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); |
391 EXPECT_NE(nullptr, svgRootWithOpacityProperties->effect()->parent()); | 391 EXPECT_NE(nullptr, svgRootWithOpacityProperties->effect()->parent()); |
392 | 392 |
393 LayoutObject& foreignObjectWithOpacity = *document().getElementById("foreign
ObjectWithOpacity")->layoutObject(); | 393 LayoutObject& foreignObjectWithOpacity = *document().getElementById("foreign
ObjectWithOpacity")->layoutObject(); |
394 ObjectPaintProperties* foreignObjectWithOpacityProperties = foreignObjectWit
hOpacity.objectPaintProperties(); | 394 const ObjectPaintProperties* foreignObjectWithOpacityProperties = foreignObj
ectWithOpacity.objectPaintProperties(); |
395 EXPECT_EQ(0.4f, foreignObjectWithOpacityProperties->effect()->opacity()); | 395 EXPECT_EQ(0.4f, foreignObjectWithOpacityProperties->effect()->opacity()); |
396 EXPECT_EQ(svgRootWithOpacityProperties->effect(), foreignObjectWithOpacityPr
operties->effect()->parent()); | 396 EXPECT_EQ(svgRootWithOpacityProperties->effect(), foreignObjectWithOpacityPr
operties->effect()->parent()); |
397 | 397 |
398 LayoutObject& spanWithOpacity = *document().getElementById("spanWithOpacity"
)->layoutObject(); | 398 LayoutObject& spanWithOpacity = *document().getElementById("spanWithOpacity"
)->layoutObject(); |
399 ObjectPaintProperties* spanWithOpacityProperties = spanWithOpacity.objectPai
ntProperties(); | 399 const ObjectPaintProperties* spanWithOpacityProperties = spanWithOpacity.obj
ectPaintProperties(); |
400 EXPECT_EQ(0.5f, spanWithOpacityProperties->effect()->opacity()); | 400 EXPECT_EQ(0.5f, spanWithOpacityProperties->effect()->opacity()); |
401 EXPECT_EQ(foreignObjectWithOpacityProperties->effect(), spanWithOpacityPrope
rties->effect()->parent()); | 401 EXPECT_EQ(foreignObjectWithOpacityProperties->effect(), spanWithOpacityPrope
rties->effect()->parent()); |
402 } | 402 } |
403 | 403 |
404 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInSVG) | 404 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInSVG) |
405 { | 405 { |
406 setBodyInnerHTML( | 406 setBodyInnerHTML( |
407 "<style>" | 407 "<style>" |
408 " body {" | 408 " body {" |
409 " margin: 0px;" | 409 " margin: 0px;" |
410 " }" | 410 " }" |
411 " svg {" | 411 " svg {" |
412 " margin-left: 50px;" | 412 " margin-left: 50px;" |
413 " transform: translate3d(1px, 2px, 3px);" | 413 " transform: translate3d(1px, 2px, 3px);" |
414 " position: absolute;" | 414 " position: absolute;" |
415 " left: 20px;" | 415 " left: 20px;" |
416 " top: 25px;" | 416 " top: 25px;" |
417 " }" | 417 " }" |
418 " rect {" | 418 " rect {" |
419 " transform: translate(100px, 100px) rotate(45deg);" | 419 " transform: translate(100px, 100px) rotate(45deg);" |
420 " transform-origin: 50px 25px;" | 420 " transform-origin: 50px 25px;" |
421 " }" | 421 " }" |
422 "</style>" | 422 "</style>" |
423 "<svg id='svgRootWith3dTransform' width='100px' height='100px'>" | 423 "<svg id='svgRootWith3dTransform' width='100px' height='100px'>" |
424 " <rect id='rectWith2dTransform' width='100px' height='100px' />" | 424 " <rect id='rectWith2dTransform' width='100px' height='100px' />" |
425 "</svg>"); | 425 "</svg>"); |
426 | 426 |
427 LayoutObject& svgRootWith3dTransform = *document().getElementById("svgRootWi
th3dTransform")->layoutObject(); | 427 LayoutObject& svgRootWith3dTransform = *document().getElementById("svgRootWi
th3dTransform")->layoutObject(); |
428 ObjectPaintProperties* svgRootWith3dTransformProperties = svgRootWith3dTrans
form.objectPaintProperties(); | 428 const ObjectPaintProperties* svgRootWith3dTransformProperties = svgRootWith3
dTransform.objectPaintProperties(); |
429 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgRootWith3dTransfor
mProperties->transform()->matrix()); | 429 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgRootWith3dTransfor
mProperties->transform()->matrix()); |
430 EXPECT_EQ(FloatPoint3D(50, 50, 0), svgRootWith3dTransformProperties->transfo
rm()->origin()); | 430 EXPECT_EQ(FloatPoint3D(50, 50, 0), svgRootWith3dTransformProperties->transfo
rm()->origin()); |
431 EXPECT_EQ(svgRootWith3dTransformProperties->paintOffsetTranslation(), svgRoo
tWith3dTransformProperties->transform()->parent()); | 431 EXPECT_EQ(svgRootWith3dTransformProperties->paintOffsetTranslation(), svgRoo
tWith3dTransformProperties->transform()->parent()); |
432 EXPECT_EQ(TransformationMatrix().translate(70, 25), svgRootWith3dTransformPr
operties->paintOffsetTranslation()->matrix()); | 432 EXPECT_EQ(TransformationMatrix().translate(70, 25), svgRootWith3dTransformPr
operties->paintOffsetTranslation()->matrix()); |
433 EXPECT_EQ(document().view()->scrollTranslation(), svgRootWith3dTransformProp
erties->paintOffsetTranslation()->parent()); | 433 EXPECT_EQ(document().view()->scrollTranslation(), svgRootWith3dTransformProp
erties->paintOffsetTranslation()->parent()); |
434 | 434 |
435 LayoutObject& rectWith2dTransform = *document().getElementById("rectWith2dTr
ansform")->layoutObject(); | 435 LayoutObject& rectWith2dTransform = *document().getElementById("rectWith2dTr
ansform")->layoutObject(); |
436 ObjectPaintProperties* rectWith2dTransformProperties = rectWith2dTransform.o
bjectPaintProperties(); | 436 const ObjectPaintProperties* rectWith2dTransformProperties = rectWith2dTrans
form.objectPaintProperties(); |
437 TransformationMatrix matrix; | 437 TransformationMatrix matrix; |
438 matrix.translate(100, 100); | 438 matrix.translate(100, 100); |
439 matrix.rotate(45); | 439 matrix.rotate(45); |
440 // SVG's transform origin is baked into the transform. | 440 // SVG's transform origin is baked into the transform. |
441 matrix.applyTransformOrigin(50, 25, 0); | 441 matrix.applyTransformOrigin(50, 25, 0); |
442 EXPECT_EQ(matrix, rectWith2dTransformProperties->transform()->matrix()); | 442 EXPECT_EQ(matrix, rectWith2dTransformProperties->transform()->matrix()); |
443 EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->transform()-
>origin()); | 443 EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->transform()-
>origin()); |
444 // SVG does not use paint offset. | 444 // SVG does not use paint offset. |
445 EXPECT_EQ(nullptr, rectWith2dTransformProperties->paintOffsetTranslation()); | 445 EXPECT_EQ(nullptr, rectWith2dTransformProperties->paintOffsetTranslation()); |
446 } | 446 } |
(...skipping 11 matching lines...) Expand all Loading... |
458 " }" | 458 " }" |
459 " rect {" | 459 " rect {" |
460 " transform: translate(100px, 100px);" | 460 " transform: translate(100px, 100px);" |
461 " }" | 461 " }" |
462 "</style>" | 462 "</style>" |
463 "<svg id='svgWithViewBox' width='100px' height='100px' viewBox='50 50 10
0 100'>" | 463 "<svg id='svgWithViewBox' width='100px' height='100px' viewBox='50 50 10
0 100'>" |
464 " <rect id='rect' width='100px' height='100px' />" | 464 " <rect id='rect' width='100px' height='100px' />" |
465 "</svg>"); | 465 "</svg>"); |
466 | 466 |
467 LayoutObject& svgWithViewBox = *document().getElementById("svgWithViewBox")-
>layoutObject(); | 467 LayoutObject& svgWithViewBox = *document().getElementById("svgWithViewBox")-
>layoutObject(); |
468 ObjectPaintProperties* svgWithViewBoxProperties = svgWithViewBox.objectPaint
Properties(); | 468 const ObjectPaintProperties* svgWithViewBoxProperties = svgWithViewBox.objec
tPaintProperties(); |
469 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithViewBoxPropert
ies->transform()->matrix()); | 469 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithViewBoxPropert
ies->transform()->matrix()); |
470 EXPECT_EQ(TransformationMatrix().translate(-50, -50), svgWithViewBoxProperti
es->svgLocalToBorderBoxTransform()->matrix()); | 470 EXPECT_EQ(TransformationMatrix().translate(-50, -50), svgWithViewBoxProperti
es->svgLocalToBorderBoxTransform()->matrix()); |
471 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->parent()
, svgWithViewBoxProperties->transform()); | 471 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->parent()
, svgWithViewBoxProperties->transform()); |
472 | 472 |
473 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); | 473 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); |
474 ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); | 474 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); |
475 EXPECT_EQ(TransformationMatrix().translate(100, 100), rectProperties->transf
orm()->matrix()); | 475 EXPECT_EQ(TransformationMatrix().translate(100, 100), rectProperties->transf
orm()->matrix()); |
476 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), rectProp
erties->transform()->parent()); | 476 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), rectProp
erties->transform()->parent()); |
477 } | 477 } |
478 | 478 |
479 TEST_F(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode) | 479 TEST_F(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode) |
480 { | 480 { |
481 setBodyInnerHTML( | 481 setBodyInnerHTML( |
482 "<style>body { margin: 0px; } </style>" | 482 "<style>body { margin: 0px; } </style>" |
483 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px;
height: 100px;' />"); | 483 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px;
height: 100px;' />"); |
484 | 484 |
485 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 485 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
486 ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 486 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); |
487 // Ensure that a paint offset transform is not unnecessarily emitted. | 487 // Ensure that a paint offset transform is not unnecessarily emitted. |
488 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); | 488 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); |
489 EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->svgLocalT
oBorderBoxTransform()->matrix()); | 489 EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->svgLocalT
oBorderBoxTransform()->matrix()); |
490 EXPECT_EQ(document().view()->scrollTranslation(), svgProperties->svgLocalToB
orderBoxTransform()->parent()); | 490 EXPECT_EQ(document().view()->scrollTranslation(), svgProperties->svgLocalToB
orderBoxTransform()->parent()); |
491 } | 491 } |
492 | 492 |
493 TEST_F(PaintPropertyTreeBuilderTest, SVGRootLocalToBorderBoxTransformNode) | 493 TEST_F(PaintPropertyTreeBuilderTest, SVGRootLocalToBorderBoxTransformNode) |
494 { | 494 { |
495 setBodyInnerHTML( | 495 setBodyInnerHTML( |
496 "<style>" | 496 "<style>" |
497 " body { margin: 0px; }" | 497 " body { margin: 0px; }" |
498 " svg { margin-left: 2px; margin-top: 3px; transform: translate(5px, 7p
x); border: 11px solid green; }" | 498 " svg { margin-left: 2px; margin-top: 3px; transform: translate(5px, 7p
x); border: 11px solid green; }" |
499 "</style>" | 499 "</style>" |
500 "<svg id='svg' width='100px' height='100px' viewBox='0 0 13 13'>" | 500 "<svg id='svg' width='100px' height='100px' viewBox='0 0 13 13'>" |
501 " <rect id='rect' transform='translate(17 19)' />" | 501 " <rect id='rect' transform='translate(17 19)' />" |
502 "</svg>"); | 502 "</svg>"); |
503 | 503 |
504 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 504 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
505 ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 505 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); |
506 EXPECT_EQ(TransformationMatrix().translate(2, 3), svgProperties->paintOffset
Translation()->matrix()); | 506 EXPECT_EQ(TransformationMatrix().translate(2, 3), svgProperties->paintOffset
Translation()->matrix()); |
507 EXPECT_EQ(TransformationMatrix().translate(5, 7), svgProperties->transform()
->matrix()); | 507 EXPECT_EQ(TransformationMatrix().translate(5, 7), svgProperties->transform()
->matrix()); |
508 EXPECT_EQ(TransformationMatrix().translate(11, 11).scale(100.0 / 13.0), svgP
roperties->svgLocalToBorderBoxTransform()->matrix()); | 508 EXPECT_EQ(TransformationMatrix().translate(11, 11).scale(100.0 / 13.0), svgP
roperties->svgLocalToBorderBoxTransform()->matrix()); |
509 EXPECT_EQ(svgProperties->paintOffsetTranslation(), svgProperties->transform(
)->parent()); | 509 EXPECT_EQ(svgProperties->paintOffsetTranslation(), svgProperties->transform(
)->parent()); |
510 EXPECT_EQ(svgProperties->transform(), svgProperties->svgLocalToBorderBoxTran
sform()->parent()); | 510 EXPECT_EQ(svgProperties->transform(), svgProperties->svgLocalToBorderBoxTran
sform()->parent()); |
511 | 511 |
512 // Ensure the rect's transform is a child of the local to border box transfo
rm. | 512 // Ensure the rect's transform is a child of the local to border box transfo
rm. |
513 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); | 513 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); |
514 ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); | 514 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); |
515 EXPECT_EQ(TransformationMatrix().translate(17, 19), rectProperties->transfor
m()->matrix()); | 515 EXPECT_EQ(TransformationMatrix().translate(17, 19), rectProperties->transfor
m()->matrix()); |
516 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), rectProperties->tra
nsform()->parent()); | 516 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), rectProperties->tra
nsform()->parent()); |
517 } | 517 } |
518 | 518 |
519 TEST_F(PaintPropertyTreeBuilderTest, SVGNestedViewboxTransforms) | 519 TEST_F(PaintPropertyTreeBuilderTest, SVGNestedViewboxTransforms) |
520 { | 520 { |
521 setBodyInnerHTML( | 521 setBodyInnerHTML( |
522 "<style>body { margin: 0px; } </style>" | 522 "<style>body { margin: 0px; } </style>" |
523 "<svg id='svg' width='100px' height='100px' viewBox='0 0 50 50' style='t
ransform: translate(11px, 11px);'>" | 523 "<svg id='svg' width='100px' height='100px' viewBox='0 0 50 50' style='t
ransform: translate(11px, 11px);'>" |
524 " <svg id='nestedSvg' width='50px' height='50px' viewBox='0 0 5 5'>" | 524 " <svg id='nestedSvg' width='50px' height='50px' viewBox='0 0 5 5'>" |
525 " <rect id='rect' transform='translate(13 13)' />" | 525 " <rect id='rect' transform='translate(13 13)' />" |
526 " </svg>" | 526 " </svg>" |
527 "</svg>"); | 527 "</svg>"); |
528 | 528 |
529 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 529 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
530 ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 530 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); |
531 EXPECT_EQ(TransformationMatrix().translate(11, 11), svgProperties->transform
()->matrix()); | 531 EXPECT_EQ(TransformationMatrix().translate(11, 11), svgProperties->transform
()->matrix()); |
532 EXPECT_EQ(TransformationMatrix().scale(2), svgProperties->svgLocalToBorderBo
xTransform()->matrix()); | 532 EXPECT_EQ(TransformationMatrix().scale(2), svgProperties->svgLocalToBorderBo
xTransform()->matrix()); |
533 | 533 |
534 LayoutObject& nestedSvg = *document().getElementById("nestedSvg")->layoutObj
ect(); | 534 LayoutObject& nestedSvg = *document().getElementById("nestedSvg")->layoutObj
ect(); |
535 ObjectPaintProperties* nestedSvgProperties = nestedSvg.objectPaintProperties
(); | 535 const ObjectPaintProperties* nestedSvgProperties = nestedSvg.objectPaintProp
erties(); |
536 EXPECT_EQ(TransformationMatrix().scale(10), nestedSvgProperties->transform()
->matrix()); | 536 EXPECT_EQ(TransformationMatrix().scale(10), nestedSvgProperties->transform()
->matrix()); |
537 EXPECT_EQ(nullptr, nestedSvgProperties->svgLocalToBorderBoxTransform()); | 537 EXPECT_EQ(nullptr, nestedSvgProperties->svgLocalToBorderBoxTransform()); |
538 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), nestedSvgProperties
->transform()->parent()); | 538 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), nestedSvgProperties
->transform()->parent()); |
539 | 539 |
540 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); | 540 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); |
541 ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); | 541 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); |
542 EXPECT_EQ(TransformationMatrix().translate(13, 13), rectProperties->transfor
m()->matrix()); | 542 EXPECT_EQ(TransformationMatrix().translate(13, 13), rectProperties->transfor
m()->matrix()); |
543 EXPECT_EQ(nestedSvgProperties->transform(), rectProperties->transform()->par
ent()); | 543 EXPECT_EQ(nestedSvgProperties->transform(), rectProperties->transform()->par
ent()); |
544 } | 544 } |
545 | 545 |
546 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSVGHTMLBoundary) | 546 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSVGHTMLBoundary) |
547 { | 547 { |
548 setBodyInnerHTML( | 548 setBodyInnerHTML( |
549 "<style> body { margin: 0px; } </style>" | 549 "<style> body { margin: 0px; } </style>" |
550 "<svg id='svgWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" | 550 "<svg id='svgWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" |
551 " <foreignObject>" | 551 " <foreignObject>" |
552 " <body>" | 552 " <body>" |
553 " <div id='divWithTransform' style='transform: translate3d(3px, 4px
, 5px);'></div>" | 553 " <div id='divWithTransform' style='transform: translate3d(3px, 4px
, 5px);'></div>" |
554 " </body>" | 554 " </body>" |
555 " </foreignObject>" | 555 " </foreignObject>" |
556 "</svg>"); | 556 "</svg>"); |
557 | 557 |
558 LayoutObject& svgWithTransform = *document().getElementById("svgWithTransfor
m")->layoutObject(); | 558 LayoutObject& svgWithTransform = *document().getElementById("svgWithTransfor
m")->layoutObject(); |
559 ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.objectP
aintProperties(); | 559 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o
bjectPaintProperties(); |
560 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithTransformPrope
rties->transform()->matrix()); | 560 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithTransformPrope
rties->transform()->matrix()); |
561 | 561 |
562 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); | 562 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); |
563 ObjectPaintProperties* divWithTransformProperties = divWithTransform.objectP
aintProperties(); | 563 const ObjectPaintProperties* divWithTransformProperties = divWithTransform.o
bjectPaintProperties(); |
564 EXPECT_EQ(TransformationMatrix().translate3d(3, 4, 5), divWithTransformPrope
rties->transform()->matrix()); | 564 EXPECT_EQ(TransformationMatrix().translate3d(3, 4, 5), divWithTransformPrope
rties->transform()->matrix()); |
565 // Ensure the div's transform node is a child of the svg's transform node. | 565 // Ensure the div's transform node is a child of the svg's transform node. |
566 EXPECT_EQ(svgWithTransformProperties->transform(), divWithTransformPropertie
s->transform()->parent()); | 566 EXPECT_EQ(svgWithTransformProperties->transform(), divWithTransformPropertie
s->transform()->parent()); |
567 } | 567 } |
568 | 568 |
569 TEST_F(PaintPropertyTreeBuilderTest, FixedTransformAncestorAcrossSVGHTMLBoundary
) | 569 TEST_F(PaintPropertyTreeBuilderTest, FixedTransformAncestorAcrossSVGHTMLBoundary
) |
570 { | 570 { |
571 setBodyInnerHTML( | 571 setBodyInnerHTML( |
572 "<style> body { margin: 0px; } </style>" | 572 "<style> body { margin: 0px; } </style>" |
573 "<svg id='svg' style='transform: translate3d(1px, 2px, 3px);'>" | 573 "<svg id='svg' style='transform: translate3d(1px, 2px, 3px);'>" |
574 " <g id='container' transform='translate(20 30)'>" | 574 " <g id='container' transform='translate(20 30)'>" |
575 " <foreignObject>" | 575 " <foreignObject>" |
576 " <body>" | 576 " <body>" |
577 " <div id='fixed' style='position: fixed; left: 200px; top: 150px
;'></div>" | 577 " <div id='fixed' style='position: fixed; left: 200px; top: 150px
;'></div>" |
578 " </body>" | 578 " </body>" |
579 " </foreignObject>" | 579 " </foreignObject>" |
580 " </g>" | 580 " </g>" |
581 "</svg>"); | 581 "</svg>"); |
582 | 582 |
583 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 583 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
584 ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 584 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); |
585 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgProperties->transf
orm()->matrix()); | 585 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgProperties->transf
orm()->matrix()); |
586 | 586 |
587 LayoutObject& container = *document().getElementById("container")->layoutObj
ect(); | 587 LayoutObject& container = *document().getElementById("container")->layoutObj
ect(); |
588 ObjectPaintProperties* containerProperties = container.objectPaintProperties
(); | 588 const ObjectPaintProperties* containerProperties = container.objectPaintProp
erties(); |
589 EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->tra
nsform()->matrix()); | 589 EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->tra
nsform()->matrix()); |
590 EXPECT_EQ(svgProperties->transform(), containerProperties->transform()->pare
nt()); | 590 EXPECT_EQ(svgProperties->transform(), containerProperties->transform()->pare
nt()); |
591 | 591 |
592 Element* fixed = document().getElementById("fixed"); | 592 Element* fixed = document().getElementById("fixed"); |
593 ObjectPaintProperties* fixedProperties = fixed->layoutObject()->objectPaintP
roperties(); | 593 const ObjectPaintProperties* fixedProperties = fixed->layoutObject()->object
PaintProperties(); |
594 EXPECT_EQ(TransformationMatrix().translate(200, 150), fixedProperties->paint
OffsetTranslation()->matrix()); | 594 EXPECT_EQ(TransformationMatrix().translate(200, 150), fixedProperties->paint
OffsetTranslation()->matrix()); |
595 // Ensure the fixed position element is rooted at the nearest transform cont
ainer. | 595 // Ensure the fixed position element is rooted at the nearest transform cont
ainer. |
596 EXPECT_EQ(containerProperties->transform(), fixedProperties->paintOffsetTran
slation()->parent()); | 596 EXPECT_EQ(containerProperties->transform(), fixedProperties->paintOffsetTran
slation()->parent()); |
597 } | 597 } |
598 | 598 |
599 TEST_F(PaintPropertyTreeBuilderTest, ControlClip) | 599 TEST_F(PaintPropertyTreeBuilderTest, ControlClip) |
600 { | 600 { |
601 setBodyInnerHTML( | 601 setBodyInnerHTML( |
602 "<style>" | 602 "<style>" |
603 " body {" | 603 " body {" |
604 " margin: 0;" | 604 " margin: 0;" |
605 " }" | 605 " }" |
606 " input {" | 606 " input {" |
607 " border-width: 5px;" | 607 " border-width: 5px;" |
608 " padding: 0;" | 608 " padding: 0;" |
609 " }" | 609 " }" |
610 "</style>" | 610 "</style>" |
611 "<input id='button' type='button' style='width:345px; height:123px' valu
e='some text'/>"); | 611 "<input id='button' type='button' style='width:345px; height:123px' valu
e='some text'/>"); |
612 | 612 |
613 FrameView* frameView = document().view(); | 613 FrameView* frameView = document().view(); |
614 LayoutObject& button = *document().getElementById("button")->layoutObject(); | 614 LayoutObject& button = *document().getElementById("button")->layoutObject(); |
615 ObjectPaintProperties* buttonProperties = button.objectPaintProperties(); | 615 const ObjectPaintProperties* buttonProperties = button.objectPaintProperties
(); |
616 EXPECT_EQ(frameView->scrollTranslation(), buttonProperties->overflowClip()->
localTransformSpace()); | 616 EXPECT_EQ(frameView->scrollTranslation(), buttonProperties->overflowClip()->
localTransformSpace()); |
617 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip()
->clipRect()); | 617 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip()
->clipRect()); |
618 EXPECT_EQ(frameView->contentClip(), buttonProperties->overflowClip()->parent
()); | 618 EXPECT_EQ(frameView->contentClip(), buttonProperties->overflowClip()->parent
()); |
619 } | 619 } |
620 | 620 |
621 TEST_F(PaintPropertyTreeBuilderTest, BorderRadiusClip) | 621 TEST_F(PaintPropertyTreeBuilderTest, BorderRadiusClip) |
622 { | 622 { |
623 setBodyInnerHTML( | 623 setBodyInnerHTML( |
624 "<style>" | 624 "<style>" |
625 " body {" | 625 " body {" |
626 " margin: 0px;" | 626 " margin: 0px;" |
627 " }" | 627 " }" |
628 " #div {" | 628 " #div {" |
629 " border-radius: 12px 34px 56px 78px;" | 629 " border-radius: 12px 34px 56px 78px;" |
630 " border-top: 45px solid;" | 630 " border-top: 45px solid;" |
631 " border-right: 50px solid;" | 631 " border-right: 50px solid;" |
632 " border-bottom: 55px solid;" | 632 " border-bottom: 55px solid;" |
633 " border-left: 60px solid;" | 633 " border-left: 60px solid;" |
634 " width: 500px;" | 634 " width: 500px;" |
635 " height: 400px;" | 635 " height: 400px;" |
636 " overflow: scroll;" | 636 " overflow: scroll;" |
637 " }" | 637 " }" |
638 "</style>" | 638 "</style>" |
639 "<div id='div'></div>"); | 639 "<div id='div'></div>"); |
640 | 640 |
641 FrameView* frameView = document().view(); | 641 FrameView* frameView = document().view(); |
642 LayoutObject& div = *document().getElementById("div")->layoutObject(); | 642 LayoutObject& div = *document().getElementById("div")->layoutObject(); |
643 ObjectPaintProperties* divProperties = div.objectPaintProperties(); | 643 const ObjectPaintProperties* divProperties = div.objectPaintProperties(); |
644 EXPECT_EQ(frameView->scrollTranslation(), divProperties->overflowClip()->loc
alTransformSpace()); | 644 EXPECT_EQ(frameView->scrollTranslation(), divProperties->overflowClip()->loc
alTransformSpace()); |
645 // The overflow clip rect includes only the padding box. | 645 // 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) | 646 // 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()); | 647 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), divProperties->overflowClip()-
>clipRect()); |
648 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip(
)->parent(); | 648 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip(
)->parent(); |
649 EXPECT_EQ(frameView->scrollTranslation(), borderRadiusClip->localTransformSp
ace()); | 649 EXPECT_EQ(frameView->scrollTranslation(), borderRadiusClip->localTransformSp
ace()); |
650 // The border radius clip is the area enclosed by inner border edge, includi
ng the scrollbars. | 650 // 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: | 651 // 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) | 652 // 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 | 653 // In the case that two adjacent borders have different width, the inner rad
ius of the corner |
(...skipping 13 matching lines...) Expand all Loading... |
667 { | 667 { |
668 setBodyInnerHTML( | 668 setBodyInnerHTML( |
669 "<style>body { margin: 0; }</style>" | 669 "<style>body { margin: 0; }</style>" |
670 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" | 670 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" |
671 " <iframe id='frame'></iframe>" | 671 " <iframe id='frame'></iframe>" |
672 "</div>"); | 672 "</div>"); |
673 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0
; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px);'></
div>"); | 673 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0
; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px);'></
div>"); |
674 document().view()->updateAllLifecyclePhases(); | 674 document().view()->updateAllLifecyclePhases(); |
675 | 675 |
676 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); | 676 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); |
677 ObjectPaintProperties* divWithTransformProperties = divWithTransform.objectP
aintProperties(); | 677 const ObjectPaintProperties* divWithTransformProperties = divWithTransform.o
bjectPaintProperties(); |
678 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope
rties->transform()->matrix()); | 678 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope
rties->transform()->matrix()); |
679 | 679 |
680 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); | 680 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); |
681 ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithTransfo
rm->objectPaintProperties(); | 681 const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithT
ransform->objectPaintProperties(); |
682 auto* innerDivTransform = innerDivWithTransformProperties->transform(); | 682 auto* innerDivTransform = innerDivWithTransformProperties->transform(); |
683 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma
trix()); | 683 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma
trix()); |
684 | 684 |
685 // Ensure that the inner div's transform is correctly rooted in the root fra
me's transform tree. | 685 // 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: | 686 // This asserts that we have the following tree structure: |
687 // ... | 687 // ... |
688 // Transform transform=translation=1.000000,2.000000,3.000000 | 688 // Transform transform=translation=1.000000,2.000000,3.000000 |
689 // PreTranslation transform=translation=2.000000,2.000000,0.000000 | 689 // PreTranslation transform=translation=2.000000,2.000000,0.000000 |
690 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 | 690 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 |
691 // Transform transform=translation=4.000000,5.000000,6.000000 | 691 // Transform transform=translation=4.000000,5.000000,6.000000 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 // the painting ancestors. | 744 // the painting ancestors. |
745 setBodyInnerHTML( | 745 setBodyInnerHTML( |
746 "<style>body { margin: 0; }</style>" | 746 "<style>body { margin: 0; }</style>" |
747 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>
" | 747 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>
" |
748 " <div id='child' style='position:relative;'></div>" | 748 " <div id='child' style='position:relative;'></div>" |
749 " <div style='height:10000px;'></div>" | 749 " <div style='height:10000px;'></div>" |
750 "</div>" | 750 "</div>" |
751 ); | 751 ); |
752 | 752 |
753 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); | 753 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); |
754 ObjectPaintProperties* scrollerProperties = scroller.objectPaintProperties()
; | 754 const ObjectPaintProperties* scrollerProperties = scroller.objectPaintProper
ties(); |
755 LayoutObject& child = *document().getElementById("child")->layoutObject(); | 755 LayoutObject& child = *document().getElementById("child")->layoutObject(); |
756 ObjectPaintProperties* childProperties = child.objectPaintProperties(); | 756 const ObjectPaintProperties* childProperties = child.objectPaintProperties()
; |
757 | 757 |
758 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo
xProperties()->propertyTreeState.clip); | 758 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo
xProperties()->propertyTreeState.clip); |
759 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor
derBoxProperties()->propertyTreeState.transform); | 759 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor
derBoxProperties()->propertyTreeState.transform); |
760 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree
State.effect); | 760 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree
State.effect); |
761 } | 761 } |
762 | 762 |
763 TEST_F(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext) | 763 TEST_F(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext) |
764 { | 764 { |
765 // This test verifies the tree builder correctly computes and records the pr
operty tree context | 765 // This test verifies the tree builder correctly computes and records the pr
operty tree context |
766 // for a (pseudo) stacking context that has a scrolling painting ancestor th
at is not its | 766 // for a (pseudo) stacking context that has a scrolling painting ancestor th
at is not its |
767 // containing block (thus should not be scrolled by it). | 767 // containing block (thus should not be scrolled by it). |
768 | 768 |
769 setBodyInnerHTML( | 769 setBodyInnerHTML( |
770 "<style>body { margin: 0; }</style>" | 770 "<style>body { margin: 0; }</style>" |
771 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" | 771 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" |
772 " <div id='child' style='position:absolute; left:0; top:0;'></div>" | 772 " <div id='child' style='position:absolute; left:0; top:0;'></div>" |
773 " <div style='height:10000px;'></div>" | 773 " <div style='height:10000px;'></div>" |
774 "</div>" | 774 "</div>" |
775 ); | 775 ); |
776 | 776 |
777 FrameView* frameView = document().view(); | 777 FrameView* frameView = document().view(); |
778 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); | 778 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); |
779 ObjectPaintProperties* scrollerProperties = scroller.objectPaintProperties()
; | 779 const ObjectPaintProperties* scrollerProperties = scroller.objectPaintProper
ties(); |
780 LayoutObject& child = *document().getElementById("child")->layoutObject(); | 780 LayoutObject& child = *document().getElementById("child")->layoutObject(); |
781 ObjectPaintProperties* childProperties = child.objectPaintProperties(); | 781 const ObjectPaintProperties* childProperties = child.objectPaintProperties()
; |
782 | 782 |
783 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie
s()->propertyTreeState.clip); | 783 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie
s()->propertyTreeState.clip); |
784 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro
perties()->propertyTreeState.transform); | 784 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro
perties()->propertyTreeState.transform); |
785 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope
rties()->propertyTreeState.effect); | 785 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope
rties()->propertyTreeState.effect); |
786 } | 786 } |
787 | 787 |
788 TEST_F(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) | 788 TEST_F(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) |
789 { | 789 { |
790 // This test verifies that the border box space of a table cell is being cor
rectly computed. | 790 // 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. | 791 // Table cells have weird location adjustment in our layout/paint implementa
tion. |
(...skipping 20 matching lines...) Expand all Loading... |
812 " }" | 812 " }" |
813 "</style>" | 813 "</style>" |
814 "<table>" | 814 "<table>" |
815 " <tr><td></td><td></td></tr>" | 815 " <tr><td></td><td></td></tr>" |
816 " <tr><td></td><td><div id='target'></div></td></tr>" | 816 " <tr><td></td><td><div id='target'></div></td></tr>" |
817 "</table>" | 817 "</table>" |
818 ); | 818 ); |
819 | 819 |
820 FrameView* frameView = document().view(); | 820 FrameView* frameView = document().view(); |
821 LayoutObject& target = *document().getElementById("target")->layoutObject(); | 821 LayoutObject& target = *document().getElementById("target")->layoutObject(); |
822 ObjectPaintProperties* targetProperties = target.objectPaintProperties(); | 822 const ObjectPaintProperties* targetProperties = target.objectPaintProperties
(); |
823 | 823 |
824 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties(
)->paintOffset); | 824 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties(
)->paintOffset); |
825 EXPECT_EQ(frameView->scrollTranslation(), targetProperties->localBorderBoxPr
operties()->propertyTreeState.transform); | 825 EXPECT_EQ(frameView->scrollTranslation(), targetProperties->localBorderBoxPr
operties()->propertyTreeState.transform); |
826 } | 826 } |
827 | 827 |
828 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) | 828 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) |
829 { | 829 { |
830 // This test verifies that clip tree hierarchy being generated correctly for
the hard case | 830 // 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. | 831 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. |
832 setBodyInnerHTML( | 832 setBodyInnerHTML( |
(...skipping 14 matching lines...) Expand all Loading... |
847 "</style>" | 847 "</style>" |
848 "<div id='clip'><div id='fixed'></div></div>" | 848 "<div id='clip'><div id='fixed'></div></div>" |
849 ); | 849 ); |
850 LayoutRect localClipRect(40, 10, 40, 60); | 850 LayoutRect localClipRect(40, 10, 40, 60); |
851 LayoutRect absoluteClipRect = localClipRect; | 851 LayoutRect absoluteClipRect = localClipRect; |
852 absoluteClipRect.move(123, 456); | 852 absoluteClipRect.move(123, 456); |
853 | 853 |
854 FrameView* frameView = document().view(); | 854 FrameView* frameView = document().view(); |
855 | 855 |
856 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); | 856 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); |
857 ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); | 857 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); |
858 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); | 858 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); |
859 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); | 859 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); |
860 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 860 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
861 | 861 |
862 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); | 862 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); |
863 ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties(); | 863 const ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties()
; |
864 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); | 864 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); |
865 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); | 865 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); |
866 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 866 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
867 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 867 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
868 } | 868 } |
869 | 869 |
870 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) | 870 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) |
871 { | 871 { |
872 // This test is similar to CSSClipFixedPositionDescendant above, except that | 872 // This test is similar to CSSClipFixedPositionDescendant above, except that |
873 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. | 873 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. |
(...skipping 24 matching lines...) Expand all Loading... |
898 "</style>" | 898 "</style>" |
899 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>" | 899 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>" |
900 ); | 900 ); |
901 LayoutRect localClipRect(40, 10, 40, 60); | 901 LayoutRect localClipRect(40, 10, 40, 60); |
902 LayoutRect absoluteClipRect = localClipRect; | 902 LayoutRect absoluteClipRect = localClipRect; |
903 absoluteClipRect.move(123, 456); | 903 absoluteClipRect.move(123, 456); |
904 | 904 |
905 FrameView* frameView = document().view(); | 905 FrameView* frameView = document().view(); |
906 | 906 |
907 LayoutObject& overflow = *document().getElementById("overflow")->layoutObjec
t(); | 907 LayoutObject& overflow = *document().getElementById("overflow")->layoutObjec
t(); |
908 ObjectPaintProperties* overflowProperties = overflow.objectPaintProperties()
; | 908 const ObjectPaintProperties* overflowProperties = overflow.objectPaintProper
ties(); |
909 EXPECT_EQ(frameView->contentClip(), overflowProperties->overflowClip()->pare
nt()); | 909 EXPECT_EQ(frameView->contentClip(), overflowProperties->overflowClip()->pare
nt()); |
910 EXPECT_EQ(frameView->scrollTranslation(), overflowProperties->scrollTranslat
ion()->parent()); | 910 EXPECT_EQ(frameView->scrollTranslation(), overflowProperties->scrollTranslat
ion()->parent()); |
911 | 911 |
912 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); | 912 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); |
913 ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); | 913 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); |
914 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par
ent()); | 914 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par
ent()); |
915 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip()
->localTransformSpace()); | 915 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip()
->localTransformSpace()); |
916 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 916 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
917 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClipFixedPosition()->
parent()); | 917 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClipFixedPosition()->
parent()); |
918 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi
xedPosition()->localTransformSpace()); | 918 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi
xedPosition()->localTransformSpace()); |
919 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
ClipFixedPosition()->clipRect()); | 919 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
ClipFixedPosition()->clipRect()); |
920 | 920 |
921 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); | 921 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); |
922 ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties(); | 922 const ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties()
; |
923 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord
erBoxProperties()->propertyTreeState.clip); | 923 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord
erBoxProperties()->propertyTreeState.clip); |
924 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); | 924 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); |
925 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 925 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
926 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 926 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
927 } | 927 } |
928 | 928 |
929 TEST_F(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) | 929 TEST_F(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) |
930 { | 930 { |
931 setBodyInnerHTML( | 931 setBodyInnerHTML( |
932 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" | 932 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" |
(...skipping 12 matching lines...) Expand all Loading... |
945 setBodyInnerHTML( | 945 setBodyInnerHTML( |
946 "<style>" | 946 "<style>" |
947 " * { margin: 0; }" | 947 " * { margin: 0; }" |
948 " div { position: absolute; }" | 948 " div { position: absolute; }" |
949 "</style>" | 949 "</style>" |
950 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;'
>" | 950 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;'
>" |
951 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p
x;'></div>" | 951 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p
x;'></div>" |
952 "</div>" | 952 "</div>" |
953 ); | 953 ); |
954 | 954 |
955 ObjectPaintProperties* aProperties = document().getElementById("a")->layoutO
bject()->objectPaintProperties(); | 955 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); |
956 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); | 956 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); |
957 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset
); | 957 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset
); |
958 | 958 |
959 ObjectPaintProperties* bProperties = document().getElementById("b")->layoutO
bject()->objectPaintProperties(); | 959 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
960 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1))
; | 960 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1))
; |
961 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset
); | 961 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset
); |
962 } | 962 } |
963 | 963 |
964 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) | 964 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) |
965 { | 965 { |
966 setBodyInnerHTML( | 966 setBodyInnerHTML( |
967 "<style>" | 967 "<style>" |
968 " * { margin: 0; }" | 968 " * { margin: 0; }" |
969 " div { position: relative; }" | 969 " div { position: relative; }" |
970 "</style>" | 970 "</style>" |
971 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;'
>" | 971 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;'
>" |
972 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" | 972 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" |
973 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1
px;'></div>" | 973 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1
px;'></div>" |
974 " </div>" | 974 " </div>" |
975 "</div>" | 975 "</div>" |
976 ); | 976 ); |
977 | 977 |
978 ObjectPaintProperties* bProperties = document().getElementById("b")->layoutO
bject()->objectPaintProperties(); | 978 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
979 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); | 979 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); |
980 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). | 980 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). |
981 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
parent()->matrix()); | 981 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
parent()->matrix()); |
982 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). | 982 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). |
983 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); | 983 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); |
984 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 984 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
985 | 985 |
986 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = (0.4,0
.4). | 986 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = (0.4,0
.4). |
987 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1
, 0.1)); | 987 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1
, 0.1)); |
988 ObjectPaintProperties* cProperties = document().getElementById("c")->layoutO
bject()->objectPaintProperties(); | 988 const ObjectPaintProperties* cProperties = document().getElementById("c")->l
ayoutObject()->objectPaintProperties(); |
989 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); | 989 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); |
990 } | 990 } |
991 | 991 |
992 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor
m) | 992 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor
m) |
993 { | 993 { |
994 setBodyInnerHTML( | 994 setBodyInnerHTML( |
995 "<style>" | 995 "<style>" |
996 " * { margin: 0; }" | 996 " * { margin: 0; }" |
997 " div { position: relative; }" | 997 " div { position: relative; }" |
998 "</style>" | 998 "</style>" |
999 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" | 999 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" |
1000 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" | 1000 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" |
1001 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7
px;'></div>" | 1001 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7
px;'></div>" |
1002 " </div>" | 1002 " </div>" |
1003 "</div>" | 1003 "</div>" |
1004 ); | 1004 ); |
1005 | 1005 |
1006 ObjectPaintProperties* bProperties = document().getElementById("b")->layoutO
bject()->objectPaintProperties(); | 1006 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
1007 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); | 1007 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); |
1008 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). | 1008 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). |
1009 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); | 1009 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); |
1010 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). | 1010 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). |
1011 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); | 1011 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); |
1012 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1012 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
1013 | 1013 |
1014 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). | 1014 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). |
1015 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); | 1015 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); |
1016 ObjectPaintProperties* cProperties = document().getElementById("c")->layoutO
bject()->objectPaintProperties(); | 1016 const ObjectPaintProperties* cProperties = document().getElementById("c")->l
ayoutObject()->objectPaintProperties(); |
1017 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); | 1017 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); |
1018 } | 1018 } |
1019 | 1019 |
1020 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple
Transforms) | 1020 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple
Transforms) |
1021 { | 1021 { |
1022 setBodyInnerHTML( | 1022 setBodyInnerHTML( |
1023 "<style>" | 1023 "<style>" |
1024 " * { margin: 0; }" | 1024 " * { margin: 0; }" |
1025 " div { position: relative; }" | 1025 " div { position: relative; }" |
1026 "</style>" | 1026 "</style>" |
1027 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" | 1027 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" |
1028 " <div id='b' style='width: 40px; height: 40px; transform: translate3d(
5px, 7px, 0);'>" | 1028 " <div id='b' style='width: 40px; height: 40px; transform: translate3d(
5px, 7px, 0);'>" |
1029 " <div id='c' style='width: 40px; height: 40px; transform: translate3
d(11px, 13px, 0);'>" | 1029 " <div id='c' style='width: 40px; height: 40px; transform: translate3
d(11px, 13px, 0);'>" |
1030 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0
.7px;'></div>" | 1030 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0
.7px;'></div>" |
1031 " </div>" | 1031 " </div>" |
1032 " </div>" | 1032 " </div>" |
1033 "</div>" | 1033 "</div>" |
1034 ); | 1034 ); |
1035 | 1035 |
1036 ObjectPaintProperties* bProperties = document().getElementById("b")->layoutO
bject()->objectPaintProperties(); | 1036 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
1037 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0), bProperties->transfor
m()->matrix()); | 1037 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0), bProperties->transfor
m()->matrix()); |
1038 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). | 1038 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). |
1039 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); | 1039 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); |
1040 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). | 1040 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). |
1041 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); | 1041 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); |
1042 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1042 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
1043 | 1043 |
1044 ObjectPaintProperties* cProperties = document().getElementById("c")->layoutO
bject()->objectPaintProperties(); | 1044 const ObjectPaintProperties* cProperties = document().getElementById("c")->l
ayoutObject()->objectPaintProperties(); |
1045 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), cProperties->transf
orm()->matrix()); | 1045 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), cProperties->transf
orm()->matrix()); |
1046 // The paint offset should be (-0.3,-0.3) but the paint offset transform sho
uld still be at | 1046 // The paint offset should be (-0.3,-0.3) but the paint offset transform sho
uld still be at |
1047 // (0,0) because it should be snapped. | 1047 // (0,0) because it should be snapped. |
1048 EXPECT_EQ(TransformationMatrix().translate(0, 0), cProperties->transform()->
parent()->matrix()); | 1048 EXPECT_EQ(TransformationMatrix().translate(0, 0), cProperties->transform()->
parent()->matrix()); |
1049 // The residual subpixel adjustment should still be (-0.3,-0.3). | 1049 // The residual subpixel adjustment should still be (-0.3,-0.3). |
1050 EXPECT_EQ(subpixelAccumulation, cProperties->localBorderBoxProperties()->pai
ntOffset); | 1050 EXPECT_EQ(subpixelAccumulation, cProperties->localBorderBoxProperties()->pai
ntOffset); |
1051 | 1051 |
1052 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). | 1052 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). |
1053 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); | 1053 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); |
1054 ObjectPaintProperties* dProperties = document().getElementById("d")->layoutO
bject()->objectPaintProperties(); | 1054 const ObjectPaintProperties* dProperties = document().getElementById("d")->l
ayoutObject()->objectPaintProperties(); |
1055 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); | 1055 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); |
1056 } | 1056 } |
1057 | 1057 |
1058 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) | 1058 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) |
1059 { | 1059 { |
1060 setBodyInnerHTML( | 1060 setBodyInnerHTML( |
1061 "<style>" | 1061 "<style>" |
1062 " * { margin: 0; }" | 1062 " * { margin: 0; }" |
1063 "</style>" | 1063 "</style>" |
1064 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re
lative;'>" | 1064 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re
lative;'>" |
1065 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
); position: relative;'>" | 1065 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
); position: relative;'>" |
1066 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;'
>" | 1066 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;'
>" |
1067 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi
on: relative;'></div>" | 1067 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi
on: relative;'></div>" |
1068 " </div>" | 1068 " </div>" |
1069 " </div>" | 1069 " </div>" |
1070 "</div>" | 1070 "</div>" |
1071 ); | 1071 ); |
1072 | 1072 |
1073 ObjectPaintProperties* bProperties = document().getElementById("b")->layoutO
bject()->objectPaintProperties(); | 1073 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
1074 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
matrix()); | 1074 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
matrix()); |
1075 // The paint offset transform should be snapped from (0.7,0) to (1,0). | 1075 // The paint offset transform should be snapped from (0.7,0) to (1,0). |
1076 EXPECT_EQ(TransformationMatrix().translate(1, 0), bProperties->transform()->
parent()->matrix()); | 1076 EXPECT_EQ(TransformationMatrix().translate(1, 0), bProperties->transform()->
parent()->matrix()); |
1077 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0). | 1077 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0). |
1078 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
)) - LayoutPoint(1, 0)); | 1078 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
)) - LayoutPoint(1, 0)); |
1079 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1079 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
1080 | 1080 |
1081 ObjectPaintProperties* fixedProperties = document().getElementById("fixed")-
>layoutObject()->objectPaintProperties(); | 1081 const ObjectPaintProperties* fixedProperties = document().getElementById("fi
xed")->layoutObject()->objectPaintProperties(); |
1082 // The residual subpixel adjustment should still be (-0.3,0). | 1082 // The residual subpixel adjustment should still be (-0.3,0). |
1083 EXPECT_EQ(subpixelAccumulation, fixedProperties->localBorderBoxProperties()-
>paintOffset); | 1083 EXPECT_EQ(subpixelAccumulation, fixedProperties->localBorderBoxProperties()-
>paintOffset); |
1084 | 1084 |
1085 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). | 1085 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). |
1086 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0)); | 1086 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0)); |
1087 ObjectPaintProperties* dProperties = document().getElementById("d")->layoutO
bject()->objectPaintProperties(); | 1087 const ObjectPaintProperties* dProperties = document().getElementById("d")->l
ayoutObject()->objectPaintProperties(); |
1088 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); | 1088 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); |
1089 } | 1089 } |
1090 | 1090 |
1091 TEST_F(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) | 1091 TEST_F(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) |
1092 { | 1092 { |
1093 setBodyInnerHTML( | 1093 setBodyInnerHTML( |
1094 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix
(1, 0, 0, 1, 0, 0);'>" | 1094 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix
(1, 0, 0, 1, 0, 0);'>" |
1095 " <rect id='rect' transform='translate(1, 1)'/>" | 1095 " <rect id='rect' transform='translate(1, 1)'/>" |
1096 "</svg>"); | 1096 "</svg>"); |
1097 | 1097 |
1098 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb
ject(); | 1098 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb
ject(); |
1099 ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.objectP
aintProperties(); | 1099 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o
bjectPaintProperties(); |
1100 EXPECT_EQ(TransformationMatrix(), svgWithTransformProperties->transform()->m
atrix()); | 1100 EXPECT_EQ(TransformationMatrix(), svgWithTransformProperties->transform()->m
atrix()); |
1101 EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), svgWithTransformProperties->local
BorderBoxProperties()->paintOffset); | 1101 EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), svgWithTransformProperties->local
BorderBoxProperties()->paintOffset); |
1102 EXPECT_EQ(nullptr, svgWithTransformProperties->svgLocalToBorderBoxTransform(
)); | 1102 EXPECT_EQ(nullptr, svgWithTransformProperties->svgLocalToBorderBoxTransform(
)); |
1103 | 1103 |
1104 LayoutObject& rectWithTransform = *document().getElementById("rect")->layout
Object(); | 1104 LayoutObject& rectWithTransform = *document().getElementById("rect")->layout
Object(); |
1105 ObjectPaintProperties* rectWithTransformProperties = rectWithTransform.objec
tPaintProperties(); | 1105 const ObjectPaintProperties* rectWithTransformProperties = rectWithTransform
.objectPaintProperties(); |
1106 EXPECT_EQ(TransformationMatrix().translate(1, 1), rectWithTransformPropertie
s->transform()->matrix()); | 1106 EXPECT_EQ(TransformationMatrix().translate(1, 1), rectWithTransformPropertie
s->transform()->matrix()); |
1107 | 1107 |
1108 // Ensure there is no PaintOffset transform between the rect and the svg's t
ransform. | 1108 // Ensure there is no PaintOffset transform between the rect and the svg's t
ransform. |
1109 EXPECT_EQ(svgWithTransformProperties->transform(), rectWithTransformProperti
es->transform()->parent()); | 1109 EXPECT_EQ(svgWithTransformProperties->transform(), rectWithTransformProperti
es->transform()->parent()); |
1110 } | 1110 } |
1111 | 1111 |
1112 TEST_F(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) | 1112 TEST_F(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) |
1113 { | 1113 { |
1114 setBodyInnerHTML("<div style=\"transform: translateZ(0)\"></div>"); | 1114 setBodyInnerHTML("<div style=\"transform: translateZ(0)\"></div>"); |
1115 | 1115 |
1116 ObjectPaintProperties* properties = document().body()->firstChild()->layoutO
bject()->objectPaintProperties(); | 1116 const ObjectPaintProperties* properties = document().body()->firstChild()->l
ayoutObject()->objectPaintProperties(); |
1117 ASSERT_TRUE(properties->transform()); | 1117 ASSERT_TRUE(properties->transform()); |
1118 EXPECT_FALSE(properties->transform()->hasRenderingContext()); | 1118 EXPECT_FALSE(properties->transform()->hasRenderingContext()); |
1119 } | 1119 } |
1120 | 1120 |
1121 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext) | 1121 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext) |
1122 { | 1122 { |
1123 setBodyInnerHTML( | 1123 setBodyInnerHTML( |
1124 "<div style=\"transform-style: preserve-3d\">" | 1124 "<div style=\"transform-style: preserve-3d\">" |
1125 " <div id=\"a\" style=\"transform: translateZ(0)\"></div>" | 1125 " <div id=\"a\" style=\"transform: translateZ(0)\"></div>" |
1126 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" | 1126 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" |
1127 "</div>"); | 1127 "</div>"); |
1128 | 1128 |
1129 ObjectPaintProperties* aProperties = document().getElementById("a")->layoutO
bject()->objectPaintProperties(); | 1129 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); |
1130 ObjectPaintProperties* bProperties = document().getElementById("b")->layoutO
bject()->objectPaintProperties(); | 1130 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
1131 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1131 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
1132 EXPECT_NE(aProperties->transform(), bProperties->transform()); | 1132 EXPECT_NE(aProperties->transform(), bProperties->transform()); |
1133 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1133 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
1134 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); | 1134 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); |
1135 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); | 1135 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); |
1136 } | 1136 } |
1137 | 1137 |
1138 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) | 1138 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) |
1139 { | 1139 { |
1140 setBodyInnerHTML( | 1140 setBodyInnerHTML( |
1141 "<div style=\"transform-style: preserve-3d\">" | 1141 "<div style=\"transform-style: preserve-3d\">" |
1142 " <div id=\"a\" style=\"transform: translateZ(0)\">" | 1142 " <div id=\"a\" style=\"transform: translateZ(0)\">" |
1143 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" | 1143 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" |
1144 " </div>" | 1144 " </div>" |
1145 "</div>"); | 1145 "</div>"); |
1146 | 1146 |
1147 ASSERT_FALSE(document().getElementById("a")->layoutObject()->styleRef().pres
erves3D()); | 1147 ASSERT_FALSE(document().getElementById("a")->layoutObject()->styleRef().pres
erves3D()); |
1148 ObjectPaintProperties* aProperties = document().getElementById("a")->layoutO
bject()->objectPaintProperties(); | 1148 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); |
1149 ObjectPaintProperties* bProperties = document().getElementById("b")->layoutO
bject()->objectPaintProperties(); | 1149 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
1150 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1150 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
1151 | 1151 |
1152 // #a should participate in a rendering context (due to its parent), but its | 1152 // #a should participate in a rendering context (due to its parent), but its |
1153 // child #b should not. | 1153 // child #b should not. |
1154 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1154 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
1155 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); | 1155 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); |
1156 } | 1156 } |
1157 | 1157 |
1158 TEST_F(PaintPropertyTreeBuilderTest, NestedRenderingContexts) | 1158 TEST_F(PaintPropertyTreeBuilderTest, NestedRenderingContexts) |
1159 { | 1159 { |
1160 setBodyInnerHTML( | 1160 setBodyInnerHTML( |
1161 "<div style=\"transform-style: preserve-3d\">" | 1161 "<div style=\"transform-style: preserve-3d\">" |
1162 " <div id=\"a\" style=\"transform: translateZ(0)\">" | 1162 " <div id=\"a\" style=\"transform: translateZ(0)\">" |
1163 " <div style=\"transform-style: preserve-3d\">" | 1163 " <div style=\"transform-style: preserve-3d\">" |
1164 " <div id=\"b\" style=\"transform: translateZ(0)\">" | 1164 " <div id=\"b\" style=\"transform: translateZ(0)\">" |
1165 " </div>" | 1165 " </div>" |
1166 " </div>" | 1166 " </div>" |
1167 "</div>"); | 1167 "</div>"); |
1168 | 1168 |
1169 ASSERT_FALSE(document().getElementById("a")->layoutObject()->styleRef().pres
erves3D()); | 1169 ASSERT_FALSE(document().getElementById("a")->layoutObject()->styleRef().pres
erves3D()); |
1170 ObjectPaintProperties* aProperties = document().getElementById("a")->layoutO
bject()->objectPaintProperties(); | 1170 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); |
1171 ObjectPaintProperties* bProperties = document().getElementById("b")->layoutO
bject()->objectPaintProperties(); | 1171 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
1172 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1172 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
1173 | 1173 |
1174 // #a should participate in a rendering context (due to its parent). Its | 1174 // #a should participate in a rendering context (due to its parent). Its |
1175 // child does preserve 3D, but since #a does not, #a's rendering context is | 1175 // child does preserve 3D, but since #a does not, #a's rendering context is |
1176 // not passed on to its children. Thus #b ends up in a separate rendering | 1176 // not passed on to its children. Thus #b ends up in a separate rendering |
1177 // context rooted at its parent. | 1177 // context rooted at its parent. |
1178 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1178 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
1179 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); | 1179 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); |
1180 EXPECT_NE(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); | 1180 EXPECT_NE(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); |
1181 } | 1181 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) | 1242 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) |
1243 { | 1243 { |
1244 // It's necessary to make nodes from the one that applies perspective to | 1244 // It's necessary to make nodes from the one that applies perspective to |
1245 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't | 1245 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't |
1246 // do anything. | 1246 // do anything. |
1247 setBodyInnerHTML( | 1247 setBodyInnerHTML( |
1248 "<div id=\"a\" style=\"perspective: 800px\">" | 1248 "<div id=\"a\" style=\"perspective: 800px\">" |
1249 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" | 1249 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" |
1250 "</div>"); | 1250 "</div>"); |
1251 | 1251 |
1252 ObjectPaintProperties* aProperties = document().getElementById("a")->layoutO
bject()->objectPaintProperties(); | 1252 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); |
1253 ObjectPaintProperties* bProperties = document().getElementById("b")->layoutO
bject()->objectPaintProperties(); | 1253 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
1254 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); | 1254 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); |
1255 ASSERT_TRUE(aPerspective); | 1255 ASSERT_TRUE(aPerspective); |
1256 const TransformPaintPropertyNode* bTransform = bProperties->transform(); | 1256 const TransformPaintPropertyNode* bTransform = bProperties->transform(); |
1257 ASSERT_TRUE(bTransform); | 1257 ASSERT_TRUE(bTransform); |
1258 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); | 1258 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); |
1259 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); | 1259 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); |
1260 } | 1260 } |
1261 | 1261 |
1262 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext
) | 1262 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext
) |
1263 { | 1263 { |
1264 // It's necessary to make nodes from the one that applies perspective to | 1264 // It's necessary to make nodes from the one that applies perspective to |
1265 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't | 1265 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't |
1266 // do anything. | 1266 // do anything. |
1267 setBodyInnerHTML( | 1267 setBodyInnerHTML( |
1268 "<div id=\"a\" style=\"perspective: 800px\">" | 1268 "<div id=\"a\" style=\"perspective: 800px\">" |
1269 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" | 1269 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" |
1270 "</div>"); | 1270 "</div>"); |
1271 | 1271 |
1272 ObjectPaintProperties* aProperties = document().getElementById("a")->layoutO
bject()->objectPaintProperties(); | 1272 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); |
1273 ObjectPaintProperties* bProperties = document().getElementById("b")->layoutO
bject()->objectPaintProperties(); | 1273 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
1274 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); | 1274 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); |
1275 ASSERT_TRUE(aPerspective); | 1275 ASSERT_TRUE(aPerspective); |
1276 EXPECT_FALSE(aPerspective->hasRenderingContext()); | 1276 EXPECT_FALSE(aPerspective->hasRenderingContext()); |
1277 const TransformPaintPropertyNode* bTransform = bProperties->transform(); | 1277 const TransformPaintPropertyNode* bTransform = bProperties->transform(); |
1278 ASSERT_TRUE(bTransform); | 1278 ASSERT_TRUE(bTransform); |
1279 EXPECT_FALSE(bTransform->hasRenderingContext()); | 1279 EXPECT_FALSE(bTransform->hasRenderingContext()); |
1280 } | 1280 } |
1281 | 1281 |
1282 TEST_F(PaintPropertyTreeBuilderTest, CachedProperties) | 1282 TEST_F(PaintPropertyTreeBuilderTest, CachedProperties) |
1283 { | 1283 { |
1284 setBodyInnerHTML( | 1284 setBodyInnerHTML( |
1285 "<div id='a' style='transform: translate(33px, 44px)'>" | 1285 "<div id='a' style='transform: translate(33px, 44px)'>" |
1286 " <div id='b' style='transform: translate(55px, 66px)'>" | 1286 " <div id='b' style='transform: translate(55px, 66px)'>" |
1287 " <div id='c' style='transform: translate(77px, 88px)'>C<div>" | 1287 " <div id='c' style='transform: translate(77px, 88px)'>C<div>" |
1288 " </div>" | 1288 " </div>" |
1289 "</div>"); | 1289 "</div>"); |
1290 | 1290 |
1291 Element* a = document().getElementById("a"); | 1291 Element* a = document().getElementById("a"); |
1292 ObjectPaintProperties* aProperties = a->layoutObject()->objectPaintPropertie
s(); | 1292 const ObjectPaintProperties* aProperties = a->layoutObject()->objectPaintPro
perties(); |
1293 TransformPaintPropertyNode* aTransformNode = aProperties->transform(); | 1293 const TransformPaintPropertyNode* aTransformNode = aProperties->transform(); |
1294 EXPECT_EQ(TransformationMatrix().translate(33, 44), aTransformNode->matrix()
); | 1294 EXPECT_EQ(TransformationMatrix().translate(33, 44), aTransformNode->matrix()
); |
1295 | 1295 |
1296 Element* b = document().getElementById("b"); | 1296 Element* b = document().getElementById("b"); |
1297 ObjectPaintProperties* bProperties = b->layoutObject()->objectPaintPropertie
s(); | 1297 const ObjectPaintProperties* bProperties = b->layoutObject()->objectPaintPro
perties(); |
1298 TransformPaintPropertyNode* bTransformNode = bProperties->transform(); | 1298 const TransformPaintPropertyNode* bTransformNode = bProperties->transform(); |
1299 EXPECT_EQ(TransformationMatrix().translate(55, 66), bTransformNode->matrix()
); | 1299 EXPECT_EQ(TransformationMatrix().translate(55, 66), bTransformNode->matrix()
); |
1300 | 1300 |
1301 Element* c = document().getElementById("c"); | 1301 Element* c = document().getElementById("c"); |
1302 ObjectPaintProperties* cProperties = c->layoutObject()->objectPaintPropertie
s(); | 1302 const ObjectPaintProperties* cProperties = c->layoutObject()->objectPaintPro
perties(); |
1303 TransformPaintPropertyNode* cTransformNode = cProperties->transform(); | 1303 const TransformPaintPropertyNode* cTransformNode = cProperties->transform(); |
1304 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix()
); | 1304 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix()
); |
1305 | 1305 |
1306 // Change transform of b. B's transform node should be a new node with the n
ew value, | 1306 // Change transform of b. B's transform node should be a new node with the n
ew value, |
1307 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). | 1307 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). |
1308 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)"); | 1308 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)"); |
1309 document().view()->updateAllLifecyclePhases(); | 1309 document().view()->updateAllLifecyclePhases(); |
1310 | 1310 |
1311 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); | 1311 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); |
1312 EXPECT_EQ(aTransformNode, aProperties->transform()); | 1312 EXPECT_EQ(aTransformNode, aProperties->transform()); |
1313 | 1313 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 bTransformNode = bProperties->transform(); | 1347 bTransformNode = bProperties->transform(); |
1348 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); | 1348 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); |
1349 EXPECT_EQ(aTransformNode, bTransformNode->parent()); | 1349 EXPECT_EQ(aTransformNode, bTransformNode->parent()); |
1350 | 1350 |
1351 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1351 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); |
1352 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1352 EXPECT_EQ(cTransformNode, cProperties->transform()); |
1353 EXPECT_EQ(bTransformNode, cTransformNode->parent()); | 1353 EXPECT_EQ(bTransformNode, cTransformNode->parent()); |
1354 } | 1354 } |
1355 | 1355 |
1356 } // namespace blink | 1356 } // namespace blink |
OLD | NEW |