mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:37:45 +00:00
LibWeb: Ignore invisible boxes and stacking contexts during hit testing
This commit is contained in:
parent
df8ef03957
commit
196a3eb239
2 changed files with 10 additions and 3 deletions
|
@ -464,6 +464,9 @@ void PaintableBox::set_stacking_context(NonnullOwnPtr<StackingContext> stacking_
|
|||
|
||||
Optional<HitTestResult> PaintableBox::hit_test(Gfx::FloatPoint const& position, HitTestType type) const
|
||||
{
|
||||
if (!is_visible())
|
||||
return {};
|
||||
|
||||
if (layout_box().is_initial_containing_block_box()) {
|
||||
const_cast<Layout::InitialContainingBlock&>(static_cast<Layout::InitialContainingBlock const&>(layout_box())).build_stacking_context_tree_if_needed();
|
||||
return stacking_context()->hit_test(position, type);
|
||||
|
@ -497,7 +500,7 @@ Optional<HitTestResult> PaintableWithLines::hit_test(const Gfx::FloatPoint& posi
|
|||
|
||||
if (type == HitTestType::TextCursor && last_good_candidate.has_value())
|
||||
return last_good_candidate;
|
||||
if (absolute_border_box_rect().contains(position.x(), position.y()))
|
||||
if (is_visible() && absolute_border_box_rect().contains(position.x(), position.y()))
|
||||
return HitTestResult { *this };
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -286,8 +286,10 @@ Optional<HitTestResult> StackingContext::hit_test(Gfx::FloatPoint const& positio
|
|||
// 7. the child stacking contexts with positive stack levels (least positive first).
|
||||
for (ssize_t i = m_children.size() - 1; i >= 0; --i) {
|
||||
auto const& child = *m_children[i];
|
||||
if (!child.m_box.is_visible())
|
||||
continue;
|
||||
if (child.m_box.computed_values().z_index().value_or(0) < 0)
|
||||
break;
|
||||
continue;
|
||||
auto result = child.hit_test(transformed_position, type);
|
||||
if (result.has_value())
|
||||
return result;
|
||||
|
@ -340,7 +342,9 @@ Optional<HitTestResult> StackingContext::hit_test(Gfx::FloatPoint const& positio
|
|||
for (ssize_t i = m_children.size() - 1; i >= 0; --i) {
|
||||
auto const& child = *m_children[i];
|
||||
if (child.m_box.computed_values().z_index().value_or(0) < 0)
|
||||
break;
|
||||
continue;
|
||||
if (!child.m_box.is_visible())
|
||||
continue;
|
||||
auto result = child.hit_test(transformed_position, type);
|
||||
if (result.has_value())
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue