Commit 82eda384 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Fieldset NG: Fix hit-testing for the rendered legend

If LayoutNGFragmentTraversal is disabled, no one calls
NodeAtPoint() for the rendered legend. This CL fixes it by adding
LayoutNGFieldset::HitTestChildren() override so that it handles the
fieldset's rendered legend.

Bug: 1127743
Change-Id: Idb21c4dc198591509e4172d89dc84e379a12097f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2409416Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806924}
parent cd6695a1
...@@ -140,6 +140,29 @@ bool LayoutNGFieldset::BackgroundIsKnownToBeOpaqueInRect( ...@@ -140,6 +140,29 @@ bool LayoutNGFieldset::BackgroundIsKnownToBeOpaqueInRect(
return LayoutBlockFlow::BackgroundIsKnownToBeOpaqueInRect(local_rect); return LayoutBlockFlow::BackgroundIsKnownToBeOpaqueInRect(local_rect);
} }
bool LayoutNGFieldset::HitTestChildren(HitTestResult& result,
const HitTestLocation& hit_test_location,
const PhysicalOffset& accumulated_offset,
HitTestAction hit_test_action) {
if (LayoutNGBlockFlow::HitTestChildren(result, hit_test_location,
accumulated_offset, hit_test_action))
return true;
DCHECK(!RuntimeEnabledFeatures::LayoutNGFragmentTraversalEnabled());
LayoutBox* legend = LayoutFieldset::FindInFlowLegend(*this);
if (!legend || legend->HasSelfPaintingLayer() || legend->IsColumnSpanAll())
return false;
if (legend->NodeAtPoint(result, hit_test_location,
legend->PhysicalLocation(this),
hit_test_action == kHitTestChildBlockBackgrounds
? kHitTestChildBlockBackground
: hit_test_action)) {
UpdateHitTestResult(result, hit_test_location.Point() - accumulated_offset);
return true;
}
return false;
}
LayoutUnit LayoutNGFieldset::ScrollWidth() const { LayoutUnit LayoutNGFieldset::ScrollWidth() const {
const LayoutObject* child = FirstChild(); const LayoutObject* child = FirstChild();
if (child && child->IsAnonymous()) if (child && child->IsAnonymous())
......
...@@ -27,6 +27,10 @@ class CORE_EXPORT LayoutNGFieldset final : public LayoutNGBlockFlow { ...@@ -27,6 +27,10 @@ class CORE_EXPORT LayoutNGFieldset final : public LayoutNGBlockFlow {
ComputedStyle& child_style) const override; ComputedStyle& child_style) const override;
void InvalidatePaint(const PaintInvalidatorContext& context) const final; void InvalidatePaint(const PaintInvalidatorContext& context) const final;
bool BackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&) const override; bool BackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&) const override;
bool HitTestChildren(HitTestResult& result,
const HitTestLocation& hit_test_location,
const PhysicalOffset& accumulated_offset,
HitTestAction hit_test_action) override;
bool AllowsNonVisibleOverflow() const override { return false; } bool AllowsNonVisibleOverflow() const override { return false; }
// Override to forward to the anonymous fieldset content box. // Override to forward to the anonymous fieldset content box.
......
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style>
legend:hover {
background: lime;
}
</style>
<fieldset>
<legend>Legend</legend>
</fieldset>
<script>
// https://crbug.com/1127743
promise_test(async () => {
await test_driver.click(document.querySelector('legend'));
assert_not_equals(document.querySelector('legend:hover'), null);
}, 'The rendered LEGEND should work well for :hover.');
</script>
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