mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:37:34 +00:00
LibWeb: Implement CSS unset
builtin value
This is equivalent to `initial` or `inherit`, depending on if the property is inherited by default.
This commit is contained in:
parent
3296fd70b3
commit
b92a6d6542
3 changed files with 32 additions and 3 deletions
|
@ -1407,7 +1407,9 @@ RefPtr<StyleValue> Parser::parse_builtin_value(ParsingContext const&, StyleCompo
|
||||||
return InheritStyleValue::the();
|
return InheritStyleValue::the();
|
||||||
if (ident.equals_ignoring_case("initial"))
|
if (ident.equals_ignoring_case("initial"))
|
||||||
return InitialStyleValue::the();
|
return InitialStyleValue::the();
|
||||||
// FIXME: Implement `unset` keyword
|
if (ident.equals_ignoring_case("unset"))
|
||||||
|
return UnsetStyleValue::the();
|
||||||
|
// FIXME: Implement `revert` and `revert-layer` keywords, from Cascade4 and Cascade5 respectively
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -71,6 +71,13 @@ Optional<NonnullRefPtr<StyleValue>> StyleProperties::property(CSS::PropertyID id
|
||||||
return fetch_initial(id);
|
return fetch_initial(id);
|
||||||
if (value->is_inherit())
|
if (value->is_inherit())
|
||||||
return fetch_inherited(id);
|
return fetch_inherited(id);
|
||||||
|
if (value->is_unset()) {
|
||||||
|
if (is_inherited_property(id)) {
|
||||||
|
return fetch_inherited(id);
|
||||||
|
} else {
|
||||||
|
return fetch_initial(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,6 +219,7 @@ public:
|
||||||
Invalid,
|
Invalid,
|
||||||
Inherit,
|
Inherit,
|
||||||
Initial,
|
Initial,
|
||||||
|
Unset,
|
||||||
String,
|
String,
|
||||||
Length,
|
Length,
|
||||||
Color,
|
Color,
|
||||||
|
@ -245,6 +246,7 @@ public:
|
||||||
|
|
||||||
bool is_inherit() const { return type() == Type::Inherit; }
|
bool is_inherit() const { return type() == Type::Inherit; }
|
||||||
bool is_initial() const { return type() == Type::Initial; }
|
bool is_initial() const { return type() == Type::Initial; }
|
||||||
|
bool is_unset() const { return type() == Type::Unset; }
|
||||||
bool is_color() const { return type() == Type::Color; }
|
bool is_color() const { return type() == Type::Color; }
|
||||||
bool is_identifier() const { return type() == Type::Identifier || is_auto(); }
|
bool is_identifier() const { return type() == Type::Identifier || is_auto(); }
|
||||||
bool is_image() const { return type() == Type::Image; }
|
bool is_image() const { return type() == Type::Image; }
|
||||||
|
@ -266,11 +268,11 @@ public:
|
||||||
bool is_overflow() const { return type() == Type::Overflow; }
|
bool is_overflow() const { return type() == Type::Overflow; }
|
||||||
bool is_text_decoration() const { return type() == Type::TextDecoration; }
|
bool is_text_decoration() const { return type() == Type::TextDecoration; }
|
||||||
|
|
||||||
bool is_builtin() const { return is_inherit() || is_initial(); }
|
bool is_builtin() const { return is_inherit() || is_initial() || is_unset(); }
|
||||||
|
|
||||||
bool is_builtin_or_dynamic() const
|
bool is_builtin_or_dynamic() const
|
||||||
{
|
{
|
||||||
return is_inherit() || is_initial() || is_custom_property() || is_calculated();
|
return is_builtin() || is_custom_property() || is_calculated();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual String to_string() const = 0;
|
virtual String to_string() const = 0;
|
||||||
|
@ -568,6 +570,24 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class UnsetStyleValue final : public StyleValue {
|
||||||
|
public:
|
||||||
|
static NonnullRefPtr<UnsetStyleValue> the()
|
||||||
|
{
|
||||||
|
static NonnullRefPtr<UnsetStyleValue> instance = adopt_ref(*new UnsetStyleValue);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
virtual ~UnsetStyleValue() override { }
|
||||||
|
|
||||||
|
String to_string() const override { return "unset"; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
UnsetStyleValue()
|
||||||
|
: StyleValue(Type::Unset)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class ColorStyleValue : public StyleValue {
|
class ColorStyleValue : public StyleValue {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<ColorStyleValue> create(Color color)
|
static NonnullRefPtr<ColorStyleValue> create(Color color)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue