mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
util: Remove the old broken SerializableLinkedList
code in favor of
serde's native implementation.
This commit is contained in:
parent
ef9fdc6e30
commit
f041e1aa60
2 changed files with 32 additions and 105 deletions
|
@ -42,7 +42,7 @@ use style::computed_values::{pointer_events};
|
|||
use style::properties::ComputedValues;
|
||||
use util::cursor::Cursor;
|
||||
use util::geometry::{self, Au, MAX_RECT, ZERO_RECT};
|
||||
use util::linked_list::{SerializableLinkedList, prepend_from};
|
||||
use util::linked_list::prepend_from;
|
||||
use util::mem::HeapSizeOf;
|
||||
use util::opts;
|
||||
use util::range::Range;
|
||||
|
@ -84,19 +84,19 @@ impl OpaqueNode {
|
|||
#[derive(HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct DisplayList {
|
||||
/// The border and backgrounds for the root of this stacking context: steps 1 and 2.
|
||||
pub background_and_borders: SerializableLinkedList<DisplayItem>,
|
||||
pub background_and_borders: LinkedList<DisplayItem>,
|
||||
/// Borders and backgrounds for block-level descendants: step 4.
|
||||
pub block_backgrounds_and_borders: SerializableLinkedList<DisplayItem>,
|
||||
pub block_backgrounds_and_borders: LinkedList<DisplayItem>,
|
||||
/// Floats: step 5. These are treated as pseudo-stacking contexts.
|
||||
pub floats: SerializableLinkedList<DisplayItem>,
|
||||
pub floats: LinkedList<DisplayItem>,
|
||||
/// All non-positioned content.
|
||||
pub content: SerializableLinkedList<DisplayItem>,
|
||||
pub content: LinkedList<DisplayItem>,
|
||||
/// All positioned content that does not get a stacking context.
|
||||
pub positioned_content: SerializableLinkedList<DisplayItem>,
|
||||
pub positioned_content: LinkedList<DisplayItem>,
|
||||
/// Outlines: step 10.
|
||||
pub outlines: SerializableLinkedList<DisplayItem>,
|
||||
pub outlines: LinkedList<DisplayItem>,
|
||||
/// Child stacking contexts.
|
||||
pub children: SerializableLinkedList<Arc<StackingContext>>,
|
||||
pub children: LinkedList<Arc<StackingContext>>,
|
||||
}
|
||||
|
||||
impl DisplayList {
|
||||
|
@ -104,13 +104,13 @@ impl DisplayList {
|
|||
#[inline]
|
||||
pub fn new() -> DisplayList {
|
||||
DisplayList {
|
||||
background_and_borders: SerializableLinkedList::new(LinkedList::new()),
|
||||
block_backgrounds_and_borders: SerializableLinkedList::new(LinkedList::new()),
|
||||
floats: SerializableLinkedList::new(LinkedList::new()),
|
||||
content: SerializableLinkedList::new(LinkedList::new()),
|
||||
positioned_content: SerializableLinkedList::new(LinkedList::new()),
|
||||
outlines: SerializableLinkedList::new(LinkedList::new()),
|
||||
children: SerializableLinkedList::new(LinkedList::new()),
|
||||
background_and_borders: LinkedList::new(),
|
||||
block_backgrounds_and_borders: LinkedList::new(),
|
||||
floats: LinkedList::new(),
|
||||
content: LinkedList::new(),
|
||||
positioned_content: LinkedList::new(),
|
||||
outlines: LinkedList::new(),
|
||||
children: LinkedList::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,34 +118,34 @@ impl DisplayList {
|
|||
/// `other` in the process.
|
||||
#[inline]
|
||||
pub fn append_from(&mut self, other: &mut DisplayList) {
|
||||
self.background_and_borders.append(&mut *other.background_and_borders);
|
||||
self.block_backgrounds_and_borders.append(&mut *other.block_backgrounds_and_borders);
|
||||
self.floats.append(&mut *other.floats);
|
||||
self.content.append(&mut *other.content);
|
||||
self.positioned_content.append(&mut *other.positioned_content);
|
||||
self.outlines.append(&mut *other.outlines);
|
||||
self.children.append(&mut *other.children);
|
||||
self.background_and_borders.append(&mut other.background_and_borders);
|
||||
self.block_backgrounds_and_borders.append(&mut other.block_backgrounds_and_borders);
|
||||
self.floats.append(&mut other.floats);
|
||||
self.content.append(&mut other.content);
|
||||
self.positioned_content.append(&mut other.positioned_content);
|
||||
self.outlines.append(&mut other.outlines);
|
||||
self.children.append(&mut other.children);
|
||||
}
|
||||
|
||||
/// Merges all display items from all non-float stacking levels to the `float` stacking level.
|
||||
#[inline]
|
||||
pub fn form_float_pseudo_stacking_context(&mut self) {
|
||||
prepend_from(&mut *self.floats, &mut *self.outlines);
|
||||
prepend_from(&mut *self.floats, &mut *self.positioned_content);
|
||||
prepend_from(&mut *self.floats, &mut *self.content);
|
||||
prepend_from(&mut *self.floats, &mut *self.block_backgrounds_and_borders);
|
||||
prepend_from(&mut *self.floats, &mut *self.background_and_borders);
|
||||
prepend_from(&mut self.floats, &mut self.outlines);
|
||||
prepend_from(&mut self.floats, &mut self.positioned_content);
|
||||
prepend_from(&mut self.floats, &mut self.content);
|
||||
prepend_from(&mut self.floats, &mut self.block_backgrounds_and_borders);
|
||||
prepend_from(&mut self.floats, &mut self.background_and_borders);
|
||||
}
|
||||
|
||||
/// Merges all display items from all non-positioned-content stacking levels to the
|
||||
/// positioned-content stacking level.
|
||||
#[inline]
|
||||
pub fn form_pseudo_stacking_context_for_positioned_content(&mut self) {
|
||||
prepend_from(&mut *self.positioned_content, &mut *self.outlines);
|
||||
prepend_from(&mut *self.positioned_content, &mut *self.content);
|
||||
prepend_from(&mut *self.positioned_content, &mut *self.floats);
|
||||
prepend_from(&mut *self.positioned_content, &mut *self.block_backgrounds_and_borders);
|
||||
prepend_from(&mut *self.positioned_content, &mut *self.background_and_borders);
|
||||
prepend_from(&mut self.positioned_content, &mut self.outlines);
|
||||
prepend_from(&mut self.positioned_content, &mut self.content);
|
||||
prepend_from(&mut self.positioned_content, &mut self.floats);
|
||||
prepend_from(&mut self.positioned_content, &mut self.block_backgrounds_and_borders);
|
||||
prepend_from(&mut self.positioned_content, &mut self.background_and_borders);
|
||||
}
|
||||
|
||||
/// Returns a list of all items in this display list concatenated together. This is extremely
|
||||
|
|
|
@ -4,81 +4,8 @@
|
|||
|
||||
//! Utility functions for doubly-linked lists.
|
||||
|
||||
use mem::HeapSizeOf;
|
||||
|
||||
use serde::de::{Error, SeqVisitor, Visitor};
|
||||
use serde::ser::impls::SeqIteratorVisitor;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::collections::LinkedList;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
pub struct SerializableLinkedList<T>(LinkedList<T>);
|
||||
|
||||
impl<T> SerializableLinkedList<T> {
|
||||
pub fn new(linked_list: LinkedList<T>) -> SerializableLinkedList<T> {
|
||||
SerializableLinkedList(linked_list)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for SerializableLinkedList<T> {
|
||||
type Target = LinkedList<T>;
|
||||
|
||||
fn deref(&self) -> &LinkedList<T> {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> DerefMut for SerializableLinkedList<T> {
|
||||
fn deref_mut(&mut self) -> &mut LinkedList<T> {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: HeapSizeOf> HeapSizeOf for SerializableLinkedList<T> {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
self.0.heap_size_of_children()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Serialize for SerializableLinkedList<T> where T: Serialize {
|
||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer {
|
||||
serializer.visit_seq(SeqIteratorVisitor::new(self.0.iter(), Some(self.0.len())))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deserialize for SerializableLinkedList<T> where T: Deserialize {
|
||||
fn deserialize<D>(deserializer: &mut D) -> Result<SerializableLinkedList<T>, D::Error>
|
||||
where D: Deserializer {
|
||||
struct SerializableLinkedListVisitor<T> {
|
||||
marker: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T> Visitor for SerializableLinkedListVisitor<T> where T: Deserialize {
|
||||
type Value = SerializableLinkedList<T>;
|
||||
|
||||
#[inline]
|
||||
fn visit_seq<V>(&mut self, mut visitor: V)
|
||||
-> Result<SerializableLinkedList<T>, V::Error>
|
||||
where V: SeqVisitor {
|
||||
let mut list = LinkedList::new();
|
||||
for _ in 0..visitor.size_hint().0 {
|
||||
match try!(visitor.visit()) {
|
||||
Some(element) => list.push_back(element),
|
||||
None => return Err(Error::end_of_stream_error()),
|
||||
}
|
||||
}
|
||||
try!(visitor.end());
|
||||
Ok(SerializableLinkedList(list))
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.visit_seq(SerializableLinkedListVisitor {
|
||||
marker: PhantomData,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Splits the head off a list in O(1) time, and returns the head.
|
||||
pub fn split_off_head<T>(list: &mut LinkedList<T>) -> LinkedList<T> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue