LibWeb/HTML: Remove uneeded handling for non-box paintable HTMLElements

All inline nodes are now PaintableBoxes, so we do not need to handle the
non box case any more :^)
This commit is contained in:
Shannon Booth 2025-01-01 01:08:10 +13:00 committed by Andreas Kling
parent c7d6a7aafb
commit 372f2dd7a1
Notes: github-actions[bot] 2025-01-02 10:29:42 +00:00

View file

@ -463,12 +463,7 @@ int HTMLElement::offset_top() const
if (!layout_node())
return 0;
CSSPixels top_border_edge_of_element;
if (paintable()->is_paintable_box()) {
top_border_edge_of_element = paintable_box()->absolute_border_box_rect().y();
} else {
top_border_edge_of_element = paintable()->box_type_agnostic_position().y();
}
CSSPixels top_border_edge_of_element = paintable_box()->absolute_border_box_rect().y();
// 2. If the offsetParent of the element is null
// return the y-coordinate of the top border edge of the first CSS layout box associated with the element,
@ -489,12 +484,10 @@ int HTMLElement::offset_top() const
// Spec bug: https://github.com/w3c/csswg-drafts/issues/10549
CSSPixels top_padding_edge_of_offset_parent;
if (offset_parent->is_html_body_element() && !offset_parent->paintable()->is_positioned()) {
if (offset_parent->is_html_body_element() && !offset_parent->paintable_box()->is_positioned()) {
top_padding_edge_of_offset_parent = 0;
} else if (offset_parent->paintable()->is_paintable_box()) {
top_padding_edge_of_offset_parent = offset_parent->paintable_box()->absolute_padding_box_rect().y();
} else {
top_padding_edge_of_offset_parent = offset_parent->paintable()->box_type_agnostic_position().y();
top_padding_edge_of_offset_parent = offset_parent->paintable_box()->absolute_padding_box_rect().y();
}
return (top_border_edge_of_element - top_padding_edge_of_offset_parent).to_int();
}
@ -512,12 +505,7 @@ int HTMLElement::offset_left() const
if (!layout_node())
return 0;
CSSPixels left_border_edge_of_element;
if (paintable()->is_paintable_box()) {
left_border_edge_of_element = paintable_box()->absolute_border_box_rect().x();
} else {
left_border_edge_of_element = paintable()->box_type_agnostic_position().x();
}
CSSPixels left_border_edge_of_element = paintable_box()->absolute_border_box_rect().x();
// 2. If the offsetParent of the element is null
// return the x-coordinate of the left border edge of the first CSS layout box associated with the element,
@ -538,12 +526,10 @@ int HTMLElement::offset_left() const
// Spec bug: https://github.com/w3c/csswg-drafts/issues/10549
CSSPixels left_padding_edge_of_offset_parent;
if (offset_parent->is_html_body_element() && !offset_parent->paintable()->is_positioned()) {
if (offset_parent->is_html_body_element() && !offset_parent->paintable_box()->is_positioned()) {
left_padding_edge_of_offset_parent = 0;
} else if (offset_parent->paintable()->is_paintable_box()) {
left_padding_edge_of_offset_parent = offset_parent->paintable_box()->absolute_padding_box_rect().x();
} else {
left_padding_edge_of_offset_parent = offset_parent->paintable()->box_type_agnostic_position().x();
left_padding_edge_of_offset_parent = offset_parent->paintable_box()->absolute_padding_box_rect().x();
}
return (left_border_edge_of_element - left_padding_edge_of_offset_parent).to_int();
}
@ -560,7 +546,6 @@ int HTMLElement::offset_width() const
// 2. Return the width of the axis-aligned bounding box of the border boxes of all fragments generated by the elements principal box,
// ignoring any transforms that apply to the element and its ancestors.
// FIXME: Account for inline boxes.
return paintable_box()->border_box_width().to_int();
}
@ -576,7 +561,6 @@ int HTMLElement::offset_height() const
// 2. Return the height of the axis-aligned bounding box of the border boxes of all fragments generated by the elements principal box,
// ignoring any transforms that apply to the element and its ancestors.
// FIXME: Account for inline boxes.
return paintable_box()->border_box_height().to_int();
}