Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: cc/trees/layer_tree_impl.cc

Issue 1878323002: cc: Scroll on main when possible incorrect hit testing hits scrollbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make sure the unit test fails without the patch Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_impl.h" 5 #include "cc/trees/layer_tree_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 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 distance_to_intersection > 1748 distance_to_intersection >
1749 state->closest_distance + std::numeric_limits<float>::epsilon(); 1749 state->closest_distance + std::numeric_limits<float>::epsilon();
1750 1750
1751 if (!state->closest_match || in_front_of_previous_candidate) { 1751 if (!state->closest_match || in_front_of_previous_candidate) {
1752 state->closest_distance = distance_to_intersection; 1752 state->closest_distance = distance_to_intersection;
1753 state->closest_match = layer; 1753 state->closest_match = layer;
1754 } 1754 }
1755 } 1755 }
1756 } 1756 }
1757 1757
1758 static bool ScrollsAnyDrawnRenderSurfaceLayerListMember(LayerImpl* layer) { 1758 static bool ScrollsOrScrollbarAnyDrawnRenderSurfaceLayerListMember(
1759 if (!layer->scrollable()) 1759 LayerImpl* layer) {
1760 if (!layer->scrollable() && !layer->ToScrollbarLayer())
1760 return false; 1761 return false;
1761 if (layer->layer_or_descendant_is_drawn()) 1762 if (layer->layer_or_descendant_is_drawn())
1762 return true; 1763 return true;
1763 1764
1764 if (!layer->scroll_children()) 1765 if (!layer->scroll_children())
1765 return false; 1766 return false;
1766 for (std::set<LayerImpl*>::const_iterator it = 1767 for (std::set<LayerImpl*>::const_iterator it =
1767 layer->scroll_children()->begin(); 1768 layer->scroll_children()->begin();
1768 it != layer->scroll_children()->end(); ++it) { 1769 it != layer->scroll_children()->end(); ++it) {
1769 if ((*it)->layer_or_descendant_is_drawn()) 1770 if ((*it)->layer_or_descendant_is_drawn())
1770 return true; 1771 return true;
1771 } 1772 }
1772 return false; 1773 return false;
1773 } 1774 }
1774 1775
1775 struct FindScrollingLayerFunctor { 1776 struct FindScrollingLayerOrScrollbarLayerFunctor {
1776 bool operator()(LayerImpl* layer) const { 1777 bool operator()(LayerImpl* layer) const {
1777 return ScrollsAnyDrawnRenderSurfaceLayerListMember(layer); 1778 return ScrollsOrScrollbarAnyDrawnRenderSurfaceLayerListMember(layer);
1778 } 1779 }
1779 }; 1780 };
1780 1781
1781 LayerImpl* LayerTreeImpl::FindFirstScrollingLayerThatIsHitByPoint( 1782 LayerImpl*
1783 LayerTreeImpl::FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint(
1782 const gfx::PointF& screen_space_point) { 1784 const gfx::PointF& screen_space_point) {
1783 FindClosestMatchingLayerState state; 1785 FindClosestMatchingLayerState state;
1784 FindClosestMatchingLayer( 1786 FindClosestMatchingLayer(screen_space_point, root_layer(),
1785 screen_space_point, root_layer(), FindScrollingLayerFunctor(), 1787 FindScrollingLayerOrScrollbarLayerFunctor(),
1786 property_trees_.transform_tree, property_trees_.clip_tree, &state); 1788 property_trees_.transform_tree,
1789 property_trees_.clip_tree, &state);
1787 return state.closest_match; 1790 return state.closest_match;
1788 } 1791 }
1789 1792
1790 struct HitTestVisibleScrollableOrTouchableFunctor { 1793 struct HitTestVisibleScrollableOrTouchableFunctor {
1791 bool operator()(LayerImpl* layer) const { 1794 bool operator()(LayerImpl* layer) const {
1792 return layer->IsDrawnRenderSurfaceLayerListMember() || 1795 return layer->IsDrawnRenderSurfaceLayerListMember() ||
1793 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || 1796 ScrollsOrScrollbarAnyDrawnRenderSurfaceLayerListMember(layer) ||
1794 !layer->touch_event_handler_region().IsEmpty(); 1797 !layer->touch_event_handler_region().IsEmpty();
1795 } 1798 }
1796 }; 1799 };
1797 1800
1798 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( 1801 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint(
1799 const gfx::PointF& screen_space_point) { 1802 const gfx::PointF& screen_space_point) {
1800 if (!root_layer()) 1803 if (!root_layer())
1801 return NULL; 1804 return NULL;
1802 bool update_lcd_text = false; 1805 bool update_lcd_text = false;
1803 if (!UpdateDrawProperties(update_lcd_text)) 1806 if (!UpdateDrawProperties(update_lcd_text))
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 } 2105 }
2103 2106
2104 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { 2107 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) {
2105 layers_that_should_push_properties_.clear(); 2108 layers_that_should_push_properties_.clear();
2106 for (auto* layer : *this) 2109 for (auto* layer : *this)
2107 layer->ResetChangeTracking(); 2110 layer->ResetChangeTracking();
2108 property_trees_.ResetAllChangeTracking(flag); 2111 property_trees_.ResetAllChangeTracking(flag);
2109 } 2112 }
2110 2113
2111 } // namespace cc 2114 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698