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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 1576
1577 active_tree()->DidUpdateScroll(); 1577 active_tree()->DidUpdateScroll();
1578 if (did_scroll) { 1578 if (did_scroll) {
1579 client_->SetNeedsCommitOnImplThread(); 1579 client_->SetNeedsCommitOnImplThread();
1580 client_->SetNeedsRedrawOnImplThread(); 1580 client_->SetNeedsRedrawOnImplThread();
1581 client_->RenewTreePriority(); 1581 client_->RenewTreePriority();
1582 } 1582 }
1583 return did_scroll; 1583 return did_scroll;
1584 } 1584 }
1585 1585
1586 // This implements scrolling by page as described here:
1587 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp x#_win32_The_Mouse_Wheel
1588 // for events with WHEEL_PAGESCROLL set.
1589 bool LayerTreeHostImpl::ScrollVerticallyByPage(
1590 gfx::Point viewport_point,
1591 WebKit::WebScrollbar::ScrollDirection direction) {
1592 DCHECK(wheel_scrolling_);
1593
1594 for (LayerImpl* layer_impl = CurrentlyScrollingLayer();
1595 layer_impl;
1596 layer_impl = layer_impl->parent()) {
1597 if (!layer_impl->scrollable())
1598 continue;
1599
1600 if (!layer_impl->vertical_scrollbar_layer())
1601 continue;
1602
1603 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
1604
1605 // These magical values match WebKit and are designed to scroll nearly the
1606 // entire visible content height but leave a bit of overlap.
1607 float page = std::max(height * 0.875f, 1.f);
1608 if (direction == WebKit::WebScrollbar::ScrollBackward)
1609 page = -page;
1610
1611 gfx::Vector2dF delta = gfx::Vector2dF(0.f, page);
1612
1613 gfx::Vector2dF applied_delta = ScrollLayerWithLocalDelta(layer_impl, delta);
1614
1615 if (!applied_delta.IsZero()) {
Vangelis Kokkevis 2013/03/23 01:49:14 scrollBy checks against a small threshold ( move_t
1616 active_tree()->DidUpdateScroll();
1617 client_->SetNeedsCommitOnImplThread();
1618 client_->SetNeedsRedrawOnImplThread();
1619 client_->RenewTreePriority();
1620 return true;
1621 }
1622
Vangelis Kokkevis 2013/03/23 01:49:14 Do we care about bubbling up the remainder of the
1623 active_tree_->SetCurrentlyScrollingLayer(layer_impl);
1624 }
1625
1626 return false;
1627 }
1628
1586 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { 1629 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() {
1587 active_tree_->ClearCurrentlyScrollingLayer(); 1630 active_tree_->ClearCurrentlyScrollingLayer();
1588 did_lock_scrolling_layer_ = false; 1631 did_lock_scrolling_layer_ = false;
1589 } 1632 }
1590 1633
1591 void LayerTreeHostImpl::ScrollEnd() { 1634 void LayerTreeHostImpl::ScrollEnd() {
1592 if (top_controls_manager_) 1635 if (top_controls_manager_)
1593 top_controls_manager_->ScrollEnd(); 1636 top_controls_manager_->ScrollEnd();
1594 ClearCurrentlyScrollingLayer(); 1637 ClearCurrentlyScrollingLayer();
1595 active_tree()->DidEndScroll(); 1638 active_tree()->DidEndScroll();
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 debug_state_ = debug_state; 2008 debug_state_ = debug_state;
1966 } 2009 }
1967 2010
1968 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, 2011 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time,
1969 int commit_number) { 2012 int commit_number) {
1970 DCHECK(debug_state_.continuous_painting); 2013 DCHECK(debug_state_.continuous_painting);
1971 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); 2014 paint_time_counter_->SavePaintTime(total_paint_time, commit_number);
1972 } 2015 }
1973 2016
1974 } // namespace cc 2017 } // namespace cc
OLDNEW
« 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