1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:27:45 +00:00

LibWeb: Move width into LayoutStyle

This patch also adds the ability for Length to contain percentage
values. This is a little off-spec, but will make storing and dealing
with lengths a lot easier.

To resolve a Length to a px-or-auto Length, there are now helpers
for that. After calling them, you no longer have to think about
em, rem, %, and such things.
This commit is contained in:
Andreas Kling 2020-06-24 15:38:21 +02:00
parent 959464fce4
commit ecacab8618
6 changed files with 53 additions and 29 deletions

View file

@ -36,11 +36,13 @@ public:
Optional<int> z_index() const { return m_z_index; }
CSS::TextAlign text_align() const { return m_text_align; }
CSS::Position position() const { return m_position; }
const Length& width() const { return m_width; }
protected:
Optional<int> m_z_index;
CSS::TextAlign m_text_align;
CSS::Position m_position;
Length m_width;
};
class ImmutableLayoutStyle final : public LayoutStyle {
@ -51,6 +53,7 @@ public:
void set_z_index(Optional<int> value) { m_z_index = value; }
void set_text_align(CSS::TextAlign text_align) { m_text_align = text_align; }
void set_position(CSS::Position position) { m_position = position; }
void set_width(const Length& width) { m_width = width; }
};
}