LibWeb: Return a scroll offset of 0 for colgroup elements

Ideally we would not create a layout node at all for these elements so
that every layout node would always have a paintable associated with it.
But for now, to fix the crash, just leave a FIXME and special case this
element.

Also leave a VERIFY to make it easier to debug this type of crash in the
future.

Fixes a crash seen on codecov.io for my 'patch' project.
This commit is contained in:
Shannon Booth 2023-10-08 10:55:51 +13:00 committed by Alexander Kalenik
parent eb1c99bd72
commit decc071060
Notes: sideshowbarker 2024-07-16 23:34:44 +09:00
3 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,2 @@
scroll left = 0
scroll top = 0

View file

@ -0,0 +1,13 @@
<table>
<colgroup id="my-group">
<col width="40">
<col></colgroup>
<tbody>
<script src="include.js"></script>
<script>
test(() => {
const element = document.getElementById('my-group');
println(`scroll left = ${element.scrollLeft}`);
println(`scroll top = ${element.scrollTop}`);
});
</script>

View file

@ -1085,8 +1085,16 @@ double Element::scroll_top() const
if (!layout_node() || !is<Layout::Box>(layout_node()))
return 0.0;
// FIXME: Ideally we would stop creating a layout node for column group so that a layout node would always have
// a paintable, but in the meantime, special case this node.
if (layout_node()->display().is_table_column_group()) {
VERIFY(!paintable_box());
return 0.0;
}
// 9. Return the y-coordinate of the scrolling area at the alignment point with the top of the padding edge of the element.
// FIXME: Is this correct?
VERIFY(paintable_box());
return paintable_box()->scroll_offset().y().to_double();
}
@ -1125,8 +1133,16 @@ double Element::scroll_left() const
if (!layout_node() || !is<Layout::Box>(layout_node()))
return 0.0;
// FIXME: Ideally we would stop creating a layout node for column group so that a layout node would always have
// a paintable, but in the meantime, special case this node.
if (layout_node()->display().is_table_column_group()) {
VERIFY(!paintable_box());
return 0.0;
}
// 9. Return the x-coordinate of the scrolling area at the alignment point with the left of the padding edge of the element.
// FIXME: Is this correct?
VERIFY(paintable_box());
return paintable_box()->scroll_offset().x().to_double();
}