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 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2133 scroll_layer_impl->have_scroll_event_handlers()) | 2133 scroll_layer_impl->have_scroll_event_handlers()) |
2134 *has_ancestor_scroll_handler = true; | 2134 *has_ancestor_scroll_handler = true; |
2135 | 2135 |
2136 if (status == ScrollStarted && !potentially_scrolling_layer_impl) | 2136 if (status == ScrollStarted && !potentially_scrolling_layer_impl) |
2137 potentially_scrolling_layer_impl = scroll_layer_impl; | 2137 potentially_scrolling_layer_impl = scroll_layer_impl; |
2138 } | 2138 } |
2139 | 2139 |
2140 return potentially_scrolling_layer_impl; | 2140 return potentially_scrolling_layer_impl; |
2141 } | 2141 } |
2142 | 2142 |
2143 // Similar to LayerImpl::HasAncestor, but takes into account scroll parents. | |
2144 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { | |
2145 if (!scroll_ancestor) | |
2146 return false; | |
2147 | |
2148 LayerImpl* ancestor = child; | |
enne (OOO)
2014/04/15 21:25:54
style nit: don't put this out of scope just to avo
| |
2149 for (; ancestor; ancestor = NextScrollLayer(ancestor)) { | |
2150 if (ancestor == scroll_ancestor) | |
2151 return true; | |
2152 } | |
2153 | |
2154 return false; | |
2155 } | |
2156 | |
2143 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( | 2157 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( |
2144 const gfx::Point& viewport_point, | 2158 const gfx::Point& viewport_point, |
2145 InputHandler::ScrollInputType type) { | 2159 InputHandler::ScrollInputType type) { |
2146 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); | 2160 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); |
2147 | 2161 |
2148 if (top_controls_manager_) | 2162 if (top_controls_manager_) |
2149 top_controls_manager_->ScrollBegin(); | 2163 top_controls_manager_->ScrollBegin(); |
2150 | 2164 |
2151 DCHECK(!CurrentlyScrollingLayer()); | 2165 DCHECK(!CurrentlyScrollingLayer()); |
2152 ClearCurrentlyScrollingLayer(); | 2166 ClearCurrentlyScrollingLayer(); |
2153 | 2167 |
2154 if (!EnsureRenderSurfaceLayerList()) | 2168 if (!EnsureRenderSurfaceLayerList()) |
2155 return ScrollIgnored; | 2169 return ScrollIgnored; |
2156 | 2170 |
2157 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, | 2171 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, |
2158 device_scale_factor_); | 2172 device_scale_factor_); |
2159 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 2173 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
2160 device_viewport_point, | 2174 device_viewport_point, |
2161 active_tree_->RenderSurfaceLayerList()); | 2175 active_tree_->RenderSurfaceLayerList()); |
2176 | |
2177 if (layer_impl) { | |
2178 LayerImpl* scroll_layer_impl = | |
2179 LayerTreeHostCommon::FindFirstScrollingLayerThatIsHitByPoint( | |
2180 device_viewport_point, active_tree_->RenderSurfaceLayerList()); | |
2181 if (!HasScrollAncestor(layer_impl, scroll_layer_impl)) | |
2182 return ScrollOnMainThread; | |
2183 } | |
2184 | |
2162 bool scroll_on_main_thread = false; | 2185 bool scroll_on_main_thread = false; |
2163 LayerImpl* potentially_scrolling_layer_impl = | 2186 LayerImpl* potentially_scrolling_layer_impl = |
2164 FindScrollLayerForDeviceViewportPoint(device_viewport_point, | 2187 FindScrollLayerForDeviceViewportPoint(device_viewport_point, |
2165 type, | 2188 type, |
2166 layer_impl, | 2189 layer_impl, |
2167 &scroll_on_main_thread, | 2190 &scroll_on_main_thread, |
2168 &scroll_affects_scroll_handler_); | 2191 &scroll_affects_scroll_handler_); |
2169 | 2192 |
2170 if (scroll_on_main_thread) { | 2193 if (scroll_on_main_thread) { |
2171 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 2194 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3101 swap_promise_monitor_.erase(monitor); | 3124 swap_promise_monitor_.erase(monitor); |
3102 } | 3125 } |
3103 | 3126 |
3104 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3127 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3105 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3128 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3106 for (; it != swap_promise_monitor_.end(); it++) | 3129 for (; it != swap_promise_monitor_.end(); it++) |
3107 (*it)->OnSetNeedsRedrawOnImpl(); | 3130 (*it)->OnSetNeedsRedrawOnImpl(); |
3108 } | 3131 } |
3109 | 3132 |
3110 } // namespace cc | 3133 } // namespace cc |
OLD | NEW |