diff options
38 files changed, 302 insertions, 316 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs index 6a3db5a6141..3ae8a439a4d 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -56,7 +56,7 @@ use style::computed_values::{border_collapse, box_sizing, display, float, overfl use style::computed_values::{position, text_align}; use style::context::SharedStyleContext; use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode}; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION}; use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage}; use style::values::computed::LengthOrPercentageOrAuto; @@ -2139,7 +2139,7 @@ impl Flow for BlockFlow { self.build_display_list_for_block(state, BorderPaintingMode::Separate); } - fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) { self.fragment.repair_style(new_style) } diff --git a/components/layout/construct.rs b/components/layout/construct.rs index cbb4400544e..cfb92ebc78a 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -52,7 +52,7 @@ use style::computed_values::content::ContentItem; use style::computed_values::position; use style::context::SharedStyleContext; use style::logical_geometry::Direction; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::properties::longhands::list_style_image; use style::selector_parser::{PseudoElement, RestyleDamage}; use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW}; @@ -109,7 +109,7 @@ pub enum ConstructionItem { /// Inline fragments and associated {ib} splits that have not yet found flows. InlineFragments(InlineFragmentsConstructionResult), /// Potentially ignorable whitespace. - Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ServoComputedValues>, RestyleDamage), + Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ComputedValues>, RestyleDamage), /// TableColumn Fragment TableColumnFragment(Fragment), } @@ -677,7 +677,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> fn create_fragments_for_node_text_content(&self, fragments: &mut IntermediateInlineFragments, node: &ConcreteThreadSafeLayoutNode, - style: &StyleArc<ServoComputedValues>) { + style: &StyleArc<ComputedValues>) { // Fast path: If there is no text content, return immediately. let text_content = node.text_content(); if text_content.is_empty() { @@ -1806,7 +1806,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: &StyleArc<ServoComputedValues>) -> Option<(&'static str, &'static str)> { +fn bidi_control_chars(style: &StyleArc<ComputedValues>) -> Option<(&'static str, &'static str)> { use style::computed_values::direction::T::*; use style::computed_values::unicode_bidi::T::*; @@ -1851,7 +1851,7 @@ trait ComputedValueUtils { fn has_padding_or_border(&self) -> bool; } -impl ComputedValueUtils for ServoComputedValues { +impl ComputedValueUtils for ComputedValues { fn has_padding_or_border(&self) -> bool { let padding = self.get_padding(); let border = self.get_border(); diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 4b79c5e7a68..025a5d5f654 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -51,7 +51,7 @@ use style::computed_values::{background_attachment, background_clip, background_ use style::computed_values::{background_repeat, border_style, cursor}; use style::computed_values::{image_rendering, overflow_x, pointer_events, position, visibility}; use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode}; -use style::properties::{self, ServoComputedValues}; +use style::properties::{self, ComputedValues}; use style::properties::longhands::border_image_repeat::computed_value::RepeatKeyword; use style::properties::style_structs; use style::servo::restyle_damage::REPAINT; @@ -375,14 +375,14 @@ pub trait FragmentDisplayListBuilding { /// list if necessary. fn build_display_list_for_background_if_applicable(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: &Rect<Au>); /// Computes the background size for an image with the given background area according to the /// rules in CSS-BACKGROUNDS § 3.9. fn compute_background_image_size(&self, - style: &ServoComputedValues, + style: &ComputedValues, bounds: &Rect<Au>, image: &WebRenderImageInfo, index: usize) -> Size2D<Au>; @@ -391,7 +391,7 @@ pub trait FragmentDisplayListBuilding { /// appropriate section of the display list. fn build_display_list_for_background_image(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: &Rect<Au>, clip: &LocalClip, @@ -402,7 +402,7 @@ pub trait FragmentDisplayListBuilding { /// appropriate section of the display list. fn build_display_list_for_webrender_image(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: &Rect<Au>, clip: &LocalClip, @@ -413,7 +413,7 @@ pub trait FragmentDisplayListBuilding { /// worklet to the appropriate section of the display list. fn build_display_list_for_background_paint_worklet(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: &Rect<Au>, clip: &LocalClip, @@ -443,14 +443,14 @@ pub trait FragmentDisplayListBuilding { absolute_bounds: &Rect<Au>, clip: &LocalClip, gradient: &Gradient, - style: &ServoComputedValues); + style: &ComputedValues); /// Adds the display items necessary to paint the borders of this fragment to a display list if /// necessary. fn build_display_list_for_borders_if_applicable( &self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, border_painting_mode: BorderPaintingMode, bounds: &Rect<Au>, display_list_section: DisplayListSection, @@ -460,7 +460,7 @@ pub trait FragmentDisplayListBuilding { /// if necessary. fn build_display_list_for_outline_if_applicable(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, bounds: &Rect<Au>, clip: &Rect<Au>); @@ -468,7 +468,7 @@ pub trait FragmentDisplayListBuilding { /// list if necessary. fn build_display_list_for_box_shadow_if_applicable(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: &Rect<Au>, clip: &Rect<Au>); @@ -476,7 +476,7 @@ pub trait FragmentDisplayListBuilding { /// Adds display items necessary to draw debug boxes around a scanned text fragment. fn build_debug_borders_around_text_fragments(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, stacking_relative_border_box: &Rect<Au>, stacking_relative_content_box: &Rect<Au>, text_fragment: &ScannedTextFragmentInfo, @@ -607,7 +607,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: &ServoComputedValues) + style: &ComputedValues) -> BorderRadii<Au> { let mut radii = build_border_radius(&outer_rect, style.get_border()); if radii.is_square() { @@ -633,7 +633,7 @@ fn build_border_radius_for_inner_rect(outer_rect: &Rect<Au>, } fn build_inner_border_box_for_border_rect(border_box: &Rect<Au>, - style: &ServoComputedValues) + style: &ComputedValues) -> Rect<Au> { let border_widths = style.logical_border_width().to_physical(style.writing_mode); let mut inner_border_box = *border_box; @@ -845,7 +845,7 @@ fn convert_ellipse_size_keyword(keyword: ShapeExtent, impl FragmentDisplayListBuilding for Fragment { fn build_display_list_for_background_if_applicable(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: &Rect<Au>) { // FIXME: This causes a lot of background colors to be displayed when they are clearly not @@ -950,7 +950,7 @@ impl FragmentDisplayListBuilding for Fragment { } fn compute_background_image_size(&self, - style: &ServoComputedValues, + style: &ComputedValues, bounds: &Rect<Au>, image: &WebRenderImageInfo, index: usize) @@ -996,7 +996,7 @@ impl FragmentDisplayListBuilding for Fragment { fn build_display_list_for_background_image(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: &Rect<Au>, clip: &LocalClip, @@ -1020,7 +1020,7 @@ impl FragmentDisplayListBuilding for Fragment { fn build_display_list_for_webrender_image(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: &Rect<Au>, clip: &LocalClip, @@ -1157,7 +1157,7 @@ impl FragmentDisplayListBuilding for Fragment { fn build_display_list_for_background_paint_worklet(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: &Rect<Au>, clip: &LocalClip, @@ -1338,7 +1338,7 @@ impl FragmentDisplayListBuilding for Fragment { absolute_bounds: &Rect<Au>, clip: &LocalClip, gradient: &Gradient, - style: &ServoComputedValues) { + style: &ComputedValues) { let border = self.border_width().to_physical(style.writing_mode); let mut bounds = *absolute_bounds; bounds.origin.x = bounds.origin.x + border.left; @@ -1380,7 +1380,7 @@ impl FragmentDisplayListBuilding for Fragment { fn build_display_list_for_box_shadow_if_applicable(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: &Rect<Au>, clip: &Rect<Au>) { @@ -1423,7 +1423,7 @@ impl FragmentDisplayListBuilding for Fragment { fn build_display_list_for_borders_if_applicable( &self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, border_painting_mode: BorderPaintingMode, bounds: &Rect<Au>, display_list_section: DisplayListSection, @@ -1570,7 +1570,7 @@ impl FragmentDisplayListBuilding for Fragment { fn build_display_list_for_outline_if_applicable(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, bounds: &Rect<Au>, clip: &Rect<Au>) { use style::values::Either; @@ -1615,7 +1615,7 @@ impl FragmentDisplayListBuilding for Fragment { fn build_debug_borders_around_text_fragments(&self, state: &mut DisplayListBuildState, - style: &ServoComputedValues, + style: &ComputedValues, stacking_relative_border_box: &Rect<Au>, stacking_relative_content_box: &Rect<Au>, text_fragment: &ScannedTextFragmentInfo, @@ -2886,12 +2886,12 @@ impl BaseFlowDisplayListBuilding for BaseFlow { } } -trait ServoComputedValuesCursorUtility { +trait ComputedValuesCursorUtility { fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor>; } -impl ServoComputedValuesCursorUtility for ServoComputedValues { - /// Gets the cursor to use given the specific ServoComputedValues. `default_cursor` specifies +impl ComputedValuesCursorUtility for ComputedValues { + /// Gets the cursor to use given the specific ComputedValues. `default_cursor` specifies /// the cursor to use if `cursor` is `auto`. Typically, this will be `PointerCursor`, but for /// text display items it may be `TextCursor` or `VerticalTextCursor`. #[inline] diff --git a/components/layout/flex.rs b/components/layout/flex.rs index 30295eabfe7..6b2e5d3425a 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -23,7 +23,7 @@ use std::ops::Range; 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}; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW}; use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; use style::values::computed::flex::FlexBasis; @@ -973,7 +973,7 @@ impl Flow for FlexFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 240942ec843..be71745883f 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -52,7 +52,7 @@ use std::sync::atomic::Ordering; use style::computed_values::{clear, float, overflow_x, position, text_align}; use style::context::SharedStyleContext; use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::selector_parser::RestyleDamage; use style::servo::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION}; use style::values::computed::LengthOrPercentageOrAuto; @@ -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: &::StyleArc<ServoComputedValues>); + fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>); /// 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: &::StyleArc<ServoComputedValues>); + fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ComputedValues>); } pub trait MutableOwnedFlowUtils { @@ -1033,7 +1033,7 @@ pub enum ForceNonfloatedFlag { impl BaseFlow { #[inline] - pub fn new(style: Option<&ServoComputedValues>, + pub fn new(style: Option<&ComputedValues>, writing_mode: WritingMode, force_nonfloated: ForceNonfloatedFlag) -> BaseFlow { @@ -1381,7 +1381,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: &::StyleArc<ServoComputedValues>) { + fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ComputedValues>) { self.repair_style(style); mut_base(self).update_flags_if_needed(style); self.bubble_inline_sizes(); diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index b9bbe5ddd6e..9e7eaf6c72f 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -45,7 +45,7 @@ use style::computed_values::{overflow_wrap, overflow_x, position, text_decoratio use style::computed_values::{transform_style, vertical_align, white_space, word_break}; use style::computed_values::content::ContentItem; use style::logical_geometry::{Direction, LogicalMargin, LogicalRect, LogicalSize, WritingMode}; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::selector_parser::RestyleDamage; use style::servo::restyle_damage::RECONSTRUCT_FLOW; use style::str::char_is_whitespace; @@ -95,10 +95,10 @@ pub struct Fragment { pub node: OpaqueNode, /// The CSS style of this fragment. - pub style: StyleArc<ServoComputedValues>, + pub style: StyleArc<ComputedValues>, /// The CSS style of this fragment when it's selected - pub selected_style: StyleArc<ServoComputedValues>, + pub selected_style: StyleArc<ComputedValues>, /// The position of this fragment relative to its owning flow. The size includes padding and /// border, but not margin. @@ -676,8 +676,8 @@ impl Fragment { /// Constructs a new `Fragment` instance from an opaque node. pub fn from_opaque_node_and_style(node: OpaqueNode, pseudo: PseudoElementType<()>, - style: StyleArc<ServoComputedValues>, - selected_style: StyleArc<ServoComputedValues>, + style: StyleArc<ComputedValues>, + selected_style: StyleArc<ComputedValues>, mut restyle_damage: RestyleDamage, specific: SpecificFragmentInfo) -> Fragment { @@ -706,7 +706,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: StyleArc<ServoComputedValues>, + style: StyleArc<ComputedValues>, specific: SpecificFragmentInfo) -> Fragment { let writing_mode = style.writing_mode; @@ -1339,7 +1339,7 @@ impl Fragment { // Return offset from original position because of `position: relative`. pub fn relative_position(&self, containing_block_size: &LogicalSize<Au>) -> LogicalSize<Au> { - fn from_style(style: &ServoComputedValues, container_size: &LogicalSize<Au>) + fn from_style(style: &ComputedValues, container_size: &LogicalSize<Au>) -> LogicalSize<Au> { let offsets = style.logical_position(); let offset_i = if offsets.inline_start != LengthOrPercentageOrAuto::Auto { @@ -1392,12 +1392,12 @@ impl Fragment { } #[inline(always)] - pub fn style(&self) -> &ServoComputedValues { + pub fn style(&self) -> &ComputedValues { &*self.style } #[inline(always)] - pub fn selected_style(&self) -> &ServoComputedValues { + pub fn selected_style(&self) -> &ComputedValues { &*self.selected_style } @@ -2142,7 +2142,7 @@ impl Fragment { }; return inline_metrics; - fn inline_metrics_of_block(flow: &FlowRef, style: &ServoComputedValues) -> InlineMetrics { + fn inline_metrics_of_block(flow: &FlowRef, style: &ComputedValues) -> InlineMetrics { // CSS 2.1 § 10.8: "The height of each inline-level box in the line box is calculated. // For replaced elements, inline-block elements, and inline-table elements, this is the // height of their margin box." @@ -2423,7 +2423,7 @@ impl Fragment { } } - pub fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) { + pub fn repair_style(&mut self, new_style: &StyleArc<ComputedValues>) { self.style = (*new_style).clone() } @@ -3038,9 +3038,9 @@ pub struct InlineStyleIterator<'a> { } impl<'a> Iterator for InlineStyleIterator<'a> { - type Item = &'a ServoComputedValues; + type Item = &'a ComputedValues; - fn next(&mut self) -> Option<&'a ServoComputedValues> { + fn next(&mut self) -> Option<&'a ComputedValues> { if !self.primary_style_yielded { self.primary_style_yielded = true; return Some(&*self.fragment.style) diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index 5f6f9b1e706..281c5965c9f 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -18,7 +18,7 @@ use smallvec::SmallVec; use std::collections::{HashMap, LinkedList}; use style::computed_values::{display, list_style_type}; use style::computed_values::content::ContentItem; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::selector_parser::RestyleDamage; use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT; use text::TextRunScanner; @@ -298,7 +298,7 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> { self.incremented = true } - fn quote(&self, style: &ServoComputedValues, close: bool) -> String { + fn quote(&self, style: &ComputedValues, close: bool) -> String { let quotes = &style.get_list().quotes; if quotes.0.is_empty() { return String::new() @@ -368,7 +368,7 @@ impl Counter { layout_context: &LayoutContext, node: OpaqueNode, pseudo: PseudoElementType<()>, - style: ::StyleArc<ServoComputedValues>, + style: ::StyleArc<ComputedValues>, list_style_type: list_style_type::T, mode: RenderingMode) -> Option<SpecificFragmentInfo> { @@ -431,7 +431,7 @@ struct CounterValue { fn render_text(layout_context: &LayoutContext, node: OpaqueNode, pseudo: PseudoElementType<()>, - style: ::StyleArc<ServoComputedValues>, + style: ::StyleArc<ComputedValues>, string: String) -> Option<SpecificFragmentInfo> { let mut fragments = LinkedList::new(); diff --git a/components/layout/inline.rs b/components/layout/inline.rs index de58b05255b..9228c21a7ba 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -33,7 +33,7 @@ use std::sync::Arc; 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}; -use style::properties::{longhands, ServoComputedValues}; +use style::properties::{longhands, ComputedValues}; use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION, RESOLVE_GENERATED_CONTENT}; use text; use unicode_bidi as bidi; @@ -1106,7 +1106,7 @@ impl InlineFlow { /// Computes the minimum metrics for each line. This is done during flow construction. /// /// `style` is the style of the block. - pub fn minimum_line_metrics(&self, font_context: &mut FontContext, style: &ServoComputedValues) + pub fn minimum_line_metrics(&self, font_context: &mut FontContext, style: &ComputedValues) -> LineMetrics { InlineFlow::minimum_line_metrics_for_fragments(&self.fragments.fragments, font_context, @@ -1119,7 +1119,7 @@ impl InlineFlow { /// `style` is the style of the block that these fragments belong to. pub fn minimum_line_metrics_for_fragments(fragments: &[Fragment], font_context: &mut FontContext, - style: &ServoComputedValues) + style: &ComputedValues) -> LineMetrics { // As a special case, if this flow contains only hypothetical fragments, then the entire // flow is hypothetical and takes up no space. See CSS 2.1 § 10.3.7. @@ -1665,7 +1665,7 @@ impl Flow for InlineFlow { self.build_display_list_for_inline(state); } - fn repair_style(&mut self, _: &StyleArc<ServoComputedValues>) {} + fn repair_style(&mut self, _: &StyleArc<ComputedValues>) {} fn compute_overflow(&self) -> Overflow { let mut overflow = Overflow::new(); @@ -1754,8 +1754,8 @@ impl fmt::Debug for InlineFlow { #[derive(Clone)] pub struct InlineFragmentNodeInfo { pub address: OpaqueNode, - pub style: StyleArc<ServoComputedValues>, - pub selected_style: StyleArc<ServoComputedValues>, + pub style: StyleArc<ComputedValues>, + pub selected_style: StyleArc<ComputedValues>, pub pseudo: PseudoElementType<()>, pub flags: InlineFragmentNodeFlags, } diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index cb8cd27df70..faf8ae259fc 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -20,7 +20,7 @@ use generated_content; use inline::InlineFlow; use style::computed_values::{list_style_type, position}; use style::logical_geometry::LogicalSize; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT; /// A block with the CSS `display` property equal to `list-item`. @@ -147,7 +147,7 @@ impl Flow for ListItemFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/model.rs b/components/layout/model.rs index 7f564a599ab..c96c3bdaaf5 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -13,7 +13,7 @@ use std::cmp::{max, min}; use std::fmt; use style::computed_values::transform::ComputedMatrix; use style::logical_geometry::{LogicalMargin, WritingMode}; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::values::computed::{BorderCornerRadius, LengthOrPercentageOrAuto}; use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone}; @@ -481,7 +481,7 @@ pub fn specified_border_radius( } #[inline] -pub fn padding_from_style(style: &ServoComputedValues, +pub fn padding_from_style(style: &ComputedValues, containing_block_inline_size: Au, writing_mode: WritingMode) -> LogicalMargin<Au> { @@ -498,7 +498,7 @@ pub fn padding_from_style(style: &ServoComputedValues, /// /// This is used when calculating intrinsic inline sizes. #[inline] -pub fn specified_margin_from_style(style: &ServoComputedValues, +pub fn specified_margin_from_style(style: &ComputedValues, writing_mode: WritingMode) -> LogicalMargin<Au> { let margin_style = style.get_margin(); LogicalMargin::from_physical(writing_mode, SideOffsets2D::new( diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index afe45c2aea7..739341ab4e3 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -20,7 +20,7 @@ use std::cmp::{min, max}; use std::fmt; use std::sync::Arc; use style::logical_geometry::LogicalSize; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::values::Either; use style::values::computed::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; @@ -193,7 +193,7 @@ impl Flow for MulticolFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &StyleArc<ComputedValues>) { self.block_flow.repair_style(new_style) } @@ -275,7 +275,7 @@ impl Flow for MulticolColumnFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &StyleArc<ComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table.rs b/components/layout/table.rs index d199b059a69..809e2ac4e29 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -24,7 +24,7 @@ use std::fmt; use style::computed_values::{border_collapse, border_spacing, table_layout}; use style::context::SharedStyleContext; use style::logical_geometry::LogicalSize; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW}; use style::values::CSSFloat; use style::values::computed::LengthOrPercentageOrAuto; @@ -506,7 +506,7 @@ impl Flow for TableFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs index 99d95fd9587..c225339b082 100644 --- a/components/layout/table_caption.rs +++ b/components/layout/table_caption.rs @@ -16,7 +16,7 @@ use fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use gfx_traits::print_tree::PrintTree; use std::fmt; use style::logical_geometry::LogicalSize; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; /// A table formatting context. pub struct TableCaptionFlow { @@ -83,7 +83,7 @@ impl Flow for TableCaptionFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index 47f74891488..6ba7667a0a9 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -20,7 +20,7 @@ use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode; use std::fmt; use style::computed_values::{border_collapse, border_top_style, vertical_align}; use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::values::computed::Color; use table::InternalTable; use table_row::{CollapsedBorder, CollapsedBorderProvenance}; @@ -263,7 +263,7 @@ impl Flow for TableCellFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index 85d5207646e..4967f19ee73 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -16,7 +16,7 @@ use layout_debug; use std::cmp::max; use std::fmt; use style::logical_geometry::LogicalSize; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::values::computed::LengthOrPercentageOrAuto; /// A table formatting context. @@ -94,7 +94,7 @@ impl Flow for TableColGroupFlow { fn collect_stacking_contexts(&mut self, _: &mut DisplayListBuildState) {} - fn repair_style(&mut self, _: &::StyleArc<ServoComputedValues>) {} + fn repair_style(&mut self, _: &::StyleArc<ComputedValues>) {} fn compute_overflow(&self) -> Overflow { Overflow::new() diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 45b47ee8de5..cc683096831 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -23,7 +23,7 @@ use std::fmt; use std::iter::{Enumerate, IntoIterator, Peekable}; use style::computed_values::{border_collapse, border_spacing, border_top_style}; use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode}; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW}; use style::values::computed::{Color, LengthOrPercentageOrAuto}; use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt}; @@ -481,7 +481,7 @@ impl Flow for TableRowFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) { self.block_flow.repair_style(new_style) } @@ -612,7 +612,7 @@ impl CollapsedBorder { /// Creates a collapsed border from the block-start border described in the given CSS style /// object. - fn top(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) + fn top(css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { CollapsedBorder { style: css_style.get_border().border_top_style, @@ -624,7 +624,7 @@ impl CollapsedBorder { /// Creates a collapsed border style from the right border described in the given CSS style /// object. - fn right(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) + fn right(css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { CollapsedBorder { style: css_style.get_border().border_right_style, @@ -636,7 +636,7 @@ impl CollapsedBorder { /// Creates a collapsed border style from the bottom border described in the given CSS style /// object. - fn bottom(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) + fn bottom(css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { CollapsedBorder { style: css_style.get_border().border_bottom_style, @@ -648,7 +648,7 @@ impl CollapsedBorder { /// Creates a collapsed border style from the left border described in the given CSS style /// object. - fn left(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) + fn left(css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { CollapsedBorder { style: css_style.get_border().border_left_style, @@ -660,7 +660,7 @@ impl CollapsedBorder { /// Creates a collapsed border style from the given physical side. fn from_side(side: PhysicalSide, - css_style: &ServoComputedValues, + css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { match side { @@ -673,7 +673,7 @@ impl CollapsedBorder { /// Creates a collapsed border style from the inline-start border described in the given CSS /// style object. - pub fn inline_start(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) + pub fn inline_start(css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { CollapsedBorder::from_side(css_style.writing_mode.inline_start_physical_side(), css_style, @@ -682,7 +682,7 @@ impl CollapsedBorder { /// Creates a collapsed border style from the inline-start border described in the given CSS /// style object. - pub fn inline_end(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) + pub fn inline_end(css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { CollapsedBorder::from_side(css_style.writing_mode.inline_end_physical_side(), css_style, @@ -691,7 +691,7 @@ impl CollapsedBorder { /// Creates a collapsed border style from the block-start border described in the given CSS /// style object. - pub fn block_start(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) + pub fn block_start(css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { CollapsedBorder::from_side(css_style.writing_mode.block_start_physical_side(), css_style, @@ -700,7 +700,7 @@ impl CollapsedBorder { /// Creates a collapsed border style from the block-end border described in the given CSS style /// object. - pub fn block_end(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) + pub fn block_end(css_style: &ComputedValues, provenance: CollapsedBorderProvenance) -> CollapsedBorder { CollapsedBorder::from_side(css_style.writing_mode.block_end_physical_side(), css_style, @@ -909,7 +909,7 @@ pub struct BorderCollapseInfoForChildTableCell<'a> { /// table row. This is done eagerly here so that at least the inline inside border collapse /// computations can be parallelized across all the rows of the table. fn perform_inline_direction_border_collapse_for_row( - row_style: &ServoComputedValues, + row_style: &ComputedValues, children_count: usize, child_index: usize, child_table_cell: &mut TableCellFlow, diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index 7664796b082..779832923d0 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -20,7 +20,7 @@ use std::fmt; use std::iter::{IntoIterator, Iterator, Peekable}; use style::computed_values::{border_collapse, border_spacing}; use style::logical_geometry::LogicalSize; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use table::{ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow}; /// A table formatting context. @@ -185,7 +185,7 @@ impl Flow for TableRowGroupFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 015f32a9762..ac0e6025c67 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -30,7 +30,7 @@ use std::ops::Add; use style::computed_values::{border_collapse, position, table_layout}; use style::context::SharedStyleContext; use style::logical_geometry::{LogicalRect, LogicalSize}; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::values::CSSFloat; use style::values::computed::LengthOrPercentageOrAuto; use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize}; @@ -466,7 +466,7 @@ impl Flow for TableWrapperFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/text.rs b/components/layout/text.rs index 10093f251b8..ab2f941fc03 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -26,7 +26,7 @@ use std::sync::Arc; use style::computed_values::{text_rendering, text_transform}; use style::computed_values::{word_break, white_space}; use style::logical_geometry::{LogicalSize, WritingMode}; -use style::properties::ServoComputedValues; +use style::properties::ComputedValues; use style::properties::style_structs; use style::values::generics::text::LineHeight; use unicode_bidi as bidi; @@ -445,7 +445,7 @@ pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: ::Styl } /// Returns the line block-size needed by the given computed style and font size. -pub fn line_height_from_style(style: &ServoComputedValues, metrics: &FontMetrics) -> Au { +pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) -> Au { let font_size = style.get_font().font_size; match style.get_inheritedtext().line_height { LineHeight::Normal => metrics.line_gap, diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs index 33ffc3b545b..a32a6e6b99c 100644 --- a/components/script_layout_interface/wrapper_traits.rs +++ b/components/script_layout_interface/wrapper_traits.rs @@ -22,7 +22,7 @@ use style::data::ElementData; use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthesizer, TNode}; use style::dom::OpaqueNode; use style::font_metrics::ServoMetricsProvider; -use style::properties::{CascadeFlags, ServoComputedValues}; +use style::properties::{CascadeFlags, ComputedValues}; use style::selector_parser::{PseudoElement, PseudoElementCascadeType, SelectorImpl}; use style::stylearc::Arc; use style::stylist::RuleInclusion; @@ -181,7 +181,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo /// it can be used to reach siblings and cousins. A simple immutable borrow /// of the parent data is fine, since the bottom-up traversal will not process /// the parent until all the children have been processed. - fn parent_style(&self) -> Arc<ServoComputedValues>; + fn parent_style(&self) -> Arc<ComputedValues>; #[inline] fn is_element_or_elements_pseudo(&self) -> bool { @@ -223,7 +223,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData>; - fn style(&self, context: &SharedStyleContext) -> Arc<ServoComputedValues> { + fn style(&self, context: &SharedStyleContext) -> Arc<ComputedValues> { if let Some(el) = self.as_element() { el.style(context) } else { @@ -234,7 +234,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo } } - fn selected_style(&self) -> Arc<ServoComputedValues> { + fn selected_style(&self) -> Arc<ComputedValues> { if let Some(el) = self.as_element() { el.selected_style() } else { @@ -393,7 +393,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug + /// /// Unlike the version on TNode, this handles pseudo-elements. #[inline] - fn style(&self, context: &SharedStyleContext) -> Arc<ServoComputedValues> { + fn style(&self, context: &SharedStyleContext) -> Arc<ComputedValues> { let data = self.style_data(); match self.get_pseudo_element_type() { PseudoElementType::Normal => { @@ -438,7 +438,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug + } #[inline] - fn selected_style(&self) -> Arc<ServoComputedValues> { + fn selected_style(&self) -> Arc<ComputedValues> { let data = self.style_data(); data.styles.pseudos .get(&PseudoElement::Selection).map(|s| s) @@ -454,7 +454,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug + /// This should be used just for querying layout, or when we know the /// element style is precomputed, not from general layout itself. #[inline] - fn resolved_style(&self) -> Arc<ServoComputedValues> { + fn resolved_style(&self) -> Arc<ComputedValues> { let data = self.style_data(); match self.get_pseudo_element_type() { PseudoElementType::Normal diff --git a/components/style/animation.rs b/components/style/animation.rs index a696d6bb303..84392bead13 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -11,7 +11,7 @@ use context::SharedStyleContext; use dom::OpaqueNode; use euclid::Point2D; use font_metrics::FontMetricsProvider; -use properties::{self, CascadeFlags, ComputedValues, Importance}; +use properties::{self, CascadeFlags, ComputedValues, ComputedValuesInner, Importance}; use properties::animated_properties::{AnimatableLonghand, AnimatedProperty, TransitionProperty}; use properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection; use properties::longhands::animation_iteration_count::single_value::computed_value::T as AnimationIterationCount; @@ -347,8 +347,8 @@ impl PropertyAnimation { fn from_animatable_longhand(animatable_longhand: &AnimatableLonghand, timing_function: TimingFunction, duration: Time, - old_style: &ComputedValues, - new_style: &ComputedValues) + old_style: &ComputedValuesInner, + new_style: &ComputedValuesInner) -> Option<PropertyAnimation> { let animated_property = AnimatedProperty::from_animatable_longhand(animatable_longhand, old_style, @@ -480,10 +480,10 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation> fn compute_style_for_animation_step(context: &SharedStyleContext, step: &KeyframesStep, - previous_style: &ComputedValues, - style_from_cascade: &ComputedValues, + previous_style: &ComputedValuesInner, + style_from_cascade: &ComputedValuesInner, font_metrics_provider: &FontMetricsProvider) - -> ComputedValues { + -> ComputedValuesInner { match step.value { KeyframesStepValue::ComputedValues => style_from_cascade.clone(), KeyframesStepValue::Declarations { block: ref declarations } => { diff --git a/components/style/dom.rs b/components/style/dom.rs index fefa193eba9..8a3e9e7643e 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -15,7 +15,7 @@ use data::ElementData; use element_state::ElementState; use font_metrics::FontMetricsProvider; use media_queries::Device; -use properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock}; +use properties::{AnimationRules, ComputedValues, ComputedValuesInner, PropertyDeclarationBlock}; #[cfg(feature = "gecko")] use properties::animated_properties::AnimationValue; #[cfg(feature = "gecko")] use properties::animated_properties::TransitionProperty; use rule_tree::CascadeLevel; @@ -436,7 +436,7 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone + fn may_generate_pseudo( &self, pseudo: &PseudoElement, - _primary_style: &ComputedValues, + _primary_style: &ComputedValuesInner, ) -> bool { // ::before/::after are always supported for now, though we could try to // optimize out leaf elements. diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs index c6a73714b26..88af4fed72d 100644 --- a/components/style/gecko/data.rs +++ b/components/style/gecko/data.rs @@ -16,7 +16,7 @@ use gecko_bindings::structs::nsIDocument; use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI}; use invalidation::media_queries::{MediaListKey, ToMediaListKey}; use media_queries::{Device, MediaList}; -use properties::ComputedValues; +use properties::ComputedValuesInner; use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard}; use stylearc::Arc; use stylesheet_set::StylesheetSet; @@ -188,8 +188,8 @@ impl PerDocumentStyleDataImpl { } /// Get the default computed values for this document. - pub fn default_computed_values(&self) -> &Arc<ComputedValues> { - self.stylist.device().default_computed_values_arc() + pub fn default_computed_values(&self) -> &ComputedValuesInner { + self.stylist.device().default_computed_values() } /// Clear the stylist. This will be a no-op if the stylist is diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index 58dbe0f9c9d..2e7d6c594e1 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -17,7 +17,7 @@ use gecko_bindings::structs::{nsMediaFeature_ValueType, nsMediaFeature_RangeType use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextOwned}; use media_queries::MediaType; use parser::ParserContext; -use properties::{ComputedValues, StyleBuilder}; +use properties::{ComputedValuesInner, StyleBuilder}; use properties::longhands::font_size; use selectors::parser::SelectorParseError; use std::fmt::{self, Write}; @@ -26,7 +26,6 @@ use str::starts_with_ignore_ascii_case; use string_cache::Atom; use style_traits::{ToCss, ParseError, StyleParseError}; use style_traits::viewport::ViewportConstraints; -use stylearc::Arc; use values::{CSSFloat, specified}; use values::computed::{self, ToComputedValue}; @@ -37,7 +36,7 @@ pub struct Device { /// stylist, and thus the `Device`, so having a raw pres context pointer /// here is fine. pres_context: RawGeckoPresContextOwned, - default_values: Arc<ComputedValues>, + default_values: ComputedValuesInner, viewport_override: Option<ViewportConstraints>, /// The font size of the root element /// This is set when computing the style of the root @@ -62,7 +61,7 @@ impl Device { assert!(!pres_context.is_null()); Device { pres_context: pres_context, - default_values: ComputedValues::default_values(unsafe { &*pres_context }), + default_values: ComputedValuesInner::default_values(unsafe { &*pres_context }), viewport_override: None, root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious? used_root_font_size: AtomicBool::new(false), @@ -78,19 +77,7 @@ impl Device { /// Returns the default computed values as a reference, in order to match /// Servo. - pub fn default_computed_values(&self) -> &ComputedValues { - &*self.default_values - } - - /// Returns the default computed values, but wrapped in an arc for cheap - /// cloning. - pub fn default_computed_values_arc(&self) -> &Arc<ComputedValues> { - &self.default_values - } - - /// Returns the default computed values as an `Arc`, in order to avoid - /// clones. - pub fn default_values_arc(&self) -> &Arc<ComputedValues> { + pub fn default_computed_values(&self) -> &ComputedValuesInner { &self.default_values } @@ -114,7 +101,7 @@ impl Device { pub fn reset_computed_values(&mut self) { // NB: A following stylesheet flush will populate this if appropriate. self.viewport_override = None; - self.default_values = ComputedValues::default_values(self.pres_context()); + self.default_values = ComputedValuesInner::default_values(self.pres_context()); self.used_root_font_size.store(false, Ordering::Relaxed); } diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index 7afbdbdd518..0e2bb0eb040 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -110,13 +110,13 @@ impl<'a> Iterator for PropertyDeclarationIterator<'a> { pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> { iter: Iter<'a, (PropertyDeclaration, Importance)>, context: &'cx mut Context<'cx_a>, - default_values: &'a Arc<ComputedValues>, + default_values: &'a ComputedValuesInner, } impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> { fn new(declarations: &'a PropertyDeclarationBlock, context: &'cx mut Context<'cx_a>, - default_values: &'a Arc<ComputedValues>) -> AnimationValueIterator<'a, 'cx, 'cx_a> { + default_values: &'a ComputedValuesInner) -> AnimationValueIterator<'a, 'cx, 'cx_a> { AnimationValueIterator { iter: declarations.declarations().iter(), context: context, @@ -204,7 +204,7 @@ impl PropertyDeclarationBlock { /// Return an iterator of (AnimatableLonghand, AnimationValue). pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self, context: &'cx mut Context<'cx_a>, - default_values: &'a Arc<ComputedValues>) + default_values: &'a ComputedValuesInner) -> AnimationValueIterator<'a, 'cx, 'cx_a> { AnimationValueIterator::new(self, context, default_values) } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index a432e8d2369..74b93402090 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -97,7 +97,7 @@ impl Clone for ComputedValuesInner { } } -impl ComputedValues { +impl ComputedValuesInner { pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>, writing_mode: WritingMode, font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>, @@ -108,24 +108,21 @@ impl ComputedValues { ${style_struct.ident}: Arc<style_structs::${style_struct.name}>, % endfor ) -> Self { - ComputedValues { - inner: ComputedValuesInner { - custom_properties: custom_properties, - writing_mode: writing_mode, - font_computation_data: FontComputationData::new(font_size_keyword), - rules: rules, - visited_style: visited_style, - flags: flags, - % for style_struct in data.style_structs: - ${style_struct.gecko_name}: Arc::into_raw_offset(${style_struct.ident}), - % endfor - } + ComputedValuesInner { + custom_properties: custom_properties, + writing_mode: writing_mode, + font_computation_data: FontComputationData::new(font_size_keyword), + rules: rules, + visited_style: visited_style, + flags: flags, + % for style_struct in data.style_structs: + ${style_struct.gecko_name}: Arc::into_raw_offset(${style_struct.ident}), + % endfor } } - pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> { - Arc::new(ComputedValues { - inner: ComputedValuesInner { + pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Self { + ComputedValuesInner { custom_properties: None, writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious font_computation_data: FontComputationData::default_values(), @@ -135,8 +132,10 @@ impl ComputedValues { % for style_struct in data.style_structs: ${style_struct.gecko_name}: Arc::into_raw_offset(style_structs::${style_struct.name}::default(pres_context)), % endfor - } - }) + } + } + pub fn to_outer(self) -> Arc<ComputedValues> { + Arc::new(ComputedValues {inner: self}) } } @@ -198,12 +197,12 @@ impl ComputedValuesInner { } /// Gets a reference to the visited style, if any. - pub fn get_visited_style(&self) -> Option<<&Arc<ComputedValues>> { - self.visited_style.as_ref() + pub fn get_visited_style(&self) -> Option< & ComputedValuesInner> { + self.visited_style.as_ref().map(|x| &***x) } /// Gets a reference to the visited style. Panic if no visited style exists. - pub fn visited_style(&self) -> &Arc<ComputedValues> { + pub fn visited_style(&self) -> &ComputedValuesInner { self.get_visited_style().unwrap() } diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index e59be799737..580e2fd6329 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -292,7 +292,7 @@ #[allow(unused_imports)] use properties::{DeclaredValue, LonghandId, LonghandIdSet}; #[allow(unused_imports)] - use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration}; + use properties::{CSSWideKeyword, ComputedValuesInner, PropertyDeclaration}; #[allow(unused_imports)] use properties::style_structs; #[allow(unused_imports)] @@ -310,8 +310,8 @@ ${caller.body()} #[allow(unused_variables)] pub fn cascade_property(declaration: &PropertyDeclaration, - inherited_style: &ComputedValues, - default_style: &ComputedValues, + inherited_style: &ComputedValuesInner, + default_style: &ComputedValuesInner, context: &mut computed::Context, cacheable: &mut bool, cascade_info: &mut Option<<&mut CascadeInfo>) { diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index d81028284e3..f4c16093f91 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -29,7 +29,7 @@ use smallvec::SmallVec; use std::cmp; #[cfg(feature = "gecko")] use fnv::FnvHashMap; use style_traits::ParseError; -use super::ComputedValues; +use super::ComputedValuesInner; #[cfg(any(feature = "gecko", feature = "testing"))] use values::Auto; use values::{CSSFloat, CustomIdent, Either}; @@ -394,7 +394,7 @@ impl AnimatedProperty { /// Update `style` with the proper computed style corresponding to this /// animation at `progress`. - pub fn update(&self, style: &mut ComputedValues, progress: f64) { + pub fn update(&self, style: &mut ComputedValuesInner, progress: f64) { match *self { % for prop in data.longhands: % if prop.animatable: @@ -427,8 +427,8 @@ impl AnimatedProperty { /// Get an animatable value from a transition-property, an old style, and a /// new style. pub fn from_animatable_longhand(property: &AnimatableLonghand, - old_style: &ComputedValues, - new_style: &ComputedValues) + old_style: &ComputedValuesInner, + new_style: &ComputedValuesInner) -> AnimatedProperty { match *property { % for prop in data.longhands: @@ -521,7 +521,7 @@ impl AnimationValue { /// Construct an AnimationValue from a property declaration pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context, - initial: &ComputedValues) -> Option<Self> { + initial: &ComputedValuesInner) -> Option<Self> { use properties::LonghandId; match *decl { @@ -593,7 +593,7 @@ impl AnimationValue { /// Get an AnimationValue for an AnimatableLonghand from a given computed values. pub fn from_computed_values(property: &AnimatableLonghand, - computed_values: &ComputedValues) + computed_values: &ComputedValuesInner) -> Self { match *property { % for prop in data.longhands: diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index f2c3c8d517e..10e1358e48d 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -181,7 +181,7 @@ % if product == "servo": fn cascade_property_custom(_declaration: &PropertyDeclaration, - _inherited_style: &ComputedValues, + _inherited_style: &ComputedValuesInner, context: &mut computed::Context, _cacheable: &mut bool) { longhands::_servo_display_for_hypothetical_box::derive_from_display(context); diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index 3be23f1681e..c2ec468f7c1 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -249,7 +249,7 @@ ${helpers.single_keyword("unicode-bidi", % if product == "servo": fn cascade_property_custom(_declaration: &PropertyDeclaration, - _inherited_style: &ComputedValues, + _inherited_style: &ComputedValuesInner, context: &mut computed::Context, _cacheable: &mut bool) { longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context); diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index cc3a38731a0..383bc5651ec 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1872,6 +1872,8 @@ pub mod style_structs { #[cfg(feature = "gecko")] pub use gecko_properties::ComputedValues; +#[cfg(feature = "gecko")] +pub use gecko_properties::ComputedValuesInner; #[cfg(feature = "servo")] @@ -1920,7 +1922,7 @@ pub struct ComputedValues { } #[cfg(feature = "servo")] -impl ComputedValues { +impl ComputedValuesInner { /// Construct a `ComputedValues` instance. pub fn new( custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>, @@ -1933,18 +1935,16 @@ impl ComputedValues { ${style_struct.ident}: Arc<style_structs::${style_struct.name}>, % endfor ) -> Self { - ComputedValues { - inner: ComputedValuesInner { - custom_properties: custom_properties, - writing_mode: writing_mode, - font_computation_data: FontComputationData::new(font_size_keyword), - rules: rules, - visited_style: visited_style, - flags: flags, - % for style_struct in data.active_style_structs(): - ${style_struct.ident}: ${style_struct.ident}, - % endfor - } + ComputedValuesInner { + custom_properties: custom_properties, + writing_mode: writing_mode, + font_computation_data: FontComputationData::new(font_size_keyword), + rules: rules, + visited_style: visited_style, + flags: flags, + % for style_struct in data.active_style_structs(): + ${style_struct.ident}: ${style_struct.ident}, + % endfor } } @@ -1969,6 +1969,11 @@ impl ops::DerefMut for ComputedValues { #[cfg(feature = "servo")] impl ComputedValuesInner { + /// Convert to an Arc<ComputedValues> + pub fn to_outer(self) -> Arc<ComputedValues> { + Arc::new(ComputedValues {inner: self}) + } + % for style_struct in data.active_style_structs(): /// Clone the ${style_struct.name} struct. #[inline] @@ -2006,13 +2011,13 @@ impl ComputedValuesInner { } /// Gets a reference to the visited style, if any. - pub fn get_visited_style(&self) -> Option<<&Arc<ComputedValues>> { - self.visited_style.as_ref() + pub fn get_visited_style(&self) -> Option< & ComputedValuesInner> { + self.visited_style.as_ref().map(|x| &***x) } /// Gets a reference to the visited style. Panic if no visited style exists. - pub fn visited_style(&self) -> &Arc<ComputedValues> { - self.get_visited_style().unwrap() + pub fn visited_style(&self) -> &ComputedValuesInner { + self.get_visited_style().as_ref().map(|x| &**x).unwrap() } /// Clone the visited style. Used for inheriting parent styles in @@ -2441,8 +2446,8 @@ pub struct StyleBuilder<'a> { impl<'a> StyleBuilder<'a> { /// Trivially construct a `StyleBuilder`. fn new( - inherited_style: &'a ComputedValues, - reset_style: &'a ComputedValues, + inherited_style: &'a ComputedValuesInner, + reset_style: &'a ComputedValuesInner, rules: Option<StrongRuleNode>, custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>, writing_mode: WritingMode, @@ -2469,15 +2474,15 @@ impl<'a> StyleBuilder<'a> { /// Creates a StyleBuilder holding only references to the structs of `s`, in /// order to create a derived style. - pub fn for_derived_style(s: &'a ComputedValues) -> Self { + pub fn for_derived_style(s: &'a ComputedValuesInner) -> Self { Self::for_inheritance(s, s) } /// Inherits style from the parent element, accounting for the default /// computed values that need to be provided as well. pub fn for_inheritance( - parent: &'a ComputedValues, - default: &'a ComputedValues + parent: &'a ComputedValuesInner, + default: &'a ComputedValuesInner ) -> Self { Self::new( parent, @@ -2521,7 +2526,7 @@ impl<'a> StyleBuilder<'a> { } /// Reset the current `${style_struct.name}` style to its default value. - pub fn reset_${style_struct.name_lower}(&mut self, default: &'a ComputedValues) { + pub fn reset_${style_struct.name_lower}(&mut self, default: &'a ComputedValuesInner) { self.${style_struct.ident} = StyleStructRef::Borrowed(default.${style_struct.name_lower}_arc()); } @@ -2555,8 +2560,8 @@ impl<'a> StyleBuilder<'a> { /// Turns this `StyleBuilder` into a proper `ComputedValues` instance. - pub fn build(self) -> ComputedValues { - ComputedValues::new(self.custom_properties, + pub fn build(self) -> ComputedValuesInner { + ComputedValuesInner::new(self.custom_properties, self.writing_mode, self.font_size_keyword, self.flags, @@ -2586,30 +2591,28 @@ pub use self::lazy_static_module::INITIAL_SERVO_VALUES; mod lazy_static_module { use logical_geometry::WritingMode; use stylearc::Arc; - use super::{ComputedValues, ComputedValuesInner, longhands, style_structs, FontComputationData}; + use super::{ComputedValuesInner, longhands, style_structs, FontComputationData}; use super::computed_value_flags::ComputedValueFlags; /// The initial values for all style structs as defined by the specification. lazy_static! { - pub static ref INITIAL_SERVO_VALUES: ComputedValues = ComputedValues { - inner: ComputedValuesInner { - % for style_struct in data.active_style_structs(): - ${style_struct.ident}: Arc::new(style_structs::${style_struct.name} { - % for longhand in style_struct.longhands: - ${longhand.ident}: longhands::${longhand.ident}::get_initial_value(), - % endfor - % if style_struct.name == "Font": - hash: 0, - % endif - }), - % endfor - custom_properties: None, - writing_mode: WritingMode::empty(), - font_computation_data: FontComputationData::default_values(), - rules: None, - visited_style: None, - flags: ComputedValueFlags::empty(), - } + pub static ref INITIAL_SERVO_VALUES: ComputedValuesInner = ComputedValuesInner { + % for style_struct in data.active_style_structs(): + ${style_struct.ident}: Arc::new(style_structs::${style_struct.name} { + % for longhand in style_struct.longhands: + ${longhand.ident}: longhands::${longhand.ident}::get_initial_value(), + % endfor + % if style_struct.name == "Font": + hash: 0, + % endif + }), + % endfor + custom_properties: None, + writing_mode: WritingMode::empty(), + font_computation_data: FontComputationData::default_values(), + rules: None, + visited_style: None, + flags: ComputedValueFlags::empty(), }; } } @@ -2617,8 +2620,8 @@ mod lazy_static_module { /// A per-longhand function that performs the CSS cascade for that longhand. pub type CascadePropertyFn = extern "Rust" fn(declaration: &PropertyDeclaration, - inherited_style: &ComputedValues, - default_style: &ComputedValues, + inherited_style: &ComputedValuesInner, + default_style: &ComputedValuesInner, context: &mut computed::Context, cacheable: &mut bool, cascade_info: &mut Option<<&mut CascadeInfo>); @@ -2679,14 +2682,14 @@ bitflags! { pub fn cascade(device: &Device, rule_node: &StrongRuleNode, guards: &StylesheetGuards, - parent_style: Option<<&ComputedValues>, - layout_parent_style: Option<<&ComputedValues>, + parent_style: Option<<&ComputedValuesInner>, + layout_parent_style: Option<<&ComputedValuesInner>, visited_style: Option<Arc<ComputedValues>>, cascade_info: Option<<&mut CascadeInfo>, font_metrics_provider: &FontMetricsProvider, flags: CascadeFlags, quirks_mode: QuirksMode) - -> ComputedValues { + -> ComputedValuesInner { debug_assert!(layout_parent_style.is_none() || parent_style.is_some()); let (inherited_style, layout_parent_style) = match parent_style { Some(parent_style) => { @@ -2741,14 +2744,14 @@ pub fn cascade(device: &Device, pub fn apply_declarations<'a, F, I>(device: &Device, rules: &StrongRuleNode, iter_declarations: F, - inherited_style: &ComputedValues, - layout_parent_style: &ComputedValues, + inherited_style: &ComputedValuesInner, + layout_parent_style: &ComputedValuesInner, visited_style: Option<Arc<ComputedValues>>, mut cascade_info: Option<<&mut CascadeInfo>, font_metrics_provider: &FontMetricsProvider, flags: CascadeFlags, quirks_mode: QuirksMode) - -> ComputedValues + -> ComputedValuesInner where F: Fn() -> I, I: Iterator<Item = (&'a PropertyDeclaration, CascadeLevel)>, { diff --git a/components/style/servo/media_queries.rs b/components/style/servo/media_queries.rs index 023f5f8de77..ba758af514d 100644 --- a/components/style/servo/media_queries.rs +++ b/components/style/servo/media_queries.rs @@ -11,7 +11,7 @@ use euclid::{Size2D, TypedSize2D}; use font_metrics::ServoMetricsProvider; use media_queries::MediaType; use parser::ParserContext; -use properties::{ComputedValues, StyleBuilder}; +use properties::{ComputedValuesInner, StyleBuilder}; use properties::longhands::font_size; use selectors::parser::SelectorParseError; use std::fmt; @@ -62,11 +62,11 @@ impl Device { } /// Return the default computed values for this device. - pub fn default_computed_values(&self) -> &ComputedValues { + pub fn default_computed_values(&self) -> &ComputedValuesInner { // FIXME(bz): This isn't really right, but it's no more wrong // than what we used to do. See // https://github.com/servo/servo/issues/14773 for fixing it properly. - ComputedValues::initial_values() + ComputedValuesInner::initial_values() } /// Get the font size of the root element (for rem) diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs index 5b60231b2c4..9b4d8a69551 100644 --- a/components/style/style_adjuster.rs +++ b/components/style/style_adjuster.rs @@ -6,7 +6,7 @@ //! a computed style needs in order for it to adhere to the CSS spec. use app_units::Au; -use properties::{self, CascadeFlags, ComputedValues}; +use properties::{self, CascadeFlags, ComputedValuesInner}; use properties::{IS_ROOT_ELEMENT, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, StyleBuilder}; use properties::longhands::display::computed_value::T as display; use properties::longhands::float::computed_value::T as float; @@ -54,7 +54,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { /// Apply the blockification rules based on the table in CSS 2.2 section 9.7. /// https://drafts.csswg.org/css2/visuren.html#dis-pos-flo fn blockify_if_necessary(&mut self, - layout_parent_style: &ComputedValues, + layout_parent_style: &ComputedValuesInner, flags: CascadeFlags) { let mut blockify = false; macro_rules! blockify_if { @@ -136,7 +136,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { /// https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html /// https://github.com/servo/servo/issues/15754 fn adjust_for_writing_mode(&mut self, - layout_parent_style: &ComputedValues) { + layout_parent_style: &ComputedValuesInner) { let our_writing_mode = self.style.get_inheritedbox().clone_writing_mode(); let parent_writing_mode = layout_parent_style.get_inheritedbox().clone_writing_mode(); @@ -196,7 +196,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { /// /// See https://github.com/servo/servo/issues/15229 #[cfg(feature = "servo")] - fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValues) { + fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValuesInner) { use computed_values::align_items::T as align_items; use computed_values::align_self::T as align_self; @@ -315,7 +315,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { } /// Set the HAS_TEXT_DECORATION_LINES flag based on parent style. - fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValues) { + fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValuesInner) { use properties::computed_value_flags::HAS_TEXT_DECORATION_LINES; if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) || !self.style.get_text().clone_text_decoration_line().is_empty() { @@ -324,7 +324,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { } #[cfg(feature = "gecko")] - fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValues) -> bool { + fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValuesInner) -> bool { use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK; // Line break suppression should only be propagated to in-flow children. if self.style.floated() || self.style.out_of_flow_positioned() { @@ -361,8 +361,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { /// * correct unicode-bidi. #[cfg(feature = "gecko")] fn adjust_for_ruby(&mut self, - layout_parent_style: &ComputedValues, - default_computed_values: &'b ComputedValues, + layout_parent_style: &ComputedValuesInner, + default_computed_values: &'b ComputedValuesInner, flags: CascadeFlags) { use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP; use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK; @@ -406,8 +406,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { /// When comparing to Gecko, this is similar to the work done by /// `nsStyleContext::ApplyStyleFixups`. pub fn adjust(&mut self, - layout_parent_style: &ComputedValues, - _default_computed_values: &'b ComputedValues, + layout_parent_style: &ComputedValuesInner, + _default_computed_values: &'b ComputedValuesInner, flags: CascadeFlags) { #[cfg(feature = "gecko")] { diff --git a/components/style/style_resolver.rs b/components/style/style_resolver.rs index 0a98e563e76..65d35aa6700 100644 --- a/components/style/style_resolver.rs +++ b/components/style/style_resolver.rs @@ -11,7 +11,7 @@ use data::{ElementStyles, EagerPseudoStyles}; use dom::TElement; use log::LogLevel::Trace; use matching::{CascadeVisitedMode, MatchMethods}; -use properties::{AnimationRules, CascadeFlags, ComputedValues}; +use properties::{AnimationRules, CascadeFlags, ComputedValues, ComputedValuesInner}; use properties::{IS_ROOT_ELEMENT, PROHIBIT_DISPLAY_CONTENTS, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP}; use properties::{VISITED_DEPENDENT_ONLY, cascade}; use rule_tree::StrongRuleNode; @@ -47,7 +47,7 @@ pub struct PrimaryStyle { fn with_default_parent_styles<E, F, R>(element: E, f: F) -> R where E: TElement, - F: FnOnce(Option<&ComputedValues>, Option<&ComputedValues>) -> R, + F: FnOnce(Option<&ComputedValuesInner>, Option<&ComputedValuesInner>) -> R, { let parent_el = element.inheritance_parent(); let parent_data = parent_el.as_ref().and_then(|e| e.borrow_data()); @@ -72,7 +72,7 @@ where layout_parent_style = Some(layout_parent_data.styles.primary()); } - f(parent_style.map(|s| &**s), layout_parent_style.map(|s| &**s)) + f(parent_style.map(|s| &***s), layout_parent_style.map(|s| &***s)) } impl<'a, 'ctx, 'le, E> StyleResolverForElement<'a, 'ctx, 'le, E> @@ -98,8 +98,8 @@ where /// Resolve just the style of a given element. pub fn resolve_primary_style( &mut self, - parent_style: Option<&ComputedValues>, - layout_parent_style: Option<&ComputedValues>, + parent_style: Option<&ComputedValuesInner>, + layout_parent_style: Option<&ComputedValuesInner>, ) -> PrimaryStyle { let primary_results = self.match_primary(VisitedHandlingMode::AllLinksUnvisited); @@ -146,8 +146,8 @@ where /// Resolve the style of a given element, and all its eager pseudo-elements. pub fn resolve_style( &mut self, - parent_style: Option<&ComputedValues>, - layout_parent_style: Option<&ComputedValues>, + parent_style: Option<&ComputedValuesInner>, + layout_parent_style: Option<&ComputedValuesInner>, ) -> ElementStyles { use properties::longhands::display::computed_value::T as display; @@ -168,7 +168,7 @@ where if primary_style.style.is_display_contents() { layout_parent_style } else { - Some(&*primary_style.style) + Some(&**primary_style.style) }; SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| { let pseudo_style = self.resolve_pseudo_style( @@ -215,8 +215,8 @@ where fn cascade_style_and_visited( &mut self, inputs: CascadeInputs, - parent_style: Option<&ComputedValues>, - layout_parent_style: Option<&ComputedValues>, + parent_style: Option<&ComputedValuesInner>, + layout_parent_style: Option<&ComputedValuesInner>, pseudo: Option<&PseudoElement>, ) -> Arc<ComputedValues> { let mut style_if_visited = None; @@ -272,7 +272,7 @@ where if primary_style.style.is_display_contents() { layout_parent_style } else { - Some(&*primary_style.style) + Some(&**primary_style.style) }; for (i, mut inputs) in pseudo_array.unwrap().iter_mut().enumerate() { @@ -302,7 +302,7 @@ where &mut self, pseudo: &PseudoElement, originating_element_style: &PrimaryStyle, - layout_parent_style: Option<&ComputedValues>, + layout_parent_style: Option<&ComputedValuesInner>, ) -> Option<Arc<ComputedValues>> { let rules = self.match_pseudo( &originating_element_style.style, @@ -398,7 +398,7 @@ where fn match_pseudo( &mut self, - originating_element_style: &ComputedValues, + originating_element_style: &ComputedValuesInner, pseudo_element: &PseudoElement, visited_handling: VisitedHandlingMode, ) -> Option<StrongRuleNode> { @@ -462,8 +462,8 @@ where &mut self, rules: Option<&StrongRuleNode>, style_if_visited: Option<Arc<ComputedValues>>, - mut parent_style: Option<&ComputedValues>, - layout_parent_style: Option<&ComputedValues>, + mut parent_style: Option<&ComputedValuesInner>, + layout_parent_style: Option<&ComputedValuesInner>, cascade_visited: CascadeVisitedMode, pseudo: Option<&PseudoElement>, ) -> Arc<ComputedValues> { @@ -475,7 +475,7 @@ where } if cascade_visited.visited_dependent_only() { parent_style = parent_style.map(|s| { - s.get_visited_style().map(|s| &**s).unwrap_or(s) + s.get_visited_style().unwrap_or(s) }); cascade_flags.insert(VISITED_DEPENDENT_ONLY); } @@ -486,7 +486,7 @@ where } let values = - Arc::new(cascade( + cascade( self.context.shared.stylist.device(), rules.unwrap_or(self.context.shared.stylist.rule_tree().root()), &self.context.shared.guards, @@ -497,9 +497,9 @@ where &self.context.thread_local.font_metrics_provider, cascade_flags, self.context.shared.quirks_mode - )); + ); cascade_info.finish(&self.element.as_node()); - values + values.to_outer() } } diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 0b50b6d82f1..395a1cccf42 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -16,7 +16,7 @@ use gecko_bindings::structs::{nsIAtom, StyleRuleInclusion}; use invalidation::element::invalidation_map::InvalidationMap; use invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey}; use media_queries::Device; -use properties::{self, CascadeFlags, ComputedValues}; +use properties::{self, CascadeFlags, ComputedValues, ComputedValuesInner}; use properties::{AnimationRules, PropertyDeclarationBlock}; #[cfg(feature = "servo")] use properties::INHERIT_ALL; @@ -599,7 +599,7 @@ impl Stylist { pub fn precomputed_values_for_pseudo(&self, guards: &StylesheetGuards, pseudo: &PseudoElement, - parent: Option<&Arc<ComputedValues>>, + parent: Option<&ComputedValuesInner>, cascade_flags: CascadeFlags, font_metrics: &FontMetricsProvider) -> Arc<ComputedValues> { @@ -629,18 +629,16 @@ impl Stylist { // descendant of a display: contents element where display: contents is // the actual used value, and the computed value of it would need // blockification. - let computed = - properties::cascade(&self.device, - &rule_node, - guards, - parent.map(|p| &**p), - parent.map(|p| &**p), - None, - None, - font_metrics, - cascade_flags, - self.quirks_mode); - Arc::new(computed) + properties::cascade(&self.device, + &rule_node, + guards, + parent, + parent, + None, + None, + font_metrics, + cascade_flags, + self.quirks_mode).to_outer() } /// Returns the style for an anonymous box of the given type. @@ -648,7 +646,7 @@ impl Stylist { pub fn style_for_anonymous(&self, guards: &StylesheetGuards, pseudo: &PseudoElement, - parent_style: &Arc<ComputedValues>) + parent_style: &ComputedValuesInner) -> Arc<ComputedValues> { use font_metrics::ServoMetricsProvider; @@ -692,7 +690,7 @@ impl Stylist { element: &E, pseudo: &PseudoElement, rule_inclusion: RuleInclusion, - parent_style: &Arc<ComputedValues>, + parent_style: &ComputedValuesInner, is_probe: bool, font_metrics: &FontMetricsProvider) -> Option<Arc<ComputedValues>> @@ -713,7 +711,7 @@ impl Stylist { pub fn compute_pseudo_element_style_with_inputs(&self, inputs: &CascadeInputs, guards: &StylesheetGuards, - parent_style: &Arc<ComputedValues>, + parent_style: &ComputedValuesInner, font_metrics: &FontMetricsProvider) -> Option<Arc<ComputedValues>> { @@ -736,7 +734,7 @@ impl Stylist { // We want to use the visited bits (if any) from our parent style as // our parent. let inherited_style = - parent_style.get_visited_style().unwrap_or(&*parent_style); + parent_style.get_visited_style().unwrap_or(parent_style); // FIXME(emilio): The lack of layout_parent_style here could be // worrying, but we're probably dropping the display fixup for @@ -753,9 +751,9 @@ impl Stylist { None, font_metrics, CascadeFlags::empty(), - self.quirks_mode); + self.quirks_mode).to_outer(); - Some(Arc::new(computed)) + Some(computed) } else { None }; @@ -768,19 +766,16 @@ impl Stylist { // difficult to assert that display: contents nodes never arrive here // (tl;dr: It doesn't apply for replaced elements and such, but the // computed value is still "contents"). - let computed = - properties::cascade(&self.device, - rules, - guards, - Some(parent_style), - Some(parent_style), - visited_values, - None, - font_metrics, - CascadeFlags::empty(), - self.quirks_mode); - - Some(Arc::new(computed)) + Some(properties::cascade(&self.device, + rules, + guards, + Some(parent_style), + Some(parent_style), + visited_values, + None, + font_metrics, + CascadeFlags::empty(), + self.quirks_mode).to_outer()) } /// Computes the cascade inputs for a lazily-cascaded pseudo-element. @@ -1317,7 +1312,7 @@ impl Stylist { /// Computes styles for a given declaration with parent_style. pub fn compute_for_declarations(&self, guards: &StylesheetGuards, - parent_style: &Arc<ComputedValues>, + parent_style: &ComputedValuesInner, declarations: Arc<Locked<PropertyDeclarationBlock>>) -> Arc<ComputedValues> { use font_metrics::get_metrics_provider_for_product; @@ -1333,16 +1328,16 @@ impl Stylist { // font styles in <canvas> via Servo_StyleSet_ResolveForDeclarations. // It is unclear if visited styles are meaningful for this case. let metrics = get_metrics_provider_for_product(); - Arc::new(properties::cascade(&self.device, - &rule_node, - guards, - Some(parent_style), - Some(parent_style), - None, - None, - &metrics, - CascadeFlags::empty(), - self.quirks_mode)) + properties::cascade(&self.device, + &rule_node, + guards, + Some(parent_style), + Some(parent_style), + None, + None, + &metrics, + CascadeFlags::empty(), + self.quirks_mode).to_outer() } /// Accessor for a shared reference to the device. diff --git a/components/style/traversal.rs b/components/style/traversal.rs index 485024627a0..2f7223ad717 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -484,8 +484,8 @@ where let primary_style = StyleResolverForElement::new(*ancestor, context, rule_inclusion) .resolve_primary_style( - style.as_ref().map(|s| &**s), - layout_parent_style.as_ref().map(|s| &**s) + style.as_ref().map(|s| &***s), + layout_parent_style.as_ref().map(|s| &***s) ); let is_display_contents = primary_style.style.is_display_contents(); @@ -501,8 +501,8 @@ where context.thread_local.bloom_filter.assert_complete(element); StyleResolverForElement::new(element, context, rule_inclusion) .resolve_style( - style.as_ref().map(|s| &**s), - layout_parent_style.as_ref().map(|s| &**s) + style.as_ref().map(|s| &***s), + layout_parent_style.as_ref().map(|s| &***s) ) } diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index deb74f75022..8d06fe57a7b 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -11,7 +11,7 @@ use font_metrics::FontMetricsProvider; use media_queries::Device; #[cfg(feature = "gecko")] use properties; -use properties::{ComputedValues, StyleBuilder}; +use properties::{ComputedValuesInner, StyleBuilder}; use std::f32; use std::f64; use std::f64::consts::PI; @@ -72,13 +72,13 @@ pub struct Context<'a> { pub device: &'a Device, /// The style we're inheriting from. - pub inherited_style: &'a ComputedValues, + pub inherited_style: &'a ComputedValuesInner, /// The style of the layout parent node. This will almost always be /// `inherited_style`, except when `display: contents` is at play, in which /// case it's the style of the last ancestor with a `display` value that /// isn't `contents`. - pub layout_parent_style: &'a ComputedValues, + pub layout_parent_style: &'a ComputedValuesInner, /// Values accessed through this need to be in the properties "computed /// early": color, text-decoration, font-size, display, position, float, @@ -115,7 +115,7 @@ impl<'a> Context<'a> { /// The current viewport size. pub fn viewport_size(&self) -> Size2D<Au> { self.device.au_viewport_size() } /// The style we're inheriting from. - pub fn inherited_style(&self) -> &ComputedValues { &self.inherited_style } + pub fn inherited_style(&self) -> &ComputedValuesInner { &self.inherited_style } /// The current style. Note that only "eager" properties should be accessed /// from here, see the comment in the member. pub fn style(&self) -> &StyleBuilder { &self.style } diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 18015cc07e1..d98ceb34531 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1514,7 +1514,8 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: .expect("Not an anon box pseudo?"); - let maybe_parent = ComputedValues::arc_from_borrowed(&parent_style_or_null); + let maybe_parent = ComputedValues::arc_from_borrowed(&parent_style_or_null) + .map(|p| &p.inner); let cascade_flags = SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP; let metrics = get_metrics_provider_for_product(); data.stylist.precomputed_values_for_pseudo(&guards, &pseudo, maybe_parent, @@ -1543,7 +1544,7 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed, return if is_probe { Strong::null() } else { - doc_data.default_computed_values().clone().into_strong() + doc_data.default_computed_values().clone().to_outer().into_strong() }; } @@ -1676,10 +1677,10 @@ fn get_pseudo_style( } Some(style.unwrap_or_else(|| { - Arc::new(StyleBuilder::for_inheritance( + StyleBuilder::for_inheritance( styles.primary(), doc_data.default_computed_values(), - ).build()) + ).build().to_outer() })) } @@ -1702,20 +1703,20 @@ pub extern "C" fn Servo_ComputedValues_Inherit( .adjust_for_text(); } - Arc::new(style.build()) + style.build() } else { debug_assert!(!for_text); data.default_computed_values().clone() }; - style.into_strong() + style.to_outer().into_strong() } #[no_mangle] pub extern "C" fn Servo_ComputedValues_GetVisitedStyle(values: ServoComputedValuesBorrowed) -> ServoComputedValuesStrong { - match ComputedValues::as_arc(&values).get_visited_style() { - Some(v) => v.clone().into_strong(), + match ComputedValues::as_arc(&values).clone_visited_style() { + Some(v) => v.into_strong(), None => Strong::null(), } } @@ -2870,12 +2871,13 @@ fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl, parent_style: &'a Option<&Arc<ComputedValues>>) -> Context<'a> { let default_values = per_doc_data.default_computed_values(); + let inherited_style = parent_style.map(|x| &x.inner).unwrap_or(default_values); Context { is_root_element: false, device: per_doc_data.stylist.device(), - inherited_style: parent_style.unwrap_or(default_values), - layout_parent_style: parent_style.unwrap_or(default_values), + inherited_style: inherited_style, + layout_parent_style: inherited_style, style: StyleBuilder::for_derived_style(&style), font_metrics_provider: font_metrics_provider, cached_system_font: None, @@ -3264,7 +3266,7 @@ pub extern "C" fn Servo_StyleSet_ResolveForDeclarations( let guards = StylesheetGuards::same(&guard); let parent_style = match ComputedValues::arc_from_borrowed(&parent_style_or_null) { - Some(parent) => &parent, + Some(parent) => &parent.inner, None => doc_data.default_computed_values(), }; |