mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 02:58:12 +00:00
LibHTML: Add Length and LengthBox classes.
We need a way to represent values that are "auto", so adding a Length class seems like the easiest way to achieve that.
This commit is contained in:
parent
a190f67450
commit
33ac0de988
4 changed files with 49 additions and 18 deletions
26
LibHTML/CSS/Length.h
Normal file
26
LibHTML/CSS/Length.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
class Length {
|
||||
public:
|
||||
enum class Type {
|
||||
Auto,
|
||||
Absolute,
|
||||
};
|
||||
|
||||
Length() {}
|
||||
Length(int value, Type type)
|
||||
: m_type(type)
|
||||
, m_value(value)
|
||||
{
|
||||
}
|
||||
~Length() {}
|
||||
|
||||
bool is_auto() const { return m_type == Type::Auto; }
|
||||
bool is_absolute() const { return m_type == Type::Absolute; }
|
||||
|
||||
int value() const { return m_value; }
|
||||
|
||||
private:
|
||||
Type m_type { Type::Auto };
|
||||
int m_value { 0 };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue