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

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: 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 unified diff | Download patch | Annotate | Revision Log
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
enne (OOO) 2013/03/23 00:25:51 80 col. ;)
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();
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(
1608 std::max(height * 0.875f, height - 40.f),
1609 1.f);
1610 if (direction == WebKit::WebScrollbar::ScrollBackward)
1611 page = -page;
1612
1613 gfx::Vector2dF delta = gfx::Vector2dF(0.f, page);
1614
1615 gfx::Vector2dF applied_delta = ScrollLayerWithLocalDelta(layer_impl, delta);
1616
1617 if (!applied_delta.IsZero()) {
1618 active_tree()->DidUpdateScroll();
1619 client_->SetNeedsCommitOnImplThread();
1620 client_->SetNeedsRedrawOnImplThread();
1621 client_->RenewTreePriority();
1622 return true;
1623 }
1624
1625 active_tree_->SetCurrentlyScrollingLayer(layer_impl);
1626 }
1627
1628 return false;
1629 }
1630
1586 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { 1631 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() {
1587 active_tree_->ClearCurrentlyScrollingLayer(); 1632 active_tree_->ClearCurrentlyScrollingLayer();
1588 did_lock_scrolling_layer_ = false; 1633 did_lock_scrolling_layer_ = false;
1589 } 1634 }
1590 1635
1591 void LayerTreeHostImpl::ScrollEnd() { 1636 void LayerTreeHostImpl::ScrollEnd() {
1592 if (top_controls_manager_) 1637 if (top_controls_manager_)
1593 top_controls_manager_->ScrollEnd(); 1638 top_controls_manager_->ScrollEnd();
1594 ClearCurrentlyScrollingLayer(); 1639 ClearCurrentlyScrollingLayer();
1595 active_tree()->DidEndScroll(); 1640 active_tree()->DidEndScroll();
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 debug_state_ = debug_state; 2010 debug_state_ = debug_state;
1966 } 2011 }
1967 2012
1968 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, 2013 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time,
1969 int commit_number) { 2014 int commit_number) {
1970 DCHECK(debug_state_.continuous_painting); 2015 DCHECK(debug_state_.continuous_painting);
1971 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); 2016 paint_time_counter_->SavePaintTime(total_paint_time, commit_number);
1972 } 2017 }
1973 2018
1974 } // namespace cc 2019 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698