Commit 88311578 authored by Nick Burris's avatar Nick Burris Committed by Commit Bot

Make Android scrollbars not hit testable

Android scrollbars can't be interacted with by user input. This change
makes the SolidColorScrollbarLayer explicitly not hit testable to
ensure we don't enter any scrollbar scrolling code paths.

Also updated a few tests in layer_tree_host_impl_unittest.cc that were
using a SolidColorScrollbarLayer as a generic (hit-testable) scrollbar
layer, which should instead use a PaintedScrollbarLayer.

Bug: 954366
Change-Id: Icae9f43e043c412603d30330386710bf59482fad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1601348
Commit-Queue: Nick Burris <nburris@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662839}
parent 1f8404dc
...@@ -336,7 +336,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> { ...@@ -336,7 +336,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
// Set or get whether this layer should be a hit test target // Set or get whether this layer should be a hit test target
void SetHitTestable(bool should_hit_test); void SetHitTestable(bool should_hit_test);
bool HitTestable() const; virtual bool HitTestable() const;
// Set or gets if this layer is a container for fixed position layers in its // Set or gets if this layer is a container for fixed position layers in its
// subtree. Such layers will be positioned and transformed relative to this // subtree. Such layers will be positioned and transformed relative to this
......
...@@ -76,6 +76,8 @@ void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { ...@@ -76,6 +76,8 @@ void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
SolidColorScrollbarLayerImpl* scrollbar_layer = SolidColorScrollbarLayerImpl* scrollbar_layer =
static_cast<SolidColorScrollbarLayerImpl*>(layer); static_cast<SolidColorScrollbarLayerImpl*>(layer);
DCHECK(!scrollbar_layer->HitTestable());
scrollbar_layer->SetScrollElementId( scrollbar_layer->SetScrollElementId(
solid_color_scrollbar_layer_inputs_.scroll_element_id); solid_color_scrollbar_layer_inputs_.scroll_element_id);
} }
...@@ -96,4 +98,10 @@ void SolidColorScrollbarLayer::SetScrollElementId(ElementId element_id) { ...@@ -96,4 +98,10 @@ void SolidColorScrollbarLayer::SetScrollElementId(ElementId element_id) {
SetNeedsCommit(); SetNeedsCommit();
} }
bool SolidColorScrollbarLayer::HitTestable() const {
// Android scrollbars can't be interacted with by user input. They should
// avoid hit testing so we don't enter any scrollbar scrolling code paths.
return false;
}
} // namespace cc } // namespace cc
...@@ -34,6 +34,8 @@ class CC_EXPORT SolidColorScrollbarLayer : public ScrollbarLayerInterface, ...@@ -34,6 +34,8 @@ class CC_EXPORT SolidColorScrollbarLayer : public ScrollbarLayerInterface,
void SetNeedsDisplayRect(const gfx::Rect& rect) override; void SetNeedsDisplayRect(const gfx::Rect& rect) override;
bool HitTestable() const override;
// ScrollbarLayerInterface // ScrollbarLayerInterface
void SetScrollElementId(ElementId element_id) override; void SetScrollElementId(ElementId element_id) override;
......
...@@ -58,6 +58,7 @@ SolidColorScrollbarLayerImpl::SolidColorScrollbarLayerImpl( ...@@ -58,6 +58,7 @@ SolidColorScrollbarLayerImpl::SolidColorScrollbarLayerImpl(
void SolidColorScrollbarLayerImpl::PushPropertiesTo(LayerImpl* layer) { void SolidColorScrollbarLayerImpl::PushPropertiesTo(LayerImpl* layer) {
ScrollbarLayerImplBase::PushPropertiesTo(layer); ScrollbarLayerImplBase::PushPropertiesTo(layer);
DCHECK(!layer->HitTestable());
} }
int SolidColorScrollbarLayerImpl::ThumbThickness() const { int SolidColorScrollbarLayerImpl::ThumbThickness() const {
......
This diff is collapsed.
...@@ -2112,9 +2112,10 @@ static void FindClosestMatchingLayer(const gfx::PointF& screen_space_point, ...@@ -2112,9 +2112,10 @@ static void FindClosestMatchingLayer(const gfx::PointF& screen_space_point,
} }
} }
struct FindScrollingLayerOrScrollbarFunctor { struct HitTestScrollingLayerOrScrollbarFunctor {
bool operator()(LayerImpl* layer) const { bool operator()(LayerImpl* layer) const {
return layer->scrollable() || layer->is_scrollbar(); return layer->HitTestable() &&
(layer->scrollable() || layer->is_scrollbar());
} }
}; };
...@@ -2126,7 +2127,7 @@ LayerImpl* LayerTreeImpl::FindFirstScrollingLayerOrScrollbarThatIsHitByPoint( ...@@ -2126,7 +2127,7 @@ LayerImpl* LayerTreeImpl::FindFirstScrollingLayerOrScrollbarThatIsHitByPoint(
FindClosestMatchingLayerState state; FindClosestMatchingLayerState state;
LayerImpl* root_layer = layer_list_[0]; LayerImpl* root_layer = layer_list_[0];
FindClosestMatchingLayer(screen_space_point, root_layer, FindClosestMatchingLayer(screen_space_point, root_layer,
FindScrollingLayerOrScrollbarFunctor(), &state); HitTestScrollingLayerOrScrollbarFunctor(), &state);
return state.closest_match; return state.closest_match;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment