Commit 0a743a98 authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

[PaintTouchActionRects] Do not respect touch-action on visibility:hidden

This patch stops "visibility: hidden" objects from creating hit test
rects because hidden objects do not participate in hit testing. The
non-PaintTouchActionRects result is incorrect and has been temporarily
marked as failing.

Bug: 897186
Change-Id: If42a619a5b8acb6c205899bc655b4c4e589f6b7b
Reviewed-on: https://chromium-review.googlesource.com/c/1292952
Commit-Queue: Philip Rogers <pdr@chromium.org>
Reviewed-by: default avatarXida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603375}
parent fc6e7af2
......@@ -2174,8 +2174,13 @@ crbug.com/567837 virtual/scalefactor150/fast/hidpi/static/popup-menu-with-scroll
crbug.com/567837 virtual/scalefactor200/fast/hidpi/static/popup-menu-with-scrollbar-appearance.html [ Skip ]
crbug.com/567837 virtual/scalefactor200withzoom/fast/hidpi/static/popup-menu-with-scrollbar-appearance.html [ Skip ]
# These tests currently fail but are fixed with PaintTouchActionRects.
crbug.com/876305 fast/events/touch/compositor-touch-hit-rects-list-translate.html [ Failure ]
crbug.com/876305 fast/events/touch/compositor-touch-hit-rects.html [ Failure ]
crbug.com/897186 fast/events/touch/compositor-touch-hit-rects-visibility-hidden.html [ Failure ]
crbug.com/897186 virtual/scroll_customization/fast/events/touch/compositor-touch-hit-rects-visibility-hidden.html [ Failure ]
crbug.com/897186 virtual/user-activation-v2/fast/events/touch/compositor-touch-hit-rects-visibility-hidden.html [ Failure ]
crbug.com/897186 virtual/mouseevent_fractional/fast/events/touch/compositor-touch-hit-rects-visibility-hidden.html [ Failure ]
# TODO(ojan): These tests aren't flaky. See crbug.com/517144.
# Release trybots run asserts, but the main waterfall ones don't. So, even
......
: no rects
: no rects
: #document scrolling (13, 220, 42, 42)
: #document scrolling (13, 325, 102, 102)
: no rects
: #document scrolling (8, 532, 100, 100)
: no rects
: #document scrolling (8, 738, 100, 100)
: no rects
: #document scrolling (120, 840, 102, 102)
: no rects
: #document scrolling (118, 944, 100, 100)
<!DOCTYPE html>
<link rel="stylesheet" href="resources/compositor-touch-hit-rects.css">
<!-- This tests verifies that visibility:hidden objects do not create touch
action rects, but visibility:visible objects do. -->
<div id="tests">
<div class="testcase" style="width: 100px; height: 100px; background: red; visibility: hidden;"></div>
<div style="width: 100px; height: 100px; background: red; visibility: hidden;">
<!-- This div should inherit the hidden visibility of the parent and be hidden. -->
<div class="testcase" style="width: 30px; height: 30px; background: red;"></div>
</div>
<div style="width: 100px; height: 100px; background: red; visibility: hidden;">
<!-- This div should override the hidden visibility of the parent and be visible. -->
<div class="testcase" style="width: 40px; height: 40px; background: green; visibility: visible;"></div>
</div>
<div class="testcase" style="width: 100px; height: 100px; background: green; visibility: visible;"></div>
<table class="testcase" style="width: 100px; height: 100px; background: red; visibility: hidden;"></table>
<table class="testcase" style="width: 100px; height: 100px; background: green; visibility: visible;"></table>
<table style="width: 100px; height: 100px;">
<tr class="testcase" style="width: 100px; height: 100px; background: red; visibility: hidden;"><td></td></tr>
</table>
<table style="width: 100px; height: 100px;">
<tr class="testcase" style="width: 100px; height: 100px; background: green; visibility: visible;"><td></td></tr>
</table>
<img class="testcase" style="width: 100px; height: 100px; background: red; visibility: hidden;"></img>
<img class="testcase" style="width: 100px; height: 100px; background: green; visibility: visible;"></img>
<svg width="100" height="100">
<rect class="testcase" width="100" height="100" fill="red" style="visibility: hidden;"></rect>
</svg>
<svg width="100" height="100">
<rect class="testcase" width="100" height="100" fill="green" style="visibility: visible;"></rect>
</svg>
</div>
<div id="console"></div>
<script src="resources/compositor-touch-hit-rects.js"></script>
......@@ -174,6 +174,7 @@ TEST_F(BlockPainterTestWithPaintTouchAction, TouchActionRectsWithoutPaint) {
.touchActionNone { touch-action: none; }
#childVisible { width: 200px; height: 25px; }
#childHidden { width: 200px; height: 30px; visibility: hidden; }
#childDisplayNone { width: 200px; height: 30px; display: none; }
</style>
<div id='parent'>
<div id='childVisible'></div>
......@@ -189,19 +190,17 @@ TEST_F(BlockPainterTestWithPaintTouchAction, TouchActionRectsWithoutPaint) {
TestDisplayItem(scrolling_client, kDocumentBackgroundType));
// Add a touch action to parent and ensure that hit test display items are
// created for both the parent and child.
// created for both the parent and the visible child.
auto* parent_element = GetElementById("parent");
parent_element->setAttribute(HTMLNames::classAttr, "touchActionNone");
GetDocument().View()->UpdateAllLifecyclePhases();
auto* parent = GetLayoutObjectByElementId("parent");
auto* childVisible = GetLayoutObjectByElementId("childVisible");
auto* childHidden = GetLayoutObjectByElementId("childHidden");
EXPECT_DISPLAY_LIST(
RootPaintController().GetDisplayItemList(), 4,
RootPaintController().GetDisplayItemList(), 3,
TestDisplayItem(scrolling_client, kDocumentBackgroundType),
TestDisplayItem(*parent, DisplayItem::kHitTest),
TestDisplayItem(*childVisible, DisplayItem::kHitTest),
TestDisplayItem(*childHidden, DisplayItem::kHitTest));
TestDisplayItem(*childVisible, DisplayItem::kHitTest));
// Remove the touch action from parent and ensure no hit test display items
// are left.
......
......@@ -267,6 +267,10 @@ void BoxPainter::RecordHitTestData(const PaintInfo& paint_info,
if (paint_info.GetGlobalPaintFlags() & kGlobalPaintFlattenCompositingLayers)
return;
// If an object is not visible, it does not participate in hit testing.
if (layout_box_.StyleRef().Visibility() != EVisibility::kVisible)
return;
auto touch_action = layout_box_.EffectiveWhitelistedTouchAction();
if (touch_action == TouchAction::kTouchActionAuto)
return;
......
......@@ -337,6 +337,10 @@ void InlineFlowBoxPainter::RecordHitTestData(const PaintInfo& paint_info,
LayoutObject* layout_object =
LineLayoutAPIShim::LayoutObjectFrom(inline_flow_box_.GetLineLayoutItem());
// If an object is not visible, it does not participate in hit testing.
if (layout_object->StyleRef().Visibility() != EVisibility::kVisible)
return;
auto touch_action = layout_object->EffectiveWhitelistedTouchAction();
if (touch_action == TouchAction::kTouchActionAuto)
return;
......
......@@ -201,6 +201,10 @@ void NGBoxFragmentPainter::RecordHitTestData(const PaintInfo& paint_info,
if (paint_info.GetGlobalPaintFlags() & kGlobalPaintFlattenCompositingLayers)
return;
// If an object is not visible, it does not participate in hit testing.
if (box_fragment_.Style().Visibility() != EVisibility::kVisible)
return;
const NGPhysicalFragment& physical_fragment = PhysicalFragment();
auto touch_action = physical_fragment.EffectiveWhitelistedTouchAction();
if (touch_action == TouchAction::kTouchActionAuto)
......
......@@ -186,6 +186,10 @@ void ReplacedPainter::RecordHitTestData(const PaintInfo& paint_info,
if (paint_info.phase != PaintPhase::kForeground)
return;
// If an object is not visible, it does not participate in hit testing.
if (layout_replaced_.StyleRef().Visibility() != EVisibility::kVisible)
return;
auto touch_action = layout_replaced_.EffectiveWhitelistedTouchAction();
if (touch_action == TouchAction::kTouchActionAuto)
return;
......
......@@ -74,6 +74,10 @@ void TableRowPainter::RecordHitTestData(const PaintInfo& paint_info,
if (paint_info.GetGlobalPaintFlags() & kGlobalPaintFlattenCompositingLayers)
return;
// If an object is not visible, it does not participate in hit testing.
if (layout_table_row_.StyleRef().Visibility() != EVisibility::kVisible)
return;
auto touch_action = layout_table_row_.EffectiveWhitelistedTouchAction();
if (touch_action == TouchAction::kTouchActionAuto)
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