OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer_tree_host_impl.h" | 7 #include "cc/layer_tree_host_impl.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 scrollInfo = m_hostImpl->processScrollDeltas(); | 329 scrollInfo = m_hostImpl->processScrollDeltas(); |
330 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); | 330 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); |
331 } | 331 } |
332 | 332 |
333 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) | 333 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) |
334 { | 334 { |
335 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 335 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
336 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 336 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
337 initializeRendererAndDrawFrame(); | 337 initializeRendererAndDrawFrame(); |
338 | 338 |
339 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 339 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
340 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 340 m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10)); |
341 m_hostImpl->scrollEnd(); | 341 m_hostImpl->scrollEnd(); |
342 EXPECT_TRUE(m_didRequestRedraw); | 342 EXPECT_TRUE(m_didRequestRedraw); |
343 EXPECT_TRUE(m_didRequestCommit); | 343 EXPECT_TRUE(m_didRequestCommit); |
344 } | 344 } |
345 | 345 |
346 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer) | 346 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer) |
347 { | 347 { |
348 // We should not crash when trying to scroll an empty layer tree. | 348 // We should not crash when trying to scroll an empty layer tree. |
349 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); | 349 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
350 } | 350 } |
351 | 351 |
352 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) | 352 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) |
353 { | 353 { |
354 LayerTreeSettings settings; | 354 LayerTreeSettings settings; |
355 m_hostImpl = LayerTreeHostImpl::create(settings, this); | 355 m_hostImpl = LayerTreeHostImpl::create(settings, this); |
356 | 356 |
357 // Initialization will fail here. | 357 // Initialization will fail here. |
358 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<GraphicsContext>()); | 358 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<GraphicsContext>()); |
359 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 359 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
360 | 360 |
361 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 361 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
362 | 362 |
363 // We should not crash when trying to scroll after the renderer initializati
on fails. | 363 // We should not crash when trying to scroll after the renderer initializati
on fails. |
364 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); | 364 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
365 } | 365 } |
366 | 366 |
367 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) | 367 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) |
368 { | 368 { |
369 const int scrollLayerId = 1; | 369 const int scrollLayerId = 1; |
370 | 370 |
371 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 371 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
372 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 372 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
373 initializeRendererAndDrawFrame(); | 373 initializeRendererAndDrawFrame(); |
374 | 374 |
375 // We should not crash if the tree is replaced while we are scrolling. | 375 // We should not crash if the tree is replaced while we are scrolling. |
376 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 376 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
377 m_hostImpl->detachLayerTree(); | 377 m_hostImpl->detachLayerTree(); |
378 | 378 |
379 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 379 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
380 | 380 |
381 // We should still be scrolling, because the scrolled layer also exists in t
he new tree. | 381 // We should still be scrolling, because the scrolled layer also exists in t
he new tree. |
382 IntSize scrollDelta(0, 10); | 382 IntSize scrollDelta(0, 10); |
383 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 383 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
384 m_hostImpl->scrollEnd(); | 384 m_hostImpl->scrollEnd(); |
385 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 385 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
386 expectContains(*scrollInfo, scrollLayerId, scrollDelta); | 386 expectContains(*scrollInfo, scrollLayerId, scrollDelta); |
387 } | 387 } |
388 | 388 |
389 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) | 389 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) |
390 { | 390 { |
391 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 391 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
392 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 392 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
393 initializeRendererAndDrawFrame(); | 393 initializeRendererAndDrawFrame(); |
394 | 394 |
395 // We should be able to scroll even if the root layer loses its render surfa
ce after the most | 395 // We should be able to scroll even if the root layer loses its render surfa
ce after the most |
396 // recent render. | 396 // recent render. |
397 m_hostImpl->rootLayer()->clearRenderSurface(); | 397 m_hostImpl->rootLayer()->clearRenderSurface(); |
398 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 398 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
399 } | 399 } |
400 | 400 |
401 TEST_P(LayerTreeHostImplTest, wheelEventHandlers) | 401 TEST_P(LayerTreeHostImplTest, wheelEventHandlers) |
402 { | 402 { |
403 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 403 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
404 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 404 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
405 initializeRendererAndDrawFrame(); | 405 initializeRendererAndDrawFrame(); |
406 LayerImpl* root = m_hostImpl->rootLayer(); | 406 LayerImpl* root = m_hostImpl->rootLayer(); |
407 | 407 |
408 root->setHaveWheelEventHandlers(true); | 408 root->setHaveWheelEventHandlers(true); |
409 | 409 |
410 // With registered event handlers, wheel scrolls have to go to the main thre
ad. | 410 // With registered event handlers, wheel scrolls have to go to the main thre
ad. |
411 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollOnMainThread); | 411 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); |
412 | 412 |
413 // But gesture scrolls can still be handled. | 413 // But gesture scrolls can still be handled. |
414 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollStarted); | 414 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); |
415 } | 415 } |
416 | 416 |
417 TEST_P(LayerTreeHostImplTest, shouldScrollOnMainThread) | 417 TEST_P(LayerTreeHostImplTest, shouldScrollOnMainThread) |
418 { | 418 { |
419 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 419 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
420 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 420 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
421 initializeRendererAndDrawFrame(); | 421 initializeRendererAndDrawFrame(); |
422 LayerImpl* root = m_hostImpl->rootLayer(); | 422 LayerImpl* root = m_hostImpl->rootLayer(); |
423 | 423 |
424 root->setShouldScrollOnMainThread(true); | 424 root->setShouldScrollOnMainThread(true); |
425 | 425 |
426 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollOnMainThread); | 426 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); |
427 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollOnMainThread); | 427 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollOnMainThread); |
428 } | 428 } |
429 | 429 |
430 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionBasic) | 430 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionBasic) |
431 { | 431 { |
432 setupScrollAndContentsLayers(gfx::Size(200, 200)); | 432 setupScrollAndContentsLayers(gfx::Size(200, 200)); |
433 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); | 433 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
434 initializeRendererAndDrawFrame(); | 434 initializeRendererAndDrawFrame(); |
435 LayerImpl* root = m_hostImpl->rootLayer(); | 435 LayerImpl* root = m_hostImpl->rootLayer(); |
436 | 436 |
437 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 437 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
438 | 438 |
439 // All scroll types inside the non-fast scrollable region should fail. | 439 // All scroll types inside the non-fast scrollable region should fail. |
440 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); | 440 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); |
441 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollOnMainThread); | 441 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollOnMainThread); |
442 | 442 |
443 // All scroll types outside this region should succeed. | 443 // All scroll types outside this region should succeed. |
444 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 444 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); |
445 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 445 m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10)); |
446 m_hostImpl->scrollEnd(); | 446 m_hostImpl->scrollEnd(); |
447 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); | 447 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); |
448 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 448 m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10)); |
449 m_hostImpl->scrollEnd(); | 449 m_hostImpl->scrollEnd(); |
450 } | 450 } |
451 | 451 |
452 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) | 452 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) |
453 { | 453 { |
454 setupScrollAndContentsLayers(gfx::Size(200, 200)); | 454 setupScrollAndContentsLayers(gfx::Size(200, 200)); |
455 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); | 455 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
456 LayerImpl* root = m_hostImpl->rootLayer(); | 456 LayerImpl* root = m_hostImpl->rootLayer(); |
457 | 457 |
458 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 458 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
459 root->setPosition(gfx::PointF(-25, 0)); | 459 root->setPosition(gfx::PointF(-25, 0)); |
460 initializeRendererAndDrawFrame(); | 460 initializeRendererAndDrawFrame(); |
461 | 461 |
462 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. | 462 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. |
463 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(40, 10), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 463 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); |
464 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 1)); | 464 m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 1)); |
465 m_hostImpl->scrollEnd(); | 465 m_hostImpl->scrollEnd(); |
466 | 466 |
467 // This point is still inside the non-fast region. | 467 // This point is still inside the non-fast region. |
468 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(10, 10), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); | 468 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); |
469 } | 469 } |
470 | 470 |
471 TEST_P(LayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor) | 471 TEST_P(LayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor) |
472 { | 472 { |
473 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 473 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
474 | 474 |
475 float deviceScaleFactor = 2; | 475 float deviceScaleFactor = 2; |
476 gfx::Size layoutViewport(25, 25); | 476 gfx::Size layoutViewport(25, 25); |
477 gfx::Size deviceViewport(gfx::ToFlooredSize(layoutViewport.Scale(deviceScale
Factor))); | 477 gfx::Size deviceViewport(gfx::ToFlooredSize(layoutViewport.Scale(deviceScale
Factor))); |
478 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); | 478 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 526 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
527 scrollLayer->setImplTransform(identityScaleTransform); | 527 scrollLayer->setImplTransform(identityScaleTransform); |
528 scrollLayer->setScrollDelta(IntSize()); | 528 scrollLayer->setScrollDelta(IntSize()); |
529 | 529 |
530 float pageScaleDelta = 2; | 530 float pageScaleDelta = 2; |
531 m_hostImpl->pinchGestureBegin(); | 531 m_hostImpl->pinchGestureBegin(); |
532 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); | 532 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); |
533 m_hostImpl->pinchGestureEnd(); | 533 m_hostImpl->pinchGestureEnd(); |
534 | 534 |
535 IntSize scrollDelta(0, 10); | 535 IntSize scrollDelta(0, 10); |
536 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); | 536 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
537 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 537 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
538 m_hostImpl->scrollEnd(); | 538 m_hostImpl->scrollEnd(); |
539 | 539 |
540 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 540 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
541 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); | 541 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); |
542 } | 542 } |
543 } | 543 } |
544 | 544 |
545 TEST_P(LayerTreeHostImplTest, pinchGesture) | 545 TEST_P(LayerTreeHostImplTest, pinchGesture) |
546 { | 546 { |
547 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 547 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 if (!Settings::pageScalePinchZoomEnabled()) { | 778 if (!Settings::pageScalePinchZoomEnabled()) { |
779 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 779 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
780 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | 780 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); |
781 } else { | 781 } else { |
782 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); | 782 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); |
783 EXPECT_TRUE(scrollInfo->scrolls.empty()); | 783 EXPECT_TRUE(scrollInfo->scrolls.empty()); |
784 } | 784 } |
785 | 785 |
786 // Scrolling during the animation is ignored. | 786 // Scrolling during the animation is ignored. |
787 const IntSize scrollDelta(0, 10); | 787 const IntSize scrollDelta(0, 10); |
788 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 788 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); |
789 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 789 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
790 m_hostImpl->scrollEnd(); | 790 m_hostImpl->scrollEnd(); |
791 | 791 |
792 // The final page scale and scroll deltas should match what we got | 792 // The final page scale and scroll deltas should match what we got |
793 // earlier. | 793 // earlier. |
794 m_hostImpl->animate(endTime, base::Time()); | 794 m_hostImpl->animate(endTime, base::Time()); |
795 scrollInfo = m_hostImpl->processScrollDeltas(); | 795 scrollInfo = m_hostImpl->processScrollDeltas(); |
796 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 796 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
797 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | 797 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); |
798 } | 798 } |
799 | 799 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 } | 1020 } |
1021 | 1021 |
1022 TEST_P(LayerTreeHostImplTest, scrollRootIgnored) | 1022 TEST_P(LayerTreeHostImplTest, scrollRootIgnored) |
1023 { | 1023 { |
1024 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1024 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1025 root->setScrollable(false); | 1025 root->setScrollable(false); |
1026 m_hostImpl->setRootLayer(root.Pass()); | 1026 m_hostImpl->setRootLayer(root.Pass()); |
1027 initializeRendererAndDrawFrame(); | 1027 initializeRendererAndDrawFrame(); |
1028 | 1028 |
1029 // Scroll event is ignored because layer is not scrollable. | 1029 // Scroll event is ignored because layer is not scrollable. |
1030 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); | 1030 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
1031 EXPECT_FALSE(m_didRequestRedraw); | 1031 EXPECT_FALSE(m_didRequestRedraw); |
1032 EXPECT_FALSE(m_didRequestCommit); | 1032 EXPECT_FALSE(m_didRequestCommit); |
1033 } | 1033 } |
1034 | 1034 |
1035 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot) | 1035 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot) |
1036 { | 1036 { |
1037 // Test the configuration where a non-composited root layer is embedded in a | 1037 // Test the configuration where a non-composited root layer is embedded in a |
1038 // scrollable outer layer. | 1038 // scrollable outer layer. |
1039 gfx::Size surfaceSize(10, 10); | 1039 gfx::Size surfaceSize(10, 10); |
1040 | 1040 |
(...skipping 12 matching lines...) Expand all Loading... |
1053 scrollLayer->setBounds(surfaceSize); | 1053 scrollLayer->setBounds(surfaceSize); |
1054 scrollLayer->setContentBounds(surfaceSize); | 1054 scrollLayer->setContentBounds(surfaceSize); |
1055 scrollLayer->setPosition(gfx::PointF(0, 0)); | 1055 scrollLayer->setPosition(gfx::PointF(0, 0)); |
1056 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); | 1056 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); |
1057 scrollLayer->addChild(contentLayer.Pass()); | 1057 scrollLayer->addChild(contentLayer.Pass()); |
1058 | 1058 |
1059 m_hostImpl->setRootLayer(scrollLayer.Pass()); | 1059 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
1060 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1060 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1061 initializeRendererAndDrawFrame(); | 1061 initializeRendererAndDrawFrame(); |
1062 | 1062 |
1063 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1063 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1064 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 1064 m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10)); |
1065 m_hostImpl->scrollEnd(); | 1065 m_hostImpl->scrollEnd(); |
1066 EXPECT_TRUE(m_didRequestRedraw); | 1066 EXPECT_TRUE(m_didRequestRedraw); |
1067 EXPECT_TRUE(m_didRequestCommit); | 1067 EXPECT_TRUE(m_didRequestCommit); |
1068 } | 1068 } |
1069 | 1069 |
1070 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) | 1070 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) |
1071 { | 1071 { |
1072 gfx::Size surfaceSize(10, 10); | 1072 gfx::Size surfaceSize(10, 10); |
1073 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1073 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1074 root->setBounds(surfaceSize); | 1074 root->setBounds(surfaceSize); |
1075 root->setContentBounds(surfaceSize); | 1075 root->setContentBounds(surfaceSize); |
1076 root->addChild(createScrollableLayer(2, surfaceSize)); | 1076 root->addChild(createScrollableLayer(2, surfaceSize)); |
1077 m_hostImpl->setRootLayer(root.Pass()); | 1077 m_hostImpl->setRootLayer(root.Pass()); |
1078 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1078 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1079 initializeRendererAndDrawFrame(); | 1079 initializeRendererAndDrawFrame(); |
1080 | 1080 |
1081 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1081 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1082 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 1082 m_hostImpl->scrollBy(gfx::Point(), IntSize(0, 10)); |
1083 m_hostImpl->scrollEnd(); | 1083 m_hostImpl->scrollEnd(); |
1084 EXPECT_TRUE(m_didRequestRedraw); | 1084 EXPECT_TRUE(m_didRequestRedraw); |
1085 EXPECT_TRUE(m_didRequestCommit); | 1085 EXPECT_TRUE(m_didRequestCommit); |
1086 } | 1086 } |
1087 | 1087 |
1088 TEST_P(LayerTreeHostImplTest, scrollMissesChild) | 1088 TEST_P(LayerTreeHostImplTest, scrollMissesChild) |
1089 { | 1089 { |
1090 gfx::Size surfaceSize(10, 10); | 1090 gfx::Size surfaceSize(10, 10); |
1091 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1091 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1092 root->addChild(createScrollableLayer(2, surfaceSize)); | 1092 root->addChild(createScrollableLayer(2, surfaceSize)); |
1093 m_hostImpl->setRootLayer(root.Pass()); | 1093 m_hostImpl->setRootLayer(root.Pass()); |
1094 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1094 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1095 initializeRendererAndDrawFrame(); | 1095 initializeRendererAndDrawFrame(); |
1096 | 1096 |
1097 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. | 1097 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. |
1098 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), InputHandlerClient::Wheel
), InputHandlerClient::ScrollIgnored); | 1098 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(15, 5), InputHandlerClient::Whe
el), InputHandlerClient::ScrollIgnored); |
1099 EXPECT_FALSE(m_didRequestRedraw); | 1099 EXPECT_FALSE(m_didRequestRedraw); |
1100 EXPECT_FALSE(m_didRequestCommit); | 1100 EXPECT_FALSE(m_didRequestCommit); |
1101 } | 1101 } |
1102 | 1102 |
1103 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) | 1103 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) |
1104 { | 1104 { |
1105 gfx::Size surfaceSize(10, 10); | 1105 gfx::Size surfaceSize(10, 10); |
1106 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1106 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1107 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1107 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
1108 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1108 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1109 | 1109 |
1110 WebTransformationMatrix matrix; | 1110 WebTransformationMatrix matrix; |
1111 matrix.rotate3d(180, 0, 0); | 1111 matrix.rotate3d(180, 0, 0); |
1112 child->setTransform(matrix); | 1112 child->setTransform(matrix); |
1113 child->setDoubleSided(false); | 1113 child->setDoubleSided(false); |
1114 | 1114 |
1115 root->addChild(child.Pass()); | 1115 root->addChild(child.Pass()); |
1116 m_hostImpl->setRootLayer(root.Pass()); | 1116 m_hostImpl->setRootLayer(root.Pass()); |
1117 initializeRendererAndDrawFrame(); | 1117 initializeRendererAndDrawFrame(); |
1118 | 1118 |
1119 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is | 1119 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is |
1120 // nothing scrollable behind it. | 1120 // nothing scrollable behind it. |
1121 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollIgnored); | 1121 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
1122 EXPECT_FALSE(m_didRequestRedraw); | 1122 EXPECT_FALSE(m_didRequestRedraw); |
1123 EXPECT_FALSE(m_didRequestCommit); | 1123 EXPECT_FALSE(m_didRequestCommit); |
1124 } | 1124 } |
1125 | 1125 |
1126 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer) | 1126 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer) |
1127 { | 1127 { |
1128 gfx::Size surfaceSize(10, 10); | 1128 gfx::Size surfaceSize(10, 10); |
1129 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); | 1129 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); |
1130 contentLayer->setShouldScrollOnMainThread(true); | 1130 contentLayer->setShouldScrollOnMainThread(true); |
1131 contentLayer->setScrollable(false); | 1131 contentLayer->setScrollable(false); |
1132 | 1132 |
1133 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); | 1133 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); |
1134 scrollLayer->addChild(contentLayer.Pass()); | 1134 scrollLayer->addChild(contentLayer.Pass()); |
1135 | 1135 |
1136 m_hostImpl->setRootLayer(scrollLayer.Pass()); | 1136 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
1137 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1137 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1138 initializeRendererAndDrawFrame(); | 1138 initializeRendererAndDrawFrame(); |
1139 | 1139 |
1140 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. | 1140 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. |
1141 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollOnMainThread); | 1141 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); |
1142 } | 1142 } |
1143 | 1143 |
1144 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) | 1144 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) |
1145 { | 1145 { |
1146 gfx::Size surfaceSize(10, 10); | 1146 gfx::Size surfaceSize(10, 10); |
1147 float pageScale = 2; | 1147 float pageScale = 2; |
1148 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1148 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1149 m_hostImpl->setRootLayer(root.Pass()); | 1149 m_hostImpl->setRootLayer(root.Pass()); |
1150 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1150 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1151 initializeRendererAndDrawFrame(); | 1151 initializeRendererAndDrawFrame(); |
1152 | 1152 |
1153 IntSize scrollDelta(0, 10); | 1153 IntSize scrollDelta(0, 10); |
1154 IntSize expectedScrollDelta(scrollDelta); | 1154 IntSize expectedScrollDelta(scrollDelta); |
1155 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1155 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
1156 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1156 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1157 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1157 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1158 m_hostImpl->scrollEnd(); | 1158 m_hostImpl->scrollEnd(); |
1159 | 1159 |
1160 // Set new page scale from main thread. | 1160 // Set new page scale from main thread. |
1161 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); | 1161 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); |
1162 | 1162 |
1163 if (!Settings::pageScalePinchZoomEnabled()) { | 1163 if (!Settings::pageScalePinchZoomEnabled()) { |
1164 // The scale should apply to the scroll delta. | 1164 // The scale should apply to the scroll delta. |
1165 expectedScrollDelta.scale(pageScale); | 1165 expectedScrollDelta.scale(pageScale); |
1166 } | 1166 } |
1167 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1167 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
(...skipping 12 matching lines...) Expand all Loading... |
1180 float pageScale = 2; | 1180 float pageScale = 2; |
1181 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1181 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1182 m_hostImpl->setRootLayer(root.Pass()); | 1182 m_hostImpl->setRootLayer(root.Pass()); |
1183 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1183 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1184 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 1184 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
1185 initializeRendererAndDrawFrame(); | 1185 initializeRendererAndDrawFrame(); |
1186 | 1186 |
1187 IntSize scrollDelta(0, 10); | 1187 IntSize scrollDelta(0, 10); |
1188 IntSize expectedScrollDelta(scrollDelta); | 1188 IntSize expectedScrollDelta(scrollDelta); |
1189 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1189 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
1190 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1190 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1191 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1191 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1192 m_hostImpl->scrollEnd(); | 1192 m_hostImpl->scrollEnd(); |
1193 | 1193 |
1194 // Set new page scale on impl thread by pinching. | 1194 // Set new page scale on impl thread by pinching. |
1195 m_hostImpl->pinchGestureBegin(); | 1195 m_hostImpl->pinchGestureBegin(); |
1196 m_hostImpl->pinchGestureUpdate(pageScale, IntPoint()); | 1196 m_hostImpl->pinchGestureUpdate(pageScale, IntPoint()); |
1197 m_hostImpl->pinchGestureEnd(); | 1197 m_hostImpl->pinchGestureEnd(); |
1198 m_hostImpl->updateRootScrollLayerImplTransform(); | 1198 m_hostImpl->updateRootScrollLayerImplTransform(); |
1199 | 1199 |
1200 // The scroll delta is not scaled because the main thread did not scale. | 1200 // The scroll delta is not scaled because the main thread did not scale. |
1201 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1201 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); | 1267 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); |
1268 m_hostImpl->setRootLayer(root.Pass()); | 1268 m_hostImpl->setRootLayer(root.Pass()); |
1269 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1269 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1270 initializeRendererAndDrawFrame(); | 1270 initializeRendererAndDrawFrame(); |
1271 | 1271 |
1272 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1272 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
1273 | 1273 |
1274 IntSize scrollDelta(0, 10); | 1274 IntSize scrollDelta(0, 10); |
1275 IntSize expectedScrollDelta(scrollDelta); | 1275 IntSize expectedScrollDelta(scrollDelta); |
1276 IntSize expectedMaxScroll(child->maxScrollPosition()); | 1276 IntSize expectedMaxScroll(child->maxScrollPosition()); |
1277 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1277 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1278 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1278 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1279 m_hostImpl->scrollEnd(); | 1279 m_hostImpl->scrollEnd(); |
1280 | 1280 |
1281 float pageScale = 2; | 1281 float pageScale = 2; |
1282 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); | 1282 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); |
1283 | 1283 |
1284 m_hostImpl->updateRootScrollLayerImplTransform(); | 1284 m_hostImpl->updateRootScrollLayerImplTransform(); |
1285 | 1285 |
1286 if (!Settings::pageScalePinchZoomEnabled()) { | 1286 if (!Settings::pageScalePinchZoomEnabled()) { |
1287 // The scale should apply to the scroll delta. | 1287 // The scale should apply to the scroll delta. |
1288 expectedScrollDelta.scale(pageScale); | 1288 expectedScrollDelta.scale(pageScale); |
(...skipping 23 matching lines...) Expand all Loading... |
1312 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1312 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
1313 child->setScrollPosition(IntPoint(3, 0)); | 1313 child->setScrollPosition(IntPoint(3, 0)); |
1314 child->addChild(grandChild.Pass()); | 1314 child->addChild(grandChild.Pass()); |
1315 | 1315 |
1316 root->addChild(child.Pass()); | 1316 root->addChild(child.Pass()); |
1317 m_hostImpl->setRootLayer(root.Pass()); | 1317 m_hostImpl->setRootLayer(root.Pass()); |
1318 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1318 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1319 initializeRendererAndDrawFrame(); | 1319 initializeRendererAndDrawFrame(); |
1320 { | 1320 { |
1321 IntSize scrollDelta(-8, -7); | 1321 IntSize scrollDelta(-8, -7); |
1322 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); | 1322 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
1323 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1323 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1324 m_hostImpl->scrollEnd(); | 1324 m_hostImpl->scrollEnd(); |
1325 | 1325 |
1326 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1326 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1327 | 1327 |
1328 // The grand child should have scrolled up to its limit. | 1328 // The grand child should have scrolled up to its limit. |
1329 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1329 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
1330 LayerImpl* grandChild = child->children()[0]; | 1330 LayerImpl* grandChild = child->children()[0]; |
1331 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); | 1331 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); |
1332 | 1332 |
1333 // The child should have only scrolled on the other axis. | 1333 // The child should have only scrolled on the other axis. |
(...skipping 10 matching lines...) Expand all Loading... |
1344 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1344 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
1345 | 1345 |
1346 child->setScrollable(false); | 1346 child->setScrollable(false); |
1347 root->addChild(child.Pass()); | 1347 root->addChild(child.Pass()); |
1348 | 1348 |
1349 m_hostImpl->setRootLayer(root.Pass()); | 1349 m_hostImpl->setRootLayer(root.Pass()); |
1350 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1350 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1351 initializeRendererAndDrawFrame(); | 1351 initializeRendererAndDrawFrame(); |
1352 { | 1352 { |
1353 IntSize scrollDelta(0, 4); | 1353 IntSize scrollDelta(0, 4); |
1354 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); | 1354 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
1355 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1355 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1356 m_hostImpl->scrollEnd(); | 1356 m_hostImpl->scrollEnd(); |
1357 | 1357 |
1358 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1358 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1359 | 1359 |
1360 // Only the root should have scrolled. | 1360 // Only the root should have scrolled. |
1361 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 1361 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
1362 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); | 1362 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); |
1363 } | 1363 } |
1364 } | 1364 } |
1365 | 1365 |
1366 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw) | 1366 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw) |
1367 { | 1367 { |
1368 gfx::Size surfaceSize(10, 10); | 1368 gfx::Size surfaceSize(10, 10); |
1369 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize)); | 1369 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize)); |
1370 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1370 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1371 | 1371 |
1372 // Draw one frame and then immediately rebuild the layer tree to mimic a tre
e synchronization. | 1372 // Draw one frame and then immediately rebuild the layer tree to mimic a tre
e synchronization. |
1373 initializeRendererAndDrawFrame(); | 1373 initializeRendererAndDrawFrame(); |
1374 m_hostImpl->detachLayerTree(); | 1374 m_hostImpl->detachLayerTree(); |
1375 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize)); | 1375 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize)); |
1376 | 1376 |
1377 // Scrolling should still work even though we did not draw yet. | 1377 // Scrolling should still work even though we did not draw yet. |
1378 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1378 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1379 } | 1379 } |
1380 | 1380 |
1381 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) | 1381 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) |
1382 { | 1382 { |
1383 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 1383 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
1384 | 1384 |
1385 // Rotate the root layer 90 degrees counter-clockwise about its center. | 1385 // Rotate the root layer 90 degrees counter-clockwise about its center. |
1386 WebTransformationMatrix rotateTransform; | 1386 WebTransformationMatrix rotateTransform; |
1387 rotateTransform.rotate(-90); | 1387 rotateTransform.rotate(-90); |
1388 m_hostImpl->rootLayer()->setTransform(rotateTransform); | 1388 m_hostImpl->rootLayer()->setTransform(rotateTransform); |
1389 | 1389 |
1390 gfx::Size surfaceSize(50, 50); | 1390 gfx::Size surfaceSize(50, 50); |
1391 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1391 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1392 initializeRendererAndDrawFrame(); | 1392 initializeRendererAndDrawFrame(); |
1393 | 1393 |
1394 // Scroll to the right in screen coordinates with a gesture. | 1394 // Scroll to the right in screen coordinates with a gesture. |
1395 IntSize gestureScrollDelta(10, 0); | 1395 IntSize gestureScrollDelta(10, 0); |
1396 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollStarted); | 1396 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); |
1397 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); | 1397 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); |
1398 m_hostImpl->scrollEnd(); | 1398 m_hostImpl->scrollEnd(); |
1399 | 1399 |
1400 // The layer should have scrolled down in its local coordinates. | 1400 // The layer should have scrolled down in its local coordinates. |
1401 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1401 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
1402 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0,
gestureScrollDelta.width())); | 1402 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0,
gestureScrollDelta.width())); |
1403 | 1403 |
1404 // Reset and scroll down with the wheel. | 1404 // Reset and scroll down with the wheel. |
1405 m_hostImpl->rootLayer()->setScrollDelta(FloatSize()); | 1405 m_hostImpl->rootLayer()->setScrollDelta(FloatSize()); |
1406 IntSize wheelScrollDelta(0, 10); | 1406 IntSize wheelScrollDelta(0, 10); |
1407 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1407 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1408 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta); | 1408 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); |
1409 m_hostImpl->scrollEnd(); | 1409 m_hostImpl->scrollEnd(); |
1410 | 1410 |
1411 // The layer should have scrolled down in its local coordinates. | 1411 // The layer should have scrolled down in its local coordinates. |
1412 scrollInfo = m_hostImpl->processScrollDeltas(); | 1412 scrollInfo = m_hostImpl->processScrollDeltas(); |
1413 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); | 1413 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); |
1414 } | 1414 } |
1415 | 1415 |
1416 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) | 1416 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) |
1417 { | 1417 { |
1418 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 1418 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
(...skipping 12 matching lines...) Expand all Loading... |
1431 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height())); | 1431 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height())); |
1432 m_hostImpl->rootLayer()->addChild(child.Pass()); | 1432 m_hostImpl->rootLayer()->addChild(child.Pass()); |
1433 | 1433 |
1434 gfx::Size surfaceSize(50, 50); | 1434 gfx::Size surfaceSize(50, 50); |
1435 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1435 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1436 initializeRendererAndDrawFrame(); | 1436 initializeRendererAndDrawFrame(); |
1437 | 1437 |
1438 { | 1438 { |
1439 // Scroll down in screen coordinates with a gesture. | 1439 // Scroll down in screen coordinates with a gesture. |
1440 IntSize gestureScrollDelta(0, 10); | 1440 IntSize gestureScrollDelta(0, 10); |
1441 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); | 1441 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); |
1442 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); | 1442 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); |
1443 m_hostImpl->scrollEnd(); | 1443 m_hostImpl->scrollEnd(); |
1444 | 1444 |
1445 // The child layer should have scrolled down in its local coordinates an
amount proportional to | 1445 // The child layer should have scrolled down in its local coordinates an
amount proportional to |
1446 // the angle between it and the input scroll delta. | 1446 // the angle between it and the input scroll delta. |
1447 IntSize expectedScrollDelta(0, gestureScrollDelta.height() * cosf(deg2ra
d(childLayerAngle))); | 1447 IntSize expectedScrollDelta(0, gestureScrollDelta.height() * cosf(deg2ra
d(childLayerAngle))); |
1448 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1448 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1449 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1449 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
1450 | 1450 |
1451 // The root layer should not have scrolled, because the input delta was
close to the layer's | 1451 // The root layer should not have scrolled, because the input delta was
close to the layer's |
1452 // axis of movement. | 1452 // axis of movement. |
1453 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); | 1453 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); |
1454 } | 1454 } |
1455 | 1455 |
1456 { | 1456 { |
1457 // Now reset and scroll the same amount horizontally. | 1457 // Now reset and scroll the same amount horizontally. |
1458 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(FloatSize()); | 1458 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(FloatSize()); |
1459 IntSize gestureScrollDelta(10, 0); | 1459 IntSize gestureScrollDelta(10, 0); |
1460 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); | 1460 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); |
1461 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); | 1461 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); |
1462 m_hostImpl->scrollEnd(); | 1462 m_hostImpl->scrollEnd(); |
1463 | 1463 |
1464 // The child layer should have scrolled down in its local coordinates an
amount proportional to | 1464 // The child layer should have scrolled down in its local coordinates an
amount proportional to |
1465 // the angle between it and the input scroll delta. | 1465 // the angle between it and the input scroll delta. |
1466 IntSize expectedScrollDelta(0, -gestureScrollDelta.width() * sinf(deg2ra
d(childLayerAngle))); | 1466 IntSize expectedScrollDelta(0, -gestureScrollDelta.width() * sinf(deg2ra
d(childLayerAngle))); |
1467 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1467 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1468 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1468 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
1469 | 1469 |
1470 // The root layer should have scrolled more, since the input scroll delt
a was mostly | 1470 // The root layer should have scrolled more, since the input scroll delt
a was mostly |
1471 // orthogonal to the child layer's vertical scroll axis. | 1471 // orthogonal to the child layer's vertical scroll axis. |
(...skipping 11 matching lines...) Expand all Loading... |
1483 WebTransformationMatrix scaleTransform; | 1483 WebTransformationMatrix scaleTransform; |
1484 scaleTransform.scale(scale); | 1484 scaleTransform.scale(scale); |
1485 m_hostImpl->rootLayer()->setTransform(scaleTransform); | 1485 m_hostImpl->rootLayer()->setTransform(scaleTransform); |
1486 | 1486 |
1487 gfx::Size surfaceSize(50, 50); | 1487 gfx::Size surfaceSize(50, 50); |
1488 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1488 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1489 initializeRendererAndDrawFrame(); | 1489 initializeRendererAndDrawFrame(); |
1490 | 1490 |
1491 // Scroll down in screen coordinates with a gesture. | 1491 // Scroll down in screen coordinates with a gesture. |
1492 IntSize scrollDelta(0, 10); | 1492 IntSize scrollDelta(0, 10); |
1493 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur
e), InputHandlerClient::ScrollStarted); | 1493 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); |
1494 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1494 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1495 m_hostImpl->scrollEnd(); | 1495 m_hostImpl->scrollEnd(); |
1496 | 1496 |
1497 // The layer should have scrolled down in its local coordinates, but half he
amount. | 1497 // The layer should have scrolled down in its local coordinates, but half he
amount. |
1498 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1498 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
1499 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0,
scrollDelta.height() / scale)); | 1499 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0,
scrollDelta.height() / scale)); |
1500 | 1500 |
1501 // Reset and scroll down with the wheel. | 1501 // Reset and scroll down with the wheel. |
1502 m_hostImpl->rootLayer()->setScrollDelta(FloatSize()); | 1502 m_hostImpl->rootLayer()->setScrollDelta(FloatSize()); |
1503 IntSize wheelScrollDelta(0, 10); | 1503 IntSize wheelScrollDelta(0, 10); |
1504 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel)
, InputHandlerClient::ScrollStarted); | 1504 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1505 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta); | 1505 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); |
1506 m_hostImpl->scrollEnd(); | 1506 m_hostImpl->scrollEnd(); |
1507 | 1507 |
1508 // The scale should not have been applied to the scroll delta. | 1508 // The scale should not have been applied to the scroll delta. |
1509 scrollInfo = m_hostImpl->processScrollDeltas(); | 1509 scrollInfo = m_hostImpl->processScrollDeltas(); |
1510 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); | 1510 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); |
1511 } | 1511 } |
1512 | 1512 |
1513 class BlendStateTrackerContext: public FakeWebGraphicsContext3D { | 1513 class BlendStateTrackerContext: public FakeWebGraphicsContext3D { |
1514 public: | 1514 public: |
1515 BlendStateTrackerContext() : m_blend(false) { } | 1515 BlendStateTrackerContext() : m_blend(false) { } |
(...skipping 2887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4403 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4403 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
4404 testCaseIndex++; | 4404 testCaseIndex++; |
4405 } | 4405 } |
4406 } | 4406 } |
4407 | 4407 |
4408 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4408 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4409 LayerTreeHostImplTest, | 4409 LayerTreeHostImplTest, |
4410 ::testing::Values(false, true)); | 4410 ::testing::Values(false, true)); |
4411 | 4411 |
4412 } // namespace | 4412 } // namespace |
OLD | NEW |