LibWeb: Prevent time-traveling leading inline metrics
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

In `InlineLevelIterator`, whenever we call `skip_to_next()` and enter a
node with box model metrics, we could potentially accumulate leading and
trailing metrics. This lead to a weird situation where an element with
`display: inline-block` could adopt the leading metrics of an inline
element that follows it, since we perform the call to
`add_extra_box_model_metrics_to_item()` too late.

Move `skip_to_next()` down so it no longer interferes with the `Item`
we're creating.

The test expectation for
`atomic-inline-with-percentage-vertical-align.html` is updated, although
neither the old nor new results are 100% accurate since either box jumps
one pixel to the right.
This commit is contained in:
Jelle Raaijmakers 2025-06-20 00:40:15 +02:00 committed by Alexander Kalenik
commit 30efcd0d00
Notes: github-actions[bot] 2025-06-20 18:00:38 +00:00
4 changed files with 114 additions and 7 deletions

View file

@ -620,7 +620,6 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::next_without_lookahead(
auto& box_state = m_layout_state.get(box);
m_inline_formatting_context.dimension_box_on_line(box, m_layout_mode);
skip_to_next();
auto item = Item {
.type = Item::Type::Element,
.node = &box,
@ -635,6 +634,7 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::next_without_lookahead(
.margin_end = box_state.margin_right,
};
add_extra_box_model_metrics_to_item(item, true, true);
skip_to_next();
return item;
}