| Differences between
and this patch
- a/Source/WebKit/chromium/ChangeLog +35 lines
Lines 1-3 a/Source/WebKit/chromium/ChangeLog_sec1
1
2012-09-13  Sami Kyostila  <skyostil@chromium.org>
2
3
        [chromium] Add test for ScrollingCoordinatorChromium
4
        https://bugs.webkit.org/show_bug.cgi?id=96657
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Add tests for ScrollingCoordinatorChromium. These tests mainly verify that
9
        fast (non-main thread) scrolling is enabled when necessary and that a proper
10
        compositing layer structure is created for fixed position and accelerated
11
        scrolling layers.
12
13
        Tests: ScrollingCoordinatorChromiumTest.fastScrollingByDefault
14
               ScrollingCoordinatorChromiumTest.fastScrollingForFixedPosition
15
               ScrollingCoordinatorChromiumTest.slowScrollingForNonCompositedFixedPosition
16
               ScrollingCoordinatorChromiumTest.nonFastScrollableRegion
17
               ScrollingCoordinatorChromiumTest.wheelEventHandler
18
               ScrollingCoordinatorChromiumTest.touchOverflowScrolling
19
20
        * WebKit.gypi:
21
        * tests/ScrollingCoordinatorChromiumTest.cpp: Added.
22
        (WebKit):
23
        (MockWebViewClient):
24
        (ScrollingCoordinatorChromiumTest):
25
        (WebKit::ScrollingCoordinatorChromiumTest::ScrollingCoordinatorChromiumTest):
26
        (WebKit::ScrollingCoordinatorChromiumTest::createCompositedWebViewImpl):
27
        (WebKit::ScrollingCoordinatorChromiumTest::registerMockedHttpURLLoad):
28
        (WebKit::ScrollingCoordinatorChromiumTest::getRootScrollLayer):
29
        (WebKit::TEST_F):
30
        * tests/data/fixed_position.html: Added.
31
        * tests/data/fixed_position_non_composited.html: Added.
32
        * tests/data/non_fast_scrollable.html: Added.
33
        * tests/data/touch_overflow_scrolling.html: Added.
34
        * tests/data/wheel_event_handler.html: Added.
35
1
2012-09-14  Keishi Hattori  <keishi@webkit.org>
36
2012-09-14  Keishi Hattori  <keishi@webkit.org>
2
37
3
        Make time input lang attribute aware for testing
38
        Make time input lang attribute aware for testing
- a/Source/Platform/chromium/public/WebLayer.h +13 lines
Lines 169-180 public: a/Source/Platform/chromium/public/WebLayer.h_sec1
169
    virtual WebPoint scrollPosition() const = 0;
169
    virtual WebPoint scrollPosition() const = 0;
170
170
171
    virtual void setMaxScrollPosition(WebSize) = 0;
171
    virtual void setMaxScrollPosition(WebSize) = 0;
172
    virtual WebSize maxScrollPosition() const = 0;
173
172
    virtual void setScrollable(bool) = 0;
174
    virtual void setScrollable(bool) = 0;
175
    virtual bool scrollable() const = 0;
176
173
    virtual void setHaveWheelEventHandlers(bool) = 0;
177
    virtual void setHaveWheelEventHandlers(bool) = 0;
178
    virtual bool haveWheelEventHandlers() const = 0;
179
174
    virtual void setShouldScrollOnMainThread(bool) = 0;
180
    virtual void setShouldScrollOnMainThread(bool) = 0;
181
    virtual bool shouldScrollOnMainThread() const = 0;
182
175
    virtual void setNonFastScrollableRegion(const WebVector<WebRect>&) = 0;
183
    virtual void setNonFastScrollableRegion(const WebVector<WebRect>&) = 0;
184
    virtual WebVector<WebRect> nonFastScrollableRegion() const = 0;
185
176
    virtual void setIsContainerForFixedPositionLayers(bool) = 0;
186
    virtual void setIsContainerForFixedPositionLayers(bool) = 0;
187
    virtual bool isContainerForFixedPositionLayers() const = 0;
188
177
    virtual void setFixedToContainerLayer(bool) = 0;
189
    virtual void setFixedToContainerLayer(bool) = 0;
190
    virtual bool fixedToContainerLayer() const = 0;
178
191
179
    // The scroll client is notified when the scroll position of the WebLayer
192
    // The scroll client is notified when the scroll position of the WebLayer
180
    // changes. Only a single scroll client can be set for a WebLayer at a time.
193
    // changes. Only a single scroll client can be set for a WebLayer at a time.
- a/Source/WebKit/chromium/WebKit.gyp +1 lines
Lines 718-723 a/Source/WebKit/chromium/WebKit.gyp_sec1
718
                                'tests/PopupMenuTest.cpp',
