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:
Callum Law 2025-08-02 00:07:48 +12:00 committed by Tim Ledbetter
commit a70a397501
Notes: github-actions[bot] 2025-08-05 10:45:07 +00:00
5 changed files with 25 additions and 15 deletions

View file

@ -528,7 +528,8 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::next_without_lookahead(
CSS::CalculationResolutionContext calculation_context { .length_resolution_context = CSS::Length::ResolutionContext::for_layout_node(text_node) };
auto letter_spacing = text_node.computed_values().letter_spacing().resolved(calculation_context).map([&](auto& it) { return it.to_px(text_node); }).value_or(0);
auto word_spacing = text_node.computed_values().word_spacing().resolved(calculation_context).map([&](auto& it) { return it.to_px(text_node); }).value_or(0);
// FIXME: We should apply word spacing to all word-separator characters not just breaking tabs
auto word_spacing = text_node.computed_values().word_spacing().resolved(text_node, CSS::Length::make_px(chunk.font->glyph_width(' ')).to_px(text_node)).absolute_length_to_px();
auto x = 0.0f;
if (chunk.has_breaking_tab) {