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

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: add some explanation 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
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..edb20dfe82fc816dfc601e54cc3b665792496c5f 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1583,6 +1583,51 @@ 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
enne (OOO) 2013/03/23 00:25:51 80 col. ;)
+// 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();
+
+ // 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(
+ std::max(height * 0.875f, height - 40.f),
+ 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()) {
+ active_tree()->DidUpdateScroll();
+ client_->SetNeedsCommitOnImplThread();
+ client_->SetNeedsRedrawOnImplThread();
+ client_->RenewTreePriority();
+ return true;
+ }
+
+ active_tree_->SetCurrentlyScrollingLayer(layer_impl);
+ }
+
+ return false;
+}
+
void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() {
active_tree_->ClearCurrentlyScrollingLayer();
did_lock_scrolling_layer_ = false;

Powered by Google App Engine
This is Rietveld 408576698