Commit a5d0ab06 authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

[PaintTouchActionRects] Paint replaced hit test rects without background

There was an early-out in ReplacedPainter::Paint that would skip
painting touch-action hit test rects if the replaced element did not
also paint a background. This patch skips the early-out if there is a
hit test rect that should be painted.

This does not fully fix https://crbug.com/903480 because accelerated
canvases still do not generate the correct touch action rects.

Bug: 903480
Change-Id: If6cda7339c5a20a04fe669c4d54fae30e83debf2
Reviewed-on: https://chromium-review.googlesource.com/c/1331033Reviewed-by: default avatarXianda Sun <sunxd@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607236}
parent 3803f14f
......@@ -1937,6 +1937,9 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
return TouchAction::kTouchActionNone;
return StyleRef().GetEffectiveTouchAction();
}
bool HasEffectiveWhitelistedTouchAction() const {
return EffectiveWhitelistedTouchAction() != TouchAction::kTouchActionAuto;
}
// Whether this object's Node has a blocking touch event handler on itself
// or an ancestor.
......
......@@ -517,6 +517,20 @@ TEST_P(ScrollingCoordinatorTest, elementTouchEventHandlerPassive) {
EXPECT_TRUE(region.IsEmpty());
}
TEST_P(ScrollingCoordinatorTest, TouchActionRectsOnImage) {
LoadHTML(R"HTML(
<img id="image" style="width: 100px; height: 100px; touch-action: none;">
)HTML");
ForceFullCompositingUpdate();
auto* layout_view = GetFrame()->View()->GetLayoutView();
auto* mapping = layout_view->Layer()->GetCompositedLayerMapping();
cc::Layer* cc_layer = mapping->ScrollingContentsLayer()->CcLayer();
cc::Region region = cc_layer->touch_action_region().GetRegionForTouchAction(
TouchAction::kTouchActionNone);
EXPECT_EQ(region.bounds(), gfx::Rect(8, 8, 100, 100));
}
TEST_P(ScrollingCoordinatorTest, touchEventHandlerBoth) {
RegisterMockedHttpURLLoad("touch-event-handler-both.html");
NavigateTo(base_url_ + "touch-event-handler-both.html");
......
......@@ -226,10 +226,8 @@ void PaintInvalidator::UpdatePaintingLayer(const LayoutObject& object,
context.painting_layer->SetNeedsPaintPhaseDescendantBlockBackgrounds();
} else if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled()) {
// Hit testing rects for touch action paint in the background phase.
if (object.EffectiveWhitelistedTouchAction() !=
TouchAction::kTouchActionAuto) {
if (object.HasEffectiveWhitelistedTouchAction())
context.painting_layer->SetNeedsPaintPhaseDescendantBlockBackgrounds();
}
}
}
......
......@@ -105,8 +105,16 @@ void ReplacedPainter::Paint(const PaintInfo& paint_info) {
LayoutRect border_rect(paint_offset, layout_replaced_.Size());
if (ShouldPaintBoxDecorationBackground(local_paint_info)) {
if (layout_replaced_.StyleRef().Visibility() == EVisibility::kVisible &&
layout_replaced_.HasBoxDecorationBackground()) {
bool should_paint_background = false;
if (layout_replaced_.StyleRef().Visibility() == EVisibility::kVisible) {
if (layout_replaced_.HasBoxDecorationBackground())
should_paint_background = true;
if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled() &&
layout_replaced_.HasEffectiveWhitelistedTouchAction()) {
should_paint_background = true;
}
}
if (should_paint_background) {
if (layout_replaced_.HasLayer() &&
layout_replaced_.Layer()->GetCompositingState() ==
kPaintsIntoOwnBacking &&
......
......@@ -37,8 +37,7 @@ void ViewPainter::PaintBoxDecorationBackground(const PaintInfo& paint_info) {
bool has_touch_action_rect =
RuntimeEnabledFeatures::PaintTouchActionRectsEnabled() &&
(layout_view_.EffectiveWhitelistedTouchAction() !=
TouchAction::kTouchActionAuto);
(layout_view_.HasEffectiveWhitelistedTouchAction());
if (!layout_view_.HasBoxDecorationBackground() && !has_touch_action_rect)
return;
......
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