--- a/servo/components/layout/block.rs
+++ b/servo/components/layout/block.rs
@@ -51,17 +51,17 @@ use serde::{Serialize, Serializer};
use servo_geometry::max_rect;
use std::cmp::{max, min};
use std::fmt;
use std::sync::Arc;
use style::computed_values::{border_collapse, box_sizing, display, float, overflow_x};
use style::computed_values::{position, text_align};
use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION};
use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage};
use style::values::computed::LengthOrPercentageOrAuto;
/// Information specific to floated blocks.
#[derive(Clone, Serialize)]
pub struct FloatedBlockInfo {
/// The amount of inline size that is available for the float.
@@ -2134,17 +2134,17 @@ impl Flow for BlockFlow {
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.collect_stacking_contexts_for_block(state);
}
fn build_display_list(&mut self, state: &mut DisplayListBuildState) {
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)
}
fn compute_overflow(&self) -> Overflow {
let flow_size = self.base.position.size.to_physical(self.base.writing_mode);
let overflow = self.fragment.compute_overflow(&flow_size,
&self.base
.early_absolute_position_info
--- a/servo/components/layout/construct.rs
+++ b/servo/components/layout/construct.rs
@@ -47,17 +47,17 @@ use std::marker::PhantomData;
use std::mem;
use std::sync::Arc;
use std::sync::atomic::Ordering;
use style::computed_values::{caption_side, display, empty_cells, float, list_style_position};
use style::computed_values::content::ContentItem;
use style::computed_values::position;
use style::context::SharedStyleContext;
use style::logical_geometry::Direction;
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::properties::longhands::list_style_image;
use style::selector_parser::{PseudoElement, RestyleDamage};
use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW};
use style::values::Either;
use table::TableFlow;
use table_caption::TableCaptionFlow;
use table_cell::TableCellFlow;
use table_colgroup::TableColGroupFlow;
@@ -104,17 +104,17 @@ impl ConstructionResult {
/// Represents the output of flow construction for a DOM node that has not yet resulted in a
/// complete flow. Construction items bubble up the tree until they find a `Flow` to be attached
/// to.
#[derive(Clone)]
pub enum ConstructionItem {
/// Inline fragments and associated {ib} splits that have not yet found flows.
InlineFragments(InlineFragmentsConstructionResult),
/// Potentially ignorable whitespace.
- Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ServoComputedValues>, RestyleDamage),
+ Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ComputedValues>, RestyleDamage),
/// TableColumn Fragment
TableColumnFragment(Fragment),
}
/// Represents inline fragments and {ib} splits that are bubbling up from an inline.
#[derive(Clone)]
pub struct InlineFragmentsConstructionResult {
/// Any {ib} splits that we're bubbling up.
@@ -672,17 +672,17 @@ impl<'a, ConcreteThreadSafeLayoutNode: T
}
self.build_flow_for_block_starting_with_fragments(flow, node, fragments)
}
/// Pushes fragments appropriate for the content of the given node onto the given list.
fn create_fragments_for_node_text_content(&self,
fragments: &mut IntermediateInlineFragments,
node: &ConcreteThreadSafeLayoutNode,
- style: &StyleArc<ServoComputedValues>) {
+ style: &StyleArc<ComputedValues>) {
// Fast path: If there is no text content, return immediately.
let text_content = node.text_content();
if text_content.is_empty() {
return
}
let style = (*style).clone();
let selected_style = node.selected_style();
@@ -1801,17 +1801,17 @@ pub fn strip_ignorable_whitespace_from_e
}
}
}
this.append(&mut trailing_fragments_consisting_of_solely_bidi_control_characters);
}
/// If the 'unicode-bidi' property has a value other than 'normal', return the bidi control codes
/// to inject before and after the text content of the element.
-fn bidi_control_chars(style: &StyleArc<ServoComputedValues>) -> Option<(&'static str, &'static str)> {
+fn bidi_control_chars(style: &StyleArc<ComputedValues>) -> Option<(&'static str, &'static str)> {
use style::computed_values::direction::T::*;
use style::computed_values::unicode_bidi::T::*;
let unicode_bidi = style.get_text().unicode_bidi;
let direction = style.get_inheritedbox().direction;
// See the table in http://dev.w3.org/csswg/css-writing-modes/#unicode-bidi
match (unicode_bidi, direction) {
@@ -1846,17 +1846,17 @@ fn control_chars_to_fragment(node: &Inli
}
/// Convenience methods for computed CSS values
trait ComputedValueUtils {
/// Returns true if this node has non-zero padding or border.
fn has_padding_or_border(&self) -> bool;
}
-impl ComputedValueUtils for ServoComputedValues {
+impl ComputedValueUtils for ComputedValues {
fn has_padding_or_border(&self) -> bool {
let padding = self.get_padding();
let border = self.get_border();
!padding.padding_top.is_definitely_zero() ||
!padding.padding_right.is_definitely_zero() ||
!padding.padding_bottom.is_definitely_zero() ||
!padding.padding_left.is_definitely_zero() ||
--- a/servo/components/layout/display_list_builder.rs
+++ b/servo/components/layout/display_list_builder.rs
@@ -46,17 +46,17 @@ use std::{cmp, f32};
use std::collections::HashMap;
use std::default::Default;
use std::mem;
use std::sync::Arc;
use style::computed_values::{background_attachment, background_clip, background_origin};
use style::computed_values::{background_repeat, border_style, cursor};
use style::computed_values::{image_rendering, overflow_x, pointer_events, position, visibility};
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
-use style::properties::{self, ServoComputedValues};
+use style::properties::{self, ComputedValues};
use style::properties::longhands::border_image_repeat::computed_value::RepeatKeyword;
use style::properties::style_structs;
use style::servo::restyle_damage::REPAINT;
use style::values::{Either, RGBA};
use style::values::computed::{Angle, Gradient, GradientItem, LengthOrPercentage};
use style::values::computed::{LengthOrPercentageOrAuto, NumberOrPercentage, Position};
use style::values::computed::effects::SimpleShadow;
use style::values::computed::image::{EndingShape, LineDirection};
@@ -371,55 +371,55 @@ pub enum IdType {
CSSClip,
}
pub trait FragmentDisplayListBuilding {
/// Adds the display items necessary to paint the background of this fragment to the display
/// list if necessary.
fn build_display_list_for_background_if_applicable(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>);
/// Computes the background size for an image with the given background area according to the
/// rules in CSS-BACKGROUNDS ยง 3.9.
fn compute_background_image_size(&self,
- style: &ServoComputedValues,
+ style: &ComputedValues,
bounds: &Rect<Au>,
image: &WebRenderImageInfo, index: usize)
-> Size2D<Au>;
/// Adds the display items necessary to paint the background image of this fragment to the
/// appropriate section of the display list.
fn build_display_list_for_background_image(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>,
clip: &LocalClip,
image_url: &ServoUrl,
background_index: usize);
/// Adds the display items necessary to paint a webrender image of this fragment to the
/// appropriate section of the display list.
fn build_display_list_for_webrender_image(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>,
clip: &LocalClip,
webrender_image: WebRenderImageInfo,
index: usize);
/// Adds the display items necessary to paint the background image created by this fragment's
/// worklet to the appropriate section of the display list.
fn build_display_list_for_background_paint_worklet(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>,
clip: &LocalClip,
paint_worklet: &PaintWorklet,
index: usize);
fn convert_linear_gradient(&self,
bounds: &Rect<Au>,
@@ -439,50 +439,50 @@ pub trait FragmentDisplayListBuilding {
/// Adds the display items necessary to paint the background linear gradient of this fragment
/// to the appropriate section of the display list.
fn build_display_list_for_background_gradient(&self,
state: &mut DisplayListBuildState,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>,
clip: &LocalClip,
gradient: &Gradient,
- style: &ServoComputedValues);
+ style: &ComputedValues);
/// Adds the display items necessary to paint the borders of this fragment to a display list if
/// necessary.
fn build_display_list_for_borders_if_applicable(
&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
border_painting_mode: BorderPaintingMode,
bounds: &Rect<Au>,
display_list_section: DisplayListSection,
clip: &Rect<Au>);
/// Adds the display items necessary to paint the outline of this fragment to the display list
/// if necessary.
fn build_display_list_for_outline_if_applicable(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
bounds: &Rect<Au>,
clip: &Rect<Au>);
/// Adds the display items necessary to paint the box shadow of this fragment to the display
/// list if necessary.
fn build_display_list_for_box_shadow_if_applicable(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>,
clip: &Rect<Au>);
/// Adds display items necessary to draw debug boxes around a scanned text fragment.
fn build_debug_borders_around_text_fragments(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
stacking_relative_border_box: &Rect<Au>,
stacking_relative_content_box: &Rect<Au>,
text_fragment: &ScannedTextFragmentInfo,
clip: &Rect<Au>);
/// Adds display items necessary to draw debug boxes around this fragment.
fn build_debug_borders_around_fragment(&self,
state: &mut DisplayListBuildState,
@@ -603,17 +603,17 @@ fn build_border_radius(abs_bounds: &Rect
bottom_left: model::specified_border_radius(border_style.border_bottom_left_radius,
abs_bounds.size),
})
}
/// Get the border radius for the rectangle inside of a rounded border. This is useful
/// for building the clip for the content inside the border.
fn build_border_radius_for_inner_rect(outer_rect: &Rect<Au>,
- style: &ServoComputedValues)
+ style: &ComputedValues)
-> BorderRadii<Au> {
let mut radii = build_border_radius(&outer_rect, style.get_border());
if radii.is_square() {
return radii;
}
// Since we are going to using the inner rectangle (outer rectangle minus
// border width), we need to adjust to border radius so that we are smaller
@@ -841,17 +841,17 @@ fn convert_ellipse_size_keyword(keyword:
get_ellipse_radius(size, center, ::std::cmp::max)
},
}
}
impl FragmentDisplayListBuilding for Fragment {
fn build_display_list_for_background_if_applicable(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>) {
// FIXME: This causes a lot of background colors to be displayed when they are clearly not
// needed. We could use display list optimization to clean this up, but it still seems
// inefficient. What we really want is something like "nearest ancestor element that
// doesn't have a fragment".
let background = style.get_background();
let background_color = style.resolve_color(background.background_color);
@@ -946,17 +946,17 @@ impl FragmentDisplayListBuilding for Fra
Either::Second(Image::Element(_)) => {
// TODO: Implement `-moz-element`
}
}
}
}
fn compute_background_image_size(&self,
- style: &ServoComputedValues,
+ style: &ComputedValues,
bounds: &Rect<Au>,
image: &WebRenderImageInfo,
index: usize)
-> Size2D<Au> {
// If `image_aspect_ratio` < `bounds_aspect_ratio`, the image is tall; otherwise, it is
// wide.
let image_aspect_ratio = (image.width as f64) / (image.height as f64);
let bounds_aspect_ratio = bounds.size.width.to_f64_px() / bounds.size.height.to_f64_px();
@@ -992,17 +992,17 @@ impl FragmentDisplayListBuilding for Fra
MaybeAuto::from_style(height, bounds.size.height)
.specified_or_default(intrinsic_size.height))
}
}
}
fn build_display_list_for_background_image(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>,
clip: &LocalClip,
image_url: &ServoUrl,
index: usize) {
let webrender_image = state.layout_context
.get_webrender_image_for_url(self.node,
image_url.clone(),
@@ -1016,17 +1016,17 @@ impl FragmentDisplayListBuilding for Fra
clip,
webrender_image,
index);
}
}
fn build_display_list_for_webrender_image(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>,
clip: &LocalClip,
webrender_image: WebRenderImageInfo,
index: usize) {
debug!("(building display list) building background image");
let background = style.get_background();
@@ -1153,17 +1153,17 @@ impl FragmentDisplayListBuilding for Fra
tile_spacing: tile_spacing,
image_rendering: style.get_inheritedbox().image_rendering.clone(),
}));
}
fn build_display_list_for_background_paint_worklet(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>,
clip: &LocalClip,
paint_worklet: &PaintWorklet,
index: usize)
{
// This should be the "concrete object size" of the fragment.
// https://drafts.css-houdini.org/css-paint-api/#draw-a-paint-image
@@ -1334,17 +1334,17 @@ impl FragmentDisplayListBuilding for Fra
}
fn build_display_list_for_background_gradient(&self,
state: &mut DisplayListBuildState,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>,
clip: &LocalClip,
gradient: &Gradient,
- style: &ServoComputedValues) {
+ style: &ComputedValues) {
let border = self.border_width().to_physical(style.writing_mode);
let mut bounds = *absolute_bounds;
bounds.origin.x = bounds.origin.x + border.left;
bounds.origin.y = bounds.origin.y + border.top;
bounds.size.width = bounds.size.width - border.horizontal();
bounds.size.height = bounds.size.height - border.vertical();
let base = state.create_base_display_item(&bounds,
@@ -1376,17 +1376,17 @@ impl FragmentDisplayListBuilding for Fra
})
}
};
state.add_display_item(display_item);
}
fn build_display_list_for_box_shadow_if_applicable(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: &Rect<Au>,
clip: &Rect<Au>) {
// NB: According to CSS-BACKGROUNDS, box shadows render in *reverse* order (front to back).
for box_shadow in style.get_effects().box_shadow.0.iter().rev() {
let bounds = shadow_bounds(
&absolute_bounds.translate(&Vector2D::new(
box_shadow.base.horizontal,
@@ -1419,17 +1419,17 @@ impl FragmentDisplayListBuilding for Fra
},
}));
}
}
fn build_display_list_for_borders_if_applicable(
&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
border_painting_mode: BorderPaintingMode,
bounds: &Rect<Au>,
display_list_section: DisplayListSection,
clip: &Rect<Au>) {
let mut border = style.logical_border_width();
match border_painting_mode {
BorderPaintingMode::Separate => {}
@@ -1566,17 +1566,17 @@ impl FragmentDisplayListBuilding for Fra
}
}
}
}
}
fn build_display_list_for_outline_if_applicable(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
bounds: &Rect<Au>,
clip: &Rect<Au>) {
use style::values::Either;
let width = style.get_outline().outline_width;
if width == Au(0) {
return
}
@@ -1611,17 +1611,17 @@ impl FragmentDisplayListBuilding for Fra
style: SideOffsets2D::new_all_same(outline_style),
radius: Default::default(),
}),
}));
}
fn build_debug_borders_around_text_fragments(&self,
state: &mut DisplayListBuildState,
- style: &ServoComputedValues,
+ style: &ComputedValues,
stacking_relative_border_box: &Rect<Au>,
stacking_relative_content_box: &Rect<Au>,
text_fragment: &ScannedTextFragmentInfo,
clip: &Rect<Au>) {
// FIXME(pcwalton, #2795): Get the real container size.
let container_size = Size2D::zero();
// Compute the text fragment bounds and draw a border surrounding them.
@@ -2882,22 +2882,22 @@ impl BaseFlowDisplayListBuilding for Bas
color: SideOffsets2D::new_all_same(color),
style: SideOffsets2D::new_all_same(border_style::T::solid),
radius: BorderRadii::all_same(Au(0)),
}),
}));
}
}
-trait ServoComputedValuesCursorUtility {
+trait ComputedValuesCursorUtility {
fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor>;
}
-impl ServoComputedValuesCursorUtility for ServoComputedValues {
- /// Gets the cursor to use given the specific ServoComputedValues. `default_cursor` specifies
+impl ComputedValuesCursorUtility for ComputedValues {
+ /// Gets the cursor to use given the specific ComputedValues. `default_cursor` specifies
/// the cursor to use if `cursor` is `auto`. Typically, this will be `PointerCursor`, but for
/// text display items it may be `TextCursor` or `VerticalTextCursor`.
#[inline]
fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor> {
match (self.get_pointing().pointer_events, self.get_pointing().cursor) {
(pointer_events::T::none, _) => None,
(pointer_events::T::auto, cursor::Keyword::Auto) => Some(default_cursor),
(pointer_events::T::auto, cursor::Keyword::Cursor(cursor)) => Some(cursor),
--- a/servo/components/layout/flex.rs
+++ b/servo/components/layout/flex.rs
@@ -18,17 +18,17 @@ use flow::{INLINE_POSITION_IS_STATIC, IS
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use layout_debug;
use model::{IntrinsicISizes, MaybeAuto, SizeConstraint};
use std::cmp::{max, min};
use std::ops::Range;
use style::computed_values::{align_content, align_self, flex_direction, flex_wrap, justify_content};
use style::computed_values::border_collapse;
use style::logical_geometry::{Direction, LogicalSize};
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
use style::values::computed::flex::FlexBasis;
use style::values::generics::flex::FlexBasis as GenericFlexBasis;
/// The size of an axis. May be a specified size, a min/max
/// constraint, or an unlimited size
#[derive(Debug, Serialize)]
@@ -968,17 +968,17 @@ impl Flow for FlexFlow {
fn build_display_list(&mut self, state: &mut DisplayListBuildState) {
self.build_display_list_for_flex(state);
}
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
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)
}
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn generated_containing_block_size(&self, flow: OpaqueFlow) -> LogicalSize<Au> {
--- a/servo/components/layout/flow.rs
+++ b/servo/components/layout/flow.rs
@@ -47,17 +47,17 @@ use servo_geometry::{au_rect_to_f32_rect
use std::{fmt, mem, raw};
use std::iter::Zip;
use std::slice::IterMut;
use std::sync::Arc;
use std::sync::atomic::Ordering;
use style::computed_values::{clear, float, overflow_x, position, text_align};
use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION};
use style::values::computed::LengthOrPercentageOrAuto;
use table::TableFlow;
use table_caption::TableCaptionFlow;
use table_cell::TableCellFlow;
use table_colgroup::TableColGroupFlow;
use table_row::TableRowFlow;
@@ -419,17 +419,17 @@ pub trait Flow: fmt::Debug + Sync + Send
/// positioned descendant referenced by `for_flow`. For block flows, this is the padding box.
///
/// NB: Do not change this `&self` to `&mut self` under any circumstances! It has security
/// implications because this can be called on parents concurrently from descendants!
fn generated_containing_block_size(&self, _: OpaqueFlow) -> LogicalSize<Au>;
/// Attempts to perform incremental fixup of this flow by replacing its fragment's style with
/// the new style. This can only succeed if the flow has exactly one fragment.
- fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>);
+ fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>);
/// Print any extra children (such as fragments) contained in this Flow
/// for debugging purposes. Any items inserted into the tree will become
/// children of this flow.
fn print_extra_flow_children(&self, _: &mut PrintTree) { }
fn scroll_root_id(&self, pipeline_id: PipelineId) -> ClipId {
match base(self).scroll_root_id {
@@ -556,17 +556,17 @@ pub trait MutableFlowUtils {
/// Return true if the traversal is to continue or false to stop.
fn traverse_postorder_absolute_flows<T>(&mut self, traversal: &mut T)
where T: PostorderFlowTraversal;
// Mutators
/// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of
/// calling them individually, since there is no reason not to perform both operations.
- fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>);
+ fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ComputedValues>);
}
pub trait MutableOwnedFlowUtils {
/// Set absolute descendants for this flow.
///
/// Set this flow as the Containing Block for all the absolute descendants.
fn set_absolute_descendants(&mut self, abs_descendants: AbsoluteDescendants);
@@ -1028,17 +1028,17 @@ pub enum ForceNonfloatedFlag {
/// The flow should be floated if the node has a `float` property.
FloatIfNecessary,
/// The flow should be forced to be nonfloated.
ForceNonfloated,
}
impl BaseFlow {
#[inline]
- pub fn new(style: Option<&ServoComputedValues>,
+ pub fn new(style: Option<&ComputedValues>,
writing_mode: WritingMode,
force_nonfloated: ForceNonfloatedFlag)
-> BaseFlow {
let mut flags = FlowFlags::empty();
match style {
Some(style) => {
match style.get_box().position {
position::T::absolute | position::T::fixed => {
@@ -1376,17 +1376,17 @@ impl<'a> MutableFlowUtils for &'a mut Fl
if traversal.should_process(self) {
traversal.process(self)
}
}
/// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of
/// calling them individually, since there is no reason not to perform both operations.
- fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>) {
+ fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ComputedValues>) {
self.repair_style(style);
mut_base(self).update_flags_if_needed(style);
self.bubble_inline_sizes();
}
/// Traverse the Absolute flow tree in preorder.
///
/// Traverse all your direct absolute descendants, who will then traverse
--- a/servo/components/layout/fragment.rs
+++ b/servo/components/layout/fragment.rs
@@ -40,17 +40,17 @@ use std::borrow::ToOwned;
use std::cmp::{Ordering, max, min};
use std::collections::LinkedList;
use std::sync::{Arc, Mutex};
use style::computed_values::{border_collapse, box_sizing, clear, color, display, mix_blend_mode};
use style::computed_values::{overflow_wrap, overflow_x, position, text_decoration_line, transform};
use style::computed_values::{transform_style, vertical_align, white_space, word_break};
use style::computed_values::content::ContentItem;
use style::logical_geometry::{Direction, LogicalMargin, LogicalRect, LogicalSize, WritingMode};
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::RECONSTRUCT_FLOW;
use style::str::char_is_whitespace;
use style::values::{self, Either, Auto};
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
use text;
use text::TextRunScanner;
use wrapper::ThreadSafeLayoutNodeHelpers;
@@ -90,20 +90,20 @@ static DEFAULT_REPLACED_HEIGHT: i32 = 15
/// FIXME(#2260, pcwalton): This can be slimmed down some by (at least) moving `inline_context`
/// to be on `InlineFlow` only.
#[derive(Clone)]
pub struct Fragment {
/// An opaque reference to the DOM node that this `Fragment` originates from.
pub node: OpaqueNode,
/// The CSS style of this fragment.
- pub style: StyleArc<ServoComputedValues>,
+ pub style: StyleArc<ComputedValues>,
/// The CSS style of this fragment when it's selected
- pub selected_style: StyleArc<ServoComputedValues>,
+ pub selected_style: StyleArc<ComputedValues>,
/// The position of this fragment relative to its owning flow. The size includes padding and
/// border, but not margin.
///
/// NB: This does not account for relative positioning.
/// NB: Collapsed borders are not included in this.
pub border_box: LogicalRect<Au>,
@@ -671,18 +671,18 @@ impl Fragment {
debug_id: DebugId::new(),
stacking_context_id: StackingContextId::root(),
}
}
/// Constructs a new `Fragment` instance from an opaque node.
pub fn from_opaque_node_and_style(node: OpaqueNode,
pseudo: PseudoElementType<()>,
- style: StyleArc<ServoComputedValues>,
- selected_style: StyleArc<ServoComputedValues>,
+ style: StyleArc<ComputedValues>,
+ selected_style: StyleArc<ComputedValues>,
mut restyle_damage: RestyleDamage,
specific: SpecificFragmentInfo)
-> Fragment {
let writing_mode = style.writing_mode;
restyle_damage.remove(RECONSTRUCT_FLOW);
Fragment {
@@ -701,17 +701,17 @@ impl Fragment {
stacking_context_id: StackingContextId::root(),
}
}
/// Creates an anonymous fragment just like this one but with the given style and fragment
/// type. For the new anonymous fragment, layout-related values (border box, etc.) are reset to
/// initial values.
pub fn create_similar_anonymous_fragment(&self,
- style: StyleArc<ServoComputedValues>,
+ style: StyleArc<ComputedValues>,
specific: SpecificFragmentInfo)
-> Fragment {
let writing_mode = style.writing_mode;
Fragment {
node: self.node,
style: style,
selected_style: self.selected_style.clone(),
restyle_damage: self.restyle_damage,
@@ -1334,17 +1334,17 @@ impl Fragment {
}
};
self.border_padding = border + padding_from_style + padding_from_inline_fragment_context
}
// Return offset from original position because of `position: relative`.
pub fn relative_position(&self, containing_block_size: &LogicalSize<Au>) -> LogicalSize<Au> {
- fn from_style(style: &ServoComputedValues, container_size: &LogicalSize<Au>)
+ fn from_style(style: &ComputedValues, container_size: &LogicalSize<Au>)
-> LogicalSize<Au> {
let offsets = style.logical_position();
let offset_i = if offsets.inline_start != LengthOrPercentageOrAuto::Auto {
MaybeAuto::from_style(offsets.inline_start,
container_size.inline).specified_or_zero()
} else {
-MaybeAuto::from_style(offsets.inline_end,
container_size.inline).specified_or_zero()
@@ -1387,22 +1387,22 @@ impl Fragment {
clear::T::none => None,
clear::T::left => Some(ClearType::Left),
clear::T::right => Some(ClearType::Right),
clear::T::both => Some(ClearType::Both),
}
}
#[inline(always)]
- pub fn style(&self) -> &ServoComputedValues {
+ pub fn style(&self) -> &ComputedValues {
&*self.style
}
#[inline(always)]
- pub fn selected_style(&self) -> &ServoComputedValues {
+ pub fn selected_style(&self) -> &ComputedValues {
&*self.selected_style
}
pub fn white_space(&self) -> white_space::T {
self.style().get_inheritedtext().white_space
}
pub fn color(&self) -> color::T {
@@ -2137,17 +2137,17 @@ impl Fragment {
SpecificFragmentInfo::Multicol |
SpecificFragmentInfo::MulticolColumn |
SpecificFragmentInfo::UnscannedText(_) => {
unreachable!("Shouldn't see fragments of this type here!")
}
};
return inline_metrics;
- fn inline_metrics_of_block(flow: &FlowRef, style: &ServoComputedValues) -> InlineMetrics {
+ fn inline_metrics_of_block(flow: &FlowRef, style: &ComputedValues) -> InlineMetrics {
// CSS 2.1 ยง 10.8: "The height of each inline-level box in the line box is calculated.
// For replaced elements, inline-block elements, and inline-table elements, this is the
// height of their margin box."
//
// CSS 2.1 ยง 10.8.1: "The baseline of an 'inline-block' is the baseline of its last
// line box in the normal flow, unless it has either no in-flow line boxes or if its
// 'overflow' property has a computed value other than 'visible', in which case the
// baseline is the bottom margin edge."
@@ -2418,17 +2418,17 @@ impl Fragment {
pub fn update_late_computed_block_position_if_necessary(&mut self) {
if let SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) = self.specific {
let position = self.border_box.start.b;
FlowRef::deref_mut(&mut info.flow_ref)
.update_late_computed_block_position_if_necessary(position)
}
}
- 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()
}
/// Given the stacking-context-relative position of the containing flow, returns the border box
/// of this fragment relative to the parent stacking context. This takes `position: relative`
/// into account.
///
/// If `coordinate_system` is `Parent`, this returns the border box in the parent stacking
@@ -3033,19 +3033,19 @@ pub enum CoordinateSystem {
pub struct InlineStyleIterator<'a> {
fragment: &'a Fragment,
inline_style_index: usize,
primary_style_yielded: bool,
}
impl<'a> Iterator for InlineStyleIterator<'a> {
- type Item = &'a ServoComputedValues;
+ type Item = &'a ComputedValues;
- fn next(&mut self) -> Option<&'a ServoComputedValues> {
+ fn next(&mut self) -> Option<&'a ComputedValues> {
if !self.primary_style_yielded {
self.primary_style_yielded = true;
return Some(&*self.fragment.style)
}
let inline_context = match self.fragment.inline_context {
None => return None,
Some(ref inline_context) => inline_context,
};
--- a/servo/components/layout/generated_content.rs
+++ b/servo/components/layout/generated_content.rs
@@ -13,17 +13,17 @@ use flow::{self, AFFECTS_COUNTERS, Flow,
use flow::InorderFlowTraversal;
use fragment::{Fragment, GeneratedContentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
use gfx::display_list::OpaqueNode;
use script_layout_interface::wrapper_traits::PseudoElementType;
use smallvec::SmallVec;
use std::collections::{HashMap, LinkedList};
use style::computed_values::{display, list_style_type};
use style::computed_values::content::ContentItem;
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
use text::TextRunScanner;
// Decimal styles per CSS-COUNTER-STYLES ยง 6.1:
static DECIMAL: [char; 10] = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ];
// TODO(pcwalton): `decimal-leading-zero`
static ARABIC_INDIC: [char; 10] = [ 'ู ', 'ูก', 'ูข', 'ูฃ', 'ูค', 'ูฅ', 'ูฆ', 'ูง', 'ูจ', 'ูฉ' ];
@@ -293,17 +293,17 @@ impl<'a,'b> ResolveGeneratedContentFragm
let mut counter = Counter::new();
counter.increment(self.level, value);
self.traversal.counters.insert(counter_name.to_owned(), counter);
}
self.incremented = true
}
- fn quote(&self, style: &ServoComputedValues, close: bool) -> String {
+ fn quote(&self, style: &ComputedValues, close: bool) -> String {
let quotes = &style.get_list().quotes;
if quotes.0.is_empty() {
return String::new()
}
let &(ref open_quote, ref close_quote) =
if self.traversal.quote as usize >= quotes.0.len() {
quotes.0.last().unwrap()
} else {
@@ -363,17 +363,17 @@ impl Counter {
value: amount,
})
}
fn render(&self,
layout_context: &LayoutContext,
node: OpaqueNode,
pseudo: PseudoElementType<()>,
- style: ::StyleArc<ServoComputedValues>,
+ style: ::StyleArc<ComputedValues>,
list_style_type: list_style_type::T,
mode: RenderingMode)
-> Option<SpecificFragmentInfo> {
let mut string = String::new();
match mode {
RenderingMode::Plain => {
let value = match self.values.last() {
Some(ref value) => value.value,
@@ -426,17 +426,17 @@ struct CounterValue {
/// The value of the counter at this level.
value: i32,
}
/// Creates fragment info for a literal string.
fn render_text(layout_context: &LayoutContext,
node: OpaqueNode,
pseudo: PseudoElementType<()>,
- style: ::StyleArc<ServoComputedValues>,
+ style: ::StyleArc<ComputedValues>,
string: String)
-> Option<SpecificFragmentInfo> {
let mut fragments = LinkedList::new();
let info = SpecificFragmentInfo::UnscannedText(
box UnscannedTextFragmentInfo::new(string, None));
fragments.push_back(Fragment::from_opaque_node_and_style(node,
pseudo,
style.clone(),
--- a/servo/components/layout/inline.rs
+++ b/servo/components/layout/inline.rs
@@ -28,17 +28,17 @@ use range::{Range, RangeIndex};
use script_layout_interface::wrapper_traits::PseudoElementType;
use std::{fmt, i32, isize, mem};
use std::cmp::max;
use std::collections::VecDeque;
use std::sync::Arc;
use style::computed_values::{display, overflow_x, position, text_align, text_justify};
use style::computed_values::{vertical_align, white_space};
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
-use style::properties::{longhands, ServoComputedValues};
+use style::properties::{longhands, ComputedValues};
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION, RESOLVE_GENERATED_CONTENT};
use text;
use unicode_bidi as bidi;
/// `Line`s are represented as offsets into the child list, rather than
/// as an object that "owns" fragments. Choosing a different set of line
/// breaks requires a new list of offsets, and possibly some splitting and
/// merging of TextFragments.
@@ -1101,30 +1101,30 @@ impl InlineFlow {
fragment.update_late_computed_block_position_if_necessary();
}
}
/// Computes the minimum metrics for each line. This is done during flow construction.
///
/// `style` is the style of the block.
- pub fn minimum_line_metrics(&self, font_context: &mut FontContext, style: &ServoComputedValues)
+ pub fn minimum_line_metrics(&self, font_context: &mut FontContext, style: &ComputedValues)
-> LineMetrics {
InlineFlow::minimum_line_metrics_for_fragments(&self.fragments.fragments,
font_context,
style)
}
/// Computes the minimum line metrics for the given fragments. This is typically done during
/// flow construction.
///
/// `style` is the style of the block that these fragments belong to.
pub fn minimum_line_metrics_for_fragments(fragments: &[Fragment],
font_context: &mut FontContext,
- style: &ServoComputedValues)
+ style: &ComputedValues)
-> LineMetrics {
// As a special case, if this flow contains only hypothetical fragments, then the entire
// flow is hypothetical and takes up no space. See CSS 2.1 ยง 10.3.7.
if fragments.iter().all(Fragment::is_hypothetical) {
return LineMetrics::new(Au(0), Au(0))
}
let font_style = style.clone_font();
@@ -1660,17 +1660,17 @@ impl Flow for InlineFlow {
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.collect_stacking_contexts_for_inline(state);
}
fn build_display_list(&mut self, state: &mut DisplayListBuildState) {
self.build_display_list_for_inline(state);
}
- fn repair_style(&mut self, _: &StyleArc<ServoComputedValues>) {}
+ fn repair_style(&mut self, _: &StyleArc<ComputedValues>) {}
fn compute_overflow(&self) -> Overflow {
let mut overflow = Overflow::new();
let flow_size = self.base.position.size.to_physical(self.base.writing_mode);
let relative_containing_block_size =
&self.base.early_absolute_position_info.relative_containing_block_size;
for fragment in &self.fragments.fragments {
overflow.union(&fragment.compute_overflow(&flow_size, &relative_containing_block_size))
@@ -1749,18 +1749,18 @@ impl fmt::Debug for InlineFlow {
self.base.debug_id(),
flow::base(self))
}
}
#[derive(Clone)]
pub struct InlineFragmentNodeInfo {
pub address: OpaqueNode,
- pub style: StyleArc<ServoComputedValues>,
- pub selected_style: StyleArc<ServoComputedValues>,
+ pub style: StyleArc<ComputedValues>,
+ pub selected_style: StyleArc<ComputedValues>,
pub pseudo: PseudoElementType<()>,
pub flags: InlineFragmentNodeFlags,
}
bitflags! {
pub flags InlineFragmentNodeFlags: u8 {
const FIRST_FRAGMENT_OF_ELEMENT = 0x01,
const LAST_FRAGMENT_OF_ELEMENT = 0x02,
--- a/servo/components/layout/list_item.rs
+++ b/servo/components/layout/list_item.rs
@@ -15,17 +15,17 @@ use euclid::Point2D;
use floats::FloatKind;
use flow::{Flow, FlowClass, OpaqueFlow};
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedContentInfo};
use fragment::Overflow;
use generated_content;
use inline::InlineFlow;
use style::computed_values::{list_style_type, position};
use style::logical_geometry::LogicalSize;
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
/// A block with the CSS `display` property equal to `list-item`.
#[derive(Debug)]
pub struct ListItemFlow {
/// Data common to all block flows.
pub block_flow: BlockFlow,
/// The marker, if outside. (Markers that are inside are instead just fragments on the interior
@@ -142,17 +142,17 @@ impl Flow for ListItemFlow {
fn build_display_list(&mut self, state: &mut DisplayListBuildState) {
self.build_display_list_for_list_item(state);
}
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
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)
}
fn compute_overflow(&self) -> Overflow {
let mut overflow = self.block_flow.compute_overflow();
let flow_size = self.block_flow.base.position.size.to_physical(self.block_flow.base.writing_mode);
let relative_containing_block_size =
&self.block_flow.base.early_absolute_position_info.relative_containing_block_size;
--- a/servo/components/layout/model.rs
+++ b/servo/components/layout/model.rs
@@ -8,17 +8,17 @@
use app_units::Au;
use euclid::{Transform3D, SideOffsets2D, Size2D};
use fragment::Fragment;
use std::cmp::{max, min};
use std::fmt;
use style::computed_values::transform::ComputedMatrix;
use style::logical_geometry::{LogicalMargin, WritingMode};
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::values::computed::{BorderCornerRadius, LengthOrPercentageOrAuto};
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone};
/// A collapsible margin. See CSS 2.1 ยง 8.3.1.
#[derive(Copy, Clone, Debug)]
pub struct AdjoiningMargins {
/// The value of the greatest positive margin.
pub most_positive: Au,
@@ -476,34 +476,34 @@ pub fn specified_border_radius(
-> Size2D<Au>
{
let w = radius.0.width.to_used_value(containing_size.width);
let h = radius.0.height.to_used_value(containing_size.height);
Size2D::new(w, h)
}
#[inline]
-pub fn padding_from_style(style: &ServoComputedValues,
+pub fn padding_from_style(style: &ComputedValues,
containing_block_inline_size: Au,
writing_mode: WritingMode)
-> LogicalMargin<Au> {
let padding_style = style.get_padding();
LogicalMargin::from_physical(writing_mode, SideOffsets2D::new(
padding_style.padding_top.to_used_value(containing_block_inline_size),
padding_style.padding_right.to_used_value(containing_block_inline_size),
padding_style.padding_bottom.to_used_value(containing_block_inline_size),
padding_style.padding_left.to_used_value(containing_block_inline_size)))
}
/// Returns the explicitly-specified margin lengths from the given style. Percentage and auto
/// margins are returned as zero.
///
/// This is used when calculating intrinsic inline sizes.
#[inline]
-pub fn specified_margin_from_style(style: &ServoComputedValues,
+pub fn specified_margin_from_style(style: &ComputedValues,
writing_mode: WritingMode) -> LogicalMargin<Au> {
let margin_style = style.get_margin();
LogicalMargin::from_physical(writing_mode, SideOffsets2D::new(
MaybeAuto::from_style(margin_style.margin_top, Au(0)).specified_or_zero(),
MaybeAuto::from_style(margin_style.margin_right, Au(0)).specified_or_zero(),
MaybeAuto::from_style(margin_style.margin_bottom, Au(0)).specified_or_zero(),
MaybeAuto::from_style(margin_style.margin_left, Au(0)).specified_or_zero()))
}
--- a/servo/components/layout/multicol.rs
+++ b/servo/components/layout/multicol.rs
@@ -15,17 +15,17 @@ use euclid::{Point2D, Vector2D};
use floats::FloatKind;
use flow::{Flow, FlowClass, OpaqueFlow, mut_base, FragmentationContext};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx_traits::print_tree::PrintTree;
use std::cmp::{min, max};
use std::fmt;
use std::sync::Arc;
use style::logical_geometry::LogicalSize;
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::values::Either;
use style::values::computed::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
pub struct MulticolFlow {
pub block_flow: BlockFlow,
/// Length between the inline-start edge of a column and that of the next.
/// That is, the used column-width + used column-gap.
@@ -188,17 +188,17 @@ impl Flow for MulticolFlow {
debug!("build_display_list_multicol");
self.block_flow.build_display_list(state);
}
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
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)
}
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn generated_containing_block_size(&self, flow: OpaqueFlow) -> LogicalSize<Au> {
@@ -270,17 +270,17 @@ impl Flow for MulticolColumnFlow {
debug!("build_display_list_multicol column");
self.block_flow.build_display_list(state);
}
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
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)
}
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn generated_containing_block_size(&self, flow: OpaqueFlow) -> LogicalSize<Au> {
--- a/servo/components/layout/table.rs
+++ b/servo/components/layout/table.rs
@@ -19,17 +19,17 @@ use fragment::{Fragment, FragmentBorderB
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto};
use std::cmp;
use std::fmt;
use style::computed_values::{border_collapse, border_spacing, table_layout};
use style::context::SharedStyleContext;
use style::logical_geometry::LogicalSize;
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::CSSFloat;
use style::values::computed::LengthOrPercentageOrAuto;
use table_row::{self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderProvenance};
use table_row::TableRowFlow;
use table_wrapper::TableLayout;
/// A table flow corresponded to the table's internal table fragment under a table wrapper flow.
@@ -501,17 +501,17 @@ impl Flow for TableFlow {
self.block_flow.build_display_list_for_block(state, border_painting_mode);
}
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
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)
}
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn iterate_through_fragment_border_boxes(&self,
--- a/servo/components/layout/table_caption.rs
+++ b/servo/components/layout/table_caption.rs
@@ -11,17 +11,17 @@ use block::BlockFlow;
use context::LayoutContext;
use display_list_builder::DisplayListBuildState;
use euclid::Point2D;
use flow::{Flow, FlowClass, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx_traits::print_tree::PrintTree;
use std::fmt;
use style::logical_geometry::LogicalSize;
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
/// A table formatting context.
pub struct TableCaptionFlow {
pub block_flow: BlockFlow,
}
impl TableCaptionFlow {
pub fn from_fragment(fragment: Fragment) -> TableCaptionFlow {
@@ -78,17 +78,17 @@ impl Flow for TableCaptionFlow {
debug!("build_display_list_table_caption: same process as block flow");
self.block_flow.build_display_list(state);
}
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
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)
}
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn generated_containing_block_size(&self, flow: OpaqueFlow) -> LogicalSize<Au> {
--- a/servo/components/layout/table_cell.rs
+++ b/servo/components/layout/table_cell.rs
@@ -15,17 +15,17 @@ use flow::{self, Flow, FlowClass, IS_ABS
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::MaybeAuto;
use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode;
use std::fmt;
use style::computed_values::{border_collapse, border_top_style, vertical_align};
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::values::computed::Color;
use table::InternalTable;
use table_row::{CollapsedBorder, CollapsedBorderProvenance};
/// A table formatting context.
#[derive(Serialize)]
pub struct TableCellFlow {
/// Data common to all block flows.
@@ -258,17 +258,17 @@ impl Flow for TableCellFlow {
self.block_flow.build_display_list_for_block(state, border_painting_mode)
}
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
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)
}
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn generated_containing_block_size(&self, flow: OpaqueFlow) -> LogicalSize<Au> {
--- a/servo/components/layout/table_colgroup.rs
+++ b/servo/components/layout/table_colgroup.rs
@@ -11,17 +11,17 @@ use context::LayoutContext;
use display_list_builder::DisplayListBuildState;
use euclid::Point2D;
use flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow, SpecificFragmentInfo};
use layout_debug;
use std::cmp::max;
use std::fmt;
use style::logical_geometry::LogicalSize;
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::values::computed::LengthOrPercentageOrAuto;
/// A table formatting context.
pub struct TableColGroupFlow {
/// Data common to all flows.
pub base: BaseFlow,
/// The associated fragment.
@@ -89,17 +89,17 @@ impl Flow for TableColGroupFlow {
fn update_late_computed_block_position_if_necessary(&mut self, _: Au) {}
// Table columns are invisible.
fn build_display_list(&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 {
Overflow::new()
}
fn generated_containing_block_size(&self, _: OpaqueFlow) -> LogicalSize<Au> {
panic!("Table column groups can't be containing blocks!")
}
--- a/servo/components/layout/table_row.rs
+++ b/servo/components/layout/table_row.rs
@@ -18,17 +18,17 @@ use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::MaybeAuto;
use serde::{Serialize, Serializer};
use std::cmp::max;
use std::fmt;
use std::iter::{Enumerate, IntoIterator, Peekable};
use style::computed_values::{border_collapse, border_spacing, border_top_style};
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::computed::{Color, LengthOrPercentageOrAuto};
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
use table_cell::{CollapsedBordersForCell, TableCellFlow};
/// A single row of a table.
pub struct TableRowFlow {
/// Fields common to all block flows.
@@ -476,17 +476,17 @@ impl Flow for TableRowFlow {
self.block_flow.build_display_list_for_block(state, border_painting_mode);
}
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
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)
}
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn generated_containing_block_size(&self, flow: OpaqueFlow) -> LogicalSize<Au> {
@@ -607,105 +607,105 @@ impl CollapsedBorder {
width: Au(0),
color: Color::transparent(),
provenance: CollapsedBorderProvenance::FromTable,
}
}
/// Creates a collapsed border from the block-start border described in the given CSS style
/// object.
- fn top(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
+ fn top(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_top_style,
width: css_style.get_border().border_top_width,
color: css_style.get_border().border_top_color,
provenance: provenance,
}
}
/// Creates a collapsed border style from the right border described in the given CSS style
/// object.
- fn right(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
+ fn right(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_right_style,
width: css_style.get_border().border_right_width,
color: css_style.get_border().border_right_color,
provenance: provenance,
}
}
/// Creates a collapsed border style from the bottom border described in the given CSS style
/// object.
- fn bottom(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
+ fn bottom(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_bottom_style,
width: css_style.get_border().border_bottom_width,
color: css_style.get_border().border_bottom_color,
provenance: provenance,
}
}
/// Creates a collapsed border style from the left border described in the given CSS style
/// object.
- fn left(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
+ fn left(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_left_style,
width: css_style.get_border().border_left_width,
color: css_style.get_border().border_left_color,
provenance: provenance,
}
}
/// Creates a collapsed border style from the given physical side.
fn from_side(side: PhysicalSide,
- css_style: &ServoComputedValues,
+ css_style: &ComputedValues,
provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
match side {
PhysicalSide::Top => CollapsedBorder::top(css_style, provenance),
PhysicalSide::Right => CollapsedBorder::right(css_style, provenance),
PhysicalSide::Bottom => CollapsedBorder::bottom(css_style, provenance),
PhysicalSide::Left => CollapsedBorder::left(css_style, provenance),
}
}
/// Creates a collapsed border style from the inline-start border described in the given CSS
/// style object.
- pub fn inline_start(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
+ pub fn inline_start(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
CollapsedBorder::from_side(css_style.writing_mode.inline_start_physical_side(),
css_style,
provenance)
}
/// Creates a collapsed border style from the inline-start border described in the given CSS
/// style object.
- pub fn inline_end(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
+ pub fn inline_end(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
CollapsedBorder::from_side(css_style.writing_mode.inline_end_physical_side(),
css_style,
provenance)
}
/// Creates a collapsed border style from the block-start border described in the given CSS
/// style object.
- pub fn block_start(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
+ pub fn block_start(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
CollapsedBorder::from_side(css_style.writing_mode.block_start_physical_side(),
css_style,
provenance)
}
/// Creates a collapsed border style from the block-end border described in the given CSS style
/// object.
- pub fn block_end(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
+ pub fn block_end(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
CollapsedBorder::from_side(css_style.writing_mode.block_end_physical_side(),
css_style,
provenance)
}
/// If `other` has a higher priority per CSS 2.1 ยง 17.6.2.1, replaces `self` with it.
pub fn combine(&mut self, other: &CollapsedBorder) {
@@ -904,17 +904,17 @@ pub struct BorderCollapseInfoForChildTab
collapsed_border_spacing_for_row: &'a CollapsedBorderSpacingForRow,
}
/// Performs border-collapse in the inline direction for all the cells' inside borders in the
/// inline-direction cells and propagates the outside borders (the far left and right) up to the
/// table row. This is done eagerly here so that at least the inline inside border collapse
/// computations can be parallelized across all the rows of the table.
fn perform_inline_direction_border_collapse_for_row(
- row_style: &ServoComputedValues,
+ row_style: &ComputedValues,
children_count: usize,
child_index: usize,
child_table_cell: &mut TableCellFlow,
iterator: &mut Peekable<Enumerate<MutFlowListIterator>>,
preliminary_collapsed_borders: &mut CollapsedBordersForRow) {
// In the first cell, combine its border with the one coming from the row.
if child_index == 0 {
let first_inline_border = &mut preliminary_collapsed_borders.inline[0];
--- a/servo/components/layout/table_rowgroup.rs
+++ b/servo/components/layout/table_rowgroup.rs
@@ -15,17 +15,17 @@ use flow::{Flow, FlowClass, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use serde::{Serialize, Serializer};
use std::fmt;
use std::iter::{IntoIterator, Iterator, Peekable};
use style::computed_values::{border_collapse, border_spacing};
use style::logical_geometry::LogicalSize;
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use table::{ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow};
/// A table formatting context.
pub struct TableRowGroupFlow {
/// Fields common to all block flows.
pub block_flow: BlockFlow,
/// Information about the intrinsic inline-sizes of each column.
@@ -180,17 +180,17 @@ impl Flow for TableRowGroupFlow {
debug!("build_display_list_table_rowgroup: same process as block flow");
self.block_flow.build_display_list(state);
}
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
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)
}
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn generated_containing_block_size(&self, flow: OpaqueFlow) -> LogicalSize<Au> {
--- a/servo/components/layout/table_wrapper.rs
+++ b/servo/components/layout/table_wrapper.rs
@@ -25,17 +25,17 @@ use fragment::{Fragment, FragmentBorderB
use gfx_traits::print_tree::PrintTree;
use model::MaybeAuto;
use std::cmp::{max, min};
use std::fmt;
use std::ops::Add;
use style::computed_values::{border_collapse, position, table_layout};
use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalRect, LogicalSize};
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::values::CSSFloat;
use style::values::computed::LengthOrPercentageOrAuto;
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize};
#[derive(Copy, Clone, Serialize, Debug)]
pub enum TableLayout {
Fixed,
Auto
@@ -461,17 +461,17 @@ impl Flow for TableWrapperFlow {
fn build_display_list(&mut self, state: &mut DisplayListBuildState) {
self.block_flow.build_display_list(state);
}
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
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)
}
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn iterate_through_fragment_border_boxes(&self,
--- a/servo/components/layout/text.rs
+++ b/servo/components/layout/text.rs
@@ -21,17 +21,17 @@ use ordered_float::NotNaN;
use range::Range;
use std::borrow::ToOwned;
use std::collections::LinkedList;
use std::mem;
use std::sync::Arc;
use style::computed_values::{text_rendering, text_transform};
use style::computed_values::{word_break, white_space};
use style::logical_geometry::{LogicalSize, WritingMode};
-use style::properties::ServoComputedValues;
+use style::properties::ComputedValues;
use style::properties::style_structs;
use style::values::generics::text::LineHeight;
use unicode_bidi as bidi;
use unicode_script::{Script, get_script};
/// Returns the concatenated text of a list of unscanned text fragments.
fn text(fragments: &LinkedList<Fragment>) -> String {
// FIXME: Some of this work is later duplicated in split_first_fragment_at_newline_if_necessary
@@ -440,17 +440,17 @@ pub fn font_metrics_for_style(font_conte
-> FontMetrics {
let fontgroup = font_context.layout_font_group_for_style(font_style);
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let font = fontgroup.fonts[0].borrow();
font.metrics.clone()
}
/// Returns the line block-size needed by the given computed style and font size.
-pub fn line_height_from_style(style: &ServoComputedValues, metrics: &FontMetrics) -> Au {
+pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) -> Au {
let font_size = style.get_font().font_size;
match style.get_inheritedtext().line_height {
LineHeight::Normal => metrics.line_gap,
LineHeight::Number(l) => font_size.scale_by(l),
LineHeight::Length(l) => l
}
}
--- a/servo/components/script_layout_interface/wrapper_traits.rs
+++ b/servo/components/script_layout_interface/wrapper_traits.rs
@@ -17,17 +17,17 @@ use servo_url::ServoUrl;
use std::fmt::Debug;
use style::attr::AttrValue;
use style::computed_values::display;
use style::context::SharedStyleContext;
use style::data::ElementData;
use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthesizer, TNode};
use style::dom::OpaqueNode;
use style::font_metrics::ServoMetricsProvider;
-use style::properties::{CascadeFlags, ServoComputedValues};
+use style::properties::{CascadeFlags, ComputedValues};
use style::selector_parser::{PseudoElement, PseudoElementCascadeType, SelectorImpl};
use style::stylearc::Arc;
use style::stylist::RuleInclusion;
use webrender_api::ClipId;
#[derive(Copy, PartialEq, Clone, Debug)]
pub enum PseudoElementType<T> {
Normal,
@@ -175,17 +175,17 @@ pub trait ThreadSafeLayoutNode: Clone +
/// Returns the style for a text node. This is computed on the fly from the
/// parent style to avoid traversing text nodes in the style system.
///
/// Note that this does require accessing the parent, which this interface
/// technically forbids. But accessing the parent is only unsafe insofar as
/// it can be used to reach siblings and cousins. A simple immutable borrow
/// of the parent data is fine, since the bottom-up traversal will not process
/// the parent until all the children have been processed.
- fn parent_style(&self) -> Arc<ServoComputedValues>;
+ fn parent_style(&self) -> Arc<ComputedValues>;
#[inline]
fn is_element_or_elements_pseudo(&self) -> bool {
match self.type_id_without_excluding_pseudo_elements() {
LayoutNodeType::Element(..) => true,
_ => false,
}
}
@@ -217,28 +217,28 @@ pub trait ThreadSafeLayoutNode: Clone +
#[inline]
fn get_pseudo_element_type(&self) -> PseudoElementType<Option<display::T>> {
self.as_element().map_or(PseudoElementType::Normal, |el| el.get_pseudo_element_type())
}
fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData>;
- fn style(&self, context: &SharedStyleContext) -> Arc<ServoComputedValues> {
+ fn style(&self, context: &SharedStyleContext) -> Arc<ComputedValues> {
if let Some(el) = self.as_element() {
el.style(context)
} else {
// Text nodes are not styled during traversal,instead we simply
// return parent style here and do cascading during layout.
debug_assert!(self.is_text_node());
self.parent_style()
}
}
- fn selected_style(&self) -> Arc<ServoComputedValues> {
+ fn selected_style(&self) -> Arc<ComputedValues> {
if let Some(el) = self.as_element() {
el.selected_style()
} else {
debug_assert!(self.is_text_node());
// TODO(stshine): What should the selected style be for text?
self.parent_style()
}
}
@@ -387,17 +387,17 @@ pub trait ThreadSafeLayoutElement: Clone
}
}
/// Returns the style results for the given node. If CSS selector matching
/// has not yet been performed, fails.
///
/// Unlike the version on TNode, this handles pseudo-elements.
#[inline]
- fn style(&self, context: &SharedStyleContext) -> Arc<ServoComputedValues> {
+ fn style(&self, context: &SharedStyleContext) -> Arc<ComputedValues> {
let data = self.style_data();
match self.get_pseudo_element_type() {
PseudoElementType::Normal => {
data.styles.primary().clone()
},
other => {
// Precompute non-eagerly-cascaded pseudo-element styles if not
// cached before.
@@ -432,33 +432,33 @@ pub trait ThreadSafeLayoutElement: Clone
.clone()
}
}
}
}
}
#[inline]
- fn selected_style(&self) -> Arc<ServoComputedValues> {
+ fn selected_style(&self) -> Arc<ComputedValues> {
let data = self.style_data();
data.styles.pseudos
.get(&PseudoElement::Selection).map(|s| s)
.unwrap_or(data.styles.primary())
.clone()
}
/// Returns the already resolved style of the node.
///
/// This differs from `style(ctx)` in that if the pseudo-element has not yet
/// been computed it would panic.
///
/// This should be used just for querying layout, or when we know the
/// element style is precomputed, not from general layout itself.
#[inline]
- fn resolved_style(&self) -> Arc<ServoComputedValues> {
+ fn resolved_style(&self) -> Arc<ComputedValues> {
let data = self.style_data();
match self.get_pseudo_element_type() {
PseudoElementType::Normal
=> data.styles.primary().clone(),
other
=> data.styles.pseudos
.get(&other.style_pseudo_element()).unwrap().clone(),
}
--- a/servo/components/style/animation.rs
+++ b/servo/components/style/animation.rs
@@ -6,17 +6,17 @@
#![deny(missing_docs)]
use Atom;
use bezier::Bezier;
use context::SharedStyleContext;
use dom::OpaqueNode;
use euclid::Point2D;
use font_metrics::FontMetricsProvider;
-use properties::{self, CascadeFlags, ComputedValues, Importance};
+use properties::{self, CascadeFlags, ComputedValues, ComputedValuesInner, Importance};
use properties::animated_properties::{AnimatableLonghand, AnimatedProperty, TransitionProperty};
use properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection;
use properties::longhands::animation_iteration_count::single_value::computed_value::T as AnimationIterationCount;
use properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState;
use rule_tree::CascadeLevel;
use std::sync::mpsc::Sender;
use stylearc::Arc;
use stylesheets::keyframes_rule::{KeyframesStep, KeyframesStepValue};
@@ -342,18 +342,18 @@ impl PropertyAnimation {
duration,
old_style,
new_style)
}
fn from_animatable_longhand(animatable_longhand: &AnimatableLonghand,
timing_function: TimingFunction,
duration: Time,
- old_style: &ComputedValues,
- new_style: &ComputedValues)
+ old_style: &ComputedValuesInner,
+ new_style: &ComputedValuesInner)
-> Option<PropertyAnimation> {
let animated_property = AnimatedProperty::from_animatable_longhand(animatable_longhand,
old_style,
new_style);
let property_animation = PropertyAnimation {
property: animated_property,
timing_function: timing_function,
@@ -475,20 +475,20 @@ pub fn start_transitions_if_applicable(n
}
}
had_animations
}
fn compute_style_for_animation_step(context: &SharedStyleContext,
step: &KeyframesStep,
- previous_style: &ComputedValues,
- style_from_cascade: &ComputedValues,
+ previous_style: &ComputedValuesInner,
+ style_from_cascade: &ComputedValuesInner,
font_metrics_provider: &FontMetricsProvider)
- -> ComputedValues {
+ -> ComputedValuesInner {
match step.value {
KeyframesStepValue::ComputedValues => style_from_cascade.clone(),
KeyframesStepValue::Declarations { block: ref declarations } => {
let guard = declarations.read_with(context.guards.author);
// No !important in keyframes.
debug_assert!(guard.declarations().iter()
.all(|&(_, importance)| importance == Importance::Normal));
--- a/servo/components/style/dom.rs
+++ b/servo/components/style/dom.rs
@@ -10,17 +10,17 @@
use {Atom, Namespace, LocalName};
use applicable_declarations::ApplicableDeclarationBlock;
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
#[cfg(feature = "gecko")] use context::UpdateAnimationsTasks;
use data::ElementData;
use element_state::ElementState;
use font_metrics::FontMetricsProvider;
use media_queries::Device;
-use properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock};
+use properties::{AnimationRules, ComputedValues, ComputedValuesInner, PropertyDeclarationBlock};
#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValue;
#[cfg(feature = "gecko")] use properties::animated_properties::TransitionProperty;
use rule_tree::CascadeLevel;
use selector_parser::{AttrValue, ElementExt, PreExistingComputedValues};
use selector_parser::{PseudoClassStringArg, PseudoElement};
use selectors::matching::{ElementSelectorFlags, VisitedHandlingMode};
use selectors::sink::Push;
use shared_lock::Locked;
@@ -431,17 +431,17 @@ pub trait TElement : Eq + PartialEq + De
///
/// This is useful to avoid computing, for example, pseudo styles for
/// `::-first-line` or `::-first-letter`, when we know it won't affect us.
///
/// TODO(emilio, bz): actually implement the logic for it.
fn may_generate_pseudo(
&self,
pseudo: &PseudoElement,
- _primary_style: &ComputedValues,
+ _primary_style: &ComputedValuesInner,
) -> bool {
// ::before/::after are always supported for now, though we could try to
// optimize out leaf elements.
// ::first-letter and ::first-line are only supported for block-inside
// things, and only in Gecko, not Servo. Unfortunately, Gecko has
// block-inside things that might have any computed display value due to
// things like fieldsets, legends, etc. Need to figure out how this
--- a/servo/components/style/gecko/data.rs
+++ b/servo/components/style/gecko/data.rs
@@ -11,17 +11,17 @@ use fnv::FnvHashMap;
use gecko::rules::{CounterStyleRule, FontFaceRule};
use gecko_bindings::bindings::{self, RawServoStyleSet};
use gecko_bindings::structs::{ServoStyleSheet, StyleSheetInfo, ServoStyleSheetInner};
use gecko_bindings::structs::RawGeckoPresContextOwned;
use gecko_bindings::structs::nsIDocument;
use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
use invalidation::media_queries::{MediaListKey, ToMediaListKey};
use media_queries::{Device, MediaList};
-use properties::ComputedValues;
+use properties::ComputedValuesInner;
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
use stylearc::Arc;
use stylesheet_set::StylesheetSet;
use stylesheets::{Origin, StylesheetContents, StylesheetInDocument};
use stylist::{ExtraStyleData, Stylist};
/// Little wrapper to a Gecko style sheet.
#[derive(PartialEq, Eq, Debug)]
@@ -183,18 +183,18 @@ impl PerDocumentStyleDataImpl {
/* ua_sheets = */ None,
/* stylesheets_changed = */ true,
author_style_disabled,
&mut extra_data
);
}
/// Get the default computed values for this document.
- pub fn default_computed_values(&self) -> &Arc<ComputedValues> {
- self.stylist.device().default_computed_values_arc()
+ pub fn default_computed_values(&self) -> &ComputedValuesInner {
+ self.stylist.device().default_computed_values()
}
/// Clear the stylist. This will be a no-op if the stylist is
/// already cleared; the stylist handles that.
pub fn clear_stylist(&mut self) {
self.stylist.clear();
}
}
--- a/servo/components/style/gecko/media_queries.rs
+++ b/servo/components/style/gecko/media_queries.rs
@@ -12,37 +12,36 @@ use font_metrics::get_metrics_provider_f
use gecko::values::convert_nscolor_to_rgba;
use gecko_bindings::bindings;
use gecko_bindings::structs::{nsCSSKeyword, nsCSSProps_KTableEntry, nsCSSValue, nsCSSUnit, nsStringBuffer};
use gecko_bindings::structs::{nsMediaExpression_Range, nsMediaFeature};
use gecko_bindings::structs::{nsMediaFeature_ValueType, nsMediaFeature_RangeType, nsMediaFeature_RequirementFlags};
use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextOwned};
use media_queries::MediaType;
use parser::ParserContext;
-use properties::{ComputedValues, StyleBuilder};
+use properties::{ComputedValuesInner, StyleBuilder};
use properties::longhands::font_size;
use selectors::parser::SelectorParseError;
use std::fmt::{self, Write};
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering};
use str::starts_with_ignore_ascii_case;
use string_cache::Atom;
use style_traits::{ToCss, ParseError, StyleParseError};
use style_traits::viewport::ViewportConstraints;
-use stylearc::Arc;
use values::{CSSFloat, specified};
use values::computed::{self, ToComputedValue};
/// The `Device` in Gecko wraps a pres context, has a default values computed,
/// and contains all the viewport rule state.
pub struct Device {
/// NB: The pres context lifetime is tied to the styleset, who owns the
/// stylist, and thus the `Device`, so having a raw pres context pointer
/// here is fine.
pres_context: RawGeckoPresContextOwned,
- default_values: Arc<ComputedValues>,
+ default_values: ComputedValuesInner,
viewport_override: Option<ViewportConstraints>,
/// The font size of the root element
/// This is set when computing the style of the root
/// element, and used for rem units in other elements.
///
/// When computing the style of the root element, there can't be any
/// other style being computed at the same time, given we need the style of
/// the parent to compute everything else. So it is correct to just use
@@ -57,45 +56,33 @@ unsafe impl Sync for Device {}
unsafe impl Send for Device {}
impl Device {
/// Trivially constructs a new `Device`.
pub fn new(pres_context: RawGeckoPresContextOwned) -> Self {
assert!(!pres_context.is_null());
Device {
pres_context: pres_context,
- default_values: ComputedValues::default_values(unsafe { &*pres_context }),
+ default_values: ComputedValuesInner::default_values(unsafe { &*pres_context }),
viewport_override: None,
root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious?
used_root_font_size: AtomicBool::new(false),
}
}
/// Tells the device that a new viewport rule has been found, and stores the
/// relevant viewport constraints.
pub fn account_for_viewport_rule(&mut self,
constraints: &ViewportConstraints) {
self.viewport_override = Some(constraints.clone());
}
/// Returns the default computed values as a reference, in order to match
/// Servo.
- pub fn default_computed_values(&self) -> &ComputedValues {
- &*self.default_values
- }
-
- /// Returns the default computed values, but wrapped in an arc for cheap
- /// cloning.
- pub fn default_computed_values_arc(&self) -> &Arc<ComputedValues> {
- &self.default_values
- }
-
- /// Returns the default computed values as an `Arc`, in order to avoid
- /// clones.
- pub fn default_values_arc(&self) -> &Arc<ComputedValues> {
+ pub fn default_computed_values(&self) -> &ComputedValuesInner {
&self.default_values
}
/// Get the font size of the root element (for rem)
pub fn root_font_size(&self) -> Au {
self.used_root_font_size.store(true, Ordering::Relaxed);
Au::new(self.root_font_size.load(Ordering::Relaxed) as i32)
}
@@ -109,17 +96,17 @@ impl Device {
pub fn pres_context(&self) -> &nsPresContext {
unsafe { &*self.pres_context }
}
/// Recreates the default computed values.
pub fn reset_computed_values(&mut self) {
// NB: A following stylesheet flush will populate this if appropriate.
self.viewport_override = None;
- self.default_values = ComputedValues::default_values(self.pres_context());
+ self.default_values = ComputedValuesInner::default_values(self.pres_context());
self.used_root_font_size.store(false, Ordering::Relaxed);
}
/// Returns whether we ever looked up the root font size of the Device.
pub fn used_root_font_size(&self) -> bool {
self.used_root_font_size.load(Ordering::Relaxed)
}
--- a/servo/components/style/properties/declaration_block.rs
+++ b/servo/components/style/properties/declaration_block.rs
@@ -105,23 +105,23 @@ impl<'a> Iterator for PropertyDeclaratio
self.iter.next().map(get_declaration as fn(_) -> _)
}
}
/// Iterator for AnimationValue to be generated from PropertyDeclarationBlock.
pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
iter: Iter<'a, (PropertyDeclaration, Importance)>,
context: &'cx mut Context<'cx_a>,
- default_values: &'a Arc<ComputedValues>,
+ default_values: &'a ComputedValuesInner,
}
impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
fn new(declarations: &'a PropertyDeclarationBlock,
context: &'cx mut Context<'cx_a>,
- default_values: &'a Arc<ComputedValues>) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
+ default_values: &'a ComputedValuesInner) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
AnimationValueIterator {
iter: declarations.declarations().iter(),
context: context,
default_values: default_values,
}
}
}
@@ -199,17 +199,17 @@ impl PropertyDeclarationBlock {
PropertyDeclarationIterator {
iter: self.declarations.iter(),
}
}
/// Return an iterator of (AnimatableLonghand, AnimationValue).
pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self,
context: &'cx mut Context<'cx_a>,
- default_values: &'a Arc<ComputedValues>)
+ default_values: &'a ComputedValuesInner)
-> AnimationValueIterator<'a, 'cx, 'cx_a> {
AnimationValueIterator::new(self, context, default_values)
}
/// Returns whether this block contains any declaration with `!important`.
///
/// This is based on the `important_count` counter,
/// which should be maintained whenever `declarations` is changed.
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -92,56 +92,55 @@ impl Clone for ComputedValuesInner {
font_computation_data: self.font_computation_data.clone(),
flags: self.flags.clone(),
rules: self.rules.clone(),
visited_style: self.visited_style.clone(),
}
}
}
-impl ComputedValues {
+impl ComputedValuesInner {
pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>,
writing_mode: WritingMode,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
flags: ComputedValueFlags,
rules: Option<StrongRuleNode>,
visited_style: Option<Arc<ComputedValues>>,
% for style_struct in data.style_structs:
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
% endfor
) -> Self {
- ComputedValues {
- inner: ComputedValuesInner {
- custom_properties: custom_properties,
- writing_mode: writing_mode,
- font_computation_data: FontComputationData::new(font_size_keyword),
- rules: rules,
- visited_style: visited_style,
- flags: flags,
- % for style_struct in data.style_structs:
- ${style_struct.gecko_name}: Arc::into_raw_offset(${style_struct.ident}),
- % endfor
- }
+ ComputedValuesInner {
+ custom_properties: custom_properties,
+ writing_mode: writing_mode,
+ font_computation_data: FontComputationData::new(font_size_keyword),
+ rules: rules,
+ visited_style: visited_style,
+ flags: flags,
+ % for style_struct in data.style_structs:
+ ${style_struct.gecko_name}: Arc::into_raw_offset(${style_struct.ident}),
+ % endfor
}
}
- pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
- Arc::new(ComputedValues {
- inner: ComputedValuesInner {
+ pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Self {
+ ComputedValuesInner {
custom_properties: None,
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
font_computation_data: FontComputationData::default_values(),
rules: None,
visited_style: None,
flags: ComputedValueFlags::empty(),
% for style_struct in data.style_structs:
${style_struct.gecko_name}: Arc::into_raw_offset(style_structs::${style_struct.name}::default(pres_context)),
% endfor
- }
- })
+ }
+ }
+ pub fn to_outer(self) -> Arc<ComputedValues> {
+ Arc::new(ComputedValues {inner: self})
}
}
impl ops::Deref for ComputedValues {
type Target = ComputedValuesInner;
fn deref(&self) -> &ComputedValuesInner {
&self.inner
}
@@ -193,22 +192,22 @@ impl ComputedValuesInner {
}
/// Whether there is a visited style.
pub fn has_visited_style(&self) -> bool {
self.visited_style.is_some()
}
/// Gets a reference to the visited style, if any.
- pub fn get_visited_style(&self) -> Option<<&Arc<ComputedValues>> {
- self.visited_style.as_ref()
+ pub fn get_visited_style(&self) -> Option< & ComputedValuesInner> {
+ self.visited_style.as_ref().map(|x| &***x)
}
/// Gets a reference to the visited style. Panic if no visited style exists.
- pub fn visited_style(&self) -> &Arc<ComputedValues> {
+ pub fn visited_style(&self) -> &ComputedValuesInner {
self.get_visited_style().unwrap()
}
/// Clone the visited style. Used for inheriting parent styles in
/// StyleBuilder::for_inheritance.
pub fn clone_visited_style(&self) -> Option<Arc<ComputedValues>> {
self.visited_style.clone()
}
--- a/servo/components/style/properties/helpers.mako.rs
+++ b/servo/components/style/properties/helpers.mako.rs
@@ -287,17 +287,17 @@
use cascade_info::CascadeInfo;
#[allow(unused_imports)]
use error_reporting::ParseErrorReporter;
#[allow(unused_imports)]
use properties::longhands;
#[allow(unused_imports)]
use properties::{DeclaredValue, LonghandId, LonghandIdSet};
#[allow(unused_imports)]
- use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration};
+ use properties::{CSSWideKeyword, ComputedValuesInner, PropertyDeclaration};
#[allow(unused_imports)]
use properties::style_structs;
#[allow(unused_imports)]
use selectors::parser::SelectorParseError;
#[allow(unused_imports)]
use stylearc::Arc;
#[allow(unused_imports)]
use style_traits::{ParseError, StyleParseError};
@@ -305,18 +305,18 @@
use values::computed::{Context, ToComputedValue};
#[allow(unused_imports)]
use values::{computed, generics, specified};
#[allow(unused_imports)]
use Atom;
${caller.body()}
#[allow(unused_variables)]
pub fn cascade_property(declaration: &PropertyDeclaration,
- inherited_style: &ComputedValues,
- default_style: &ComputedValues,
+ inherited_style: &ComputedValuesInner,
+ default_style: &ComputedValuesInner,
context: &mut computed::Context,
cacheable: &mut bool,
cascade_info: &mut Option<<&mut CascadeInfo>) {
let value = match *declaration {
PropertyDeclaration::${property.camel_case}(ref value) => {
DeclaredValue::Value(value)
},
PropertyDeclaration::CSSWideKeyword(id, value) => {
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -24,17 +24,17 @@ use properties::longhands::transform::co
use properties::longhands::vertical_align::computed_value::T as VerticalAlign;
use properties::longhands::visibility::computed_value::T as Visibility;
#[cfg(feature = "gecko")] use properties::{PropertyDeclarationId, LonghandId};
use selectors::parser::SelectorParseError;
use smallvec::SmallVec;
use std::cmp;
#[cfg(feature = "gecko")] use fnv::FnvHashMap;
use style_traits::ParseError;
-use super::ComputedValues;
+use super::ComputedValuesInner;
#[cfg(any(feature = "gecko", feature = "testing"))]
use values::Auto;
use values::{CSSFloat, CustomIdent, Either};
use values::animated::ToAnimatedValue;
use values::animated::effects::BoxShadowList as AnimatedBoxShadowList;
use values::animated::effects::Filter as AnimatedFilter;
use values::animated::effects::FilterList as AnimatedFilterList;
use values::animated::effects::TextShadowList as AnimatedTextShadowList;
@@ -390,17 +390,17 @@ impl AnimatedProperty {
% endif
% endfor
_ => false,
}
}
/// Update `style` with the proper computed style corresponding to this
/// animation at `progress`.
- pub fn update(&self, style: &mut ComputedValues, progress: f64) {
+ pub fn update(&self, style: &mut ComputedValuesInner, progress: f64) {
match *self {
% for prop in data.longhands:
% if prop.animatable:
AnimatedProperty::${prop.camel_case}(ref from, ref to) => {
// https://w3c.github.io/web-animations/#discrete-animation-type
% if prop.animation_value_type == "discrete":
let value = if progress < 0.5 { from.clone() } else { to.clone() };
% else:
@@ -423,18 +423,18 @@ impl AnimatedProperty {
% endif
% endfor
}
}
/// Get an animatable value from a transition-property, an old style, and a
/// new style.
pub fn from_animatable_longhand(property: &AnimatableLonghand,
- old_style: &ComputedValues,
- new_style: &ComputedValues)
+ old_style: &ComputedValuesInner,
+ new_style: &ComputedValuesInner)
-> AnimatedProperty {
match *property {
% for prop in data.longhands:
% if prop.animatable:
AnimatableLonghand::${prop.camel_case} => {
let old_computed = old_style.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}();
let new_computed = new_style.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}();
AnimatedProperty::${prop.camel_case}(
@@ -517,17 +517,17 @@ impl AnimationValue {
}
% endif
% endfor
}
}
/// Construct an AnimationValue from a property declaration
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
- initial: &ComputedValues) -> Option<Self> {
+ initial: &ComputedValuesInner) -> Option<Self> {
use properties::LonghandId;
match *decl {
% for prop in data.longhands:
% if prop.animatable:
PropertyDeclaration::${prop.camel_case}(ref val) => {
% if prop.ident in SYSTEM_FONT_LONGHANDS and product == "gecko":
if let Some(sf) = val.get_system() {
@@ -589,17 +589,17 @@ impl AnimationValue {
AnimationValue::from_declaration(&substituted, context, initial)
},
_ => None // non animatable properties will get included because of shorthands. ignore.
}
}
/// Get an AnimationValue for an AnimatableLonghand from a given computed values.
pub fn from_computed_values(property: &AnimatableLonghand,
- computed_values: &ComputedValues)
+ computed_values: &ComputedValuesInner)
-> Self {
match *property {
% for prop in data.longhands:
% if prop.animatable:
AnimatableLonghand::${prop.camel_case} => {
let computed = computed_values
.get_${prop.style_struct.ident.strip("_")}()
.clone_${prop.ident}();
--- a/servo/components/style/properties/longhand/box.mako.rs
+++ b/servo/components/style/properties/longhand/box.mako.rs
@@ -176,17 +176,17 @@
% endfor
}
}
impl ComputedValueAsSpecified for SpecifiedValue {}
% if product == "servo":
fn cascade_property_custom(_declaration: &PropertyDeclaration,
- _inherited_style: &ComputedValues,
+ _inherited_style: &ComputedValuesInner,
context: &mut computed::Context,
_cacheable: &mut bool) {
longhands::_servo_display_for_hypothetical_box::derive_from_display(context);
longhands::_servo_text_decorations_in_effect::derive_from_display(context);
longhands::_servo_under_display_none::derive_from_display(context);
}
% endif
--- a/servo/components/style/properties/longhand/text.mako.rs
+++ b/servo/components/style/properties/longhand/text.mako.rs
@@ -244,17 +244,17 @@
}
}
if !empty { Ok(result) } else { Err(StyleParseError::UnspecifiedError.into()) }
}
% if product == "servo":
fn cascade_property_custom(_declaration: &PropertyDeclaration,
- _inherited_style: &ComputedValues,
+ _inherited_style: &ComputedValuesInner,
context: &mut computed::Context,
_cacheable: &mut bool) {
longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context);
}
% endif
#[cfg(feature = "gecko")]
impl_bitflags_conversions!(SpecifiedValue);
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -1867,16 +1867,18 @@ pub mod style_structs {
}
% endif
% endfor
% endfor
#[cfg(feature = "gecko")]
pub use gecko_properties::ComputedValues;
+#[cfg(feature = "gecko")]
+pub use gecko_properties::ComputedValuesInner;
#[cfg(feature = "servo")]
#[cfg_attr(feature = "servo", derive(Clone, Debug))]
/// Actual data of ComputedValues, to match up with Gecko
pub struct ComputedValuesInner {
% for style_struct in data.active_style_structs():
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
@@ -1915,42 +1917,40 @@ pub struct ComputedValues {
/// In Gecko the outer ComputedValues is actually a style context,
/// whereas ComputedValuesInner is the core set of computed values.
///
/// We maintain this distinction in servo to reduce the amount of special casing.
pub inner: ComputedValuesInner,
}
#[cfg(feature = "servo")]
-impl ComputedValues {
+impl ComputedValuesInner {
/// Construct a `ComputedValues` instance.
pub fn new(
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
writing_mode: WritingMode,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
flags: ComputedValueFlags,
rules: Option<StrongRuleNode>,
visited_style: Option<Arc<ComputedValues>>,
% for style_struct in data.active_style_structs():
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
% endfor
) -> Self {
let font_computation_data = FontComputationData::new(font_size_keyword);
- ComputedValues {
- inner: ComputedValuesInner {
- custom_properties: custom_properties,
- writing_mode: writing_mode,
- font_computation_data: FontComputationData::new(font_size_keyword),
- rules: rules,
- visited_style: visited_style,
- flags: flags,
- % for style_struct in data.active_style_structs():
- ${style_struct.ident}: ${style_struct.ident},
- % endfor
- }
+ ComputedValuesInner {
+ custom_properties: custom_properties,
+ writing_mode: writing_mode,
+ font_computation_data: FontComputationData::new(font_size_keyword),
+ rules: rules,
+ visited_style: visited_style,
+ flags: flags,
+ % for style_struct in data.active_style_structs():
+ ${style_struct.ident}: ${style_struct.ident},
+ % endfor
}
}
/// Get the initial computed values.
pub fn initial_values() -> &'static Self { &*INITIAL_SERVO_VALUES }
}
#[cfg(feature = "servo")]
@@ -1965,16 +1965,21 @@ impl ops::Deref for ComputedValues {
impl ops::DerefMut for ComputedValues {
fn deref_mut(&mut self) -> &mut ComputedValuesInner {
&mut self.inner
}
}
#[cfg(feature = "servo")]
impl ComputedValuesInner {
+ /// Convert to an Arc<ComputedValues>
+ pub fn to_outer(self) -> Arc<ComputedValues> {
+ Arc::new(ComputedValues {inner: self})
+ }
+
% for style_struct in data.active_style_structs():
/// Clone the ${style_struct.name} struct.
#[inline]
pub fn clone_${style_struct.name_lower}(&self) -> Arc<style_structs::${style_struct.name}> {
self.${style_struct.ident}.clone()
}
/// Get a immutable reference to the ${style_struct.name} struct.
@@ -2002,23 +2007,23 @@ impl ComputedValuesInner {
}
/// Whether there is a visited style.
pub fn has_visited_style(&self) -> bool {
self.visited_style.is_some()
}
/// Gets a reference to the visited style, if any.
- pub fn get_visited_style(&self) -> Option<<&Arc<ComputedValues>> {
- self.visited_style.as_ref()
+ pub fn get_visited_style(&self) -> Option< & ComputedValuesInner> {
+ self.visited_style.as_ref().map(|x| &**x)
}
/// Gets a reference to the visited style. Panic if no visited style exists.
- pub fn visited_style(&self) -> &Arc<ComputedValues> {
- self.get_visited_style().unwrap()
+ pub fn visited_style(&self) -> &ComputedValuesInner {
+ self.get_visited_style().as_ref().map(|x| &**x).unwrap()
}
/// Clone the visited style. Used for inheriting parent styles in
/// StyleBuilder::for_inheritance.
pub fn clone_visited_style(&self) -> Option<Arc<ComputedValues>> {
self.visited_style.clone()
}
@@ -2437,18 +2442,18 @@ pub struct StyleBuilder<'a> {
% for style_struct in data.active_style_structs():
${style_struct.ident}: StyleStructRef<'a, style_structs::${style_struct.name}>,
% endfor
}
impl<'a> StyleBuilder<'a> {
/// Trivially construct a `StyleBuilder`.
fn new(
- inherited_style: &'a ComputedValues,
- reset_style: &'a ComputedValues,
+ inherited_style: &'a ComputedValuesInner,
+ reset_style: &'a ComputedValuesInner,
rules: Option<StrongRuleNode>,
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
writing_mode: WritingMode,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
flags: ComputedValueFlags,
visited_style: Option<Arc<ComputedValues>>,
) -> Self {
StyleBuilder {
@@ -2465,25 +2470,25 @@ impl<'a> StyleBuilder<'a> {
${style_struct.ident}: StyleStructRef::Borrowed(reset_style.${style_struct.name_lower}_arc()),
% endif
% endfor
}
}
/// Creates a StyleBuilder holding only references to the structs of `s`, in
/// order to create a derived style.
- pub fn for_derived_style(s: &'a ComputedValues) -> Self {
+ pub fn for_derived_style(s: &'a ComputedValuesInner) -> Self {
Self::for_inheritance(s, s)
}
/// Inherits style from the parent element, accounting for the default
/// computed values that need to be provided as well.
pub fn for_inheritance(
- parent: &'a ComputedValues,
- default: &'a ComputedValues
+ parent: &'a ComputedValuesInner,
+ default: &'a ComputedValuesInner
) -> Self {
Self::new(
parent,
default,
/* rules = */ None,
parent.custom_properties(),
parent.writing_mode,
parent.font_computation_data.font_size_keyword,
@@ -2517,17 +2522,17 @@ impl<'a> StyleBuilder<'a> {
/// Gets a mutable view of the current `${style_struct.name}` style,
/// only if it's been mutated before.
pub fn get_${style_struct.name_lower}_if_mutated(&mut self)
-> Option<<&mut style_structs::${style_struct.name}> {
self.${style_struct.ident}.get_if_mutated()
}
/// Reset the current `${style_struct.name}` style to its default value.
- pub fn reset_${style_struct.name_lower}(&mut self, default: &'a ComputedValues) {
+ pub fn reset_${style_struct.name_lower}(&mut self, default: &'a ComputedValuesInner) {
self.${style_struct.ident} =
StyleStructRef::Borrowed(default.${style_struct.name_lower}_arc());
}
% endfor
/// Returns whether this computed style represents a floated object.
pub fn floated(&self) -> bool {
self.get_box().clone_float() != longhands::float::computed_value::T::none
@@ -2551,18 +2556,18 @@ impl<'a> StyleBuilder<'a> {
#[cfg(feature = "gecko")]
pub fn in_top_layer(&self) -> bool {
matches!(self.get_box().clone__moz_top_layer(),
longhands::_moz_top_layer::computed_value::T::top)
}
/// Turns this `StyleBuilder` into a proper `ComputedValues` instance.
- pub fn build(self) -> ComputedValues {
- ComputedValues::new(self.custom_properties,
+ pub fn build(self) -> ComputedValuesInner {
+ ComputedValuesInner::new(self.custom_properties,
self.writing_mode,
self.font_size_keyword,
self.flags,
self.rules,
self.visited_style,
% for style_struct in data.active_style_structs():
self.${style_struct.ident}.build(),
% endfor
@@ -2582,49 +2587,47 @@ impl<'a> StyleBuilder<'a> {
pub use self::lazy_static_module::INITIAL_SERVO_VALUES;
// Use a module to work around #[cfg] on lazy_static! not being applied to every generated item.
#[cfg(feature = "servo")]
#[allow(missing_docs)]
mod lazy_static_module {
use logical_geometry::WritingMode;
use stylearc::Arc;
- use super::{ComputedValues, ComputedValuesInner, longhands, style_structs, FontComputationData};
+ use super::{ComputedValuesInner, longhands, style_structs, FontComputationData};
use super::computed_value_flags::ComputedValueFlags;
/// The initial values for all style structs as defined by the specification.
lazy_static! {
- pub static ref INITIAL_SERVO_VALUES: ComputedValues = ComputedValues {
- inner: ComputedValuesInner {
- % for style_struct in data.active_style_structs():
- ${style_struct.ident}: Arc::new(style_structs::${style_struct.name} {
- % for longhand in style_struct.longhands:
- ${longhand.ident}: longhands::${longhand.ident}::get_initial_value(),
- % endfor
- % if style_struct.name == "Font":
- hash: 0,
- % endif
- }),
- % endfor
- custom_properties: None,
- writing_mode: WritingMode::empty(),
- font_computation_data: FontComputationData::default_values(),
- rules: None,
- visited_style: None,
- flags: ComputedValueFlags::empty(),
- }
+ pub static ref INITIAL_SERVO_VALUES: ComputedValuesInner = ComputedValuesInner {
+ % for style_struct in data.active_style_structs():
+ ${style_struct.ident}: Arc::new(style_structs::${style_struct.name} {
+ % for longhand in style_struct.longhands:
+ ${longhand.ident}: longhands::${longhand.ident}::get_initial_value(),
+ % endfor
+ % if style_struct.name == "Font":
+ hash: 0,
+ % endif
+ }),
+ % endfor
+ custom_properties: None,
+ writing_mode: WritingMode::empty(),
+ font_computation_data: FontComputationData::default_values(),
+ rules: None,
+ visited_style: None,
+ flags: ComputedValueFlags::empty(),
};
}
}
/// A per-longhand function that performs the CSS cascade for that longhand.
pub type CascadePropertyFn =
extern "Rust" fn(declaration: &PropertyDeclaration,
- inherited_style: &ComputedValues,
- default_style: &ComputedValues,
+ inherited_style: &ComputedValuesInner,
+ default_style: &ComputedValuesInner,
context: &mut computed::Context,
cacheable: &mut bool,
cascade_info: &mut Option<<&mut CascadeInfo>);
/// A per-longhand array of functions to perform the CSS cascade on each of
/// them, effectively doing virtual dispatch.
static CASCADE_PROPERTY: [CascadePropertyFn; ${len(data.longhands)}] = [
% for property in data.longhands:
@@ -2675,24 +2678,24 @@ bitflags! {
/// * `parent_style`: The parent style, if applicable; if `None`, this is the root node.
///
/// Returns the computed values.
/// * `flags`: Various flags.
///
pub fn cascade(device: &Device,
rule_node: &StrongRuleNode,
guards: &StylesheetGuards,
- parent_style: Option<<&ComputedValues>,
- layout_parent_style: Option<<&ComputedValues>,
+ parent_style: Option<<&ComputedValuesInner>,
+ layout_parent_style: Option<<&ComputedValuesInner>,
visited_style: Option<Arc<ComputedValues>>,
cascade_info: Option<<&mut CascadeInfo>,
font_metrics_provider: &FontMetricsProvider,
flags: CascadeFlags,
quirks_mode: QuirksMode)
- -> ComputedValues {
+ -> ComputedValuesInner {
debug_assert!(layout_parent_style.is_none() || parent_style.is_some());
let (inherited_style, layout_parent_style) = match parent_style {
Some(parent_style) => {
(parent_style,
layout_parent_style.unwrap_or(parent_style))
},
None => {
(device.default_computed_values(),
@@ -2737,24 +2740,24 @@ pub fn cascade(device: &Device,
}
/// NOTE: This function expects the declaration with more priority to appear
/// first.
#[allow(unused_mut)] // conditionally compiled code for "position"
pub fn apply_declarations<'a, F, I>(device: &Device,
rules: &StrongRuleNode,
iter_declarations: F,
- inherited_style: &ComputedValues,
- layout_parent_style: &ComputedValues,
+ inherited_style: &ComputedValuesInner,
+ layout_parent_style: &ComputedValuesInner,
visited_style: Option<Arc<ComputedValues>>,
mut cascade_info: Option<<&mut CascadeInfo>,
font_metrics_provider: &FontMetricsProvider,
flags: CascadeFlags,
quirks_mode: QuirksMode)
- -> ComputedValues
+ -> ComputedValuesInner
where F: Fn() -> I,
I: Iterator<Item = (&'a PropertyDeclaration, CascadeLevel)>,
{
let default_style = device.default_computed_values();
let inherited_custom_properties = inherited_style.custom_properties();
let mut custom_properties = None;
let mut seen_custom = HashSet::new();
for (declaration, _cascade_level) in iter_declarations() {
--- a/servo/components/style/servo/media_queries.rs
+++ b/servo/components/style/servo/media_queries.rs
@@ -6,17 +6,17 @@
use app_units::Au;
use context::QuirksMode;
use cssparser::{Parser, RGBA};
use euclid::{Size2D, TypedSize2D};
use font_metrics::ServoMetricsProvider;
use media_queries::MediaType;
use parser::ParserContext;
-use properties::{ComputedValues, StyleBuilder};
+use properties::{ComputedValuesInner, StyleBuilder};
use properties::longhands::font_size;
use selectors::parser::SelectorParseError;
use std::fmt;
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering};
use style_traits::{CSSPixel, ToCss, ParseError};
use style_traits::viewport::ViewportConstraints;
use values::computed::{self, ToComputedValue};
use values::specified;
@@ -57,21 +57,21 @@ impl Device {
media_type: media_type,
viewport_size: viewport_size,
root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious?
used_root_font_size: AtomicBool::new(false),
}
}
/// Return the default computed values for this device.
- pub fn default_computed_values(&self) -> &ComputedValues {
+ pub fn default_computed_values(&self) -> &ComputedValuesInner {
// FIXME(bz): This isn't really right, but it's no more wrong
// than what we used to do. See
// https://github.com/servo/servo/issues/14773 for fixing it properly.
- ComputedValues::initial_values()
+ ComputedValuesInner::initial_values()
}
/// Get the font size of the root element (for rem)
pub fn root_font_size(&self) -> Au {
self.used_root_font_size.store(true, Ordering::Relaxed);
Au::new(self.root_font_size.load(Ordering::Relaxed) as i32)
}
--- a/servo/components/style/style_adjuster.rs
+++ b/servo/components/style/style_adjuster.rs
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A struct to encapsulate all the style fixups and flags propagations
//! a computed style needs in order for it to adhere to the CSS spec.
use app_units::Au;
-use properties::{self, CascadeFlags, ComputedValues};
+use properties::{self, CascadeFlags, ComputedValuesInner};
use properties::{IS_ROOT_ELEMENT, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, StyleBuilder};
use properties::longhands::display::computed_value::T as display;
use properties::longhands::float::computed_value::T as float;
use properties::longhands::overflow_x::computed_value::T as overflow;
use properties::longhands::position::computed_value::T as position;
#[cfg(feature = "gecko")]
use properties::longhands::unicode_bidi::computed_value::T as unicode_bidi;
@@ -49,17 +49,17 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
if self.style.out_of_flow_positioned() && self.style.floated() {
self.style.mutate_box().set_float(float::none);
}
}
/// Apply the blockification rules based on the table in CSS 2.2 section 9.7.
/// https://drafts.csswg.org/css2/visuren.html#dis-pos-flo
fn blockify_if_necessary(&mut self,
- layout_parent_style: &ComputedValues,
+ layout_parent_style: &ComputedValuesInner,
flags: CascadeFlags) {
let mut blockify = false;
macro_rules! blockify_if {
($if_what:expr) => {
if !blockify {
blockify = $if_what;
}
}
@@ -131,17 +131,17 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// computes to inline-block. [CSS21]
///
/// This matches the adjustment that Gecko does, not exactly following
/// the spec. See also:
///
/// https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html
/// https://github.com/servo/servo/issues/15754
fn adjust_for_writing_mode(&mut self,
- layout_parent_style: &ComputedValues) {
+ layout_parent_style: &ComputedValuesInner) {
let our_writing_mode = self.style.get_inheritedbox().clone_writing_mode();
let parent_writing_mode = layout_parent_style.get_inheritedbox().clone_writing_mode();
if our_writing_mode != parent_writing_mode &&
self.style.get_box().clone_display() == display::inline {
self.style.mutate_box().set_display(display::inline_block);
}
}
@@ -191,17 +191,17 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
}
}
/// This implements an out-of-date spec. The new spec moves the handling of
/// this to layout, which Gecko implements but Servo doesn't.
///
/// See https://github.com/servo/servo/issues/15229
#[cfg(feature = "servo")]
- fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValues) {
+ fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValuesInner) {
use computed_values::align_items::T as align_items;
use computed_values::align_self::T as align_self;
if self.style.get_position().clone_align_self() == align_self::auto &&
!self.style.out_of_flow_positioned() {
let self_align =
match layout_parent_style.get_position().clone_align_items() {
align_items::stretch => align_self::stretch,
@@ -310,26 +310,26 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
text_align::_moz_right => {}
_ => return,
}
self.style.mutate_inheritedtext().set_text_align(text_align::start);
}
/// Set the HAS_TEXT_DECORATION_LINES flag based on parent style.
- fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValues) {
+ fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValuesInner) {
use properties::computed_value_flags::HAS_TEXT_DECORATION_LINES;
if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) ||
!self.style.get_text().clone_text_decoration_line().is_empty() {
self.style.flags.insert(HAS_TEXT_DECORATION_LINES);
}
}
#[cfg(feature = "gecko")]
- fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValues) -> bool {
+ fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValuesInner) -> bool {
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
// Line break suppression should only be propagated to in-flow children.
if self.style.floated() || self.style.out_of_flow_positioned() {
return false;
}
let parent_display = layout_parent_style.get_box().clone_display();
if layout_parent_style.flags.contains(SHOULD_SUPPRESS_LINEBREAK) {
// Line break suppression is propagated to any children of
@@ -356,18 +356,18 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// Do ruby-related style adjustments, which include:
/// * propagate the line break suppression flag,
/// * inlinify block descendants,
/// * suppress border and padding for ruby level containers,
/// * correct unicode-bidi.
#[cfg(feature = "gecko")]
fn adjust_for_ruby(&mut self,
- layout_parent_style: &ComputedValues,
- default_computed_values: &'b ComputedValues,
+ layout_parent_style: &ComputedValuesInner,
+ default_computed_values: &'b ComputedValuesInner,
flags: CascadeFlags) {
use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
let self_display = self.style.get_box().clone_display();
// Check whether line break should be suppressed for this element.
if self.should_suppress_linebreak(layout_parent_style) {
self.style.flags.insert(SHOULD_SUPPRESS_LINEBREAK);
// Inlinify the display type if allowed.
@@ -401,18 +401,18 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
}
/// Adjusts the style to account for various fixups that don't fit naturally
/// into the cascade.
///
/// When comparing to Gecko, this is similar to the work done by
/// `nsStyleContext::ApplyStyleFixups`.
pub fn adjust(&mut self,
- layout_parent_style: &ComputedValues,
- _default_computed_values: &'b ComputedValues,
+ layout_parent_style: &ComputedValuesInner,
+ _default_computed_values: &'b ComputedValuesInner,
flags: CascadeFlags) {
#[cfg(feature = "gecko")]
{
self.adjust_for_prohibited_display_contents(flags);
}
self.adjust_for_top_layer();
self.blockify_if_necessary(layout_parent_style, flags);
self.adjust_for_position();
--- a/servo/components/style/style_resolver.rs
+++ b/servo/components/style/style_resolver.rs
@@ -6,17 +6,17 @@
use applicable_declarations::ApplicableDeclarationList;
use cascade_info::CascadeInfo;
use context::{CascadeInputs, ElementCascadeInputs, StyleContext};
use data::{ElementStyles, EagerPseudoStyles};
use dom::TElement;
use log::LogLevel::Trace;
use matching::{CascadeVisitedMode, MatchMethods};
-use properties::{AnimationRules, CascadeFlags, ComputedValues};
+use properties::{AnimationRules, CascadeFlags, ComputedValues, ComputedValuesInner};
use properties::{IS_ROOT_ELEMENT, PROHIBIT_DISPLAY_CONTENTS, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP};
use properties::{VISITED_DEPENDENT_ONLY, cascade};
use rule_tree::StrongRuleNode;
use selector_parser::{PseudoElement, SelectorImpl};
use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode, VisitedHandlingMode};
use stylearc::Arc;
use stylist::RuleInclusion;
@@ -42,17 +42,17 @@ struct MatchingResults {
pub struct PrimaryStyle {
/// The style per se.
pub style: Arc<ComputedValues>,
}
fn with_default_parent_styles<E, F, R>(element: E, f: F) -> R
where
E: TElement,
- F: FnOnce(Option<&ComputedValues>, Option<&ComputedValues>) -> R,
+ F: FnOnce(Option<&ComputedValuesInner>, Option<&ComputedValuesInner>) -> R,
{
let parent_el = element.inheritance_parent();
let parent_data = parent_el.as_ref().and_then(|e| e.borrow_data());
let parent_style = parent_data.as_ref().map(|d| {
// Sometimes Gecko eagerly styles things without processing
// pending restyles first. In general we'd like to avoid this,
// but there can be good reasons (for example, needing to
// construct a frame for some small piece of newly-added
@@ -67,17 +67,17 @@ where
let layout_parent_data;
let mut layout_parent_style = parent_style;
if parent_style.map_or(false, |s| s.is_display_contents()) {
layout_parent_el = Some(layout_parent_el.unwrap().layout_parent());
layout_parent_data = layout_parent_el.as_ref().unwrap().borrow_data().unwrap();
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>
where
'ctx: 'a,
'le: 'ctx,
E: TElement + MatchMethods + 'le,
{
@@ -93,18 +93,18 @@ where
rule_inclusion,
_marker: ::std::marker::PhantomData,
}
}
/// Resolve just the style of a given element.
pub fn resolve_primary_style(
&mut self,
- parent_style: Option<&ComputedValues>,
- layout_parent_style: Option<&ComputedValues>,
+ parent_style: Option<&ComputedValuesInner>,
+ layout_parent_style: Option<&ComputedValuesInner>,
) -> PrimaryStyle {
let primary_results =
self.match_primary(VisitedHandlingMode::AllLinksUnvisited);
let relevant_link_found = primary_results.relevant_link_found;
let visited_rules = if relevant_link_found {
let visited_matching_results =
@@ -141,18 +141,18 @@ where
PrimaryStyle { style, }
}
/// Resolve the style of a given element, and all its eager pseudo-elements.
pub fn resolve_style(
&mut self,
- parent_style: Option<&ComputedValues>,
- layout_parent_style: Option<&ComputedValues>,
+ parent_style: Option<&ComputedValuesInner>,
+ layout_parent_style: Option<&ComputedValuesInner>,
) -> ElementStyles {
use properties::longhands::display::computed_value::T as display;
let primary_style =
self.resolve_primary_style(parent_style, layout_parent_style);
let mut pseudo_styles = EagerPseudoStyles::default();
if primary_style.style.get_box().clone_display() == display::none {
@@ -163,17 +163,17 @@ where
}
}
if self.element.implemented_pseudo_element().is_none() {
let layout_parent_style_for_pseudo =
if primary_style.style.is_display_contents() {
layout_parent_style
} else {
- Some(&*primary_style.style)
+ Some(&**primary_style.style)
};
SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| {
let pseudo_style = self.resolve_pseudo_style(
&pseudo,
&primary_style,
layout_parent_style_for_pseudo
);
if let Some(style) = pseudo_style {
@@ -210,18 +210,18 @@ where
/* pseudo = */ None
)
})
}
fn cascade_style_and_visited(
&mut self,
inputs: CascadeInputs,
- parent_style: Option<&ComputedValues>,
- layout_parent_style: Option<&ComputedValues>,
+ parent_style: Option<&ComputedValuesInner>,
+ layout_parent_style: Option<&ComputedValuesInner>,
pseudo: Option<&PseudoElement>,
) -> Arc<ComputedValues> {
let mut style_if_visited = None;
if parent_style.map_or(false, |s| s.get_visited_style().is_some()) ||
inputs.visited_rules.is_some() {
style_if_visited = Some(self.cascade_style(
inputs.visited_rules.as_ref(),
/* style_if_visited = */ None,
@@ -267,17 +267,17 @@ where
}
}
{
let layout_parent_style_for_pseudo =
if primary_style.style.is_display_contents() {
layout_parent_style
} else {
- Some(&*primary_style.style)
+ Some(&**primary_style.style)
};
for (i, mut inputs) in pseudo_array.unwrap().iter_mut().enumerate() {
if let Some(inputs) = inputs.take() {
let pseudo = PseudoElement::from_eager_index(i);
pseudo_styles.set(
&pseudo,
self.cascade_style_and_visited(
@@ -297,17 +297,17 @@ where
}
})
}
fn resolve_pseudo_style(
&mut self,
pseudo: &PseudoElement,
originating_element_style: &PrimaryStyle,
- layout_parent_style: Option<&ComputedValues>,
+ layout_parent_style: Option<&ComputedValuesInner>,
) -> Option<Arc<ComputedValues>> {
let rules = self.match_pseudo(
&originating_element_style.style,
pseudo,
VisitedHandlingMode::AllLinksUnvisited
);
let rules = match rules {
Some(rules) => rules,
@@ -393,17 +393,17 @@ where
}
}
MatchingResults { rule_node, relevant_link_found }
}
fn match_pseudo(
&mut self,
- originating_element_style: &ComputedValues,
+ originating_element_style: &ComputedValuesInner,
pseudo_element: &PseudoElement,
visited_handling: VisitedHandlingMode,
) -> Option<StrongRuleNode> {
debug!("Match pseudo {:?} for {:?}, visited: {:?}",
self.element, pseudo_element, visited_handling);
debug_assert!(pseudo_element.is_eager() || pseudo_element.is_lazy());
debug_assert!(self.element.implemented_pseudo_element().is_none(),
"Element pseudos can't have any other pseudo.");
@@ -457,49 +457,49 @@ where
Some(rule_node)
}
fn cascade_style(
&mut self,
rules: Option<&StrongRuleNode>,
style_if_visited: Option<Arc<ComputedValues>>,
- mut parent_style: Option<&ComputedValues>,
- layout_parent_style: Option<&ComputedValues>,
+ mut parent_style: Option<&ComputedValuesInner>,
+ layout_parent_style: Option<&ComputedValuesInner>,
cascade_visited: CascadeVisitedMode,
pseudo: Option<&PseudoElement>,
) -> Arc<ComputedValues> {
let mut cascade_info = CascadeInfo::new();
let mut cascade_flags = CascadeFlags::empty();
if self.element.skip_root_and_item_based_display_fixup() {
cascade_flags.insert(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP);
}
if cascade_visited.visited_dependent_only() {
parent_style = parent_style.map(|s| {
- s.get_visited_style().map(|s| &**s).unwrap_or(s)
+ s.get_visited_style().unwrap_or(s)
});
cascade_flags.insert(VISITED_DEPENDENT_ONLY);
}
if self.element.is_native_anonymous() || pseudo.is_some() {
cascade_flags.insert(PROHIBIT_DISPLAY_CONTENTS);
} else if self.element.is_root() {
cascade_flags.insert(IS_ROOT_ELEMENT);
}
let values =
- Arc::new(cascade(
+ cascade(
self.context.shared.stylist.device(),
rules.unwrap_or(self.context.shared.stylist.rule_tree().root()),
&self.context.shared.guards,
parent_style,
layout_parent_style,
style_if_visited,
Some(&mut cascade_info),
&self.context.thread_local.font_metrics_provider,
cascade_flags,
self.context.shared.quirks_mode
- ));
+ );
cascade_info.finish(&self.element.as_node());
- values
+ values.to_outer()
}
}
--- a/servo/components/style/stylist.rs
+++ b/servo/components/style/stylist.rs
@@ -11,17 +11,17 @@ use context::{CascadeInputs, QuirksMode}
use dom::TElement;
use element_state::ElementState;
use font_metrics::FontMetricsProvider;
#[cfg(feature = "gecko")]
use gecko_bindings::structs::{nsIAtom, StyleRuleInclusion};
use invalidation::element::invalidation_map::InvalidationMap;
use invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey};
use media_queries::Device;
-use properties::{self, CascadeFlags, ComputedValues};
+use properties::{self, CascadeFlags, ComputedValues, ComputedValuesInner};
use properties::{AnimationRules, PropertyDeclarationBlock};
#[cfg(feature = "servo")]
use properties::INHERIT_ALL;
use rule_tree::{CascadeLevel, RuleTree, StyleSource};
use selector_map::{SelectorMap, SelectorMapEntry};
use selector_parser::{SelectorImpl, PseudoElement};
use selectors::attr::NamespaceConstraint;
use selectors::bloom::BloomFilter;
@@ -594,17 +594,17 @@ impl Stylist {
///
/// If `inherit_all` is true, then all properties are inherited from the
/// parent; otherwise, non-inherited properties are reset to their initial
/// values. The flow constructor uses this flag when constructing anonymous
/// flows.
pub fn precomputed_values_for_pseudo(&self,
guards: &StylesheetGuards,
pseudo: &PseudoElement,
- parent: Option<&Arc<ComputedValues>>,
+ parent: Option<&ComputedValuesInner>,
cascade_flags: CascadeFlags,
font_metrics: &FontMetricsProvider)
-> Arc<ComputedValues> {
debug_assert!(pseudo.is_precomputed());
let rule_node = match self.precomputed_pseudo_element_decls.get(pseudo) {
Some(declarations) => {
self.rule_tree.insert_ordered_rules_with_important(
@@ -624,36 +624,34 @@ impl Stylist {
// <fieldset style="display: contents">. That is, the computed value of
// display for the fieldset is "contents", even though it's not the used
// value, so we don't need to adjust in a different way anyway.
//
// In practice, I don't think any anonymous content can be a direct
// descendant of a display: contents element where display: contents is
// the actual used value, and the computed value of it would need
// blockification.
- let computed =
- properties::cascade(&self.device,
- &rule_node,
- guards,
- parent.map(|p| &**p),
- parent.map(|p| &**p),
- None,
- None,
- font_metrics,
- cascade_flags,
- self.quirks_mode);
- Arc::new(computed)
+ properties::cascade(&self.device,
+ &rule_node,
+ guards,
+ parent,
+ parent,
+ None,
+ None,
+ font_metrics,
+ cascade_flags,
+ self.quirks_mode).to_outer()
}
/// Returns the style for an anonymous box of the given type.
#[cfg(feature = "servo")]
pub fn style_for_anonymous(&self,
guards: &StylesheetGuards,
pseudo: &PseudoElement,
- parent_style: &Arc<ComputedValues>)
+ parent_style: &ComputedValuesInner)
-> Arc<ComputedValues> {
use font_metrics::ServoMetricsProvider;
// For most (but not all) pseudo-elements, we inherit all values from the parent.
let inherit_all = match *pseudo {
PseudoElement::ServoText |
PseudoElement::ServoInputText => false,
PseudoElement::ServoAnonymousBlock |
@@ -687,17 +685,17 @@ impl Stylist {
///
/// Check the documentation on lazy pseudo-elements in
/// docs/components/style.md
pub fn lazily_compute_pseudo_element_style<E>(&self,
guards: &StylesheetGuards,
element: &E,
pseudo: &PseudoElement,
rule_inclusion: RuleInclusion,
- parent_style: &Arc<ComputedValues>,
+ parent_style: &ComputedValuesInner,
is_probe: bool,
font_metrics: &FontMetricsProvider)
-> Option<Arc<ComputedValues>>
where E: TElement,
{
let cascade_inputs =
self.lazy_pseudo_rules(guards, element, pseudo, is_probe, rule_inclusion);
self.compute_pseudo_element_style_with_inputs(&cascade_inputs,
@@ -708,17 +706,17 @@ impl Stylist {
/// Computes a pseudo-element style lazily using the given CascadeInputs.
/// This can be used for truly lazy pseudo-elements or to avoid redoing
/// selector matching for eager pseudo-elements when we need to recompute
/// their style with a new parent style.
pub fn compute_pseudo_element_style_with_inputs(&self,
inputs: &CascadeInputs,
guards: &StylesheetGuards,
- parent_style: &Arc<ComputedValues>,
+ parent_style: &ComputedValuesInner,
font_metrics: &FontMetricsProvider)
-> Option<Arc<ComputedValues>>
{
// We may have only visited rules in cases when we are actually
// resolving, not probing, pseudo-element style.
if inputs.rules.is_none() && inputs.visited_rules.is_none() {
return None
}
@@ -731,61 +729,58 @@ impl Stylist {
// maybe it just has visited rules, so can't unwrap_or.
let rule_node = match inputs.visited_rules.as_ref() {
Some(rules) => rules,
None => inputs.rules.as_ref().unwrap(),
};
// We want to use the visited bits (if any) from our parent style as
// our parent.
let inherited_style =
- parent_style.get_visited_style().unwrap_or(&*parent_style);
+ parent_style.get_visited_style().unwrap_or(parent_style);
// FIXME(emilio): The lack of layout_parent_style here could be
// worrying, but we're probably dropping the display fixup for
// pseudos other than before and after, so it's probably ok.
//
// (Though the flags don't indicate so!)
let computed =
properties::cascade(&self.device,
rule_node,
guards,
Some(inherited_style),
Some(inherited_style),
None,
None,
font_metrics,
CascadeFlags::empty(),
- self.quirks_mode);
+ self.quirks_mode).to_outer();
- Some(Arc::new(computed))
+ Some(computed)
} else {
None
};
// We may not have non-visited rules, if we only had visited ones. In
// that case we want to use the root rulenode for our non-visited rules.
let rules = inputs.rules.as_ref().unwrap_or(self.rule_tree.root());
// Read the comment on `precomputed_values_for_pseudo` to see why it's
// difficult to assert that display: contents nodes never arrive here
// (tl;dr: It doesn't apply for replaced elements and such, but the
// computed value is still "contents").
- let computed =
- properties::cascade(&self.device,
- rules,
- guards,
- Some(parent_style),
- Some(parent_style),
- visited_values,
- None,
- font_metrics,
- CascadeFlags::empty(),
- self.quirks_mode);
-
- Some(Arc::new(computed))
+ Some(properties::cascade(&self.device,
+ rules,
+ guards,
+ Some(parent_style),
+ Some(parent_style),
+ visited_values,
+ None,
+ font_metrics,
+ CascadeFlags::empty(),
+ self.quirks_mode).to_outer())
}
/// Computes the cascade inputs for a lazily-cascaded pseudo-element.
///
/// See the documentation on lazy pseudo-elements in
/// docs/components/style.md
pub fn lazy_pseudo_rules<E>(&self,
guards: &StylesheetGuards,
@@ -1312,42 +1307,42 @@ impl Stylist {
);
results
}
/// Computes styles for a given declaration with parent_style.
pub fn compute_for_declarations(&self,
guards: &StylesheetGuards,
- parent_style: &Arc<ComputedValues>,
+ parent_style: &ComputedValuesInner,
declarations: Arc<Locked<PropertyDeclarationBlock>>)
-> Arc<ComputedValues> {
use font_metrics::get_metrics_provider_for_product;
let v = vec![
ApplicableDeclarationBlock::from_declarations(declarations.clone(),
CascadeLevel::StyleAttributeNormal)
];
let rule_node =
self.rule_tree.insert_ordered_rules(v.into_iter().map(|a| a.order_and_level()));
// This currently ignores visited styles. It appears to be used for
// font styles in <canvas> via Servo_StyleSet_ResolveForDeclarations.
// It is unclear if visited styles are meaningful for this case.
let metrics = get_metrics_provider_for_product();
- Arc::new(properties::cascade(&self.device,
- &rule_node,
- guards,
- Some(parent_style),
- Some(parent_style),
- None,
- None,
- &metrics,
- CascadeFlags::empty(),
- self.quirks_mode))
+ properties::cascade(&self.device,
+ &rule_node,
+ guards,
+ Some(parent_style),
+ Some(parent_style),
+ None,
+ None,
+ &metrics,
+ CascadeFlags::empty(),
+ self.quirks_mode).to_outer()
}
/// Accessor for a shared reference to the device.
pub fn device(&self) -> &Device {
&self.device
}
/// Accessor for a mutable reference to the device.
--- a/servo/components/style/traversal.rs
+++ b/servo/components/style/traversal.rs
@@ -571,35 +571,35 @@ where
}
for ancestor in ancestors_requiring_style_resolution.iter().rev() {
context.thread_local.bloom_filter.assert_complete(*ancestor);
let primary_style =
StyleResolverForElement::new(*ancestor, context, rule_inclusion)
.resolve_primary_style(
- style.as_ref().map(|s| &**s),
- layout_parent_style.as_ref().map(|s| &**s)
+ style.as_ref().map(|s| &***s),
+ layout_parent_style.as_ref().map(|s| &***s)
);
let is_display_contents = primary_style.style.is_display_contents();
style = Some(primary_style.style);
if !is_display_contents {
layout_parent_style = style.clone();
}
context.thread_local.bloom_filter.push(*ancestor);
}
context.thread_local.bloom_filter.assert_complete(element);
StyleResolverForElement::new(element, context, rule_inclusion)
.resolve_style(
- style.as_ref().map(|s| &**s),
- layout_parent_style.as_ref().map(|s| &**s)
+ style.as_ref().map(|s| &***s),
+ layout_parent_style.as_ref().map(|s| &***s)
)
}
/// Calculates the style for a single node.
#[inline]
#[allow(unsafe_code)]
pub fn recalc_style_at<E, D>(
traversal: &D,
--- a/servo/components/style/values/computed/mod.rs
+++ b/servo/components/style/values/computed/mod.rs
@@ -6,17 +6,17 @@
use Atom;
use context::QuirksMode;
use euclid::Size2D;
use font_metrics::FontMetricsProvider;
use media_queries::Device;
#[cfg(feature = "gecko")]
use properties;
-use properties::{ComputedValues, StyleBuilder};
+use properties::{ComputedValuesInner, StyleBuilder};
use std::f32;
use std::f32::consts::PI;
use std::fmt;
use style_traits::ToCss;
use super::{CSSFloat, CSSInteger, RGBA};
use super::generics::grid::{TrackBreadth as GenericTrackBreadth, TrackSize as GenericTrackSize};
use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent;
use super::generics::grid::TrackList as GenericTrackList;
@@ -66,23 +66,23 @@ pub mod transform;
pub struct Context<'a> {
/// Whether the current element is the root element.
pub is_root_element: bool,
/// The Device holds the viewport and other external state.
pub device: &'a Device,
/// The style we're inheriting from.
- pub inherited_style: &'a ComputedValues,
+ pub inherited_style: &'a ComputedValuesInner,
/// The style of the layout parent node. This will almost always be
/// `inherited_style`, except when `display: contents` is at play, in which
/// case it's the style of the last ancestor with a `display` value that
/// isn't `contents`.
- pub layout_parent_style: &'a ComputedValues,
+ pub layout_parent_style: &'a ComputedValuesInner,
/// Values accessed through this need to be in the properties "computed
/// early": color, text-decoration, font-size, display, position, float,
/// border-*-style, outline-style, font-family, writing-mode...
pub style: StyleBuilder<'a>,
/// A cached computed system font value, for use by gecko.
///
@@ -109,17 +109,17 @@ pub struct Context<'a> {
}
impl<'a> Context<'a> {
/// Whether the current element is the root element.
pub fn is_root_element(&self) -> bool { self.is_root_element }
/// The current viewport size.
pub fn viewport_size(&self) -> Size2D<Au> { self.device.au_viewport_size() }
/// The style we're inheriting from.
- pub fn inherited_style(&self) -> &ComputedValues { &self.inherited_style }
+ pub fn inherited_style(&self) -> &ComputedValuesInner { &self.inherited_style }
/// The current style. Note that only "eager" properties should be accessed
/// from here, see the comment in the member.
pub fn style(&self) -> &StyleBuilder { &self.style }
/// A mutable reference to the current style.
pub fn mutate_style(&mut self) -> &mut StyleBuilder<'a> { &mut self.style }
/// Get a mutable reference to the current style as well as the device
pub fn mutate_style_with_device(&mut self) -> (&mut StyleBuilder<'a>, &Device) { (&mut self.style, &self.device) }
}
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -1508,17 +1508,18 @@ pub extern "C" fn Servo_ComputedValues_G
let guard = global_style_data.shared_lock.read();
let guards = StylesheetGuards::same(&guard);
let data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
let atom = Atom::from(pseudo_tag);
let pseudo = PseudoElement::from_anon_box_atom(&atom)
.expect("Not an anon box pseudo?");
- let maybe_parent = ComputedValues::arc_from_borrowed(&parent_style_or_null);
+ let maybe_parent = ComputedValues::arc_from_borrowed(&parent_style_or_null)
+ .map(|p| &p.inner);
let cascade_flags = SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
let metrics = get_metrics_provider_for_product();
data.stylist.precomputed_values_for_pseudo(&guards, &pseudo, maybe_parent,
cascade_flags, &metrics)
.into_strong()
}
#[no_mangle]
@@ -1537,17 +1538,17 @@ pub extern "C" fn Servo_ResolvePseudoSty
element, PseudoElement::from_pseudo_type(pseudo_type), is_probe);
// FIXME(bholley): Assert against this.
if !data.has_styles() {
warn!("Calling Servo_ResolvePseudoStyle on unstyled element");
return if is_probe {
Strong::null()
} else {
- doc_data.default_computed_values().clone().into_strong()
+ doc_data.default_computed_values().clone().to_outer().into_strong()
};
}
let pseudo = PseudoElement::from_pseudo_type(pseudo_type)
.expect("ResolvePseudoStyle with a non-pseudo?");
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
@@ -1670,20 +1671,20 @@ fn get_pseudo_style(
},
};
if is_probe {
return style;
}
Some(style.unwrap_or_else(|| {
- Arc::new(StyleBuilder::for_inheritance(
+ StyleBuilder::for_inheritance(
styles.primary(),
doc_data.default_computed_values(),
- ).build())
+ ).build().to_outer()
}))
}
#[no_mangle]
pub extern "C" fn Servo_ComputedValues_Inherit(
raw_data: RawServoStyleSetBorrowed,
parent_style: ServoComputedValuesBorrowedOrNull,
target: structs::InheritTarget
@@ -1696,30 +1697,30 @@ pub extern "C" fn Servo_ComputedValues_I
let mut style =
StyleBuilder::for_inheritance(reference,
&data.default_computed_values());
if for_text {
StyleAdjuster::new(&mut style)
.adjust_for_text();
}
- Arc::new(style.build())
+ style.build()
} else {
debug_assert!(!for_text);
data.default_computed_values().clone()
};
- style.into_strong()
+ style.to_outer().into_strong()
}
#[no_mangle]
pub extern "C" fn Servo_ComputedValues_GetVisitedStyle(values: ServoComputedValuesBorrowed)
-> ServoComputedValuesStrong {
- match ComputedValues::as_arc(&values).get_visited_style() {
- Some(v) => v.clone().into_strong(),
+ match ComputedValues::as_arc(&values).clone_visited_style() {
+ Some(v) => v.into_strong(),
None => Strong::null(),
}
}
#[no_mangle]
pub extern "C" fn Servo_ComputedValues_GetStyleBits(values: ServoComputedValuesBorrowed) -> u64 {
use style::properties::computed_value_flags::*;
let flags = ComputedValues::as_arc(&values).flags;
@@ -2755,17 +2756,17 @@ pub extern "C" fn Servo_ResolveStyle(ele
let element = GeckoElement(element);
debug!("Servo_ResolveStyle: {:?}", element);
let data = unsafe { element.ensure_data() }.borrow();
if !element.has_current_styles(&*data) {
debug_assert!(false, "Resolving style on element without current styles with lazy \
computation forbidden.");
let per_doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
- return per_doc_data.default_computed_values().clone().into_strong();
+ return per_doc_data.default_computed_values().clone().to_outer().into_strong();
}
data.styles.primary().clone().into_strong()
}
#[no_mangle]
pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
pseudo_type: CSSPseudoElementType,
@@ -2845,22 +2846,23 @@ fn simulate_compute_values_failure(_: &P
}
fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
font_metrics_provider: &'a FontMetricsProvider,
style: &'a ComputedValues,
parent_style: &'a Option<&Arc<ComputedValues>>)
-> Context<'a> {
let default_values = per_doc_data.default_computed_values();
+ let inherited_style = parent_style.map(|x| &x.inner).unwrap_or(default_values);
Context {
is_root_element: false,
device: per_doc_data.stylist.device(),
- inherited_style: parent_style.unwrap_or(default_values),
- layout_parent_style: parent_style.unwrap_or(default_values),
+ inherited_style: inherited_style,
+ layout_parent_style: inherited_style,
style: StyleBuilder::for_derived_style(&style),
font_metrics_provider: font_metrics_provider,
cached_system_font: None,
in_media_query: false,
quirks_mode: per_doc_data.stylist.quirks_mode(),
}
}
@@ -3239,17 +3241,17 @@ pub extern "C" fn Servo_StyleSet_Resolve
declarations: RawServoDeclarationBlockBorrowed
) -> ServoComputedValuesStrong {
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
let guards = StylesheetGuards::same(&guard);
let parent_style = match ComputedValues::arc_from_borrowed(&parent_style_or_null) {
- Some(parent) => &parent,
+ Some(parent) => &parent.inner,
None => doc_data.default_computed_values(),
};
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
doc_data.stylist.compute_for_declarations(&guards,
parent_style,
declarations.clone()).into_strong()