718
                                'tests/PopupMenuTest.cpp',
719
                                'tests/RenderTableCellTest.cpp',
719
                                'tests/RenderTableCellTest.cpp',
720
                                'tests/RenderTableRowTest.cpp',
720
                                'tests/RenderTableRowTest.cpp',
721
                                'tests/ScrollingCoordinatorChromiumTest.cpp',
721
                                'tests/URLTestHelpers.cpp',
722
                                'tests/URLTestHelpers.cpp',
722
                                'tests/WebFrameTest.cpp',
723
                                'tests/WebFrameTest.cpp',
723
                                'tests/WebPageNewSerializerTest.cpp',
724
                                'tests/WebPageNewSerializerTest.cpp',
- a/Source/WebKit/chromium/WebKit.gypi +1 lines
Lines 93-98 a/Source/WebKit/chromium/WebKit.gypi_sec1
93
            'tests/RegionTest.cpp',
93
            'tests/RegionTest.cpp',
94
            'tests/RenderTableCellTest.cpp',
94
            'tests/RenderTableCellTest.cpp',
95
            'tests/RenderTableRowTest.cpp',
95
            'tests/RenderTableRowTest.cpp',
96
            'tests/ScrollingCoordinatorChromiumTest.cpp',
96
            'tests/TilingDataTest.cpp',
97
            'tests/TilingDataTest.cpp',
97
            'tests/TreeTestHelpers.cpp',
98
            'tests/TreeTestHelpers.cpp',
98
            'tests/TreeTestHelpers.h',
99
            'tests/TreeTestHelpers.h',
- a/Source/WebKit/chromium/tests/ScrollingCoordinatorChromiumTest.cpp +235 lines
Line 0 a/Source/WebKit/chromium/tests/ScrollingCoordinatorChromiumTest.cpp_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1.  Redistributions of source code must retain the above copyright
8
 *     notice, this list of conditions and the following disclaimer.
9
 * 2.  Redistributions in binary form must reproduce the above copyright
10
 *     notice, this list of conditions and the following disclaimer in the
11
 *     documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
 */
24
25
#include "config.h"
26
27
#include "ScrollingCoordinator.h"
28
29
#include "CompositorFakeWebGraphicsContext3D.h"
30
#include "FakeWebCompositorOutputSurface.h"
31
#include "FrameTestHelpers.h"
32
#include "RenderLayerCompositor.h"
33
#include "RenderView.h"
34
#include "URLTestHelpers.h"
35
#include "WebFrameClient.h"
36
#include "WebFrameImpl.h"
37
#include "WebSettings.h"
38
#include "WebViewClient.h"
39
#include "WebViewImpl.h"
40
#include <gtest/gtest.h>
41
#include <public/WebCompositorSupport.h>
42
#include <public/WebLayer.h>
43
#include <webkit/support/webkit_support.h>
44
45
#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
46
#include "GraphicsLayerChromium.h"
47
#endif
48
49
using namespace WebCore;
50
using namespace WebKit;
51
52
namespace {
53
54
class MockWebViewClient : public WebViewClient {
55
public:
56
    virtual WebCompositorOutputSurface* createOutputSurface() OVERRIDE
57
    {
58
        return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes())).leakPtr();
59
    }
60
};
61
62
class MockWebFrameClient : public WebFrameClient {
63
};
64
65
class ScrollingCoordinatorChromiumTest : public testing::Test {
66
public:
67
    ScrollingCoordinatorChromiumTest()
68
        : m_baseURL("http://www.test.com/")
69
        , m_webViewImpl(0) { }
70
71
    WebViewImpl* createCompositedWebViewImpl(const std::string& url)
72
    {
73
        ASSERT(!m_webViewImpl);
74
        WebKit::Platform::current()->compositorSupport()->initialize(0);
75
76
        // We cannot reuse FrameTestHelpers::createWebViewAndLoad here because the compositing
77
        // settings need to be set before the page is loaded.
78
        m_webViewImpl = static_cast<WebViewImpl*>(WebView::create(&m_mockWebViewClient));
79
        m_webViewImpl->settings()->setJavaScriptEnabled(true);
80
        m_webViewImpl->settings()->setForceCompositingMode(true);
81
        m_webViewImpl->settings()->setAcceleratedCompositingEnabled(true);
82
        m_webViewImpl->settings()->setAcceleratedCompositingForFixedPositionEnabled(true);
83
        m_webViewImpl->initializeMainFrame(&m_mockWebFrameClient);
84
        m_webViewImpl->resize(IntSize(320, 240));
85
86
        FrameTestHelpers::loadFrame(m_webViewImpl->mainFrame(), url);
87
        webkit_support::ServeAsynchronousMockedRequests();
88
89
        return m_webViewImpl;
90
    }
91
92
    virtual void TearDown() OVERRIDE
93
    {
94
        webkit_support::UnregisterAllMockedURLs();
95
        if (m_webViewImpl) {
96
            m_webViewImpl->close();
97
            m_webViewImpl = 0;
98
            WebKit::Platform::current()->compositorSupport()->shutdown();
99
        }
100
    }
101
102
    void registerMockedHttpURLLoad(const std::string& fileName)
103
    {
104
        URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(fileName.c_str()));
105
    }
