mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 03:08:13 +00:00
LibWeb: Make HTMLElement.offset{Left,Top} work on inline elements
Before this change, we were returning (0, 0) for inline elements, due to a bogus paintable type check in box_type_agnostic_position().
This commit is contained in:
parent
79db9c27c6
commit
dea91afba7
3 changed files with 86 additions and 10 deletions
|
@ -229,16 +229,14 @@ CSSPixelPoint Node::box_type_agnostic_position() const
|
|||
return verify_cast<Box>(*this).paintable_box()->absolute_position();
|
||||
VERIFY(is_inline());
|
||||
CSSPixelPoint position;
|
||||
if (auto* block = containing_block()) {
|
||||
if (is<Painting::PaintableWithLines>(*block)) {
|
||||
static_cast<Painting::PaintableWithLines const&>(*block->paintable_box()).for_each_fragment([&](auto& fragment) {
|
||||
if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) {
|
||||
position = fragment.absolute_rect().location();
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
if (auto* block = containing_block(); block && block->paintable() && is<Painting::PaintableWithLines>(*block->paintable())) {
|
||||
static_cast<Painting::PaintableWithLines const&>(*block->paintable_box()).for_each_fragment([&](auto& fragment) {
|
||||
if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) {
|
||||
position = fragment.absolute_rect().location();
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue