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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 LayerTreeHostImpl::EventListenerTypeForTouchStartAt( | 609 LayerTreeHostImpl::EventListenerTypeForTouchStartAt( |
610 const gfx::Point& viewport_point) { | 610 const gfx::Point& viewport_point) { |
611 gfx::PointF device_viewport_point = gfx::ScalePoint( | 611 gfx::PointF device_viewport_point = gfx::ScalePoint( |
612 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 612 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
613 | 613 |
614 // Now determine if there are actually any handlers at that point. | 614 // Now determine if there are actually any handlers at that point. |
615 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). | 615 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). |
616 LayerImpl* layer_impl = | 616 LayerImpl* layer_impl = |
617 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( | 617 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
618 device_viewport_point); | 618 device_viewport_point); |
619 if (layer_impl == NULL) | 619 if (layer_impl == NULL) { |
| 620 // At present, TouchHandlerRegions are only set for LayerTrees serving the |
| 621 // document's mainframe, i.e. LayerTrees that have a ViewPort defined. But |
| 622 // subframes can still have touch handlers, so here we err on the side of |
| 623 // caution and report a handler even if we don't know which layer it's on. |
| 624 // This code can be removed once ScrollingCoordinator is per-compositor |
| 625 // rather than per-page, https://crbug.com/680606, since a per-compositor |
| 626 // version will correctly send touch-rects for non-mainframes. |
| 627 EventListenerProperties properties = |
| 628 active_tree_->event_listener_properties( |
| 629 EventListenerClass::kTouchStartOrMove); |
| 630 if ((properties == EventListenerProperties::kBlocking || |
| 631 properties == EventListenerProperties::kBlockingAndPassive) && |
| 632 !active_tree_->OuterViewportScrollLayer()) { |
| 633 return InputHandler::TouchStartEventListenerType::HANDLER; |
| 634 } |
620 return InputHandler::TouchStartEventListenerType::NO_HANDLER; | 635 return InputHandler::TouchStartEventListenerType::NO_HANDLER; |
| 636 } |
621 | 637 |
622 if (!CurrentlyScrollingLayer()) | 638 if (!CurrentlyScrollingLayer()) |
623 return InputHandler::TouchStartEventListenerType::HANDLER; | 639 return InputHandler::TouchStartEventListenerType::HANDLER; |
624 | 640 |
625 bool is_ancestor = | 641 bool is_ancestor = |
626 IsScrolledBy(layer_impl, active_tree_->CurrentlyScrollingLayer()); | 642 IsScrolledBy(layer_impl, active_tree_->CurrentlyScrollingLayer()); |
627 return is_ancestor ? InputHandler::TouchStartEventListenerType:: | 643 return is_ancestor ? InputHandler::TouchStartEventListenerType:: |
628 HANDLER_ON_SCROLLING_LAYER | 644 HANDLER_ON_SCROLLING_LAYER |
629 : InputHandler::TouchStartEventListenerType::HANDLER; | 645 : InputHandler::TouchStartEventListenerType::HANDLER; |
630 } | 646 } |
(...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2988 bool is_viewport_scroll_layer = | 3004 bool is_viewport_scroll_layer = |
2989 viewport()->MainScrollLayer() && | 3005 viewport()->MainScrollLayer() && |
2990 scroll_node->owning_layer_id == viewport()->MainScrollLayer()->id(); | 3006 scroll_node->owning_layer_id == viewport()->MainScrollLayer()->id(); |
2991 | 3007 |
2992 // This is needed if the scroll chains up to the viewport without going | 3008 // This is needed if the scroll chains up to the viewport without going |
2993 // through the outer viewport scroll layer. This can happen if we scroll an | 3009 // through the outer viewport scroll layer. This can happen if we scroll an |
2994 // element that's not a descendant of the document.rootScroller. In that case | 3010 // element that's not a descendant of the document.rootScroller. In that case |
2995 // we want to scroll the inner viewport -- to allow panning while zoomed -- | 3011 // we want to scroll the inner viewport -- to allow panning while zoomed -- |
2996 // but also move browser controls if needed. | 3012 // but also move browser controls if needed. |
2997 bool is_inner_viewport_scroll_layer = | 3013 bool is_inner_viewport_scroll_layer = |
| 3014 InnerViewportScrollLayer() && |
2998 scroll_node->owning_layer_id == InnerViewportScrollLayer()->id(); | 3015 scroll_node->owning_layer_id == InnerViewportScrollLayer()->id(); |
2999 | 3016 |
3000 if (is_viewport_scroll_layer || is_inner_viewport_scroll_layer) { | 3017 if (is_viewport_scroll_layer || is_inner_viewport_scroll_layer) { |
3001 Viewport::ScrollResult result = viewport()->ScrollBy( | 3018 Viewport::ScrollResult result = viewport()->ScrollBy( |
3002 delta, viewport_point, scroll_state->is_direct_manipulation(), | 3019 delta, viewport_point, scroll_state->is_direct_manipulation(), |
3003 !wheel_scrolling_, is_viewport_scroll_layer); | 3020 !wheel_scrolling_, is_viewport_scroll_layer); |
3004 | 3021 |
3005 applied_delta = result.consumed_delta; | 3022 applied_delta = result.consumed_delta; |
3006 delta_applied_to_content = result.content_scrolled_delta; | 3023 delta_applied_to_content = result.content_scrolled_delta; |
3007 } else { | 3024 } else { |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4092 worker_context_visibility_ = | 4109 worker_context_visibility_ = |
4093 worker_context->CacheController()->ClientBecameVisible(); | 4110 worker_context->CacheController()->ClientBecameVisible(); |
4094 } else { | 4111 } else { |
4095 worker_context->CacheController()->ClientBecameNotVisible( | 4112 worker_context->CacheController()->ClientBecameNotVisible( |
4096 std::move(worker_context_visibility_)); | 4113 std::move(worker_context_visibility_)); |
4097 } | 4114 } |
4098 } | 4115 } |
4099 } | 4116 } |
4100 | 4117 |
4101 } // namespace cc | 4118 } // namespace cc |
OLD | NEW |