Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(653)

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 12582009: Implement windows mousewheel scroll by page functionality (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix scroll distance calculation to more closely match windows behavior Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index ee98af38e5ca78eac7265068d239d0a1d957927b..41696b8ab401fe28f380daeb28ba3757379503dd 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1583,6 +1583,49 @@ bool LayerTreeHostImpl::ScrollBy(gfx::Point viewport_point,
return did_scroll;
}
+// This implements scrolling by page as described here:
+// http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).aspx#_win32_The_Mouse_Wheel
+// for events with WHEEL_PAGESCROLL set.
+bool LayerTreeHostImpl::ScrollVerticallyByPage(
+ gfx::Point viewport_point,
+ WebKit::WebScrollbar::ScrollDirection direction) {
+ DCHECK(wheel_scrolling_);
+
+ for (LayerImpl* layer_impl = CurrentlyScrollingLayer();
+ layer_impl;
+ layer_impl = layer_impl->parent()) {
+ if (!layer_impl->scrollable())
+ continue;
+
+ if (!layer_impl->vertical_scrollbar_layer())
+ continue;
+
+ float height = layer_impl->vertical_scrollbar_layer()->bounds().height();
Vangelis Kokkevis 2013/03/23 01:49:14 If you're scrolling an overflow-scroll element, do
+
+ // These magical values match WebKit and are designed to scroll nearly the
+ // entire visible content height but leave a bit of overlap.
+ float page = std::max(height * 0.875f, 1.f);
+ if (direction == WebKit::WebScrollbar::ScrollBackward)
+ page = -page;
+
+ gfx::Vector2dF delta = gfx::Vector2dF(0.f, page);
+
+ gfx::Vector2dF applied_delta = ScrollLayerWithLocalDelta(layer_impl, delta);
+
+ if (!applied_delta.IsZero()) {
Vangelis Kokkevis 2013/03/23 01:49:14 scrollBy checks against a small threshold ( move_t
+ active_tree()->DidUpdateScroll();
+ client_->SetNeedsCommitOnImplThread();
+ client_->SetNeedsRedrawOnImplThread();
+ client_->RenewTreePriority();
+ return true;
+ }
+
Vangelis Kokkevis 2013/03/23 01:49:14 Do we care about bubbling up the remainder of the
+ active_tree_->SetCurrentlyScrollingLayer(layer_impl);
+ }
+
+ return false;
+}
+
void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() {
active_tree_->ClearCurrentlyScrollingLayer();
did_lock_scrolling_layer_ = false;
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698