diff --git a/Cargo.lock b/Cargo.lock index e34c348c01c..1d73ed16de3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2334,7 +2334,6 @@ dependencies = [ "script_layout_interface 0.0.1", "script_traits 0.0.1", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", - "servo_arc 0.1.1", "servo_url 0.0.1", "style 0.0.1", "style_traits 0.0.1", diff --git a/components/layout_2020/Cargo.toml b/components/layout_2020/Cargo.toml index 0e743765cd1..296d069c7e1 100644 --- a/components/layout_2020/Cargo.toml +++ b/components/layout_2020/Cargo.toml @@ -27,7 +27,6 @@ rayon = "1" script_layout_interface = {path = "../script_layout_interface"} script_traits = {path = "../script_traits"} serde = "1.0" -servo_arc = {path = "../servo_arc"} servo_url = {path = "../url"} style = {path = "../style", features = ["servo", "servo-layout-2020"]} style_traits = {path = "../style_traits"} diff --git a/components/layout_2020/fragment.rs b/components/layout_2020/fragment.rs deleted file mode 100644 index 71e23b7ffaa..00000000000 --- a/components/layout_2020/fragment.rs +++ /dev/null @@ -1,99 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -//! The `Fragment` type, which represents the leaves of the layout tree. - -use crate::context::LayoutContext; -use crate::ServoArc; -use app_units::Au; -use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutNode}; -use serde::ser::{Serialize, SerializeStruct, Serializer}; -use style::dom::OpaqueNode; -use style::logical_geometry::{LogicalMargin, LogicalRect}; -use style::properties::ComputedValues; -use style::selector_parser::RestyleDamage; -use style::servo::restyle_damage::ServoRestyleDamage; - -#[derive(Clone)] -pub struct Fragment { - pub node: OpaqueNode, - pub style: ServoArc, - pub border_box: LogicalRect, - pub border_padding: LogicalMargin, - pub margin: LogicalMargin, - pub specific: SpecificFragmentInfo, - pub restyle_damage: RestyleDamage, - pub pseudo: PseudoElementType, -} - -impl Serialize for Fragment { - fn serialize(&self, serializer: S) -> Result { - let mut serializer = serializer.serialize_struct("fragment", 3)?; - serializer.serialize_field("border_box", &self.border_box)?; - serializer.serialize_field("margin", &self.margin)?; - serializer.end() - } -} - -#[derive(Clone)] -pub enum SpecificFragmentInfo { - Generic, -} - -impl SpecificFragmentInfo { - fn restyle_damage(&self) -> RestyleDamage { - RestyleDamage::empty() - } -} - -impl Fragment { - /// Constructs a new `Fragment` instance. - pub fn new( - node: &N, - specific: SpecificFragmentInfo, - ctx: &LayoutContext, - ) -> Fragment { - let shared_context = ctx.shared_context(); - let style = node.style(shared_context); - let writing_mode = style.writing_mode; - - let mut restyle_damage = RestyleDamage::rebuild_and_reflow(); - restyle_damage.remove(ServoRestyleDamage::RECONSTRUCT_FLOW); - - Fragment { - node: node.opaque(), - style: style, - restyle_damage: restyle_damage, - border_box: LogicalRect::zero(writing_mode), - border_padding: LogicalMargin::zero(writing_mode), - margin: LogicalMargin::zero(writing_mode), - specific: specific, - pseudo: node.get_pseudo_element_type(), - } - } - - pub fn restyle_damage(&self) -> RestyleDamage { - self.restyle_damage | self.specific.restyle_damage() - } - - pub fn contains_node(&self, node_address: OpaqueNode) -> bool { - node_address == self.node - } - - /// Returns the sum of the inline-sizes of all the borders of this fragment. Note that this - /// can be expensive to compute, so if possible use the `border_padding` field instead. - #[inline] - pub fn border_width(&self) -> LogicalMargin { - self.style().logical_border_width() - } - - #[inline(always)] - pub fn style(&self) -> &ComputedValues { - &*self.style - } - - pub fn is_primary_fragment(&self) -> bool { - true - } -} diff --git a/components/layout_2020/lib.rs b/components/layout_2020/lib.rs index 4af20789529..af5709eae38 100644 --- a/components/layout_2020/lib.rs +++ b/components/layout_2020/lib.rs @@ -6,13 +6,7 @@ pub mod context; pub mod data; -mod fragment; pub mod opaque_node; pub mod query; pub mod traversal; pub mod wrapper; - -// For unit tests: -pub use crate::fragment::Fragment; - -use servo_arc::Arc as ServoArc;