mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
LibWeb: Move the offset, margin and padding boxes into LayoutStyle
This commit is contained in:
parent
6b334e02e6
commit
4b2ac34725
9 changed files with 66 additions and 79 deletions
|
@ -155,7 +155,6 @@ public:
|
|||
Initial,
|
||||
String,
|
||||
Length,
|
||||
Percentage,
|
||||
Color,
|
||||
Identifier,
|
||||
Image,
|
||||
|
@ -171,7 +170,6 @@ public:
|
|||
bool is_image() const { return type() == Type::Image; }
|
||||
bool is_string() const { return type() == Type::String; }
|
||||
bool is_length() const { return type() == Type::Length; }
|
||||
bool is_percentage() const { return type() == Type::Percentage; }
|
||||
bool is_position() const { return type() == Type::Position; }
|
||||
|
||||
virtual String to_string() const = 0;
|
||||
|
@ -232,31 +230,6 @@ private:
|
|||
Length m_length;
|
||||
};
|
||||
|
||||
class PercentageStyleValue : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<PercentageStyleValue> create(float percentage)
|
||||
{
|
||||
return adopt(*new PercentageStyleValue(percentage));
|
||||
}
|
||||
virtual ~PercentageStyleValue() override { }
|
||||
|
||||
virtual String to_string() const override { return String::format("%g%%", m_percentage); }
|
||||
|
||||
Length to_length(float reference) const { return Length((m_percentage / 100.0f) * reference, Length::Type::Px); }
|
||||
|
||||
private:
|
||||
virtual Length to_length() const override { return Length::make_auto(); }
|
||||
virtual bool is_auto() const override { return false; }
|
||||
|
||||
explicit PercentageStyleValue(float percentage)
|
||||
: StyleValue(Type::Percentage)
|
||||
, m_percentage(percentage)
|
||||
{
|
||||
}
|
||||
|
||||
float m_percentage { 0 };
|
||||
};
|
||||
|
||||
class InitialStyleValue final : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<InitialStyleValue> create() { return adopt(*new InitialStyleValue); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue