1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:38:10 +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

@ -27,27 +27,26 @@
#pragma once
#include <LibGfx/Size.h>
#include <LibWeb/CSS/LengthBox.h>
namespace Web::Layout {
struct PixelBox {
float top;
float right;
float bottom;
float left;
float top { 0 };
float right { 0 };
float bottom { 0 };
float left { 0 };
};
struct BoxModelMetrics {
public:
CSS::LengthBox margin;
CSS::LengthBox padding;
CSS::LengthBox border;
CSS::LengthBox offset;
PixelBox margin;
PixelBox padding;
PixelBox border;
PixelBox offset;
PixelBox margin_box(const Node&) const;
PixelBox padding_box(const Node&) const;
PixelBox border_box(const Node&) const;
PixelBox margin_box() const;
PixelBox padding_box() const;
PixelBox border_box() const;
};
}