mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-04 15:09:40 +00:00
LibWeb: Don't crash when querying offsets of empty inline elements
Previously, querying `offsetTop` or `offsetLeft` of an inline element with no text would cause a crash.
This commit is contained in:
parent
99fbd33d7d
commit
d1226f0b15
|
@ -0,0 +1,2 @@
|
|||
Top: 0
|
||||
Left: 0
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const element = document.getElementById("empty");
|
||||
println("Top: " + element.offsetTop);
|
||||
println("Left: " + element.offsetLeft);
|
||||
});
|
||||
</script>
|
||||
<body>
|
||||
<span id="empty"></span>
|
||||
</body>
|
|
@ -158,7 +158,7 @@ CSSPixelPoint Paintable::box_type_agnostic_position() const
|
|||
auto const& inline_paintable = static_cast<Painting::InlinePaintable const&>(*this);
|
||||
if (!inline_paintable.fragments().is_empty())
|
||||
return inline_paintable.fragments().first().absolute_rect().location();
|
||||
VERIFY_NOT_REACHED();
|
||||
return inline_paintable.bounding_rect().location();
|
||||
}
|
||||
|
||||
CSSPixelPoint position;
|
||||
|
|
Loading…
Reference in a new issue