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 DCHECK(scroll_ancestor); |
| 2146 for (LayerImpl* ancestor = child; ancestor; |
| 2147 ancestor = NextScrollLayer(ancestor)) { |
| 2148 if (ancestor->scrollable()) |
| 2149 return ancestor == scroll_ancestor; |
| 2150 } |
| 2151 return false; |
| 2152 } |
| 2153 |
2143 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( | 2154 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( |
2144 const gfx::Point& viewport_point, | 2155 const gfx::Point& viewport_point, |
2145 InputHandler::ScrollInputType type) { | 2156 InputHandler::ScrollInputType type) { |
2146 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); | 2157 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); |
2147 | 2158 |
2148 if (top_controls_manager_) | 2159 if (top_controls_manager_) |
2149 top_controls_manager_->ScrollBegin(); | 2160 top_controls_manager_->ScrollBegin(); |
2150 | 2161 |
2151 DCHECK(!CurrentlyScrollingLayer()); | 2162 DCHECK(!CurrentlyScrollingLayer()); |
2152 ClearCurrentlyScrollingLayer(); | 2163 ClearCurrentlyScrollingLayer(); |
2153 | 2164 |
2154 if (!EnsureRenderSurfaceLayerList()) | 2165 if (!EnsureRenderSurfaceLayerList()) |
2155 return ScrollIgnored; | 2166 return ScrollIgnored; |
2156 | 2167 |
2157 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, | 2168 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, |
2158 device_scale_factor_); | 2169 device_scale_factor_); |
2159 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 2170 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
2160 device_viewport_point, | 2171 device_viewport_point, |
2161 active_tree_->RenderSurfaceLayerList()); | 2172 active_tree_->RenderSurfaceLayerList()); |
| 2173 |
| 2174 if (layer_impl) { |
| 2175 LayerImpl* scroll_layer_impl = |
| 2176 LayerTreeHostCommon::FindFirstScrollingLayerThatIsHitByPoint( |
| 2177 device_viewport_point, active_tree_->RenderSurfaceLayerList()); |
| 2178 if (scroll_layer_impl && !HasScrollAncestor(layer_impl, scroll_layer_impl)) |
| 2179 return ScrollUnknown; |
| 2180 } |
| 2181 |
2162 bool scroll_on_main_thread = false; | 2182 bool scroll_on_main_thread = false; |
2163 LayerImpl* potentially_scrolling_layer_impl = | 2183 LayerImpl* potentially_scrolling_layer_impl = |
2164 FindScrollLayerForDeviceViewportPoint(device_viewport_point, | 2184 FindScrollLayerForDeviceViewportPoint(device_viewport_point, |
2165 type, | 2185 type, |
2166 layer_impl, | 2186 layer_impl, |
2167 &scroll_on_main_thread, | 2187 &scroll_on_main_thread, |
2168 &scroll_affects_scroll_handler_); | 2188 &scroll_affects_scroll_handler_); |
2169 | 2189 |
2170 if (scroll_on_main_thread) { | 2190 if (scroll_on_main_thread) { |
2171 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 2191 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); | 3121 swap_promise_monitor_.erase(monitor); |
3102 } | 3122 } |
3103 | 3123 |
3104 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3124 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3105 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3125 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3106 for (; it != swap_promise_monitor_.end(); it++) | 3126 for (; it != swap_promise_monitor_.end(); it++) |
3107 (*it)->OnSetNeedsRedrawOnImpl(); | 3127 (*it)->OnSetNeedsRedrawOnImpl(); |
3108 } | 3128 } |
3109 | 3129 |
3110 } // namespace cc | 3130 } // namespace cc |
OLD | NEW |