1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 14:04:59 +00:00

LibWeb: Store layout box model metrics as floats

Instead of storing them as CSS::Lengths, we now store the resolved
values for margin/padding/border/offset top/right/bottom/left with
each Layout::NodeWithStyleAndBoxModelMetrics.

This simplifies a lot of code since it's no longer necessary to
resolve values before using them.
This commit is contained in:
Andreas Kling 2020-12-12 21:02:06 +01:00
parent 1042762deb
commit 9d442ba606
7 changed files with 132 additions and 134 deletions

View file

@ -28,33 +28,33 @@
namespace Web::Layout {
PixelBox BoxModelMetrics::margin_box(const Node& layout_node) const
PixelBox BoxModelMetrics::margin_box() const
{
return {
margin.top.to_px(layout_node) + border.top.to_px(layout_node) + padding.top.to_px(layout_node),
margin.right.to_px(layout_node) + border.right.to_px(layout_node) + padding.right.to_px(layout_node),
margin.bottom.to_px(layout_node) + border.bottom.to_px(layout_node) + padding.bottom.to_px(layout_node),
margin.left.to_px(layout_node) + border.left.to_px(layout_node) + padding.left.to_px(layout_node),
margin.top + border.top + padding.top,
margin.right + border.right + padding.right,
margin.bottom + border.bottom + padding.bottom,
margin.left + border.left + padding.left,
};
}
PixelBox BoxModelMetrics::padding_box(const Node& layout_node) const
PixelBox BoxModelMetrics::padding_box() const
{
return {
padding.top.to_px(layout_node),
padding.right.to_px(layout_node),
padding.bottom.to_px(layout_node),
padding.left.to_px(layout_node),
padding.top,
padding.right,
padding.bottom,
padding.left,
};
}
PixelBox BoxModelMetrics::border_box(const Node& layout_node) const
PixelBox BoxModelMetrics::border_box() const
{
return {
border.top.to_px(layout_node) + padding.top.to_px(layout_node),
border.right.to_px(layout_node) + padding.right.to_px(layout_node),
border.bottom.to_px(layout_node) + padding.bottom.to_px(layout_node),
border.left.to_px(layout_node) + padding.left.to_px(layout_node),
border.top + padding.top,
border.right + padding.right,
border.bottom + padding.bottom,
border.left + padding.left,
};
}