diff options
author | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-20 04:11:57 +0000 |
---|---|---|
committer | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-20 04:11:57 +0000 |
commit | c77745df642b8143389f15119c90af5dda3b4167 (patch) | |
tree | bf8b2f24347ef1946a8358361af6830be9094990 /cc | |
parent | a5432c74c14428c0a73293e38ad1d4de93382117 (diff) | |
download | chromium_src-c77745df642b8143389f15119c90af5dda3b4167.zip chromium_src-c77745df642b8143389f15119c90af5dda3b4167.tar.gz chromium_src-c77745df642b8143389f15119c90af5dda3b4167.tar.bz2 |
Fixes for nonmodal pinch zoom.
In Android 4.2, pinch gestures send both pinch events (for the
zoom-in/out part of the pinch) and scroll events (for double-finger
panning). The previous logic in LayerTreeHostImpl created a pan from
the pinch event, resulting in 2x overpanning on Android 4.2.
In order to have compatible gesture generation in older Android versions as
well, I copy-pasted the latest Android GestureDetector.java file into the
Chromium tree and use that instead of the system file.
BUG=161909
Review URL: https://chromiumcodereview.appspot.com/11299083
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168721 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layer_tree_host_impl.cc | 5 | ||||
-rw-r--r-- | cc/layer_tree_host_impl_unittest.cc | 23 |
2 files changed, 23 insertions, 5 deletions
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index 8c2df3c..8ea79c2 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -1241,13 +1241,10 @@ void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta, gfx::Point anchor if (!m_rootScrollLayerImpl) return; - if (m_previousPinchAnchor == gfx::Point()) - m_previousPinchAnchor = anchor; - // Keep the center-of-pinch anchor specified by (x, y) in a stable // position over the course of the magnify. float pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); - gfx::PointF previousScaleAnchor = gfx::ScalePoint(m_previousPinchAnchor, 1 / pageScaleDelta); + gfx::PointF previousScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta); setPageScaleDelta(pageScaleDelta * magnifyDelta); pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); gfx::PointF newScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta); diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc index 278f467..f772155 100644 --- a/cc/layer_tree_host_impl_unittest.cc +++ b/cc/layer_tree_host_impl_unittest.cc @@ -646,7 +646,7 @@ TEST_P(LayerTreeHostImplTest, pinchGesture) } } - // Two-finger panning + // Two-finger panning should not happen based on pinch events only { m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); scrollLayer->setImplTransform(identityScaleTransform); @@ -661,6 +661,27 @@ TEST_P(LayerTreeHostImplTest, pinchGesture) scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); + EXPECT_TRUE(scrollInfo->scrolls.empty()); + } + + // Two-finger panning should work with interleaved scroll events + { + m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); + scrollLayer->setImplTransform(identityScaleTransform); + scrollLayer->setScrollDelta(gfx::Vector2d()); + scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); + + float pageScaleDelta = 1; + m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel); + m_hostImpl->pinchGestureBegin(); + m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); + m_hostImpl->scrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); + m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); + m_hostImpl->pinchGestureEnd(); + m_hostImpl->scrollEnd(); + + scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); + EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10)); } } |