106
107
    WebLayer* getRootScrollLayer(WebViewImpl* webViewImpl)
108
    {
109
        RenderLayerCompositor* compositor = webViewImpl->mainFrameImpl()->frame()->contentRenderer()->compositor();
110
        ASSERT(compositor);
111
        ASSERT(compositor->scrollLayer());
112
113
        WebLayer* webScrollLayer = static_cast<WebLayer*>(compositor->scrollLayer()->platformLayer());
114
        return webScrollLayer;
115
    }
116
117
protected:
118
    std::string m_baseURL;
119
    MockWebFrameClient m_mockWebFrameClient;
120
    MockWebViewClient m_mockWebViewClient;
121
    WebViewImpl* m_webViewImpl;
122
};
123
124
TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingByDefault)
125
{
126
    WebViewImpl* webViewImpl = createCompositedWebViewImpl("about:blank");
127
128
    // Make sure the scrolling coordinator is active.
129
    FrameView* frameView = webViewImpl->mainFrameImpl()->frameView();
130
    Page* page = webViewImpl->mainFrameImpl()->frame()->page();
131
    ASSERT_TRUE(page->scrollingCoordinator());
132
    ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView(frameView));
133
134
    // Fast scrolling should be enabled by default.
135
    WebLayer* rootScrollLayer = getRootScrollLayer(webViewImpl);
136
    ASSERT_TRUE(rootScrollLayer->scrollable());
137
    ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread());
138
    ASSERT_FALSE(rootScrollLayer->haveWheelEventHandlers());
139
}
140
141
TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingForFixedPosition)
142
{
143
    registerMockedHttpURLLoad("fixed_position.html");
144
    WebViewImpl* webViewImpl = createCompositedWebViewImpl(m_baseURL + "fixed_position.html");
145
146
    Page* page = webViewImpl->mainFrameImpl()->frame()->page();
147
    ASSERT_TRUE(page->scrollingCoordinator()->supportsFixedPositionLayers());
148
149
    // Fixed position should not fall back to main thread scrolling.
150
    WebLayer* rootScrollLayer = getRootScrollLayer(webViewImpl);
151
    ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread());
152
153
    // Verify the properties of the fixed position element starting from the RenderObject all the
154
    // way to the LayerChromium.
155
    Element* fixedElement = webViewImpl->mainFrameImpl()->frame()->document()->getElementById("fixed");
156
    ASSERT(fixedElement);
157
158
    RenderObject* renderer = fixedElement->renderer();
159
    ASSERT_TRUE(renderer->isBoxModelObject());
160
    ASSERT_TRUE(renderer->hasLayer());
161
162
    RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
163
    ASSERT_TRUE(layer->isComposited());
164
165
    RenderLayerBacking* layerBacking = layer->backing();
166
    WebLayer* webLayer = static_cast<WebLayer*>(layerBacking->graphicsLayer()->platformLayer());
167
    ASSERT_TRUE(webLayer->fixedToContainerLayer());
