summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android_webview/browser/in_process_view_renderer.cc18
-rw-r--r--android_webview/browser/in_process_view_renderer.h9
-rw-r--r--cc/input/input_handler.h9
-rw-r--r--cc/trees/layer_tree_host_impl.cc7
-rw-r--r--cc/trees/layer_tree_host_unittest_scroll.cc3
-rw-r--r--content/browser/android/in_process/synchronous_compositor_impl.cc7
-rw-r--r--content/browser/android/in_process/synchronous_compositor_impl.h4
-rw-r--r--content/browser/android/in_process/synchronous_input_event_filter.cc6
-rw-r--r--content/browser/android/in_process/synchronous_input_event_filter.h3
-rw-r--r--content/public/browser/android/synchronous_compositor_client.h2
-rw-r--r--content/renderer/gpu/input_event_filter.cc8
-rw-r--r--content/renderer/gpu/input_event_filter.h3
-rw-r--r--content/renderer/gpu/input_handler_manager.cc7
-rw-r--r--content/renderer/gpu/input_handler_manager.h5
-rw-r--r--content/renderer/gpu/input_handler_manager_client.h4
-rw-r--r--content/renderer/gpu/input_handler_proxy.cc11
-rw-r--r--content/renderer/gpu/input_handler_proxy.h3
-rw-r--r--content/renderer/gpu/input_handler_proxy_client.h3
-rw-r--r--content/renderer/gpu/input_handler_proxy_unittest.cc10
-rw-r--r--content/renderer/gpu/input_handler_wrapper.cc7
-rw-r--r--content/renderer/gpu/input_handler_wrapper.h3
21 files changed, 64 insertions, 68 deletions
diff --git a/android_webview/browser/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc
index 09a0e02..ee4c201 100644
--- a/android_webview/browser/in_process_view_renderer.cc
+++ b/android_webview/browser/in_process_view_renderer.cc
@@ -537,8 +537,6 @@ void InProcessViewRenderer::ScrollTo(gfx::Vector2d new_value) {
void InProcessViewRenderer::SetTotalRootLayerScrollOffset(
gfx::Vector2dF new_value_css) {
- previous_accumulated_overscroll_ = gfx::Vector2dF();
-
// TOOD(mkosiba): Add a DCHECK to say that this does _not_ get called during
// DrawGl when http://crbug.com/249972 is fixed.
if (scroll_offset_css_ == new_value_css)
@@ -560,17 +558,19 @@ gfx::Vector2dF InProcessViewRenderer::GetTotalRootLayerScrollOffset() {
}
void InProcessViewRenderer::DidOverscroll(
- gfx::Vector2dF accumulated_overscroll,
+ gfx::Vector2dF latest_overscroll_delta,
gfx::Vector2dF current_fling_velocity) {
// TODO(mkosiba): Enable this once flinging is handled entirely Java-side.
// DCHECK(current_fling_velocity.IsZero());
const float physical_pixel_scale = dip_scale_ * page_scale_factor_;
- gfx::Vector2d overscroll_delta = gfx::ToRoundedVector2d(gfx::ScaleVector2d(
- accumulated_overscroll - previous_accumulated_overscroll_,
- physical_pixel_scale));
- previous_accumulated_overscroll_ +=
- gfx::ScaleVector2d(overscroll_delta, 1.0f / physical_pixel_scale);
- client_->DidOverscroll(overscroll_delta);
+ gfx::Vector2dF scaled_overscroll_delta = gfx::ScaleVector2d(
+ latest_overscroll_delta + overscroll_rounding_error_,
+ physical_pixel_scale);
+ gfx::Vector2d rounded_overscroll_delta =
+ gfx::ToRoundedVector2d(scaled_overscroll_delta);
+ overscroll_rounding_error_ =
+ scaled_overscroll_delta - rounded_overscroll_delta;
+ client_->DidOverscroll(rounded_overscroll_delta);
}
void InProcessViewRenderer::EnsureContinuousInvalidation(
diff --git a/android_webview/browser/in_process_view_renderer.h b/android_webview/browser/in_process_view_renderer.h
index 3ec2830..07c03dd 100644
--- a/android_webview/browser/in_process_view_renderer.h
+++ b/android_webview/browser/in_process_view_renderer.h
@@ -63,7 +63,7 @@ class InProcessViewRenderer : public BrowserViewRenderer,
virtual void SetTotalRootLayerScrollOffset(
gfx::Vector2dF new_value_css) OVERRIDE;
virtual gfx::Vector2dF GetTotalRootLayerScrollOffset() OVERRIDE;
- virtual void DidOverscroll(gfx::Vector2dF accumulated_overscroll,
+ virtual void DidOverscroll(gfx::Vector2dF latest_overscroll_delta,
gfx::Vector2dF current_fling_velocity) OVERRIDE;
void WebContentsGone();
@@ -114,9 +114,10 @@ class InProcessViewRenderer : public BrowserViewRenderer,
// Current scroll offset in CSS pixels.
gfx::Vector2dF scroll_offset_css_;
- // Used to convert accumulated-based overscroll updates into delta-based
- // updates.
- gfx::Vector2dF previous_accumulated_overscroll_;
+ // Used to prevent rounding errors from accumulating enough to generate
+ // visible skew (especially noticeable when scrolling up and down in the same
+ // spot over a period of time).
+ gfx::Vector2dF overscroll_rounding_error_;
DISALLOW_COPY_AND_ASSIGN(InProcessViewRenderer);
};
diff --git a/cc/input/input_handler.h b/cc/input/input_handler.h
index f8bb6f3..db26561 100644
--- a/cc/input/input_handler.h
+++ b/cc/input/input_handler.h
@@ -23,6 +23,12 @@ namespace cc {
class LayerScrollOffsetDelegate;
+struct DidOverscrollParams {
+ gfx::Vector2dF accumulated_overscroll;
+ gfx::Vector2dF latest_overscroll_delta;
+ gfx::Vector2dF current_fling_velocity;
+};
+
class CC_EXPORT InputHandlerClient {
public:
virtual ~InputHandlerClient() {}
@@ -34,8 +40,7 @@ class CC_EXPORT InputHandlerClient {
// Called when scroll deltas reaching the root scrolling layer go unused.
// The accumulated overscroll is scoped by the most recent call to
// InputHandler::ScrollBegin.
- virtual void DidOverscroll(gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) = 0;
+ virtual void DidOverscroll(const DidOverscrollParams& params) = 0;
protected:
InputHandlerClient() {}
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index ab34fbf..f88cf8a 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1974,8 +1974,11 @@ bool LayerTreeHostImpl::ScrollBy(gfx::Point viewport_point,
accumulated_root_overscroll_ += unused_root_delta;
bool did_overscroll = !gfx::ToRoundedVector2d(unused_root_delta).IsZero();
if (did_overscroll && input_handler_client_) {
- input_handler_client_->DidOverscroll(accumulated_root_overscroll_,
- current_fling_velocity_);
+ DidOverscrollParams params;
+ params.accumulated_overscroll = accumulated_root_overscroll_;
+ params.latest_overscroll_delta = unused_root_delta;
+ params.current_fling_velocity = current_fling_velocity_;
+ input_handler_client_->DidOverscroll(params);
}
return did_scroll;
diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
index c4140af..e531194 100644
--- a/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -716,8 +716,7 @@ class ThreadCheckingInputHandlerClient : public InputHandlerClient {
*received_stop_flinging_ = true;
}
- virtual void DidOverscroll(gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) OVERRIDE {
+ virtual void DidOverscroll(const DidOverscrollParams& params) OVERRIDE {
if (!task_runner_->BelongsToCurrentThread())
ADD_FAILURE() << "DidOverscroll called on wrong thread";
}
diff --git a/content/browser/android/in_process/synchronous_compositor_impl.cc b/content/browser/android/in_process/synchronous_compositor_impl.cc
index 97b785ad..f3c1b63 100644
--- a/content/browser/android/in_process/synchronous_compositor_impl.cc
+++ b/content/browser/android/in_process/synchronous_compositor_impl.cc
@@ -214,11 +214,10 @@ void SynchronousCompositorImpl::SetInputHandler(
}
void SynchronousCompositorImpl::DidOverscroll(
- gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) {
+ const cc::DidOverscrollParams& params) {
if (compositor_client_) {
- compositor_client_->DidOverscroll(accumulated_overscroll,
- current_fling_velocity);
+ compositor_client_->DidOverscroll(params.latest_overscroll_delta,
+ params.current_fling_velocity);
}
}
diff --git a/content/browser/android/in_process/synchronous_compositor_impl.h b/content/browser/android/in_process/synchronous_compositor_impl.h
index 1e2c66e..cd34617 100644
--- a/content/browser/android/in_process/synchronous_compositor_impl.h
+++ b/content/browser/android/in_process/synchronous_compositor_impl.h
@@ -16,6 +16,7 @@
namespace cc {
class InputHandler;
+struct DidOverscrollParams;
}
namespace WebKit {
@@ -70,8 +71,7 @@ class SynchronousCompositorImpl
virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE;
void SetInputHandler(cc::InputHandler* input_handler);
- void DidOverscroll(gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity);
+ void DidOverscroll(const cc::DidOverscrollParams& params);
private:
explicit SynchronousCompositorImpl(WebContents* contents);
diff --git a/content/browser/android/in_process/synchronous_input_event_filter.cc b/content/browser/android/in_process/synchronous_input_event_filter.cc
index 81483b2..17c909d 100644
--- a/content/browser/android/in_process/synchronous_input_event_filter.cc
+++ b/content/browser/android/in_process/synchronous_input_event_filter.cc
@@ -5,6 +5,7 @@
#include "content/browser/android/in_process/synchronous_input_event_filter.h"
#include "base/callback.h"
+#include "cc/input/input_handler.h"
#include "content/browser/android/in_process/synchronous_compositor_impl.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/latency_info.h"
@@ -66,14 +67,13 @@ void SynchronousInputEventFilter::DidRemoveInputHandler(int routing_id) {
void SynchronousInputEventFilter::DidOverscroll(
int routing_id,
- gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) {
+ const cc::DidOverscrollParams& params) {
// The SynchronusCompositorImpl can be NULL if the WebContents that it's
// bound to has already been deleted.
SynchronousCompositorImpl* compositor =
SynchronousCompositorImpl::FromRoutingID(routing_id);
if (compositor)
- compositor->DidOverscroll(accumulated_overscroll, current_fling_velocity);
+ compositor->DidOverscroll(params);
}
} // namespace content
diff --git a/content/browser/android/in_process/synchronous_input_event_filter.h b/content/browser/android/in_process/synchronous_input_event_filter.h
index 73a912d..18601c2 100644
--- a/content/browser/android/in_process/synchronous_input_event_filter.h
+++ b/content/browser/android/in_process/synchronous_input_event_filter.h
@@ -37,8 +37,7 @@ class SynchronousInputEventFilter : public InputHandlerManagerClient {
cc::InputHandler* input_handler) OVERRIDE;
virtual void DidRemoveInputHandler(int routing_id) OVERRIDE;
virtual void DidOverscroll(int routing_id,
- gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) OVERRIDE;
+ const cc::DidOverscrollParams& params) OVERRIDE;
private:
void SetBoundHandlerOnUIThread(const Handler& handler);
diff --git a/content/public/browser/android/synchronous_compositor_client.h b/content/public/browser/android/synchronous_compositor_client.h
index cf42ffb..fea09cc 100644
--- a/content/public/browser/android/synchronous_compositor_client.h
+++ b/content/public/browser/android/synchronous_compositor_client.h
@@ -27,7 +27,7 @@ class SynchronousCompositorClient {
// See LayerScrollOffsetDelegate for details.
virtual void SetTotalRootLayerScrollOffset(gfx::Vector2dF new_value) = 0;
virtual gfx::Vector2dF GetTotalRootLayerScrollOffset() = 0;
- virtual void DidOverscroll(gfx::Vector2dF accumulated_overscroll,
+ virtual void DidOverscroll(gfx::Vector2dF latest_overscroll_delta,
gfx::Vector2dF current_fling_velocity) = 0;
// When true, should periodically call
diff --git a/content/renderer/gpu/input_event_filter.cc b/content/renderer/gpu/input_event_filter.cc
index 0db5814..f9b9015 100644
--- a/content/renderer/gpu/input_event_filter.cc
+++ b/content/renderer/gpu/input_event_filter.cc
@@ -7,6 +7,7 @@
#include "base/debug/trace_event.h"
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "cc/input/input_handler.h"
#include "content/common/input_messages.h"
#include "content/common/view_messages.h"
#include "content/public/common/content_switches.h"
@@ -48,8 +49,7 @@ void InputEventFilter::DidRemoveInputHandler(int routing_id) {
}
void InputEventFilter::DidOverscroll(int routing_id,
- gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) {
+ const cc::DidOverscrollParams& params) {
DCHECK(target_loop_->BelongsToCurrentThread());
if (!overscroll_notifications_enabled_)
@@ -59,8 +59,8 @@ void InputEventFilter::DidOverscroll(int routing_id,
FROM_HERE,
base::Bind(&InputEventFilter::SendMessageOnIOThread, this,
ViewHostMsg_DidOverscroll(routing_id,
- accumulated_overscroll,
- current_fling_velocity)));
+ params.accumulated_overscroll,
+ params.current_fling_velocity)));
}
void InputEventFilter::OnFilterAdded(IPC::Channel* channel) {
diff --git a/content/renderer/gpu/input_event_filter.h b/content/renderer/gpu/input_event_filter.h
index 1f44e09..4a5d410 100644
--- a/content/renderer/gpu/input_event_filter.h
+++ b/content/renderer/gpu/input_event_filter.h
@@ -48,8 +48,7 @@ class CONTENT_EXPORT InputEventFilter
cc::InputHandler* input_handler) OVERRIDE;
virtual void DidRemoveInputHandler(int routing_id) OVERRIDE;
virtual void DidOverscroll(int routing_id,
- gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) OVERRIDE;
+ const cc::DidOverscrollParams& params) OVERRIDE;
// IPC::ChannelProxy::MessageFilter methods:
virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
diff --git a/content/renderer/gpu/input_handler_manager.cc b/content/renderer/gpu/input_handler_manager.cc
index 2fb6360..1db011b 100644
--- a/content/renderer/gpu/input_handler_manager.cc
+++ b/content/renderer/gpu/input_handler_manager.cc
@@ -122,11 +122,8 @@ InputEventAckState InputHandlerManager::HandleInputEvent(
}
void InputHandlerManager::DidOverscroll(int routing_id,
- gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) {
- client_->DidOverscroll(routing_id,
- accumulated_overscroll,
- current_fling_velocity);
+ const cc::DidOverscrollParams& params) {
+ client_->DidOverscroll(routing_id, params);
}
diff --git a/content/renderer/gpu/input_handler_manager.h b/content/renderer/gpu/input_handler_manager.h
index cc41473..3811d63 100644
--- a/content/renderer/gpu/input_handler_manager.h
+++ b/content/renderer/gpu/input_handler_manager.h
@@ -18,6 +18,7 @@ class MessageLoopProxy;
namespace cc {
class InputHandler;
+struct DidOverscrollParams;
}
namespace WebKit {
@@ -55,9 +56,7 @@ class InputHandlerManager {
const ui::LatencyInfo& latency_info);
// Called from the compositor's thread.
- void DidOverscroll(int routing_id,
- gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity);
+ void DidOverscroll(int routing_id, const cc::DidOverscrollParams& params);
private:
// Called from the compositor's thread.
diff --git a/content/renderer/gpu/input_handler_manager_client.h b/content/renderer/gpu/input_handler_manager_client.h
index 418e779..c147a8a6 100644
--- a/content/renderer/gpu/input_handler_manager_client.h
+++ b/content/renderer/gpu/input_handler_manager_client.h
@@ -17,6 +17,7 @@ struct LatencyInfo;
namespace cc {
class InputHandler;
+struct DidOverscrollParams;
}
namespace WebKit {
@@ -45,8 +46,7 @@ class CONTENT_EXPORT InputHandlerManagerClient {
cc::InputHandler* input_handler) = 0;
virtual void DidRemoveInputHandler(int routing_id) = 0;
virtual void DidOverscroll(int routing_id,
- gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) = 0;
+ const cc::DidOverscrollParams& params) = 0;
protected:
InputHandlerManagerClient() {}
diff --git a/content/renderer/gpu/input_handler_proxy.cc b/content/renderer/gpu/input_handler_proxy.cc
index a24cfbe..74cc6d1 100644
--- a/content/renderer/gpu/input_handler_proxy.cc
+++ b/content/renderer/gpu/input_handler_proxy.cc
@@ -322,18 +322,19 @@ void InputHandlerProxy::MainThreadHasStoppedFlinging() {
fling_may_be_active_on_main_thread_ = false;
}
-void InputHandlerProxy::DidOverscroll(gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) {
+void InputHandlerProxy::DidOverscroll(const cc::DidOverscrollParams& params) {
DCHECK(client_);
if (fling_curve_) {
static const int kFlingOverscrollThreshold = 1;
fling_overscrolled_horizontally_ |=
- std::abs(accumulated_overscroll.x()) >= kFlingOverscrollThreshold;
+ std::abs(params.accumulated_overscroll.x()) >=
+ kFlingOverscrollThreshold;
fling_overscrolled_vertically_ |=
- std::abs(accumulated_overscroll.y()) >= kFlingOverscrollThreshold;
+ std::abs(params.accumulated_overscroll.y()) >=
+ kFlingOverscrollThreshold;
}
- client_->DidOverscroll(accumulated_overscroll, current_fling_velocity);
+ client_->DidOverscroll(params);
}
bool InputHandlerProxy::CancelCurrentFling() {
diff --git a/content/renderer/gpu/input_handler_proxy.h b/content/renderer/gpu/input_handler_proxy.h
index 5a73cf5..e307827 100644
--- a/content/renderer/gpu/input_handler_proxy.h
+++ b/content/renderer/gpu/input_handler_proxy.h
@@ -46,8 +46,7 @@ class CONTENT_EXPORT InputHandlerProxy
virtual void WillShutdown() OVERRIDE;
virtual void Animate(base::TimeTicks time) OVERRIDE;
virtual void MainThreadHasStoppedFlinging() OVERRIDE;
- virtual void DidOverscroll(gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) OVERRIDE;
+ virtual void DidOverscroll(const cc::DidOverscrollParams& params) OVERRIDE;
// WebKit::WebGestureCurveTarget implementation.
virtual void scrollBy(const WebKit::WebFloatSize& offset);
diff --git a/content/renderer/gpu/input_handler_proxy_client.h b/content/renderer/gpu/input_handler_proxy_client.h
index beebb179..6ef000c 100644
--- a/content/renderer/gpu/input_handler_proxy_client.h
+++ b/content/renderer/gpu/input_handler_proxy_client.h
@@ -32,8 +32,7 @@ class InputHandlerProxyClient {
const WebKit::WebFloatPoint& velocity,
const WebKit::WebSize& cumulative_scroll) = 0;
- virtual void DidOverscroll(gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) = 0;
+ virtual void DidOverscroll(const cc::DidOverscrollParams& params) = 0;
protected:
virtual ~InputHandlerProxyClient() {}
diff --git a/content/renderer/gpu/input_handler_proxy_unittest.cc b/content/renderer/gpu/input_handler_proxy_unittest.cc
index 9485949..ca3e2cf 100644
--- a/content/renderer/gpu/input_handler_proxy_unittest.cc
+++ b/content/renderer/gpu/input_handler_proxy_unittest.cc
@@ -125,8 +125,7 @@ class MockInputHandlerProxyClient
return new FakeWebGestureCurve(velocity, cumulative_scroll);
}
- virtual void DidOverscroll(gfx::Vector2dF overscroll,
- gfx::Vector2dF fling_velocity) {}
+ virtual void DidOverscroll(const cc::DidOverscrollParams& params) {}
private:
DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient);
@@ -991,9 +990,10 @@ TEST_F(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
// Simulate hitting the bottom content edge.
- gfx::Vector2dF overscroll_amount(0, 100);
- gfx::Vector2dF overscroll_velocity(0, 10);
- input_handler_->DidOverscroll(overscroll_amount, overscroll_velocity);
+ cc::DidOverscrollParams overscroll_params;
+ overscroll_params.accumulated_overscroll = gfx::Vector2dF(0, 100);
+ overscroll_params.current_fling_velocity = gfx::Vector2dF(0, 10);
+ input_handler_->DidOverscroll(overscroll_params);
// The next call to animate will no longer scroll vertically.
EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
diff --git a/content/renderer/gpu/input_handler_wrapper.cc b/content/renderer/gpu/input_handler_wrapper.cc
index dbdfddd..348ff6d 100644
--- a/content/renderer/gpu/input_handler_wrapper.cc
+++ b/content/renderer/gpu/input_handler_wrapper.cc
@@ -50,11 +50,8 @@ WebKit::WebGestureCurve* InputHandlerWrapper::CreateFlingAnimationCurve(
deviceSource, velocity, cumulative_scroll);
}
-void InputHandlerWrapper::DidOverscroll(gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) {
- input_handler_manager_->DidOverscroll(routing_id_,
- accumulated_overscroll,
- current_fling_velocity);
+void InputHandlerWrapper::DidOverscroll(const cc::DidOverscrollParams& params) {
+ input_handler_manager_->DidOverscroll(routing_id_, params);
}
} // namespace content
diff --git a/content/renderer/gpu/input_handler_wrapper.h b/content/renderer/gpu/input_handler_wrapper.h
index 35edd0a..f72bae5 100644
--- a/content/renderer/gpu/input_handler_wrapper.h
+++ b/content/renderer/gpu/input_handler_wrapper.h
@@ -35,8 +35,7 @@ class InputHandlerWrapper
int deviceSource,
const WebKit::WebFloatPoint& velocity,
const WebKit::WebSize& cumulativeScroll) OVERRIDE;
- virtual void DidOverscroll(gfx::Vector2dF accumulated_overscroll,
- gfx::Vector2dF current_fling_velocity) OVERRIDE;
+ virtual void DidOverscroll(const cc::DidOverscrollParams& params) OVERRIDE;
private:
friend class base::RefCountedThreadSafe<InputHandlerWrapper>;