mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix meld_with_next_inline_fragment and add meld_with_prev_inline_fragment
Factor out a new `meld_with_prev_inline_fragment` method that mirrors the existing `meld_with_next_inline_fragment`. This also fixes a bug in `meld_with_next` that was already fixed in the `meld_with_prev` by @notriddle in #10419. The bug is that it was traversing the inline context nodes in the wrong order. It should start at the outermost enclosing node, since the fragments might be at different nesting levels under some common ancestor.
This commit is contained in:
parent
587314e52b
commit
b607b3a932
2 changed files with 32 additions and 30 deletions
|
@ -1779,28 +1779,7 @@ pub fn strip_ignorable_whitespace_from_start(this: &mut LinkedList<Fragment>) {
|
|||
WhitespaceStrippingResult::FragmentContainedOnlyWhitespace => {
|
||||
let removed_fragment = this.pop_front().unwrap();
|
||||
if let Some(ref mut remaining_fragment) = this.front_mut() {
|
||||
if let Some(ref mut inline_context_of_remaining_fragment) =
|
||||
remaining_fragment.inline_context {
|
||||
if let Some(ref inline_context_of_removed_fragment) =
|
||||
removed_fragment.inline_context {
|
||||
for (inline_context_node_from_removed_fragment,
|
||||
inline_context_node_from_remaining_fragment) in
|
||||
inline_context_of_removed_fragment.nodes.iter().rev().zip(
|
||||
inline_context_of_remaining_fragment.nodes.iter_mut().rev()
|
||||
) {
|
||||
if !inline_context_node_from_removed_fragment.flags.contains(
|
||||
FIRST_FRAGMENT_OF_ELEMENT) {
|
||||
continue
|
||||
}
|
||||
if inline_context_node_from_removed_fragment.address !=
|
||||
inline_context_node_from_remaining_fragment.address {
|
||||
continue
|
||||
}
|
||||
inline_context_node_from_remaining_fragment.flags.insert(
|
||||
FIRST_FRAGMENT_OF_ELEMENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
remaining_fragment.meld_with_prev_inline_fragment(&removed_fragment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue