mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb: Apply the word-spacing css property to Node
This will let us start to begin applying this during text shaping.
This commit is contained in:
parent
e4533e5595
commit
da42c19cb6
Notes:
github-actions[bot]
2024-10-22 12:37:23 +00:00
Author: https://github.com/kostyafarber
Commit: da42c19cb6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1860
Reviewed-by: https://github.com/AtkinsSJ ✅
4 changed files with 25 additions and 0 deletions
|
@ -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::LengthOrCalculated word_spacing() { return CSS::Length::make_px(0); }
|
||||
static Variant<LengthOrCalculated, NumberOrCalculated> tab_size() { return NumberOrCalculated(8.0f); }
|
||||
static CSS::TextAlign text_align() { return CSS::TextAlign::Start; }
|
||||
static CSS::TextJustify text_justify() { return CSS::TextJustify::Auto; }
|
||||
|
@ -387,6 +388,7 @@ public:
|
|||
Vector<ShadowData> 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; }
|
||||
CSS::LengthOrCalculated word_spacing() const { return m_inherited.word_spacing; }
|
||||
CSS::FlexDirection flex_direction() const { return m_noninherited.flex_direction; }
|
||||
CSS::FlexWrap flex_wrap() const { return m_noninherited.flex_wrap; }
|
||||
FlexBasis const& flex_basis() const { return m_noninherited.flex_basis; }
|
||||
|
@ -547,6 +549,7 @@ protected:
|
|||
CSS::TextTransform text_transform { InitialValues::text_transform() };
|
||||
CSS::LengthPercentage text_indent { InitialValues::text_indent() };
|
||||
CSS::WhiteSpace white_space { InitialValues::white_space() };
|
||||
CSS::LengthOrCalculated word_spacing { InitialValues::word_spacing() };
|
||||
CSS::ListStyleType list_style_type { InitialValues::list_style_type() };
|
||||
CSS::ListStylePosition list_style_position { InitialValues::list_style_position() };
|
||||
CSS::Visibility visibility { InitialValues::visibility() };
|
||||
|
@ -721,6 +724,7 @@ public:
|
|||
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; }
|
||||
void set_word_spacing(CSS::LengthOrCalculated value) { m_inherited.word_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; }
|
||||
void set_max_width(CSS::Size const& width) { m_noninherited.max_width = width; }
|
||||
|
|
|
@ -702,6 +702,22 @@ Variant<LengthOrCalculated, NumberOrCalculated> StyleProperties::tab_size() cons
|
|||
return NumberOrCalculated { value->as_number().number() };
|
||||
}
|
||||
|
||||
Optional<CSS::LengthOrCalculated> StyleProperties::word_spacing() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::WordSpacing);
|
||||
if (value->is_math()) {
|
||||
auto& math_value = value->as_math();
|
||||
if (math_value.resolves_to_length()) {
|
||||
return LengthOrCalculated { math_value };
|
||||
}
|
||||
}
|
||||
|
||||
if (value->is_length())
|
||||
return LengthOrCalculated { value->as_length().length() };
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<CSS::WhiteSpace> StyleProperties::white_space() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::WhiteSpace);
|
||||
|
|
|
@ -115,6 +115,7 @@ public:
|
|||
Optional<CSS::Cursor> cursor() const;
|
||||
Variant<LengthOrCalculated, NumberOrCalculated> tab_size() const;
|
||||
Optional<CSS::WhiteSpace> white_space() const;
|
||||
Optional<CSS::LengthOrCalculated> word_spacing() const;
|
||||
Optional<CSS::LineStyle> line_style(CSS::PropertyID) const;
|
||||
Optional<CSS::OutlineStyle> outline_style() const;
|
||||
Vector<CSS::TextDecorationLine> text_decoration_line() const;
|
||||
|
|
|
@ -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_spacing = computed_style.word_spacing();
|
||||
if (word_spacing.has_value())
|
||||
computed_values.set_word_spacing(word_spacing.value());
|
||||
|
||||
auto float_ = computed_style.float_();
|
||||
if (float_.has_value())
|
||||
computed_values.set_float(float_.value());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue