Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send display lists over IPC in multiprocess mode. #6795

Merged
merged 6 commits into from Jul 31, 2015

util: Remove the old broken `SerializableLinkedList` code in favor of

serde's native implementation.
  • Loading branch information
pcwalton committed Jul 31, 2015
commit f041e1aa6082c2d84a3d016992aeb769c0e23e98
@@ -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,68 +84,68 @@ 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 {
/// Creates a new, empty display list.
#[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(),
}
}

/// Appends all display items from `other` into `self`, preserving stacking order and emptying
/// `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> {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.