mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:07:46 +00:00
LibHTML: Add InheritStyleValue and InitialStyleValue.
These correspond to the 'inherit' and 'initial' CSS values respectively.
This commit is contained in:
parent
105a97685e
commit
9526b0e13a
2 changed files with 35 additions and 0 deletions
|
@ -20,6 +20,9 @@ public:
|
||||||
|
|
||||||
Type type() const { return m_type; }
|
Type type() const { return m_type; }
|
||||||
|
|
||||||
|
bool is_inherit() const { return type() == Type::Inherit; }
|
||||||
|
bool is_initial() const { return type() == Type::Initial; }
|
||||||
|
|
||||||
virtual String to_string() const = 0;
|
virtual String to_string() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -68,3 +71,31 @@ private:
|
||||||
|
|
||||||
Length m_length;
|
Length m_length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class InitialStyleValue final : public StyleValue {
|
||||||
|
public:
|
||||||
|
static NonnullRefPtr<InitialStyleValue> create() { return adopt(*new InitialStyleValue); }
|
||||||
|
virtual ~InitialStyleValue() override {}
|
||||||
|
|
||||||
|
String to_string() const override { return "initial"; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
InitialStyleValue()
|
||||||
|
: StyleValue(Type::Initial)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class InheritStyleValue final : public StyleValue {
|
||||||
|
public:
|
||||||
|
static NonnullRefPtr<InheritStyleValue> create() { return adopt(*new InheritStyleValue); }
|
||||||
|
virtual ~InheritStyleValue() override {}
|
||||||
|
|
||||||
|
String to_string() const override { return "inherit"; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
InheritStyleValue()
|
||||||
|
: StyleValue(Type::Inherit)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -13,6 +13,10 @@ NonnullRefPtr<StyleValue> parse_css_value(const StringView& view)
|
||||||
unsigned as_uint = string.to_uint(ok);
|
unsigned as_uint = string.to_uint(ok);
|
||||||
if (ok)
|
if (ok)
|
||||||
return LengthStyleValue::create(Length(as_uint, Length::Type::Absolute));
|
return LengthStyleValue::create(Length(as_uint, Length::Type::Absolute));
|
||||||
|
if (string == "inherit")
|
||||||
|
return InheritStyleValue::create();
|
||||||
|
if (string == "initial")
|
||||||
|
return InitialStyleValue::create();
|
||||||
if (string == "auto")
|
if (string == "auto")
|
||||||
return LengthStyleValue::create(Length());
|
return LengthStyleValue::create(Length());
|
||||||
return StringStyleValue::create(string);
|
return StringStyleValue::create(string);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue