OLD | NEW |
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 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2003 // If any layer wants to divert the scroll event to the main thread, abort. | 2003 // If any layer wants to divert the scroll event to the main thread, abort. |
2004 if (status == ScrollOnMainThread) { | 2004 if (status == ScrollOnMainThread) { |
2005 *scroll_on_main_thread = true; | 2005 *scroll_on_main_thread = true; |
2006 return NULL; | 2006 return NULL; |
2007 } | 2007 } |
2008 | 2008 |
2009 if (status == ScrollStarted && !potentially_scrolling_layer_impl) | 2009 if (status == ScrollStarted && !potentially_scrolling_layer_impl) |
2010 potentially_scrolling_layer_impl = scroll_layer_impl; | 2010 potentially_scrolling_layer_impl = scroll_layer_impl; |
2011 } | 2011 } |
2012 | 2012 |
2013 // When hiding top controls is enabled and the controls are hidden or | |
2014 // overlaying the content, force scrolls to be enabled on the root layer to | |
2015 // allow bringing the top controls back into view. | |
2016 if (!potentially_scrolling_layer_impl && top_controls_manager_ && | |
2017 top_controls_manager_->content_top_offset() != | |
2018 settings_.top_controls_height) { | |
2019 potentially_scrolling_layer_impl = RootScrollLayer(); | |
2020 } | |
2021 | |
2022 return potentially_scrolling_layer_impl; | 2013 return potentially_scrolling_layer_impl; |
2023 } | 2014 } |
2024 | 2015 |
2025 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( | 2016 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( |
2026 gfx::Point viewport_point, InputHandler::ScrollInputType type) { | 2017 gfx::Point viewport_point, InputHandler::ScrollInputType type) { |
2027 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); | 2018 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); |
2028 | 2019 |
2029 if (top_controls_manager_) | 2020 if (top_controls_manager_) |
2030 top_controls_manager_->ScrollBegin(); | 2021 top_controls_manager_->ScrollBegin(); |
2031 | 2022 |
(...skipping 11 matching lines...) Expand all Loading... |
2043 bool scroll_on_main_thread = false; | 2034 bool scroll_on_main_thread = false; |
2044 LayerImpl* potentially_scrolling_layer_impl = | 2035 LayerImpl* potentially_scrolling_layer_impl = |
2045 FindScrollLayerForDeviceViewportPoint(device_viewport_point, type, | 2036 FindScrollLayerForDeviceViewportPoint(device_viewport_point, type, |
2046 layer_impl, &scroll_on_main_thread); | 2037 layer_impl, &scroll_on_main_thread); |
2047 | 2038 |
2048 if (scroll_on_main_thread) { | 2039 if (scroll_on_main_thread) { |
2049 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 2040 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
2050 return ScrollOnMainThread; | 2041 return ScrollOnMainThread; |
2051 } | 2042 } |
2052 | 2043 |
2053 // If we want to send a DidOverscroll for this scroll it can't be ignored. | 2044 if (!potentially_scrolling_layer_impl) |
2054 if (!potentially_scrolling_layer_impl && settings_.always_overscroll) | |
2055 potentially_scrolling_layer_impl = RootScrollLayer(); | 2045 potentially_scrolling_layer_impl = RootScrollLayer(); |
2056 | 2046 |
2057 if (potentially_scrolling_layer_impl) { | 2047 if (potentially_scrolling_layer_impl) { |
2058 active_tree_->SetCurrentlyScrollingLayer( | 2048 active_tree_->SetCurrentlyScrollingLayer( |
2059 potentially_scrolling_layer_impl); | 2049 potentially_scrolling_layer_impl); |
2060 should_bubble_scrolls_ = (type != NonBubblingGesture); | 2050 should_bubble_scrolls_ = (type != NonBubblingGesture); |
2061 wheel_scrolling_ = (type == Wheel); | 2051 wheel_scrolling_ = (type == Wheel); |
2062 client_->RenewTreePriority(); | 2052 client_->RenewTreePriority(); |
2063 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); | 2053 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); |
2064 return ScrollStarted; | 2054 return ScrollStarted; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2153 gfx::Vector2dF scroll_delta) { | 2143 gfx::Vector2dF scroll_delta) { |
2154 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); | 2144 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); |
2155 if (!CurrentlyScrollingLayer()) | 2145 if (!CurrentlyScrollingLayer()) |
2156 return false; | 2146 return false; |
2157 | 2147 |
2158 gfx::Vector2dF pending_delta = scroll_delta; | 2148 gfx::Vector2dF pending_delta = scroll_delta; |
2159 gfx::Vector2dF unused_root_delta; | 2149 gfx::Vector2dF unused_root_delta; |
2160 bool did_scroll_x = false; | 2150 bool did_scroll_x = false; |
2161 bool did_scroll_y = false; | 2151 bool did_scroll_y = false; |
2162 bool consume_by_top_controls = top_controls_manager_ && | 2152 bool consume_by_top_controls = top_controls_manager_ && |
2163 (CurrentlyScrollingLayer() == RootScrollLayer() || scroll_delta.y() < 0); | 2153 (scroll_delta.y() < 0 || |
| 2154 (RootScrollLayer() && CurrentlyScrollingLayer() == RootScrollLayer() && |
| 2155 RootScrollLayer()->max_scroll_offset().y() > 0)); |
2164 | 2156 |
2165 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); | 2157 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); |
2166 layer_impl; | 2158 layer_impl; |
2167 layer_impl = layer_impl->parent()) { | 2159 layer_impl = layer_impl->parent()) { |
2168 if (!layer_impl->scrollable()) | 2160 if (!layer_impl->scrollable()) |
2169 continue; | 2161 continue; |
2170 | 2162 |
2171 if (layer_impl == RootScrollLayer()) { | 2163 if (layer_impl == RootScrollLayer()) { |
2172 // Only allow bubble scrolling when the scroll is in the direction to make | 2164 // Only allow bubble scrolling when the scroll is in the direction to make |
2173 // the top controls visible. | 2165 // the top controls visible. |
2174 if (consume_by_top_controls && layer_impl == RootScrollLayer()) { | 2166 if (consume_by_top_controls) { |
2175 pending_delta = top_controls_manager_->ScrollBy(pending_delta); | 2167 pending_delta = top_controls_manager_->ScrollBy(pending_delta); |
2176 UpdateMaxScrollOffset(); | 2168 UpdateMaxScrollOffset(); |
2177 } | 2169 } |
2178 // Track root layer deltas for reporting overscroll. | 2170 // Track root layer deltas for reporting overscroll. |
2179 unused_root_delta = pending_delta; | 2171 unused_root_delta = pending_delta; |
2180 } | 2172 } |
2181 | 2173 |
2182 gfx::Vector2dF applied_delta; | 2174 gfx::Vector2dF applied_delta; |
2183 // Gesture events need to be transformed from viewport coordinates to local | 2175 // Gesture events need to be transformed from viewport coordinates to local |
2184 // layer coordinates so that the scrolling contents exactly follow the | 2176 // layer coordinates so that the scrolling contents exactly follow the |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2915 swap_promise_monitor_.erase(monitor); | 2907 swap_promise_monitor_.erase(monitor); |
2916 } | 2908 } |
2917 | 2909 |
2918 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 2910 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
2919 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 2911 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
2920 for (; it != swap_promise_monitor_.end(); it++) | 2912 for (; it != swap_promise_monitor_.end(); it++) |
2921 (*it)->OnSetNeedsRedrawOnImpl(); | 2913 (*it)->OnSetNeedsRedrawOnImpl(); |
2922 } | 2914 } |
2923 | 2915 |
2924 } // namespace cc | 2916 } // namespace cc |
OLD | NEW |