From 794069b3cfb72b3e6a2c4068b6018a83d7d8432b Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Wed, 24 Jul 2024 20:58:17 +0200 Subject: [PATCH] LibWeb: Add plumbing for new "text-overflow" CSS property This patch adds the new "text-overflow" CSS property to all the relevant places. --- Userland/Libraries/LibWeb/CSS/ComputedValues.h | 4 ++++ Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | 6 ++++++ Userland/Libraries/LibWeb/CSS/StyleProperties.h | 1 + Userland/Libraries/LibWeb/Layout/Node.cpp | 3 +++ 4 files changed, 14 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index 041ccb4066e..82873ef911e 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -111,6 +111,7 @@ public: static CSS::Length text_decoration_thickness() { return Length::make_auto(); } static CSS::TextDecorationStyle text_decoration_style() { return CSS::TextDecorationStyle::Solid; } static CSS::TextTransform text_transform() { return CSS::TextTransform::None; } + static CSS::TextOverflow text_overflow() { return CSS::TextOverflow::Clip; } static CSS::LengthPercentage text_indent() { return CSS::Length::make_px(0); } static CSS::Display display() { return CSS::Display { CSS::DisplayOutside::Inline, CSS::DisplayInside::Flow }; } static Color color() { return Color::Black; } @@ -374,6 +375,7 @@ public: CSS::TextDecorationStyle text_decoration_style() const { return m_noninherited.text_decoration_style; } Color text_decoration_color() const { return m_noninherited.text_decoration_color; } CSS::TextTransform text_transform() const { return m_inherited.text_transform; } + CSS::TextOverflow text_overflow() const { return m_noninherited.text_overflow; } Vector const& text_shadow() const { return m_inherited.text_shadow; } CSS::Positioning position() const { return m_noninherited.position; } CSS::WhiteSpace white_space() const { return m_inherited.white_space; } @@ -558,6 +560,7 @@ protected: CSS::LengthPercentage text_decoration_thickness { InitialValues::text_decoration_thickness() }; CSS::TextDecorationStyle text_decoration_style { InitialValues::text_decoration_style() }; Color text_decoration_color { InitialValues::color() }; + CSS::TextOverflow text_overflow { InitialValues::text_overflow() }; CSS::Positioning position { InitialValues::position() }; CSS::Size width { InitialValues::width() }; CSS::Size min_width { InitialValues::min_width() }; @@ -685,6 +688,7 @@ public: void set_text_transform(CSS::TextTransform value) { m_inherited.text_transform = value; } void set_text_shadow(Vector&& value) { m_inherited.text_shadow = move(value); } void set_text_indent(CSS::LengthPercentage value) { m_inherited.text_indent = move(value); } + void set_text_overflow(CSS::TextOverflow value) { m_noninherited.text_overflow = value; } void set_webkit_text_fill_color(Color value) { m_inherited.webkit_text_fill_color = value; } void set_position(CSS::Positioning position) { m_noninherited.position = position; } void set_white_space(CSS::WhiteSpace value) { m_inherited.white_space = value; } diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 58d433302d7..cbfd1a69950 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -643,6 +643,12 @@ Optional StyleProperties::text_justify() const return value_id_to_text_justify(value->to_identifier()); } +Optional StyleProperties::text_overflow() const +{ + auto value = property(CSS::PropertyID::TextOverflow); + return value_id_to_text_overflow(value->to_identifier()); +} + Optional StyleProperties::pointer_events() const { auto value = property(CSS::PropertyID::PointerEvents); diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h index a30bf63ec64..ef383b63837 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h @@ -66,6 +66,7 @@ public: Optional text_anchor() const; Optional text_align() const; Optional text_justify() const; + Optional text_overflow() const; CSS::Length border_spacing_horizontal() const; CSS::Length border_spacing_vertical() const; Optional caption_side() const; diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 3a4fce9093e..3221a4af974 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -586,6 +586,9 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style) if (auto text_indent = computed_style.length_percentage(CSS::PropertyID::TextIndent); text_indent.has_value()) computed_values.set_text_indent(text_indent.release_value()); + if (auto text_overflow = computed_style.text_overflow(); text_overflow.has_value()) + computed_values.set_text_overflow(text_overflow.release_value()); + auto white_space = computed_style.white_space(); if (white_space.has_value()) computed_values.set_white_space(white_space.value());