mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
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:
parent
c7d6a7aafb
commit
372f2dd7a1
Notes:
github-actions[bot]
2025-01-02 10:29:42 +00:00
Author: https://github.com/shannonbooth
Commit: 372f2dd7a1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3077
Reviewed-by: https://github.com/awesomekling
1 changed files with 6 additions and 22 deletions
|
@ -463,12 +463,7 @@ int HTMLElement::offset_top() const
|
||||||
if (!layout_node())
|
if (!layout_node())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CSSPixels top_border_edge_of_element;
|
CSSPixels top_border_edge_of_element = paintable_box()->absolute_border_box_rect().y();
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. If the offsetParent of the element is null
|
// 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,
|
// 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
|
// Spec bug: https://github.com/w3c/csswg-drafts/issues/10549
|
||||||
|
|
||||||
CSSPixels top_padding_edge_of_offset_parent;
|
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;
|
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 {
|
} 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();
|
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())
|
if (!layout_node())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CSSPixels left_border_edge_of_element;
|
CSSPixels left_border_edge_of_element = paintable_box()->absolute_border_box_rect().x();
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. If the offsetParent of the element is null
|
// 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,
|
// 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
|
// Spec bug: https://github.com/w3c/csswg-drafts/issues/10549
|
||||||
|
|
||||||
CSSPixels left_padding_edge_of_offset_parent;
|
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;
|
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 {
|
} 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();
|
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 element’s principal box,
|
// 2. Return the width of the axis-aligned bounding box of the border boxes of all fragments generated by the element’s principal box,
|
||||||
// ignoring any transforms that apply to the element and its ancestors.
|
// ignoring any transforms that apply to the element and its ancestors.
|
||||||
// FIXME: Account for inline boxes.
|
|
||||||
return paintable_box()->border_box_width().to_int();
|
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 element’s principal box,
|
// 2. Return the height of the axis-aligned bounding box of the border boxes of all fragments generated by the element’s principal box,
|
||||||
// ignoring any transforms that apply to the element and its ancestors.
|
// ignoring any transforms that apply to the element and its ancestors.
|
||||||
// FIXME: Account for inline boxes.
|
|
||||||
return paintable_box()->border_box_height().to_int();
|
return paintable_box()->border_box_height().to_int();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue