From 1c614aedd3afbd481030fd29cbc98a917ddf1049 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 4 Jan 2017 11:28:58 +0100 Subject: [PATCH 1/8] Remove unused ScrollRootId::to_stacking_context_id. --- components/gfx_traits/lib.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs index 72c1b373e2b..89ddeb512bf 100644 --- a/components/gfx_traits/lib.rs +++ b/components/gfx_traits/lib.rs @@ -211,11 +211,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. From 0b5dc7ed3425a6c32718072bc06fb4ced8de42ba Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 4 Jan 2017 11:47:02 +0100 Subject: [PATCH 2/8] Remove some unused StackingContextId methods. --- components/gfx_traits/lib.rs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs index 89ddeb512bf..72c2b9a0828 100644 --- a/components/gfx_traits/lib.rs +++ b/components/gfx_traits/lib.rs @@ -128,37 +128,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. From 7ef81c3d7d4dde7d908ee583b044651b43bea95b Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 4 Jan 2017 12:17:50 +0100 Subject: [PATCH 3/8] Move FrameTreeId to compositing. --- components/compositing/compositor.rs | 11 ++++++++++- components/gfx_traits/lib.rs | 9 --------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 1d67d9f4b39..e0d11574e0c 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -12,7 +12,7 @@ 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::{Epoch, FragmentType}; use gleam::gl; use gleam::gl::types::{GLint, GLsizei}; use image::{DynamicImage, ImageFormat, RgbImage}; @@ -108,6 +108,15 @@ enum ReadyState { ReadyToSaveImage, } +#[derive(PartialEq, Eq, Debug, Copy, Clone)] +struct FrameTreeId(u32); + +impl FrameTreeId { + pub fn next(&mut self) { + self.0 += 1; + } +} + /// NB: Never block on the constellation, because sometimes the constellation blocks on us. pub struct IOCompositor { /// The application window. diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs index 72c2b9a0828..c2339f655d9 100644 --- a/components/gfx_traits/lib.rs +++ b/components/gfx_traits/lib.rs @@ -88,15 +88,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( From 6a1f7a717d9e773a1fd287e98101c0082e5521fe Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 4 Jan 2017 12:19:06 +0100 Subject: [PATCH 4/8] Move LayerPixel to compositing. --- components/compositing/compositor.rs | 9 ++++++++- components/gfx_traits/lib.rs | 7 ------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index e0d11574e0c..d852ae728f1 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -11,7 +11,7 @@ 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::{DevicePixel, ScrollRootId}; use gfx_traits::{Epoch, FragmentType}; use gleam::gl; use gleam::gl::types::{GLint, GLsizei}; @@ -117,6 +117,13 @@ impl FrameTreeId { } } +/// 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_traits/lib.rs b/components/gfx_traits/lib.rs index c2339f655d9..fbed979bc39 100644 --- a/components/gfx_traits/lib.rs +++ b/components/gfx_traits/lib.rs @@ -44,13 +44,6 @@ const SPECIAL_STACKING_CONTEXT_ID_MASK: usize = 0xffff; #[derive(Copy, Clone, RustcEncodable, 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, From 8e12a11da91f54ff93bc5a2aeae4a603a8c63644 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 4 Jan 2017 12:20:04 +0100 Subject: [PATCH 5/8] Remove unused LayerKind and LayerType enums. --- components/gfx_traits/lib.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs index fbed979bc39..5e619dfc1ff 100644 --- a/components/gfx_traits/lib.rs +++ b/components/gfx_traits/lib.rs @@ -44,24 +44,6 @@ const SPECIAL_STACKING_CONTEXT_ID_MASK: usize = 0xffff; #[derive(Copy, Clone, RustcEncodable, Debug)] pub enum DevicePixel {} -#[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 { From 5d2a68033a25cface6d440315b7360bdfaa18713 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 4 Jan 2017 12:22:20 +0100 Subject: [PATCH 6/8] Replace gfx_traits::ScrollPolicy by webrender_traits::ScrollPolicy. --- components/gfx/display_list/mod.rs | 6 +++--- components/gfx_traits/lib.rs | 9 --------- components/layout/display_list_builder.rs | 6 +++--- components/layout/webrender_helpers.rs | 9 ++------- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index eeb78f9f9e7..3a2178255a9 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 { diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs index 5e619dfc1ff..1bb106ac23a 100644 --- a/components/gfx_traits/lib.rs +++ b/components/gfx_traits/lib.rs @@ -44,15 +44,6 @@ const SPECIAL_STACKING_CONTEXT_ID_MASK: usize = 0xffff; #[derive(Copy, Clone, RustcEncodable, Debug)] pub enum DevicePixel {} -/// 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); diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 8dd881cd277..a2c69c8d13c 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; @@ -1835,7 +1835,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow { } 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, From 137b277f1e7b43a5cd8438970e398e97d68ebb36 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 10 Jan 2017 09:58:53 +0100 Subject: [PATCH 7/8] Remove the rustc-serialize dependency from gfx. --- Cargo.lock | 1 - components/gfx/Cargo.toml | 1 - components/gfx/display_list/mod.rs | 4 ++-- components/gfx/lib.rs | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5f611e9ee7c..1ad6dcd35fe 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)", 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 3a2178255a9..544a4d4029c 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -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; From d12b385b418f09c6436d2db575209e85de3fe2b2 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 10 Jan 2017 10:05:46 +0100 Subject: [PATCH 8/8] Remove the rustc-serialize dependency from gfx_traits. --- Cargo.lock | 1 - components/gfx_traits/Cargo.toml | 1 - components/gfx_traits/lib.rs | 5 ++--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ad6dcd35fe..df71f18de7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -959,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/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 1bb106ac23a..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,7 +40,7 @@ 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 {} /// A newtype struct for denoting the age of messages; prevents race conditions. @@ -172,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)]