diff options
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/ComputedValues.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp | 19 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | 21 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleProperties.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleValue.h | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/Node.cpp | 4 |
6 files changed, 57 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index b56bf46734..d07c38ee6d 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -21,6 +21,7 @@ public: static CSS::TextAlign text_align() { return CSS::TextAlign::Left; } static CSS::Position position() { return CSS::Position::Static; } static CSS::TextDecorationLine text_decoration_line() { return CSS::TextDecorationLine::None; } + static CSS::TextDecorationStyle text_decoration_style() { return CSS::TextDecorationStyle::Solid; } static CSS::TextTransform text_transform() { return CSS::TextTransform::None; } static CSS::Display display() { return CSS::Display { CSS::Display::Outside::Inline, CSS::Display::Inside::Flow }; } static Color color() { return Color::Black; } @@ -91,6 +92,7 @@ public: Optional<int> const& z_index() const { return m_noninherited.z_index; } CSS::TextAlign text_align() const { return m_inherited.text_align; } CSS::TextDecorationLine text_decoration_line() const { return m_noninherited.text_decoration_line; } + CSS::TextDecorationStyle text_decoration_style() const { return m_noninherited.text_decoration_style; } CSS::TextTransform text_transform() const { return m_inherited.text_transform; } CSS::Position position() const { return m_noninherited.position; } CSS::WhiteSpace white_space() const { return m_inherited.white_space; } @@ -168,6 +170,7 @@ protected: CSS::Display display { InitialValues::display() }; Optional<int> z_index; CSS::TextDecorationLine text_decoration_line { InitialValues::text_decoration_line() }; + CSS::TextDecorationStyle text_decoration_style { InitialValues::text_decoration_style() }; CSS::Position position { InitialValues::position() }; CSS::LengthPercentage width { Length::make_auto() }; CSS::LengthPercentage min_width { Length::make_auto() }; @@ -219,6 +222,7 @@ public: void set_z_index(Optional<int> value) { m_noninherited.z_index = value; } void set_text_align(CSS::TextAlign text_align) { m_inherited.text_align = text_align; } void set_text_decoration_line(CSS::TextDecorationLine value) { m_noninherited.text_decoration_line = value; } + void set_text_decoration_style(CSS::TextDecorationStyle value) { m_noninherited.text_decoration_style = value; } void set_text_transform(CSS::TextTransform value) { m_inherited.text_transform = value; } void set_position(CSS::Position position) { m_noninherited.position = position; } void set_white_space(CSS::WhiteSpace value) { m_inherited.white_space = value; } diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 1d2c2eacbf..e25f1511f9 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -163,6 +163,23 @@ static CSS::ValueID to_css_value_id(CSS::TextDecorationLine value) VERIFY_NOT_REACHED(); } +static CSS::ValueID to_css_value_id(CSS::TextDecorationStyle value) +{ + switch (value) { + case TextDecorationStyle::Solid: + return CSS::ValueID::Solid; + case TextDecorationStyle::Double: + return CSS::ValueID::Double; + case TextDecorationStyle::Dotted: + return CSS::ValueID::Dotted; + case TextDecorationStyle::Dashed: + return CSS::ValueID::Dashed; + case TextDecorationStyle::Wavy: + return CSS::ValueID::Wavy; + } + VERIFY_NOT_REACHED(); +} + static CSS::ValueID to_css_value_id(CSS::Cursor value) { switch (value) { @@ -467,6 +484,8 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout: return IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().text_align())); case CSS::PropertyID::TextDecorationLine: return IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().text_decoration_line())); + case CSS::PropertyID::TextDecorationStyle: + return IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().text_decoration_style())); case CSS::PropertyID::TextTransform: return IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().text_transform())); case CSS::PropertyID::Position: diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index b243510459..e53e9c5b85 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -645,6 +645,27 @@ Optional<CSS::TextDecorationLine> StyleProperties::text_decoration_line() const } } +Optional<CSS::TextDecorationStyle> StyleProperties::text_decoration_style() const +{ + auto value = property(CSS::PropertyID::TextDecorationStyle); + if (!value.has_value()) + return {}; + switch (value.value()->to_identifier()) { + case CSS::ValueID::Solid: + return CSS::TextDecorationStyle::Solid; + case CSS::ValueID::Double: + return CSS::TextDecorationStyle::Double; + case CSS::ValueID::Dotted: + return CSS::TextDecorationStyle::Dotted; + case CSS::ValueID::Dashed: + return CSS::TextDecorationStyle::Dashed; + case CSS::ValueID::Wavy: + return CSS::TextDecorationStyle::Wavy; + default: + return {}; + } +} + Optional<CSS::TextTransform> StyleProperties::text_transform() const { auto value = property(CSS::PropertyID::TextTransform); diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h index 4589dbcf85..777a7a65c5 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h @@ -51,6 +51,7 @@ public: Optional<CSS::WhiteSpace> white_space() const; Optional<CSS::LineStyle> line_style(CSS::PropertyID) const; Optional<CSS::TextDecorationLine> text_decoration_line() const; + Optional<CSS::TextDecorationStyle> text_decoration_style() const; Optional<CSS::TextTransform> text_transform() const; Optional<CSS::ListStyleType> list_style_type() const; Optional<CSS::FlexDirection> flex_direction() const; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 22aa5e88af..95eba86609 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -233,6 +233,14 @@ enum class TextDecorationLine { Blink, }; +enum class TextDecorationStyle { + Solid, + Double, + Dotted, + Dashed, + Wavy, +}; + enum class TextTransform { None, Capitalize, diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 0ca04e8c09..185ede5c06 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -404,6 +404,10 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style) if (text_decoration_line.has_value()) computed_values.set_text_decoration_line(text_decoration_line.value()); + auto text_decoration_style = specified_style.text_decoration_style(); + if (text_decoration_style.has_value()) + computed_values.set_text_decoration_style(text_decoration_style.value()); + auto text_transform = specified_style.text_transform(); if (text_transform.has_value()) computed_values.set_text_transform(text_transform.value()); |