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