| 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 25 matching lines...) Expand all Loading... |
| 36 #include "WebFrameClient.h" | 36 #include "WebFrameClient.h" |
| 37 #include "WebFrameImpl.h" | 37 #include "WebFrameImpl.h" |
| 38 #include "WebSettings.h" | 38 #include "WebSettings.h" |
| 39 #include "WebViewClient.h" | 39 #include "WebViewClient.h" |
| 40 #include "WebViewImpl.h" | 40 #include "WebViewImpl.h" |
| 41 #include <gtest/gtest.h> | 41 #include <gtest/gtest.h> |
| 42 #include <public/WebCompositorSupport.h> | 42 #include <public/WebCompositorSupport.h> |
| 43 #include <public/WebLayer.h> | 43 #include <public/WebLayer.h> |
| 44 #include <webkit/support/webkit_support.h> | 44 #include <webkit/support/webkit_support.h> |
| 45 | 45 |
| 46 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING) | |
| 47 #include "GraphicsLayerChromium.h" | 46 #include "GraphicsLayerChromium.h" |
| 48 #endif | |
| 49 | 47 |
| 50 using namespace WebCore; | 48 using namespace WebCore; |
| 51 using namespace WebKit; | 49 using namespace WebKit; |
| 52 | 50 |
| 53 namespace { | 51 namespace { |
| 54 | 52 |
| 55 class MockWebViewClient : public WebViewClient { | 53 class MockWebViewClient : public WebViewClient { |
| 56 public: | 54 public: |
| 57 virtual WebCompositorOutputSurface* createOutputSurface() OVERRIDE | 55 virtual WebCompositorOutputSurface* createOutputSurface() OVERRIDE |
| 58 { | 56 { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 71 { | 69 { |
| 72 Platform::current()->compositorSupport()->initialize(0); | 70 Platform::current()->compositorSupport()->initialize(0); |
| 73 | 71 |
| 74 // We cannot reuse FrameTestHelpers::createWebViewAndLoad here because t
he compositing | 72 // We cannot reuse FrameTestHelpers::createWebViewAndLoad here because t
he compositing |
| 75 // settings need to be set before the page is loaded. | 73 // settings need to be set before the page is loaded. |
| 76 m_webViewImpl = static_cast<WebViewImpl*>(WebView::create(&m_mockWebView
Client)); | 74 m_webViewImpl = static_cast<WebViewImpl*>(WebView::create(&m_mockWebView
Client)); |
| 77 m_webViewImpl->settings()->setJavaScriptEnabled(true); | 75 m_webViewImpl->settings()->setJavaScriptEnabled(true); |
| 78 m_webViewImpl->settings()->setForceCompositingMode(true); | 76 m_webViewImpl->settings()->setForceCompositingMode(true); |
| 79 m_webViewImpl->settings()->setAcceleratedCompositingEnabled(true); | 77 m_webViewImpl->settings()->setAcceleratedCompositingEnabled(true); |
| 80 m_webViewImpl->settings()->setAcceleratedCompositingForFixedPositionEnab
led(true); | 78 m_webViewImpl->settings()->setAcceleratedCompositingForFixedPositionEnab
led(true); |
| 79 m_webViewImpl->settings()->setAcceleratedCompositingForOverflowScrollEna
bled(true); |
| 81 m_webViewImpl->settings()->setFixedPositionCreatesStackingContext(true); | 80 m_webViewImpl->settings()->setFixedPositionCreatesStackingContext(true); |
| 82 m_webViewImpl->initializeMainFrame(&m_mockWebFrameClient); | 81 m_webViewImpl->initializeMainFrame(&m_mockWebFrameClient); |
| 83 m_webViewImpl->resize(IntSize(320, 240)); | 82 m_webViewImpl->resize(IntSize(320, 240)); |
| 84 } | 83 } |
| 85 | 84 |
| 86 virtual ~ScrollingCoordinatorChromiumTest() | 85 virtual ~ScrollingCoordinatorChromiumTest() |
| 87 { | 86 { |
| 88 webkit_support::UnregisterAllMockedURLs(); | 87 webkit_support::UnregisterAllMockedURLs(); |
| 89 m_webViewImpl->close(); | 88 m_webViewImpl->close(); |
| 90 | 89 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 188 |
| 190 TEST_F(ScrollingCoordinatorChromiumTest, clippedBodyTest) | 189 TEST_F(ScrollingCoordinatorChromiumTest, clippedBodyTest) |
| 191 { | 190 { |
| 192 registerMockedHttpURLLoad("clipped-body.html"); | 191 registerMockedHttpURLLoad("clipped-body.html"); |
| 193 navigateTo(m_baseURL + "clipped-body.html"); | 192 navigateTo(m_baseURL + "clipped-body.html"); |
| 194 | 193 |
| 195 WebLayer* rootScrollLayer = getRootScrollLayer(); | 194 WebLayer* rootScrollLayer = getRootScrollLayer(); |
| 196 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); | 195 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); |
| 197 } | 196 } |
| 198 | 197 |
| 199 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING) | 198 TEST_F(ScrollingCoordinatorChromiumTest, overflowScrolling) |
| 200 TEST_F(ScrollingCoordinatorChromiumTest, touchOverflowScrolling) | |
| 201 { | 199 { |
| 202 registerMockedHttpURLLoad("touch-overflow-scrolling.html"); | 200 registerMockedHttpURLLoad("overflow-scrolling.html"); |
| 203 navigateTo(m_baseURL + "touch-overflow-scrolling.html"); | 201 navigateTo(m_baseURL + "overflow-scrolling.html"); |
| 204 | 202 |
| 205 // Verify the properties of the accelerated scrolling element starting from
the RenderObject | 203 // Verify the properties of the accelerated scrolling element starting from
the RenderObject |
| 206 // all the way to the WebLayer. | 204 // all the way to the WebLayer. |
| 207 Element* scrollableElement = m_webViewImpl->mainFrameImpl()->frame()->docume
nt()->getElementById("scrollable"); | 205 Element* scrollableElement = m_webViewImpl->mainFrameImpl()->frame()->docume
nt()->getElementById("scrollable"); |
| 208 ASSERT(scrollableElement); | 206 ASSERT(scrollableElement); |
| 209 | 207 |
| 210 RenderObject* renderer = scrollableElement->renderer(); | 208 RenderObject* renderer = scrollableElement->renderer(); |
| 211 ASSERT_TRUE(renderer->isBoxModelObject()); | 209 ASSERT_TRUE(renderer->isBoxModelObject()); |
| 212 ASSERT_TRUE(renderer->hasLayer()); | 210 ASSERT_TRUE(renderer->hasLayer()); |
| 213 | 211 |
| 214 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); | 212 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); |
| 215 ASSERT_TRUE(layer->usesCompositedScrolling()); | 213 ASSERT_TRUE(layer->usesCompositedScrolling()); |
| 216 ASSERT_TRUE(layer->isComposited()); | 214 ASSERT_TRUE(layer->isComposited()); |
| 217 | 215 |
| 218 RenderLayerBacking* layerBacking = layer->backing(); | 216 RenderLayerBacking* layerBacking = layer->backing(); |
| 219 ASSERT_TRUE(layerBacking->hasScrollingLayer()); | 217 ASSERT_TRUE(layerBacking->hasScrollingLayer()); |
| 220 ASSERT(layerBacking->scrollingContentsLayer()); | 218 ASSERT(layerBacking->scrollingContentsLayer()); |
| 221 | 219 |
| 222 GraphicsLayerChromium* graphicsLayerChromium = static_cast<GraphicsLayerChro
mium*>(layerBacking->scrollingContentsLayer()); | 220 GraphicsLayerChromium* graphicsLayerChromium = static_cast<GraphicsLayerChro
mium*>(layerBacking->scrollingContentsLayer()); |
| 223 ASSERT_EQ(layer, graphicsLayerChromium->scrollableArea()); | 221 ASSERT_EQ(layer, graphicsLayerChromium->scrollableArea()); |
| 224 | 222 |
| 225 WebLayer* webScrollLayer = static_cast<WebLayer*>(layerBacking->scrollingCon
tentsLayer()->platformLayer()); | 223 WebLayer* webScrollLayer = static_cast<WebLayer*>(layerBacking->scrollingCon
tentsLayer()->platformLayer()); |
| 226 ASSERT_TRUE(webScrollLayer->scrollable()); | 224 ASSERT_TRUE(webScrollLayer->scrollable()); |
| 227 } | 225 } |
| 228 #endif // ENABLE(ACCELERATED_OVERFLOW_SCROLLING) | |
| 229 | 226 |
| 230 } // namespace | 227 } // namespace |
| OLD | NEW |