diff --git a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt index f3362313d74..653e1b5d91e 100644 --- a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt +++ b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt @@ -44,6 +44,7 @@ text-shadow: none text-transform: none visibility: visible white-space: normal +word-break: normal word-spacing: normal word-wrap: normal align-content: normal @@ -119,7 +120,7 @@ grid-row-start: auto grid-template-areas: none grid-template-columns: auto grid-template-rows: auto -height: 2057px +height: 2074px inline-size: auto inset-block-end: auto inset-block-start: auto diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index c0f2071fcf0..44f35f2651c 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -105,6 +105,7 @@ public: static CSS::ContentVisibility content_visibility() { return CSS::ContentVisibility::Visible; } static CSS::Cursor cursor() { return CSS::Cursor::Auto; } static CSS::WhiteSpace white_space() { return CSS::WhiteSpace::Normal; } + static CSS::WordBreak word_break() { return CSS::WordBreak::Normal; } static CSS::LengthOrCalculated word_spacing() { return CSS::Length::make_px(0); } static LengthOrCalculated letter_spacing() { return CSS::Length::make_px(0); } static Variant tab_size() { return NumberOrCalculated(8.0f); } @@ -551,6 +552,7 @@ protected: CSS::TextTransform text_transform { InitialValues::text_transform() }; CSS::LengthPercentage text_indent { InitialValues::text_indent() }; CSS::WhiteSpace white_space { InitialValues::white_space() }; + CSS::WordBreak word_break { InitialValues::word_break() }; CSS::LengthOrCalculated word_spacing { InitialValues::word_spacing() }; LengthOrCalculated letter_spacing { InitialValues::letter_spacing() }; CSS::ListStyleType list_style_type { InitialValues::list_style_type() }; @@ -728,6 +730,7 @@ public: void set_position(CSS::Positioning position) { m_noninherited.position = position; } void set_white_space(CSS::WhiteSpace value) { m_inherited.white_space = value; } void set_word_spacing(CSS::LengthOrCalculated value) { m_inherited.word_spacing = value; } + void set_word_break(CSS::WordBreak value) { m_inherited.word_break = value; } void set_letter_spacing(CSS::LengthOrCalculated value) { m_inherited.letter_spacing = value; } void set_width(CSS::Size const& width) { m_noninherited.width = width; } void set_min_width(CSS::Size const& width) { m_noninherited.min_width = width; } diff --git a/Userland/Libraries/LibWeb/CSS/Enums.json b/Userland/Libraries/LibWeb/CSS/Enums.json index d5f04f7181a..c4127a92c83 100644 --- a/Userland/Libraries/LibWeb/CSS/Enums.json +++ b/Userland/Libraries/LibWeb/CSS/Enums.json @@ -499,5 +499,11 @@ "pre", "pre-line", "pre-wrap" + ], + "word-break": [ + "normal", + "keep-all", + "break-all", + "break-word" ] } diff --git a/Userland/Libraries/LibWeb/CSS/Keywords.json b/Userland/Libraries/LibWeb/CSS/Keywords.json index 9f5f76da19f..52497552f98 100644 --- a/Userland/Libraries/LibWeb/CSS/Keywords.json +++ b/Userland/Libraries/LibWeb/CSS/Keywords.json @@ -88,6 +88,7 @@ "both", "both-edges", "bottom", + "break-all", "break-word", "browser", "butt", @@ -215,6 +216,7 @@ "jump-none", "jump-start", "justify", + "keep-all", "landscape", "large", "larger", diff --git a/Userland/Libraries/LibWeb/CSS/Properties.json b/Userland/Libraries/LibWeb/CSS/Properties.json index 55d603ca048..5da4f76d11f 100644 --- a/Userland/Libraries/LibWeb/CSS/Properties.json +++ b/Userland/Libraries/LibWeb/CSS/Properties.json @@ -2723,6 +2723,17 @@ "unitless-length" ] }, + "word-break": { + "animation-type": "discrete", + "initial": "normal", + "inherited": true, + "valid-identifiers": [ + "normal", + "keep-all", + "break-all", + "break-word" + ] + }, "word-spacing": { "animation-type": "by-computed-value", "inherited": true, diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 8014d53f11f..d06bc029a81 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -702,6 +702,12 @@ Variant StyleProperties::tab_size() cons return NumberOrCalculated { value->as_number().number() }; } +Optional StyleProperties::word_break() const +{ + auto value = property(CSS::PropertyID::WordBreak); + return keyword_to_word_break(value->to_keyword()); +} + Optional StyleProperties::word_spacing() const { auto value = property(CSS::PropertyID::WordSpacing); diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h index f7581529570..1e4a31af5bb 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h @@ -115,6 +115,7 @@ public: Optional cursor() const; Variant tab_size() const; Optional white_space() const; + Optional word_break() const; Optional word_spacing() const; Optional letter_spacing() const; Optional line_style(CSS::PropertyID) const; diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 92611611440..fa2046a47c9 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -598,6 +598,10 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style) if (white_space.has_value()) computed_values.set_white_space(white_space.value()); + auto word_break = computed_style.word_break(); + if (word_break.has_value()) + computed_values.set_word_break(word_break.value()); + auto word_spacing = computed_style.word_spacing(); if (word_spacing.has_value()) computed_values.set_word_spacing(word_spacing.value());