| 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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 InputHandler::ScrollInputType type) { | 484 InputHandler::ScrollInputType type) { |
| 485 if (!CurrentlyScrollingLayer()) | 485 if (!CurrentlyScrollingLayer()) |
| 486 return false; | 486 return false; |
| 487 | 487 |
| 488 if (!EnsureRenderSurfaceLayerList()) | 488 if (!EnsureRenderSurfaceLayerList()) |
| 489 return false; | 489 return false; |
| 490 | 490 |
| 491 gfx::PointF device_viewport_point = | 491 gfx::PointF device_viewport_point = |
| 492 gfx::ScalePoint(viewport_point, device_scale_factor_); | 492 gfx::ScalePoint(viewport_point, device_scale_factor_); |
| 493 | 493 |
| 494 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 494 LayerImpl* layer_impl = |
| 495 device_viewport_point, active_tree_->RenderSurfaceLayerList()); | 495 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 496 | 496 |
| 497 bool scroll_on_main_thread = false; | 497 bool scroll_on_main_thread = false; |
| 498 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( | 498 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( |
| 499 device_viewport_point, type, layer_impl, &scroll_on_main_thread, NULL); | 499 device_viewport_point, type, layer_impl, &scroll_on_main_thread, NULL); |
| 500 return CurrentlyScrollingLayer() == scrolling_layer_impl; | 500 return CurrentlyScrollingLayer() == scrolling_layer_impl; |
| 501 } | 501 } |
| 502 | 502 |
| 503 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( | 503 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( |
| 504 const gfx::Point& viewport_point) { | 504 const gfx::Point& viewport_point) { |
| 505 if (!settings_.touch_hit_testing) | 505 if (!settings_.touch_hit_testing) |
| 506 return true; | 506 return true; |
| 507 if (!EnsureRenderSurfaceLayerList()) | 507 if (!EnsureRenderSurfaceLayerList()) |
| 508 return false; | 508 return false; |
| 509 | 509 |
| 510 gfx::PointF device_viewport_point = | 510 gfx::PointF device_viewport_point = |
| 511 gfx::ScalePoint(viewport_point, device_scale_factor_); | 511 gfx::ScalePoint(viewport_point, device_scale_factor_); |
| 512 | 512 |
| 513 LayerImpl* layer_impl = | 513 LayerImpl* layer_impl = |
| 514 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 514 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 515 device_viewport_point, | 515 device_viewport_point); |
| 516 active_tree_->RenderSurfaceLayerList()); | 516 |
| 517 return layer_impl != NULL; | 517 return layer_impl != NULL; |
| 518 } | 518 } |
| 519 | 519 |
| 520 scoped_ptr<SwapPromiseMonitor> | 520 scoped_ptr<SwapPromiseMonitor> |
| 521 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( | 521 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
| 522 ui::LatencyInfo* latency) { | 522 ui::LatencyInfo* latency) { |
| 523 return scoped_ptr<SwapPromiseMonitor>( | 523 return scoped_ptr<SwapPromiseMonitor>( |
| 524 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); | 524 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); |
| 525 } | 525 } |
| 526 | 526 |
| (...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2213 top_controls_manager_->ScrollBegin(); | 2213 top_controls_manager_->ScrollBegin(); |
| 2214 | 2214 |
| 2215 DCHECK(!CurrentlyScrollingLayer()); | 2215 DCHECK(!CurrentlyScrollingLayer()); |
| 2216 ClearCurrentlyScrollingLayer(); | 2216 ClearCurrentlyScrollingLayer(); |
| 2217 | 2217 |
| 2218 if (!EnsureRenderSurfaceLayerList()) | 2218 if (!EnsureRenderSurfaceLayerList()) |
| 2219 return ScrollIgnored; | 2219 return ScrollIgnored; |
| 2220 | 2220 |
| 2221 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, | 2221 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, |
| 2222 device_scale_factor_); | 2222 device_scale_factor_); |
| 2223 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 2223 LayerImpl* layer_impl = |
| 2224 device_viewport_point, | 2224 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 2225 active_tree_->RenderSurfaceLayerList()); | |
| 2226 | 2225 |
| 2227 if (layer_impl) { | 2226 if (layer_impl) { |
| 2228 LayerImpl* scroll_layer_impl = | 2227 LayerImpl* scroll_layer_impl = |
| 2229 LayerTreeHostCommon::FindFirstScrollingLayerThatIsHitByPoint( | 2228 active_tree_->FindFirstScrollingLayerThatIsHitByPoint( |
| 2230 device_viewport_point, active_tree_->RenderSurfaceLayerList()); | 2229 device_viewport_point); |
| 2231 if (scroll_layer_impl && !HasScrollAncestor(layer_impl, scroll_layer_impl)) | 2230 if (scroll_layer_impl && !HasScrollAncestor(layer_impl, scroll_layer_impl)) |
| 2232 return ScrollUnknown; | 2231 return ScrollUnknown; |
| 2233 } | 2232 } |
| 2234 | 2233 |
| 2235 bool scroll_on_main_thread = false; | 2234 bool scroll_on_main_thread = false; |
| 2236 LayerImpl* scrolling_layer_impl = | 2235 LayerImpl* scrolling_layer_impl = |
| 2237 FindScrollLayerForDeviceViewportPoint(device_viewport_point, | 2236 FindScrollLayerForDeviceViewportPoint(device_viewport_point, |
| 2238 type, | 2237 type, |
| 2239 layer_impl, | 2238 layer_impl, |
| 2240 &scroll_on_main_thread, | 2239 &scroll_on_main_thread, |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2580 return device_viewport_layer_impl_bounds.ManhattanDistanceToPoint( | 2579 return device_viewport_layer_impl_bounds.ManhattanDistanceToPoint( |
| 2581 device_viewport_point); | 2580 device_viewport_point); |
| 2582 } | 2581 } |
| 2583 | 2582 |
| 2584 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { | 2583 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { |
| 2585 if (!EnsureRenderSurfaceLayerList()) | 2584 if (!EnsureRenderSurfaceLayerList()) |
| 2586 return; | 2585 return; |
| 2587 | 2586 |
| 2588 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, | 2587 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, |
| 2589 device_scale_factor_); | 2588 device_scale_factor_); |
| 2590 | 2589 LayerImpl* layer_impl = |
| 2591 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 2590 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 2592 device_viewport_point, | |
| 2593 active_tree_->RenderSurfaceLayerList()); | |
| 2594 if (HandleMouseOverScrollbar(layer_impl, device_viewport_point)) | 2591 if (HandleMouseOverScrollbar(layer_impl, device_viewport_point)) |
| 2595 return; | 2592 return; |
| 2596 | 2593 |
| 2597 if (scroll_layer_id_when_mouse_over_scrollbar_) { | 2594 if (scroll_layer_id_when_mouse_over_scrollbar_) { |
| 2598 LayerImpl* scroll_layer_impl = active_tree_->LayerById( | 2595 LayerImpl* scroll_layer_impl = active_tree_->LayerById( |
| 2599 scroll_layer_id_when_mouse_over_scrollbar_); | 2596 scroll_layer_id_when_mouse_over_scrollbar_); |
| 2600 | 2597 |
| 2601 // The check for a null scroll_layer_impl below was added to see if it will | 2598 // The check for a null scroll_layer_impl below was added to see if it will |
| 2602 // eliminate the crashes described in http://crbug.com/326635. | 2599 // eliminate the crashes described in http://crbug.com/326635. |
| 2603 // TODO(wjmaclean) Add a unit test if this fixes the crashes. | 2600 // TODO(wjmaclean) Add a unit test if this fixes the crashes. |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3134 swap_promise_monitor_.erase(monitor); | 3131 swap_promise_monitor_.erase(monitor); |
| 3135 } | 3132 } |
| 3136 | 3133 |
| 3137 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3134 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
| 3138 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3135 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
| 3139 for (; it != swap_promise_monitor_.end(); it++) | 3136 for (; it != swap_promise_monitor_.end(); it++) |
| 3140 (*it)->OnSetNeedsRedrawOnImpl(); | 3137 (*it)->OnSetNeedsRedrawOnImpl(); |
| 3141 } | 3138 } |
| 3142 | 3139 |
| 3143 } // namespace cc | 3140 } // namespace cc |
| OLD | NEW |