зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #6583 - gfx: Make display lists serializable using `serde` (from pcwalton:serializable-display-list); r=metajack
This commit introduces the `serde` dependency, which we will use to serialize messages going between processes in multiprocess Servo. This also adds a new debugging flag, `-Z print-display-list-json`, allowing the output of display list serialization to be visualized. This will be useful for our experiments with alternate rasterizers. r? @metajack Source-Repo: https://github.com/servo/servo Source-Revision: ef9715203edf0a280d019b6e8823666f0e7020be
This commit is contained in:
Родитель
9717790bd5
Коммит
f2de86fd3c
|
@ -57,6 +57,8 @@ harfbuzz = "0.1"
|
|||
smallvec = "0.1"
|
||||
string_cache = "0.1"
|
||||
euclid = "0.1"
|
||||
serde = "*"
|
||||
serde_macros = "*"
|
||||
|
||||
[target.x86_64-apple-darwin.dependencies]
|
||||
core-foundation = "*"
|
||||
|
|
|
@ -25,28 +25,27 @@ use text::TextRun;
|
|||
|
||||
use azure::azure::AzFloat;
|
||||
use azure::azure_hl::Color;
|
||||
|
||||
use std::collections::linked_list::{self, LinkedList};
|
||||
use euclid::{Point2D, Rect, SideOffsets2D, Size2D, Matrix2D, Matrix4};
|
||||
use euclid::approxeq::ApproxEq;
|
||||
use euclid::num::Zero;
|
||||
use euclid::{Point2D, Rect, SideOffsets2D, Size2D, Matrix2D, Matrix4};
|
||||
use libc::uintptr_t;
|
||||
use paint_task::PaintLayer;
|
||||
use msg::compositor_msg::{LayerId, LayerKind};
|
||||
use net_traits::image::base::Image;
|
||||
use util::opts;
|
||||
use util::cursor::Cursor;
|
||||
use util::linked_list::prepend_from;
|
||||
use util::geometry::{self, Au, MAX_RECT, ZERO_RECT};
|
||||
use util::mem::HeapSizeOf;
|
||||
use util::range::Range;
|
||||
use paint_task::PaintLayer;
|
||||
use smallvec::SmallVec8;
|
||||
use std::collections::linked_list::{self, LinkedList};
|
||||
use std::fmt;
|
||||
use std::slice::Iter;
|
||||
use std::sync::Arc;
|
||||
use style::computed_values::{border_style, cursor, filter, image_rendering, mix_blend_mode};
|
||||
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::mem::HeapSizeOf;
|
||||
use util::opts;
|
||||
use util::range::Range;
|
||||
|
||||
// It seems cleaner to have layout code not mention Azure directly, so let's just reexport this for
|
||||
// layout to use.
|
||||
|
@ -66,7 +65,7 @@ const MIN_INDENTATION_LENGTH: usize = 4;
|
|||
/// Because the script task's GC does not trace layout, node data cannot be safely stored in layout
|
||||
/// data structures. Also, layout code tends to be faster when the DOM is not being accessed, for
|
||||
/// locality reasons. Using `OpaqueNode` enforces this invariant.
|
||||
#[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)]
|
||||
#[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct OpaqueNode(pub uintptr_t);
|
||||
|
||||
impl OpaqueNode {
|
||||
|
@ -82,22 +81,22 @@ impl OpaqueNode {
|
|||
///
|
||||
/// TODO(pcwalton): We could reduce the size of this structure with a more "skip list"-like
|
||||
/// structure, omitting several pointers and lengths.
|
||||
#[derive(HeapSizeOf)]
|
||||
#[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: LinkedList<DisplayItem>,
|
||||
pub background_and_borders: SerializableLinkedList<DisplayItem>,
|
||||
/// Borders and backgrounds for block-level descendants: step 4.
|
||||
pub block_backgrounds_and_borders: LinkedList<DisplayItem>,
|
||||
pub block_backgrounds_and_borders: SerializableLinkedList<DisplayItem>,
|
||||
/// Floats: step 5. These are treated as pseudo-stacking contexts.
|
||||
pub floats: LinkedList<DisplayItem>,
|
||||
pub floats: SerializableLinkedList<DisplayItem>,
|
||||
/// All non-positioned content.
|
||||
pub content: LinkedList<DisplayItem>,
|
||||
pub content: SerializableLinkedList<DisplayItem>,
|
||||
/// All positioned content that does not get a stacking context.
|
||||
pub positioned_content: LinkedList<DisplayItem>,
|
||||
pub positioned_content: SerializableLinkedList<DisplayItem>,
|
||||
/// Outlines: step 10.
|
||||
pub outlines: LinkedList<DisplayItem>,
|
||||
pub outlines: SerializableLinkedList<DisplayItem>,
|
||||
/// Child stacking contexts.
|
||||
pub children: LinkedList<Arc<StackingContext>>,
|
||||
pub children: SerializableLinkedList<Arc<StackingContext>>,
|
||||
}
|
||||
|
||||
impl DisplayList {
|
||||
|
@ -105,13 +104,13 @@ impl DisplayList {
|
|||
#[inline]
|
||||
pub fn new() -> DisplayList {
|
||||
DisplayList {
|
||||
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(),
|
||||
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()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,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
|
||||
|
@ -219,7 +218,7 @@ impl DisplayList {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(HeapSizeOf)]
|
||||
#[derive(HeapSizeOf, Deserialize, Serialize)]
|
||||
/// Represents one CSS stacking context, which may or may not have a hardware layer.
|
||||
pub struct StackingContext {
|
||||
/// The display items that make up this stacking context.
|
||||
|
@ -443,7 +442,8 @@ impl StackingContext {
|
|||
|
||||
} else {
|
||||
// Optimize the display list to throw out out-of-bounds display items and so forth.
|
||||
let display_list = DisplayListOptimizer::new(tile_bounds).optimize(&*self.display_list);
|
||||
let display_list =
|
||||
DisplayListOptimizer::new(tile_bounds).optimize(&*self.display_list);
|
||||
|
||||
self.draw_into_context(&display_list,
|
||||
paint_context,
|
||||
|
@ -515,12 +515,16 @@ impl StackingContext {
|
|||
// If the point is inside the border, it didn't hit the border!
|
||||
let interior_rect =
|
||||
Rect::new(
|
||||
Point2D::new(border.base.bounds.origin.x + border.border_widths.left,
|
||||
border.base.bounds.origin.y + border.border_widths.top),
|
||||
Point2D::new(border.base.bounds.origin.x +
|
||||
border.border_widths.left,
|
||||
border.base.bounds.origin.y +
|
||||
border.border_widths.top),
|
||||
Size2D::new(border.base.bounds.size.width -
|
||||
(border.border_widths.left + border.border_widths.right),
|
||||
(border.border_widths.left +
|
||||
border.border_widths.right),
|
||||
border.base.bounds.size.height -
|
||||
(border.border_widths.top + border.border_widths.bottom)));
|
||||
(border.border_widths.top +
|
||||
border.border_widths.bottom)));
|
||||
if geometry::rect_contains_point(interior_rect, point) {
|
||||
continue
|
||||
}
|
||||
|
@ -541,7 +545,7 @@ impl StackingContext {
|
|||
|
||||
debug_assert!(!topmost_only || result.is_empty());
|
||||
let frac_point = self.transform.transform_point(&Point2D::new(point.x.to_f32_px(),
|
||||
point.y.to_f32_px()));
|
||||
point.y.to_f32_px()));
|
||||
point = Point2D::new(Au::from_f32_px(frac_point.x), Au::from_f32_px(frac_point.y));
|
||||
|
||||
// Iterate through display items in reverse stacking order. Steps here refer to the
|
||||
|
@ -639,7 +643,7 @@ pub fn find_stacking_context_with_layer_id(this: &Arc<StackingContext>, layer_id
|
|||
}
|
||||
|
||||
/// One drawing command in the list.
|
||||
#[derive(Clone, HeapSizeOf)]
|
||||
#[derive(Clone, Deserialize, HeapSizeOf, Serialize)]
|
||||
pub enum DisplayItem {
|
||||
SolidColorClass(Box<SolidColorDisplayItem>),
|
||||
TextClass(Box<TextDisplayItem>),
|
||||
|
@ -651,7 +655,7 @@ pub enum DisplayItem {
|
|||
}
|
||||
|
||||
/// Information common to all display items.
|
||||
#[derive(Clone, HeapSizeOf)]
|
||||
#[derive(Clone, Deserialize, HeapSizeOf, Serialize)]
|
||||
pub struct BaseDisplayItem {
|
||||
/// The boundaries of the display item, in layer coordinates.
|
||||
pub bounds: Rect<Au>,
|
||||
|
@ -679,7 +683,7 @@ impl BaseDisplayItem {
|
|||
/// A clipping region for a display item. Currently, this can describe rectangles, rounded
|
||||
/// rectangles (for `border-radius`), or arbitrary intersections of the two. Arbitrary transforms
|
||||
/// are not supported because those are handled by the higher-level `StackingContext` abstraction.
|
||||
#[derive(Clone, PartialEq, Debug, HeapSizeOf)]
|
||||
#[derive(Clone, PartialEq, Debug, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct ClippingRegion {
|
||||
/// The main rectangular region. This does not include any corners.
|
||||
pub main: Rect<Au>,
|
||||
|
@ -693,7 +697,7 @@ pub struct ClippingRegion {
|
|||
/// A complex clipping region. These don't as easily admit arbitrary intersection operations, so
|
||||
/// they're stored in a list over to the side. Currently a complex clipping region is just a
|
||||
/// rounded rectangle, but the CSS WGs will probably make us throw more stuff in here eventually.
|
||||
#[derive(Clone, PartialEq, Debug, HeapSizeOf)]
|
||||
#[derive(Clone, PartialEq, Debug, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct ComplexClippingRegion {
|
||||
/// The boundaries of the rectangle.
|
||||
pub rect: Rect<Au>,
|
||||
|
@ -805,7 +809,7 @@ impl ClippingRegion {
|
|||
/// Metadata attached to each display item. This is useful for performing auxiliary tasks with
|
||||
/// the display list involving hit testing: finding the originating DOM node and determining the
|
||||
/// cursor to use when the element is hovered over.
|
||||
#[derive(Clone, Copy, HeapSizeOf)]
|
||||
#[derive(Clone, Copy, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct DisplayItemMetadata {
|
||||
/// The DOM node from which this display item originated.
|
||||
pub node: OpaqueNode,
|
||||
|
@ -834,7 +838,7 @@ impl DisplayItemMetadata {
|
|||
}
|
||||
|
||||
/// Paints a solid color.
|
||||
#[derive(Clone, HeapSizeOf)]
|
||||
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct SolidColorDisplayItem {
|
||||
/// Fields common to all display items.
|
||||
pub base: BaseDisplayItem,
|
||||
|
@ -844,7 +848,7 @@ pub struct SolidColorDisplayItem {
|
|||
}
|
||||
|
||||
/// Paints text.
|
||||
#[derive(Clone, HeapSizeOf)]
|
||||
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct TextDisplayItem {
|
||||
/// Fields common to all display items.
|
||||
pub base: BaseDisplayItem,
|
||||
|
@ -869,7 +873,7 @@ pub struct TextDisplayItem {
|
|||
pub blur_radius: Au,
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, HeapSizeOf)]
|
||||
#[derive(Clone, Eq, PartialEq, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub enum TextOrientation {
|
||||
Upright,
|
||||
SidewaysLeft,
|
||||
|
@ -877,7 +881,7 @@ pub enum TextOrientation {
|
|||
}
|
||||
|
||||
/// Paints an image.
|
||||
#[derive(Clone, HeapSizeOf)]
|
||||
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct ImageDisplayItem {
|
||||
pub base: BaseDisplayItem,
|
||||
#[ignore_heap_size_of = "Because it is non-owning"]
|
||||
|
@ -895,7 +899,7 @@ pub struct ImageDisplayItem {
|
|||
|
||||
|
||||
/// Paints a gradient.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct GradientDisplayItem {
|
||||
/// Fields common to all display items.
|
||||
pub base: BaseDisplayItem,
|
||||
|
@ -926,7 +930,7 @@ impl HeapSizeOf for GradientDisplayItem {
|
|||
|
||||
|
||||
/// Paints a border.
|
||||
#[derive(Clone, HeapSizeOf)]
|
||||
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct BorderDisplayItem {
|
||||
/// Fields common to all display items.
|
||||
pub base: BaseDisplayItem,
|
||||
|
@ -949,7 +953,7 @@ pub struct BorderDisplayItem {
|
|||
/// Information about the border radii.
|
||||
///
|
||||
/// TODO(pcwalton): Elliptical radii.
|
||||
#[derive(Clone, Default, PartialEq, Debug, Copy, HeapSizeOf)]
|
||||
#[derive(Clone, Default, PartialEq, Debug, Copy, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct BorderRadii<T> {
|
||||
pub top_left: T,
|
||||
pub top_right: T,
|
||||
|
@ -979,7 +983,7 @@ impl<T> BorderRadii<T> where T: PartialEq + Zero + Clone {
|
|||
}
|
||||
|
||||
/// Paints a line segment.
|
||||
#[derive(Clone, HeapSizeOf)]
|
||||
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct LineDisplayItem {
|
||||
pub base: BaseDisplayItem,
|
||||
|
||||
|
@ -991,7 +995,7 @@ pub struct LineDisplayItem {
|
|||
}
|
||||
|
||||
/// Paints a box shadow per CSS-BACKGROUNDS.
|
||||
#[derive(Clone, HeapSizeOf)]
|
||||
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct BoxShadowDisplayItem {
|
||||
/// Fields common to all display items.
|
||||
pub base: BaseDisplayItem,
|
||||
|
@ -1016,7 +1020,7 @@ pub struct BoxShadowDisplayItem {
|
|||
}
|
||||
|
||||
/// How a box shadow should be clipped.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, HeapSizeOf)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub enum BoxShadowClipMode {
|
||||
/// No special clipping should occur. This is used for (shadowed) text decorations.
|
||||
None,
|
||||
|
|
|
@ -37,7 +37,8 @@ impl DisplayListOptimizer {
|
|||
self.add_in_bounds_display_items(&mut result.content, display_list.content.iter());
|
||||
self.add_in_bounds_display_items(&mut result.positioned_content,
|
||||
display_list.positioned_content.iter());
|
||||
self.add_in_bounds_display_items(&mut result.outlines, display_list.outlines.iter());
|
||||
self.add_in_bounds_display_items(&mut result.outlines,
|
||||
display_list.outlines.iter());
|
||||
self.add_in_bounds_stacking_contexts(&mut result.children, display_list.children.iter());
|
||||
result
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ pub trait FontTableMethods {
|
|||
fn with_buffer<F>(&self, F) where F: FnOnce(*const u8, usize);
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct FontMetrics {
|
||||
pub underline_size: Au,
|
||||
pub underline_offset: Au,
|
||||
|
|
|
@ -14,9 +14,11 @@
|
|||
#![feature(vec_push_all)]
|
||||
|
||||
#![plugin(plugins)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate serde;
|
||||
|
||||
extern crate azure;
|
||||
#[macro_use] extern crate bitflags;
|
||||
|
|
|
@ -40,7 +40,7 @@ use util::task_state;
|
|||
use util::task::spawn_named;
|
||||
|
||||
/// Information about a hardware graphics layer that layout sends to the painting task.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct PaintLayer {
|
||||
/// A per-pipeline ID describing this layer that should be stable across reflows.
|
||||
pub id: LayerId,
|
||||
|
@ -353,18 +353,23 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
|||
let transform = transform.mul(&stacking_context.transform);
|
||||
let perspective = perspective.mul(&stacking_context.perspective);
|
||||
|
||||
let (next_parent_id, page_position, transform, perspective) = match stacking_context.layer {
|
||||
let (next_parent_id, page_position, transform, perspective) =
|
||||
match stacking_context.layer {
|
||||
Some(ref paint_layer) => {
|
||||
// Layers start at the top left of their overflow rect, as far as the info we give to
|
||||
// the compositor is concerned.
|
||||
// Layers start at the top left of their overflow rect, as far as the info we
|
||||
// give to the compositor is concerned.
|
||||
let overflow_relative_page_position = *page_position +
|
||||
stacking_context.bounds.origin +
|
||||
stacking_context.overflow.origin;
|
||||
let layer_position =
|
||||
Rect::new(Point2D::new(overflow_relative_page_position.x.to_nearest_px() as f32,
|
||||
overflow_relative_page_position.y.to_nearest_px() as f32),
|
||||
Size2D::new(stacking_context.overflow.size.width.to_nearest_px() as f32,
|
||||
stacking_context.overflow.size.height.to_nearest_px() as f32));
|
||||
Rect::new(Point2D::new(overflow_relative_page_position.x.to_nearest_px() as
|
||||
f32,
|
||||
overflow_relative_page_position.y.to_nearest_px() as
|
||||
f32),
|
||||
Size2D::new(stacking_context.overflow.size.width.to_nearest_px()
|
||||
as f32,
|
||||
stacking_context.overflow.size.height.to_nearest_px()
|
||||
as f32));
|
||||
|
||||
let establishes_3d_context = stacking_context.establishes_3d_context;
|
||||
|
||||
|
@ -395,12 +400,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
|||
};
|
||||
|
||||
for kid in stacking_context.display_list.children.iter() {
|
||||
build(properties,
|
||||
&**kid,
|
||||
&page_position,
|
||||
&transform,
|
||||
&perspective,
|
||||
next_parent_id);
|
||||
build(properties, &**kid, &page_position, &transform, &perspective, next_parent_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use string_cache::Atom;
|
|||
/// The identifier is an absolute path, and the bytes
|
||||
/// field is the loaded data that can be passed to
|
||||
/// freetype and azure directly.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct FontTemplateData {
|
||||
pub bytes: Vec<u8>,
|
||||
pub identifier: Atom,
|
||||
|
|
|
@ -64,7 +64,7 @@ impl FontHandleMethods for FontHandle {
|
|||
Some(s) => s.to_f64_px(),
|
||||
None => 0.0
|
||||
};
|
||||
match template.ctfont {
|
||||
match *template.ctfont {
|
||||
Some(ref ctfont) => {
|
||||
Ok(FontHandle {
|
||||
font_data: template.clone(),
|
||||
|
|
|
@ -7,14 +7,27 @@ use core_graphics::font::CGFont;
|
|||
use core_text::font::CTFont;
|
||||
use core_text;
|
||||
|
||||
use serde::de::{Error, Visitor};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::borrow::ToOwned;
|
||||
use std::ops::Deref;
|
||||
use string_cache::Atom;
|
||||
|
||||
/// Platform specific font representation for mac.
|
||||
/// The identifier is a PostScript font name. The
|
||||
/// CTFont object is cached here for use by the
|
||||
/// paint functions that create CGFont references.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct FontTemplateData {
|
||||
pub ctfont: Option<CTFont>,
|
||||
/// The `CTFont` object, if present. This is cached here so that we don't have to keep creating
|
||||
/// `CTFont` instances over and over. It can always be recreated from the `identifier` and/or
|
||||
/// `font_data` fields.
|
||||
///
|
||||
/// When sending a `FontTemplateData` instance across processes, this will be set to `None` on
|
||||
/// the other side, because `CTFont` instances cannot be sent across processes. This is
|
||||
/// harmless, however, because it can always be recreated.
|
||||
pub ctfont: CachedCTFont,
|
||||
|
||||
pub identifier: Atom,
|
||||
pub font_data: Option<Vec<u8>>
|
||||
}
|
||||
|
@ -39,9 +52,43 @@ impl FontTemplateData {
|
|||
};
|
||||
|
||||
FontTemplateData {
|
||||
ctfont: ctfont,
|
||||
ctfont: CachedCTFont(ctfont),
|
||||
identifier: identifier.to_owned(),
|
||||
font_data: font_data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CachedCTFont(Option<CTFont>);
|
||||
|
||||
impl Deref for CachedCTFont {
|
||||
type Target = Option<CTFont>;
|
||||
fn deref(&self) -> &Option<CTFont> {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for CachedCTFont {
|
||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer {
|
||||
serializer.visit_none()
|
||||
}
|
||||
}
|
||||
|
||||
impl Deserialize for CachedCTFont {
|
||||
fn deserialize<D>(deserializer: &mut D) -> Result<CachedCTFont, D::Error>
|
||||
where D: Deserializer {
|
||||
struct NoneOptionVisitor;
|
||||
|
||||
impl Visitor for NoneOptionVisitor {
|
||||
type Value = CachedCTFont;
|
||||
|
||||
#[inline]
|
||||
fn visit_none<E>(&mut self) -> Result<CachedCTFont,E> where E: Error {
|
||||
Ok(CachedCTFont(None))
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.visit_option(NoneOptionVisitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ use util::vec::*;
|
|||
/// In the uncommon case (multiple glyphs per unicode character, large glyph index/advance, or
|
||||
/// glyph offsets), we pack the glyph count into GlyphEntry, and store the other glyph information
|
||||
/// in DetailedGlyphStore.
|
||||
#[derive(Clone, Debug, Copy)]
|
||||
#[derive(Clone, Debug, Copy, Deserialize, Serialize)]
|
||||
struct GlyphEntry {
|
||||
value: u32,
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ impl GlyphEntry {
|
|||
|
||||
// Stores data for a detailed glyph, in the case that several glyphs
|
||||
// correspond to one character, or the glyph's data couldn't be packed.
|
||||
#[derive(Clone, Debug, Copy)]
|
||||
#[derive(Clone, Debug, Copy, Deserialize, Serialize)]
|
||||
struct DetailedGlyph {
|
||||
id: GlyphId,
|
||||
// glyph's advance, in the text's direction (LTR or RTL)
|
||||
|
@ -269,7 +269,7 @@ impl DetailedGlyph {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, Eq, Debug, Copy)]
|
||||
#[derive(PartialEq, Clone, Eq, Debug, Copy, Deserialize, Serialize)]
|
||||
struct DetailedGlyphRecord {
|
||||
// source string offset/GlyphEntry offset in the TextRun
|
||||
entry_offset: CharIndex,
|
||||
|
@ -293,7 +293,7 @@ impl Ord for DetailedGlyphRecord {
|
|||
// until a lookup is actually performed; this matches the expected
|
||||
// usage pattern of setting/appending all the detailed glyphs, and
|
||||
// then querying without setting.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
struct DetailedGlyphStore {
|
||||
// TODO(pcwalton): Allocation of this buffer is expensive. Consider a small-vector
|
||||
// optimization.
|
||||
|
@ -500,7 +500,7 @@ impl<'a> GlyphInfo<'a> {
|
|||
/// | +---+---+ |
|
||||
/// +---------------------------------------------+
|
||||
/// ~~~
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct GlyphStore {
|
||||
// TODO(pcwalton): Allocation of this buffer is expensive. Consider a small-vector
|
||||
// optimization.
|
||||
|
@ -515,7 +515,7 @@ pub struct GlyphStore {
|
|||
}
|
||||
|
||||
int_range_index! {
|
||||
#[derive(RustcEncodable)]
|
||||
#[derive(Deserialize, Serialize, RustcEncodable)]
|
||||
#[doc = "An index that refers to a character in a text run. This could \
|
||||
point to the middle of a glyph."]
|
||||
#[derive(HeapSizeOf)]
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::sync::Arc;
|
|||
use text::glyph::{CharIndex, GlyphStore};
|
||||
|
||||
/// A single "paragraph" of text in one font size and style.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct TextRun {
|
||||
/// The UTF-8 string represented by this text run.
|
||||
pub text: Arc<String>,
|
||||
|
@ -26,7 +26,7 @@ pub struct TextRun {
|
|||
}
|
||||
|
||||
/// A single series of glyphs within a text run.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct GlyphRun {
|
||||
/// The glyphs.
|
||||
pub glyph_store: Arc<GlyphStore>,
|
||||
|
|
|
@ -71,3 +71,6 @@ smallvec = "0.1"
|
|||
string_cache = "0.1"
|
||||
string_cache_plugin = "0.1"
|
||||
euclid = "0.1"
|
||||
serde = "*"
|
||||
serde_macros = "*"
|
||||
|
||||
|
|
|
@ -829,7 +829,9 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
let line_display_item = box LineDisplayItem {
|
||||
base: BaseDisplayItem::new(baseline,
|
||||
DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor),
|
||||
DisplayItemMetadata::new(self.node,
|
||||
style,
|
||||
Cursor::DefaultCursor),
|
||||
(*clip).clone()),
|
||||
color: color::rgb(0, 200, 0),
|
||||
style: border_style::T::dashed,
|
||||
|
|
|
@ -58,6 +58,7 @@ use script::layout_interface::{NewLayoutTaskInfo, Msg, Reflow, ReflowGoal, Reflo
|
|||
use script::layout_interface::{ScriptLayoutChan, ScriptReflow, TrustedNodeAddress};
|
||||
use script_traits::{ConstellationControlMsg, LayoutControlMsg, OpaqueScriptLayoutChannel};
|
||||
use script_traits::{ScriptControlChan, StylesheetLoadResponder};
|
||||
use serde::json;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashMap;
|
||||
|
@ -907,6 +908,9 @@ impl LayoutTask {
|
|||
println!("#### start printing display list.");
|
||||
stacking_context.print("#".to_owned());
|
||||
}
|
||||
if opts::get().dump_display_list_json {
|
||||
println!("{}", json::to_string_pretty(&stacking_context).unwrap());
|
||||
}
|
||||
|
||||
rw_data.stacking_context = Some(stacking_context.clone());
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#![feature(append)]
|
||||
#![feature(arc_unique)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(custom_derive)]
|
||||
#![feature(filling_drop)]
|
||||
#![feature(hashmap_hasher)]
|
||||
#![feature(heap_api)]
|
||||
|
@ -36,7 +37,6 @@ extern crate profile_traits;
|
|||
#[macro_use]
|
||||
extern crate util;
|
||||
|
||||
extern crate rustc_serialize;
|
||||
extern crate azure;
|
||||
extern crate canvas_traits;
|
||||
extern crate clock_ticks;
|
||||
|
@ -50,9 +50,11 @@ extern crate ipc_channel;
|
|||
extern crate layout_traits;
|
||||
extern crate libc;
|
||||
extern crate msg;
|
||||
extern crate rustc_serialize;
|
||||
extern crate script;
|
||||
extern crate script_traits;
|
||||
extern crate selectors;
|
||||
extern crate serde;
|
||||
extern crate smallvec;
|
||||
extern crate string_cache;
|
||||
extern crate style;
|
||||
|
|
|
@ -60,7 +60,7 @@ pub enum LayerKind {
|
|||
}
|
||||
|
||||
/// The scrolling policy of a layer.
|
||||
#[derive(Clone, PartialEq, Eq, Copy)]
|
||||
#[derive(Clone, PartialEq, Eq, Copy, Deserialize, Serialize)]
|
||||
pub enum ScrollPolicy {
|
||||
/// These layers scroll when the parent receives a scrolling message.
|
||||
Scrollable,
|
||||
|
|
|
@ -24,4 +24,6 @@ log = "*"
|
|||
url = "0.2.35"
|
||||
hyper = "0.6"
|
||||
euclid = "0.1"
|
||||
serde = "*"
|
||||
serde_macros = "*"
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use util::vec::byte_swap;
|
|||
// FIXME: Images must not be copied every frame. Instead we should atomically
|
||||
// reference count them.
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum PixelFormat {
|
||||
K8, // Luminance channel only
|
||||
KA8, // Luminance + alpha
|
||||
|
@ -17,6 +18,7 @@ pub enum PixelFormat {
|
|||
RGBA8, // RGB + alpha, 8 bits per channel
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Image {
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
|
|
|
@ -3,15 +3,19 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![feature(box_syntax)]
|
||||
#![feature(custom_derive)]
|
||||
#![feature(plugin)]
|
||||
#![feature(slice_patterns)]
|
||||
#![feature(step_by)]
|
||||
#![feature(vec_push_all)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate euclid;
|
||||
extern crate hyper;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate png;
|
||||
extern crate serde;
|
||||
extern crate stb_image;
|
||||
extern crate url;
|
||||
extern crate util;
|
||||
|
|
|
@ -445,9 +445,11 @@ dependencies = [
|
|||
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_traits 0.0.1",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -579,7 +581,7 @@ dependencies = [
|
|||
"mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_macros 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -720,8 +722,10 @@ dependencies = [
|
|||
"script 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -883,6 +887,8 @@ dependencies = [
|
|||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"png 0.1.0 (git+https://github.com/servo/rust-png)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
@ -1142,7 +1148,7 @@ dependencies = [
|
|||
"script_traits 0.0.1",
|
||||
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1189,7 +1195,7 @@ dependencies = [
|
|||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quicksort 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1269,13 +1275,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "string_cache"
|
||||
version = "0.1.5"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_macros 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_shared 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -1311,8 +1318,10 @@ dependencies = [
|
|||
"plugins 0.0.1",
|
||||
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
@ -1325,7 +1334,7 @@ dependencies = [
|
|||
"cssparser 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -34,3 +34,6 @@ smallvec = "0.1"
|
|||
string_cache = "0.1"
|
||||
string_cache_plugin = "0.1"
|
||||
euclid = "0.1"
|
||||
serde = "*"
|
||||
serde_macros = "*"
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#![feature(hasher_write)]
|
||||
#![feature(plugin)]
|
||||
#![feature(vec_push_all)]
|
||||
#![feature(vec_push_all)]
|
||||
|
||||
#![plugin(string_cache_plugin)]
|
||||
#![plugin(serde_macros)]
|
||||
#![plugin(plugins)]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
|
@ -20,6 +20,7 @@
|
|||
|
||||
extern crate fnv;
|
||||
extern crate euclid;
|
||||
extern crate serde;
|
||||
extern crate smallvec;
|
||||
extern crate url;
|
||||
|
||||
|
|
|
@ -3050,7 +3050,7 @@ pub mod longhands {
|
|||
use values::CSSFloat;
|
||||
use values::specified::{Angle};
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, HeapSizeOf)]
|
||||
#[derive(Clone, PartialEq, Debug, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub enum Filter {
|
||||
Blur(Au),
|
||||
Brightness(CSSFloat),
|
||||
|
@ -3063,7 +3063,7 @@ pub mod longhands {
|
|||
Sepia(CSSFloat),
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, HeapSizeOf)]
|
||||
#[derive(Clone, PartialEq, Debug, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct T { pub filters: Vec<Filter> }
|
||||
|
||||
impl T {
|
||||
|
@ -3857,7 +3857,7 @@ pub mod longhands {
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, HeapSizeOf)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub enum T {
|
||||
Auto,
|
||||
CrispEdges,
|
||||
|
|
|
@ -13,6 +13,7 @@ macro_rules! define_css_keyword_enum {
|
|||
($name: ident: $( $css: expr => $variant: ident ),+) => {
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Clone, Eq, PartialEq, Copy, Hash, RustcEncodable, Debug, HeapSizeOf)]
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum $name {
|
||||
$( $variant ),+
|
||||
}
|
||||
|
@ -44,6 +45,7 @@ macro_rules! define_numbered_css_keyword_enum {
|
|||
($name: ident: $( $css: expr => $variant: ident = $value: expr ),+) => {
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Clone, Eq, PartialEq, PartialOrd, Ord, Copy, RustcEncodable, Debug, HeapSizeOf)]
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum $name {
|
||||
$( $variant = $value ),+
|
||||
}
|
||||
|
@ -645,7 +647,7 @@ pub mod specified {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, PartialOrd, Copy, Debug, HeapSizeOf)]
|
||||
#[derive(Clone, PartialEq, PartialOrd, Copy, Debug, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct Angle(pub CSSFloat);
|
||||
|
||||
impl ToCss for Angle {
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::ascii::AsciiExt;
|
|||
|
||||
macro_rules! define_cursor {
|
||||
($( $css: expr => $variant: ident = $value: expr, )+) => {
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Deserialize, Serialize)]
|
||||
#[repr(u8)]
|
||||
pub enum Cursor {
|
||||
$( $variant = $value ),+
|
||||
|
|
|
@ -4,8 +4,81 @@
|
|||
|
||||
//! 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> {
|
||||
|
|
|
@ -140,6 +140,9 @@ pub struct Opts {
|
|||
/// Dumps the display list after a layout.
|
||||
pub dump_display_list: bool,
|
||||
|
||||
/// Dumps the display list in JSON form after a layout.
|
||||
pub dump_display_list_json: bool,
|
||||
|
||||
/// Dumps the display list after optimization (post layout, at painting time).
|
||||
pub dump_display_list_optimized: bool,
|
||||
|
||||
|
@ -178,6 +181,7 @@ pub fn print_debug_usage(app: &str) -> ! {
|
|||
print_option("disable-text-aa", "Disable antialiasing of rendered text.");
|
||||
print_option("dump-flow-tree", "Print the flow tree after each layout.");
|
||||
print_option("dump-display-list", "Print the display list after each layout.");
|
||||
print_option("dump-display-list-json", "Print the display list in JSON form.");
|
||||
print_option("dump-display-list-optimized", "Print optimized display list (at paint time).");
|
||||
print_option("relayout-event", "Print notifications when there is a relayout.");
|
||||
print_option("profile-tasks", "Instrument each task, writing the output to a file.");
|
||||
|
@ -248,6 +252,7 @@ pub fn default_opts() -> Opts {
|
|||
user_agent: None,
|
||||
dump_flow_tree: false,
|
||||
dump_display_list: false,
|
||||
dump_display_list_json: false,
|
||||
dump_display_list_optimized: false,
|
||||
relayout_event: false,
|
||||
validate_display_list_geometry: false,
|
||||
|
@ -424,6 +429,7 @@ pub fn from_cmdline_args(args: &[String]) {
|
|||
enable_canvas_antialiasing: !debug_options.contains(&"disable-canvas-aa"),
|
||||
dump_flow_tree: debug_options.contains(&"dump-flow-tree"),
|
||||
dump_display_list: debug_options.contains(&"dump-display-list"),
|
||||
dump_display_list_json: debug_options.contains(&"dump-display-list-json"),
|
||||
dump_display_list_optimized: debug_options.contains(&"dump-display-list-optimized"),
|
||||
relayout_event: debug_options.contains(&"relayout-event"),
|
||||
validate_display_list_geometry: debug_options.contains(&"validate-display-list-geometry"),
|
||||
|
|
|
@ -124,7 +124,7 @@ macro_rules! int_range_index {
|
|||
}
|
||||
|
||||
/// A range of indices
|
||||
#[derive(Clone, RustcEncodable, Copy)]
|
||||
#[derive(Clone, RustcEncodable, Copy, Deserialize, Serialize)]
|
||||
pub struct Range<I> {
|
||||
begin: I,
|
||||
length: I,
|
||||
|
|
|
@ -444,9 +444,11 @@ dependencies = [
|
|||
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_traits 0.0.1",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -571,7 +573,7 @@ dependencies = [
|
|||
"mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_macros 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -712,8 +714,10 @@ dependencies = [
|
|||
"script 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -863,6 +867,8 @@ dependencies = [
|
|||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"png 0.1.0 (git+https://github.com/servo/rust-png)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
@ -1108,6 +1114,7 @@ dependencies = [
|
|||
"hyper 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
|
||||
"js 0.1.0 (git+https://github.com/servo/rust-mozjs)",
|
||||
"layout_traits 0.0.1",
|
||||
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
|
@ -1121,7 +1128,7 @@ dependencies = [
|
|||
"script_traits 0.0.1",
|
||||
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1139,9 +1146,12 @@ version = "0.0.1"
|
|||
dependencies = [
|
||||
"devtools_traits 0.0.1",
|
||||
"euclid 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
|
||||
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"net_traits 0.0.1",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
@ -1157,7 +1167,7 @@ dependencies = [
|
|||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quicksort 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1263,13 +1273,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "string_cache"
|
||||
version = "0.1.5"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_macros 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_shared 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -1305,8 +1316,10 @@ dependencies = [
|
|||
"plugins 0.0.1",
|
||||
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
|
|
@ -423,9 +423,11 @@ dependencies = [
|
|||
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_traits 0.0.1",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -505,7 +507,7 @@ dependencies = [
|
|||
"mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_macros 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -646,8 +648,10 @@ dependencies = [
|
|||
"script 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -789,6 +793,8 @@ dependencies = [
|
|||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"png 0.1.0 (git+https://github.com/servo/rust-png)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
@ -1016,6 +1022,7 @@ dependencies = [
|
|||
"hyper 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
|
||||
"js 0.1.0 (git+https://github.com/servo/rust-mozjs)",
|
||||
"layout_traits 0.0.1",
|
||||
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
|
@ -1029,7 +1036,7 @@ dependencies = [
|
|||
"script_traits 0.0.1",
|
||||
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1047,9 +1054,12 @@ version = "0.0.1"
|
|||
dependencies = [
|
||||
"devtools_traits 0.0.1",
|
||||
"euclid 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
|
||||
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"net_traits 0.0.1",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
@ -1065,7 +1075,7 @@ dependencies = [
|
|||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quicksort 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1161,13 +1171,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "string_cache"
|
||||
version = "0.1.5"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_macros 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_shared 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -1203,8 +1214,10 @@ dependencies = [
|
|||
"plugins 0.0.1",
|
||||
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
|
||||
"serde 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
|
Загрузка…
Ссылка в новой задаче