mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:17:35 +00:00
LibWeb: Implement and use TextDecorationStyleValue
Modified text-decoration.html to better test that the values can be in any order, and that it adopts the color from the `color` property if no decoration color is specified. Right now, it always does because we do not support a different decoration color. Later, we need to support the `currentcolor` special CSS value for this purpose.
This commit is contained in:
parent
0e15561df0
commit
44a082391b
5 changed files with 132 additions and 90 deletions
|
@ -233,6 +233,7 @@ public:
|
|||
BoxShadow,
|
||||
Font,
|
||||
ListStyle,
|
||||
TextDecoration,
|
||||
};
|
||||
|
||||
Type type() const { return m_type; }
|
||||
|
@ -253,6 +254,7 @@ public:
|
|||
bool is_box_shadow() const { return type() == Type::BoxShadow; }
|
||||
bool is_font() const { return type() == Type::Font; }
|
||||
bool is_list_style() const { return type() == Type::ListStyle; }
|
||||
bool is_text_decoration() const { return type() == Type::TextDecoration; }
|
||||
|
||||
bool is_builtin() const { return is_inherit() || is_initial(); }
|
||||
|
||||
|
@ -756,6 +758,43 @@ private:
|
|||
NonnullRefPtr<StyleValue> m_style_type;
|
||||
};
|
||||
|
||||
class TextDecorationStyleValue final : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<TextDecorationStyleValue> create(
|
||||
NonnullRefPtr<StyleValue> line,
|
||||
NonnullRefPtr<StyleValue> style,
|
||||
NonnullRefPtr<StyleValue> color)
|
||||
{
|
||||
return adopt_ref(*new TextDecorationStyleValue(line, style, color));
|
||||
}
|
||||
virtual ~TextDecorationStyleValue() override { }
|
||||
|
||||
NonnullRefPtr<StyleValue> line() const { return m_line; }
|
||||
NonnullRefPtr<StyleValue> style() const { return m_style; }
|
||||
NonnullRefPtr<StyleValue> color() const { return m_color; }
|
||||
|
||||
virtual String to_string() const override
|
||||
{
|
||||
return String::formatted("TextDecoration line: {}, style: {}, color: {}", m_line->to_string(), m_style->to_string(), m_color->to_string());
|
||||
}
|
||||
|
||||
private:
|
||||
TextDecorationStyleValue(
|
||||
NonnullRefPtr<StyleValue> line,
|
||||
NonnullRefPtr<StyleValue> style,
|
||||
NonnullRefPtr<StyleValue> color)
|
||||
: StyleValue(Type::TextDecoration)
|
||||
, m_line(line)
|
||||
, m_style(style)
|
||||
, m_color(color)
|
||||
{
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue> m_line;
|
||||
NonnullRefPtr<StyleValue> m_style;
|
||||
NonnullRefPtr<StyleValue> m_color;
|
||||
};
|
||||
|
||||
class StyleValueList final : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<StyleValueList> create(NonnullRefPtrVector<StyleValue>&& values) { return adopt_ref(*new StyleValueList(move(values))); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue