diff options
Diffstat (limited to 'components/layout')
-rw-r--r-- | components/layout/block.rs | 2 | ||||
-rw-r--r-- | components/layout/construct.rs | 7 | ||||
-rw-r--r-- | components/layout/display_list_builder.rs | 2 | ||||
-rw-r--r-- | components/layout/flex.rs | 3 | ||||
-rw-r--r-- | components/layout/flow.rs | 6 | ||||
-rw-r--r-- | components/layout/fragment.rs | 16 | ||||
-rw-r--r-- | components/layout/generated_content.rs | 5 | ||||
-rw-r--r-- | components/layout/inline.rs | 10 | ||||
-rw-r--r-- | components/layout/lib.rs | 12 | ||||
-rw-r--r-- | components/layout/list_item.rs | 3 | ||||
-rw-r--r-- | components/layout/multicol.rs | 5 | ||||
-rw-r--r-- | components/layout/query.rs | 2 | ||||
-rw-r--r-- | components/layout/table.rs | 3 | ||||
-rw-r--r-- | components/layout/table_caption.rs | 3 | ||||
-rw-r--r-- | components/layout/table_cell.rs | 3 | ||||
-rw-r--r-- | components/layout/table_colgroup.rs | 3 | ||||
-rw-r--r-- | components/layout/table_row.rs | 3 | ||||
-rw-r--r-- | components/layout/table_rowgroup.rs | 3 | ||||
-rw-r--r-- | components/layout/table_wrapper.rs | 3 | ||||
-rw-r--r-- | components/layout/text.rs | 2 |
20 files changed, 50 insertions, 46 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs index 297bfcdc689..5e30c6f08ee 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -2134,7 +2134,7 @@ impl Flow for BlockFlow { self.build_display_list_for_block(state, BorderPaintingMode::Separate); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.fragment.repair_style(new_style) } diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 089209551ac..2f24629b5e4 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -13,6 +13,7 @@ #![deny(unsafe_code)] +use StyleArc; use app_units::Au; use block::BlockFlow; use context::{LayoutContext, with_thread_local_font_context}; @@ -107,7 +108,7 @@ pub enum ConstructionItem { /// Inline fragments and associated {ib} splits that have not yet found flows. InlineFragments(InlineFragmentsConstructionResult), /// Potentially ignorable whitespace. - Whitespace(OpaqueNode, PseudoElementType<()>, Arc<ServoComputedValues>, RestyleDamage), + Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ServoComputedValues>, RestyleDamage), /// TableColumn Fragment TableColumnFragment(Fragment), } @@ -675,7 +676,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> fn create_fragments_for_node_text_content(&self, fragments: &mut IntermediateInlineFragments, node: &ConcreteThreadSafeLayoutNode, - style: &Arc<ServoComputedValues>) { + style: &StyleArc<ServoComputedValues>) { // Fast path: If there is no text content, return immediately. let text_content = node.text_content(); if text_content.is_empty() { @@ -1804,7 +1805,7 @@ pub fn strip_ignorable_whitespace_from_end(this: &mut LinkedList<Fragment>) { /// If the 'unicode-bidi' property has a value other than 'normal', return the bidi control codes /// to inject before and after the text content of the element. -fn bidi_control_chars(style: &Arc<ServoComputedValues>) -> Option<(&'static str, &'static str)> { +fn bidi_control_chars(style: &StyleArc<ServoComputedValues>) -> Option<(&'static str, &'static str)> { use style::computed_values::direction::T::*; use style::computed_values::unicode_bidi::T::*; diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index a2453067e1f..878b1220336 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -577,7 +577,7 @@ fn build_border_radius(abs_bounds: &Rect<Au>, /// Get the border radius for the rectangle inside of a rounded border. This is useful /// for building the clip for the content inside the border. fn build_border_radius_for_inner_rect(outer_rect: &Rect<Au>, - style: Arc<ServoComputedValues>) + style: ::StyleArc<ServoComputedValues>) -> BorderRadii<Au> { let mut radii = build_border_radius(&outer_rect, style.get_border()); if radii.is_square() { diff --git a/components/layout/flex.rs b/components/layout/flex.rs index cf77455afa8..dd990c61510 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -21,7 +21,6 @@ use model::{IntrinsicISizes, MaybeAuto, SizeConstraint}; use model::{specified, specified_or_none}; use std::cmp::{max, min}; use std::ops::Range; -use std::sync::Arc; use style::computed_values::{align_content, align_self, flex_direction, flex_wrap, justify_content}; use style::computed_values::border_collapse; use style::logical_geometry::{Direction, LogicalSize}; @@ -970,7 +969,7 @@ impl Flow for FlexFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 27b5c291cc8..1944f0decbd 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -424,7 +424,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static { /// Attempts to perform incremental fixup of this flow by replacing its fragment's style with /// the new style. This can only succeed if the flow has exactly one fragment. - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>); + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>); /// Print any extra children (such as fragments) contained in this Flow /// for debugging purposes. Any items inserted into the tree will become @@ -561,7 +561,7 @@ pub trait MutableFlowUtils { /// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of /// calling them individually, since there is no reason not to perform both operations. - fn repair_style_and_bubble_inline_sizes(self, style: &Arc<ServoComputedValues>); + fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>); } pub trait MutableOwnedFlowUtils { @@ -1361,7 +1361,7 @@ impl<'a> MutableFlowUtils for &'a mut Flow { /// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of /// calling them individually, since there is no reason not to perform both operations. - fn repair_style_and_bubble_inline_sizes(self, style: &Arc<ServoComputedValues>) { + fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>) { self.repair_style(style); self.bubble_inline_sizes(); } diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 5c311ec3311..9f98ff318ec 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -6,6 +6,7 @@ #![deny(unsafe_code)] +use StyleArc; use app_units::Au; use canvas_traits::CanvasMsg; use context::{LayoutContext, with_thread_local_font_context}; @@ -39,7 +40,6 @@ use std::borrow::ToOwned; use std::cmp::{Ordering, max, min}; use std::collections::LinkedList; use std::sync::{Arc, Mutex}; -use style::arc_ptr_eq; use style::computed_values::{border_collapse, box_sizing, clear, color, display, mix_blend_mode}; use style::computed_values::{overflow_wrap, overflow_x, position, text_decoration_line, transform}; use style::computed_values::{transform_style, vertical_align, white_space, word_break}; @@ -95,10 +95,10 @@ pub struct Fragment { pub node: OpaqueNode, /// The CSS style of this fragment. - pub style: Arc<ServoComputedValues>, + pub style: StyleArc<ServoComputedValues>, /// The CSS style of this fragment when it's selected - pub selected_style: Arc<ServoComputedValues>, + pub selected_style: StyleArc<ServoComputedValues>, /// The position of this fragment relative to its owning flow. The size includes padding and /// border, but not margin. @@ -672,8 +672,8 @@ impl Fragment { /// Constructs a new `Fragment` instance from an opaque node. pub fn from_opaque_node_and_style(node: OpaqueNode, pseudo: PseudoElementType<()>, - style: Arc<ServoComputedValues>, - selected_style: Arc<ServoComputedValues>, + style: StyleArc<ServoComputedValues>, + selected_style: StyleArc<ServoComputedValues>, mut restyle_damage: RestyleDamage, specific: SpecificFragmentInfo) -> Fragment { @@ -702,7 +702,7 @@ impl Fragment { /// type. For the new anonymous fragment, layout-related values (border box, etc.) are reset to /// initial values. pub fn create_similar_anonymous_fragment(&self, - style: Arc<ServoComputedValues>, + style: StyleArc<ServoComputedValues>, specific: SpecificFragmentInfo) -> Fragment { let writing_mode = style.writing_mode; @@ -1846,7 +1846,7 @@ impl Fragment { match (&mut self.specific, &next_fragment.specific) { (&mut SpecificFragmentInfo::ScannedText(ref mut this_info), &SpecificFragmentInfo::ScannedText(ref other_info)) => { - debug_assert!(arc_ptr_eq(&this_info.run, &other_info.run)); + debug_assert!(::arc_ptr_eq(&this_info.run, &other_info.run)); this_info.range_end_including_stripped_whitespace = other_info.range_end_including_stripped_whitespace; if other_info.requires_line_break_afterward_if_wrapping_on_newlines() { @@ -2398,7 +2398,7 @@ impl Fragment { } } - pub fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + pub fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) { self.style = (*new_style).clone() } diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index a23fd165ecf..5f6f9b1e706 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -16,7 +16,6 @@ use gfx::display_list::OpaqueNode; use script_layout_interface::wrapper_traits::PseudoElementType; use smallvec::SmallVec; use std::collections::{HashMap, LinkedList}; -use std::sync::Arc; use style::computed_values::{display, list_style_type}; use style::computed_values::content::ContentItem; use style::properties::ServoComputedValues; @@ -369,7 +368,7 @@ impl Counter { layout_context: &LayoutContext, node: OpaqueNode, pseudo: PseudoElementType<()>, - style: Arc<ServoComputedValues>, + style: ::StyleArc<ServoComputedValues>, list_style_type: list_style_type::T, mode: RenderingMode) -> Option<SpecificFragmentInfo> { @@ -432,7 +431,7 @@ struct CounterValue { fn render_text(layout_context: &LayoutContext, node: OpaqueNode, pseudo: PseudoElementType<()>, - style: Arc<ServoComputedValues>, + style: ::StyleArc<ServoComputedValues>, string: String) -> Option<SpecificFragmentInfo> { let mut fragments = LinkedList::new(); diff --git a/components/layout/inline.rs b/components/layout/inline.rs index f28e583460f..d8cd4003ab3 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -4,6 +4,7 @@ #![deny(unsafe_code)] +use StyleArc; use app_units::Au; use block::AbsoluteAssignBSizesTraversal; use context::LayoutContext; @@ -29,7 +30,6 @@ use std::{fmt, i32, isize, mem}; use std::cmp::max; use std::collections::VecDeque; use std::sync::Arc; -use style::arc_ptr_eq; use style::computed_values::{display, overflow_x, position, text_align, text_justify}; use style::computed_values::{vertical_align, white_space}; use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; @@ -398,7 +398,7 @@ impl LineBreaker { result.border_padding.inline_end == Au(0) && candidate.border_padding.inline_start == Au(0) && result_info.selected() == candidate_info.selected() && - arc_ptr_eq(&result_info.run, &candidate_info.run) && + ::arc_ptr_eq(&result_info.run, &candidate_info.run) && inline_contexts_are_equal(&result.inline_context, &candidate.inline_context) } @@ -1657,7 +1657,7 @@ impl Flow for InlineFlow { self.build_display_list_for_inline(state); } - fn repair_style(&mut self, _: &Arc<ServoComputedValues>) {} + fn repair_style(&mut self, _: &StyleArc<ServoComputedValues>) {} fn compute_overflow(&self) -> Overflow { let mut overflow = Overflow::new(); @@ -1746,8 +1746,8 @@ impl fmt::Debug for InlineFlow { #[derive(Clone)] pub struct InlineFragmentNodeInfo { pub address: OpaqueNode, - pub style: Arc<ServoComputedValues>, - pub selected_style: Arc<ServoComputedValues>, + pub style: StyleArc<ServoComputedValues>, + pub selected_style: StyleArc<ServoComputedValues>, pub pseudo: PseudoElementType<()>, pub flags: InlineFragmentNodeFlags, } diff --git a/components/layout/lib.rs b/components/layout/lib.rs index 4c5bd766e24..dd86ba46cde 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -93,3 +93,15 @@ pub mod wrapper; // For unit tests: pub use fragment::Fragment; pub use fragment::SpecificFragmentInfo; + +/// Returns whether the two arguments point to the same value. +/// +/// FIXME: Remove this and use Arc::ptr_eq once we require Rust 1.17 +#[inline] +pub fn arc_ptr_eq<T: 'static>(a: &::std::sync::Arc<T>, b: &::std::sync::Arc<T>) -> bool { + ::style::ptr_eq::<T>(&**a, &**b) +} + +// We can't use stylearc for everything in layout, because the Flow stuff uses +// weak references. +use style::stylearc::Arc as StyleArc; diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index cb260480cb9..8a79aaa40b7 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -18,7 +18,6 @@ use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedC use fragment::Overflow; use generated_content; use inline::InlineFlow; -use std::sync::Arc; use style::computed_values::{list_style_type, position}; use style::logical_geometry::LogicalSize; use style::properties::ServoComputedValues; @@ -148,7 +147,7 @@ impl Flow for ListItemFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index 18cfe6409cb..b43a6eb17ff 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -6,6 +6,7 @@ #![deny(unsafe_code)] +use StyleArc; use app_units::Au; use block::BlockFlow; use context::LayoutContext; @@ -193,7 +194,7 @@ impl Flow for MulticolFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } @@ -275,7 +276,7 @@ impl Flow for MulticolColumnFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/query.rs b/components/layout/query.rs index 92c3a1525dd..6b594066963 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -55,7 +55,7 @@ pub struct LayoutThreadData { pub display_list: Option<Arc<DisplayList>>, /// Performs CSS selector matching and style resolution. - pub stylist: Arc<Stylist>, + pub stylist: ::StyleArc<Stylist>, /// A queued response for the union of the content boxes of a node. pub content_box_response: Option<Rect<Au>>, diff --git a/components/layout/table.rs b/components/layout/table.rs index b130b62bd04..c3ba52a305b 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -21,7 +21,6 @@ use layout_debug; use model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto}; use std::cmp; use std::fmt; -use std::sync::Arc; use style::computed_values::{border_collapse, border_spacing, table_layout}; use style::context::SharedStyleContext; use style::logical_geometry::LogicalSize; @@ -507,7 +506,7 @@ impl Flow for TableFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs index fe3eb5bf692..99d95fd9587 100644 --- a/components/layout/table_caption.rs +++ b/components/layout/table_caption.rs @@ -15,7 +15,6 @@ use flow::{Flow, FlowClass, OpaqueFlow}; use fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use gfx_traits::print_tree::PrintTree; use std::fmt; -use std::sync::Arc; use style::logical_geometry::LogicalSize; use style::properties::ServoComputedValues; @@ -84,7 +83,7 @@ impl Flow for TableCaptionFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index b40d25e936c..8c54297d4b5 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -19,7 +19,6 @@ use layout_debug; use model::MaybeAuto; use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode; use std::fmt; -use std::sync::Arc; use style::computed_values::{border_collapse, border_top_style, vertical_align}; use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use style::properties::ServoComputedValues; @@ -264,7 +263,7 @@ impl Flow for TableCellFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index 5603a02e3c9..85d5207646e 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -15,7 +15,6 @@ use fragment::{Fragment, FragmentBorderBoxIterator, Overflow, SpecificFragmentIn use layout_debug; use std::cmp::max; use std::fmt; -use std::sync::Arc; use style::logical_geometry::LogicalSize; use style::properties::ServoComputedValues; use style::values::computed::LengthOrPercentageOrAuto; @@ -95,7 +94,7 @@ impl Flow for TableColGroupFlow { fn collect_stacking_contexts(&mut self, _: &mut DisplayListBuildState) {} - fn repair_style(&mut self, _: &Arc<ServoComputedValues>) {} + fn repair_style(&mut self, _: &::StyleArc<ServoComputedValues>) {} fn compute_overflow(&self) -> Overflow { Overflow::new() diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index d1c7146d247..8d074f59c52 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -22,7 +22,6 @@ use serde::{Serialize, Serializer}; use std::cmp::max; use std::fmt; use std::iter::{Enumerate, IntoIterator, Peekable}; -use std::sync::Arc; use style::computed_values::{border_collapse, border_spacing, border_top_style}; use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode}; use style::properties::ServoComputedValues; @@ -483,7 +482,7 @@ impl Flow for TableRowFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index e4c4291bce4..7664796b082 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -18,7 +18,6 @@ use layout_debug; use serde::{Serialize, Serializer}; use std::fmt; use std::iter::{IntoIterator, Iterator, Peekable}; -use std::sync::Arc; use style::computed_values::{border_collapse, border_spacing}; use style::logical_geometry::LogicalSize; use style::properties::ServoComputedValues; @@ -186,7 +185,7 @@ impl Flow for TableRowGroupFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 64799a37e42..015f32a9762 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -27,7 +27,6 @@ use model::MaybeAuto; use std::cmp::{max, min}; use std::fmt; use std::ops::Add; -use std::sync::Arc; use style::computed_values::{border_collapse, position, table_layout}; use style::context::SharedStyleContext; use style::logical_geometry::{LogicalRect, LogicalSize}; @@ -467,7 +466,7 @@ impl Flow for TableWrapperFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/text.rs b/components/layout/text.rs index 5c9b93edee1..43b2fd086e7 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -435,7 +435,7 @@ fn bounding_box_for_run_metrics(metrics: &RunMetrics, writing_mode: WritingMode) /// /// `#[inline]` because often the caller only needs a few fields from the font metrics. #[inline] -pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<style_structs::Font>) +pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: ::StyleArc<style_structs::Font>) -> FontMetrics { let fontgroup = font_context.layout_font_group_for_style(font_style); // FIXME(https://github.com/rust-lang/rust/issues/23338) |