diff --git a/Cargo.lock b/Cargo.lock index 9a996af5fa0..6f6b9068853 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -926,7 +926,6 @@ dependencies = [ "ordered-float 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", "range 0.0.1", - "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "servo-fontconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -960,7 +959,6 @@ dependencies = [ "heapsize_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", "range 0.0.1", - "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 1d67d9f4b39..d852ae728f1 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -11,8 +11,8 @@ use euclid::Point2D; use euclid::point::TypedPoint2D; use euclid::scale_factor::ScaleFactor; use euclid::size::TypedSize2D; -use gfx_traits::{DevicePixel, LayerPixel, ScrollRootId}; -use gfx_traits::{Epoch, FrameTreeId, FragmentType}; +use gfx_traits::{DevicePixel, ScrollRootId}; +use gfx_traits::{Epoch, FragmentType}; use gleam::gl; use gleam::gl::types::{GLint, GLsizei}; use image::{DynamicImage, ImageFormat, RgbImage}; @@ -108,6 +108,22 @@ enum ReadyState { ReadyToSaveImage, } +#[derive(PartialEq, Eq, Debug, Copy, Clone)] +struct FrameTreeId(u32); + +impl FrameTreeId { + pub fn next(&mut self) { + self.0 += 1; + } +} + +/// One pixel in layer coordinate space. +/// +/// This unit corresponds to a "pixel" in layer coordinate space, which after scaling and +/// transformation becomes a device pixel. +#[derive(Copy, Clone, Debug)] +enum LayerPixel {} + /// NB: Never block on the constellation, because sometimes the constellation blocks on us. pub struct IOCompositor { /// The application window. diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index d504e0bb138..7ce2bf72546 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -29,7 +29,6 @@ net_traits = {path = "../net_traits"} ordered-float = "0.2.2" plugins = {path = "../plugins"} range = {path = "../range"} -rustc-serialize = "0.3" serde = "0.8" servo_atoms = {path = "../atoms"} servo_geometry = {path = "../geometry"} diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 1de082bdf45..a2cb83c5cf2 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -19,7 +19,7 @@ use euclid::{Matrix4D, Point2D, Rect, Size2D}; use euclid::num::{One, Zero}; use euclid::rect::TypedRect; use euclid::side_offsets::SideOffsets2D; -use gfx_traits::{ScrollPolicy, ScrollRootId, StackingContextId}; +use gfx_traits::{ScrollRootId, StackingContextId}; use gfx_traits::print_tree::PrintTree; use ipc_channel::ipc::IpcSharedMemory; use msg::constellation_msg::PipelineId; @@ -34,7 +34,7 @@ use style::computed_values::{border_style, filter, image_rendering, mix_blend_mo use style_traits::cursor::Cursor; use text::TextRun; use text::glyph::ByteIndex; -use webrender_traits::{self, ColorF, GradientStop, WebGLContextId}; +use webrender_traits::{self, ColorF, GradientStop, ScrollPolicy, WebGLContextId}; pub use style::dom::OpaqueNode; @@ -129,7 +129,7 @@ impl DisplayList { // Convert the parent translated point into stacking context local transform space if the // stacking context isn't fixed. If it's fixed, we need to use the client point anyway. debug_assert!(stacking_context.context_type == StackingContextType::Real); - let is_fixed = stacking_context.scroll_policy == ScrollPolicy::FixedPosition; + let is_fixed = stacking_context.scroll_policy == ScrollPolicy::Fixed; let translated_point = if is_fixed { *client_point } else { @@ -251,7 +251,7 @@ impl<'a> Iterator for DisplayListTraversal<'a> { /// Display list sections that make up a stacking context. Each section here refers /// to the steps in CSS 2.1 Appendix E. /// -#[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, Ord, PartialEq, PartialOrd, RustcEncodable, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, Ord, PartialEq, PartialOrd, Serialize)] pub enum DisplayListSection { BackgroundAndBorders, BlockBackgroundsAndBorders, @@ -259,7 +259,7 @@ pub enum DisplayListSection { Outlines, } -#[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, Ord, PartialEq, PartialOrd, RustcEncodable, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, Ord, PartialEq, PartialOrd, Serialize)] pub enum StackingContextType { Real, PseudoPositioned, diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index 2c50b5532c4..e02793c3a32 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -58,7 +58,6 @@ extern crate net_traits; extern crate ordered_float; #[macro_use] extern crate range; -extern crate rustc_serialize; extern crate serde; #[macro_use] extern crate serde_derive; diff --git a/components/gfx_traits/Cargo.toml b/components/gfx_traits/Cargo.toml index d0d913c1e5a..8ea8ca14f82 100644 --- a/components/gfx_traits/Cargo.toml +++ b/components/gfx_traits/Cargo.toml @@ -14,6 +14,5 @@ heapsize = "0.3.0" heapsize_derive = "0.1" plugins = {path = "../plugins"} range = {path = "../range"} -rustc-serialize = "0.3" serde = "0.8" serde_derive = "0.8" diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs index 72c1b373e2b..afc0aac0080 100644 --- a/components/gfx_traits/lib.rs +++ b/components/gfx_traits/lib.rs @@ -14,7 +14,6 @@ extern crate heapsize; #[macro_use] extern crate heapsize_derive; #[macro_use] extern crate range; -extern crate rustc_serialize; extern crate serde; #[macro_use] extern crate serde_derive; @@ -41,43 +40,9 @@ const SPECIAL_STACKING_CONTEXT_ID_MASK: usize = 0xffff; /// One hardware pixel. /// /// This unit corresponds to the smallest addressable element of the display hardware. -#[derive(Copy, Clone, RustcEncodable, Debug)] +#[derive(Copy, Clone, Debug)] pub enum DevicePixel {} -/// One pixel in layer coordinate space. -/// -/// This unit corresponds to a "pixel" in layer coordinate space, which after scaling and -/// transformation becomes a device pixel. -#[derive(Copy, Clone, RustcEncodable, Debug)] -pub enum LayerPixel {} - -#[derive(Clone, Copy, Debug, PartialEq)] -pub enum LayerKind { - NoTransform, - HasTransform, -} - -#[derive(Clone, PartialEq, Eq, Copy, Hash, Deserialize, Serialize, HeapSizeOf)] -pub enum LayerType { - /// A layer for the fragment body itself. - FragmentBody, - /// An extra layer created for a DOM fragments with overflow:scroll. - OverflowScroll, - /// A layer created to contain ::before pseudo-element content. - BeforePseudoContent, - /// A layer created to contain ::after pseudo-element content. - AfterPseudoContent, -} - -/// The scrolling policy of a layer. -#[derive(Clone, PartialEq, Eq, Copy, Deserialize, Serialize, Debug, HeapSizeOf)] -pub enum ScrollPolicy { - /// These layers scroll when the parent receives a scrolling message. - Scrollable, - /// These layers do not scroll when the parent receives a scrolling message. - FixedPosition, -} - /// A newtype struct for denoting the age of messages; prevents race conditions. #[derive(PartialEq, Eq, Debug, Copy, Clone, PartialOrd, Ord, Deserialize, Serialize)] pub struct Epoch(pub u32); @@ -88,15 +53,6 @@ impl Epoch { } } -#[derive(PartialEq, Eq, Debug, Copy, Clone)] -pub struct FrameTreeId(pub u32); - -impl FrameTreeId { - pub fn next(&mut self) { - self.0 += 1; - } -} - /// A unique ID for every stacking context. #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, Serialize)] pub struct StackingContextId( @@ -128,37 +84,11 @@ impl StackingContextId { } } - /// Returns an ID for the stacking context that forms the outer stacking context of an element - /// with `overflow: scroll`. - #[inline(always)] - pub fn new_outer(fragment_type: FragmentType) -> StackingContextId { - StackingContextId(StackingContextId::next_special_id() | (fragment_type as usize)) - } - - #[inline] - pub fn fragment_type(&self) -> FragmentType { - FragmentType::from_usize(self.0 & 3) - } - - #[inline] - pub fn id(&self) -> usize { - self.0 & !3 - } - /// Returns the stacking context ID for the outer document/layout root. #[inline] pub fn root() -> StackingContextId { StackingContextId(0) } - - /// Returns true if this is a special stacking context. - /// - /// A special stacking context is a stacking context that is one of (a) the outer stacking - /// context of an element with `overflow: scroll`; (b) generated content; (c) both (a) and (b). - #[inline] - pub fn is_special(&self) -> bool { - (self.0 & !SPECIAL_STACKING_CONTEXT_ID_MASK) == 0 - } } /// A unique ID for every scrolling root. @@ -211,11 +141,6 @@ impl ScrollRootId { pub fn fragment_type(&self) -> FragmentType { FragmentType::from_usize(self.0 & 3) } - - #[inline] - pub fn to_stacking_context_id(&self) -> StackingContextId { - StackingContextId(self.0) - } } /// The type of fragment that a stacking context represents. @@ -246,7 +171,7 @@ impl FragmentType { } int_range_index! { - #[derive(Deserialize, Serialize, RustcEncodable)] + #[derive(Deserialize, Serialize)] #[doc = "An index that refers to a byte offset in a text run. This could \ point to the middle of a glyph."] #[derive(HeapSizeOf)] diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index a32253adc69..4c7e29866c7 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -27,7 +27,7 @@ use gfx::display_list::{GradientDisplayItem, IframeDisplayItem, ImageDisplayItem use gfx::display_list::{LineDisplayItem, OpaqueNode}; use gfx::display_list::{SolidColorDisplayItem, ScrollRoot, StackingContext, StackingContextType}; use gfx::display_list::{TextDisplayItem, TextOrientation, WebGLDisplayItem, WebRenderImageInfo}; -use gfx_traits::{ScrollPolicy, ScrollRootId, StackingContextId}; +use gfx_traits::{ScrollRootId, StackingContextId}; use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT}; use ipc_channel::ipc; use list_item::ListItemFlow; @@ -58,7 +58,7 @@ use style::values::computed::{AngleOrCorner, Gradient, GradientKind, LengthOrPer use style::values::specified::{HorizontalDirection, VerticalDirection}; use style_traits::cursor::Cursor; use table_cell::CollapsedBordersForCell; -use webrender_traits::{ColorF, GradientStop}; +use webrender_traits::{ColorF, GradientStop, ScrollPolicy}; trait RgbColor { fn rgb(r: u8, g: u8, b: u8) -> Self; @@ -1912,7 +1912,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow { parent_scroll_root_id: ScrollRootId, state: &mut DisplayListBuildState) { let scroll_policy = if self.is_fixed() { - ScrollPolicy::FixedPosition + ScrollPolicy::Fixed } else { ScrollPolicy::Scrollable }; diff --git a/components/layout/webrender_helpers.rs b/components/layout/webrender_helpers.rs index 0887e7d4b0c..f222109089a 100644 --- a/components/layout/webrender_helpers.rs +++ b/components/layout/webrender_helpers.rs @@ -11,7 +11,7 @@ use app_units::Au; use euclid::{Point2D, Rect, Size2D}; use gfx::display_list::{BorderRadii, BoxShadowClipMode, ClippingRegion}; use gfx::display_list::{DisplayItem, DisplayList, DisplayListTraversal, StackingContextType}; -use gfx_traits::{FragmentType, ScrollPolicy, ScrollRootId}; +use gfx_traits::{FragmentType, ScrollRootId}; use msg::constellation_msg::PipelineId; use style::computed_values::{image_rendering, mix_blend_mode}; use style::computed_values::filter::{self, Filter}; @@ -337,16 +337,11 @@ impl WebRenderDisplayItemConverter for DisplayItem { let stacking_context = &item.stacking_context; debug_assert!(stacking_context.context_type == StackingContextType::Real); - let webrender_scroll_policy = match stacking_context.scroll_policy { - ScrollPolicy::Scrollable => webrender_traits::ScrollPolicy::Scrollable, - ScrollPolicy::FixedPosition => webrender_traits::ScrollPolicy::Fixed, - }; - let clip = builder.new_clip_region(&stacking_context.overflow.to_rectf(), vec![], None); - builder.push_stacking_context(webrender_scroll_policy, + builder.push_stacking_context(stacking_context.scroll_policy, stacking_context.bounds.to_rectf(), clip, stacking_context.z_index,