diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 9610c78b80f..e87a5888ea9 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -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, + pub background_and_borders: LinkedList, /// Borders and backgrounds for block-level descendants: step 4. - pub block_backgrounds_and_borders: SerializableLinkedList, + pub block_backgrounds_and_borders: LinkedList, /// Floats: step 5. These are treated as pseudo-stacking contexts. - pub floats: SerializableLinkedList, + pub floats: LinkedList, /// All non-positioned content. - pub content: SerializableLinkedList, + pub content: LinkedList, /// All positioned content that does not get a stacking context. - pub positioned_content: SerializableLinkedList, + pub positioned_content: LinkedList, /// Outlines: step 10. - pub outlines: SerializableLinkedList, + pub outlines: LinkedList, /// Child stacking contexts. - pub children: SerializableLinkedList>, + pub children: LinkedList>, } 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 diff --git a/components/util/linked_list.rs b/components/util/linked_list.rs index bf20f434d54..5114f02c0e4 100644 --- a/components/util/linked_list.rs +++ b/components/util/linked_list.rs @@ -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(LinkedList); - -impl SerializableLinkedList { - pub fn new(linked_list: LinkedList) -> SerializableLinkedList { - SerializableLinkedList(linked_list) - } -} - -impl Deref for SerializableLinkedList { - type Target = LinkedList; - - fn deref(&self) -> &LinkedList { - &self.0 - } -} - -impl DerefMut for SerializableLinkedList { - fn deref_mut(&mut self) -> &mut LinkedList { - &mut self.0 - } -} - -impl HeapSizeOf for SerializableLinkedList { - fn heap_size_of_children(&self) -> usize { - self.0.heap_size_of_children() - } -} - -impl Serialize for SerializableLinkedList where T: Serialize { - fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer { - serializer.visit_seq(SeqIteratorVisitor::new(self.0.iter(), Some(self.0.len()))) - } -} - -impl Deserialize for SerializableLinkedList where T: Deserialize { - fn deserialize(deserializer: &mut D) -> Result, D::Error> - where D: Deserializer { - struct SerializableLinkedListVisitor { - marker: PhantomData, - } - - impl Visitor for SerializableLinkedListVisitor where T: Deserialize { - type Value = SerializableLinkedList; - - #[inline] - fn visit_seq(&mut self, mut visitor: V) - -> Result, 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(list: &mut LinkedList) -> LinkedList {