168
}
169
170
TEST_F(ScrollingCoordinatorChromiumTest, slowScrollingForNonCompositedFixedPosition)
171
{
172
    registerMockedHttpURLLoad("fixed_position_non_composited.html");
173
    WebViewImpl* webViewImpl = createCompositedWebViewImpl(m_baseURL + "fixed_position_non_composited.html");
174
175
    Page* page = webViewImpl->mainFrameImpl()->frame()->page();
176
    ASSERT_TRUE(page->scrollingCoordinator()->supportsFixedPositionLayers());
177
178
    // Non-composited fixed position should fall back to main thread scrolling.
179
    WebLayer* rootScrollLayer = getRootScrollLayer(webViewImpl);
180
    ASSERT_TRUE(rootScrollLayer->shouldScrollOnMainThread());
181
}
182
183
TEST_F(ScrollingCoordinatorChromiumTest, nonFastScrollableRegion)
184
{
185
    registerMockedHttpURLLoad("non_fast_scrollable.html");
186
    WebViewImpl* webViewImpl = createCompositedWebViewImpl(m_baseURL + "non_fast_scrollable.html");
187
188
    WebLayer* rootScrollLayer = getRootScrollLayer(webViewImpl);
189
    WebVector<WebRect> nonFastScrollableRegion = rootScrollLayer->nonFastScrollableRegion();
190
191
    ASSERT_EQ(1u, nonFastScrollableRegion.size());
192
    ASSERT_EQ(WebRect(8, 8, 10, 10), nonFastScrollableRegion[0]);
193
}
194
195
TEST_F(ScrollingCoordinatorChromiumTest, wheelEventHandler)
196
{
197
    registerMockedHttpURLLoad("wheel_event_handler.html");
198
    WebViewImpl* webViewImpl = createCompositedWebViewImpl(m_baseURL + "wheel_event_handler.html");
199
200
    WebLayer* rootScrollLayer = getRootScrollLayer(webViewImpl);
201
    ASSERT_TRUE(rootScrollLayer->haveWheelEventHandlers());
202
}
203
204
#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
205
TEST_F(ScrollingCoordinatorChromiumTest, touchOverflowScrolling)
206
{
207
    registerMockedHttpURLLoad("touch_overflow_scrolling.html");
208
    WebViewImpl* webViewImpl = createCompositedWebViewImpl(m_baseURL + "touch_overflow_scrolling.html");
209
210
    // Verify the properties of the accelerated scrolling element starting from the RenderObject
211
    // all the way to the LayerChromium.
212
    Element* scrollableElement = webViewImpl->mainFrameImpl()->frame()->document()->getElementById("scrollable");
213
    ASSERT(scrollableElement);
214
215
    RenderObject* renderer = scrollableElement->renderer();
216
    ASSERT_TRUE(renderer->isBoxModelObject());
217
    ASSERT_TRUE(renderer->hasLayer());
218
219
    RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
220
    ASSERT_TRUE(layer->usesCompositedScrolling());
221
    ASSERT_TRUE(layer->isComposited());
222
223
    RenderLayerBacking* layerBacking = layer->backing();
224
    ASSERT_TRUE(layerBacking->hasScrollingLayer());
225
    ASSERT(layerBacking->scrollingContentsLayer());
226
227
    GraphicsLayerChromium* layerChromium = static_cast<GraphicsLayerChromium*>(layerBacking->scrollingContentsLayer());
228
    ASSERT_EQ(layer, layerChromium->scrollableArea());
229
230
    WebLayer* webScrollLayer = static_cast<WebLayer*>(layerBacking->scrollingContentsLayer()->platformLayer());
231
    ASSERT_TRUE(webScrollLayer->scrollable());
232
}
233
#endif // ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
234
235
} // namespace
- a/Source/WebKit/chromium/tests/data/fixed_position.html +18 lines
Line 0 a/Source/WebKit/chromium/tests/data/fixed_position.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
  <style type="text/css">
5
    #fixed {
6
      position: fixed;
7
      /* Use a stacking context to enable composition. */
8
      z-index: 0;
9
    }
10
  </style>
11
</head>
12
13
<body>
14
  <div id="fixed">
15
    Fixed positioned.
16
  </div>
17
</body>
18
</html>
- a/Source/WebKit/chromium/tests/data/fixed_position_non_composited.html +16 lines
Line 0 a/Source/WebKit/chromium/tests/data/fixed_position_non_composited.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
  <style type="text/css">
5
    .fixed {
6
      position: fixed;
7
    }
8
  </style>
9
</head>
10
11
<body>
12
  <div class="fixed">
13
    Fixed positioned.
14
  </div>
15
</body>
16
</html>
- a/Source/WebKit/chromium/tests/data/non_fast_scrollable.html +18 lines
Line 0 a/Source/WebKit/chromium/tests/data/non_fast_scrollable.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
  <style type="text/css">
5
    .scrollable {
6
      width: 10px;
7
      height: 10px;
8
      overflow: scroll;
9
    }
10
  </style>
11
</head>
12
13
<body>
14
  <div class="scrollable">
15
    Scrolling content.
16
  </div>
17
</body>
18
</html>
- a/Source/WebKit/chromium/tests/data/touch_overflow_scrolling.html +23 lines
Line 0 a/Source/WebKit/chromium/tests/data/touch_overflow_scrolling.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
  <style type="text/css">
5
    #scrollable {
6
      width: 10px;
7
      height: 10px;
8
      overflow: scroll;
9
      -webkit-overflow-scrolling: touch;
10
    }
11
    .content {
12
      width: 100px;
13
      height: 1000px;
14
    }
15
  </style>
16
</head>
17
18
<body>
19
  <div id="scrollable">
20
    <div class="content"></div>
21
  </div>
22
</body>
23
</html>
- a/Source/WebKit/chromium/tests/data/wheel_event_handler.html +10 lines
Line 0 a/Source/WebKit/chromium/tests/data/wheel_event_handler.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
  <script type="text/javascript">
5
      window.addEventListener('mousewheel', function(event) {
6
      });
7
  </script>
8
</head>
9
10
</html>

Return to Bug 96657