Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "core/css/CSSStyleSheet.h" | 27 #include "core/css/CSSStyleSheet.h" |
| 28 #include "core/css/StyleSheetList.h" | 28 #include "core/css/StyleSheetList.h" |
| 29 #include "core/frame/FrameHost.h" | 29 #include "core/frame/FrameHost.h" |
| 30 #include "core/frame/FrameView.h" | 30 #include "core/frame/FrameView.h" |
| 31 #include "core/frame/VisualViewport.h" | 31 #include "core/frame/VisualViewport.h" |
| 32 #include "core/layout/LayoutPart.h" | 32 #include "core/layout/LayoutPart.h" |
| 33 #include "core/layout/api/LayoutViewItem.h" | 33 #include "core/layout/api/LayoutViewItem.h" |
| 34 #include "core/layout/compositing/CompositedLayerMapping.h" | 34 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 35 #include "core/layout/compositing/PaintLayerCompositor.h" | 35 #include "core/layout/compositing/PaintLayerCompositor.h" |
| 36 #include "core/page/Page.h" | 36 #include "core/page/Page.h" |
| 37 #include "platform/geometry/IntPoint.h" | |
| 38 #include "platform/geometry/IntRect.h" | |
| 37 #include "platform/graphics/GraphicsLayer.h" | 39 #include "platform/graphics/GraphicsLayer.h" |
| 38 #include "platform/testing/URLTestHelpers.h" | 40 #include "platform/testing/URLTestHelpers.h" |
| 39 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
| 40 #include "public/platform/WebLayer.h" | 42 #include "public/platform/WebLayer.h" |
| 41 #include "public/platform/WebLayerPositionConstraint.h" | 43 #include "public/platform/WebLayerPositionConstraint.h" |
| 42 #include "public/platform/WebLayerTreeView.h" | 44 #include "public/platform/WebLayerTreeView.h" |
| 43 #include "public/platform/WebURLLoaderMockFactory.h" | 45 #include "public/platform/WebURLLoaderMockFactory.h" |
| 44 #include "public/web/WebCache.h" | 46 #include "public/web/WebCache.h" |
| 45 #include "public/web/WebSettings.h" | 47 #include "public/web/WebSettings.h" |
| 46 #include "public/web/WebViewClient.h" | 48 #include "public/web/WebViewClient.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 ASSERT_TRUE(element); | 323 ASSERT_TRUE(element); |
| 322 WebLayer* layer = webLayerFromElement(element); | 324 WebLayer* layer = webLayerFromElement(element); |
| 323 ASSERT_TRUE(layer); | 325 ASSERT_TRUE(layer); |
| 324 WebLayerPositionConstraint constraint = layer->positionConstraint(); | 326 WebLayerPositionConstraint constraint = layer->positionConstraint(); |
| 325 ASSERT_TRUE(constraint.isFixedPosition); | 327 ASSERT_TRUE(constraint.isFixedPosition); |
| 326 ASSERT_TRUE(constraint.isFixedToRightEdge && | 328 ASSERT_TRUE(constraint.isFixedToRightEdge && |
| 327 constraint.isFixedToBottomEdge); | 329 constraint.isFixedToBottomEdge); |
| 328 } | 330 } |
| 329 } | 331 } |
| 330 | 332 |
| 333 TEST_F(ScrollingCoordinatorTest, fastScrollingForStickyPosition) { | |
| 334 registerMockedHttpURLLoad("sticky-position.html"); | |
|
ajuma
2016/10/07 21:14:42
Did you forget to upload this file?
flackr
2016/10/11 12:49:01
I certainly did, it's added now.
| |
| 335 navigateTo(m_baseURL + "sticky-position.html"); | |
| 336 forceFullCompositingUpdate(); | |
| 337 | |
| 338 // Sticky position should not fall back to main thread scrolling. | |
| 339 WebLayer* rootScrollLayer = getRootScrollLayer(); | |
| 340 EXPECT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); | |
| 341 | |
| 342 Document* document = frame()->document(); | |
| 343 { | |
| 344 Element* element = document->getElementById("div-tl"); | |
| 345 ASSERT_TRUE(element); | |
| 346 WebLayer* layer = webLayerFromElement(element); | |
| 347 ASSERT_TRUE(layer); | |
| 348 WebLayerStickyPositionConstraint constraint = | |
| 349 layer->stickyPositionConstraint(); | |
| 350 ASSERT_TRUE(constraint.isSticky); | |
| 351 EXPECT_TRUE(constraint.isAnchoredTop && constraint.isAnchoredLeft && | |
| 352 !constraint.isAnchoredRight && !constraint.isAnchoredBottom); | |
| 353 EXPECT_EQ(1.f, constraint.topOffset); | |
| 354 EXPECT_EQ(1.f, constraint.leftOffset); | |
| 355 EXPECT_EQ(IntRect(100, 100, 10, 10), | |
| 356 IntRect(constraint.scrollContainerRelativeStickyBoxRect)); | |
| 357 EXPECT_EQ(IntRect(100, 100, 200, 200), | |
| 358 IntRect(constraint.scrollContainerRelativeContainingBlockRect)); | |
| 359 EXPECT_EQ(IntPoint(100, 100), | |
| 360 IntPoint(constraint.parentRelativeStickyBoxOffset)); | |
| 361 } | |
| 362 { | |
| 363 Element* element = document->getElementById("div-tr"); | |
| 364 ASSERT_TRUE(element); | |
| 365 WebLayer* layer = webLayerFromElement(element); | |
| 366 ASSERT_TRUE(layer); | |
| 367 WebLayerStickyPositionConstraint constraint = | |
| 368 layer->stickyPositionConstraint(); | |
| 369 ASSERT_TRUE(constraint.isSticky); | |
| 370 EXPECT_TRUE(constraint.isAnchoredTop && !constraint.isAnchoredLeft && | |
| 371 constraint.isAnchoredRight && !constraint.isAnchoredBottom); | |
| 372 } | |
| 373 { | |
| 374 Element* element = document->getElementById("div-bl"); | |
| 375 ASSERT_TRUE(element); | |
| 376 WebLayer* layer = webLayerFromElement(element); | |
| 377 ASSERT_TRUE(layer); | |
| 378 WebLayerStickyPositionConstraint constraint = | |
| 379 layer->stickyPositionConstraint(); | |
| 380 ASSERT_TRUE(constraint.isSticky); | |
| 381 EXPECT_TRUE(!constraint.isAnchoredTop && constraint.isAnchoredLeft && | |
| 382 !constraint.isAnchoredRight && constraint.isAnchoredBottom); | |
| 383 } | |
| 384 { | |
| 385 Element* element = document->getElementById("div-br"); | |
| 386 ASSERT_TRUE(element); | |
| 387 WebLayer* layer = webLayerFromElement(element); | |
| 388 ASSERT_TRUE(layer); | |
| 389 WebLayerStickyPositionConstraint constraint = | |
| 390 layer->stickyPositionConstraint(); | |
| 391 ASSERT_TRUE(constraint.isSticky); | |
| 392 EXPECT_TRUE(!constraint.isAnchoredTop && !constraint.isAnchoredLeft && | |
| 393 constraint.isAnchoredRight && constraint.isAnchoredBottom); | |
| 394 } | |
| 395 { | |
| 396 Element* element = document->getElementById("span-tl"); | |
| 397 ASSERT_TRUE(element); | |
| 398 WebLayer* layer = webLayerFromElement(element); | |
| 399 ASSERT_TRUE(layer); | |
| 400 WebLayerStickyPositionConstraint constraint = | |
| 401 layer->stickyPositionConstraint(); | |
| 402 ASSERT_TRUE(constraint.isSticky); | |
| 403 EXPECT_TRUE(constraint.isAnchoredTop && constraint.isAnchoredLeft && | |
| 404 !constraint.isAnchoredRight && !constraint.isAnchoredBottom); | |
| 405 } | |
| 406 { | |
| 407 Element* element = document->getElementById("span-tlbr"); | |
| 408 ASSERT_TRUE(element); | |
| 409 WebLayer* layer = webLayerFromElement(element); | |
| 410 ASSERT_TRUE(layer); | |
| 411 WebLayerStickyPositionConstraint constraint = | |
| 412 layer->stickyPositionConstraint(); | |
| 413 ASSERT_TRUE(constraint.isSticky); | |
| 414 EXPECT_TRUE(constraint.isAnchoredTop && constraint.isAnchoredLeft && | |
| 415 constraint.isAnchoredRight && constraint.isAnchoredBottom); | |
| 416 EXPECT_EQ(1.f, constraint.topOffset); | |
| 417 EXPECT_EQ(1.f, constraint.leftOffset); | |
| 418 EXPECT_EQ(1.f, constraint.rightOffset); | |
| 419 EXPECT_EQ(1.f, constraint.bottomOffset); | |
| 420 } | |
| 421 { | |
| 422 Element* element = document->getElementById("composited-top"); | |
| 423 ASSERT_TRUE(element); | |
| 424 WebLayer* layer = webLayerFromElement(element); | |
| 425 ASSERT_TRUE(layer); | |
| 426 WebLayerStickyPositionConstraint constraint = | |
| 427 layer->stickyPositionConstraint(); | |
| 428 ASSERT_TRUE(constraint.isSticky); | |
| 429 EXPECT_TRUE(constraint.isAnchoredTop); | |
| 430 EXPECT_EQ(IntRect(100, 110, 10, 10), | |
| 431 IntRect(constraint.scrollContainerRelativeStickyBoxRect)); | |
| 432 EXPECT_EQ(IntRect(100, 100, 200, 200), | |
| 433 IntRect(constraint.scrollContainerRelativeContainingBlockRect)); | |
| 434 EXPECT_EQ(IntPoint(0, 10), | |
| 435 IntPoint(constraint.parentRelativeStickyBoxOffset)); | |
| 436 } | |
| 437 } | |
| 438 | |
| 331 TEST_F(ScrollingCoordinatorTest, touchEventHandler) { | 439 TEST_F(ScrollingCoordinatorTest, touchEventHandler) { |
| 332 registerMockedHttpURLLoad("touch-event-handler.html"); | 440 registerMockedHttpURLLoad("touch-event-handler.html"); |
| 333 navigateTo(m_baseURL + "touch-event-handler.html"); | 441 navigateTo(m_baseURL + "touch-event-handler.html"); |
| 334 forceFullCompositingUpdate(); | 442 forceFullCompositingUpdate(); |
| 335 | 443 |
| 336 ASSERT_EQ(WebEventListenerProperties::Blocking, | 444 ASSERT_EQ(WebEventListenerProperties::Blocking, |
| 337 webLayerTreeView()->eventListenerProperties( | 445 webLayerTreeView()->eventListenerProperties( |
| 338 WebEventListenerClass::TouchStartOrMove)); | 446 WebEventListenerClass::TouchStartOrMove)); |
| 339 } | 447 } |
| 340 | 448 |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 735 forceFullCompositingUpdate(); | 843 forceFullCompositingUpdate(); |
| 736 scrollbarGraphicsLayer = compositedLayerMapping->layerForVerticalScrollbar(); | 844 scrollbarGraphicsLayer = compositedLayerMapping->layerForVerticalScrollbar(); |
| 737 ASSERT_FALSE( | 845 ASSERT_FALSE( |
| 738 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread()); | 846 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread()); |
| 739 ASSERT_FALSE( | 847 ASSERT_FALSE( |
| 740 scrollbarGraphicsLayer->platformLayer()->mainThreadScrollingReasons() & | 848 scrollbarGraphicsLayer->platformLayer()->mainThreadScrollingReasons() & |
| 741 MainThreadScrollingReason::kCustomScrollbarScrolling); | 849 MainThreadScrollingReason::kCustomScrollbarScrolling); |
| 742 } | 850 } |
| 743 | 851 |
| 744 } // namespace blink | 852 } // namespace blink |
| OLD | NEW |