Index: android_webview/browser/browser_view_renderer.cc |
diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc |
index ea9d60312836a4a3c45dc9dd20850bf05028defd..9730bbd3a151b3680664ec815a6997636905d30c 100644 |
--- a/android_webview/browser/browser_view_renderer.cc |
+++ b/android_webview/browser/browser_view_renderer.cc |
@@ -422,6 +422,12 @@ void BrowserViewRenderer::OnDetachedFromWindow() { |
DCHECK(!hardware_enabled_); |
} |
+void BrowserViewRenderer::OnComputeScroll(base::TimeTicks animation_time) { |
+ if (pending_fling_animation_.is_null()) |
+ return; |
+ FlushPendingFlingAnimation(animation_time); |
+} |
+ |
void BrowserViewRenderer::ReleaseHardware() { |
DCHECK(hardware_enabled_); |
ReturnUnusedResource(shared_renderer_state_.PassUncommittedFrameOnUI()); |
@@ -626,6 +632,13 @@ BrowserViewRenderer::RootLayerStateAsValue( |
return state; |
} |
+void BrowserViewRenderer::SetNeedsAnimateFling( |
+ const AnimationCallback& fling_animation) { |
+ // TODO(jdduke): Skip invalidate if animation already pending? |
+ pending_fling_animation_ = fling_animation; |
+ client_->PostInvalidate(); |
+} |
+ |
void BrowserViewRenderer::DidOverscroll(gfx::Vector2dF accumulated_overscroll, |
gfx::Vector2dF latest_overscroll_delta, |
gfx::Vector2dF current_fling_velocity) { |
@@ -638,7 +651,21 @@ void BrowserViewRenderer::DidOverscroll(gfx::Vector2dF accumulated_overscroll, |
scaled_overscroll_delta + overscroll_rounding_error_); |
overscroll_rounding_error_ = |
scaled_overscroll_delta - rounded_overscroll_delta; |
- client_->DidOverscroll(rounded_overscroll_delta); |
+ |
+ gfx::Vector2dF fling_velocity_pixels = gfx::ScaleVector2d( |
+ current_fling_velocity, physical_pixel_scale); |
+ |
+ const bool first_overscroll_x = |
+ accumulated_overscroll.x() && |
+ accumulated_overscroll.x() == latest_overscroll_delta.x(); |
+ const bool first_overscroll_y = |
+ accumulated_overscroll.y() && |
+ accumulated_overscroll.y() == latest_overscroll_delta.y(); |
+ |
+ client_->DidOverscroll(rounded_overscroll_delta, |
+ fling_velocity_pixels, |
+ first_overscroll_x, |
+ first_overscroll_y); |
} |
void BrowserViewRenderer::EnsureContinuousInvalidation( |
@@ -742,6 +769,16 @@ void BrowserViewRenderer::ForceFakeCompositeSW() { |
CompositeSW(&canvas); |
} |
+void BrowserViewRenderer::FlushPendingFlingAnimation( |
+ base::TimeTicks animation_time) { |
+ TRACE_EVENT0("android_webview", |
+ "BrowserViewRenderer::FlushPendingFlingAnimation"); |
+ DCHECK(!pending_fling_animation_.is_null()); |
+ AnimationCallback animation = pending_fling_animation_; |
+ pending_fling_animation_.Reset(); |
+ animation.Run(animation_time); |
+} |
+ |
bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { |
DCHECK(compositor_); |
ReturnResourceFromParent(); |