diff options
author | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 21:01:50 +0000 |
---|---|---|
committer | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 21:01:50 +0000 |
commit | 77766665f61aea3baaad0a070e2c3849b6a20449 (patch) | |
tree | 8aca7f4ce702873f8c170e49c5e01fcc05a3adf6 /cc | |
parent | 894e694065ad44881ac07141bb1d0636c046d687 (diff) | |
download | chromium_src-77766665f61aea3baaad0a070e2c3849b6a20449.zip chromium_src-77766665f61aea3baaad0a070e2c3849b6a20449.tar.gz chromium_src-77766665f61aea3baaad0a070e2c3849b6a20449.tar.bz2 |
Make scrollbars scroll on main thread.
BUG=139396
TEST=ScrollbarLayerTest.shouldScrollNonOverlayOnMainThread
Review URL: https://chromiumcodereview.appspot.com/11358151
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174235 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/scrollbar_layer.cc | 2 | ||||
-rw-r--r-- | cc/scrollbar_layer_unittest.cc | 59 | ||||
-rw-r--r-- | cc/test/fake_web_scrollbar.cc | 9 | ||||
-rw-r--r-- | cc/test/fake_web_scrollbar.h | 7 |
4 files changed, 61 insertions, 16 deletions
diff --git a/cc/scrollbar_layer.cc b/cc/scrollbar_layer.cc index c4e61ac..f35b865 100644 --- a/cc/scrollbar_layer.cc +++ b/cc/scrollbar_layer.cc @@ -40,6 +40,8 @@ ScrollbarLayer::ScrollbarLayer( , m_scrollLayerId(scrollLayerId) , m_textureFormat(GL_INVALID_ENUM) { + if (!m_scrollbar->isOverlay()) + setShouldScrollOnMainThread(true); } ScrollbarLayer::~ScrollbarLayer() diff --git a/cc/scrollbar_layer_unittest.cc b/cc/scrollbar_layer_unittest.cc index 3446681..1c3bcfb 100644 --- a/cc/scrollbar_layer_unittest.cc +++ b/cc/scrollbar_layer_unittest.cc @@ -22,6 +22,19 @@ namespace cc { namespace { +scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar( + FakeLayerTreeHostImpl* host_impl, + scoped_ptr<WebKit::WebScrollbar> scrollbar, + bool reverse_order) +{ + scoped_refptr<Layer> layerTreeRoot = Layer::create(); + scoped_refptr<Layer> child1 = Layer::create(); + scoped_refptr<Layer> child2 = ScrollbarLayer::create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(), child1->id()); + layerTreeRoot->addChild(child1); + layerTreeRoot->insertChild(child2, reverse_order ? 0 : 1); + return TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), host_impl->activeTree()).Pass(); +} + TEST(ScrollbarLayerTest, resolveScrollLayerPointer) { FakeImplProxy proxy; @@ -29,13 +42,7 @@ TEST(ScrollbarLayerTest, resolveScrollLayerPointer) { scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); - scoped_refptr<Layer> layerTreeRoot = Layer::create(); - scoped_refptr<Layer> child1 = Layer::create(); - scoped_refptr<Layer> child2 = ScrollbarLayer::create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(), child1->id()); - layerTreeRoot->addChild(child1); - layerTreeRoot->addChild(child2); - - scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); + scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrollbar(&hostImpl, scrollbar.Pass(), false); LayerImpl* ccChild1 = layerImplTreeRoot->children()[0]; ScrollbarLayerImpl* ccChild2 = static_cast<ScrollbarLayerImpl*>(layerImplTreeRoot->children()[1]); @@ -46,13 +53,7 @@ TEST(ScrollbarLayerTest, resolveScrollLayerPointer) { // another traverse order scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); - scoped_refptr<Layer> layerTreeRoot = Layer::create(); - scoped_refptr<Layer> child2 = Layer::create(); - scoped_refptr<Layer> child1 = ScrollbarLayer::create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(), child2->id()); - layerTreeRoot->addChild(child1); - layerTreeRoot->addChild(child2); - - scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); + scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrollbar(&hostImpl, scrollbar.Pass(), true); ScrollbarLayerImpl* ccChild1 = static_cast<ScrollbarLayerImpl*>(layerImplTreeRoot->children()[0]); LayerImpl* ccChild2 = layerImplTreeRoot->children()[1]; @@ -62,6 +63,34 @@ TEST(ScrollbarLayerTest, resolveScrollLayerPointer) } } +TEST(ScrollbarLayerTest, shouldScrollNonOverlayOnMainThread) +{ + FakeImplProxy proxy; + FakeLayerTreeHostImpl hostImpl(&proxy); + + // Create and attach a non-overlay scrollbar. + scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); + static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(false); + scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrollbar(&hostImpl, scrollbar.Pass(), false); + ScrollbarLayerImpl* scrollbarLayerImpl = static_cast<ScrollbarLayerImpl*>(layerImplTreeRoot->children()[1]); + + // When the scrollbar is not an overlay scrollbar, the scroll should be + // responded to on the main thread as the compositor does not yet implement + // scrollbar scrolling. + EXPECT_EQ(InputHandlerClient::ScrollOnMainThread, scrollbarLayerImpl->tryScroll(gfx::Point(0, 0), InputHandlerClient::Gesture)); + + // Create and attach an overlay scrollbar. + scrollbar = FakeWebScrollbar::create(); + static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(true); + + layerImplTreeRoot = layerImplForScrollAreaAndScrollbar(&hostImpl, scrollbar.Pass(), false); + scrollbarLayerImpl = static_cast<ScrollbarLayerImpl*>(layerImplTreeRoot->children()[1]); + + // The user shouldn't be able to drag an overlay scrollbar and the scroll + // may be handled in the compositor. + EXPECT_EQ(InputHandlerClient::ScrollIgnored, scrollbarLayerImpl->tryScroll(gfx::Point(0, 0), InputHandlerClient::Gesture)); +} + TEST(ScrollbarLayerTest, scrollOffsetSynchronization) { FakeImplProxy proxy; @@ -132,7 +161,7 @@ public: virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { - const int kMaxTextureSize = m_layerTreeHost->rendererCapabilities().maxTextureSize; + const int kMaxTextureSize = impl->rendererCapabilities().maxTextureSize; // Check first that we're actually testing something. EXPECT_GT(m_scrollbarLayer->bounds().width(), kMaxTextureSize); diff --git a/cc/test/fake_web_scrollbar.cc b/cc/test/fake_web_scrollbar.cc index eafda67..3b770a2 100644 --- a/cc/test/fake_web_scrollbar.cc +++ b/cc/test/fake_web_scrollbar.cc @@ -6,8 +6,12 @@ namespace cc { +void FakeWebScrollbar::setOverlay(bool isOverlay) { + m_isOverlay = isOverlay; +} + bool FakeWebScrollbar::isOverlay() const { - return false; + return m_isOverlay; } int FakeWebScrollbar::value() const { @@ -66,4 +70,7 @@ WebKit::WebScrollbar::Orientation FakeWebScrollbar::orientation() const { return WebScrollbar::Horizontal; } +FakeWebScrollbar::FakeWebScrollbar() : m_isOverlay(false) { +} + } // namespace cc diff --git a/cc/test/fake_web_scrollbar.h b/cc/test/fake_web_scrollbar.h index 4d8504a..89313d6 100644 --- a/cc/test/fake_web_scrollbar.h +++ b/cc/test/fake_web_scrollbar.h @@ -16,6 +16,8 @@ class FakeWebScrollbar : public WebKit::WebScrollbar { return make_scoped_ptr(new FakeWebScrollbar()); } + void setOverlay(bool isOverlay); + // WebScrollbar implementation virtual bool isOverlay() const OVERRIDE; virtual int value() const OVERRIDE; @@ -33,6 +35,11 @@ class FakeWebScrollbar : public WebKit::WebScrollbar { virtual ScrollbarOverlayStyle scrollbarOverlayStyle() const OVERRIDE; virtual bool isCustomScrollbar() const OVERRIDE; virtual Orientation orientation() const OVERRIDE; + + private: + FakeWebScrollbar(); + + bool m_isOverlay; }; } // namespace cc |