OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cc/layers/layer_position_constraint.h" | 5 #include "cc/layers/layer_position_constraint.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 root_->bounds()); | 147 root_->bounds()); |
148 inputs.inner_viewport_scroll_layer = | 148 inputs.inner_viewport_scroll_layer = |
149 layer_tree_host_->inner_viewport_scroll_layer(); | 149 layer_tree_host_->inner_viewport_scroll_layer(); |
150 inputs.outer_viewport_scroll_layer = | 150 inputs.outer_viewport_scroll_layer = |
151 layer_tree_host_->outer_viewport_scroll_layer(); | 151 layer_tree_host_->outer_viewport_scroll_layer(); |
152 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 152 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
153 | 153 |
154 // Since scroll deltas aren't sent back to the main thread in this test | 154 // Since scroll deltas aren't sent back to the main thread in this test |
155 // setup, clear them to maintain consistent state. | 155 // setup, clear them to maintain consistent state. |
156 if (root_impl_) { | 156 if (root_impl_) { |
157 scroll_layer_impl_->SetScrollDelta(gfx::Vector2dF()); | 157 SetScrollOffsetDelta(scroll_layer_impl_, gfx::Vector2dF()); |
158 child_impl_->SetScrollDelta(gfx::Vector2dF()); | 158 SetScrollOffsetDelta(child_impl_, gfx::Vector2dF()); |
159 grand_child_impl_->SetScrollDelta(gfx::Vector2dF()); | 159 SetScrollOffsetDelta(grand_child_impl_, gfx::Vector2dF()); |
160 } | 160 } |
161 root_impl_ = layer_tree_host_->CommitAndCreateLayerImplTree(); | 161 root_impl_ = layer_tree_host_->CommitAndCreateLayerImplTree(); |
162 inner_viewport_container_layer_impl_ = root_impl_->children()[0].get(); | 162 inner_viewport_container_layer_impl_ = root_impl_->children()[0].get(); |
163 scroll_layer_impl_ = | 163 scroll_layer_impl_ = |
164 inner_viewport_container_layer_impl_->children()[0].get(); | 164 inner_viewport_container_layer_impl_->children()[0].get(); |
165 outer_viewport_container_layer_impl_ = | 165 outer_viewport_container_layer_impl_ = |
166 scroll_layer_impl_->children()[0].get(); | 166 scroll_layer_impl_->children()[0].get(); |
167 child_transform_layer_impl_ = | 167 child_transform_layer_impl_ = |
168 outer_viewport_container_layer_impl_->children()[0].get(); | 168 outer_viewport_container_layer_impl_->children()[0].get(); |
169 child_impl_ = child_transform_layer_impl_->children()[0].get(); | 169 child_impl_ = child_transform_layer_impl_->children()[0].get(); |
(...skipping 18 matching lines...) Expand all Loading... | |
188 LayerImpl* inner_viewport_container_layer_impl_; | 188 LayerImpl* inner_viewport_container_layer_impl_; |
189 LayerImpl* scroll_layer_impl_; | 189 LayerImpl* scroll_layer_impl_; |
190 LayerImpl* outer_viewport_container_layer_impl_; | 190 LayerImpl* outer_viewport_container_layer_impl_; |
191 LayerImpl* child_transform_layer_impl_; | 191 LayerImpl* child_transform_layer_impl_; |
192 LayerImpl* child_impl_; | 192 LayerImpl* child_impl_; |
193 LayerImpl* grand_child_impl_; | 193 LayerImpl* grand_child_impl_; |
194 LayerImpl* great_grand_child_impl_; | 194 LayerImpl* great_grand_child_impl_; |
195 | 195 |
196 LayerPositionConstraint fixed_to_top_left_; | 196 LayerPositionConstraint fixed_to_top_left_; |
197 LayerPositionConstraint fixed_to_bottom_right_; | 197 LayerPositionConstraint fixed_to_bottom_right_; |
198 | |
199 // Layer_impl should not be aware of synced property logics, this function is | |
ajuma
2016/03/07 19:10:19
LayerImpl
sunxd
2016/03/09 01:51:20
Done.
| |
200 // a hack for the test to arbitrarily set the scroll delta for setting up. | |
201 void SetScrollOffsetDelta(LayerImpl* layer_impl, | |
ajuma
2016/03/07 19:10:19
static void
sunxd
2016/03/09 01:51:20
Done.
| |
202 const gfx::Vector2dF& delta) { | |
203 layer_impl->SetCurrentScrollOffset( | |
204 layer_impl->synced_scroll_offset()->ActiveBase() + | |
205 gfx::ScrollOffset(delta)); | |
206 } | |
198 }; | 207 }; |
199 | 208 |
200 namespace { | 209 namespace { |
201 | 210 |
202 void SetFixedContainerSizeDelta(LayerImpl* scroll_layer, | 211 void SetFixedContainerSizeDelta(LayerImpl* scroll_layer, |
203 const gfx::Vector2d& delta) { | 212 const gfx::Vector2d& delta) { |
204 DCHECK(scroll_layer); | 213 DCHECK(scroll_layer); |
205 DCHECK(scroll_layer->scrollable()); | 214 DCHECK(scroll_layer->scrollable()); |
206 | 215 |
207 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); | 216 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); |
208 container_layer->SetBoundsDelta(delta); | 217 container_layer->SetBoundsDelta(delta); |
209 } | 218 } |
210 } // namespace | 219 } // namespace |
211 | 220 |
212 TEST_F(LayerPositionConstraintTest, | 221 TEST_F(LayerPositionConstraintTest, |
213 ScrollCompensationForFixedPositionLayerWithDirectContainer) { | 222 ScrollCompensationForFixedPositionLayerWithDirectContainer) { |
214 // This test checks for correct scroll compensation when the fixed-position | 223 // This test checks for correct scroll compensation when the fixed-position |
215 // container is the direct parent of the fixed-position layer. | 224 // container is the direct parent of the fixed-position layer. |
216 child_->SetIsContainerForFixedPositionLayers(true); | 225 child_->SetIsContainerForFixedPositionLayers(true); |
217 grand_child_->SetPositionConstraint(fixed_to_top_left_); | 226 grand_child_->SetPositionConstraint(fixed_to_top_left_); |
218 | 227 |
219 CommitAndUpdateImplPointers(); | 228 CommitAndUpdateImplPointers(); |
220 | 229 |
221 // Case 1: scroll delta of 0, 0 | 230 // Case 1: scroll delta of 0, 0 |
222 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 231 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); |
223 ExecuteCalculateDrawProperties(root_impl_); | 232 ExecuteCalculateDrawProperties(root_impl_); |
224 | 233 |
225 gfx::Transform expected_child_transform; | 234 gfx::Transform expected_child_transform; |
226 gfx::Transform expected_grand_child_transform = expected_child_transform; | 235 gfx::Transform expected_grand_child_transform = expected_child_transform; |
227 | 236 |
228 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 237 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
229 child_impl_->DrawTransform()); | 238 child_impl_->DrawTransform()); |
230 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 239 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
231 grand_child_impl_->DrawTransform()); | 240 grand_child_impl_->DrawTransform()); |
232 | 241 |
233 // Case 2: scroll delta of 10, 10 | 242 // Case 2: scroll delta of 10, 10 |
234 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 243 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
235 child_impl_->SetDrawsContent(true); | 244 child_impl_->SetDrawsContent(true); |
236 ExecuteCalculateDrawProperties(root_impl_); | 245 ExecuteCalculateDrawProperties(root_impl_); |
237 | 246 |
238 // Here the child is affected by scroll delta, but the fixed position | 247 // Here the child is affected by scroll delta, but the fixed position |
239 // grand_child should not be affected. | 248 // grand_child should not be affected. |
240 expected_child_transform.MakeIdentity(); | 249 expected_child_transform.MakeIdentity(); |
241 expected_child_transform.Translate(-10.0, -10.0); | 250 expected_child_transform.Translate(-10.0, -10.0); |
242 | 251 |
243 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 252 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
244 child_impl_->DrawTransform()); | 253 child_impl_->DrawTransform()); |
245 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 254 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
246 grand_child_impl_->DrawTransform()); | 255 grand_child_impl_->DrawTransform()); |
247 | 256 |
248 // Case 3: fixed-container size delta of 20, 20 | 257 // Case 3: fixed-container size delta of 20, 20 |
249 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 258 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
250 ExecuteCalculateDrawProperties(root_impl_); | 259 ExecuteCalculateDrawProperties(root_impl_); |
251 | 260 |
252 // Top-left fixed-position layer should not be affected by container size. | 261 // Top-left fixed-position layer should not be affected by container size. |
253 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 262 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
254 child_impl_->DrawTransform()); | 263 child_impl_->DrawTransform()); |
255 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 264 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
256 grand_child_impl_->DrawTransform()); | 265 grand_child_impl_->DrawTransform()); |
257 | 266 |
258 // Case 4: Bottom-right fixed-position layer. | 267 // Case 4: Bottom-right fixed-position layer. |
259 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 268 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
260 CommitAndUpdateImplPointers(); | 269 CommitAndUpdateImplPointers(); |
261 | 270 |
262 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 271 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
263 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 272 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
264 ExecuteCalculateDrawProperties(root_impl_); | 273 ExecuteCalculateDrawProperties(root_impl_); |
265 | 274 |
266 // Bottom-right fixed-position layer moves as container resizes. | 275 // Bottom-right fixed-position layer moves as container resizes. |
267 expected_grand_child_transform.MakeIdentity(); | 276 expected_grand_child_transform.MakeIdentity(); |
268 // Apply size delta from the child(container) layer. | 277 // Apply size delta from the child(container) layer. |
269 expected_grand_child_transform.Translate(20.0, 20.0); | 278 expected_grand_child_transform.Translate(20.0, 20.0); |
270 | 279 |
271 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 280 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
272 child_impl_->DrawTransform()); | 281 child_impl_->DrawTransform()); |
273 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 282 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
274 grand_child_impl_->DrawTransform()); | 283 grand_child_impl_->DrawTransform()); |
275 } | 284 } |
276 | 285 |
277 TEST_F(LayerPositionConstraintTest, | 286 TEST_F(LayerPositionConstraintTest, |
278 ScrollCompensationForFixedPositionLayerWithDistantContainer) { | 287 ScrollCompensationForFixedPositionLayerWithDistantContainer) { |
279 // This test checks for correct scroll compensation when the fixed-position | 288 // This test checks for correct scroll compensation when the fixed-position |
280 // container is NOT the direct parent of the fixed-position layer. | 289 // container is NOT the direct parent of the fixed-position layer. |
281 child_->SetIsContainerForFixedPositionLayers(true); | 290 child_->SetIsContainerForFixedPositionLayers(true); |
282 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); | 291 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); |
283 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); | 292 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); |
284 | 293 |
285 CommitAndUpdateImplPointers(); | 294 CommitAndUpdateImplPointers(); |
286 | 295 |
287 // Case 1: scroll delta of 0, 0 | 296 // Case 1: scroll delta of 0, 0 |
288 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 297 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); |
289 child_impl_->SetDrawsContent(true); | 298 child_impl_->SetDrawsContent(true); |
290 ExecuteCalculateDrawProperties(root_impl_); | 299 ExecuteCalculateDrawProperties(root_impl_); |
291 | 300 |
292 gfx::Transform expected_child_transform; | 301 gfx::Transform expected_child_transform; |
293 gfx::Transform expected_grand_child_transform; | 302 gfx::Transform expected_grand_child_transform; |
294 expected_grand_child_transform.Translate(8.0, 6.0); | 303 expected_grand_child_transform.Translate(8.0, 6.0); |
295 | 304 |
296 gfx::Transform expected_great_grand_child_transform = | 305 gfx::Transform expected_great_grand_child_transform = |
297 expected_grand_child_transform; | 306 expected_grand_child_transform; |
298 | 307 |
299 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 308 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
300 child_impl_->DrawTransform()); | 309 child_impl_->DrawTransform()); |
301 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 310 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
302 grand_child_impl_->DrawTransform()); | 311 grand_child_impl_->DrawTransform()); |
303 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 312 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
304 great_grand_child_impl_->DrawTransform()); | 313 great_grand_child_impl_->DrawTransform()); |
305 | 314 |
306 // Case 2: scroll delta of 10, 10 | 315 // Case 2: scroll delta of 10, 10 |
307 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 316 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
308 ExecuteCalculateDrawProperties(root_impl_); | 317 ExecuteCalculateDrawProperties(root_impl_); |
309 | 318 |
310 // Here the child and grand_child are affected by scroll delta, but the fixed | 319 // Here the child and grand_child are affected by scroll delta, but the fixed |
311 // position great_grand_child should not be affected. | 320 // position great_grand_child should not be affected. |
312 expected_child_transform.MakeIdentity(); | 321 expected_child_transform.MakeIdentity(); |
313 expected_child_transform.Translate(-10.0, -10.0); | 322 expected_child_transform.Translate(-10.0, -10.0); |
314 expected_grand_child_transform.MakeIdentity(); | 323 expected_grand_child_transform.MakeIdentity(); |
315 expected_grand_child_transform.Translate(-2.0, -4.0); | 324 expected_grand_child_transform.Translate(-2.0, -4.0); |
316 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 325 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
317 child_impl_->DrawTransform()); | 326 child_impl_->DrawTransform()); |
(...skipping 10 matching lines...) Expand all Loading... | |
328 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 337 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
329 child_impl_->DrawTransform()); | 338 child_impl_->DrawTransform()); |
330 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 339 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
331 grand_child_impl_->DrawTransform()); | 340 grand_child_impl_->DrawTransform()); |
332 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 341 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
333 great_grand_child_impl_->DrawTransform()); | 342 great_grand_child_impl_->DrawTransform()); |
334 | 343 |
335 // Case 4: Bottom-right fixed-position layer. | 344 // Case 4: Bottom-right fixed-position layer. |
336 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 345 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
337 CommitAndUpdateImplPointers(); | 346 CommitAndUpdateImplPointers(); |
338 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 347 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
339 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 348 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
340 ExecuteCalculateDrawProperties(root_impl_); | 349 ExecuteCalculateDrawProperties(root_impl_); |
341 | 350 |
342 // Bottom-right fixed-position layer moves as container resizes. | 351 // Bottom-right fixed-position layer moves as container resizes. |
343 expected_great_grand_child_transform.MakeIdentity(); | 352 expected_great_grand_child_transform.MakeIdentity(); |
344 // Apply size delta from the child(container) layer. | 353 // Apply size delta from the child(container) layer. |
345 expected_great_grand_child_transform.Translate(20.0, 20.0); | 354 expected_great_grand_child_transform.Translate(20.0, 20.0); |
346 // Apply layer position from the grand child layer. | 355 // Apply layer position from the grand child layer. |
347 expected_great_grand_child_transform.Translate(8.0, 6.0); | 356 expected_great_grand_child_transform.Translate(8.0, 6.0); |
348 | 357 |
(...skipping 14 matching lines...) Expand all Loading... | |
363 rotation_about_z.RotateAboutZAxis(90.0); | 372 rotation_about_z.RotateAboutZAxis(90.0); |
364 | 373 |
365 child_transform_layer_->SetIsContainerForFixedPositionLayers(true); | 374 child_transform_layer_->SetIsContainerForFixedPositionLayers(true); |
366 child_transform_layer_->SetTransform(rotation_about_z); | 375 child_transform_layer_->SetTransform(rotation_about_z); |
367 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); | 376 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); |
368 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); | 377 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); |
369 | 378 |
370 CommitAndUpdateImplPointers(); | 379 CommitAndUpdateImplPointers(); |
371 | 380 |
372 // Case 1: scroll delta of 0, 0 | 381 // Case 1: scroll delta of 0, 0 |
373 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 382 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); |
374 child_impl_->SetDrawsContent(true); | 383 child_impl_->SetDrawsContent(true); |
375 ExecuteCalculateDrawProperties(root_impl_); | 384 ExecuteCalculateDrawProperties(root_impl_); |
376 | 385 |
377 gfx::Transform expected_child_transform; | 386 gfx::Transform expected_child_transform; |
378 expected_child_transform.PreconcatTransform(rotation_about_z); | 387 expected_child_transform.PreconcatTransform(rotation_about_z); |
379 | 388 |
380 gfx::Transform expected_grand_child_transform; | 389 gfx::Transform expected_grand_child_transform; |
381 expected_grand_child_transform.PreconcatTransform( | 390 expected_grand_child_transform.PreconcatTransform( |
382 rotation_about_z); // child's local transform is inherited | 391 rotation_about_z); // child's local transform is inherited |
383 // translation because of position occurs before layer's local transform. | 392 // translation because of position occurs before layer's local transform. |
384 expected_grand_child_transform.Translate(8.0, 6.0); | 393 expected_grand_child_transform.Translate(8.0, 6.0); |
385 | 394 |
386 gfx::Transform expected_great_grand_child_transform = | 395 gfx::Transform expected_great_grand_child_transform = |
387 expected_grand_child_transform; | 396 expected_grand_child_transform; |
388 | 397 |
389 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 398 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
390 child_impl_->DrawTransform()); | 399 child_impl_->DrawTransform()); |
391 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 400 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
392 grand_child_impl_->DrawTransform()); | 401 grand_child_impl_->DrawTransform()); |
393 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 402 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
394 great_grand_child_impl_->DrawTransform()); | 403 great_grand_child_impl_->DrawTransform()); |
395 | 404 |
396 // Case 2: scroll delta of 10, 20 | 405 // Case 2: scroll delta of 10, 20 |
397 child_impl_->SetScrollDelta(gfx::Vector2d(10, 0)); | 406 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 0)); |
398 grand_child_impl_->SetScrollDelta(gfx::Vector2d(5, 0)); | 407 SetScrollOffsetDelta(grand_child_impl_, gfx::Vector2d(5, 0)); |
399 ExecuteCalculateDrawProperties(root_impl_); | 408 ExecuteCalculateDrawProperties(root_impl_); |
400 | 409 |
401 // Here the child and grand_child are affected by scroll delta, but the fixed | 410 // Here the child and grand_child are affected by scroll delta, but the fixed |
402 // position great_grand_child should not be affected. | 411 // position great_grand_child should not be affected. |
403 expected_child_transform.MakeIdentity(); | 412 expected_child_transform.MakeIdentity(); |
404 expected_child_transform.PreconcatTransform(rotation_about_z); | 413 expected_child_transform.PreconcatTransform(rotation_about_z); |
405 expected_child_transform.Translate(-10.0, 0.0); // scroll delta | 414 expected_child_transform.Translate(-10.0, 0.0); // scroll delta |
406 | 415 |
407 expected_grand_child_transform.MakeIdentity(); | 416 expected_grand_child_transform.MakeIdentity(); |
408 expected_grand_child_transform.PreconcatTransform( | 417 expected_grand_child_transform.PreconcatTransform( |
(...skipping 24 matching lines...) Expand all Loading... | |
433 grand_child_->SetForceRenderSurface(true); | 442 grand_child_->SetForceRenderSurface(true); |
434 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); | 443 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); |
435 | 444 |
436 gfx::Transform rotation_about_z; | 445 gfx::Transform rotation_about_z; |
437 rotation_about_z.RotateAboutZAxis(90.0); | 446 rotation_about_z.RotateAboutZAxis(90.0); |
438 great_grand_child_->SetTransform(rotation_about_z); | 447 great_grand_child_->SetTransform(rotation_about_z); |
439 | 448 |
440 CommitAndUpdateImplPointers(); | 449 CommitAndUpdateImplPointers(); |
441 | 450 |
442 // Case 1: scroll delta of 0, 0 | 451 // Case 1: scroll delta of 0, 0 |
443 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 452 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); |
444 ExecuteCalculateDrawProperties(root_impl_); | 453 ExecuteCalculateDrawProperties(root_impl_); |
445 | 454 |
446 gfx::Transform expected_child_transform; | 455 gfx::Transform expected_child_transform; |
447 gfx::Transform expected_surface_draw_transform; | 456 gfx::Transform expected_surface_draw_transform; |
448 expected_surface_draw_transform.Translate(8.0, 6.0); | 457 expected_surface_draw_transform.Translate(8.0, 6.0); |
449 gfx::Transform expected_grand_child_transform; | 458 gfx::Transform expected_grand_child_transform; |
450 gfx::Transform expected_great_grand_child_transform; | 459 gfx::Transform expected_great_grand_child_transform; |
451 expected_great_grand_child_transform.PreconcatTransform(rotation_about_z); | 460 expected_great_grand_child_transform.PreconcatTransform(rotation_about_z); |
452 EXPECT_TRUE(grand_child_impl_->render_surface()); | 461 EXPECT_TRUE(grand_child_impl_->render_surface()); |
453 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 462 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
454 child_impl_->DrawTransform()); | 463 child_impl_->DrawTransform()); |
455 EXPECT_TRANSFORMATION_MATRIX_EQ( | 464 EXPECT_TRANSFORMATION_MATRIX_EQ( |
456 expected_surface_draw_transform, | 465 expected_surface_draw_transform, |
457 grand_child_impl_->render_surface()->draw_transform()); | 466 grand_child_impl_->render_surface()->draw_transform()); |
458 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 467 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
459 grand_child_impl_->DrawTransform()); | 468 grand_child_impl_->DrawTransform()); |
460 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 469 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
461 great_grand_child_impl_->DrawTransform()); | 470 great_grand_child_impl_->DrawTransform()); |
462 | 471 |
463 // Case 2: scroll delta of 10, 30 | 472 // Case 2: scroll delta of 10, 30 |
464 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 473 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30)); |
465 child_impl_->SetDrawsContent(true); | 474 child_impl_->SetDrawsContent(true); |
466 ExecuteCalculateDrawProperties(root_impl_); | 475 ExecuteCalculateDrawProperties(root_impl_); |
467 | 476 |
468 // Here the grand_child remains unchanged, because it scrolls along with the | 477 // Here the grand_child remains unchanged, because it scrolls along with the |
469 // render surface, and the translation is actually in the render surface. But, | 478 // render surface, and the translation is actually in the render surface. But, |
470 // the fixed position great_grand_child is more awkward: its actually being | 479 // the fixed position great_grand_child is more awkward: its actually being |
471 // drawn with respect to the render surface, but it needs to remain fixed with | 480 // drawn with respect to the render surface, but it needs to remain fixed with |
472 // resepct to a container beyond that surface. So, the net result is that, | 481 // resepct to a container beyond that surface. So, the net result is that, |
473 // unlike previous tests where the fixed position layer's transform remains | 482 // unlike previous tests where the fixed position layer's transform remains |
474 // unchanged, here the fixed position layer's transform explicitly contains | 483 // unchanged, here the fixed position layer's transform explicitly contains |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 child_impl_->DrawTransform()); | 515 child_impl_->DrawTransform()); |
507 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 516 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
508 grand_child_impl_->DrawTransform()); | 517 grand_child_impl_->DrawTransform()); |
509 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 518 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
510 great_grand_child_impl_->DrawTransform()); | 519 great_grand_child_impl_->DrawTransform()); |
511 | 520 |
512 // Case 4: Bottom-right fixed-position layer. | 521 // Case 4: Bottom-right fixed-position layer. |
513 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 522 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
514 | 523 |
515 CommitAndUpdateImplPointers(); | 524 CommitAndUpdateImplPointers(); |
516 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 525 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30)); |
517 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 526 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
518 | 527 |
519 ExecuteCalculateDrawProperties(root_impl_); | 528 ExecuteCalculateDrawProperties(root_impl_); |
520 | 529 |
521 // Bottom-right fixed-position layer moves as container resizes. | 530 // Bottom-right fixed-position layer moves as container resizes. |
522 expected_great_grand_child_transform.MakeIdentity(); | 531 expected_great_grand_child_transform.MakeIdentity(); |
523 // explicit canceling out the scroll delta that gets embedded in the fixed | 532 // explicit canceling out the scroll delta that gets embedded in the fixed |
524 // position layer's surface. | 533 // position layer's surface. |
525 expected_great_grand_child_transform.Translate(10.0, 30.0); | 534 expected_great_grand_child_transform.Translate(10.0, 30.0); |
526 // Also apply size delta in the child(container) layer space. | 535 // Also apply size delta in the child(container) layer space. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 rotation_about_z.Translate(50.0, 50.0); | 576 rotation_about_z.Translate(50.0, 50.0); |
568 rotation_about_z.RotateAboutZAxis(90.0); | 577 rotation_about_z.RotateAboutZAxis(90.0); |
569 rotation_about_z.Translate(-50.0, -50.0); | 578 rotation_about_z.Translate(-50.0, -50.0); |
570 fixed_position_child->SetTransform(rotation_about_z); | 579 fixed_position_child->SetTransform(rotation_about_z); |
571 | 580 |
572 CommitAndUpdateImplPointers(); | 581 CommitAndUpdateImplPointers(); |
573 LayerImpl* fixed_position_child_impl = | 582 LayerImpl* fixed_position_child_impl = |
574 great_grand_child_impl_->children()[0].get(); | 583 great_grand_child_impl_->children()[0].get(); |
575 | 584 |
576 // Case 1: scroll delta of 0, 0 | 585 // Case 1: scroll delta of 0, 0 |
577 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 586 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); |
578 child_impl_->SetDrawsContent(true); | 587 child_impl_->SetDrawsContent(true); |
579 ExecuteCalculateDrawProperties(root_impl_); | 588 ExecuteCalculateDrawProperties(root_impl_); |
580 | 589 |
581 gfx::Transform expected_child_transform; | 590 gfx::Transform expected_child_transform; |
582 | 591 |
583 gfx::Transform expected_grand_child_surface_draw_transform; | 592 gfx::Transform expected_grand_child_surface_draw_transform; |
584 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); | 593 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); |
585 | 594 |
586 gfx::Transform expected_grand_child_transform; | 595 gfx::Transform expected_grand_child_transform; |
587 | 596 |
(...skipping 16 matching lines...) Expand all Loading... | |
604 grand_child_impl_->DrawTransform()); | 613 grand_child_impl_->DrawTransform()); |
605 EXPECT_TRANSFORMATION_MATRIX_EQ( | 614 EXPECT_TRANSFORMATION_MATRIX_EQ( |
606 expected_great_grand_child_surface_draw_transform, | 615 expected_great_grand_child_surface_draw_transform, |
607 great_grand_child_impl_->render_surface()->draw_transform()); | 616 great_grand_child_impl_->render_surface()->draw_transform()); |
608 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 617 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
609 great_grand_child_impl_->DrawTransform()); | 618 great_grand_child_impl_->DrawTransform()); |
610 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 619 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
611 fixed_position_child_impl->DrawTransform()); | 620 fixed_position_child_impl->DrawTransform()); |
612 | 621 |
613 // Case 2: scroll delta of 10, 30 | 622 // Case 2: scroll delta of 10, 30 |
614 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 623 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30)); |
615 ExecuteCalculateDrawProperties(root_impl_); | 624 ExecuteCalculateDrawProperties(root_impl_); |
616 | 625 |
617 expected_child_transform.MakeIdentity(); | 626 expected_child_transform.MakeIdentity(); |
618 expected_child_transform.Translate(-10.0, -30.0); // scroll delta | 627 expected_child_transform.Translate(-10.0, -30.0); // scroll delta |
619 | 628 |
620 expected_grand_child_surface_draw_transform.MakeIdentity(); | 629 expected_grand_child_surface_draw_transform.MakeIdentity(); |
621 expected_grand_child_surface_draw_transform.Translate(-10.0, | 630 expected_grand_child_surface_draw_transform.Translate(-10.0, |
622 -30.0); // scroll delta | 631 -30.0); // scroll delta |
623 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); | 632 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); |
624 | 633 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 grand_child_impl_->DrawTransform()); | 670 grand_child_impl_->DrawTransform()); |
662 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 671 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
663 great_grand_child_impl_->DrawTransform()); | 672 great_grand_child_impl_->DrawTransform()); |
664 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 673 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
665 fixed_position_child_impl->DrawTransform()); | 674 fixed_position_child_impl->DrawTransform()); |
666 | 675 |
667 // Case 4: Bottom-right fixed-position layer. | 676 // Case 4: Bottom-right fixed-position layer. |
668 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_); | 677 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_); |
669 CommitAndUpdateImplPointers(); | 678 CommitAndUpdateImplPointers(); |
670 fixed_position_child_impl = great_grand_child_impl_->children()[0].get(); | 679 fixed_position_child_impl = great_grand_child_impl_->children()[0].get(); |
671 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 680 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30)); |
672 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 681 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
673 ExecuteCalculateDrawProperties(root_impl_); | 682 ExecuteCalculateDrawProperties(root_impl_); |
674 | 683 |
675 // Bottom-right fixed-position layer moves as container resizes. | 684 // Bottom-right fixed-position layer moves as container resizes. |
676 expected_fixed_position_child_transform.MakeIdentity(); | 685 expected_fixed_position_child_transform.MakeIdentity(); |
677 // explicit canceling out the scroll delta that gets embedded in the fixed | 686 // explicit canceling out the scroll delta that gets embedded in the fixed |
678 // position layer's surface. | 687 // position layer's surface. |
679 expected_fixed_position_child_transform.Translate(10.0, 30.0); | 688 expected_fixed_position_child_transform.Translate(10.0, 30.0); |
680 // Also apply size delta in the child(container) layer space. | 689 // Also apply size delta in the child(container) layer space. |
681 expected_fixed_position_child_transform.Translate(20.0, 20.0); | 690 expected_fixed_position_child_transform.Translate(20.0, 20.0); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
725 rotation_about_z.RotateAboutZAxis(30.0); | 734 rotation_about_z.RotateAboutZAxis(30.0); |
726 rotation_about_z.Translate(-50.0, -50.0); | 735 rotation_about_z.Translate(-50.0, -50.0); |
727 child_transform_layer_->SetTransform(rotation_about_z); | 736 child_transform_layer_->SetTransform(rotation_about_z); |
728 fixed_position_child->SetTransform(rotation_about_z); | 737 fixed_position_child->SetTransform(rotation_about_z); |
729 | 738 |
730 CommitAndUpdateImplPointers(); | 739 CommitAndUpdateImplPointers(); |
731 LayerImpl* fixed_position_child_impl = | 740 LayerImpl* fixed_position_child_impl = |
732 great_grand_child_impl_->children()[0].get(); | 741 great_grand_child_impl_->children()[0].get(); |
733 | 742 |
734 // Case 1: scroll delta of 0, 0 | 743 // Case 1: scroll delta of 0, 0 |
735 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 744 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); |
736 child_impl_->SetDrawsContent(true); | 745 child_impl_->SetDrawsContent(true); |
737 ExecuteCalculateDrawProperties(root_impl_); | 746 ExecuteCalculateDrawProperties(root_impl_); |
738 | 747 |
739 gfx::Transform expected_child_transform; | 748 gfx::Transform expected_child_transform; |
740 expected_child_transform.PreconcatTransform(rotation_about_z); | 749 expected_child_transform.PreconcatTransform(rotation_about_z); |
741 | 750 |
742 gfx::Transform expected_grand_child_surface_draw_transform; | 751 gfx::Transform expected_grand_child_surface_draw_transform; |
743 expected_grand_child_surface_draw_transform.PreconcatTransform( | 752 expected_grand_child_surface_draw_transform.PreconcatTransform( |
744 rotation_about_z); | 753 rotation_about_z); |
745 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); | 754 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); |
(...skipping 19 matching lines...) Expand all Loading... | |
765 grand_child_impl_->DrawTransform()); | 774 grand_child_impl_->DrawTransform()); |
766 EXPECT_TRANSFORMATION_MATRIX_EQ( | 775 EXPECT_TRANSFORMATION_MATRIX_EQ( |
767 expected_great_grand_child_surface_draw_transform, | 776 expected_great_grand_child_surface_draw_transform, |
768 great_grand_child_impl_->render_surface()->draw_transform()); | 777 great_grand_child_impl_->render_surface()->draw_transform()); |
769 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 778 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
770 great_grand_child_impl_->DrawTransform()); | 779 great_grand_child_impl_->DrawTransform()); |
771 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 780 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
772 fixed_position_child_impl->DrawTransform()); | 781 fixed_position_child_impl->DrawTransform()); |
773 | 782 |
774 // Case 2: scroll delta of 10, 30 | 783 // Case 2: scroll delta of 10, 30 |
775 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 784 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30)); |
776 ExecuteCalculateDrawProperties(root_impl_); | 785 ExecuteCalculateDrawProperties(root_impl_); |
777 | 786 |
778 expected_child_transform.MakeIdentity(); | 787 expected_child_transform.MakeIdentity(); |
779 expected_child_transform.PreconcatTransform(rotation_about_z); | 788 expected_child_transform.PreconcatTransform(rotation_about_z); |
780 expected_child_transform.Translate(-10.0, -30.0); // scroll delta | 789 expected_child_transform.Translate(-10.0, -30.0); // scroll delta |
781 | 790 |
782 expected_grand_child_surface_draw_transform.MakeIdentity(); | 791 expected_grand_child_surface_draw_transform.MakeIdentity(); |
783 expected_grand_child_surface_draw_transform.PreconcatTransform( | 792 expected_grand_child_surface_draw_transform.PreconcatTransform( |
784 rotation_about_z); | 793 rotation_about_z); |
785 expected_grand_child_surface_draw_transform.Translate(-10.0, | 794 expected_grand_child_surface_draw_transform.Translate(-10.0, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
824 // should be treated like a layer that contributes to a render target, and | 833 // should be treated like a layer that contributes to a render target, and |
825 // that render target is completely irrelevant; it should not affect the | 834 // that render target is completely irrelevant; it should not affect the |
826 // scroll compensation. | 835 // scroll compensation. |
827 child_->SetIsContainerForFixedPositionLayers(true); | 836 child_->SetIsContainerForFixedPositionLayers(true); |
828 child_->SetForceRenderSurface(true); | 837 child_->SetForceRenderSurface(true); |
829 grand_child_->SetPositionConstraint(fixed_to_top_left_); | 838 grand_child_->SetPositionConstraint(fixed_to_top_left_); |
830 | 839 |
831 CommitAndUpdateImplPointers(); | 840 CommitAndUpdateImplPointers(); |
832 | 841 |
833 // Case 1: scroll delta of 0, 0 | 842 // Case 1: scroll delta of 0, 0 |
834 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 843 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); |
835 ExecuteCalculateDrawProperties(root_impl_); | 844 ExecuteCalculateDrawProperties(root_impl_); |
836 | 845 |
837 gfx::Transform expected_surface_draw_transform; | 846 gfx::Transform expected_surface_draw_transform; |
838 gfx::Transform expected_child_transform; | 847 gfx::Transform expected_child_transform; |
839 gfx::Transform expected_grand_child_transform; | 848 gfx::Transform expected_grand_child_transform; |
840 EXPECT_TRUE(child_impl_->render_surface()); | 849 EXPECT_TRUE(child_impl_->render_surface()); |
841 EXPECT_TRANSFORMATION_MATRIX_EQ( | 850 EXPECT_TRANSFORMATION_MATRIX_EQ( |
842 expected_surface_draw_transform, | 851 expected_surface_draw_transform, |
843 child_impl_->render_surface()->draw_transform()); | 852 child_impl_->render_surface()->draw_transform()); |
844 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 853 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
845 child_impl_->DrawTransform()); | 854 child_impl_->DrawTransform()); |
846 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 855 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
847 grand_child_impl_->DrawTransform()); | 856 grand_child_impl_->DrawTransform()); |
848 | 857 |
849 // Case 2: scroll delta of 10, 10 | 858 // Case 2: scroll delta of 10, 10 |
850 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 859 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
851 ExecuteCalculateDrawProperties(root_impl_); | 860 ExecuteCalculateDrawProperties(root_impl_); |
852 | 861 |
853 // The surface is translated by scroll delta, the child transform doesn't | 862 // The surface is translated by scroll delta, the child transform doesn't |
854 // change because it scrolls along with the surface, but the fixed position | 863 // change because it scrolls along with the surface, but the fixed position |
855 // grand_child needs to compensate for the scroll translation. | 864 // grand_child needs to compensate for the scroll translation. |
856 expected_surface_draw_transform.MakeIdentity(); | 865 expected_surface_draw_transform.MakeIdentity(); |
857 expected_surface_draw_transform.Translate(-10.0, -10.0); | 866 expected_surface_draw_transform.Translate(-10.0, -10.0); |
858 expected_grand_child_transform.MakeIdentity(); | 867 expected_grand_child_transform.MakeIdentity(); |
859 expected_grand_child_transform.Translate(10.0, 10.0); | 868 expected_grand_child_transform.Translate(10.0, 10.0); |
860 | 869 |
(...skipping 12 matching lines...) Expand all Loading... | |
873 | 882 |
874 // Top-left fixed-position layer should not be affected by container size. | 883 // Top-left fixed-position layer should not be affected by container size. |
875 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 884 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
876 child_impl_->DrawTransform()); | 885 child_impl_->DrawTransform()); |
877 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 886 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
878 grand_child_impl_->DrawTransform()); | 887 grand_child_impl_->DrawTransform()); |
879 | 888 |
880 // Case 4: Bottom-right fixed-position layer. | 889 // Case 4: Bottom-right fixed-position layer. |
881 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 890 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
882 CommitAndUpdateImplPointers(); | 891 CommitAndUpdateImplPointers(); |
883 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 892 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
884 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 893 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
885 ExecuteCalculateDrawProperties(root_impl_); | 894 ExecuteCalculateDrawProperties(root_impl_); |
886 | 895 |
887 // Bottom-right fixed-position layer moves as container resizes. | 896 // Bottom-right fixed-position layer moves as container resizes. |
888 expected_grand_child_transform.MakeIdentity(); | 897 expected_grand_child_transform.MakeIdentity(); |
889 // The surface is translated by scroll delta, the child transform doesn't | 898 // The surface is translated by scroll delta, the child transform doesn't |
890 // change because it scrolls along with the surface, but the fixed position | 899 // change because it scrolls along with the surface, but the fixed position |
891 // grand_child needs to compensate for the scroll translation. | 900 // grand_child needs to compensate for the scroll translation. |
892 expected_grand_child_transform.Translate(10.0, 10.0); | 901 expected_grand_child_transform.Translate(10.0, 10.0); |
893 // Apply size delta from the child(container) layer. | 902 // Apply size delta from the child(container) layer. |
(...skipping 13 matching lines...) Expand all Loading... | |
907 child_->SetIsContainerForFixedPositionLayers(true); | 916 child_->SetIsContainerForFixedPositionLayers(true); |
908 grand_child_->SetPositionConstraint(fixed_to_top_left_); | 917 grand_child_->SetPositionConstraint(fixed_to_top_left_); |
909 | 918 |
910 // This should not confuse the grand_child. If correct, the grand_child would | 919 // This should not confuse the grand_child. If correct, the grand_child would |
911 // still be considered fixed to its container (i.e. "child"). | 920 // still be considered fixed to its container (i.e. "child"). |
912 grand_child_->SetIsContainerForFixedPositionLayers(true); | 921 grand_child_->SetIsContainerForFixedPositionLayers(true); |
913 | 922 |
914 CommitAndUpdateImplPointers(); | 923 CommitAndUpdateImplPointers(); |
915 | 924 |
916 // Case 1: scroll delta of 0, 0 | 925 // Case 1: scroll delta of 0, 0 |
917 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 926 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); |
918 child_impl_->SetDrawsContent(true); | 927 child_impl_->SetDrawsContent(true); |
919 ExecuteCalculateDrawProperties(root_impl_); | 928 ExecuteCalculateDrawProperties(root_impl_); |
920 | 929 |
921 gfx::Transform expected_child_transform; | 930 gfx::Transform expected_child_transform; |
922 gfx::Transform expected_grand_child_transform; | 931 gfx::Transform expected_grand_child_transform; |
923 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 932 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
924 child_impl_->DrawTransform()); | 933 child_impl_->DrawTransform()); |
925 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 934 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
926 grand_child_impl_->DrawTransform()); | 935 grand_child_impl_->DrawTransform()); |
927 | 936 |
928 // Case 2: scroll delta of 10, 10 | 937 // Case 2: scroll delta of 10, 10 |
929 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 938 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
930 ExecuteCalculateDrawProperties(root_impl_); | 939 ExecuteCalculateDrawProperties(root_impl_); |
931 | 940 |
932 // Here the child is affected by scroll delta, but the fixed position | 941 // Here the child is affected by scroll delta, but the fixed position |
933 // grand_child should not be affected. | 942 // grand_child should not be affected. |
934 expected_child_transform.MakeIdentity(); | 943 expected_child_transform.MakeIdentity(); |
935 expected_child_transform.Translate(-10.0, -10.0); | 944 expected_child_transform.Translate(-10.0, -10.0); |
936 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 945 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
937 child_impl_->DrawTransform()); | 946 child_impl_->DrawTransform()); |
938 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 947 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
939 grand_child_impl_->DrawTransform()); | 948 grand_child_impl_->DrawTransform()); |
940 | 949 |
941 // Case 3: fixed-container size delta of 20, 20 | 950 // Case 3: fixed-container size delta of 20, 20 |
942 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 951 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
943 ExecuteCalculateDrawProperties(root_impl_); | 952 ExecuteCalculateDrawProperties(root_impl_); |
944 | 953 |
945 // Top-left fixed-position layer should not be affected by container size. | 954 // Top-left fixed-position layer should not be affected by container size. |
946 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 955 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
947 child_impl_->DrawTransform()); | 956 child_impl_->DrawTransform()); |
948 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 957 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
949 grand_child_impl_->DrawTransform()); | 958 grand_child_impl_->DrawTransform()); |
950 | 959 |
951 // Case 4: Bottom-right fixed-position layer. | 960 // Case 4: Bottom-right fixed-position layer. |
952 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 961 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
953 CommitAndUpdateImplPointers(); | 962 CommitAndUpdateImplPointers(); |
954 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 963 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
955 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 964 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
956 | 965 |
957 ExecuteCalculateDrawProperties(root_impl_); | 966 ExecuteCalculateDrawProperties(root_impl_); |
958 | 967 |
959 // Bottom-right fixed-position layer moves as container resizes. | 968 // Bottom-right fixed-position layer moves as container resizes. |
960 expected_grand_child_transform.MakeIdentity(); | 969 expected_grand_child_transform.MakeIdentity(); |
961 // Apply size delta from the child(container) layer. | 970 // Apply size delta from the child(container) layer. |
962 expected_grand_child_transform.Translate(20.0, 20.0); | 971 expected_grand_child_transform.Translate(20.0, 20.0); |
963 | 972 |
964 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 973 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
(...skipping 13 matching lines...) Expand all Loading... | |
978 grand_child_->SetPositionConstraint(fixed_to_top_left_); | 987 grand_child_->SetPositionConstraint(fixed_to_top_left_); |
979 | 988 |
980 // Note carefully - great_grand_child is fixed to bottom right, to test | 989 // Note carefully - great_grand_child is fixed to bottom right, to test |
981 // sizeDelta being applied correctly; the compensation skips the grand_child | 990 // sizeDelta being applied correctly; the compensation skips the grand_child |
982 // because it is fixed to top left. | 991 // because it is fixed to top left. |
983 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 992 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
984 | 993 |
985 CommitAndUpdateImplPointers(); | 994 CommitAndUpdateImplPointers(); |
986 | 995 |
987 // Case 1: scrollDelta | 996 // Case 1: scrollDelta |
988 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 997 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
989 child_impl_->SetDrawsContent(true); | 998 child_impl_->SetDrawsContent(true); |
990 ExecuteCalculateDrawProperties(root_impl_); | 999 ExecuteCalculateDrawProperties(root_impl_); |
991 | 1000 |
992 // Here the child is affected by scroll delta, but the fixed position | 1001 // Here the child is affected by scroll delta, but the fixed position |
993 // grand_child should not be affected. | 1002 // grand_child should not be affected. |
994 gfx::Transform expected_child_transform; | 1003 gfx::Transform expected_child_transform; |
995 expected_child_transform.Translate(-10.0, -10.0); | 1004 expected_child_transform.Translate(-10.0, -10.0); |
996 | 1005 |
997 gfx::Transform expected_grand_child_transform; | 1006 gfx::Transform expected_grand_child_transform; |
998 gfx::Transform expected_great_grand_child_transform; | 1007 gfx::Transform expected_great_grand_child_transform; |
999 | 1008 |
1000 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 1009 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
1001 child_impl_->DrawTransform()); | 1010 child_impl_->DrawTransform()); |
1002 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 1011 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
1003 grand_child_impl_->DrawTransform()); | 1012 grand_child_impl_->DrawTransform()); |
1004 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 1013 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
1005 great_grand_child_impl_->DrawTransform()); | 1014 great_grand_child_impl_->DrawTransform()); |
1006 | 1015 |
1007 // Case 2: sizeDelta | 1016 // Case 2: sizeDelta |
1008 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 1017 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); |
1009 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 1018 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
1010 ExecuteCalculateDrawProperties(root_impl_); | 1019 ExecuteCalculateDrawProperties(root_impl_); |
1011 | 1020 |
1012 expected_child_transform.MakeIdentity(); | 1021 expected_child_transform.MakeIdentity(); |
1013 | 1022 |
1014 expected_grand_child_transform.MakeIdentity(); | 1023 expected_grand_child_transform.MakeIdentity(); |
1015 | 1024 |
1016 // Fixed to bottom-right, size-delta compensation is applied. | 1025 // Fixed to bottom-right, size-delta compensation is applied. |
1017 expected_great_grand_child_transform.MakeIdentity(); | 1026 expected_great_grand_child_transform.MakeIdentity(); |
1018 expected_great_grand_child_transform.Translate(20.0, 20.0); | 1027 expected_great_grand_child_transform.Translate(20.0, 20.0); |
(...skipping 24 matching lines...) Expand all Loading... | |
1043 great_grand_child_->SetScrollClipLayerId(root_->id()); | 1052 great_grand_child_->SetScrollClipLayerId(root_->id()); |
1044 great_great_grand_child->SetPositionConstraint(fixed_to_top_left_); | 1053 great_great_grand_child->SetPositionConstraint(fixed_to_top_left_); |
1045 | 1054 |
1046 CommitAndUpdateImplPointers(); | 1055 CommitAndUpdateImplPointers(); |
1047 | 1056 |
1048 LayerImpl* container1 = child_impl_; | 1057 LayerImpl* container1 = child_impl_; |
1049 LayerImpl* fixed_to_container1 = grand_child_impl_; | 1058 LayerImpl* fixed_to_container1 = grand_child_impl_; |
1050 LayerImpl* container2 = great_grand_child_impl_; | 1059 LayerImpl* container2 = great_grand_child_impl_; |
1051 LayerImpl* fixed_to_container2 = container2->children()[0].get(); | 1060 LayerImpl* fixed_to_container2 = container2->children()[0].get(); |
1052 | 1061 |
1053 container1->SetScrollDelta(gfx::Vector2d(0, 15)); | 1062 SetScrollOffsetDelta(container1, gfx::Vector2d(0, 15)); |
1054 container1->SetDrawsContent(true); | 1063 container1->SetDrawsContent(true); |
1055 container2->SetScrollDelta(gfx::Vector2d(30, 0)); | 1064 SetScrollOffsetDelta(container2, gfx::Vector2d(30, 0)); |
1056 container2->SetDrawsContent(true); | 1065 container2->SetDrawsContent(true); |
1057 ExecuteCalculateDrawProperties(root_impl_); | 1066 ExecuteCalculateDrawProperties(root_impl_); |
1058 | 1067 |
1059 gfx::Transform expected_container1_transform; | 1068 gfx::Transform expected_container1_transform; |
1060 expected_container1_transform.Translate(0.0, -15.0); | 1069 expected_container1_transform.Translate(0.0, -15.0); |
1061 | 1070 |
1062 gfx::Transform expected_fixed_to_container1_transform; | 1071 gfx::Transform expected_fixed_to_container1_transform; |
1063 | 1072 |
1064 // Since the container is a descendant of the fixed layer above, | 1073 // Since the container is a descendant of the fixed layer above, |
1065 // the expected draw transform for container2 would not | 1074 // the expected draw transform for container2 would not |
(...skipping 25 matching lines...) Expand all Loading... | |
1091 fixed_child->SetBounds(gfx::Size(300, 300)); | 1100 fixed_child->SetBounds(gfx::Size(300, 300)); |
1092 scroll_layer_->AddChild(fixed_child); | 1101 scroll_layer_->AddChild(fixed_child); |
1093 fixed_child->SetPositionConstraint(fixed_to_top_left_); | 1102 fixed_child->SetPositionConstraint(fixed_to_top_left_); |
1094 | 1103 |
1095 CommitAndUpdateImplPointers(); | 1104 CommitAndUpdateImplPointers(); |
1096 | 1105 |
1097 LayerImpl* fixed_child_impl = | 1106 LayerImpl* fixed_child_impl = |
1098 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); | 1107 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); |
1099 | 1108 |
1100 // Case 1: fixed-container size delta of 20, 20 | 1109 // Case 1: fixed-container size delta of 20, 20 |
1101 scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 1110 SetScrollOffsetDelta(scroll_layer_impl_, gfx::Vector2d(10, 10)); |
1102 scroll_layer_impl_->SetDrawsContent(true); | 1111 scroll_layer_impl_->SetDrawsContent(true); |
1103 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); | 1112 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); |
1104 gfx::Transform expected_scroll_layer_transform; | 1113 gfx::Transform expected_scroll_layer_transform; |
1105 expected_scroll_layer_transform.Translate(-10.0, -10.0); | 1114 expected_scroll_layer_transform.Translate(-10.0, -10.0); |
1106 gfx::Transform expected_fixed_child_transform; | 1115 gfx::Transform expected_fixed_child_transform; |
1107 | 1116 |
1108 ExecuteCalculateDrawProperties(root_impl_); | 1117 ExecuteCalculateDrawProperties(root_impl_); |
1109 | 1118 |
1110 // Top-left fixed-position layer should not be affected by container size. | 1119 // Top-left fixed-position layer should not be affected by container size. |
1111 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, | 1120 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, |
1112 scroll_layer_impl_->DrawTransform()); | 1121 scroll_layer_impl_->DrawTransform()); |
1113 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, | 1122 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, |
1114 fixed_child_impl->DrawTransform()); | 1123 fixed_child_impl->DrawTransform()); |
1115 | 1124 |
1116 // Case 2: Bottom-right fixed-position layer. | 1125 // Case 2: Bottom-right fixed-position layer. |
1117 fixed_child->SetPositionConstraint(fixed_to_bottom_right_); | 1126 fixed_child->SetPositionConstraint(fixed_to_bottom_right_); |
1118 CommitAndUpdateImplPointers(); | 1127 CommitAndUpdateImplPointers(); |
1119 fixed_child_impl = | 1128 fixed_child_impl = |
1120 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); | 1129 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); |
1121 | 1130 |
1122 scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 1131 SetScrollOffsetDelta(scroll_layer_impl_, gfx::Vector2d(10, 10)); |
1123 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); | 1132 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); |
1124 ExecuteCalculateDrawProperties(root_impl_); | 1133 ExecuteCalculateDrawProperties(root_impl_); |
1125 | 1134 |
1126 // Bottom-right fixed-position layer moves as container resizes. | 1135 // Bottom-right fixed-position layer moves as container resizes. |
1127 expected_fixed_child_transform.MakeIdentity(); | 1136 expected_fixed_child_transform.MakeIdentity(); |
1128 // Apply size delta. | 1137 // Apply size delta. |
1129 expected_fixed_child_transform.Translate(20.0, 20.0); | 1138 expected_fixed_child_transform.Translate(20.0, 20.0); |
1130 | 1139 |
1131 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, | 1140 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, |
1132 scroll_layer_impl_->DrawTransform()); | 1141 scroll_layer_impl_->DrawTransform()); |
(...skipping 22 matching lines...) Expand all Loading... | |
1155 VerifySerializeAndDeserializeProto(true, false, true); | 1164 VerifySerializeAndDeserializeProto(true, false, true); |
1156 VerifySerializeAndDeserializeProto(true, false, false); | 1165 VerifySerializeAndDeserializeProto(true, false, false); |
1157 VerifySerializeAndDeserializeProto(false, true, true); | 1166 VerifySerializeAndDeserializeProto(false, true, true); |
1158 VerifySerializeAndDeserializeProto(false, true, false); | 1167 VerifySerializeAndDeserializeProto(false, true, false); |
1159 VerifySerializeAndDeserializeProto(false, false, true); | 1168 VerifySerializeAndDeserializeProto(false, false, true); |
1160 VerifySerializeAndDeserializeProto(false, false, false); | 1169 VerifySerializeAndDeserializeProto(false, false, false); |
1161 } | 1170 } |
1162 | 1171 |
1163 } // namespace | 1172 } // namespace |
1164 } // namespace cc | 1173 } // namespace cc |
OLD | NEW |