| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 gfx::PointF device_viewport_point = | 462 gfx::PointF device_viewport_point = |
| 463 gfx::ScalePoint(viewport_point, device_scale_factor_); | 463 gfx::ScalePoint(viewport_point, device_scale_factor_); |
| 464 | 464 |
| 465 LayerImpl* layer_impl = | 465 LayerImpl* layer_impl = |
| 466 active_tree_->FindLayerWithWheelHandlerThatIsHitByPoint( | 466 active_tree_->FindLayerWithWheelHandlerThatIsHitByPoint( |
| 467 device_viewport_point); | 467 device_viewport_point); |
| 468 | 468 |
| 469 return layer_impl != NULL; | 469 return layer_impl != NULL; |
| 470 } | 470 } |
| 471 | 471 |
| 472 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( | 472 static LayerImpl* NextScrollLayer(LayerImpl* layer) { |
| 473 if (LayerImpl* scroll_parent = layer->scroll_parent()) |
| 474 return scroll_parent; |
| 475 return layer->parent(); |
| 476 } |
| 477 |
| 478 static ScrollBlocksOn EffectiveScrollBlocksOn(LayerImpl* layer) { |
| 479 ScrollBlocksOn blocks = ScrollBlocksOnNone; |
| 480 for (; layer; layer = NextScrollLayer(layer)) { |
| 481 blocks |= layer->scroll_blocks_on(); |
| 482 } |
| 483 return blocks; |
| 484 } |
| 485 |
| 486 bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( |
| 473 const gfx::Point& viewport_point) { | 487 const gfx::Point& viewport_point) { |
| 474 | |
| 475 gfx::PointF device_viewport_point = | 488 gfx::PointF device_viewport_point = |
| 476 gfx::ScalePoint(viewport_point, device_scale_factor_); | 489 gfx::ScalePoint(viewport_point, device_scale_factor_); |
| 477 | 490 |
| 491 // First check if scrolling at this point is required to block on any |
| 492 // touch event handlers. Note that we must start at the innermost layer |
| 493 // (as opposed to only the layer found to contain a touch handler region |
| 494 // below) to ensure all relevant scroll-blocks-on values are applied. |
| 478 LayerImpl* layer_impl = | 495 LayerImpl* layer_impl = |
| 479 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( | 496 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 480 device_viewport_point); | 497 ScrollBlocksOn blocking = EffectiveScrollBlocksOn(layer_impl); |
| 498 if (!(blocking & ScrollBlocksOnStartTouch)) |
| 499 return false; |
| 481 | 500 |
| 501 // Now determine if there are actually any handlers at that point. |
| 502 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). |
| 503 layer_impl = active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 504 device_viewport_point); |
| 482 return layer_impl != NULL; | 505 return layer_impl != NULL; |
| 483 } | 506 } |
| 484 | 507 |
| 485 scoped_ptr<SwapPromiseMonitor> | 508 scoped_ptr<SwapPromiseMonitor> |
| 486 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( | 509 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
| 487 ui::LatencyInfo* latency) { | 510 ui::LatencyInfo* latency) { |
| 488 return make_scoped_ptr( | 511 return make_scoped_ptr( |
| 489 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); | 512 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); |
| 490 } | 513 } |
| 491 | 514 |
| (...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 float LayerTreeHostImpl::ControlsTopOffset() const { | 2271 float LayerTreeHostImpl::ControlsTopOffset() const { |
| 2249 return active_tree_->total_top_controls_content_offset() - | 2272 return active_tree_->total_top_controls_content_offset() - |
| 2250 active_tree_->top_controls_height(); | 2273 active_tree_->top_controls_height(); |
| 2251 } | 2274 } |
| 2252 | 2275 |
| 2253 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { | 2276 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
| 2254 DCHECK(input_handler_client_ == NULL); | 2277 DCHECK(input_handler_client_ == NULL); |
| 2255 input_handler_client_ = client; | 2278 input_handler_client_ = client; |
| 2256 } | 2279 } |
| 2257 | 2280 |
| 2258 static LayerImpl* NextScrollLayer(LayerImpl* layer) { | |
| 2259 if (LayerImpl* scroll_parent = layer->scroll_parent()) | |
| 2260 return scroll_parent; | |
| 2261 return layer->parent(); | |
| 2262 } | |
| 2263 | |
| 2264 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( | 2281 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( |
| 2265 const gfx::PointF& device_viewport_point, | 2282 const gfx::PointF& device_viewport_point, |
| 2266 InputHandler::ScrollInputType type, | 2283 InputHandler::ScrollInputType type, |
| 2267 LayerImpl* layer_impl, | 2284 LayerImpl* layer_impl, |
| 2268 bool* scroll_on_main_thread, | 2285 bool* scroll_on_main_thread, |
| 2269 bool* optional_has_ancestor_scroll_handler) const { | 2286 bool* optional_has_ancestor_scroll_handler) const { |
| 2270 DCHECK(scroll_on_main_thread); | 2287 DCHECK(scroll_on_main_thread); |
| 2271 | 2288 |
| 2289 ScrollBlocksOn block_mode = EffectiveScrollBlocksOn(layer_impl); |
| 2290 |
| 2272 // Walk up the hierarchy and look for a scrollable layer. | 2291 // Walk up the hierarchy and look for a scrollable layer. |
| 2273 LayerImpl* potentially_scrolling_layer_impl = NULL; | 2292 LayerImpl* potentially_scrolling_layer_impl = NULL; |
| 2274 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { | 2293 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { |
| 2275 // The content layer can also block attempts to scroll outside the main | 2294 // The content layer can also block attempts to scroll outside the main |
| 2276 // thread. | 2295 // thread. |
| 2277 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); | 2296 ScrollStatus status = |
| 2297 layer_impl->TryScroll(device_viewport_point, type, block_mode); |
| 2278 if (status == ScrollOnMainThread) { | 2298 if (status == ScrollOnMainThread) { |
| 2279 *scroll_on_main_thread = true; | 2299 *scroll_on_main_thread = true; |
| 2280 return NULL; | 2300 return NULL; |
| 2281 } | 2301 } |
| 2282 | 2302 |
| 2283 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); | 2303 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); |
| 2284 if (!scroll_layer_impl) | 2304 if (!scroll_layer_impl) |
| 2285 continue; | 2305 continue; |
| 2286 | 2306 |
| 2287 status = scroll_layer_impl->TryScroll(device_viewport_point, type); | 2307 status = |
| 2308 scroll_layer_impl->TryScroll(device_viewport_point, type, block_mode); |
| 2288 // If any layer wants to divert the scroll event to the main thread, abort. | 2309 // If any layer wants to divert the scroll event to the main thread, abort. |
| 2289 if (status == ScrollOnMainThread) { | 2310 if (status == ScrollOnMainThread) { |
| 2290 *scroll_on_main_thread = true; | 2311 *scroll_on_main_thread = true; |
| 2291 return NULL; | 2312 return NULL; |
| 2292 } | 2313 } |
| 2293 | 2314 |
| 2294 if (optional_has_ancestor_scroll_handler && | 2315 if (optional_has_ancestor_scroll_handler && |
| 2295 scroll_layer_impl->have_scroll_event_handlers()) | 2316 scroll_layer_impl->have_scroll_event_handlers()) |
| 2296 *optional_has_ancestor_scroll_handler = true; | 2317 *optional_has_ancestor_scroll_handler = true; |
| 2297 | 2318 |
| (...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3459 } | 3480 } |
| 3460 | 3481 |
| 3461 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3482 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3462 std::vector<PictureLayerImpl*>::iterator it = | 3483 std::vector<PictureLayerImpl*>::iterator it = |
| 3463 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3484 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3464 DCHECK(it != picture_layers_.end()); | 3485 DCHECK(it != picture_layers_.end()); |
| 3465 picture_layers_.erase(it); | 3486 picture_layers_.erase(it); |
| 3466 } | 3487 } |
| 3467 | 3488 |
| 3468 } // namespace cc | 3489 } // namespace cc |
| OLD | NEW |