mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-04 23:29:52 +00:00
LibWeb: Support percentages in word-spacing
Fixes crash in the created test as well as https://wpt.live/css/css-text /word-spacing/reference/word-spacing-percent-001-ref.html. The WPT test hasn't been imported as it passing is currently a false-positive due to the fact that we don't yet respect `word-spacing` in most cases.
This commit is contained in:
parent
62cf33b98e
commit
a70a397501
Notes:
github-actions[bot]
2025-08-05 10:45:07 +00:00
Author: https://github.com/Calme1709
Commit: a70a397501
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5715
Reviewed-by: https://github.com/tcl3 ✅
5 changed files with 25 additions and 15 deletions
|
@ -839,20 +839,22 @@ WordBreak ComputedProperties::word_break() const
|
|||
return keyword_to_word_break(value.to_keyword()).release_value();
|
||||
}
|
||||
|
||||
Optional<LengthOrCalculated> ComputedProperties::word_spacing() const
|
||||
Optional<LengthPercentage> ComputedProperties::word_spacing() const
|
||||
{
|
||||
auto const& value = property(PropertyID::WordSpacing);
|
||||
if (value.is_calculated()) {
|
||||
auto& math_value = value.as_calculated();
|
||||
if (math_value.resolves_to_length()) {
|
||||
return LengthOrCalculated { math_value };
|
||||
}
|
||||
}
|
||||
if (value.is_keyword() && value.to_keyword() == Keyword::Normal)
|
||||
return LengthPercentage { Length::make_px(0) };
|
||||
|
||||
if (value.is_length())
|
||||
return LengthOrCalculated { value.as_length().length() };
|
||||
return LengthPercentage(value.as_length().length());
|
||||
|
||||
return {};
|
||||
if (value.is_percentage())
|
||||
return LengthPercentage(value.as_percentage().percentage());
|
||||
|
||||
if (value.is_calculated())
|
||||
return LengthPercentage { value.as_calculated() };
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
WhiteSpaceCollapse ComputedProperties::white_space_collapse() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue