stylo: Use ComputedValuesInner instead of ComputedValues when we don't need it

This commit is contained in:
Manish Goregaokar 2017-07-17 11:41:52 -07:00 committed by Manish Goregaokar
parent 04b0ae64f2
commit 808b1f509b
38 changed files with 302 additions and 316 deletions

View file

@ -56,7 +56,7 @@ use style::computed_values::{border_collapse, box_sizing, display, float, overfl
use style::computed_values::{position, text_align}; use style::computed_values::{position, text_align};
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode}; 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::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION};
use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage}; use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage};
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
@ -2139,7 +2139,7 @@ impl Flow for BlockFlow {
self.build_display_list_for_block(state, BorderPaintingMode::Separate); 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) self.fragment.repair_style(new_style)
} }

View file

@ -52,7 +52,7 @@ use style::computed_values::content::ContentItem;
use style::computed_values::position; use style::computed_values::position;
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::logical_geometry::Direction; use style::logical_geometry::Direction;
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use style::properties::longhands::list_style_image; use style::properties::longhands::list_style_image;
use style::selector_parser::{PseudoElement, RestyleDamage}; use style::selector_parser::{PseudoElement, RestyleDamage};
use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW}; 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. /// Inline fragments and associated {ib} splits that have not yet found flows.
InlineFragments(InlineFragmentsConstructionResult), InlineFragments(InlineFragmentsConstructionResult),
/// Potentially ignorable whitespace. /// Potentially ignorable whitespace.
Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ServoComputedValues>, RestyleDamage), Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ComputedValues>, RestyleDamage),
/// TableColumn Fragment /// TableColumn Fragment
TableColumnFragment(Fragment), TableColumnFragment(Fragment),
} }
@ -677,7 +677,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
fn create_fragments_for_node_text_content(&self, fn create_fragments_for_node_text_content(&self,
fragments: &mut IntermediateInlineFragments, fragments: &mut IntermediateInlineFragments,
node: &ConcreteThreadSafeLayoutNode, node: &ConcreteThreadSafeLayoutNode,
style: &StyleArc<ServoComputedValues>) { style: &StyleArc<ComputedValues>) {
// Fast path: If there is no text content, return immediately. // Fast path: If there is no text content, return immediately.
let text_content = node.text_content(); let text_content = node.text_content();
if text_content.is_empty() { 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 /// 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. /// 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::direction::T::*;
use style::computed_values::unicode_bidi::T::*; use style::computed_values::unicode_bidi::T::*;
@ -1851,7 +1851,7 @@ trait ComputedValueUtils {
fn has_padding_or_border(&self) -> bool; fn has_padding_or_border(&self) -> bool;
} }
impl ComputedValueUtils for ServoComputedValues { impl ComputedValueUtils for ComputedValues {
fn has_padding_or_border(&self) -> bool { fn has_padding_or_border(&self) -> bool {
let padding = self.get_padding(); let padding = self.get_padding();
let border = self.get_border(); let border = self.get_border();

View file

@ -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::{background_repeat, border_style, cursor};
use style::computed_values::{image_rendering, overflow_x, pointer_events, position, visibility}; use style::computed_values::{image_rendering, overflow_x, pointer_events, position, visibility};
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode}; 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::longhands::border_image_repeat::computed_value::RepeatKeyword;
use style::properties::style_structs; use style::properties::style_structs;
use style::servo::restyle_damage::REPAINT; use style::servo::restyle_damage::REPAINT;
@ -375,14 +375,14 @@ pub trait FragmentDisplayListBuilding {
/// list if necessary. /// list if necessary.
fn build_display_list_for_background_if_applicable(&self, fn build_display_list_for_background_if_applicable(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>); absolute_bounds: &Rect<Au>);
/// Computes the background size for an image with the given background area according to the /// Computes the background size for an image with the given background area according to the
/// rules in CSS-BACKGROUNDS § 3.9. /// rules in CSS-BACKGROUNDS § 3.9.
fn compute_background_image_size(&self, fn compute_background_image_size(&self,
style: &ServoComputedValues, style: &ComputedValues,
bounds: &Rect<Au>, bounds: &Rect<Au>,
image: &WebRenderImageInfo, index: usize) image: &WebRenderImageInfo, index: usize)
-> Size2D<Au>; -> Size2D<Au>;
@ -391,7 +391,7 @@ pub trait FragmentDisplayListBuilding {
/// appropriate section of the display list. /// appropriate section of the display list.
fn build_display_list_for_background_image(&self, fn build_display_list_for_background_image(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>, absolute_bounds: &Rect<Au>,
clip: &LocalClip, clip: &LocalClip,
@ -402,7 +402,7 @@ pub trait FragmentDisplayListBuilding {
/// appropriate section of the display list. /// appropriate section of the display list.
fn build_display_list_for_webrender_image(&self, fn build_display_list_for_webrender_image(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>, absolute_bounds: &Rect<Au>,
clip: &LocalClip, clip: &LocalClip,
@ -413,7 +413,7 @@ pub trait FragmentDisplayListBuilding {
/// worklet to the appropriate section of the display list. /// worklet to the appropriate section of the display list.
fn build_display_list_for_background_paint_worklet(&self, fn build_display_list_for_background_paint_worklet(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>, absolute_bounds: &Rect<Au>,
clip: &LocalClip, clip: &LocalClip,
@ -443,14 +443,14 @@ pub trait FragmentDisplayListBuilding {
absolute_bounds: &Rect<Au>, absolute_bounds: &Rect<Au>,
clip: &LocalClip, clip: &LocalClip,
gradient: &Gradient, gradient: &Gradient,
style: &ServoComputedValues); style: &ComputedValues);
/// Adds the display items necessary to paint the borders of this fragment to a display list if /// Adds the display items necessary to paint the borders of this fragment to a display list if
/// necessary. /// necessary.
fn build_display_list_for_borders_if_applicable( fn build_display_list_for_borders_if_applicable(
&self, &self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
border_painting_mode: BorderPaintingMode, border_painting_mode: BorderPaintingMode,
bounds: &Rect<Au>, bounds: &Rect<Au>,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
@ -460,7 +460,7 @@ pub trait FragmentDisplayListBuilding {
/// if necessary. /// if necessary.
fn build_display_list_for_outline_if_applicable(&self, fn build_display_list_for_outline_if_applicable(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
bounds: &Rect<Au>, bounds: &Rect<Au>,
clip: &Rect<Au>); clip: &Rect<Au>);
@ -468,7 +468,7 @@ pub trait FragmentDisplayListBuilding {
/// list if necessary. /// list if necessary.
fn build_display_list_for_box_shadow_if_applicable(&self, fn build_display_list_for_box_shadow_if_applicable(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>, absolute_bounds: &Rect<Au>,
clip: &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. /// Adds display items necessary to draw debug boxes around a scanned text fragment.
fn build_debug_borders_around_text_fragments(&self, fn build_debug_borders_around_text_fragments(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
stacking_relative_border_box: &Rect<Au>, stacking_relative_border_box: &Rect<Au>,
stacking_relative_content_box: &Rect<Au>, stacking_relative_content_box: &Rect<Au>,
text_fragment: &ScannedTextFragmentInfo, 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 /// 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. /// for building the clip for the content inside the border.
fn build_border_radius_for_inner_rect(outer_rect: &Rect<Au>, fn build_border_radius_for_inner_rect(outer_rect: &Rect<Au>,
style: &ServoComputedValues) style: &ComputedValues)
-> BorderRadii<Au> { -> BorderRadii<Au> {
let mut radii = build_border_radius(&outer_rect, style.get_border()); let mut radii = build_border_radius(&outer_rect, style.get_border());
if radii.is_square() { 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>, fn build_inner_border_box_for_border_rect(border_box: &Rect<Au>,
style: &ServoComputedValues) style: &ComputedValues)
-> Rect<Au> { -> Rect<Au> {
let border_widths = style.logical_border_width().to_physical(style.writing_mode); let border_widths = style.logical_border_width().to_physical(style.writing_mode);
let mut inner_border_box = *border_box; let mut inner_border_box = *border_box;
@ -845,7 +845,7 @@ fn convert_ellipse_size_keyword(keyword: ShapeExtent,
impl FragmentDisplayListBuilding for Fragment { impl FragmentDisplayListBuilding for Fragment {
fn build_display_list_for_background_if_applicable(&self, fn build_display_list_for_background_if_applicable(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>) { absolute_bounds: &Rect<Au>) {
// FIXME: This causes a lot of background colors to be displayed when they are clearly not // 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, fn compute_background_image_size(&self,
style: &ServoComputedValues, style: &ComputedValues,
bounds: &Rect<Au>, bounds: &Rect<Au>,
image: &WebRenderImageInfo, image: &WebRenderImageInfo,
index: usize) index: usize)
@ -996,7 +996,7 @@ impl FragmentDisplayListBuilding for Fragment {
fn build_display_list_for_background_image(&self, fn build_display_list_for_background_image(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>, absolute_bounds: &Rect<Au>,
clip: &LocalClip, clip: &LocalClip,
@ -1020,7 +1020,7 @@ impl FragmentDisplayListBuilding for Fragment {
fn build_display_list_for_webrender_image(&self, fn build_display_list_for_webrender_image(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>, absolute_bounds: &Rect<Au>,
clip: &LocalClip, clip: &LocalClip,
@ -1157,7 +1157,7 @@ impl FragmentDisplayListBuilding for Fragment {
fn build_display_list_for_background_paint_worklet(&self, fn build_display_list_for_background_paint_worklet(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>, absolute_bounds: &Rect<Au>,
clip: &LocalClip, clip: &LocalClip,
@ -1338,7 +1338,7 @@ impl FragmentDisplayListBuilding for Fragment {
absolute_bounds: &Rect<Au>, absolute_bounds: &Rect<Au>,
clip: &LocalClip, clip: &LocalClip,
gradient: &Gradient, gradient: &Gradient,
style: &ServoComputedValues) { style: &ComputedValues) {
let border = self.border_width().to_physical(style.writing_mode); let border = self.border_width().to_physical(style.writing_mode);
let mut bounds = *absolute_bounds; let mut bounds = *absolute_bounds;
bounds.origin.x = bounds.origin.x + border.left; 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, fn build_display_list_for_box_shadow_if_applicable(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>, absolute_bounds: &Rect<Au>,
clip: &Rect<Au>) { clip: &Rect<Au>) {
@ -1423,7 +1423,7 @@ impl FragmentDisplayListBuilding for Fragment {
fn build_display_list_for_borders_if_applicable( fn build_display_list_for_borders_if_applicable(
&self, &self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
border_painting_mode: BorderPaintingMode, border_painting_mode: BorderPaintingMode,
bounds: &Rect<Au>, bounds: &Rect<Au>,
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
@ -1570,7 +1570,7 @@ impl FragmentDisplayListBuilding for Fragment {
fn build_display_list_for_outline_if_applicable(&self, fn build_display_list_for_outline_if_applicable(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
bounds: &Rect<Au>, bounds: &Rect<Au>,
clip: &Rect<Au>) { clip: &Rect<Au>) {
use style::values::Either; use style::values::Either;
@ -1615,7 +1615,7 @@ impl FragmentDisplayListBuilding for Fragment {
fn build_debug_borders_around_text_fragments(&self, fn build_debug_borders_around_text_fragments(&self,
state: &mut DisplayListBuildState, state: &mut DisplayListBuildState,
style: &ServoComputedValues, style: &ComputedValues,
stacking_relative_border_box: &Rect<Au>, stacking_relative_border_box: &Rect<Au>,
stacking_relative_content_box: &Rect<Au>, stacking_relative_content_box: &Rect<Au>,
text_fragment: &ScannedTextFragmentInfo, text_fragment: &ScannedTextFragmentInfo,
@ -2886,12 +2886,12 @@ impl BaseFlowDisplayListBuilding for BaseFlow {
} }
} }
trait ServoComputedValuesCursorUtility { trait ComputedValuesCursorUtility {
fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor>; fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor>;
} }
impl ServoComputedValuesCursorUtility for ServoComputedValues { impl ComputedValuesCursorUtility for ComputedValues {
/// Gets the cursor to use given the specific ServoComputedValues. `default_cursor` specifies /// 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 /// the cursor to use if `cursor` is `auto`. Typically, this will be `PointerCursor`, but for
/// text display items it may be `TextCursor` or `VerticalTextCursor`. /// text display items it may be `TextCursor` or `VerticalTextCursor`.
#[inline] #[inline]

View file

@ -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::{align_content, align_self, flex_direction, flex_wrap, justify_content};
use style::computed_values::border_collapse; use style::computed_values::border_collapse;
use style::logical_geometry::{Direction, LogicalSize}; 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::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
use style::values::computed::flex::FlexBasis; use style::values::computed::flex::FlexBasis;
@ -973,7 +973,7 @@ impl Flow for FlexFlow {
self.block_flow.collect_stacking_contexts(state); 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) self.block_flow.repair_style(new_style)
} }

View file

@ -52,7 +52,7 @@ use std::sync::atomic::Ordering;
use style::computed_values::{clear, float, overflow_x, position, text_align}; use style::computed_values::{clear, float, overflow_x, position, text_align};
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use style::selector_parser::RestyleDamage; use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION}; use style::servo::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION};
use style::values::computed::LengthOrPercentageOrAuto; 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 /// 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. /// 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 /// Print any extra children (such as fragments) contained in this Flow
/// for debugging purposes. Any items inserted into the tree will become /// 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 /// 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. /// 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 { pub trait MutableOwnedFlowUtils {
@ -1033,7 +1033,7 @@ pub enum ForceNonfloatedFlag {
impl BaseFlow { impl BaseFlow {
#[inline] #[inline]
pub fn new(style: Option<&ServoComputedValues>, pub fn new(style: Option<&ComputedValues>,
writing_mode: WritingMode, writing_mode: WritingMode,
force_nonfloated: ForceNonfloatedFlag) force_nonfloated: ForceNonfloatedFlag)
-> BaseFlow { -> 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 /// 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. /// 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); self.repair_style(style);
mut_base(self).update_flags_if_needed(style); mut_base(self).update_flags_if_needed(style);
self.bubble_inline_sizes(); self.bubble_inline_sizes();

View file

@ -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::{transform_style, vertical_align, white_space, word_break};
use style::computed_values::content::ContentItem; use style::computed_values::content::ContentItem;
use style::logical_geometry::{Direction, LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{Direction, LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use style::selector_parser::RestyleDamage; use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::RECONSTRUCT_FLOW; use style::servo::restyle_damage::RECONSTRUCT_FLOW;
use style::str::char_is_whitespace; use style::str::char_is_whitespace;
@ -95,10 +95,10 @@ pub struct Fragment {
pub node: OpaqueNode, pub node: OpaqueNode,
/// The CSS style of this fragment. /// The CSS style of this fragment.
pub style: StyleArc<ServoComputedValues>, pub style: StyleArc<ComputedValues>,
/// The CSS style of this fragment when it's selected /// 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 /// The position of this fragment relative to its owning flow. The size includes padding and
/// border, but not margin. /// border, but not margin.
@ -676,8 +676,8 @@ impl Fragment {
/// Constructs a new `Fragment` instance from an opaque node. /// Constructs a new `Fragment` instance from an opaque node.
pub fn from_opaque_node_and_style(node: OpaqueNode, pub fn from_opaque_node_and_style(node: OpaqueNode,
pseudo: PseudoElementType<()>, pseudo: PseudoElementType<()>,
style: StyleArc<ServoComputedValues>, style: StyleArc<ComputedValues>,
selected_style: StyleArc<ServoComputedValues>, selected_style: StyleArc<ComputedValues>,
mut restyle_damage: RestyleDamage, mut restyle_damage: RestyleDamage,
specific: SpecificFragmentInfo) specific: SpecificFragmentInfo)
-> Fragment { -> Fragment {
@ -706,7 +706,7 @@ impl Fragment {
/// type. For the new anonymous fragment, layout-related values (border box, etc.) are reset to /// type. For the new anonymous fragment, layout-related values (border box, etc.) are reset to
/// initial values. /// initial values.
pub fn create_similar_anonymous_fragment(&self, pub fn create_similar_anonymous_fragment(&self,
style: StyleArc<ServoComputedValues>, style: StyleArc<ComputedValues>,
specific: SpecificFragmentInfo) specific: SpecificFragmentInfo)
-> Fragment { -> Fragment {
let writing_mode = style.writing_mode; let writing_mode = style.writing_mode;
@ -1339,7 +1339,7 @@ impl Fragment {
// Return offset from original position because of `position: relative`. // Return offset from original position because of `position: relative`.
pub fn relative_position(&self, containing_block_size: &LogicalSize<Au>) -> LogicalSize<Au> { 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> { -> LogicalSize<Au> {
let offsets = style.logical_position(); let offsets = style.logical_position();
let offset_i = if offsets.inline_start != LengthOrPercentageOrAuto::Auto { let offset_i = if offsets.inline_start != LengthOrPercentageOrAuto::Auto {
@ -1392,12 +1392,12 @@ impl Fragment {
} }
#[inline(always)] #[inline(always)]
pub fn style(&self) -> &ServoComputedValues { pub fn style(&self) -> &ComputedValues {
&*self.style &*self.style
} }
#[inline(always)] #[inline(always)]
pub fn selected_style(&self) -> &ServoComputedValues { pub fn selected_style(&self) -> &ComputedValues {
&*self.selected_style &*self.selected_style
} }
@ -2142,7 +2142,7 @@ impl Fragment {
}; };
return inline_metrics; 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. // 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 // For replaced elements, inline-block elements, and inline-table elements, this is the
// height of their margin box." // 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() self.style = (*new_style).clone()
} }
@ -3038,9 +3038,9 @@ pub struct InlineStyleIterator<'a> {
} }
impl<'a> Iterator for 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 { if !self.primary_style_yielded {
self.primary_style_yielded = true; self.primary_style_yielded = true;
return Some(&*self.fragment.style) return Some(&*self.fragment.style)

View file

@ -18,7 +18,7 @@ use smallvec::SmallVec;
use std::collections::{HashMap, LinkedList}; use std::collections::{HashMap, LinkedList};
use style::computed_values::{display, list_style_type}; use style::computed_values::{display, list_style_type};
use style::computed_values::content::ContentItem; use style::computed_values::content::ContentItem;
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use style::selector_parser::RestyleDamage; use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT; use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
use text::TextRunScanner; use text::TextRunScanner;
@ -298,7 +298,7 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
self.incremented = true 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; let quotes = &style.get_list().quotes;
if quotes.0.is_empty() { if quotes.0.is_empty() {
return String::new() return String::new()
@ -368,7 +368,7 @@ impl Counter {
layout_context: &LayoutContext, layout_context: &LayoutContext,
node: OpaqueNode, node: OpaqueNode,
pseudo: PseudoElementType<()>, pseudo: PseudoElementType<()>,
style: ::StyleArc<ServoComputedValues>, style: ::StyleArc<ComputedValues>,
list_style_type: list_style_type::T, list_style_type: list_style_type::T,
mode: RenderingMode) mode: RenderingMode)
-> Option<SpecificFragmentInfo> { -> Option<SpecificFragmentInfo> {
@ -431,7 +431,7 @@ struct CounterValue {
fn render_text(layout_context: &LayoutContext, fn render_text(layout_context: &LayoutContext,
node: OpaqueNode, node: OpaqueNode,
pseudo: PseudoElementType<()>, pseudo: PseudoElementType<()>,
style: ::StyleArc<ServoComputedValues>, style: ::StyleArc<ComputedValues>,
string: String) string: String)
-> Option<SpecificFragmentInfo> { -> Option<SpecificFragmentInfo> {
let mut fragments = LinkedList::new(); let mut fragments = LinkedList::new();

View file

@ -33,7 +33,7 @@ use std::sync::Arc;
use style::computed_values::{display, overflow_x, position, text_align, text_justify}; use style::computed_values::{display, overflow_x, position, text_align, text_justify};
use style::computed_values::{vertical_align, white_space}; use style::computed_values::{vertical_align, white_space};
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; 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 style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION, RESOLVE_GENERATED_CONTENT};
use text; use text;
use unicode_bidi as bidi; use unicode_bidi as bidi;
@ -1106,7 +1106,7 @@ impl InlineFlow {
/// Computes the minimum metrics for each line. This is done during flow construction. /// Computes the minimum metrics for each line. This is done during flow construction.
/// ///
/// `style` is the style of the block. /// `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 { -> LineMetrics {
InlineFlow::minimum_line_metrics_for_fragments(&self.fragments.fragments, InlineFlow::minimum_line_metrics_for_fragments(&self.fragments.fragments,
font_context, font_context,
@ -1119,7 +1119,7 @@ impl InlineFlow {
/// `style` is the style of the block that these fragments belong to. /// `style` is the style of the block that these fragments belong to.
pub fn minimum_line_metrics_for_fragments(fragments: &[Fragment], pub fn minimum_line_metrics_for_fragments(fragments: &[Fragment],
font_context: &mut FontContext, font_context: &mut FontContext,
style: &ServoComputedValues) style: &ComputedValues)
-> LineMetrics { -> LineMetrics {
// As a special case, if this flow contains only hypothetical fragments, then the entire // 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. // 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); 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 { fn compute_overflow(&self) -> Overflow {
let mut overflow = Overflow::new(); let mut overflow = Overflow::new();
@ -1754,8 +1754,8 @@ impl fmt::Debug for InlineFlow {
#[derive(Clone)] #[derive(Clone)]
pub struct InlineFragmentNodeInfo { pub struct InlineFragmentNodeInfo {
pub address: OpaqueNode, pub address: OpaqueNode,
pub style: StyleArc<ServoComputedValues>, pub style: StyleArc<ComputedValues>,
pub selected_style: StyleArc<ServoComputedValues>, pub selected_style: StyleArc<ComputedValues>,
pub pseudo: PseudoElementType<()>, pub pseudo: PseudoElementType<()>,
pub flags: InlineFragmentNodeFlags, pub flags: InlineFragmentNodeFlags,
} }

View file

@ -20,7 +20,7 @@ use generated_content;
use inline::InlineFlow; use inline::InlineFlow;
use style::computed_values::{list_style_type, position}; use style::computed_values::{list_style_type, position};
use style::logical_geometry::LogicalSize; use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT; use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
/// A block with the CSS `display` property equal to `list-item`. /// 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); 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) self.block_flow.repair_style(new_style)
} }

View file

@ -13,7 +13,7 @@ use std::cmp::{max, min};
use std::fmt; use std::fmt;
use style::computed_values::transform::ComputedMatrix; use style::computed_values::transform::ComputedMatrix;
use style::logical_geometry::{LogicalMargin, WritingMode}; use style::logical_geometry::{LogicalMargin, WritingMode};
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use style::values::computed::{BorderCornerRadius, LengthOrPercentageOrAuto}; use style::values::computed::{BorderCornerRadius, LengthOrPercentageOrAuto};
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone}; use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone};
@ -481,7 +481,7 @@ pub fn specified_border_radius(
} }
#[inline] #[inline]
pub fn padding_from_style(style: &ServoComputedValues, pub fn padding_from_style(style: &ComputedValues,
containing_block_inline_size: Au, containing_block_inline_size: Au,
writing_mode: WritingMode) writing_mode: WritingMode)
-> LogicalMargin<Au> { -> LogicalMargin<Au> {
@ -498,7 +498,7 @@ pub fn padding_from_style(style: &ServoComputedValues,
/// ///
/// This is used when calculating intrinsic inline sizes. /// This is used when calculating intrinsic inline sizes.
#[inline] #[inline]
pub fn specified_margin_from_style(style: &ServoComputedValues, pub fn specified_margin_from_style(style: &ComputedValues,
writing_mode: WritingMode) -> LogicalMargin<Au> { writing_mode: WritingMode) -> LogicalMargin<Au> {
let margin_style = style.get_margin(); let margin_style = style.get_margin();
LogicalMargin::from_physical(writing_mode, SideOffsets2D::new( LogicalMargin::from_physical(writing_mode, SideOffsets2D::new(

View file

@ -20,7 +20,7 @@ use std::cmp::{min, max};
use std::fmt; use std::fmt;
use std::sync::Arc; use std::sync::Arc;
use style::logical_geometry::LogicalSize; use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use style::values::Either; use style::values::Either;
use style::values::computed::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; use style::values::computed::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
@ -193,7 +193,7 @@ impl Flow for MulticolFlow {
self.block_flow.collect_stacking_contexts(state); 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) self.block_flow.repair_style(new_style)
} }
@ -275,7 +275,7 @@ impl Flow for MulticolColumnFlow {
self.block_flow.collect_stacking_contexts(state); 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) self.block_flow.repair_style(new_style)
} }

View file

@ -24,7 +24,7 @@ use std::fmt;
use style::computed_values::{border_collapse, border_spacing, table_layout}; use style::computed_values::{border_collapse, border_spacing, table_layout};
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::logical_geometry::LogicalSize; 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::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::CSSFloat; use style::values::CSSFloat;
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
@ -506,7 +506,7 @@ impl Flow for TableFlow {
self.block_flow.collect_stacking_contexts(state); 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) self.block_flow.repair_style(new_style)
} }

View file

@ -16,7 +16,7 @@ use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx_traits::print_tree::PrintTree; use gfx_traits::print_tree::PrintTree;
use std::fmt; use std::fmt;
use style::logical_geometry::LogicalSize; use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
/// A table formatting context. /// A table formatting context.
pub struct TableCaptionFlow { pub struct TableCaptionFlow {
@ -83,7 +83,7 @@ impl Flow for TableCaptionFlow {
self.block_flow.collect_stacking_contexts(state); 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) self.block_flow.repair_style(new_style)
} }

View file

@ -20,7 +20,7 @@ use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode;
use std::fmt; use std::fmt;
use style::computed_values::{border_collapse, border_top_style, vertical_align}; use style::computed_values::{border_collapse, border_top_style, vertical_align};
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use style::values::computed::Color; use style::values::computed::Color;
use table::InternalTable; use table::InternalTable;
use table_row::{CollapsedBorder, CollapsedBorderProvenance}; use table_row::{CollapsedBorder, CollapsedBorderProvenance};
@ -263,7 +263,7 @@ impl Flow for TableCellFlow {
self.block_flow.collect_stacking_contexts(state); 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) self.block_flow.repair_style(new_style)
} }

View file

@ -16,7 +16,7 @@ use layout_debug;
use std::cmp::max; use std::cmp::max;
use std::fmt; use std::fmt;
use style::logical_geometry::LogicalSize; use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
/// A table formatting context. /// A table formatting context.
@ -94,7 +94,7 @@ impl Flow for TableColGroupFlow {
fn collect_stacking_contexts(&mut self, _: &mut DisplayListBuildState) {} 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 { fn compute_overflow(&self) -> Overflow {
Overflow::new() Overflow::new()

View file

@ -23,7 +23,7 @@ use std::fmt;
use std::iter::{Enumerate, IntoIterator, Peekable}; use std::iter::{Enumerate, IntoIterator, Peekable};
use style::computed_values::{border_collapse, border_spacing, border_top_style}; use style::computed_values::{border_collapse, border_spacing, border_top_style};
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode}; 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::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::computed::{Color, LengthOrPercentageOrAuto}; use style::values::computed::{Color, LengthOrPercentageOrAuto};
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt}; use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
@ -481,7 +481,7 @@ impl Flow for TableRowFlow {
self.block_flow.collect_stacking_contexts(state); 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) 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 /// Creates a collapsed border from the block-start border described in the given CSS style
/// object. /// object.
fn top(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) fn top(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder { -> CollapsedBorder {
CollapsedBorder { CollapsedBorder {
style: css_style.get_border().border_top_style, 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 /// Creates a collapsed border style from the right border described in the given CSS style
/// object. /// object.
fn right(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) fn right(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder { -> CollapsedBorder {
CollapsedBorder { CollapsedBorder {
style: css_style.get_border().border_right_style, 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 /// Creates a collapsed border style from the bottom border described in the given CSS style
/// object. /// object.
fn bottom(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) fn bottom(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder { -> CollapsedBorder {
CollapsedBorder { CollapsedBorder {
style: css_style.get_border().border_bottom_style, 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 /// Creates a collapsed border style from the left border described in the given CSS style
/// object. /// object.
fn left(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) fn left(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder { -> CollapsedBorder {
CollapsedBorder { CollapsedBorder {
style: css_style.get_border().border_left_style, style: css_style.get_border().border_left_style,
@ -660,7 +660,7 @@ impl CollapsedBorder {
/// Creates a collapsed border style from the given physical side. /// Creates a collapsed border style from the given physical side.
fn from_side(side: PhysicalSide, fn from_side(side: PhysicalSide,
css_style: &ServoComputedValues, css_style: &ComputedValues,
provenance: CollapsedBorderProvenance) provenance: CollapsedBorderProvenance)
-> CollapsedBorder { -> CollapsedBorder {
match side { match side {
@ -673,7 +673,7 @@ impl CollapsedBorder {
/// Creates a collapsed border style from the inline-start border described in the given CSS /// Creates a collapsed border style from the inline-start border described in the given CSS
/// style object. /// style object.
pub fn inline_start(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) pub fn inline_start(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder { -> CollapsedBorder {
CollapsedBorder::from_side(css_style.writing_mode.inline_start_physical_side(), CollapsedBorder::from_side(css_style.writing_mode.inline_start_physical_side(),
css_style, css_style,
@ -682,7 +682,7 @@ impl CollapsedBorder {
/// Creates a collapsed border style from the inline-start border described in the given CSS /// Creates a collapsed border style from the inline-start border described in the given CSS
/// style object. /// style object.
pub fn inline_end(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) pub fn inline_end(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder { -> CollapsedBorder {
CollapsedBorder::from_side(css_style.writing_mode.inline_end_physical_side(), CollapsedBorder::from_side(css_style.writing_mode.inline_end_physical_side(),
css_style, css_style,
@ -691,7 +691,7 @@ impl CollapsedBorder {
/// Creates a collapsed border style from the block-start border described in the given CSS /// Creates a collapsed border style from the block-start border described in the given CSS
/// style object. /// style object.
pub fn block_start(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) pub fn block_start(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder { -> CollapsedBorder {
CollapsedBorder::from_side(css_style.writing_mode.block_start_physical_side(), CollapsedBorder::from_side(css_style.writing_mode.block_start_physical_side(),
css_style, css_style,
@ -700,7 +700,7 @@ impl CollapsedBorder {
/// Creates a collapsed border style from the block-end border described in the given CSS style /// Creates a collapsed border style from the block-end border described in the given CSS style
/// object. /// object.
pub fn block_end(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance) pub fn block_end(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder { -> CollapsedBorder {
CollapsedBorder::from_side(css_style.writing_mode.block_end_physical_side(), CollapsedBorder::from_side(css_style.writing_mode.block_end_physical_side(),
css_style, 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 /// 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. /// computations can be parallelized across all the rows of the table.
fn perform_inline_direction_border_collapse_for_row( fn perform_inline_direction_border_collapse_for_row(
row_style: &ServoComputedValues, row_style: &ComputedValues,
children_count: usize, children_count: usize,
child_index: usize, child_index: usize,
child_table_cell: &mut TableCellFlow, child_table_cell: &mut TableCellFlow,

View file

@ -20,7 +20,7 @@ use std::fmt;
use std::iter::{IntoIterator, Iterator, Peekable}; use std::iter::{IntoIterator, Iterator, Peekable};
use style::computed_values::{border_collapse, border_spacing}; use style::computed_values::{border_collapse, border_spacing};
use style::logical_geometry::LogicalSize; use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use table::{ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow}; use table::{ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow};
/// A table formatting context. /// A table formatting context.
@ -185,7 +185,7 @@ impl Flow for TableRowGroupFlow {
self.block_flow.collect_stacking_contexts(state); 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) self.block_flow.repair_style(new_style)
} }

View file

@ -30,7 +30,7 @@ use std::ops::Add;
use style::computed_values::{border_collapse, position, table_layout}; use style::computed_values::{border_collapse, position, table_layout};
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalRect, LogicalSize}; use style::logical_geometry::{LogicalRect, LogicalSize};
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use style::values::CSSFloat; use style::values::CSSFloat;
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize}; use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize};
@ -466,7 +466,7 @@ impl Flow for TableWrapperFlow {
self.block_flow.collect_stacking_contexts(state); 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) self.block_flow.repair_style(new_style)
} }

View file

@ -26,7 +26,7 @@ use std::sync::Arc;
use style::computed_values::{text_rendering, text_transform}; use style::computed_values::{text_rendering, text_transform};
use style::computed_values::{word_break, white_space}; use style::computed_values::{word_break, white_space};
use style::logical_geometry::{LogicalSize, WritingMode}; use style::logical_geometry::{LogicalSize, WritingMode};
use style::properties::ServoComputedValues; use style::properties::ComputedValues;
use style::properties::style_structs; use style::properties::style_structs;
use style::values::generics::text::LineHeight; use style::values::generics::text::LineHeight;
use unicode_bidi as bidi; 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. /// 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; let font_size = style.get_font().font_size;
match style.get_inheritedtext().line_height { match style.get_inheritedtext().line_height {
LineHeight::Normal => metrics.line_gap, LineHeight::Normal => metrics.line_gap,

View file

@ -22,7 +22,7 @@ use style::data::ElementData;
use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthesizer, TNode}; use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthesizer, TNode};
use style::dom::OpaqueNode; use style::dom::OpaqueNode;
use style::font_metrics::ServoMetricsProvider; use style::font_metrics::ServoMetricsProvider;
use style::properties::{CascadeFlags, ServoComputedValues}; use style::properties::{CascadeFlags, ComputedValues};
use style::selector_parser::{PseudoElement, PseudoElementCascadeType, SelectorImpl}; use style::selector_parser::{PseudoElement, PseudoElementCascadeType, SelectorImpl};
use style::stylearc::Arc; use style::stylearc::Arc;
use style::stylist::RuleInclusion; 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 /// 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 /// of the parent data is fine, since the bottom-up traversal will not process
/// the parent until all the children have been processed. /// the parent until all the children have been processed.
fn parent_style(&self) -> Arc<ServoComputedValues>; fn parent_style(&self) -> Arc<ComputedValues>;
#[inline] #[inline]
fn is_element_or_elements_pseudo(&self) -> bool { 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 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() { if let Some(el) = self.as_element() {
el.style(context) el.style(context)
} else { } 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() { if let Some(el) = self.as_element() {
el.selected_style() el.selected_style()
} else { } else {
@ -393,7 +393,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
/// ///
/// Unlike the version on TNode, this handles pseudo-elements. /// Unlike the version on TNode, this handles pseudo-elements.
#[inline] #[inline]
fn style(&self, context: &SharedStyleContext) -> Arc<ServoComputedValues> { fn style(&self, context: &SharedStyleContext) -> Arc<ComputedValues> {
let data = self.style_data(); let data = self.style_data();
match self.get_pseudo_element_type() { match self.get_pseudo_element_type() {
PseudoElementType::Normal => { PseudoElementType::Normal => {
@ -438,7 +438,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
} }
#[inline] #[inline]
fn selected_style(&self) -> Arc<ServoComputedValues> { fn selected_style(&self) -> Arc<ComputedValues> {
let data = self.style_data(); let data = self.style_data();
data.styles.pseudos data.styles.pseudos
.get(&PseudoElement::Selection).map(|s| s) .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 /// This should be used just for querying layout, or when we know the
/// element style is precomputed, not from general layout itself. /// element style is precomputed, not from general layout itself.
#[inline] #[inline]
fn resolved_style(&self) -> Arc<ServoComputedValues> { fn resolved_style(&self) -> Arc<ComputedValues> {
let data = self.style_data(); let data = self.style_data();
match self.get_pseudo_element_type() { match self.get_pseudo_element_type() {
PseudoElementType::Normal PseudoElementType::Normal

View file

@ -11,7 +11,7 @@ use context::SharedStyleContext;
use dom::OpaqueNode; use dom::OpaqueNode;
use euclid::Point2D; use euclid::Point2D;
use font_metrics::FontMetricsProvider; 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::animated_properties::{AnimatableLonghand, AnimatedProperty, TransitionProperty};
use properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection; 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; 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, fn from_animatable_longhand(animatable_longhand: &AnimatableLonghand,
timing_function: TimingFunction, timing_function: TimingFunction,
duration: Time, duration: Time,
old_style: &ComputedValues, old_style: &ComputedValuesInner,
new_style: &ComputedValues) new_style: &ComputedValuesInner)
-> Option<PropertyAnimation> { -> Option<PropertyAnimation> {
let animated_property = AnimatedProperty::from_animatable_longhand(animatable_longhand, let animated_property = AnimatedProperty::from_animatable_longhand(animatable_longhand,
old_style, 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, fn compute_style_for_animation_step(context: &SharedStyleContext,
step: &KeyframesStep, step: &KeyframesStep,
previous_style: &ComputedValues, previous_style: &ComputedValuesInner,
style_from_cascade: &ComputedValues, style_from_cascade: &ComputedValuesInner,
font_metrics_provider: &FontMetricsProvider) font_metrics_provider: &FontMetricsProvider)
-> ComputedValues { -> ComputedValuesInner {
match step.value { match step.value {
KeyframesStepValue::ComputedValues => style_from_cascade.clone(), KeyframesStepValue::ComputedValues => style_from_cascade.clone(),
KeyframesStepValue::Declarations { block: ref declarations } => { KeyframesStepValue::Declarations { block: ref declarations } => {

View file

@ -15,7 +15,7 @@ use data::ElementData;
use element_state::ElementState; use element_state::ElementState;
use font_metrics::FontMetricsProvider; use font_metrics::FontMetricsProvider;
use media_queries::Device; 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::AnimationValue;
#[cfg(feature = "gecko")] use properties::animated_properties::TransitionProperty; #[cfg(feature = "gecko")] use properties::animated_properties::TransitionProperty;
use rule_tree::CascadeLevel; use rule_tree::CascadeLevel;
@ -436,7 +436,7 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
fn may_generate_pseudo( fn may_generate_pseudo(
&self, &self,
pseudo: &PseudoElement, pseudo: &PseudoElement,
_primary_style: &ComputedValues, _primary_style: &ComputedValuesInner,
) -> bool { ) -> bool {
// ::before/::after are always supported for now, though we could try to // ::before/::after are always supported for now, though we could try to
// optimize out leaf elements. // optimize out leaf elements.

View file

@ -16,7 +16,7 @@ use gecko_bindings::structs::nsIDocument;
use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI}; use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
use invalidation::media_queries::{MediaListKey, ToMediaListKey}; use invalidation::media_queries::{MediaListKey, ToMediaListKey};
use media_queries::{Device, MediaList}; use media_queries::{Device, MediaList};
use properties::ComputedValues; use properties::ComputedValuesInner;
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard}; use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
use stylearc::Arc; use stylearc::Arc;
use stylesheet_set::StylesheetSet; use stylesheet_set::StylesheetSet;
@ -188,8 +188,8 @@ impl PerDocumentStyleDataImpl {
} }
/// Get the default computed values for this document. /// Get the default computed values for this document.
pub fn default_computed_values(&self) -> &Arc<ComputedValues> { pub fn default_computed_values(&self) -> &ComputedValuesInner {
self.stylist.device().default_computed_values_arc() self.stylist.device().default_computed_values()
} }
/// Clear the stylist. This will be a no-op if the stylist is /// Clear the stylist. This will be a no-op if the stylist is

View file

@ -17,7 +17,7 @@ use gecko_bindings::structs::{nsMediaFeature_ValueType, nsMediaFeature_RangeType
use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextOwned}; use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextOwned};
use media_queries::MediaType; use media_queries::MediaType;
use parser::ParserContext; use parser::ParserContext;
use properties::{ComputedValues, StyleBuilder}; use properties::{ComputedValuesInner, StyleBuilder};
use properties::longhands::font_size; use properties::longhands::font_size;
use selectors::parser::SelectorParseError; use selectors::parser::SelectorParseError;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
@ -26,7 +26,6 @@ use str::starts_with_ignore_ascii_case;
use string_cache::Atom; use string_cache::Atom;
use style_traits::{ToCss, ParseError, StyleParseError}; use style_traits::{ToCss, ParseError, StyleParseError};
use style_traits::viewport::ViewportConstraints; use style_traits::viewport::ViewportConstraints;
use stylearc::Arc;
use values::{CSSFloat, specified}; use values::{CSSFloat, specified};
use values::computed::{self, ToComputedValue}; use values::computed::{self, ToComputedValue};
@ -37,7 +36,7 @@ pub struct Device {
/// stylist, and thus the `Device`, so having a raw pres context pointer /// stylist, and thus the `Device`, so having a raw pres context pointer
/// here is fine. /// here is fine.
pres_context: RawGeckoPresContextOwned, pres_context: RawGeckoPresContextOwned,
default_values: Arc<ComputedValues>, default_values: ComputedValuesInner,
viewport_override: Option<ViewportConstraints>, viewport_override: Option<ViewportConstraints>,
/// The font size of the root element /// The font size of the root element
/// This is set when computing the style of the root /// This is set when computing the style of the root
@ -62,7 +61,7 @@ impl Device {
assert!(!pres_context.is_null()); assert!(!pres_context.is_null());
Device { Device {
pres_context: pres_context, pres_context: pres_context,
default_values: ComputedValues::default_values(unsafe { &*pres_context }), default_values: ComputedValuesInner::default_values(unsafe { &*pres_context }),
viewport_override: None, viewport_override: None,
root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious? root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious?
used_root_font_size: AtomicBool::new(false), 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 /// Returns the default computed values as a reference, in order to match
/// Servo. /// Servo.
pub fn default_computed_values(&self) -> &ComputedValues { pub fn default_computed_values(&self) -> &ComputedValuesInner {
&*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> {
&self.default_values &self.default_values
} }
@ -114,7 +101,7 @@ impl Device {
pub fn reset_computed_values(&mut self) { pub fn reset_computed_values(&mut self) {
// NB: A following stylesheet flush will populate this if appropriate. // NB: A following stylesheet flush will populate this if appropriate.
self.viewport_override = None; 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); self.used_root_font_size.store(false, Ordering::Relaxed);
} }

View file

@ -110,13 +110,13 @@ impl<'a> Iterator for PropertyDeclarationIterator<'a> {
pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> { pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
iter: Iter<'a, (PropertyDeclaration, Importance)>, iter: Iter<'a, (PropertyDeclaration, Importance)>,
context: &'cx mut Context<'cx_a>, 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> { impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
fn new(declarations: &'a PropertyDeclarationBlock, fn new(declarations: &'a PropertyDeclarationBlock,
context: &'cx mut Context<'cx_a>, 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 { AnimationValueIterator {
iter: declarations.declarations().iter(), iter: declarations.declarations().iter(),
context: context, context: context,
@ -204,7 +204,7 @@ impl PropertyDeclarationBlock {
/// Return an iterator of (AnimatableLonghand, AnimationValue). /// Return an iterator of (AnimatableLonghand, AnimationValue).
pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self, pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self,
context: &'cx mut Context<'cx_a>, context: &'cx mut Context<'cx_a>,
default_values: &'a Arc<ComputedValues>) default_values: &'a ComputedValuesInner)
-> AnimationValueIterator<'a, 'cx, 'cx_a> { -> AnimationValueIterator<'a, 'cx, 'cx_a> {
AnimationValueIterator::new(self, context, default_values) AnimationValueIterator::new(self, context, default_values)
} }

View file

@ -97,7 +97,7 @@ impl Clone for ComputedValuesInner {
} }
} }
impl ComputedValues { impl ComputedValuesInner {
pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>, pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>,
writing_mode: WritingMode, writing_mode: WritingMode,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>, font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
@ -108,24 +108,21 @@ impl ComputedValues {
${style_struct.ident}: Arc<style_structs::${style_struct.name}>, ${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
% endfor % endfor
) -> Self { ) -> Self {
ComputedValues { ComputedValuesInner {
inner: ComputedValuesInner { custom_properties: custom_properties,
custom_properties: custom_properties, writing_mode: writing_mode,
writing_mode: writing_mode, font_computation_data: FontComputationData::new(font_size_keyword),
font_computation_data: FontComputationData::new(font_size_keyword), rules: rules,
rules: rules, visited_style: visited_style,
visited_style: visited_style, flags: flags,
flags: flags, % for style_struct in data.style_structs:
% for style_struct in data.style_structs: ${style_struct.gecko_name}: Arc::into_raw_offset(${style_struct.ident}),
${style_struct.gecko_name}: Arc::into_raw_offset(${style_struct.ident}), % endfor
% endfor
}
} }
} }
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> { pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Self {
Arc::new(ComputedValues { ComputedValuesInner {
inner: ComputedValuesInner {
custom_properties: None, custom_properties: None,
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
font_computation_data: FontComputationData::default_values(), font_computation_data: FontComputationData::default_values(),
@ -135,8 +132,10 @@ impl ComputedValues {
% for style_struct in data.style_structs: % for style_struct in data.style_structs:
${style_struct.gecko_name}: Arc::into_raw_offset(style_structs::${style_struct.name}::default(pres_context)), ${style_struct.gecko_name}: Arc::into_raw_offset(style_structs::${style_struct.name}::default(pres_context)),
% endfor % 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. /// Gets a reference to the visited style, if any.
pub fn get_visited_style(&self) -> Option<<&Arc<ComputedValues>> { pub fn get_visited_style(&self) -> Option< & ComputedValuesInner> {
self.visited_style.as_ref() self.visited_style.as_ref().map(|x| &***x)
} }
/// Gets a reference to the visited style. Panic if no visited style exists. /// 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() self.get_visited_style().unwrap()
} }

View file

@ -292,7 +292,7 @@
#[allow(unused_imports)] #[allow(unused_imports)]
use properties::{DeclaredValue, LonghandId, LonghandIdSet}; use properties::{DeclaredValue, LonghandId, LonghandIdSet};
#[allow(unused_imports)] #[allow(unused_imports)]
use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration}; use properties::{CSSWideKeyword, ComputedValuesInner, PropertyDeclaration};
#[allow(unused_imports)] #[allow(unused_imports)]
use properties::style_structs; use properties::style_structs;
#[allow(unused_imports)] #[allow(unused_imports)]
@ -310,8 +310,8 @@
${caller.body()} ${caller.body()}
#[allow(unused_variables)] #[allow(unused_variables)]
pub fn cascade_property(declaration: &PropertyDeclaration, pub fn cascade_property(declaration: &PropertyDeclaration,
inherited_style: &ComputedValues, inherited_style: &ComputedValuesInner,
default_style: &ComputedValues, default_style: &ComputedValuesInner,
context: &mut computed::Context, context: &mut computed::Context,
cacheable: &mut bool, cacheable: &mut bool,
cascade_info: &mut Option<<&mut CascadeInfo>) { cascade_info: &mut Option<<&mut CascadeInfo>) {

View file

@ -29,7 +29,7 @@ use smallvec::SmallVec;
use std::cmp; use std::cmp;
#[cfg(feature = "gecko")] use fnv::FnvHashMap; #[cfg(feature = "gecko")] use fnv::FnvHashMap;
use style_traits::ParseError; use style_traits::ParseError;
use super::ComputedValues; use super::ComputedValuesInner;
#[cfg(any(feature = "gecko", feature = "testing"))] #[cfg(any(feature = "gecko", feature = "testing"))]
use values::Auto; use values::Auto;
use values::{CSSFloat, CustomIdent, Either}; use values::{CSSFloat, CustomIdent, Either};
@ -394,7 +394,7 @@ impl AnimatedProperty {
/// Update `style` with the proper computed style corresponding to this /// Update `style` with the proper computed style corresponding to this
/// animation at `progress`. /// animation at `progress`.
pub fn update(&self, style: &mut ComputedValues, progress: f64) { pub fn update(&self, style: &mut ComputedValuesInner, progress: f64) {
match *self { match *self {
% for prop in data.longhands: % for prop in data.longhands:
% if prop.animatable: % if prop.animatable:
@ -427,8 +427,8 @@ impl AnimatedProperty {
/// Get an animatable value from a transition-property, an old style, and a /// Get an animatable value from a transition-property, an old style, and a
/// new style. /// new style.
pub fn from_animatable_longhand(property: &AnimatableLonghand, pub fn from_animatable_longhand(property: &AnimatableLonghand,
old_style: &ComputedValues, old_style: &ComputedValuesInner,
new_style: &ComputedValues) new_style: &ComputedValuesInner)
-> AnimatedProperty { -> AnimatedProperty {
match *property { match *property {
% for prop in data.longhands: % for prop in data.longhands:
@ -521,7 +521,7 @@ impl AnimationValue {
/// Construct an AnimationValue from a property declaration /// Construct an AnimationValue from a property declaration
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context, pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
initial: &ComputedValues) -> Option<Self> { initial: &ComputedValuesInner) -> Option<Self> {
use properties::LonghandId; use properties::LonghandId;
match *decl { match *decl {
@ -593,7 +593,7 @@ impl AnimationValue {
/// Get an AnimationValue for an AnimatableLonghand from a given computed values. /// Get an AnimationValue for an AnimatableLonghand from a given computed values.
pub fn from_computed_values(property: &AnimatableLonghand, pub fn from_computed_values(property: &AnimatableLonghand,
computed_values: &ComputedValues) computed_values: &ComputedValuesInner)
-> Self { -> Self {
match *property { match *property {
% for prop in data.longhands: % for prop in data.longhands:

View file

@ -181,7 +181,7 @@
% if product == "servo": % if product == "servo":
fn cascade_property_custom(_declaration: &PropertyDeclaration, fn cascade_property_custom(_declaration: &PropertyDeclaration,
_inherited_style: &ComputedValues, _inherited_style: &ComputedValuesInner,
context: &mut computed::Context, context: &mut computed::Context,
_cacheable: &mut bool) { _cacheable: &mut bool) {
longhands::_servo_display_for_hypothetical_box::derive_from_display(context); longhands::_servo_display_for_hypothetical_box::derive_from_display(context);

View file

@ -249,7 +249,7 @@ ${helpers.single_keyword("unicode-bidi",
% if product == "servo": % if product == "servo":
fn cascade_property_custom(_declaration: &PropertyDeclaration, fn cascade_property_custom(_declaration: &PropertyDeclaration,
_inherited_style: &ComputedValues, _inherited_style: &ComputedValuesInner,
context: &mut computed::Context, context: &mut computed::Context,
_cacheable: &mut bool) { _cacheable: &mut bool) {
longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context); longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context);

View file

@ -1872,6 +1872,8 @@ pub mod style_structs {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use gecko_properties::ComputedValues; pub use gecko_properties::ComputedValues;
#[cfg(feature = "gecko")]
pub use gecko_properties::ComputedValuesInner;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
@ -1920,7 +1922,7 @@ pub struct ComputedValues {
} }
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
impl ComputedValues { impl ComputedValuesInner {
/// Construct a `ComputedValues` instance. /// Construct a `ComputedValues` instance.
pub fn new( pub fn new(
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>, custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
@ -1933,18 +1935,16 @@ impl ComputedValues {
${style_struct.ident}: Arc<style_structs::${style_struct.name}>, ${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
% endfor % endfor
) -> Self { ) -> Self {
ComputedValues { ComputedValuesInner {
inner: ComputedValuesInner { custom_properties: custom_properties,
custom_properties: custom_properties, writing_mode: writing_mode,
writing_mode: writing_mode, font_computation_data: FontComputationData::new(font_size_keyword),
font_computation_data: FontComputationData::new(font_size_keyword), rules: rules,
rules: rules, visited_style: visited_style,
visited_style: visited_style, flags: flags,
flags: flags, % for style_struct in data.active_style_structs():
% for style_struct in data.active_style_structs(): ${style_struct.ident}: ${style_struct.ident},
${style_struct.ident}: ${style_struct.ident}, % endfor
% endfor
}
} }
} }
@ -1969,6 +1969,11 @@ impl ops::DerefMut for ComputedValues {
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
impl ComputedValuesInner { 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(): % for style_struct in data.active_style_structs():
/// Clone the ${style_struct.name} struct. /// Clone the ${style_struct.name} struct.
#[inline] #[inline]
@ -2006,13 +2011,13 @@ impl ComputedValuesInner {
} }
/// Gets a reference to the visited style, if any. /// Gets a reference to the visited style, if any.
pub fn get_visited_style(&self) -> Option<<&Arc<ComputedValues>> { pub fn get_visited_style(&self) -> Option< & ComputedValuesInner> {
self.visited_style.as_ref() self.visited_style.as_ref().map(|x| &***x)
} }
/// Gets a reference to the visited style. Panic if no visited style exists. /// 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() self.get_visited_style().as_ref().map(|x| &**x).unwrap()
} }
/// Clone the visited style. Used for inheriting parent styles in /// Clone the visited style. Used for inheriting parent styles in
@ -2441,8 +2446,8 @@ pub struct StyleBuilder<'a> {
impl<'a> StyleBuilder<'a> { impl<'a> StyleBuilder<'a> {
/// Trivially construct a `StyleBuilder`. /// Trivially construct a `StyleBuilder`.
fn new( fn new(
inherited_style: &'a ComputedValues, inherited_style: &'a ComputedValuesInner,
reset_style: &'a ComputedValues, reset_style: &'a ComputedValuesInner,
rules: Option<StrongRuleNode>, rules: Option<StrongRuleNode>,
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>, custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
writing_mode: WritingMode, writing_mode: WritingMode,
@ -2469,15 +2474,15 @@ impl<'a> StyleBuilder<'a> {
/// Creates a StyleBuilder holding only references to the structs of `s`, in /// Creates a StyleBuilder holding only references to the structs of `s`, in
/// order to create a derived style. /// 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) Self::for_inheritance(s, s)
} }
/// Inherits style from the parent element, accounting for the default /// Inherits style from the parent element, accounting for the default
/// computed values that need to be provided as well. /// computed values that need to be provided as well.
pub fn for_inheritance( pub fn for_inheritance(
parent: &'a ComputedValues, parent: &'a ComputedValuesInner,
default: &'a ComputedValues default: &'a ComputedValuesInner
) -> Self { ) -> Self {
Self::new( Self::new(
parent, parent,
@ -2521,7 +2526,7 @@ impl<'a> StyleBuilder<'a> {
} }
/// Reset the current `${style_struct.name}` style to its default value. /// 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} = self.${style_struct.ident} =
StyleStructRef::Borrowed(default.${style_struct.name_lower}_arc()); StyleStructRef::Borrowed(default.${style_struct.name_lower}_arc());
} }
@ -2555,8 +2560,8 @@ impl<'a> StyleBuilder<'a> {
/// Turns this `StyleBuilder` into a proper `ComputedValues` instance. /// Turns this `StyleBuilder` into a proper `ComputedValues` instance.
pub fn build(self) -> ComputedValues { pub fn build(self) -> ComputedValuesInner {
ComputedValues::new(self.custom_properties, ComputedValuesInner::new(self.custom_properties,
self.writing_mode, self.writing_mode,
self.font_size_keyword, self.font_size_keyword,
self.flags, self.flags,
@ -2586,30 +2591,28 @@ pub use self::lazy_static_module::INITIAL_SERVO_VALUES;
mod lazy_static_module { mod lazy_static_module {
use logical_geometry::WritingMode; use logical_geometry::WritingMode;
use stylearc::Arc; use stylearc::Arc;
use super::{ComputedValues, ComputedValuesInner, longhands, style_structs, FontComputationData}; use super::{ComputedValuesInner, longhands, style_structs, FontComputationData};
use super::computed_value_flags::ComputedValueFlags; use super::computed_value_flags::ComputedValueFlags;
/// The initial values for all style structs as defined by the specification. /// The initial values for all style structs as defined by the specification.
lazy_static! { lazy_static! {
pub static ref INITIAL_SERVO_VALUES: ComputedValues = ComputedValues { pub static ref INITIAL_SERVO_VALUES: ComputedValuesInner = ComputedValuesInner {
inner: ComputedValuesInner { % for style_struct in data.active_style_structs():
% for style_struct in data.active_style_structs(): ${style_struct.ident}: Arc::new(style_structs::${style_struct.name} {
${style_struct.ident}: Arc::new(style_structs::${style_struct.name} { % for longhand in style_struct.longhands:
% for longhand in style_struct.longhands: ${longhand.ident}: longhands::${longhand.ident}::get_initial_value(),
${longhand.ident}: longhands::${longhand.ident}::get_initial_value(), % endfor
% endfor % if style_struct.name == "Font":
% if style_struct.name == "Font": hash: 0,
hash: 0, % endif
% endif }),
}), % endfor
% endfor custom_properties: None,
custom_properties: None, writing_mode: WritingMode::empty(),
writing_mode: WritingMode::empty(), font_computation_data: FontComputationData::default_values(),
font_computation_data: FontComputationData::default_values(), rules: None,
rules: None, visited_style: None,
visited_style: None, flags: ComputedValueFlags::empty(),
flags: ComputedValueFlags::empty(),
}
}; };
} }
} }
@ -2617,8 +2620,8 @@ mod lazy_static_module {
/// A per-longhand function that performs the CSS cascade for that longhand. /// A per-longhand function that performs the CSS cascade for that longhand.
pub type CascadePropertyFn = pub type CascadePropertyFn =
extern "Rust" fn(declaration: &PropertyDeclaration, extern "Rust" fn(declaration: &PropertyDeclaration,
inherited_style: &ComputedValues, inherited_style: &ComputedValuesInner,
default_style: &ComputedValues, default_style: &ComputedValuesInner,
context: &mut computed::Context, context: &mut computed::Context,
cacheable: &mut bool, cacheable: &mut bool,
cascade_info: &mut Option<<&mut CascadeInfo>); cascade_info: &mut Option<<&mut CascadeInfo>);
@ -2679,14 +2682,14 @@ bitflags! {
pub fn cascade(device: &Device, pub fn cascade(device: &Device,
rule_node: &StrongRuleNode, rule_node: &StrongRuleNode,
guards: &StylesheetGuards, guards: &StylesheetGuards,
parent_style: Option<<&ComputedValues>, parent_style: Option<<&ComputedValuesInner>,
layout_parent_style: Option<<&ComputedValues>, layout_parent_style: Option<<&ComputedValuesInner>,
visited_style: Option<Arc<ComputedValues>>, visited_style: Option<Arc<ComputedValues>>,
cascade_info: Option<<&mut CascadeInfo>, cascade_info: Option<<&mut CascadeInfo>,
font_metrics_provider: &FontMetricsProvider, font_metrics_provider: &FontMetricsProvider,
flags: CascadeFlags, flags: CascadeFlags,
quirks_mode: QuirksMode) quirks_mode: QuirksMode)
-> ComputedValues { -> ComputedValuesInner {
debug_assert!(layout_parent_style.is_none() || parent_style.is_some()); debug_assert!(layout_parent_style.is_none() || parent_style.is_some());
let (inherited_style, layout_parent_style) = match parent_style { let (inherited_style, layout_parent_style) = match parent_style {
Some(parent_style) => { Some(parent_style) => {
@ -2741,14 +2744,14 @@ pub fn cascade(device: &Device,
pub fn apply_declarations<'a, F, I>(device: &Device, pub fn apply_declarations<'a, F, I>(device: &Device,
rules: &StrongRuleNode, rules: &StrongRuleNode,
iter_declarations: F, iter_declarations: F,
inherited_style: &ComputedValues, inherited_style: &ComputedValuesInner,
layout_parent_style: &ComputedValues, layout_parent_style: &ComputedValuesInner,
visited_style: Option<Arc<ComputedValues>>, visited_style: Option<Arc<ComputedValues>>,
mut cascade_info: Option<<&mut CascadeInfo>, mut cascade_info: Option<<&mut CascadeInfo>,
font_metrics_provider: &FontMetricsProvider, font_metrics_provider: &FontMetricsProvider,
flags: CascadeFlags, flags: CascadeFlags,
quirks_mode: QuirksMode) quirks_mode: QuirksMode)
-> ComputedValues -> ComputedValuesInner
where F: Fn() -> I, where F: Fn() -> I,
I: Iterator<Item = (&'a PropertyDeclaration, CascadeLevel)>, I: Iterator<Item = (&'a PropertyDeclaration, CascadeLevel)>,
{ {

View file

@ -11,7 +11,7 @@ use euclid::{Size2D, TypedSize2D};
use font_metrics::ServoMetricsProvider; use font_metrics::ServoMetricsProvider;
use media_queries::MediaType; use media_queries::MediaType;
use parser::ParserContext; use parser::ParserContext;
use properties::{ComputedValues, StyleBuilder}; use properties::{ComputedValuesInner, StyleBuilder};
use properties::longhands::font_size; use properties::longhands::font_size;
use selectors::parser::SelectorParseError; use selectors::parser::SelectorParseError;
use std::fmt; use std::fmt;
@ -62,11 +62,11 @@ impl Device {
} }
/// Return the default computed values for this 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 // FIXME(bz): This isn't really right, but it's no more wrong
// than what we used to do. See // than what we used to do. See
// https://github.com/servo/servo/issues/14773 for fixing it properly. // 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) /// Get the font size of the root element (for rem)

View file

@ -6,7 +6,7 @@
//! a computed style needs in order for it to adhere to the CSS spec. //! a computed style needs in order for it to adhere to the CSS spec.
use app_units::Au; 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::{IS_ROOT_ELEMENT, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, StyleBuilder};
use properties::longhands::display::computed_value::T as display; use properties::longhands::display::computed_value::T as display;
use properties::longhands::float::computed_value::T as float; 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. /// 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 /// https://drafts.csswg.org/css2/visuren.html#dis-pos-flo
fn blockify_if_necessary(&mut self, fn blockify_if_necessary(&mut self,
layout_parent_style: &ComputedValues, layout_parent_style: &ComputedValuesInner,
flags: CascadeFlags) { flags: CascadeFlags) {
let mut blockify = false; let mut blockify = false;
macro_rules! blockify_if { 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://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html
/// https://github.com/servo/servo/issues/15754 /// https://github.com/servo/servo/issues/15754
fn adjust_for_writing_mode(&mut self, 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 our_writing_mode = self.style.get_inheritedbox().clone_writing_mode();
let parent_writing_mode = layout_parent_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 /// See https://github.com/servo/servo/issues/15229
#[cfg(feature = "servo")] #[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_items::T as align_items;
use computed_values::align_self::T as align_self; 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. /// 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; use properties::computed_value_flags::HAS_TEXT_DECORATION_LINES;
if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) || if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) ||
!self.style.get_text().clone_text_decoration_line().is_empty() { !self.style.get_text().clone_text_decoration_line().is_empty() {
@ -324,7 +324,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
} }
#[cfg(feature = "gecko")] #[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; use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
// Line break suppression should only be propagated to in-flow children. // Line break suppression should only be propagated to in-flow children.
if self.style.floated() || self.style.out_of_flow_positioned() { if self.style.floated() || self.style.out_of_flow_positioned() {
@ -361,8 +361,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// * correct unicode-bidi. /// * correct unicode-bidi.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
fn adjust_for_ruby(&mut self, fn adjust_for_ruby(&mut self,
layout_parent_style: &ComputedValues, layout_parent_style: &ComputedValuesInner,
default_computed_values: &'b ComputedValues, default_computed_values: &'b ComputedValuesInner,
flags: CascadeFlags) { flags: CascadeFlags) {
use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP; use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK; 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 /// When comparing to Gecko, this is similar to the work done by
/// `nsStyleContext::ApplyStyleFixups`. /// `nsStyleContext::ApplyStyleFixups`.
pub fn adjust(&mut self, pub fn adjust(&mut self,
layout_parent_style: &ComputedValues, layout_parent_style: &ComputedValuesInner,
_default_computed_values: &'b ComputedValues, _default_computed_values: &'b ComputedValuesInner,
flags: CascadeFlags) { flags: CascadeFlags) {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
{ {

View file

@ -11,7 +11,7 @@ use data::{ElementStyles, EagerPseudoStyles};
use dom::TElement; use dom::TElement;
use log::LogLevel::Trace; use log::LogLevel::Trace;
use matching::{CascadeVisitedMode, MatchMethods}; 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::{IS_ROOT_ELEMENT, PROHIBIT_DISPLAY_CONTENTS, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP};
use properties::{VISITED_DEPENDENT_ONLY, cascade}; use properties::{VISITED_DEPENDENT_ONLY, cascade};
use rule_tree::StrongRuleNode; use rule_tree::StrongRuleNode;
@ -47,7 +47,7 @@ pub struct PrimaryStyle {
fn with_default_parent_styles<E, F, R>(element: E, f: F) -> R fn with_default_parent_styles<E, F, R>(element: E, f: F) -> R
where where
E: TElement, E: TElement,
F: FnOnce(Option<&ComputedValues>, Option<&ComputedValues>) -> R, F: FnOnce(Option<&ComputedValuesInner>, Option<&ComputedValuesInner>) -> R,
{ {
let parent_el = element.inheritance_parent(); let parent_el = element.inheritance_parent();
let parent_data = parent_el.as_ref().and_then(|e| e.borrow_data()); 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()); 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> impl<'a, 'ctx, 'le, E> StyleResolverForElement<'a, 'ctx, 'le, E>
@ -98,8 +98,8 @@ where
/// Resolve just the style of a given element. /// Resolve just the style of a given element.
pub fn resolve_primary_style( pub fn resolve_primary_style(
&mut self, &mut self,
parent_style: Option<&ComputedValues>, parent_style: Option<&ComputedValuesInner>,
layout_parent_style: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValuesInner>,
) -> PrimaryStyle { ) -> PrimaryStyle {
let primary_results = let primary_results =
self.match_primary(VisitedHandlingMode::AllLinksUnvisited); self.match_primary(VisitedHandlingMode::AllLinksUnvisited);
@ -146,8 +146,8 @@ where
/// Resolve the style of a given element, and all its eager pseudo-elements. /// Resolve the style of a given element, and all its eager pseudo-elements.
pub fn resolve_style( pub fn resolve_style(
&mut self, &mut self,
parent_style: Option<&ComputedValues>, parent_style: Option<&ComputedValuesInner>,
layout_parent_style: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValuesInner>,
) -> ElementStyles { ) -> ElementStyles {
use properties::longhands::display::computed_value::T as display; use properties::longhands::display::computed_value::T as display;
@ -168,7 +168,7 @@ where
if primary_style.style.is_display_contents() { if primary_style.style.is_display_contents() {
layout_parent_style layout_parent_style
} else { } else {
Some(&*primary_style.style) Some(&**primary_style.style)
}; };
SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| { SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| {
let pseudo_style = self.resolve_pseudo_style( let pseudo_style = self.resolve_pseudo_style(
@ -215,8 +215,8 @@ where
fn cascade_style_and_visited( fn cascade_style_and_visited(
&mut self, &mut self,
inputs: CascadeInputs, inputs: CascadeInputs,
parent_style: Option<&ComputedValues>, parent_style: Option<&ComputedValuesInner>,
layout_parent_style: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValuesInner>,
pseudo: Option<&PseudoElement>, pseudo: Option<&PseudoElement>,
) -> Arc<ComputedValues> { ) -> Arc<ComputedValues> {
let mut style_if_visited = None; let mut style_if_visited = None;
@ -272,7 +272,7 @@ where
if primary_style.style.is_display_contents() { if primary_style.style.is_display_contents() {
layout_parent_style layout_parent_style
} else { } else {
Some(&*primary_style.style) Some(&**primary_style.style)
}; };
for (i, mut inputs) in pseudo_array.unwrap().iter_mut().enumerate() { for (i, mut inputs) in pseudo_array.unwrap().iter_mut().enumerate() {
@ -302,7 +302,7 @@ where
&mut self, &mut self,
pseudo: &PseudoElement, pseudo: &PseudoElement,
originating_element_style: &PrimaryStyle, originating_element_style: &PrimaryStyle,
layout_parent_style: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValuesInner>,
) -> Option<Arc<ComputedValues>> { ) -> Option<Arc<ComputedValues>> {
let rules = self.match_pseudo( let rules = self.match_pseudo(
&originating_element_style.style, &originating_element_style.style,
@ -398,7 +398,7 @@ where
fn match_pseudo( fn match_pseudo(
&mut self, &mut self,
originating_element_style: &ComputedValues, originating_element_style: &ComputedValuesInner,
pseudo_element: &PseudoElement, pseudo_element: &PseudoElement,
visited_handling: VisitedHandlingMode, visited_handling: VisitedHandlingMode,
) -> Option<StrongRuleNode> { ) -> Option<StrongRuleNode> {
@ -462,8 +462,8 @@ where
&mut self, &mut self,
rules: Option<&StrongRuleNode>, rules: Option<&StrongRuleNode>,
style_if_visited: Option<Arc<ComputedValues>>, style_if_visited: Option<Arc<ComputedValues>>,
mut parent_style: Option<&ComputedValues>, mut parent_style: Option<&ComputedValuesInner>,
layout_parent_style: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValuesInner>,
cascade_visited: CascadeVisitedMode, cascade_visited: CascadeVisitedMode,
pseudo: Option<&PseudoElement>, pseudo: Option<&PseudoElement>,
) -> Arc<ComputedValues> { ) -> Arc<ComputedValues> {
@ -475,7 +475,7 @@ where
} }
if cascade_visited.visited_dependent_only() { if cascade_visited.visited_dependent_only() {
parent_style = parent_style.map(|s| { 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); cascade_flags.insert(VISITED_DEPENDENT_ONLY);
} }
@ -486,7 +486,7 @@ where
} }
let values = let values =
Arc::new(cascade( cascade(
self.context.shared.stylist.device(), self.context.shared.stylist.device(),
rules.unwrap_or(self.context.shared.stylist.rule_tree().root()), rules.unwrap_or(self.context.shared.stylist.rule_tree().root()),
&self.context.shared.guards, &self.context.shared.guards,
@ -497,9 +497,9 @@ where
&self.context.thread_local.font_metrics_provider, &self.context.thread_local.font_metrics_provider,
cascade_flags, cascade_flags,
self.context.shared.quirks_mode self.context.shared.quirks_mode
)); );
cascade_info.finish(&self.element.as_node()); cascade_info.finish(&self.element.as_node());
values values.to_outer()
} }
} }

View file

@ -16,7 +16,7 @@ use gecko_bindings::structs::{nsIAtom, StyleRuleInclusion};
use invalidation::element::invalidation_map::InvalidationMap; use invalidation::element::invalidation_map::InvalidationMap;
use invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey}; use invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey};
use media_queries::Device; use media_queries::Device;
use properties::{self, CascadeFlags, ComputedValues}; use properties::{self, CascadeFlags, ComputedValues, ComputedValuesInner};
use properties::{AnimationRules, PropertyDeclarationBlock}; use properties::{AnimationRules, PropertyDeclarationBlock};
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use properties::INHERIT_ALL; use properties::INHERIT_ALL;
@ -599,7 +599,7 @@ impl Stylist {
pub fn precomputed_values_for_pseudo(&self, pub fn precomputed_values_for_pseudo(&self,
guards: &StylesheetGuards, guards: &StylesheetGuards,
pseudo: &PseudoElement, pseudo: &PseudoElement,
parent: Option<&Arc<ComputedValues>>, parent: Option<&ComputedValuesInner>,
cascade_flags: CascadeFlags, cascade_flags: CascadeFlags,
font_metrics: &FontMetricsProvider) font_metrics: &FontMetricsProvider)
-> Arc<ComputedValues> { -> Arc<ComputedValues> {
@ -629,18 +629,16 @@ impl Stylist {
// descendant of a display: contents element where display: contents is // descendant of a display: contents element where display: contents is
// the actual used value, and the computed value of it would need // the actual used value, and the computed value of it would need
// blockification. // blockification.
let computed = properties::cascade(&self.device,
properties::cascade(&self.device, &rule_node,
&rule_node, guards,
guards, parent,
parent.map(|p| &**p), parent,
parent.map(|p| &**p), None,
None, None,
None, font_metrics,
font_metrics, cascade_flags,
cascade_flags, self.quirks_mode).to_outer()
self.quirks_mode);
Arc::new(computed)
} }
/// Returns the style for an anonymous box of the given type. /// Returns the style for an anonymous box of the given type.
@ -648,7 +646,7 @@ impl Stylist {
pub fn style_for_anonymous(&self, pub fn style_for_anonymous(&self,
guards: &StylesheetGuards, guards: &StylesheetGuards,
pseudo: &PseudoElement, pseudo: &PseudoElement,
parent_style: &Arc<ComputedValues>) parent_style: &ComputedValuesInner)
-> Arc<ComputedValues> { -> Arc<ComputedValues> {
use font_metrics::ServoMetricsProvider; use font_metrics::ServoMetricsProvider;
@ -692,7 +690,7 @@ impl Stylist {
element: &E, element: &E,
pseudo: &PseudoElement, pseudo: &PseudoElement,
rule_inclusion: RuleInclusion, rule_inclusion: RuleInclusion,
parent_style: &Arc<ComputedValues>, parent_style: &ComputedValuesInner,
is_probe: bool, is_probe: bool,
font_metrics: &FontMetricsProvider) font_metrics: &FontMetricsProvider)
-> Option<Arc<ComputedValues>> -> Option<Arc<ComputedValues>>
@ -713,7 +711,7 @@ impl Stylist {
pub fn compute_pseudo_element_style_with_inputs(&self, pub fn compute_pseudo_element_style_with_inputs(&self,
inputs: &CascadeInputs, inputs: &CascadeInputs,
guards: &StylesheetGuards, guards: &StylesheetGuards,
parent_style: &Arc<ComputedValues>, parent_style: &ComputedValuesInner,
font_metrics: &FontMetricsProvider) font_metrics: &FontMetricsProvider)
-> Option<Arc<ComputedValues>> -> Option<Arc<ComputedValues>>
{ {
@ -736,7 +734,7 @@ impl Stylist {
// We want to use the visited bits (if any) from our parent style as // We want to use the visited bits (if any) from our parent style as
// our parent. // our parent.
let inherited_style = 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 // FIXME(emilio): The lack of layout_parent_style here could be
// worrying, but we're probably dropping the display fixup for // worrying, but we're probably dropping the display fixup for
@ -753,9 +751,9 @@ impl Stylist {
None, None,
font_metrics, font_metrics,
CascadeFlags::empty(), CascadeFlags::empty(),
self.quirks_mode); self.quirks_mode).to_outer();
Some(Arc::new(computed)) Some(computed)
} else { } else {
None None
}; };
@ -768,19 +766,16 @@ impl Stylist {
// difficult to assert that display: contents nodes never arrive here // difficult to assert that display: contents nodes never arrive here
// (tl;dr: It doesn't apply for replaced elements and such, but the // (tl;dr: It doesn't apply for replaced elements and such, but the
// computed value is still "contents"). // computed value is still "contents").
let computed = Some(properties::cascade(&self.device,
properties::cascade(&self.device, rules,
rules, guards,
guards, Some(parent_style),
Some(parent_style), Some(parent_style),
Some(parent_style), visited_values,
visited_values, None,
None, font_metrics,
font_metrics, CascadeFlags::empty(),
CascadeFlags::empty(), self.quirks_mode).to_outer())
self.quirks_mode);
Some(Arc::new(computed))
} }
/// Computes the cascade inputs for a lazily-cascaded pseudo-element. /// 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. /// Computes styles for a given declaration with parent_style.
pub fn compute_for_declarations(&self, pub fn compute_for_declarations(&self,
guards: &StylesheetGuards, guards: &StylesheetGuards,
parent_style: &Arc<ComputedValues>, parent_style: &ComputedValuesInner,
declarations: Arc<Locked<PropertyDeclarationBlock>>) declarations: Arc<Locked<PropertyDeclarationBlock>>)
-> Arc<ComputedValues> { -> Arc<ComputedValues> {
use font_metrics::get_metrics_provider_for_product; use font_metrics::get_metrics_provider_for_product;
@ -1333,16 +1328,16 @@ impl Stylist {
// font styles in <canvas> via Servo_StyleSet_ResolveForDeclarations. // font styles in <canvas> via Servo_StyleSet_ResolveForDeclarations.
// It is unclear if visited styles are meaningful for this case. // It is unclear if visited styles are meaningful for this case.
let metrics = get_metrics_provider_for_product(); let metrics = get_metrics_provider_for_product();
Arc::new(properties::cascade(&self.device, properties::cascade(&self.device,
&rule_node, &rule_node,
guards, guards,
Some(parent_style), Some(parent_style),
Some(parent_style), Some(parent_style),
None, None,
None, None,
&metrics, &metrics,
CascadeFlags::empty(), CascadeFlags::empty(),
self.quirks_mode)) self.quirks_mode).to_outer()
} }
/// Accessor for a shared reference to the device. /// Accessor for a shared reference to the device.

View file

@ -484,8 +484,8 @@ where
let primary_style = let primary_style =
StyleResolverForElement::new(*ancestor, context, rule_inclusion) StyleResolverForElement::new(*ancestor, context, rule_inclusion)
.resolve_primary_style( .resolve_primary_style(
style.as_ref().map(|s| &**s), style.as_ref().map(|s| &***s),
layout_parent_style.as_ref().map(|s| &**s) layout_parent_style.as_ref().map(|s| &***s)
); );
let is_display_contents = primary_style.style.is_display_contents(); let is_display_contents = primary_style.style.is_display_contents();
@ -501,8 +501,8 @@ where
context.thread_local.bloom_filter.assert_complete(element); context.thread_local.bloom_filter.assert_complete(element);
StyleResolverForElement::new(element, context, rule_inclusion) StyleResolverForElement::new(element, context, rule_inclusion)
.resolve_style( .resolve_style(
style.as_ref().map(|s| &**s), style.as_ref().map(|s| &***s),
layout_parent_style.as_ref().map(|s| &**s) layout_parent_style.as_ref().map(|s| &***s)
) )
} }

View file

@ -11,7 +11,7 @@ use font_metrics::FontMetricsProvider;
use media_queries::Device; use media_queries::Device;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use properties; use properties;
use properties::{ComputedValues, StyleBuilder}; use properties::{ComputedValuesInner, StyleBuilder};
use std::f32; use std::f32;
use std::f64; use std::f64;
use std::f64::consts::PI; use std::f64::consts::PI;
@ -72,13 +72,13 @@ pub struct Context<'a> {
pub device: &'a Device, pub device: &'a Device,
/// The style we're inheriting from. /// 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 /// The style of the layout parent node. This will almost always be
/// `inherited_style`, except when `display: contents` is at play, in which /// `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 /// case it's the style of the last ancestor with a `display` value that
/// isn't `contents`. /// 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 /// Values accessed through this need to be in the properties "computed
/// early": color, text-decoration, font-size, display, position, float, /// early": color, text-decoration, font-size, display, position, float,
@ -115,7 +115,7 @@ impl<'a> Context<'a> {
/// The current viewport size. /// The current viewport size.
pub fn viewport_size(&self) -> Size2D<Au> { self.device.au_viewport_size() } pub fn viewport_size(&self) -> Size2D<Au> { self.device.au_viewport_size() }
/// The style we're inheriting from. /// 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 /// The current style. Note that only "eager" properties should be accessed
/// from here, see the comment in the member. /// from here, see the comment in the member.
pub fn style(&self) -> &StyleBuilder { &self.style } pub fn style(&self) -> &StyleBuilder { &self.style }

View file

@ -1514,7 +1514,8 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
.expect("Not an anon box pseudo?"); .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 cascade_flags = SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
let metrics = get_metrics_provider_for_product(); let metrics = get_metrics_provider_for_product();
data.stylist.precomputed_values_for_pseudo(&guards, &pseudo, maybe_parent, 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 { return if is_probe {
Strong::null() Strong::null()
} else { } 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(|| { Some(style.unwrap_or_else(|| {
Arc::new(StyleBuilder::for_inheritance( StyleBuilder::for_inheritance(
styles.primary(), styles.primary(),
doc_data.default_computed_values(), doc_data.default_computed_values(),
).build()) ).build().to_outer()
})) }))
} }
@ -1702,20 +1703,20 @@ pub extern "C" fn Servo_ComputedValues_Inherit(
.adjust_for_text(); .adjust_for_text();
} }
Arc::new(style.build()) style.build()
} else { } else {
debug_assert!(!for_text); debug_assert!(!for_text);
data.default_computed_values().clone() data.default_computed_values().clone()
}; };
style.into_strong() style.to_outer().into_strong()
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_ComputedValues_GetVisitedStyle(values: ServoComputedValuesBorrowed) pub extern "C" fn Servo_ComputedValues_GetVisitedStyle(values: ServoComputedValuesBorrowed)
-> ServoComputedValuesStrong { -> ServoComputedValuesStrong {
match ComputedValues::as_arc(&values).get_visited_style() { match ComputedValues::as_arc(&values).clone_visited_style() {
Some(v) => v.clone().into_strong(), Some(v) => v.into_strong(),
None => Strong::null(), None => Strong::null(),
} }
} }
@ -2870,12 +2871,13 @@ fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
parent_style: &'a Option<&Arc<ComputedValues>>) parent_style: &'a Option<&Arc<ComputedValues>>)
-> Context<'a> { -> Context<'a> {
let default_values = per_doc_data.default_computed_values(); let default_values = per_doc_data.default_computed_values();
let inherited_style = parent_style.map(|x| &x.inner).unwrap_or(default_values);
Context { Context {
is_root_element: false, is_root_element: false,
device: per_doc_data.stylist.device(), device: per_doc_data.stylist.device(),
inherited_style: parent_style.unwrap_or(default_values), inherited_style: inherited_style,
layout_parent_style: parent_style.unwrap_or(default_values), layout_parent_style: inherited_style,
style: StyleBuilder::for_derived_style(&style), style: StyleBuilder::for_derived_style(&style),
font_metrics_provider: font_metrics_provider, font_metrics_provider: font_metrics_provider,
cached_system_font: None, cached_system_font: None,
@ -3264,7 +3266,7 @@ pub extern "C" fn Servo_StyleSet_ResolveForDeclarations(
let guards = StylesheetGuards::same(&guard); let guards = StylesheetGuards::same(&guard);
let parent_style = match ComputedValues::arc_from_borrowed(&parent_style_or_null) { 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(), None => doc_data.default_computed_values(),
}; };