mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Replace append_from and prepend_from with DList::append
This commit is contained in:
parent
29d24a5049
commit
76a2653f8f
2 changed files with 8 additions and 56 deletions
|
@ -109,14 +109,12 @@ impl DisplayList {
|
||||||
/// `other` in the process.
|
/// `other` in the process.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn append_from(&mut self, other: &mut DisplayList) {
|
pub fn append_from(&mut self, other: &mut DisplayList) {
|
||||||
servo_dlist::append_from(&mut self.background_and_borders,
|
self.background_and_borders.append(&mut other.background_and_borders);
|
||||||
&mut other.background_and_borders);
|
self.block_backgrounds_and_borders.append(&mut other.block_backgrounds_and_borders);
|
||||||
servo_dlist::append_from(&mut self.block_backgrounds_and_borders,
|
self.floats.append(&mut other.floats);
|
||||||
&mut other.block_backgrounds_and_borders);
|
self.content.append(&mut other.content);
|
||||||
servo_dlist::append_from(&mut self.floats, &mut other.floats);
|
self.outlines.append(&mut other.outlines);
|
||||||
servo_dlist::append_from(&mut self.content, &mut other.content);
|
self.children.append(&mut other.children);
|
||||||
servo_dlist::append_from(&mut self.outlines, &mut other.outlines);
|
|
||||||
servo_dlist::append_from(&mut self.children, &mut other.children);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merges all display items from all non-float stacking levels to the `float` stacking level.
|
/// Merges all display items from all non-float stacking levels to the `float` stacking level.
|
||||||
|
|
|
@ -71,55 +71,9 @@ pub fn split<T>(list: &mut DList<T>) -> DList<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Appends the items in the other list to this one, leaving the other list empty.
|
|
||||||
#[inline]
|
|
||||||
pub fn append_from<T>(this: &mut DList<T>, other: &mut DList<T>) {
|
|
||||||
unsafe {
|
|
||||||
let this = mem::transmute::<&mut DList<T>,&mut RawDList<T>>(this);
|
|
||||||
let other = mem::transmute::<&mut DList<T>,&mut RawDList<T>>(other);
|
|
||||||
if this.length == 0 {
|
|
||||||
this.head = mem::replace(&mut other.head, ptr::null_mut());
|
|
||||||
this.tail = mem::replace(&mut other.tail, ptr::null_mut());
|
|
||||||
this.length = mem::replace(&mut other.length, 0);
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let old_other_head = mem::replace(&mut other.head, ptr::null_mut());
|
|
||||||
if old_other_head.is_null() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
(*old_other_head).prev = this.tail;
|
|
||||||
(*this.tail).next = old_other_head;
|
|
||||||
|
|
||||||
this.tail = mem::replace(&mut other.tail, ptr::null_mut());
|
|
||||||
this.length += other.length;
|
|
||||||
other.length = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Prepends the items in the other list to this one, leaving the other list empty.
|
/// Prepends the items in the other list to this one, leaving the other list empty.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn prepend_from<T>(this: &mut DList<T>, other: &mut DList<T>) {
|
pub fn prepend_from<T>(this: &mut DList<T>, other: &mut DList<T>) {
|
||||||
unsafe {
|
other.append(this);
|
||||||
let this = mem::transmute::<&mut DList<T>,&mut RawDList<T>>(this);
|
mem::swap(this, other);
|
||||||
let other = mem::transmute::<&mut DList<T>,&mut RawDList<T>>(other);
|
|
||||||
if this.length == 0 {
|
|
||||||
this.head = mem::replace(&mut other.head, ptr::null_mut());
|
|
||||||
this.tail = mem::replace(&mut other.tail, ptr::null_mut());
|
|
||||||
this.length = mem::replace(&mut other.length, 0);
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let old_other_tail = mem::replace(&mut other.tail, ptr::null_mut());
|
|
||||||
if old_other_tail.is_null() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
(*old_other_tail).next = this.head;
|
|
||||||
(*this.head).prev = old_other_tail;
|
|
||||||
|
|
||||||
this.head = mem::replace(&mut other.head, ptr::null_mut());
|
|
||||||
this.length += other.length;
|
|
||||||
other.length = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue