mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #17767 - Manishearth:stylo-fuse, r=bholley
stylo: Fuse ServoStyleContext and ServoComputedValues r=bholley https://bugzilla.mozilla.org/show_bug.cgi?id=1367904 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17767) <!-- Reviewable:end -->
This commit is contained in:
commit
d746abaa9e
59 changed files with 12760 additions and 9410 deletions
|
@ -56,7 +56,7 @@ use style::computed_values::{border_collapse, box_sizing, display, float, overfl
|
|||
use style::computed_values::{position, text_align};
|
||||
use style::context::SharedStyleContext;
|
||||
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION};
|
||||
use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage};
|
||||
use style::values::computed::LengthOrPercentageOrAuto;
|
||||
|
@ -2139,7 +2139,7 @@ impl Flow for BlockFlow {
|
|||
self.build_display_list_for_block(state, BorderPaintingMode::Separate);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) {
|
||||
self.fragment.repair_style(new_style)
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ use style::computed_values::content::ContentItem;
|
|||
use style::computed_values::position;
|
||||
use style::context::SharedStyleContext;
|
||||
use style::logical_geometry::Direction;
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::properties::longhands::list_style_image;
|
||||
use style::selector_parser::{PseudoElement, RestyleDamage};
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW};
|
||||
|
@ -109,7 +109,7 @@ pub enum ConstructionItem {
|
|||
/// Inline fragments and associated {ib} splits that have not yet found flows.
|
||||
InlineFragments(InlineFragmentsConstructionResult),
|
||||
/// Potentially ignorable whitespace.
|
||||
Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ServoComputedValues>, RestyleDamage),
|
||||
Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ComputedValues>, RestyleDamage),
|
||||
/// TableColumn Fragment
|
||||
TableColumnFragment(Fragment),
|
||||
}
|
||||
|
@ -677,7 +677,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
fn create_fragments_for_node_text_content(&self,
|
||||
fragments: &mut IntermediateInlineFragments,
|
||||
node: &ConcreteThreadSafeLayoutNode,
|
||||
style: &StyleArc<ServoComputedValues>) {
|
||||
style: &StyleArc<ComputedValues>) {
|
||||
// Fast path: If there is no text content, return immediately.
|
||||
let text_content = node.text_content();
|
||||
if text_content.is_empty() {
|
||||
|
@ -1806,7 +1806,7 @@ pub fn strip_ignorable_whitespace_from_end(this: &mut LinkedList<Fragment>) {
|
|||
|
||||
/// If the 'unicode-bidi' property has a value other than 'normal', return the bidi control codes
|
||||
/// to inject before and after the text content of the element.
|
||||
fn bidi_control_chars(style: &StyleArc<ServoComputedValues>) -> Option<(&'static str, &'static str)> {
|
||||
fn bidi_control_chars(style: &StyleArc<ComputedValues>) -> Option<(&'static str, &'static str)> {
|
||||
use style::computed_values::direction::T::*;
|
||||
use style::computed_values::unicode_bidi::T::*;
|
||||
|
||||
|
@ -1851,7 +1851,7 @@ trait ComputedValueUtils {
|
|||
fn has_padding_or_border(&self) -> bool;
|
||||
}
|
||||
|
||||
impl ComputedValueUtils for ServoComputedValues {
|
||||
impl ComputedValueUtils for ComputedValues {
|
||||
fn has_padding_or_border(&self) -> bool {
|
||||
let padding = self.get_padding();
|
||||
let border = self.get_border();
|
||||
|
|
|
@ -51,7 +51,7 @@ use style::computed_values::{background_attachment, background_clip, background_
|
|||
use style::computed_values::{background_repeat, border_style, cursor};
|
||||
use style::computed_values::{image_rendering, overflow_x, pointer_events, position, visibility};
|
||||
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::{self, ServoComputedValues};
|
||||
use style::properties::{self, ComputedValues};
|
||||
use style::properties::longhands::border_image_repeat::computed_value::RepeatKeyword;
|
||||
use style::properties::style_structs;
|
||||
use style::servo::restyle_damage::REPAINT;
|
||||
|
@ -375,14 +375,14 @@ pub trait FragmentDisplayListBuilding {
|
|||
/// list if necessary.
|
||||
fn build_display_list_for_background_if_applicable(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
display_list_section: DisplayListSection,
|
||||
absolute_bounds: &Rect<Au>);
|
||||
|
||||
/// Computes the background size for an image with the given background area according to the
|
||||
/// rules in CSS-BACKGROUNDS § 3.9.
|
||||
fn compute_background_image_size(&self,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
bounds: &Rect<Au>,
|
||||
image: &WebRenderImageInfo, index: usize)
|
||||
-> Size2D<Au>;
|
||||
|
@ -391,7 +391,7 @@ pub trait FragmentDisplayListBuilding {
|
|||
/// appropriate section of the display list.
|
||||
fn build_display_list_for_background_image(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
display_list_section: DisplayListSection,
|
||||
absolute_bounds: &Rect<Au>,
|
||||
clip: &LocalClip,
|
||||
|
@ -402,7 +402,7 @@ pub trait FragmentDisplayListBuilding {
|
|||
/// appropriate section of the display list.
|
||||
fn build_display_list_for_webrender_image(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
display_list_section: DisplayListSection,
|
||||
absolute_bounds: &Rect<Au>,
|
||||
clip: &LocalClip,
|
||||
|
@ -413,7 +413,7 @@ pub trait FragmentDisplayListBuilding {
|
|||
/// worklet to the appropriate section of the display list.
|
||||
fn build_display_list_for_background_paint_worklet(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
display_list_section: DisplayListSection,
|
||||
absolute_bounds: &Rect<Au>,
|
||||
clip: &LocalClip,
|
||||
|
@ -443,14 +443,14 @@ pub trait FragmentDisplayListBuilding {
|
|||
absolute_bounds: &Rect<Au>,
|
||||
clip: &LocalClip,
|
||||
gradient: &Gradient,
|
||||
style: &ServoComputedValues);
|
||||
style: &ComputedValues);
|
||||
|
||||
/// Adds the display items necessary to paint the borders of this fragment to a display list if
|
||||
/// necessary.
|
||||
fn build_display_list_for_borders_if_applicable(
|
||||
&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
border_painting_mode: BorderPaintingMode,
|
||||
bounds: &Rect<Au>,
|
||||
display_list_section: DisplayListSection,
|
||||
|
@ -460,7 +460,7 @@ pub trait FragmentDisplayListBuilding {
|
|||
/// if necessary.
|
||||
fn build_display_list_for_outline_if_applicable(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
bounds: &Rect<Au>,
|
||||
clip: &Rect<Au>);
|
||||
|
||||
|
@ -468,7 +468,7 @@ pub trait FragmentDisplayListBuilding {
|
|||
/// list if necessary.
|
||||
fn build_display_list_for_box_shadow_if_applicable(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
display_list_section: DisplayListSection,
|
||||
absolute_bounds: &Rect<Au>,
|
||||
clip: &Rect<Au>);
|
||||
|
@ -476,7 +476,7 @@ pub trait FragmentDisplayListBuilding {
|
|||
/// Adds display items necessary to draw debug boxes around a scanned text fragment.
|
||||
fn build_debug_borders_around_text_fragments(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
stacking_relative_border_box: &Rect<Au>,
|
||||
stacking_relative_content_box: &Rect<Au>,
|
||||
text_fragment: &ScannedTextFragmentInfo,
|
||||
|
@ -607,7 +607,7 @@ fn build_border_radius(abs_bounds: &Rect<Au>,
|
|||
/// Get the border radius for the rectangle inside of a rounded border. This is useful
|
||||
/// for building the clip for the content inside the border.
|
||||
fn build_border_radius_for_inner_rect(outer_rect: &Rect<Au>,
|
||||
style: &ServoComputedValues)
|
||||
style: &ComputedValues)
|
||||
-> BorderRadii<Au> {
|
||||
let mut radii = build_border_radius(&outer_rect, style.get_border());
|
||||
if radii.is_square() {
|
||||
|
@ -633,7 +633,7 @@ fn build_border_radius_for_inner_rect(outer_rect: &Rect<Au>,
|
|||
}
|
||||
|
||||
fn build_inner_border_box_for_border_rect(border_box: &Rect<Au>,
|
||||
style: &ServoComputedValues)
|
||||
style: &ComputedValues)
|
||||
-> Rect<Au> {
|
||||
let border_widths = style.logical_border_width().to_physical(style.writing_mode);
|
||||
let mut inner_border_box = *border_box;
|
||||
|
@ -845,7 +845,7 @@ fn convert_ellipse_size_keyword(keyword: ShapeExtent,
|
|||
impl FragmentDisplayListBuilding for Fragment {
|
||||
fn build_display_list_for_background_if_applicable(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
display_list_section: DisplayListSection,
|
||||
absolute_bounds: &Rect<Au>) {
|
||||
// FIXME: This causes a lot of background colors to be displayed when they are clearly not
|
||||
|
@ -950,7 +950,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
}
|
||||
|
||||
fn compute_background_image_size(&self,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
bounds: &Rect<Au>,
|
||||
image: &WebRenderImageInfo,
|
||||
index: usize)
|
||||
|
@ -996,7 +996,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
fn build_display_list_for_background_image(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
display_list_section: DisplayListSection,
|
||||
absolute_bounds: &Rect<Au>,
|
||||
clip: &LocalClip,
|
||||
|
@ -1020,7 +1020,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
fn build_display_list_for_webrender_image(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
display_list_section: DisplayListSection,
|
||||
absolute_bounds: &Rect<Au>,
|
||||
clip: &LocalClip,
|
||||
|
@ -1157,7 +1157,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
fn build_display_list_for_background_paint_worklet(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
display_list_section: DisplayListSection,
|
||||
absolute_bounds: &Rect<Au>,
|
||||
clip: &LocalClip,
|
||||
|
@ -1338,7 +1338,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
absolute_bounds: &Rect<Au>,
|
||||
clip: &LocalClip,
|
||||
gradient: &Gradient,
|
||||
style: &ServoComputedValues) {
|
||||
style: &ComputedValues) {
|
||||
let border = self.border_width().to_physical(style.writing_mode);
|
||||
let mut bounds = *absolute_bounds;
|
||||
bounds.origin.x = bounds.origin.x + border.left;
|
||||
|
@ -1380,7 +1380,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
fn build_display_list_for_box_shadow_if_applicable(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
display_list_section: DisplayListSection,
|
||||
absolute_bounds: &Rect<Au>,
|
||||
clip: &Rect<Au>) {
|
||||
|
@ -1423,7 +1423,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
fn build_display_list_for_borders_if_applicable(
|
||||
&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
border_painting_mode: BorderPaintingMode,
|
||||
bounds: &Rect<Au>,
|
||||
display_list_section: DisplayListSection,
|
||||
|
@ -1570,7 +1570,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
fn build_display_list_for_outline_if_applicable(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
bounds: &Rect<Au>,
|
||||
clip: &Rect<Au>) {
|
||||
use style::values::Either;
|
||||
|
@ -1615,7 +1615,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
fn build_debug_borders_around_text_fragments(&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ServoComputedValues,
|
||||
style: &ComputedValues,
|
||||
stacking_relative_border_box: &Rect<Au>,
|
||||
stacking_relative_content_box: &Rect<Au>,
|
||||
text_fragment: &ScannedTextFragmentInfo,
|
||||
|
@ -2886,12 +2886,12 @@ impl BaseFlowDisplayListBuilding for BaseFlow {
|
|||
}
|
||||
}
|
||||
|
||||
trait ServoComputedValuesCursorUtility {
|
||||
trait ComputedValuesCursorUtility {
|
||||
fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor>;
|
||||
}
|
||||
|
||||
impl ServoComputedValuesCursorUtility for ServoComputedValues {
|
||||
/// Gets the cursor to use given the specific ServoComputedValues. `default_cursor` specifies
|
||||
impl ComputedValuesCursorUtility for ComputedValues {
|
||||
/// Gets the cursor to use given the specific ComputedValues. `default_cursor` specifies
|
||||
/// the cursor to use if `cursor` is `auto`. Typically, this will be `PointerCursor`, but for
|
||||
/// text display items it may be `TextCursor` or `VerticalTextCursor`.
|
||||
#[inline]
|
||||
|
|
|
@ -23,7 +23,7 @@ use std::ops::Range;
|
|||
use style::computed_values::{align_content, align_self, flex_direction, flex_wrap, justify_content};
|
||||
use style::computed_values::border_collapse;
|
||||
use style::logical_geometry::{Direction, LogicalSize};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
|
||||
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
||||
use style::values::computed::flex::FlexBasis;
|
||||
|
@ -973,7 +973,7 @@ impl Flow for FlexFlow {
|
|||
self.block_flow.collect_stacking_contexts(state);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) {
|
||||
self.block_flow.repair_style(new_style)
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ use std::sync::atomic::Ordering;
|
|||
use style::computed_values::{clear, float, overflow_x, position, text_align};
|
||||
use style::context::SharedStyleContext;
|
||||
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::selector_parser::RestyleDamage;
|
||||
use style::servo::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION};
|
||||
use style::values::computed::LengthOrPercentageOrAuto;
|
||||
|
@ -424,7 +424,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static {
|
|||
|
||||
/// Attempts to perform incremental fixup of this flow by replacing its fragment's style with
|
||||
/// the new style. This can only succeed if the flow has exactly one fragment.
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>);
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>);
|
||||
|
||||
/// Print any extra children (such as fragments) contained in this Flow
|
||||
/// for debugging purposes. Any items inserted into the tree will become
|
||||
|
@ -561,7 +561,7 @@ pub trait MutableFlowUtils {
|
|||
|
||||
/// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of
|
||||
/// calling them individually, since there is no reason not to perform both operations.
|
||||
fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>);
|
||||
fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ComputedValues>);
|
||||
}
|
||||
|
||||
pub trait MutableOwnedFlowUtils {
|
||||
|
@ -1033,7 +1033,7 @@ pub enum ForceNonfloatedFlag {
|
|||
|
||||
impl BaseFlow {
|
||||
#[inline]
|
||||
pub fn new(style: Option<&ServoComputedValues>,
|
||||
pub fn new(style: Option<&ComputedValues>,
|
||||
writing_mode: WritingMode,
|
||||
force_nonfloated: ForceNonfloatedFlag)
|
||||
-> BaseFlow {
|
||||
|
@ -1119,7 +1119,7 @@ impl BaseFlow {
|
|||
///
|
||||
/// These flags are initially set during flow construction. They only need to be updated here
|
||||
/// if they are based on properties that can change without triggering `RECONSTRUCT_FLOW`.
|
||||
pub fn update_flags_if_needed(&mut self, style: &ServoComputedValues) {
|
||||
pub fn update_flags_if_needed(&mut self, style: &ComputedValues) {
|
||||
// For absolutely-positioned flows, changes to top/bottom/left/right can cause these flags
|
||||
// to get out of date:
|
||||
if self.restyle_damage.contains(REFLOW_OUT_OF_FLOW) {
|
||||
|
@ -1381,7 +1381,7 @@ impl<'a> MutableFlowUtils for &'a mut Flow {
|
|||
|
||||
/// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of
|
||||
/// calling them individually, since there is no reason not to perform both operations.
|
||||
fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>) {
|
||||
fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ComputedValues>) {
|
||||
self.repair_style(style);
|
||||
mut_base(self).update_flags_if_needed(style);
|
||||
self.bubble_inline_sizes();
|
||||
|
|
|
@ -45,7 +45,7 @@ use style::computed_values::{overflow_wrap, overflow_x, position, text_decoratio
|
|||
use style::computed_values::{transform_style, vertical_align, white_space, word_break};
|
||||
use style::computed_values::content::ContentItem;
|
||||
use style::logical_geometry::{Direction, LogicalMargin, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::selector_parser::RestyleDamage;
|
||||
use style::servo::restyle_damage::RECONSTRUCT_FLOW;
|
||||
use style::str::char_is_whitespace;
|
||||
|
@ -95,10 +95,10 @@ pub struct Fragment {
|
|||
pub node: OpaqueNode,
|
||||
|
||||
/// The CSS style of this fragment.
|
||||
pub style: StyleArc<ServoComputedValues>,
|
||||
pub style: StyleArc<ComputedValues>,
|
||||
|
||||
/// The CSS style of this fragment when it's selected
|
||||
pub selected_style: StyleArc<ServoComputedValues>,
|
||||
pub selected_style: StyleArc<ComputedValues>,
|
||||
|
||||
/// The position of this fragment relative to its owning flow. The size includes padding and
|
||||
/// border, but not margin.
|
||||
|
@ -676,8 +676,8 @@ impl Fragment {
|
|||
/// Constructs a new `Fragment` instance from an opaque node.
|
||||
pub fn from_opaque_node_and_style(node: OpaqueNode,
|
||||
pseudo: PseudoElementType<()>,
|
||||
style: StyleArc<ServoComputedValues>,
|
||||
selected_style: StyleArc<ServoComputedValues>,
|
||||
style: StyleArc<ComputedValues>,
|
||||
selected_style: StyleArc<ComputedValues>,
|
||||
mut restyle_damage: RestyleDamage,
|
||||
specific: SpecificFragmentInfo)
|
||||
-> Fragment {
|
||||
|
@ -706,7 +706,7 @@ impl Fragment {
|
|||
/// type. For the new anonymous fragment, layout-related values (border box, etc.) are reset to
|
||||
/// initial values.
|
||||
pub fn create_similar_anonymous_fragment(&self,
|
||||
style: StyleArc<ServoComputedValues>,
|
||||
style: StyleArc<ComputedValues>,
|
||||
specific: SpecificFragmentInfo)
|
||||
-> Fragment {
|
||||
let writing_mode = style.writing_mode;
|
||||
|
@ -1339,7 +1339,7 @@ impl Fragment {
|
|||
|
||||
// Return offset from original position because of `position: relative`.
|
||||
pub fn relative_position(&self, containing_block_size: &LogicalSize<Au>) -> LogicalSize<Au> {
|
||||
fn from_style(style: &ServoComputedValues, container_size: &LogicalSize<Au>)
|
||||
fn from_style(style: &ComputedValues, container_size: &LogicalSize<Au>)
|
||||
-> LogicalSize<Au> {
|
||||
let offsets = style.logical_position();
|
||||
let offset_i = if offsets.inline_start != LengthOrPercentageOrAuto::Auto {
|
||||
|
@ -1392,12 +1392,12 @@ impl Fragment {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn style(&self) -> &ServoComputedValues {
|
||||
pub fn style(&self) -> &ComputedValues {
|
||||
&*self.style
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn selected_style(&self) -> &ServoComputedValues {
|
||||
pub fn selected_style(&self) -> &ComputedValues {
|
||||
&*self.selected_style
|
||||
}
|
||||
|
||||
|
@ -2142,7 +2142,7 @@ impl Fragment {
|
|||
};
|
||||
return inline_metrics;
|
||||
|
||||
fn inline_metrics_of_block(flow: &FlowRef, style: &ServoComputedValues) -> InlineMetrics {
|
||||
fn inline_metrics_of_block(flow: &FlowRef, style: &ComputedValues) -> InlineMetrics {
|
||||
// CSS 2.1 § 10.8: "The height of each inline-level box in the line box is calculated.
|
||||
// For replaced elements, inline-block elements, and inline-table elements, this is the
|
||||
// height of their margin box."
|
||||
|
@ -2423,7 +2423,7 @@ impl Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) {
|
||||
pub fn repair_style(&mut self, new_style: &StyleArc<ComputedValues>) {
|
||||
self.style = (*new_style).clone()
|
||||
}
|
||||
|
||||
|
@ -3038,9 +3038,9 @@ pub struct InlineStyleIterator<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Iterator for InlineStyleIterator<'a> {
|
||||
type Item = &'a ServoComputedValues;
|
||||
type Item = &'a ComputedValues;
|
||||
|
||||
fn next(&mut self) -> Option<&'a ServoComputedValues> {
|
||||
fn next(&mut self) -> Option<&'a ComputedValues> {
|
||||
if !self.primary_style_yielded {
|
||||
self.primary_style_yielded = true;
|
||||
return Some(&*self.fragment.style)
|
||||
|
|
|
@ -18,7 +18,7 @@ use smallvec::SmallVec;
|
|||
use std::collections::{HashMap, LinkedList};
|
||||
use style::computed_values::{display, list_style_type};
|
||||
use style::computed_values::content::ContentItem;
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::selector_parser::RestyleDamage;
|
||||
use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
|
||||
use text::TextRunScanner;
|
||||
|
@ -298,7 +298,7 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
|
|||
self.incremented = true
|
||||
}
|
||||
|
||||
fn quote(&self, style: &ServoComputedValues, close: bool) -> String {
|
||||
fn quote(&self, style: &ComputedValues, close: bool) -> String {
|
||||
let quotes = &style.get_list().quotes;
|
||||
if quotes.0.is_empty() {
|
||||
return String::new()
|
||||
|
@ -368,7 +368,7 @@ impl Counter {
|
|||
layout_context: &LayoutContext,
|
||||
node: OpaqueNode,
|
||||
pseudo: PseudoElementType<()>,
|
||||
style: ::StyleArc<ServoComputedValues>,
|
||||
style: ::StyleArc<ComputedValues>,
|
||||
list_style_type: list_style_type::T,
|
||||
mode: RenderingMode)
|
||||
-> Option<SpecificFragmentInfo> {
|
||||
|
@ -431,7 +431,7 @@ struct CounterValue {
|
|||
fn render_text(layout_context: &LayoutContext,
|
||||
node: OpaqueNode,
|
||||
pseudo: PseudoElementType<()>,
|
||||
style: ::StyleArc<ServoComputedValues>,
|
||||
style: ::StyleArc<ComputedValues>,
|
||||
string: String)
|
||||
-> Option<SpecificFragmentInfo> {
|
||||
let mut fragments = LinkedList::new();
|
||||
|
|
|
@ -33,7 +33,7 @@ use std::sync::Arc;
|
|||
use style::computed_values::{display, overflow_x, position, text_align, text_justify};
|
||||
use style::computed_values::{vertical_align, white_space};
|
||||
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::{longhands, ServoComputedValues};
|
||||
use style::properties::{longhands, ComputedValues};
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION, RESOLVE_GENERATED_CONTENT};
|
||||
use text;
|
||||
use unicode_bidi as bidi;
|
||||
|
@ -1106,7 +1106,7 @@ impl InlineFlow {
|
|||
/// Computes the minimum metrics for each line. This is done during flow construction.
|
||||
///
|
||||
/// `style` is the style of the block.
|
||||
pub fn minimum_line_metrics(&self, font_context: &mut FontContext, style: &ServoComputedValues)
|
||||
pub fn minimum_line_metrics(&self, font_context: &mut FontContext, style: &ComputedValues)
|
||||
-> LineMetrics {
|
||||
InlineFlow::minimum_line_metrics_for_fragments(&self.fragments.fragments,
|
||||
font_context,
|
||||
|
@ -1119,7 +1119,7 @@ impl InlineFlow {
|
|||
/// `style` is the style of the block that these fragments belong to.
|
||||
pub fn minimum_line_metrics_for_fragments(fragments: &[Fragment],
|
||||
font_context: &mut FontContext,
|
||||
style: &ServoComputedValues)
|
||||
style: &ComputedValues)
|
||||
-> LineMetrics {
|
||||
// As a special case, if this flow contains only hypothetical fragments, then the entire
|
||||
// flow is hypothetical and takes up no space. See CSS 2.1 § 10.3.7.
|
||||
|
@ -1665,7 +1665,7 @@ impl Flow for InlineFlow {
|
|||
self.build_display_list_for_inline(state);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, _: &StyleArc<ServoComputedValues>) {}
|
||||
fn repair_style(&mut self, _: &StyleArc<ComputedValues>) {}
|
||||
|
||||
fn compute_overflow(&self) -> Overflow {
|
||||
let mut overflow = Overflow::new();
|
||||
|
@ -1754,8 +1754,8 @@ impl fmt::Debug for InlineFlow {
|
|||
#[derive(Clone)]
|
||||
pub struct InlineFragmentNodeInfo {
|
||||
pub address: OpaqueNode,
|
||||
pub style: StyleArc<ServoComputedValues>,
|
||||
pub selected_style: StyleArc<ServoComputedValues>,
|
||||
pub style: StyleArc<ComputedValues>,
|
||||
pub selected_style: StyleArc<ComputedValues>,
|
||||
pub pseudo: PseudoElementType<()>,
|
||||
pub flags: InlineFragmentNodeFlags,
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ use generated_content;
|
|||
use inline::InlineFlow;
|
||||
use style::computed_values::{list_style_type, position};
|
||||
use style::logical_geometry::LogicalSize;
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
|
||||
|
||||
/// A block with the CSS `display` property equal to `list-item`.
|
||||
|
@ -147,7 +147,7 @@ impl Flow for ListItemFlow {
|
|||
self.block_flow.collect_stacking_contexts(state);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) {
|
||||
self.block_flow.repair_style(new_style)
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::cmp::{max, min};
|
|||
use std::fmt;
|
||||
use style::computed_values::transform::ComputedMatrix;
|
||||
use style::logical_geometry::{LogicalMargin, WritingMode};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{BorderCornerRadius, LengthOrPercentageOrAuto};
|
||||
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone};
|
||||
|
||||
|
@ -481,7 +481,7 @@ pub fn specified_border_radius(
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn padding_from_style(style: &ServoComputedValues,
|
||||
pub fn padding_from_style(style: &ComputedValues,
|
||||
containing_block_inline_size: Au,
|
||||
writing_mode: WritingMode)
|
||||
-> LogicalMargin<Au> {
|
||||
|
@ -498,7 +498,7 @@ pub fn padding_from_style(style: &ServoComputedValues,
|
|||
///
|
||||
/// This is used when calculating intrinsic inline sizes.
|
||||
#[inline]
|
||||
pub fn specified_margin_from_style(style: &ServoComputedValues,
|
||||
pub fn specified_margin_from_style(style: &ComputedValues,
|
||||
writing_mode: WritingMode) -> LogicalMargin<Au> {
|
||||
let margin_style = style.get_margin();
|
||||
LogicalMargin::from_physical(writing_mode, SideOffsets2D::new(
|
||||
|
|
|
@ -20,7 +20,7 @@ use std::cmp::{min, max};
|
|||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use style::logical_geometry::LogicalSize;
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::Either;
|
||||
use style::values::computed::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
||||
|
||||
|
@ -193,7 +193,7 @@ impl Flow for MulticolFlow {
|
|||
self.block_flow.collect_stacking_contexts(state);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) {
|
||||
fn repair_style(&mut self, new_style: &StyleArc<ComputedValues>) {
|
||||
self.block_flow.repair_style(new_style)
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ impl Flow for MulticolColumnFlow {
|
|||
self.block_flow.collect_stacking_contexts(state);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) {
|
||||
fn repair_style(&mut self, new_style: &StyleArc<ComputedValues>) {
|
||||
self.block_flow.repair_style(new_style)
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ use std::fmt;
|
|||
use style::computed_values::{border_collapse, border_spacing, table_layout};
|
||||
use style::context::SharedStyleContext;
|
||||
use style::logical_geometry::LogicalSize;
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
|
||||
use style::values::CSSFloat;
|
||||
use style::values::computed::LengthOrPercentageOrAuto;
|
||||
|
@ -506,7 +506,7 @@ impl Flow for TableFlow {
|
|||
self.block_flow.collect_stacking_contexts(state);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) {
|
||||
self.block_flow.repair_style(new_style)
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
|||
use gfx_traits::print_tree::PrintTree;
|
||||
use std::fmt;
|
||||
use style::logical_geometry::LogicalSize;
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
|
||||
/// A table formatting context.
|
||||
pub struct TableCaptionFlow {
|
||||
|
@ -83,7 +83,7 @@ impl Flow for TableCaptionFlow {
|
|||
self.block_flow.collect_stacking_contexts(state);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) {
|
||||
self.block_flow.repair_style(new_style)
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode;
|
|||
use std::fmt;
|
||||
use style::computed_values::{border_collapse, border_top_style, vertical_align};
|
||||
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::Color;
|
||||
use table::InternalTable;
|
||||
use table_row::{CollapsedBorder, CollapsedBorderProvenance};
|
||||
|
@ -263,7 +263,7 @@ impl Flow for TableCellFlow {
|
|||
self.block_flow.collect_stacking_contexts(state);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) {
|
||||
self.block_flow.repair_style(new_style)
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use layout_debug;
|
|||
use std::cmp::max;
|
||||
use std::fmt;
|
||||
use style::logical_geometry::LogicalSize;
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::LengthOrPercentageOrAuto;
|
||||
|
||||
/// A table formatting context.
|
||||
|
@ -94,7 +94,7 @@ impl Flow for TableColGroupFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self, _: &mut DisplayListBuildState) {}
|
||||
|
||||
fn repair_style(&mut self, _: &::StyleArc<ServoComputedValues>) {}
|
||||
fn repair_style(&mut self, _: &::StyleArc<ComputedValues>) {}
|
||||
|
||||
fn compute_overflow(&self) -> Overflow {
|
||||
Overflow::new()
|
||||
|
|
|
@ -23,7 +23,7 @@ use std::fmt;
|
|||
use std::iter::{Enumerate, IntoIterator, Peekable};
|
||||
use style::computed_values::{border_collapse, border_spacing, border_top_style};
|
||||
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
|
||||
use style::values::computed::{Color, LengthOrPercentageOrAuto};
|
||||
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
|
||||
|
@ -481,7 +481,7 @@ impl Flow for TableRowFlow {
|
|||
self.block_flow.collect_stacking_contexts(state);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) {
|
||||
self.block_flow.repair_style(new_style)
|
||||
}
|
||||
|
||||
|
@ -612,7 +612,7 @@ impl CollapsedBorder {
|
|||
|
||||
/// Creates a collapsed border from the block-start border described in the given CSS style
|
||||
/// object.
|
||||
fn top(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
|
||||
fn top(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
|
||||
-> CollapsedBorder {
|
||||
CollapsedBorder {
|
||||
style: css_style.get_border().border_top_style,
|
||||
|
@ -624,7 +624,7 @@ impl CollapsedBorder {
|
|||
|
||||
/// Creates a collapsed border style from the right border described in the given CSS style
|
||||
/// object.
|
||||
fn right(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
|
||||
fn right(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
|
||||
-> CollapsedBorder {
|
||||
CollapsedBorder {
|
||||
style: css_style.get_border().border_right_style,
|
||||
|
@ -636,7 +636,7 @@ impl CollapsedBorder {
|
|||
|
||||
/// Creates a collapsed border style from the bottom border described in the given CSS style
|
||||
/// object.
|
||||
fn bottom(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
|
||||
fn bottom(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
|
||||
-> CollapsedBorder {
|
||||
CollapsedBorder {
|
||||
style: css_style.get_border().border_bottom_style,
|
||||
|
@ -648,7 +648,7 @@ impl CollapsedBorder {
|
|||
|
||||
/// Creates a collapsed border style from the left border described in the given CSS style
|
||||
/// object.
|
||||
fn left(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
|
||||
fn left(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
|
||||
-> CollapsedBorder {
|
||||
CollapsedBorder {
|
||||
style: css_style.get_border().border_left_style,
|
||||
|
@ -660,7 +660,7 @@ impl CollapsedBorder {
|
|||
|
||||
/// Creates a collapsed border style from the given physical side.
|
||||
fn from_side(side: PhysicalSide,
|
||||
css_style: &ServoComputedValues,
|
||||
css_style: &ComputedValues,
|
||||
provenance: CollapsedBorderProvenance)
|
||||
-> CollapsedBorder {
|
||||
match side {
|
||||
|
@ -673,7 +673,7 @@ impl CollapsedBorder {
|
|||
|
||||
/// Creates a collapsed border style from the inline-start border described in the given CSS
|
||||
/// style object.
|
||||
pub fn inline_start(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
|
||||
pub fn inline_start(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
|
||||
-> CollapsedBorder {
|
||||
CollapsedBorder::from_side(css_style.writing_mode.inline_start_physical_side(),
|
||||
css_style,
|
||||
|
@ -682,7 +682,7 @@ impl CollapsedBorder {
|
|||
|
||||
/// Creates a collapsed border style from the inline-start border described in the given CSS
|
||||
/// style object.
|
||||
pub fn inline_end(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
|
||||
pub fn inline_end(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
|
||||
-> CollapsedBorder {
|
||||
CollapsedBorder::from_side(css_style.writing_mode.inline_end_physical_side(),
|
||||
css_style,
|
||||
|
@ -691,7 +691,7 @@ impl CollapsedBorder {
|
|||
|
||||
/// Creates a collapsed border style from the block-start border described in the given CSS
|
||||
/// style object.
|
||||
pub fn block_start(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
|
||||
pub fn block_start(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
|
||||
-> CollapsedBorder {
|
||||
CollapsedBorder::from_side(css_style.writing_mode.block_start_physical_side(),
|
||||
css_style,
|
||||
|
@ -700,7 +700,7 @@ impl CollapsedBorder {
|
|||
|
||||
/// Creates a collapsed border style from the block-end border described in the given CSS style
|
||||
/// object.
|
||||
pub fn block_end(css_style: &ServoComputedValues, provenance: CollapsedBorderProvenance)
|
||||
pub fn block_end(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
|
||||
-> CollapsedBorder {
|
||||
CollapsedBorder::from_side(css_style.writing_mode.block_end_physical_side(),
|
||||
css_style,
|
||||
|
@ -909,7 +909,7 @@ pub struct BorderCollapseInfoForChildTableCell<'a> {
|
|||
/// table row. This is done eagerly here so that at least the inline inside border collapse
|
||||
/// computations can be parallelized across all the rows of the table.
|
||||
fn perform_inline_direction_border_collapse_for_row(
|
||||
row_style: &ServoComputedValues,
|
||||
row_style: &ComputedValues,
|
||||
children_count: usize,
|
||||
child_index: usize,
|
||||
child_table_cell: &mut TableCellFlow,
|
||||
|
|
|
@ -20,7 +20,7 @@ use std::fmt;
|
|||
use std::iter::{IntoIterator, Iterator, Peekable};
|
||||
use style::computed_values::{border_collapse, border_spacing};
|
||||
use style::logical_geometry::LogicalSize;
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use table::{ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow};
|
||||
|
||||
/// A table formatting context.
|
||||
|
@ -185,7 +185,7 @@ impl Flow for TableRowGroupFlow {
|
|||
self.block_flow.collect_stacking_contexts(state);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) {
|
||||
self.block_flow.repair_style(new_style)
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ use std::ops::Add;
|
|||
use style::computed_values::{border_collapse, position, table_layout};
|
||||
use style::context::SharedStyleContext;
|
||||
use style::logical_geometry::{LogicalRect, LogicalSize};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::CSSFloat;
|
||||
use style::values::computed::LengthOrPercentageOrAuto;
|
||||
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize};
|
||||
|
@ -466,7 +466,7 @@ impl Flow for TableWrapperFlow {
|
|||
self.block_flow.collect_stacking_contexts(state);
|
||||
}
|
||||
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
|
||||
fn repair_style(&mut self, new_style: &::StyleArc<ComputedValues>) {
|
||||
self.block_flow.repair_style(new_style)
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ use std::sync::Arc;
|
|||
use style::computed_values::{text_rendering, text_transform};
|
||||
use style::computed_values::{word_break, white_space};
|
||||
use style::logical_geometry::{LogicalSize, WritingMode};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::properties::ComputedValues;
|
||||
use style::properties::style_structs;
|
||||
use style::values::generics::text::LineHeight;
|
||||
use unicode_bidi as bidi;
|
||||
|
@ -445,7 +445,7 @@ pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: ::Styl
|
|||
}
|
||||
|
||||
/// Returns the line block-size needed by the given computed style and font size.
|
||||
pub fn line_height_from_style(style: &ServoComputedValues, metrics: &FontMetrics) -> Au {
|
||||
pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) -> Au {
|
||||
let font_size = style.get_font().font_size;
|
||||
match style.get_inheritedtext().line_height {
|
||||
LineHeight::Normal => metrics.line_gap,
|
||||
|
|
|
@ -78,7 +78,7 @@ use style::selector_parser::{AttrValue as SelectorAttrValue, NonTSPseudoClass, P
|
|||
use style::selector_parser::{PseudoElement, SelectorImpl, extended_filtering};
|
||||
use style::shared_lock::{SharedRwLock as StyleSharedRwLock, Locked as StyleLocked};
|
||||
use style::str::is_whitespace;
|
||||
use style::stylearc::Arc;
|
||||
use style::stylearc::{Arc, ArcBorrow};
|
||||
|
||||
pub unsafe fn drop_style_and_layout_data(data: OpaqueStyleAndLayoutData) {
|
||||
let ptr: *mut StyleData = data.ptr.get();
|
||||
|
@ -412,9 +412,9 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
|||
ServoLayoutNode::from_layout_js(self.element.upcast())
|
||||
}
|
||||
|
||||
fn style_attribute(&self) -> Option<&Arc<StyleLocked<PropertyDeclarationBlock>>> {
|
||||
fn style_attribute(&self) -> Option<ArcBorrow<StyleLocked<PropertyDeclarationBlock>>> {
|
||||
unsafe {
|
||||
(*self.element.style_attribute()).as_ref()
|
||||
(*self.element.style_attribute()).as_ref().map(|x| x.borrow_arc())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,13 +90,15 @@ impl CSSRuleList {
|
|||
let index = idx as usize;
|
||||
|
||||
let parent_stylesheet = self.parent_stylesheet.style_stylesheet();
|
||||
let new_rule =
|
||||
css_rules.insert_rule(&parent_stylesheet.shared_lock,
|
||||
rule,
|
||||
&parent_stylesheet.contents,
|
||||
index,
|
||||
nested,
|
||||
None)?;
|
||||
let new_rule = css_rules.with_raw_offset_arc(|arc| {
|
||||
arc.insert_rule(&parent_stylesheet.shared_lock,
|
||||
rule,
|
||||
&parent_stylesheet.contents,
|
||||
index,
|
||||
nested,
|
||||
None)
|
||||
})?;
|
||||
|
||||
|
||||
let parent_stylesheet = &*self.parent_stylesheet;
|
||||
let dom_rule = CSSRule::new_specific(&window, parent_stylesheet, new_rule);
|
||||
|
|
|
@ -22,7 +22,7 @@ use style::data::ElementData;
|
|||
use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthesizer, TNode};
|
||||
use style::dom::OpaqueNode;
|
||||
use style::font_metrics::ServoMetricsProvider;
|
||||
use style::properties::{CascadeFlags, ServoComputedValues};
|
||||
use style::properties::{CascadeFlags, ComputedValues};
|
||||
use style::selector_parser::{PseudoElement, PseudoElementCascadeType, SelectorImpl};
|
||||
use style::stylearc::Arc;
|
||||
use style::stylist::RuleInclusion;
|
||||
|
@ -181,7 +181,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo
|
|||
/// it can be used to reach siblings and cousins. A simple immutable borrow
|
||||
/// of the parent data is fine, since the bottom-up traversal will not process
|
||||
/// the parent until all the children have been processed.
|
||||
fn parent_style(&self) -> Arc<ServoComputedValues>;
|
||||
fn parent_style(&self) -> Arc<ComputedValues>;
|
||||
|
||||
#[inline]
|
||||
fn is_element_or_elements_pseudo(&self) -> bool {
|
||||
|
@ -223,7 +223,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo
|
|||
|
||||
fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData>;
|
||||
|
||||
fn style(&self, context: &SharedStyleContext) -> Arc<ServoComputedValues> {
|
||||
fn style(&self, context: &SharedStyleContext) -> Arc<ComputedValues> {
|
||||
if let Some(el) = self.as_element() {
|
||||
el.style(context)
|
||||
} else {
|
||||
|
@ -234,7 +234,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo
|
|||
}
|
||||
}
|
||||
|
||||
fn selected_style(&self) -> Arc<ServoComputedValues> {
|
||||
fn selected_style(&self) -> Arc<ComputedValues> {
|
||||
if let Some(el) = self.as_element() {
|
||||
el.selected_style()
|
||||
} else {
|
||||
|
@ -393,7 +393,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
|||
///
|
||||
/// Unlike the version on TNode, this handles pseudo-elements.
|
||||
#[inline]
|
||||
fn style(&self, context: &SharedStyleContext) -> Arc<ServoComputedValues> {
|
||||
fn style(&self, context: &SharedStyleContext) -> Arc<ComputedValues> {
|
||||
let data = self.style_data();
|
||||
match self.get_pseudo_element_type() {
|
||||
PseudoElementType::Normal => {
|
||||
|
@ -416,7 +416,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
|||
&style_pseudo,
|
||||
Some(data.styles.primary()),
|
||||
CascadeFlags::empty(),
|
||||
&ServoMetricsProvider)
|
||||
&ServoMetricsProvider, (), ())
|
||||
.clone()
|
||||
}
|
||||
PseudoElementCascadeType::Lazy => {
|
||||
|
@ -428,7 +428,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
|||
RuleInclusion::All,
|
||||
data.styles.primary(),
|
||||
/* is_probe = */ false,
|
||||
&ServoMetricsProvider)
|
||||
&ServoMetricsProvider, (), ())
|
||||
.unwrap()
|
||||
.clone()
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn selected_style(&self) -> Arc<ServoComputedValues> {
|
||||
fn selected_style(&self) -> Arc<ComputedValues> {
|
||||
let data = self.style_data();
|
||||
data.styles.pseudos
|
||||
.get(&PseudoElement::Selection).map(|s| s)
|
||||
|
@ -454,7 +454,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
|||
/// This should be used just for querying layout, or when we know the
|
||||
/// element style is precomputed, not from general layout itself.
|
||||
#[inline]
|
||||
fn resolved_style(&self) -> Arc<ServoComputedValues> {
|
||||
fn resolved_style(&self) -> Arc<ComputedValues> {
|
||||
let data = self.style_data();
|
||||
match self.get_pseudo_element_type() {
|
||||
PseudoElementType::Normal
|
||||
|
|
|
@ -194,6 +194,30 @@ impl<T> Arc<T> {
|
|||
p: NonZeroPtrMut::new(ptr as *mut ArcInner<T>),
|
||||
}
|
||||
}
|
||||
|
||||
/// Produce a pointer to the data that can be converted back
|
||||
/// to an arc
|
||||
pub fn borrow_arc<'a>(&'a self) -> ArcBorrow<'a, T> {
|
||||
ArcBorrow(&**self)
|
||||
}
|
||||
/// Temporarily converts |self| into a bonafide RawOffsetArc and exposes it to the
|
||||
/// provided callback. The refcount is not modified.
|
||||
#[inline(always)]
|
||||
pub fn with_raw_offset_arc<F, U>(&self, f: F) -> U
|
||||
where F: FnOnce(&RawOffsetArc<T>) -> U
|
||||
{
|
||||
// Synthesize transient Arc, which never touches the refcount of the ArcInner.
|
||||
let transient = unsafe { NoDrop::new(Arc::into_raw_offset(ptr::read(self))) };
|
||||
|
||||
// Expose the transient Arc to the callback, which may clone it if it wants.
|
||||
let result = f(&transient);
|
||||
|
||||
// Forget the transient Arc to leave the refcount untouched.
|
||||
mem::forget(transient);
|
||||
|
||||
// Forward the result.
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ?Sized> Arc<T> {
|
||||
|
@ -637,6 +661,8 @@ impl<H: 'static, T: 'static> ThinArc<H, T> {
|
|||
let result = f(&transient);
|
||||
|
||||
// Forget the transient Arc to leave the refcount untouched.
|
||||
// XXXManishearth this can be removed when unions stabilize,
|
||||
// since then NoDrop becomes zero overhead
|
||||
mem::forget(transient);
|
||||
|
||||
// Forward the result.
|
||||
|
@ -700,6 +726,193 @@ impl<H: PartialEq + 'static, T: PartialEq + 'static> PartialEq for ThinArc<H, T>
|
|||
|
||||
impl<H: Eq + 'static, T: Eq + 'static> Eq for ThinArc<H, T> {}
|
||||
|
||||
/// An Arc, except it holds a pointer to the T instead of to the
|
||||
/// entire ArcInner.
|
||||
///
|
||||
/// ```text
|
||||
/// Arc<T> RawOffsetArc<T>
|
||||
/// | |
|
||||
/// v v
|
||||
/// ---------------------
|
||||
/// | RefCount | T (data) | [ArcInner<T>]
|
||||
/// ---------------------
|
||||
/// ```
|
||||
///
|
||||
/// This means that this is a direct pointer to
|
||||
/// its contained data (and can be read from by both C++ and Rust),
|
||||
/// but we can also convert it to a "regular" Arc<T> by removing the offset
|
||||
#[derive(Eq)]
|
||||
pub struct RawOffsetArc<T: 'static> {
|
||||
ptr: NonZeroPtrMut<T>,
|
||||
}
|
||||
|
||||
unsafe impl<T: 'static + Sync + Send> Send for RawOffsetArc<T> {}
|
||||
unsafe impl<T: 'static + Sync + Send> Sync for RawOffsetArc<T> {}
|
||||
|
||||
impl<T: 'static> Deref for RawOffsetArc<T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe { &*self.ptr.ptr() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> Clone for RawOffsetArc<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Arc::into_raw_offset(self.clone_arc())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> Drop for RawOffsetArc<T> {
|
||||
fn drop(&mut self) {
|
||||
let _ = Arc::from_raw_offset(RawOffsetArc { ptr: self.ptr.clone() });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<T: fmt::Debug + 'static> fmt::Debug for RawOffsetArc<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Debug::fmt(&**self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: PartialEq> PartialEq for RawOffsetArc<T> {
|
||||
fn eq(&self, other: &RawOffsetArc<T>) -> bool {
|
||||
*(*self) == *(*other)
|
||||
}
|
||||
|
||||
fn ne(&self, other: &RawOffsetArc<T>) -> bool {
|
||||
*(*self) != *(*other)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> RawOffsetArc<T> {
|
||||
/// Temporarily converts |self| into a bonafide Arc and exposes it to the
|
||||
/// provided callback. The refcount is not modified.
|
||||
#[inline(always)]
|
||||
pub fn with_arc<F, U>(&self, f: F) -> U
|
||||
where F: FnOnce(&Arc<T>) -> U
|
||||
{
|
||||
// Synthesize transient Arc, which never touches the refcount of the ArcInner.
|
||||
let transient = unsafe { NoDrop::new(Arc::from_raw(self.ptr.ptr())) };
|
||||
|
||||
// Expose the transient Arc to the callback, which may clone it if it wants.
|
||||
let result = f(&transient);
|
||||
|
||||
// Forget the transient Arc to leave the refcount untouched.
|
||||
// XXXManishearth this can be removed when unions stabilize,
|
||||
// since then NoDrop becomes zero overhead
|
||||
mem::forget(transient);
|
||||
|
||||
// Forward the result.
|
||||
result
|
||||
}
|
||||
|
||||
/// If uniquely owned, provide a mutable reference
|
||||
/// Else create a copy, and mutate that
|
||||
pub fn make_mut(&mut self) -> &mut T where T: Clone {
|
||||
unsafe {
|
||||
// extract the RawOffsetArc as an owned variable
|
||||
let this = ptr::read(self);
|
||||
// treat it as a real Arc
|
||||
let mut arc = Arc::from_raw_offset(this);
|
||||
// obtain the mutable reference. Cast away the lifetime
|
||||
// This may mutate `arc`
|
||||
let ret = Arc::make_mut(&mut arc) as *mut _;
|
||||
// Store the possibly-mutated arc back inside, after converting
|
||||
// it to a RawOffsetArc again
|
||||
ptr::write(self, Arc::into_raw_offset(arc));
|
||||
&mut *ret
|
||||
}
|
||||
}
|
||||
|
||||
/// Clone it as an Arc
|
||||
pub fn clone_arc(&self) -> Arc<T> {
|
||||
RawOffsetArc::with_arc(self, |a| a.clone())
|
||||
}
|
||||
|
||||
/// Produce a pointer to the data that can be converted back
|
||||
/// to an arc
|
||||
pub fn borrow_arc<'a>(&'a self) -> ArcBorrow<'a, T> {
|
||||
ArcBorrow(&**self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> Arc<T> {
|
||||
/// Converts an Arc into a RawOffsetArc. This consumes the Arc, so the refcount
|
||||
/// is not modified.
|
||||
#[inline]
|
||||
pub fn into_raw_offset(a: Self) -> RawOffsetArc<T> {
|
||||
RawOffsetArc {
|
||||
ptr: NonZeroPtrMut::new(Arc::into_raw(a) as *mut T),
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts a RawOffsetArc into an Arc. This consumes the RawOffsetArc, so the refcount
|
||||
/// is not modified.
|
||||
#[inline]
|
||||
pub fn from_raw_offset(a: RawOffsetArc<T>) -> Self {
|
||||
let ptr = a.ptr.ptr();
|
||||
mem::forget(a);
|
||||
unsafe { Arc::from_raw(ptr) }
|
||||
}
|
||||
}
|
||||
|
||||
/// A "borrowed Arc". This is a pointer to
|
||||
/// a T that is known to have been allocated within an
|
||||
/// Arc.
|
||||
///
|
||||
/// This is equivalent in guarantees to `&Arc<T>`, however it is
|
||||
/// a bit more flexible. To obtain an `&Arc<T>` you must have
|
||||
/// an Arc<T> instance somewhere pinned down until we're done with it.
|
||||
///
|
||||
/// However, Gecko hands us refcounted things as pointers to T directly,
|
||||
/// so we have to conjure up a temporary Arc on the stack each time. The
|
||||
/// same happens for when the object is managed by a RawOffsetArc.
|
||||
///
|
||||
/// ArcBorrow lets us deal with borrows of known-refcounted objects
|
||||
/// without needing to worry about how they're actually stored.
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct ArcBorrow<'a, T: 'a>(&'a T);
|
||||
|
||||
impl<'a, T> Copy for ArcBorrow<'a, T> {}
|
||||
impl<'a, T> Clone for ArcBorrow<'a, T> {
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> ArcBorrow<'a, T> {
|
||||
pub fn clone_arc(&self) -> Arc<T> {
|
||||
let arc = unsafe { Arc::from_raw(self.0) };
|
||||
// addref it!
|
||||
mem::forget(arc.clone());
|
||||
arc
|
||||
}
|
||||
|
||||
pub fn with_arc<F, U>(&self, f: F) -> U where F: FnOnce(&Arc<T>) -> U, T: 'static {
|
||||
// Synthesize transient Arc, which never touches the refcount.
|
||||
let transient = unsafe { NoDrop::new(Arc::from_raw(self.0)) };
|
||||
|
||||
// Expose the transient Arc to the callback, which may clone it if it wants.
|
||||
let result = f(&transient);
|
||||
|
||||
// Forget the transient Arc to leave the refcount untouched.
|
||||
// XXXManishearth this can be removed when unions stabilize,
|
||||
// since then NoDrop becomes zero overhead
|
||||
mem::forget(transient);
|
||||
|
||||
// Forward the result.
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> Deref for ArcBorrow<'a, T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &T {
|
||||
&*self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::clone::Clone;
|
||||
|
|
|
@ -11,7 +11,7 @@ use context::SharedStyleContext;
|
|||
use dom::OpaqueNode;
|
||||
use euclid::Point2D;
|
||||
use font_metrics::FontMetricsProvider;
|
||||
use properties::{self, CascadeFlags, ComputedValues, Importance};
|
||||
use properties::{self, CascadeFlags, ComputedValues, ComputedValuesInner, Importance};
|
||||
use properties::animated_properties::{AnimatableLonghand, AnimatedProperty, TransitionProperty};
|
||||
use properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection;
|
||||
use properties::longhands::animation_iteration_count::single_value::computed_value::T as AnimationIterationCount;
|
||||
|
@ -347,8 +347,8 @@ impl PropertyAnimation {
|
|||
fn from_animatable_longhand(animatable_longhand: &AnimatableLonghand,
|
||||
timing_function: TimingFunction,
|
||||
duration: Time,
|
||||
old_style: &ComputedValues,
|
||||
new_style: &ComputedValues)
|
||||
old_style: &ComputedValuesInner,
|
||||
new_style: &ComputedValuesInner)
|
||||
-> Option<PropertyAnimation> {
|
||||
let animated_property = AnimatedProperty::from_animatable_longhand(animatable_longhand,
|
||||
old_style,
|
||||
|
@ -480,10 +480,10 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation>
|
|||
|
||||
fn compute_style_for_animation_step(context: &SharedStyleContext,
|
||||
step: &KeyframesStep,
|
||||
previous_style: &ComputedValues,
|
||||
style_from_cascade: &ComputedValues,
|
||||
previous_style: &ComputedValuesInner,
|
||||
style_from_cascade: &ComputedValuesInner,
|
||||
font_metrics_provider: &FontMetricsProvider)
|
||||
-> ComputedValues {
|
||||
-> ComputedValuesInner {
|
||||
match step.value {
|
||||
KeyframesStepValue::ComputedValues => style_from_cascade.clone(),
|
||||
KeyframesStepValue::Declarations { block: ref declarations } => {
|
||||
|
|
|
@ -15,7 +15,7 @@ use data::ElementData;
|
|||
use element_state::ElementState;
|
||||
use font_metrics::FontMetricsProvider;
|
||||
use media_queries::Device;
|
||||
use properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock};
|
||||
use properties::{AnimationRules, ComputedValues, ComputedValuesInner, PropertyDeclarationBlock};
|
||||
#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValue;
|
||||
#[cfg(feature = "gecko")] use properties::animated_properties::TransitionProperty;
|
||||
use rule_tree::CascadeLevel;
|
||||
|
@ -30,7 +30,7 @@ use std::fmt;
|
|||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use std::ops::Deref;
|
||||
use stylearc::Arc;
|
||||
use stylearc::{Arc, ArcBorrow};
|
||||
use stylist::Stylist;
|
||||
use thread_state;
|
||||
|
||||
|
@ -360,7 +360,7 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
|
|||
}
|
||||
|
||||
/// Get this element's style attribute.
|
||||
fn style_attribute(&self) -> Option<&Arc<Locked<PropertyDeclarationBlock>>>;
|
||||
fn style_attribute(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>;
|
||||
|
||||
/// Unset the style attribute's dirty bit.
|
||||
/// Servo doesn't need to manage ditry bit for style attribute.
|
||||
|
@ -368,7 +368,7 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
|
|||
}
|
||||
|
||||
/// Get this element's SMIL override declarations.
|
||||
fn get_smil_override(&self) -> Option<&Arc<Locked<PropertyDeclarationBlock>>> {
|
||||
fn get_smil_override(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
|
|||
fn may_generate_pseudo(
|
||||
&self,
|
||||
pseudo: &PseudoElement,
|
||||
_primary_style: &ComputedValues,
|
||||
_primary_style: &ComputedValuesInner,
|
||||
) -> bool {
|
||||
// ::before/::after are always supported for now, though we could try to
|
||||
// optimize out leaf elements.
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
use gecko_bindings::bindings::{RawServoImportRule, RawServoSupportsRule};
|
||||
use gecko_bindings::bindings::{RawServoKeyframe, RawServoKeyframesRule};
|
||||
use gecko_bindings::bindings::{RawServoNamespaceRule, RawServoPageRule};
|
||||
use gecko_bindings::bindings::{RawServoRuleNode, RawServoRuleNodeStrong, RawServoDocumentRule, RawServoMediaRule};
|
||||
use gecko_bindings::bindings::{ServoComputedValues, ServoCssRules};
|
||||
use gecko_bindings::bindings::{RawServoMediaRule, RawServoNamespaceRule, RawServoPageRule};
|
||||
use gecko_bindings::bindings::{RawServoRuleNode, RawServoRuleNodeStrong, RawServoDocumentRule};
|
||||
use gecko_bindings::bindings::ServoCssRules;
|
||||
use gecko_bindings::structs::{RawServoAnimationValue, RawServoDeclarationBlock, RawServoStyleRule, RawServoMediaList};
|
||||
use gecko_bindings::structs::RawServoStyleSheetContents;
|
||||
use gecko_bindings::structs::{RawServoStyleSheetContents, ServoStyleContext};
|
||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI};
|
||||
use media_queries::MediaList;
|
||||
use properties::{ComputedValues, PropertyDeclarationBlock};
|
||||
|
@ -51,8 +51,8 @@ impl_arc_ffi!(Locked<CssRules> => ServoCssRules
|
|||
impl_arc_ffi!(StylesheetContents => RawServoStyleSheetContents
|
||||
[Servo_StyleSheetContents_AddRef, Servo_StyleSheetContents_Release]);
|
||||
|
||||
impl_arc_ffi!(ComputedValues => ServoComputedValues
|
||||
[Servo_ComputedValues_AddRef, Servo_ComputedValues_Release]);
|
||||
impl_arc_ffi!(ComputedValues => ServoStyleContext
|
||||
[Servo_StyleContext_AddRef, Servo_StyleContext_Release]);
|
||||
|
||||
impl_arc_ffi!(Locked<PropertyDeclarationBlock> => RawServoDeclarationBlock
|
||||
[Servo_DeclarationBlock_AddRef, Servo_DeclarationBlock_Release]);
|
||||
|
|
|
@ -16,7 +16,7 @@ use gecko_bindings::structs::nsIDocument;
|
|||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||
use invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
||||
use media_queries::{Device, MediaList};
|
||||
use properties::ComputedValues;
|
||||
use properties::ComputedValuesInner;
|
||||
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
|
||||
use stylearc::Arc;
|
||||
use stylesheet_set::StylesheetSet;
|
||||
|
@ -188,8 +188,8 @@ impl PerDocumentStyleDataImpl {
|
|||
}
|
||||
|
||||
/// Get the default computed values for this document.
|
||||
pub fn default_computed_values(&self) -> &Arc<ComputedValues> {
|
||||
self.stylist.device().default_computed_values_arc()
|
||||
pub fn default_computed_values(&self) -> &ComputedValuesInner {
|
||||
self.stylist.device().default_computed_values()
|
||||
}
|
||||
|
||||
/// Clear the stylist. This will be a no-op if the stylist is
|
||||
|
|
|
@ -5,6 +5,10 @@ use gecko_bindings::structs::nsStyleTransformMatrix;
|
|||
use gecko_bindings::structs::nsTArray;
|
||||
type nsACString_internal = nsACString;
|
||||
type nsAString_internal = nsAString;
|
||||
pub type ServoStyleContextBorrowed<'a> = &'a ServoStyleContext;
|
||||
pub type ServoStyleContextBorrowedOrNull<'a> = Option<&'a ::properties::ComputedValues>;
|
||||
pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues;
|
||||
pub type ServoComputedValuesBorrowedOrNull<'a> = Option<&'a ServoComputedValues>;
|
||||
use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue;
|
||||
use gecko_bindings::structs::mozilla::css::ErrorReporter;
|
||||
use gecko_bindings::structs::mozilla::css::ImageValue;
|
||||
|
@ -215,6 +219,9 @@ use gecko_bindings::structs::nsresult;
|
|||
use gecko_bindings::structs::Loader;
|
||||
use gecko_bindings::structs::LoaderReusableStyleSheets;
|
||||
use gecko_bindings::structs::ServoStyleSheet;
|
||||
use gecko_bindings::structs::ServoComputedValues;
|
||||
use gecko_bindings::structs::ServoStyleContext;
|
||||
use gecko_bindings::structs::ServoStyleContextStrong;
|
||||
use gecko_bindings::structs::EffectCompositor_CascadeLevel;
|
||||
use gecko_bindings::structs::UpdateAnimationsTasks;
|
||||
use gecko_bindings::structs::ParsingMode;
|
||||
|
@ -314,11 +321,6 @@ pub struct ServoCssRules(ServoCssRulesVoid);
|
|||
pub type RawServoStyleSheetContentsStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoStyleSheetContents>;
|
||||
pub type RawServoStyleSheetContentsBorrowed<'a> = &'a RawServoStyleSheetContents;
|
||||
pub type RawServoStyleSheetContentsBorrowedOrNull<'a> = Option<&'a RawServoStyleSheetContents>;
|
||||
pub type ServoComputedValuesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoComputedValues>;
|
||||
pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues;
|
||||
pub type ServoComputedValuesBorrowedOrNull<'a> = Option<&'a ServoComputedValues>;
|
||||
enum ServoComputedValuesVoid { }
|
||||
pub struct ServoComputedValues(ServoComputedValuesVoid);
|
||||
pub type RawServoDeclarationBlockStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoDeclarationBlock>;
|
||||
pub type RawServoDeclarationBlockBorrowed<'a> = &'a RawServoDeclarationBlock;
|
||||
pub type RawServoDeclarationBlockBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlock>;
|
||||
|
@ -399,12 +401,6 @@ extern "C" {
|
|||
pub fn Servo_StyleSheetContents_Release(ptr:
|
||||
RawServoStyleSheetContentsBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_AddRef(ptr: ServoComputedValuesBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_Release(ptr: ServoComputedValuesBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_DeclarationBlock_AddRef(ptr:
|
||||
RawServoDeclarationBlockBorrowed);
|
||||
|
@ -528,6 +524,19 @@ extern "C" {
|
|||
pub fn Gecko_DestroyAnonymousContentList(anon_content:
|
||||
*mut nsTArray<*mut nsIContent>);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ServoStyleContext_Init(context: *mut ServoStyleContext,
|
||||
parent_context:
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed,
|
||||
values: ServoComputedValuesBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ServoStyleContext_Destroy(context: *mut ServoStyleContext);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ConstructStyleChildrenIterator(aElement:
|
||||
RawGeckoElementBorrowed,
|
||||
|
@ -755,9 +764,9 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_UpdateAnimations(aElementOrPseudo: RawGeckoElementBorrowed,
|
||||
aOldComputedValues:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
aComputedValues:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
aTasks: UpdateAnimationsTasks);
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -1957,10 +1966,10 @@ extern "C" {
|
|||
pub fn Servo_StyleSet_ResolveForDeclarations(set:
|
||||
RawServoStyleSetBorrowed,
|
||||
parent_style:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
declarations:
|
||||
RawServoDeclarationBlockBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_MightHaveAttributeDependency(set:
|
||||
|
@ -2661,23 +2670,22 @@ extern "C" {
|
|||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
pseudo_type:
|
||||
CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
set:
|
||||
RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_Inherit(set: RawServoStyleSetBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
parent_style:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
target: InheritTarget)
|
||||
-> ServoComputedValuesStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_GetVisitedStyle(values:
|
||||
ServoComputedValuesBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_GetStyleBits(values:
|
||||
|
@ -2697,6 +2705,16 @@ extern "C" {
|
|||
rules:
|
||||
RawGeckoServoStyleRuleListBorrowedMut);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleContext_NewContext(values: ServoComputedValuesBorrowed,
|
||||
parent:
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom)
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_Initialize(dummy_url_data: *mut RawGeckoURLExtraData);
|
||||
}
|
||||
|
@ -2716,20 +2734,22 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
||||
set: RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
is_probe: bool,
|
||||
pseudo_tag: *mut nsIAtom, is_probe: bool,
|
||||
inherited_style:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
parent_style_context:
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
set: RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_SetExplicitStyle(element: RawGeckoElementBorrowed,
|
||||
primary_style: ServoComputedValuesBorrowed);
|
||||
primary_style: ServoStyleContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_HasAuthorSpecifiedRules(element: RawGeckoElementBorrowed,
|
||||
|
@ -2739,11 +2759,14 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
parent_style_context:
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
rule_inclusion: StyleRuleInclusion,
|
||||
snapshots:
|
||||
*const ServoElementSnapshotTable,
|
||||
set: RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
|
||||
|
@ -2765,12 +2788,12 @@ extern "C" {
|
|||
element:
|
||||
RawGeckoElementBorrowed,
|
||||
existing_style:
|
||||
ServoComputedValuesBorrowed,
|
||||
ServoStyleContextBorrowed,
|
||||
snapshots:
|
||||
*const ServoElementSnapshotTable,
|
||||
pseudo_type:
|
||||
CSSPseudoElementType)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_SerializeFontValueForCanvas(declarations:
|
||||
|
@ -2794,124 +2817,7 @@ extern "C" {
|
|||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleFont(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleFont;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleColor(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleColor;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleList(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleList;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleText(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleText;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleVisibility(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleVisibility;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleUserInterface(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleUserInterface;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleTableBorder(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleTableBorder;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleSVG(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleSVG;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleVariables(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleVariables;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleBackground(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleBackground;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStylePosition(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStylePosition;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleTextReset(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleTextReset;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleDisplay(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleDisplay;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleContent(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleContent;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleUIReset(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleUIReset;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleTable(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleTable;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleMargin(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleMargin;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStylePadding(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStylePadding;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleBorder(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleBorder;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleOutline(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleOutline;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleXUL(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleXUL;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleSVGReset(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleSVGReset;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleColumn(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleColumn;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleEffects(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleEffects;
|
||||
pub fn Servo_GetEmptyVariables() -> *const nsStyleVariables;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CreateCSSErrorReporter(sheet: *mut ServoStyleSheet,
|
||||
|
|
|
@ -689,6 +689,45 @@ impl PseudoElement {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Construct a `CSSPseudoElementType` from a pseudo-element
|
||||
#[inline]
|
||||
pub fn pseudo_type(&self) -> CSSPseudoElementType {
|
||||
match *self {
|
||||
PseudoElement::After => CSSPseudoElementType::after,
|
||||
PseudoElement::Before => CSSPseudoElementType::before,
|
||||
PseudoElement::Backdrop => CSSPseudoElementType::backdrop,
|
||||
PseudoElement::Cue => CSSPseudoElementType::cue,
|
||||
PseudoElement::FirstLetter => CSSPseudoElementType::firstLetter,
|
||||
PseudoElement::FirstLine => CSSPseudoElementType::firstLine,
|
||||
PseudoElement::MozSelection => CSSPseudoElementType::mozSelection,
|
||||
PseudoElement::MozFocusInner => CSSPseudoElementType::mozFocusInner,
|
||||
PseudoElement::MozFocusOuter => CSSPseudoElementType::mozFocusOuter,
|
||||
PseudoElement::MozListBullet => CSSPseudoElementType::mozListBullet,
|
||||
PseudoElement::MozListNumber => CSSPseudoElementType::mozListNumber,
|
||||
PseudoElement::MozMathAnonymous => CSSPseudoElementType::mozMathAnonymous,
|
||||
PseudoElement::MozNumberWrapper => CSSPseudoElementType::mozNumberWrapper,
|
||||
PseudoElement::MozNumberText => CSSPseudoElementType::mozNumberText,
|
||||
PseudoElement::MozNumberSpinBox => CSSPseudoElementType::mozNumberSpinBox,
|
||||
PseudoElement::MozNumberSpinUp => CSSPseudoElementType::mozNumberSpinUp,
|
||||
PseudoElement::MozNumberSpinDown => CSSPseudoElementType::mozNumberSpinDown,
|
||||
PseudoElement::MozProgressBar => CSSPseudoElementType::mozProgressBar,
|
||||
PseudoElement::MozRangeTrack => CSSPseudoElementType::mozRangeTrack,
|
||||
PseudoElement::MozRangeProgress => CSSPseudoElementType::mozRangeProgress,
|
||||
PseudoElement::MozRangeThumb => CSSPseudoElementType::mozRangeThumb,
|
||||
PseudoElement::MozMeterBar => CSSPseudoElementType::mozMeterBar,
|
||||
PseudoElement::MozPlaceholder => CSSPseudoElementType::mozPlaceholder,
|
||||
PseudoElement::Placeholder => CSSPseudoElementType::placeholder,
|
||||
PseudoElement::MozColorSwatch => CSSPseudoElementType::mozColorSwatch,
|
||||
_ => CSSPseudoElementType::NotPseudo
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a PseudoInfo for a pseudo
|
||||
pub fn pseudo_info(&self) -> (*mut structs::nsIAtom, CSSPseudoElementType) {
|
||||
(self.atom().as_ptr(), self.pseudo_type())
|
||||
}
|
||||
|
||||
/// Construct a pseudo-element from an anonymous box `Atom`.
|
||||
#[inline]
|
||||
pub fn from_anon_box_atom(atom: &Atom) -> Option<Self> {
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -17,7 +17,7 @@ use gecko_bindings::structs::{nsMediaFeature_ValueType, nsMediaFeature_RangeType
|
|||
use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextOwned};
|
||||
use media_queries::MediaType;
|
||||
use parser::ParserContext;
|
||||
use properties::{ComputedValues, StyleBuilder};
|
||||
use properties::{ComputedValuesInner, StyleBuilder};
|
||||
use properties::longhands::font_size;
|
||||
use selectors::parser::SelectorParseError;
|
||||
use std::fmt::{self, Write};
|
||||
|
@ -26,7 +26,6 @@ use str::starts_with_ignore_ascii_case;
|
|||
use string_cache::Atom;
|
||||
use style_traits::{ToCss, ParseError, StyleParseError};
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
use stylearc::Arc;
|
||||
use values::{CSSFloat, specified};
|
||||
use values::computed::{self, ToComputedValue};
|
||||
|
||||
|
@ -37,7 +36,7 @@ pub struct Device {
|
|||
/// stylist, and thus the `Device`, so having a raw pres context pointer
|
||||
/// here is fine.
|
||||
pres_context: RawGeckoPresContextOwned,
|
||||
default_values: Arc<ComputedValues>,
|
||||
default_values: ComputedValuesInner,
|
||||
viewport_override: Option<ViewportConstraints>,
|
||||
/// The font size of the root element
|
||||
/// This is set when computing the style of the root
|
||||
|
@ -62,7 +61,7 @@ impl Device {
|
|||
assert!(!pres_context.is_null());
|
||||
Device {
|
||||
pres_context: pres_context,
|
||||
default_values: ComputedValues::default_values(unsafe { &*pres_context }),
|
||||
default_values: ComputedValuesInner::default_values(unsafe { &*pres_context }),
|
||||
viewport_override: None,
|
||||
root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious?
|
||||
used_root_font_size: AtomicBool::new(false),
|
||||
|
@ -78,19 +77,7 @@ impl Device {
|
|||
|
||||
/// Returns the default computed values as a reference, in order to match
|
||||
/// Servo.
|
||||
pub fn default_computed_values(&self) -> &ComputedValues {
|
||||
&*self.default_values
|
||||
}
|
||||
|
||||
/// Returns the default computed values, but wrapped in an arc for cheap
|
||||
/// cloning.
|
||||
pub fn default_computed_values_arc(&self) -> &Arc<ComputedValues> {
|
||||
&self.default_values
|
||||
}
|
||||
|
||||
/// Returns the default computed values as an `Arc`, in order to avoid
|
||||
/// clones.
|
||||
pub fn default_values_arc(&self) -> &Arc<ComputedValues> {
|
||||
pub fn default_computed_values(&self) -> &ComputedValuesInner {
|
||||
&self.default_values
|
||||
}
|
||||
|
||||
|
@ -114,7 +101,7 @@ impl Device {
|
|||
pub fn reset_computed_values(&mut self) {
|
||||
// NB: A following stylesheet flush will populate this if appropriate.
|
||||
self.viewport_override = None;
|
||||
self.default_values = ComputedValues::default_values(self.pres_context());
|
||||
self.default_values = ComputedValuesInner::default_values(self.pres_context());
|
||||
self.used_root_font_size.store(false, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,25 @@ impl PseudoElement {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Construct a `CSSPseudoElementType` from a pseudo-element
|
||||
#[inline]
|
||||
pub fn pseudo_type(&self) -> CSSPseudoElementType {
|
||||
match *self {
|
||||
% for pseudo in PSEUDOS:
|
||||
% if not pseudo.is_anon_box():
|
||||
PseudoElement::${pseudo.capitalized()} => CSSPseudoElementType::${pseudo.original_ident},
|
||||
% endif
|
||||
% endfor
|
||||
_ => CSSPseudoElementType::NotPseudo
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a PseudoInfo for a pseudo
|
||||
pub fn pseudo_info(&self) -> (*mut structs::nsIAtom, CSSPseudoElementType) {
|
||||
(self.atom().as_ptr(), self.pseudo_type())
|
||||
}
|
||||
|
||||
/// Construct a pseudo-element from an anonymous box `Atom`.
|
||||
#[inline]
|
||||
pub fn from_anon_box_atom(atom: &Atom) -> Option<Self> {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
use gecko_bindings::bindings;
|
||||
use gecko_bindings::structs;
|
||||
use gecko_bindings::structs::{nsChangeHint, nsStyleContext};
|
||||
use gecko_bindings::sugar::ownership::FFIArcHelpers;
|
||||
use matching::{StyleChange, StyleDifference};
|
||||
use properties::ComputedValues;
|
||||
use std::ops::{BitAnd, BitOr, BitOrAssign, Not};
|
||||
|
@ -56,7 +55,7 @@ impl GeckoRestyleDamage {
|
|||
let mut any_style_changed: bool = false;
|
||||
let hint = unsafe {
|
||||
bindings::Gecko_CalcStyleDifference(context,
|
||||
new_style.as_borrowed_opt().unwrap(),
|
||||
&new_style,
|
||||
&mut any_style_changed)
|
||||
};
|
||||
let change = if any_style_changed { StyleChange::Changed } else { StyleChange::Unchanged };
|
||||
|
|
|
@ -88,7 +88,7 @@ use std::mem;
|
|||
use std::ops::DerefMut;
|
||||
use std::ptr;
|
||||
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
|
||||
use stylearc::Arc;
|
||||
use stylearc::{Arc, ArcBorrow, RawOffsetArc};
|
||||
use stylesheets::UrlExtraData;
|
||||
use stylist::Stylist;
|
||||
|
||||
|
@ -860,13 +860,15 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
device.pres_context().mDocument.raw::<structs::nsIDocument>()
|
||||
}
|
||||
|
||||
fn style_attribute(&self) -> Option<&Arc<Locked<PropertyDeclarationBlock>>> {
|
||||
fn style_attribute(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>> {
|
||||
if !self.may_have_style_attribute() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let declarations = unsafe { Gecko_GetStyleAttrDeclarationBlock(self.0) };
|
||||
declarations.map_or(None, |s| s.as_arc_opt())
|
||||
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
||||
declarations.and_then(|s| s.as_arc_opt());
|
||||
declarations.map(|s| s.borrow_arc())
|
||||
}
|
||||
|
||||
fn unset_dirty_style_attribute(&self) {
|
||||
|
@ -877,9 +879,11 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
unsafe { Gecko_UnsetDirtyStyleAttr(self.0) };
|
||||
}
|
||||
|
||||
fn get_smil_override(&self) -> Option<&Arc<Locked<PropertyDeclarationBlock>>> {
|
||||
fn get_smil_override(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>> {
|
||||
let declarations = unsafe { Gecko_GetSMILOverrideDeclarationBlock(self.0) };
|
||||
declarations.map(|s| s.as_arc_opt()).unwrap_or(None)
|
||||
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
||||
declarations.and_then(|s| s.as_arc_opt());
|
||||
declarations.map(|s| s.borrow_arc())
|
||||
}
|
||||
|
||||
fn get_animation_rule_by_cascade(&self, cascade_level: ServoCascadeLevel)
|
||||
|
@ -1097,10 +1101,9 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
let computed_data = self.borrow_data();
|
||||
let computed_values =
|
||||
computed_data.as_ref().map(|d| d.styles.primary());
|
||||
let computed_values_opt =
|
||||
computed_values.map(|v| *HasArcFFI::arc_as_borrowed(v));
|
||||
let before_change_values =
|
||||
before_change_style.as_ref().map(|v| *HasArcFFI::arc_as_borrowed(v));
|
||||
before_change_style.as_ref().map(|x| &**x);
|
||||
let computed_values_opt = computed_values.as_ref().map(|x| &***x);
|
||||
unsafe {
|
||||
Gecko_UpdateAnimations(self.0,
|
||||
before_change_values,
|
||||
|
@ -1182,7 +1185,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
};
|
||||
let end_value = AnimationValue::arc_from_borrowed(&raw_end_value);
|
||||
debug_assert!(end_value.is_some());
|
||||
map.insert(property, end_value.unwrap().clone());
|
||||
map.insert(property, end_value.unwrap().clone_arc());
|
||||
}
|
||||
map
|
||||
}
|
||||
|
@ -1428,17 +1431,19 @@ impl<'le> PresentationalHintsSynthesizer for GeckoElement<'le> {
|
|||
}
|
||||
}
|
||||
let declarations = unsafe { Gecko_GetHTMLPresentationAttrDeclarationBlock(self.0) };
|
||||
let declarations = declarations.and_then(|s| s.as_arc_opt());
|
||||
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
||||
declarations.and_then(|s| s.as_arc_opt());
|
||||
if let Some(decl) = declarations {
|
||||
hints.push(
|
||||
ApplicableDeclarationBlock::from_declarations(Clone::clone(decl), ServoCascadeLevel::PresHints)
|
||||
ApplicableDeclarationBlock::from_declarations(decl.clone_arc(), ServoCascadeLevel::PresHints)
|
||||
);
|
||||
}
|
||||
let declarations = unsafe { Gecko_GetExtraContentStyleDeclarations(self.0) };
|
||||
let declarations = declarations.and_then(|s| s.as_arc_opt());
|
||||
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
||||
declarations.and_then(|s| s.as_arc_opt());
|
||||
if let Some(decl) = declarations {
|
||||
hints.push(
|
||||
ApplicableDeclarationBlock::from_declarations(Clone::clone(decl), ServoCascadeLevel::PresHints)
|
||||
ApplicableDeclarationBlock::from_declarations(decl.clone_arc(), ServoCascadeLevel::PresHints)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1458,20 +1463,22 @@ impl<'le> PresentationalHintsSynthesizer for GeckoElement<'le> {
|
|||
Gecko_GetVisitedLinkAttrDeclarationBlock(self.0)
|
||||
},
|
||||
};
|
||||
let declarations = declarations.and_then(|s| s.as_arc_opt());
|
||||
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
||||
declarations.and_then(|s| s.as_arc_opt());
|
||||
if let Some(decl) = declarations {
|
||||
hints.push(
|
||||
ApplicableDeclarationBlock::from_declarations(Clone::clone(decl), ServoCascadeLevel::PresHints)
|
||||
ApplicableDeclarationBlock::from_declarations(decl.clone_arc(), ServoCascadeLevel::PresHints)
|
||||
);
|
||||
}
|
||||
|
||||
let active = self.get_state().intersects(NonTSPseudoClass::Active.state_flag());
|
||||
if active {
|
||||
let declarations = unsafe { Gecko_GetActiveLinkAttrDeclarationBlock(self.0) };
|
||||
let declarations = declarations.and_then(|s| s.as_arc_opt());
|
||||
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
||||
declarations.and_then(|s| s.as_arc_opt());
|
||||
if let Some(decl) = declarations {
|
||||
hints.push(
|
||||
ApplicableDeclarationBlock::from_declarations(Clone::clone(decl), ServoCascadeLevel::PresHints)
|
||||
ApplicableDeclarationBlock::from_declarations(decl.clone_arc(), ServoCascadeLevel::PresHints)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::marker::PhantomData;
|
|||
use std::mem::{forget, transmute};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::ptr;
|
||||
use stylearc::Arc;
|
||||
use stylearc::{Arc, RawOffsetArc};
|
||||
|
||||
/// Indicates that a given Servo type has a corresponding Gecko FFI type.
|
||||
pub unsafe trait HasFFI : Sized + 'static {
|
||||
|
@ -88,7 +88,7 @@ pub unsafe trait HasArcFFI : HasFFI {
|
|||
/// (usually on the C++ side) without running the Arc destructor.
|
||||
unsafe fn release_opt(ptr: Option<&Self::FFIType>) {
|
||||
if let Some(arc) = Self::arc_from_borrowed(&ptr) {
|
||||
let _: Arc<_> = ptr::read(arc as *const Arc<_>);
|
||||
let _: RawOffsetArc<_> = ptr::read(arc as *const RawOffsetArc<_>);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,16 +102,16 @@ pub unsafe trait HasArcFFI : HasFFI {
|
|||
/// know that a strong reference to the backing Arc is disappearing
|
||||
/// (usually on the C++ side) without running the Arc destructor.
|
||||
unsafe fn release(ptr: &Self::FFIType) {
|
||||
let _: Arc<_> = ptr::read(Self::as_arc(&ptr) as *const Arc<_>);
|
||||
let _: RawOffsetArc<_> = ptr::read(Self::as_arc(&ptr) as *const RawOffsetArc<_>);
|
||||
}
|
||||
#[inline]
|
||||
/// Converts a borrowed FFI reference to a borrowed Arc.
|
||||
///
|
||||
/// &GeckoType -> &Arc<ServoType>
|
||||
fn as_arc<'a>(ptr: &'a &Self::FFIType) -> &'a Arc<Self> {
|
||||
fn as_arc<'a>(ptr: &'a &Self::FFIType) -> &'a RawOffsetArc<Self> {
|
||||
debug_assert!(!(ptr as *const _).is_null());
|
||||
unsafe {
|
||||
transmute::<&&Self::FFIType, &Arc<Self>>(ptr)
|
||||
transmute::<&&Self::FFIType, &RawOffsetArc<Self>>(ptr)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,9 +119,9 @@ pub unsafe trait HasArcFFI : HasFFI {
|
|||
/// Converts a borrowed Arc to a borrowed FFI reference.
|
||||
///
|
||||
/// &Arc<ServoType> -> &GeckoType
|
||||
fn arc_as_borrowed<'a>(arc: &'a Arc<Self>) -> &'a &Self::FFIType {
|
||||
fn arc_as_borrowed<'a>(arc: &'a RawOffsetArc<Self>) -> &'a &Self::FFIType {
|
||||
unsafe {
|
||||
transmute::<&Arc<Self>, &&Self::FFIType>(arc)
|
||||
transmute::<&RawOffsetArc<Self>, &&Self::FFIType>(arc)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,10 +129,10 @@ pub unsafe trait HasArcFFI : HasFFI {
|
|||
/// Converts a borrowed nullable FFI reference to a borrowed Arc.
|
||||
///
|
||||
/// &GeckoType -> &Arc<ServoType>
|
||||
fn arc_from_borrowed<'a>(ptr: &'a Option<&Self::FFIType>) -> Option<&'a Arc<Self>> {
|
||||
fn arc_from_borrowed<'a>(ptr: &'a Option<&Self::FFIType>) -> Option<&'a RawOffsetArc<Self>> {
|
||||
unsafe {
|
||||
if let Some(ref reference) = *ptr {
|
||||
Some(transmute::<&&Self::FFIType, &Arc<_>>(reference))
|
||||
Some(transmute::<&&Self::FFIType, &RawOffsetArc<_>>(reference))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ impl<GeckoType> Strong<GeckoType> {
|
|||
/// Panics on null.
|
||||
///
|
||||
/// Strong<GeckoType> -> Arc<ServoType>
|
||||
pub fn into_arc<ServoType>(self) -> Arc<ServoType>
|
||||
pub fn into_arc<ServoType>(self) -> RawOffsetArc<ServoType>
|
||||
where ServoType: HasArcFFI<FFIType = GeckoType>,
|
||||
{
|
||||
self.into_arc_opt().unwrap()
|
||||
|
@ -177,7 +177,7 @@ impl<GeckoType> Strong<GeckoType> {
|
|||
/// Returns None on null.
|
||||
///
|
||||
/// Strong<GeckoType> -> Arc<ServoType>
|
||||
pub fn into_arc_opt<ServoType>(self) -> Option<Arc<ServoType>>
|
||||
pub fn into_arc_opt<ServoType>(self) -> Option<RawOffsetArc<ServoType>>
|
||||
where ServoType: HasArcFFI<FFIType = GeckoType>,
|
||||
{
|
||||
if self.is_null() {
|
||||
|
@ -194,7 +194,7 @@ impl<GeckoType> Strong<GeckoType> {
|
|||
/// Returns None on null.
|
||||
///
|
||||
/// Strong<GeckoType> -> Arc<ServoType>
|
||||
pub fn as_arc_opt<ServoType>(&self) -> Option<&Arc<ServoType>>
|
||||
pub fn as_arc_opt<ServoType>(&self) -> Option<&RawOffsetArc<ServoType>>
|
||||
where ServoType: HasArcFFI<FFIType = GeckoType>,
|
||||
{
|
||||
if self.is_null() {
|
||||
|
@ -222,18 +222,15 @@ pub unsafe trait FFIArcHelpers {
|
|||
/// Arc<ServoType> -> Strong<GeckoType>
|
||||
fn into_strong(self) -> Strong<<Self::Inner as HasFFI>::FFIType>;
|
||||
|
||||
/// Produces a (nullable) borrowed FFI reference by borrowing an Arc.
|
||||
/// Produces a borrowed FFI reference by borrowing an Arc.
|
||||
///
|
||||
/// &Arc<ServoType> -> Option<&GeckoType>
|
||||
///
|
||||
/// FIXME(emilio): What's the point of the nullability? Arc should be
|
||||
/// non-null, right?
|
||||
/// &Arc<ServoType> -> &GeckoType
|
||||
///
|
||||
/// Then the `arc_as_borrowed` method can go away.
|
||||
fn as_borrowed_opt(&self) -> Option<&<Self::Inner as HasFFI>::FFIType>;
|
||||
fn as_borrowed(&self) -> &<Self::Inner as HasFFI>::FFIType;
|
||||
}
|
||||
|
||||
unsafe impl<T: HasArcFFI> FFIArcHelpers for Arc<T> {
|
||||
unsafe impl<T: HasArcFFI> FFIArcHelpers for RawOffsetArc<T> {
|
||||
type Inner = T;
|
||||
|
||||
#[inline]
|
||||
|
@ -242,9 +239,22 @@ unsafe impl<T: HasArcFFI> FFIArcHelpers for Arc<T> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn as_borrowed_opt(&self) -> Option<&T::FFIType> {
|
||||
let borrowedptr = self as *const Arc<T> as *const Option<&T::FFIType>;
|
||||
unsafe { ptr::read(borrowedptr) }
|
||||
fn as_borrowed(&self) -> &T::FFIType {
|
||||
unsafe { &*(&**self as *const T as *const T::FFIType) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T: HasArcFFI> FFIArcHelpers for Arc<T> {
|
||||
type Inner = T;
|
||||
|
||||
#[inline]
|
||||
fn into_strong(self) -> Strong<T::FFIType> {
|
||||
Arc::into_raw_offset(self).into_strong()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_borrowed(&self) -> &T::FFIType {
|
||||
unsafe { &*(&**self as *const T as *const T::FFIType) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ impl<T> structs::RefPtr<T> {
|
|||
/// Sets the contents to an Arc<T>
|
||||
/// will leak existing contents
|
||||
pub fn set_arc_leaky<U>(&mut self, other: Arc<U>) where U: HasArcFFI<FFIType = T> {
|
||||
*self = unsafe { mem::transmute(other) }; // Arc::into_raw is unstable :(
|
||||
*self = unsafe { mem::transmute(Arc::into_raw_offset(other)) };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use properties::longhands::display::computed_value as display;
|
|||
use rule_tree::{CascadeLevel, StrongRuleNode};
|
||||
use selector_parser::{PseudoElement, RestyleDamage};
|
||||
use selectors::matching::ElementSelectorFlags;
|
||||
use stylearc::Arc;
|
||||
use stylearc::{Arc, ArcBorrow};
|
||||
|
||||
/// Represents the result of comparing an element's old and new style.
|
||||
pub struct StyleDifference {
|
||||
|
@ -690,7 +690,7 @@ pub trait MatchMethods : TElement {
|
|||
};
|
||||
|
||||
let replace_rule_node = |level: CascadeLevel,
|
||||
pdb: Option<&Arc<Locked<PropertyDeclarationBlock>>>,
|
||||
pdb: Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>,
|
||||
path: &mut StrongRuleNode| -> bool {
|
||||
let new_node = stylist.rule_tree()
|
||||
.update_rule_at_level(level, pdb, path, guards);
|
||||
|
@ -737,7 +737,7 @@ pub trait MatchMethods : TElement {
|
|||
primary_rules: &mut StrongRuleNode| {
|
||||
let animation_rule = self.get_animation_rule_by_cascade(level);
|
||||
replace_rule_node(level,
|
||||
animation_rule.as_ref(),
|
||||
animation_rule.as_ref().map(|a| a.borrow_arc()),
|
||||
primary_rules);
|
||||
};
|
||||
|
||||
|
|
|
@ -110,13 +110,13 @@ impl<'a> Iterator for PropertyDeclarationIterator<'a> {
|
|||
pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
|
||||
iter: Iter<'a, (PropertyDeclaration, Importance)>,
|
||||
context: &'cx mut Context<'cx_a>,
|
||||
default_values: &'a Arc<ComputedValues>,
|
||||
default_values: &'a ComputedValuesInner,
|
||||
}
|
||||
|
||||
impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||
fn new(declarations: &'a PropertyDeclarationBlock,
|
||||
context: &'cx mut Context<'cx_a>,
|
||||
default_values: &'a Arc<ComputedValues>) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||
default_values: &'a ComputedValuesInner) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||
AnimationValueIterator {
|
||||
iter: declarations.declarations().iter(),
|
||||
context: context,
|
||||
|
@ -204,7 +204,7 @@ impl PropertyDeclarationBlock {
|
|||
/// Return an iterator of (AnimatableLonghand, AnimationValue).
|
||||
pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self,
|
||||
context: &'cx mut Context<'cx_a>,
|
||||
default_values: &'a Arc<ComputedValues>)
|
||||
default_values: &'a ComputedValuesInner)
|
||||
-> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||
AnimationValueIterator::new(self, context, default_values)
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ use gecko_bindings::structs;
|
|||
use gecko_bindings::structs::nsCSSPropertyID;
|
||||
use gecko_bindings::structs::nsStyleVariables;
|
||||
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
|
||||
use gecko_bindings::sugar::ownership::HasArcFFI;
|
||||
use gecko::values::convert_nscolor_to_rgba;
|
||||
use gecko::values::convert_rgba_to_nscolor;
|
||||
use gecko::values::GeckoStyleCoordConvertible;
|
||||
|
@ -58,11 +57,9 @@ use properties::computed_value_flags::ComputedValueFlags;
|
|||
use properties::{longhands, FontComputationData, Importance, LonghandId};
|
||||
use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId};
|
||||
use rule_tree::StrongRuleNode;
|
||||
use std::fmt::{self, Debug};
|
||||
use std::mem::{forget, transmute, zeroed};
|
||||
use std::ptr;
|
||||
use stylearc::Arc;
|
||||
use std::cmp;
|
||||
use std::mem::{forget, uninitialized, transmute, zeroed};
|
||||
use std::{cmp, ops, ptr};
|
||||
use stylearc::{Arc, RawOffsetArc};
|
||||
use values::{Auto, CustomIdent, Either, KeyframesName};
|
||||
use values::computed::ToComputedValue;
|
||||
use values::computed::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
|
@ -75,28 +72,50 @@ pub mod style_structs {
|
|||
% endfor
|
||||
}
|
||||
|
||||
// FIXME(emilio): Unify both definitions, since they're equal now.
|
||||
#[derive(Clone)]
|
||||
pub struct ComputedValues {
|
||||
% for style_struct in data.style_structs:
|
||||
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||
% endfor
|
||||
custom_properties: Option<Arc<CustomPropertiesMap>>,
|
||||
pub writing_mode: WritingMode,
|
||||
pub font_computation_data: FontComputationData,
|
||||
pub flags: ComputedValueFlags,
|
||||
|
||||
/// The rule node representing the ordered list of rules matched for this
|
||||
/// node. Can be None for default values and text nodes. This is
|
||||
/// essentially an optimization to avoid referencing the root rule node.
|
||||
pub rules: Option<StrongRuleNode>,
|
||||
/// The element's computed values if visited, only computed if there's a
|
||||
/// relevant link for this element. A element's "relevant link" is the
|
||||
/// element being matched if it is a link or the nearest ancestor link.
|
||||
visited_style: Option<Arc<ComputedValues>>,
|
||||
pub type ComputedValuesInner = ::gecko_bindings::structs::ServoComputedValues;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
pub struct ComputedValues(::gecko_bindings::structs::mozilla::ServoStyleContext);
|
||||
|
||||
impl Drop for ComputedValues {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
bindings::Gecko_ServoStyleContext_Destroy(&mut self.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ComputedValues {
|
||||
unsafe impl Sync for ComputedValues {}
|
||||
unsafe impl Send for ComputedValues {}
|
||||
|
||||
impl Clone for ComputedValues {
|
||||
fn clone(&self) -> Self {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for ComputedValuesInner {
|
||||
fn clone(&self) -> Self {
|
||||
ComputedValuesInner {
|
||||
% for style_struct in data.style_structs:
|
||||
${style_struct.gecko_name}: self.${style_struct.gecko_name}.clone(),
|
||||
% endfor
|
||||
custom_properties: self.custom_properties.clone(),
|
||||
writing_mode: self.writing_mode.clone(),
|
||||
font_computation_data: self.font_computation_data.clone(),
|
||||
flags: self.flags.clone(),
|
||||
rules: self.rules.clone(),
|
||||
visited_style: self.visited_style.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type PseudoInfo = (*mut structs::nsIAtom, structs::CSSPseudoElementType);
|
||||
pub type ParentStyleContextInfo<'a> = Option< &'a ComputedValues>;
|
||||
|
||||
impl ComputedValuesInner {
|
||||
pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>,
|
||||
writing_mode: WritingMode,
|
||||
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
|
||||
|
@ -107,33 +126,76 @@ impl ComputedValues {
|
|||
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||
% endfor
|
||||
) -> Self {
|
||||
ComputedValues {
|
||||
custom_properties,
|
||||
writing_mode,
|
||||
ComputedValuesInner {
|
||||
custom_properties: custom_properties,
|
||||
writing_mode: writing_mode,
|
||||
font_computation_data: FontComputationData::new(font_size_keyword),
|
||||
flags,
|
||||
rules,
|
||||
visited_style: visited_style,
|
||||
rules: rules,
|
||||
visited_style: visited_style.map(|x| Arc::into_raw_offset(x)),
|
||||
flags: flags,
|
||||
% for style_struct in data.style_structs:
|
||||
${style_struct.ident},
|
||||
${style_struct.gecko_name}: Arc::into_raw_offset(${style_struct.ident}),
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
|
||||
Arc::new(ComputedValues {
|
||||
custom_properties: None,
|
||||
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
|
||||
font_computation_data: FontComputationData::default_values(),
|
||||
flags: ComputedValueFlags::empty(),
|
||||
rules: None,
|
||||
visited_style: None,
|
||||
% for style_struct in data.style_structs:
|
||||
${style_struct.ident}: style_structs::${style_struct.name}::default(pres_context),
|
||||
% endfor
|
||||
})
|
||||
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, device: &Device, parent: ParentStyleContextInfo,
|
||||
info: Option<PseudoInfo>) -> Arc<ComputedValues> {
|
||||
let (tag, ty) = if let Some(info) = info {
|
||||
info
|
||||
} else {
|
||||
(ptr::null_mut(), structs::CSSPseudoElementType::NotPseudo)
|
||||
};
|
||||
|
||||
unsafe { self.to_outer_helper(device.pres_context(), parent, ty, tag) }
|
||||
}
|
||||
|
||||
pub unsafe fn to_outer_helper(self, pres_context: bindings::RawGeckoPresContextBorrowed,
|
||||
parent: ParentStyleContextInfo,
|
||||
pseudo_ty: structs::CSSPseudoElementType,
|
||||
pseudo_tag: *mut structs::nsIAtom) -> Arc<ComputedValues> {
|
||||
let arc = unsafe {
|
||||
let arc: Arc<ComputedValues> = Arc::new(uninitialized());
|
||||
bindings::Gecko_ServoStyleContext_Init(&arc.0 as *const _ as *mut _, parent, pres_context,
|
||||
&self, pseudo_ty, pseudo_tag);
|
||||
// We're simulating a move by having C++ do a memcpy and then forgetting
|
||||
// it on this end.
|
||||
forget(self);
|
||||
arc
|
||||
};
|
||||
arc
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Deref for ComputedValues {
|
||||
type Target = ComputedValuesInner;
|
||||
fn deref(&self) -> &ComputedValuesInner {
|
||||
&self.0.mSource
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::DerefMut for ComputedValues {
|
||||
fn deref_mut(&mut self) -> &mut ComputedValuesInner {
|
||||
&mut self.0.mSource
|
||||
}
|
||||
}
|
||||
|
||||
impl ComputedValuesInner {
|
||||
#[inline]
|
||||
pub fn is_display_contents(&self) -> bool {
|
||||
self.get_box().clone_display() == longhands::display::computed_value::T::contents
|
||||
|
@ -149,20 +211,21 @@ impl ComputedValues {
|
|||
% for style_struct in data.style_structs:
|
||||
#[inline]
|
||||
pub fn clone_${style_struct.name_lower}(&self) -> Arc<style_structs::${style_struct.name}> {
|
||||
self.${style_struct.ident}.clone()
|
||||
Arc::from_raw_offset(self.${style_struct.gecko_name}.clone())
|
||||
}
|
||||
#[inline]
|
||||
pub fn get_${style_struct.name_lower}(&self) -> &style_structs::${style_struct.name} {
|
||||
&self.${style_struct.ident}
|
||||
&self.${style_struct.gecko_name}
|
||||
}
|
||||
|
||||
pub fn ${style_struct.name_lower}_arc(&self) -> &Arc<style_structs::${style_struct.name}> {
|
||||
&self.${style_struct.ident}
|
||||
|
||||
pub fn ${style_struct.name_lower}_arc(&self) -> &RawOffsetArc<style_structs::${style_struct.name}> {
|
||||
&self.${style_struct.gecko_name}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn mutate_${style_struct.name_lower}(&mut self) -> &mut style_structs::${style_struct.name} {
|
||||
Arc::make_mut(&mut self.${style_struct.ident})
|
||||
RawOffsetArc::make_mut(&mut self.${style_struct.gecko_name})
|
||||
}
|
||||
% endfor
|
||||
|
||||
|
@ -177,19 +240,19 @@ impl ComputedValues {
|
|||
}
|
||||
|
||||
/// 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< & ComputedValues> {
|
||||
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) -> &ComputedValues {
|
||||
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()
|
||||
self.visited_style.as_ref().map(|x| x.clone_arc())
|
||||
}
|
||||
|
||||
/// Gets a reference to the custom properties map (if one exists).
|
||||
|
@ -238,9 +301,7 @@ impl ComputedValues {
|
|||
}
|
||||
|
||||
<%def name="declare_style_struct(style_struct)">
|
||||
pub struct ${style_struct.gecko_struct_name} {
|
||||
gecko: ${style_struct.gecko_ffi_name},
|
||||
}
|
||||
pub use ::gecko_bindings::structs::mozilla::Gecko${style_struct.gecko_name} as ${style_struct.gecko_struct_name};
|
||||
impl ${style_struct.gecko_struct_name} {
|
||||
pub fn gecko(&self) -> &${style_struct.gecko_ffi_name} {
|
||||
&self.gecko
|
||||
|
@ -737,20 +798,6 @@ impl Clone for ${style_struct.gecko_struct_name} {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME(bholley): Make bindgen generate Debug for all types.
|
||||
%if style_struct.gecko_ffi_name in ("nsStyle" + x for x in "Border Display List Background Font SVGReset".split()):
|
||||
impl Debug for ${style_struct.gecko_struct_name} {
|
||||
// FIXME(bholley): Generate this.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Gecko style struct: ${style_struct.gecko_struct_name}")
|
||||
}
|
||||
}
|
||||
%else:
|
||||
impl Debug for ${style_struct.gecko_struct_name} {
|
||||
// FIXME(bholley): Generate this.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.gecko.fmt(f) }
|
||||
}
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="impl_simple_type_with_conversion(ident, gecko_ffi_name=None)">
|
||||
|
@ -4797,7 +4844,7 @@ clip-path
|
|||
#[allow(non_snake_case, unused_variables)]
|
||||
pub unsafe extern "C" fn Servo_GetStyle${style_struct.gecko_name}(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull) -> *const ${style_struct.gecko_ffi_name} {
|
||||
ComputedValues::arc_from_borrowed(&computed_values).unwrap().get_${style_struct.name_lower}().get_gecko()
|
||||
computed_values.unwrap().get_${style_struct.name_lower}().get_gecko()
|
||||
as *const ${style_struct.gecko_ffi_name}
|
||||
}
|
||||
</%def>
|
||||
|
@ -4816,7 +4863,7 @@ static mut EMPTY_VARIABLES_STRUCT: Option<nsStyleVariables> = None;
|
|||
|
||||
#[no_mangle]
|
||||
#[allow(non_snake_case)]
|
||||
pub unsafe extern "C" fn Servo_GetStyleVariables(_cv: ServoComputedValuesBorrowedOrNull)
|
||||
pub unsafe extern "C" fn Servo_GetEmptyVariables()
|
||||
-> *const nsStyleVariables {
|
||||
EMPTY_VARIABLES_STRUCT.as_ref().unwrap()
|
||||
}
|
||||
|
|
|
@ -292,7 +292,7 @@
|
|||
#[allow(unused_imports)]
|
||||
use properties::{DeclaredValue, LonghandId, LonghandIdSet};
|
||||
#[allow(unused_imports)]
|
||||
use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration};
|
||||
use properties::{CSSWideKeyword, ComputedValuesInner, PropertyDeclaration};
|
||||
#[allow(unused_imports)]
|
||||
use properties::style_structs;
|
||||
#[allow(unused_imports)]
|
||||
|
@ -310,8 +310,8 @@
|
|||
${caller.body()}
|
||||
#[allow(unused_variables)]
|
||||
pub fn cascade_property(declaration: &PropertyDeclaration,
|
||||
inherited_style: &ComputedValues,
|
||||
default_style: &ComputedValues,
|
||||
inherited_style: &ComputedValuesInner,
|
||||
default_style: &ComputedValuesInner,
|
||||
context: &mut computed::Context,
|
||||
cacheable: &mut bool,
|
||||
cascade_info: &mut Option<<&mut CascadeInfo>) {
|
||||
|
|
|
@ -29,7 +29,7 @@ use smallvec::SmallVec;
|
|||
use std::cmp;
|
||||
#[cfg(feature = "gecko")] use fnv::FnvHashMap;
|
||||
use style_traits::ParseError;
|
||||
use super::ComputedValues;
|
||||
use super::ComputedValuesInner;
|
||||
#[cfg(any(feature = "gecko", feature = "testing"))]
|
||||
use values::Auto;
|
||||
use values::{CSSFloat, CustomIdent, Either};
|
||||
|
@ -394,7 +394,7 @@ impl AnimatedProperty {
|
|||
|
||||
/// Update `style` with the proper computed style corresponding to this
|
||||
/// animation at `progress`.
|
||||
pub fn update(&self, style: &mut ComputedValues, progress: f64) {
|
||||
pub fn update(&self, style: &mut ComputedValuesInner, progress: f64) {
|
||||
match *self {
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
|
@ -427,8 +427,8 @@ impl AnimatedProperty {
|
|||
/// Get an animatable value from a transition-property, an old style, and a
|
||||
/// new style.
|
||||
pub fn from_animatable_longhand(property: &AnimatableLonghand,
|
||||
old_style: &ComputedValues,
|
||||
new_style: &ComputedValues)
|
||||
old_style: &ComputedValuesInner,
|
||||
new_style: &ComputedValuesInner)
|
||||
-> AnimatedProperty {
|
||||
match *property {
|
||||
% for prop in data.longhands:
|
||||
|
@ -521,7 +521,7 @@ impl AnimationValue {
|
|||
|
||||
/// Construct an AnimationValue from a property declaration
|
||||
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
|
||||
initial: &ComputedValues) -> Option<Self> {
|
||||
initial: &ComputedValuesInner) -> Option<Self> {
|
||||
use properties::LonghandId;
|
||||
|
||||
match *decl {
|
||||
|
@ -593,7 +593,7 @@ impl AnimationValue {
|
|||
|
||||
/// Get an AnimationValue for an AnimatableLonghand from a given computed values.
|
||||
pub fn from_computed_values(property: &AnimatableLonghand,
|
||||
computed_values: &ComputedValues)
|
||||
computed_values: &ComputedValuesInner)
|
||||
-> Self {
|
||||
match *property {
|
||||
% for prop in data.longhands:
|
||||
|
|
|
@ -181,7 +181,7 @@
|
|||
|
||||
% if product == "servo":
|
||||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||
_inherited_style: &ComputedValues,
|
||||
_inherited_style: &ComputedValuesInner,
|
||||
context: &mut computed::Context,
|
||||
_cacheable: &mut bool) {
|
||||
longhands::_servo_display_for_hypothetical_box::derive_from_display(context);
|
||||
|
|
|
@ -249,7 +249,7 @@ ${helpers.single_keyword("unicode-bidi",
|
|||
|
||||
% if product == "servo":
|
||||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||
_inherited_style: &ComputedValues,
|
||||
_inherited_style: &ComputedValuesInner,
|
||||
context: &mut computed::Context,
|
||||
_cacheable: &mut bool) {
|
||||
longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context);
|
||||
|
|
|
@ -12,9 +12,7 @@
|
|||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashSet;
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use std::ops::Deref;
|
||||
use std::{fmt, mem, ops};
|
||||
use stylearc::{Arc, UniqueArc};
|
||||
|
||||
use app_units::Au;
|
||||
|
@ -113,7 +111,7 @@ pub struct FontComputationData {
|
|||
}
|
||||
|
||||
|
||||
impl FontComputationData{
|
||||
impl FontComputationData {
|
||||
/// Assigns values for variables in struct FontComputationData
|
||||
pub fn new(font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>) -> Self {
|
||||
FontComputationData {
|
||||
|
@ -1873,21 +1871,20 @@ pub mod style_structs {
|
|||
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use gecko_properties::ComputedValues;
|
||||
pub use gecko_properties::{ComputedValues, ComputedValuesInner, ParentStyleContextInfo, PseudoInfo};
|
||||
|
||||
/// A legacy alias for a servo-version of ComputedValues. Should go away soon.
|
||||
#[cfg(feature = "servo")]
|
||||
pub type ServoComputedValues = ComputedValues;
|
||||
/// Servo doesn't have style contexts so this is extraneous info
|
||||
pub type PseudoInfo = ();
|
||||
#[cfg(feature = "servo")]
|
||||
/// Servo doesn't have style contexts so this is extraneous info
|
||||
pub type ParentStyleContextInfo = ();
|
||||
|
||||
|
||||
/// The struct that Servo uses to represent computed values.
|
||||
///
|
||||
/// This struct contains an immutable atomically-reference-counted pointer to
|
||||
/// every kind of style struct.
|
||||
///
|
||||
/// When needed, the structs may be copied in order to get mutated.
|
||||
#[cfg(feature = "servo")]
|
||||
#[cfg_attr(feature = "servo", derive(Clone))]
|
||||
pub struct ComputedValues {
|
||||
#[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}>,
|
||||
% endfor
|
||||
|
@ -1911,8 +1908,26 @@ pub struct ComputedValues {
|
|||
visited_style: Option<Arc<ComputedValues>>,
|
||||
}
|
||||
|
||||
/// The struct that Servo uses to represent computed values.
|
||||
///
|
||||
/// This struct contains an immutable atomically-reference-counted pointer to
|
||||
/// every kind of style struct.
|
||||
///
|
||||
/// When needed, the structs may be copied in order to get mutated.
|
||||
#[cfg(feature = "servo")]
|
||||
impl ComputedValues {
|
||||
#[cfg_attr(feature = "servo", derive(Clone, Debug))]
|
||||
pub struct ComputedValues {
|
||||
/// The actual computed values
|
||||
///
|
||||
/// 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 ComputedValuesInner {
|
||||
/// Construct a `ComputedValues` instance.
|
||||
pub fn new(
|
||||
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
|
@ -1925,22 +1940,45 @@ impl ComputedValues {
|
|||
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||
% endfor
|
||||
) -> Self {
|
||||
let font_computation_data = FontComputationData::new(font_size_keyword);
|
||||
ComputedValues {
|
||||
custom_properties,
|
||||
writing_mode,
|
||||
font_computation_data,
|
||||
flags,
|
||||
rules,
|
||||
visited_style,
|
||||
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}: ${style_struct.ident},
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the initial computed values.
|
||||
pub fn initial_values() -> &'static Self { &*INITIAL_SERVO_VALUES }
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
impl ops::Deref for ComputedValues {
|
||||
type Target = ComputedValuesInner;
|
||||
fn deref(&self) -> &ComputedValuesInner {
|
||||
&self.inner
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
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, _: &Device, _: ParentStyleContextInfo,
|
||||
_: Option<PseudoInfo>) -> Arc<ComputedValues> {
|
||||
Arc::new(ComputedValues {inner: self})
|
||||
}
|
||||
|
||||
% for style_struct in data.active_style_structs():
|
||||
/// Clone the ${style_struct.name} struct.
|
||||
|
@ -1979,12 +2017,12 @@ impl ComputedValues {
|
|||
}
|
||||
|
||||
/// 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< & ComputedValues> {
|
||||
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) -> &ComputedValues {
|
||||
self.get_visited_style().unwrap()
|
||||
}
|
||||
|
||||
|
@ -2237,14 +2275,6 @@ impl ComputedValues {
|
|||
}
|
||||
}
|
||||
|
||||
// We manually implement Debug for ComputedValues so that we can avoid the
|
||||
// verbose stringification of every property and instead focus on a few values.
|
||||
impl fmt::Debug for ComputedValues {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "ComputedValues {{ rules: {:?}, .. }}", self.rules)
|
||||
}
|
||||
}
|
||||
|
||||
/// Return a WritingMode bitflags from the relevant CSS properties.
|
||||
pub fn get_writing_mode(inheritedbox_style: &style_structs::InheritedBox) -> WritingMode {
|
||||
use logical_geometry;
|
||||
|
@ -2296,10 +2326,24 @@ pub fn get_writing_mode(inheritedbox_style: &style_structs::InheritedBox) -> Wri
|
|||
flags
|
||||
}
|
||||
|
||||
% if product == "gecko":
|
||||
pub use ::stylearc::RawOffsetArc as BuilderArc;
|
||||
/// Clone an arc, returning a regular arc
|
||||
fn clone_arc<T: 'static>(x: &BuilderArc<T>) -> Arc<T> {
|
||||
Arc::from_raw_offset(x.clone())
|
||||
}
|
||||
% else:
|
||||
pub use ::stylearc::Arc as BuilderArc;
|
||||
/// Clone an arc, returning a regular arc
|
||||
fn clone_arc<T: 'static>(x: &BuilderArc<T>) -> Arc<T> {
|
||||
x.clone()
|
||||
}
|
||||
% endif
|
||||
|
||||
/// A reference to a style struct of the parent, or our own style struct.
|
||||
pub enum StyleStructRef<'a, T: 'static> {
|
||||
/// A borrowed struct from the parent, for example, for inheriting style.
|
||||
Borrowed(&'a Arc<T>),
|
||||
Borrowed(&'a BuilderArc<T>),
|
||||
/// An owned struct, that we've already mutated.
|
||||
Owned(UniqueArc<T>),
|
||||
/// Temporarily vacated, will panic if accessed
|
||||
|
@ -2360,13 +2404,13 @@ impl<'a, T: 'a> StyleStructRef<'a, T>
|
|||
pub fn build(self) -> Arc<T> {
|
||||
match self {
|
||||
StyleStructRef::Owned(v) => v.shareable(),
|
||||
StyleStructRef::Borrowed(v) => v.clone(),
|
||||
StyleStructRef::Borrowed(v) => clone_arc(v),
|
||||
StyleStructRef::Vacated => panic!("Accessed vacated style struct")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: 'a> Deref for StyleStructRef<'a, T> {
|
||||
impl<'a, T: 'a> ops::Deref for StyleStructRef<'a, T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &T {
|
||||
|
@ -2408,8 +2452,8 @@ pub struct StyleBuilder<'a> {
|
|||
impl<'a> StyleBuilder<'a> {
|
||||
/// Trivially construct a `StyleBuilder`.
|
||||
fn new(
|
||||
inherited_style: &'a ComputedValues,
|
||||
reset_style: &'a ComputedValues,
|
||||
inherited_style: &'a ComputedValuesInner,
|
||||
reset_style: &'a ComputedValuesInner,
|
||||
rules: Option<StrongRuleNode>,
|
||||
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
writing_mode: WritingMode,
|
||||
|
@ -2436,15 +2480,15 @@ impl<'a> StyleBuilder<'a> {
|
|||
|
||||
/// Creates a StyleBuilder holding only references to the structs of `s`, in
|
||||
/// order to create a derived style.
|
||||
pub fn for_derived_style(s: &'a ComputedValues) -> Self {
|
||||
pub fn for_derived_style(s: &'a ComputedValuesInner) -> Self {
|
||||
Self::for_inheritance(s, s)
|
||||
}
|
||||
|
||||
/// Inherits style from the parent element, accounting for the default
|
||||
/// computed values that need to be provided as well.
|
||||
pub fn for_inheritance(
|
||||
parent: &'a ComputedValues,
|
||||
default: &'a ComputedValues
|
||||
parent: &'a ComputedValuesInner,
|
||||
default: &'a ComputedValuesInner
|
||||
) -> Self {
|
||||
Self::new(
|
||||
parent,
|
||||
|
@ -2488,7 +2532,7 @@ impl<'a> StyleBuilder<'a> {
|
|||
}
|
||||
|
||||
/// Reset the current `${style_struct.name}` style to its default value.
|
||||
pub fn reset_${style_struct.name_lower}(&mut self, default: &'a ComputedValues) {
|
||||
pub fn reset_${style_struct.name_lower}(&mut self, default: &'a ComputedValuesInner) {
|
||||
self.${style_struct.ident} =
|
||||
StyleStructRef::Borrowed(default.${style_struct.name_lower}_arc());
|
||||
}
|
||||
|
@ -2522,8 +2566,8 @@ impl<'a> StyleBuilder<'a> {
|
|||
|
||||
|
||||
/// Turns this `StyleBuilder` into a proper `ComputedValues` instance.
|
||||
pub fn build(self) -> ComputedValues {
|
||||
ComputedValues::new(self.custom_properties,
|
||||
pub fn build(self) -> ComputedValuesInner {
|
||||
ComputedValuesInner::new(self.custom_properties,
|
||||
self.writing_mode,
|
||||
self.font_size_keyword,
|
||||
self.flags,
|
||||
|
@ -2553,12 +2597,12 @@ pub use self::lazy_static_module::INITIAL_SERVO_VALUES;
|
|||
mod lazy_static_module {
|
||||
use logical_geometry::WritingMode;
|
||||
use stylearc::Arc;
|
||||
use super::{ComputedValues, 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 {
|
||||
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:
|
||||
|
@ -2571,10 +2615,10 @@ mod lazy_static_module {
|
|||
% endfor
|
||||
custom_properties: None,
|
||||
writing_mode: WritingMode::empty(),
|
||||
flags: ComputedValueFlags::empty(),
|
||||
font_computation_data: FontComputationData::default_values(),
|
||||
rules: None,
|
||||
visited_style: None,
|
||||
flags: ComputedValueFlags::empty(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -2582,8 +2626,8 @@ mod lazy_static_module {
|
|||
/// A per-longhand function that performs the CSS cascade for that longhand.
|
||||
pub type CascadePropertyFn =
|
||||
extern "Rust" fn(declaration: &PropertyDeclaration,
|
||||
inherited_style: &ComputedValues,
|
||||
default_style: &ComputedValues,
|
||||
inherited_style: &ComputedValuesInner,
|
||||
default_style: &ComputedValuesInner,
|
||||
context: &mut computed::Context,
|
||||
cacheable: &mut bool,
|
||||
cascade_info: &mut Option<<&mut CascadeInfo>);
|
||||
|
@ -2644,14 +2688,14 @@ bitflags! {
|
|||
pub fn cascade(device: &Device,
|
||||
rule_node: &StrongRuleNode,
|
||||
guards: &StylesheetGuards,
|
||||
parent_style: Option<<&ComputedValues>,
|
||||
layout_parent_style: Option<<&ComputedValues>,
|
||||
parent_style: Option<<&ComputedValuesInner>,
|
||||
layout_parent_style: Option<<&ComputedValuesInner>,
|
||||
visited_style: Option<Arc<ComputedValues>>,
|
||||
cascade_info: Option<<&mut CascadeInfo>,
|
||||
font_metrics_provider: &FontMetricsProvider,
|
||||
flags: CascadeFlags,
|
||||
quirks_mode: QuirksMode)
|
||||
-> ComputedValues {
|
||||
-> ComputedValuesInner {
|
||||
debug_assert!(layout_parent_style.is_none() || parent_style.is_some());
|
||||
let (inherited_style, layout_parent_style) = match parent_style {
|
||||
Some(parent_style) => {
|
||||
|
@ -2706,14 +2750,14 @@ pub fn cascade(device: &Device,
|
|||
pub fn apply_declarations<'a, F, I>(device: &Device,
|
||||
rules: &StrongRuleNode,
|
||||
iter_declarations: F,
|
||||
inherited_style: &ComputedValues,
|
||||
layout_parent_style: &ComputedValues,
|
||||
inherited_style: &ComputedValuesInner,
|
||||
layout_parent_style: &ComputedValuesInner,
|
||||
visited_style: Option<Arc<ComputedValues>>,
|
||||
mut cascade_info: Option<<&mut CascadeInfo>,
|
||||
font_metrics_provider: &FontMetricsProvider,
|
||||
flags: CascadeFlags,
|
||||
quirks_mode: QuirksMode)
|
||||
-> ComputedValues
|
||||
-> ComputedValuesInner
|
||||
where F: Fn() -> I,
|
||||
I: Iterator<Item = (&'a PropertyDeclaration, CascadeLevel)>,
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ use std::io::{self, Write};
|
|||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
|
||||
use stylearc::{Arc, NonZeroPtrMut};
|
||||
use stylearc::{Arc, ArcBorrow, NonZeroPtrMut};
|
||||
use stylesheets::StyleRule;
|
||||
use thread_state;
|
||||
|
||||
|
@ -308,7 +308,7 @@ impl RuleTree {
|
|||
/// the old path is still valid.
|
||||
pub fn update_rule_at_level(&self,
|
||||
level: CascadeLevel,
|
||||
pdb: Option<&Arc<Locked<PropertyDeclarationBlock>>>,
|
||||
pdb: Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>,
|
||||
path: &StrongRuleNode,
|
||||
guards: &StylesheetGuards)
|
||||
-> Option<StrongRuleNode> {
|
||||
|
@ -347,7 +347,7 @@ impl RuleTree {
|
|||
// so let's skip it for now.
|
||||
let is_here_already = match ¤t.get().source {
|
||||
&StyleSource::Declarations(ref already_here) => {
|
||||
Arc::ptr_eq(pdb, already_here)
|
||||
pdb.with_arc(|arc| Arc::ptr_eq(arc, already_here))
|
||||
},
|
||||
_ => unreachable!("Replacing non-declarations style?"),
|
||||
};
|
||||
|
@ -371,13 +371,13 @@ impl RuleTree {
|
|||
if level.is_important() {
|
||||
if pdb.read_with(level.guard(guards)).any_important() {
|
||||
current = current.ensure_child(self.root.downgrade(),
|
||||
StyleSource::Declarations(pdb.clone()),
|
||||
StyleSource::Declarations(pdb.clone_arc()),
|
||||
level);
|
||||
}
|
||||
} else {
|
||||
if pdb.read_with(level.guard(guards)).any_normal() {
|
||||
current = current.ensure_child(self.root.downgrade(),
|
||||
StyleSource::Declarations(pdb.clone()),
|
||||
StyleSource::Declarations(pdb.clone_arc()),
|
||||
level);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ pub use gecko::restyle_damage::GeckoRestyleDamage as RestyleDamage;
|
|||
/// A type that represents the previous computed values needed for restyle
|
||||
/// damage calculation.
|
||||
#[cfg(feature = "servo")]
|
||||
pub type PreExistingComputedValues = ::properties::ServoComputedValues;
|
||||
pub type PreExistingComputedValues = ::properties::ComputedValues;
|
||||
|
||||
/// A type that represents the previous computed values needed for restyle
|
||||
/// damage calculation.
|
||||
|
|
|
@ -11,7 +11,7 @@ use euclid::{Size2D, TypedSize2D};
|
|||
use font_metrics::ServoMetricsProvider;
|
||||
use media_queries::MediaType;
|
||||
use parser::ParserContext;
|
||||
use properties::{ComputedValues, StyleBuilder};
|
||||
use properties::{ComputedValuesInner, StyleBuilder};
|
||||
use properties::longhands::font_size;
|
||||
use selectors::parser::SelectorParseError;
|
||||
use std::fmt;
|
||||
|
@ -62,11 +62,11 @@ impl Device {
|
|||
}
|
||||
|
||||
/// Return the default computed values for this device.
|
||||
pub fn default_computed_values(&self) -> &ComputedValues {
|
||||
pub fn default_computed_values(&self) -> &ComputedValuesInner {
|
||||
// FIXME(bz): This isn't really right, but it's no more wrong
|
||||
// than what we used to do. See
|
||||
// https://github.com/servo/servo/issues/14773 for fixing it properly.
|
||||
ComputedValues::initial_values()
|
||||
ComputedValuesInner::initial_values()
|
||||
}
|
||||
|
||||
/// Get the font size of the root element (for rem)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
use computed_values::display;
|
||||
use heapsize::HeapSizeOf;
|
||||
use matching::{StyleChange, StyleDifference};
|
||||
use properties::ServoComputedValues;
|
||||
use properties::ComputedValues;
|
||||
use std::fmt;
|
||||
|
||||
bitflags! {
|
||||
|
@ -60,8 +60,8 @@ impl HeapSizeOf for ServoRestyleDamage {
|
|||
impl ServoRestyleDamage {
|
||||
/// Compute the `StyleDifference` (including the appropriate restyle damage)
|
||||
/// for a given style change between `old` and `new`.
|
||||
pub fn compute_style_difference(old: &ServoComputedValues,
|
||||
new: &ServoComputedValues)
|
||||
pub fn compute_style_difference(old: &ComputedValues,
|
||||
new: &ComputedValues)
|
||||
-> StyleDifference {
|
||||
let damage = compute_damage(old, new);
|
||||
let change = if damage.is_empty() { StyleChange::Unchanged } else { StyleChange::Changed };
|
||||
|
@ -182,11 +182,11 @@ macro_rules! add_if_not_equal(
|
|||
})
|
||||
);
|
||||
|
||||
fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> ServoRestyleDamage {
|
||||
fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> ServoRestyleDamage {
|
||||
let mut damage = ServoRestyleDamage::empty();
|
||||
|
||||
// This should check every CSS property, as enumerated in the fields of
|
||||
// http://doc.servo.org/style/properties/struct.ServoComputedValues.html
|
||||
// http://doc.servo.org/style/properties/struct.ComputedValues.html
|
||||
|
||||
// FIXME: Test somehow that every property is included.
|
||||
|
||||
|
|
|
@ -166,6 +166,9 @@ impl PseudoElement {
|
|||
pub fn canonical(&self) -> PseudoElement {
|
||||
self.clone()
|
||||
}
|
||||
|
||||
/// Stub, only Gecko needs this
|
||||
pub fn pseudo_info(&self) { () }
|
||||
}
|
||||
|
||||
/// The type used for storing pseudo-class string arguments.
|
||||
|
|
|
@ -43,7 +43,7 @@ pub fn have_same_style_attribute<E>(
|
|||
match (target.style_attribute(), candidate.style_attribute()) {
|
||||
(None, None) => true,
|
||||
(Some(_), None) | (None, Some(_)) => false,
|
||||
(Some(a), Some(b)) => Arc::ptr_eq(a, b)
|
||||
(Some(a), Some(b)) => &*a as *const _ == &*b as *const _
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//! a computed style needs in order for it to adhere to the CSS spec.
|
||||
|
||||
use app_units::Au;
|
||||
use properties::{self, CascadeFlags, ComputedValues};
|
||||
use properties::{self, CascadeFlags, ComputedValuesInner};
|
||||
use properties::{IS_ROOT_ELEMENT, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, StyleBuilder};
|
||||
use properties::longhands::display::computed_value::T as display;
|
||||
use properties::longhands::float::computed_value::T as float;
|
||||
|
@ -54,7 +54,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
/// Apply the blockification rules based on the table in CSS 2.2 section 9.7.
|
||||
/// https://drafts.csswg.org/css2/visuren.html#dis-pos-flo
|
||||
fn blockify_if_necessary(&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
layout_parent_style: &ComputedValuesInner,
|
||||
flags: CascadeFlags) {
|
||||
let mut blockify = false;
|
||||
macro_rules! blockify_if {
|
||||
|
@ -136,7 +136,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
/// https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html
|
||||
/// https://github.com/servo/servo/issues/15754
|
||||
fn adjust_for_writing_mode(&mut self,
|
||||
layout_parent_style: &ComputedValues) {
|
||||
layout_parent_style: &ComputedValuesInner) {
|
||||
let our_writing_mode = self.style.get_inheritedbox().clone_writing_mode();
|
||||
let parent_writing_mode = layout_parent_style.get_inheritedbox().clone_writing_mode();
|
||||
|
||||
|
@ -196,7 +196,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
///
|
||||
/// See https://github.com/servo/servo/issues/15229
|
||||
#[cfg(feature = "servo")]
|
||||
fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValues) {
|
||||
fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValuesInner) {
|
||||
use computed_values::align_items::T as align_items;
|
||||
use computed_values::align_self::T as align_self;
|
||||
|
||||
|
@ -315,7 +315,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
}
|
||||
|
||||
/// Set the HAS_TEXT_DECORATION_LINES flag based on parent style.
|
||||
fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValues) {
|
||||
fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValuesInner) {
|
||||
use properties::computed_value_flags::HAS_TEXT_DECORATION_LINES;
|
||||
if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) ||
|
||||
!self.style.get_text().clone_text_decoration_line().is_empty() {
|
||||
|
@ -324,7 +324,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValues) -> bool {
|
||||
fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValuesInner) -> bool {
|
||||
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
||||
// Line break suppression should only be propagated to in-flow children.
|
||||
if self.style.floated() || self.style.out_of_flow_positioned() {
|
||||
|
@ -361,8 +361,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
/// * correct unicode-bidi.
|
||||
#[cfg(feature = "gecko")]
|
||||
fn adjust_for_ruby(&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
default_computed_values: &'b ComputedValues,
|
||||
layout_parent_style: &ComputedValuesInner,
|
||||
default_computed_values: &'b ComputedValuesInner,
|
||||
flags: CascadeFlags) {
|
||||
use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
|
||||
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
||||
|
@ -406,8 +406,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
/// When comparing to Gecko, this is similar to the work done by
|
||||
/// `nsStyleContext::ApplyStyleFixups`.
|
||||
pub fn adjust(&mut self,
|
||||
layout_parent_style: &ComputedValues,
|
||||
_default_computed_values: &'b ComputedValues,
|
||||
layout_parent_style: &ComputedValuesInner,
|
||||
_default_computed_values: &'b ComputedValuesInner,
|
||||
flags: CascadeFlags) {
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ use data::{ElementStyles, EagerPseudoStyles};
|
|||
use dom::TElement;
|
||||
use log::LogLevel::Trace;
|
||||
use matching::{CascadeVisitedMode, MatchMethods};
|
||||
use properties::{AnimationRules, CascadeFlags, ComputedValues};
|
||||
use properties::{AnimationRules, CascadeFlags, ComputedValues, ComputedValuesInner};
|
||||
use properties::{IS_ROOT_ELEMENT, PROHIBIT_DISPLAY_CONTENTS, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP};
|
||||
use properties::{VISITED_DEPENDENT_ONLY, cascade};
|
||||
use rule_tree::StrongRuleNode;
|
||||
|
@ -47,7 +47,7 @@ pub struct PrimaryStyle {
|
|||
fn with_default_parent_styles<E, F, R>(element: E, f: F) -> R
|
||||
where
|
||||
E: TElement,
|
||||
F: FnOnce(Option<&ComputedValues>, Option<&ComputedValues>) -> R,
|
||||
F: FnOnce(Option<&ComputedValues>, Option<&ComputedValuesInner>) -> R,
|
||||
{
|
||||
let parent_el = element.inheritance_parent();
|
||||
let parent_data = parent_el.as_ref().and_then(|e| e.borrow_data());
|
||||
|
@ -72,7 +72,7 @@ where
|
|||
layout_parent_style = Some(layout_parent_data.styles.primary());
|
||||
}
|
||||
|
||||
f(parent_style.map(|s| &**s), layout_parent_style.map(|s| &**s))
|
||||
f(parent_style.map(|x| &**x), layout_parent_style.map(|s| &***s))
|
||||
}
|
||||
|
||||
impl<'a, 'ctx, 'le, E> StyleResolverForElement<'a, 'ctx, 'le, E>
|
||||
|
@ -99,7 +99,7 @@ where
|
|||
pub fn resolve_primary_style(
|
||||
&mut self,
|
||||
parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValuesInner>,
|
||||
) -> PrimaryStyle {
|
||||
let primary_results =
|
||||
self.match_primary(VisitedHandlingMode::AllLinksUnvisited);
|
||||
|
@ -119,6 +119,7 @@ where
|
|||
relevant_link_found ||
|
||||
parent_style.and_then(|s| s.get_visited_style()).is_some();
|
||||
|
||||
let pseudo = self.element.implemented_pseudo_element();
|
||||
if should_compute_visited_style {
|
||||
visited_style = Some(self.cascade_style(
|
||||
visited_rules.as_ref().or(Some(&primary_results.rule_node)),
|
||||
|
@ -126,17 +127,16 @@ where
|
|||
parent_style,
|
||||
layout_parent_style,
|
||||
CascadeVisitedMode::Visited,
|
||||
/* pseudo = */ None,
|
||||
/* pseudo = */ pseudo.as_ref(),
|
||||
));
|
||||
}
|
||||
|
||||
let style = self.cascade_style(
|
||||
Some(&primary_results.rule_node),
|
||||
visited_style,
|
||||
parent_style,
|
||||
layout_parent_style,
|
||||
CascadeVisitedMode::Unvisited,
|
||||
/* pseudo = */ None,
|
||||
/* pseudo = */ pseudo.as_ref(),
|
||||
);
|
||||
|
||||
PrimaryStyle { style, }
|
||||
|
@ -147,7 +147,7 @@ where
|
|||
pub fn resolve_style(
|
||||
&mut self,
|
||||
parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValuesInner>,
|
||||
) -> ElementStyles {
|
||||
use properties::longhands::display::computed_value::T as display;
|
||||
|
||||
|
@ -168,7 +168,7 @@ where
|
|||
if primary_style.style.is_display_contents() {
|
||||
layout_parent_style
|
||||
} else {
|
||||
Some(&*primary_style.style)
|
||||
Some(&**primary_style.style)
|
||||
};
|
||||
SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| {
|
||||
let pseudo_style = self.resolve_pseudo_style(
|
||||
|
@ -216,7 +216,7 @@ where
|
|||
&mut self,
|
||||
inputs: CascadeInputs,
|
||||
parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValuesInner>,
|
||||
pseudo: Option<&PseudoElement>,
|
||||
) -> Arc<ComputedValues> {
|
||||
let mut style_if_visited = None;
|
||||
|
@ -272,7 +272,7 @@ where
|
|||
if primary_style.style.is_display_contents() {
|
||||
layout_parent_style
|
||||
} else {
|
||||
Some(&*primary_style.style)
|
||||
Some(&**primary_style.style)
|
||||
};
|
||||
|
||||
for (i, mut inputs) in pseudo_array.unwrap().iter_mut().enumerate() {
|
||||
|
@ -302,7 +302,7 @@ where
|
|||
&mut self,
|
||||
pseudo: &PseudoElement,
|
||||
originating_element_style: &PrimaryStyle,
|
||||
layout_parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValuesInner>,
|
||||
) -> Option<Arc<ComputedValues>> {
|
||||
let rules = self.match_pseudo(
|
||||
&originating_element_style.style,
|
||||
|
@ -398,7 +398,7 @@ where
|
|||
|
||||
fn match_pseudo(
|
||||
&mut self,
|
||||
originating_element_style: &ComputedValues,
|
||||
originating_element_style: &ComputedValuesInner,
|
||||
pseudo_element: &PseudoElement,
|
||||
visited_handling: VisitedHandlingMode,
|
||||
) -> Option<StrongRuleNode> {
|
||||
|
@ -463,7 +463,7 @@ where
|
|||
rules: Option<&StrongRuleNode>,
|
||||
style_if_visited: Option<Arc<ComputedValues>>,
|
||||
mut parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValuesInner>,
|
||||
cascade_visited: CascadeVisitedMode,
|
||||
pseudo: Option<&PseudoElement>,
|
||||
) -> Arc<ComputedValues> {
|
||||
|
@ -475,7 +475,7 @@ where
|
|||
}
|
||||
if cascade_visited.visited_dependent_only() {
|
||||
parent_style = parent_style.map(|s| {
|
||||
s.get_visited_style().map(|s| &**s).unwrap_or(s)
|
||||
s.get_visited_style().unwrap_or(s)
|
||||
});
|
||||
cascade_flags.insert(VISITED_DEPENDENT_ONLY);
|
||||
}
|
||||
|
@ -485,21 +485,38 @@ where
|
|||
cascade_flags.insert(IS_ROOT_ELEMENT);
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
let parent_style_context = parent_style;
|
||||
#[cfg(feature = "servo")]
|
||||
let parent_style_context = ();
|
||||
|
||||
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,
|
||||
parent_style.map(|x| &**x),
|
||||
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
|
||||
|
||||
// In case of NAC like ::placeholder we style it via
|
||||
// cascade_primary without a PseudoElement, but
|
||||
// the element itself is a pseudo, so try to use that
|
||||
// when `pseudo` is unset
|
||||
let pseudo_info = if let Some(pseudo) = pseudo {
|
||||
Some(pseudo.pseudo_info())
|
||||
} else {
|
||||
self.element.implemented_pseudo_element().map(|x| x.pseudo_info())
|
||||
};
|
||||
values.to_outer(self.context.shared.stylist.device(),
|
||||
parent_style_context,
|
||||
pseudo_info)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! A list of CSS rules.
|
||||
|
||||
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard};
|
||||
use stylearc::Arc;
|
||||
use stylearc::{Arc, RawOffsetArc};
|
||||
use stylesheets::{CssRule, RulesMutateError};
|
||||
use stylesheets::loader::StylesheetLoader;
|
||||
use stylesheets::memory::{MallocSizeOfFn, MallocSizeOfWithGuard};
|
||||
|
@ -109,7 +109,7 @@ pub trait CssRulesHelpers {
|
|||
-> Result<CssRule, RulesMutateError>;
|
||||
}
|
||||
|
||||
impl CssRulesHelpers for Arc<Locked<CssRules>> {
|
||||
impl CssRulesHelpers for RawOffsetArc<Locked<CssRules>> {
|
||||
fn insert_rule(&self,
|
||||
lock: &SharedRwLock,
|
||||
rule: &str,
|
||||
|
|
|
@ -16,8 +16,8 @@ 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::{AnimationRules, PropertyDeclarationBlock};
|
||||
use properties::{self, CascadeFlags, ComputedValues, ComputedValuesInner};
|
||||
use properties::{AnimationRules, PropertyDeclarationBlock, PseudoInfo, ParentStyleContextInfo};
|
||||
#[cfg(feature = "servo")]
|
||||
use properties::INHERIT_ALL;
|
||||
use rule_tree::{CascadeLevel, RuleTree, StyleSource};
|
||||
|
@ -37,7 +37,7 @@ use std::fmt::Debug;
|
|||
#[cfg(feature = "servo")]
|
||||
use std::marker::PhantomData;
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
use stylearc::Arc;
|
||||
use stylearc::{Arc, ArcBorrow};
|
||||
#[cfg(feature = "gecko")]
|
||||
use stylesheets::{CounterStyleRule, FontFaceRule};
|
||||
use stylesheets::{CssRule, StyleRule};
|
||||
|
@ -599,9 +599,11 @@ impl Stylist {
|
|||
pub fn precomputed_values_for_pseudo(&self,
|
||||
guards: &StylesheetGuards,
|
||||
pseudo: &PseudoElement,
|
||||
parent: Option<&Arc<ComputedValues>>,
|
||||
parent: Option<&ComputedValuesInner>,
|
||||
cascade_flags: CascadeFlags,
|
||||
font_metrics: &FontMetricsProvider)
|
||||
font_metrics: &FontMetricsProvider,
|
||||
pseudo_info: PseudoInfo,
|
||||
parent_style_context: ParentStyleContextInfo)
|
||||
-> Arc<ComputedValues> {
|
||||
debug_assert!(pseudo.is_precomputed());
|
||||
|
||||
|
@ -629,18 +631,17 @@ impl Stylist {
|
|||
// descendant of a display: contents element where display: contents is
|
||||
// the actual used value, and the computed value of it would need
|
||||
// blockification.
|
||||
let computed =
|
||||
properties::cascade(&self.device,
|
||||
&rule_node,
|
||||
guards,
|
||||
parent.map(|p| &**p),
|
||||
parent.map(|p| &**p),
|
||||
None,
|
||||
None,
|
||||
font_metrics,
|
||||
cascade_flags,
|
||||
self.quirks_mode);
|
||||
Arc::new(computed)
|
||||
properties::cascade(&self.device,
|
||||
&rule_node,
|
||||
guards,
|
||||
parent,
|
||||
parent,
|
||||
None,
|
||||
None,
|
||||
font_metrics,
|
||||
cascade_flags,
|
||||
self.quirks_mode).to_outer(self.device(), parent_style_context,
|
||||
Some(pseudo_info))
|
||||
}
|
||||
|
||||
/// Returns the style for an anonymous box of the given type.
|
||||
|
@ -648,7 +649,7 @@ impl Stylist {
|
|||
pub fn style_for_anonymous(&self,
|
||||
guards: &StylesheetGuards,
|
||||
pseudo: &PseudoElement,
|
||||
parent_style: &Arc<ComputedValues>)
|
||||
parent_style: &ComputedValuesInner)
|
||||
-> Arc<ComputedValues> {
|
||||
use font_metrics::ServoMetricsProvider;
|
||||
|
||||
|
@ -677,7 +678,7 @@ impl Stylist {
|
|||
cascade_flags.insert(INHERIT_ALL);
|
||||
}
|
||||
self.precomputed_values_for_pseudo(guards, &pseudo, Some(parent_style), cascade_flags,
|
||||
&ServoMetricsProvider)
|
||||
&ServoMetricsProvider, (), ())
|
||||
}
|
||||
|
||||
/// Computes a pseudo-element style lazily during layout.
|
||||
|
@ -692,9 +693,11 @@ impl Stylist {
|
|||
element: &E,
|
||||
pseudo: &PseudoElement,
|
||||
rule_inclusion: RuleInclusion,
|
||||
parent_style: &Arc<ComputedValues>,
|
||||
parent_style: &ComputedValuesInner,
|
||||
is_probe: bool,
|
||||
font_metrics: &FontMetricsProvider)
|
||||
font_metrics: &FontMetricsProvider,
|
||||
pseudo_info: PseudoInfo,
|
||||
parent_style_context: ParentStyleContextInfo)
|
||||
-> Option<Arc<ComputedValues>>
|
||||
where E: TElement,
|
||||
{
|
||||
|
@ -703,7 +706,9 @@ impl Stylist {
|
|||
self.compute_pseudo_element_style_with_inputs(&cascade_inputs,
|
||||
guards,
|
||||
parent_style,
|
||||
font_metrics)
|
||||
font_metrics,
|
||||
pseudo_info,
|
||||
parent_style_context)
|
||||
}
|
||||
|
||||
/// Computes a pseudo-element style lazily using the given CascadeInputs.
|
||||
|
@ -713,8 +718,10 @@ impl Stylist {
|
|||
pub fn compute_pseudo_element_style_with_inputs(&self,
|
||||
inputs: &CascadeInputs,
|
||||
guards: &StylesheetGuards,
|
||||
parent_style: &Arc<ComputedValues>,
|
||||
font_metrics: &FontMetricsProvider)
|
||||
parent_style: &ComputedValuesInner,
|
||||
font_metrics: &FontMetricsProvider,
|
||||
pseudo_info: PseudoInfo,
|
||||
parent_style_context: ParentStyleContextInfo)
|
||||
-> Option<Arc<ComputedValues>>
|
||||
{
|
||||
// We may have only visited rules in cases when we are actually
|
||||
|
@ -736,7 +743,7 @@ impl Stylist {
|
|||
// We want to use the visited bits (if any) from our parent style as
|
||||
// our parent.
|
||||
let inherited_style =
|
||||
parent_style.get_visited_style().unwrap_or(&*parent_style);
|
||||
parent_style.get_visited_style().map(|x| &**x).unwrap_or(parent_style);
|
||||
|
||||
// FIXME(emilio): The lack of layout_parent_style here could be
|
||||
// worrying, but we're probably dropping the display fixup for
|
||||
|
@ -753,9 +760,10 @@ impl Stylist {
|
|||
None,
|
||||
font_metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode);
|
||||
self.quirks_mode).to_outer(self.device(), parent_style_context,
|
||||
Some(pseudo_info.clone()));
|
||||
|
||||
Some(Arc::new(computed))
|
||||
Some(computed)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -768,19 +776,18 @@ impl Stylist {
|
|||
// difficult to assert that display: contents nodes never arrive here
|
||||
// (tl;dr: It doesn't apply for replaced elements and such, but the
|
||||
// computed value is still "contents").
|
||||
let computed =
|
||||
properties::cascade(&self.device,
|
||||
rules,
|
||||
guards,
|
||||
Some(parent_style),
|
||||
Some(parent_style),
|
||||
visited_values,
|
||||
None,
|
||||
font_metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode);
|
||||
|
||||
Some(Arc::new(computed))
|
||||
Some(properties::cascade(&self.device,
|
||||
rules,
|
||||
guards,
|
||||
Some(parent_style),
|
||||
Some(parent_style),
|
||||
visited_values,
|
||||
None,
|
||||
font_metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode).to_outer(self.device(),
|
||||
parent_style_context,
|
||||
Some(pseudo_info)))
|
||||
}
|
||||
|
||||
/// Computes the cascade inputs for a lazily-cascaded pseudo-element.
|
||||
|
@ -1108,8 +1115,8 @@ impl Stylist {
|
|||
&self,
|
||||
element: &E,
|
||||
pseudo_element: Option<&PseudoElement>,
|
||||
style_attribute: Option<&Arc<Locked<PropertyDeclarationBlock>>>,
|
||||
smil_override: Option<&Arc<Locked<PropertyDeclarationBlock>>>,
|
||||
style_attribute: Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>,
|
||||
smil_override: Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>,
|
||||
animation_rules: AnimationRules,
|
||||
rule_inclusion: RuleInclusion,
|
||||
applicable_declarations: &mut V,
|
||||
|
@ -1213,7 +1220,7 @@ impl Stylist {
|
|||
if let Some(sa) = style_attribute {
|
||||
Push::push(
|
||||
applicable_declarations,
|
||||
ApplicableDeclarationBlock::from_declarations(sa.clone(),
|
||||
ApplicableDeclarationBlock::from_declarations(sa.clone_arc(),
|
||||
CascadeLevel::StyleAttributeNormal));
|
||||
}
|
||||
|
||||
|
@ -1222,7 +1229,7 @@ impl Stylist {
|
|||
if let Some(so) = smil_override {
|
||||
Push::push(
|
||||
applicable_declarations,
|
||||
ApplicableDeclarationBlock::from_declarations(so.clone(),
|
||||
ApplicableDeclarationBlock::from_declarations(so.clone_arc(),
|
||||
CascadeLevel::SMILOverride));
|
||||
}
|
||||
|
||||
|
@ -1317,8 +1324,9 @@ impl Stylist {
|
|||
/// Computes styles for a given declaration with parent_style.
|
||||
pub fn compute_for_declarations(&self,
|
||||
guards: &StylesheetGuards,
|
||||
parent_style: &Arc<ComputedValues>,
|
||||
declarations: Arc<Locked<PropertyDeclarationBlock>>)
|
||||
parent_style: &ComputedValuesInner,
|
||||
declarations: Arc<Locked<PropertyDeclarationBlock>>,
|
||||
parent_style_context: ParentStyleContextInfo)
|
||||
-> Arc<ComputedValues> {
|
||||
use font_metrics::get_metrics_provider_for_product;
|
||||
|
||||
|
@ -1333,16 +1341,16 @@ impl Stylist {
|
|||
// font styles in <canvas> via Servo_StyleSet_ResolveForDeclarations.
|
||||
// It is unclear if visited styles are meaningful for this case.
|
||||
let metrics = get_metrics_provider_for_product();
|
||||
Arc::new(properties::cascade(&self.device,
|
||||
&rule_node,
|
||||
guards,
|
||||
Some(parent_style),
|
||||
Some(parent_style),
|
||||
None,
|
||||
None,
|
||||
&metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode))
|
||||
properties::cascade(&self.device,
|
||||
&rule_node,
|
||||
guards,
|
||||
Some(parent_style),
|
||||
Some(parent_style),
|
||||
None,
|
||||
None,
|
||||
&metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode).to_outer(self.device(), parent_style_context, None)
|
||||
}
|
||||
|
||||
/// Accessor for a shared reference to the device.
|
||||
|
|
|
@ -485,7 +485,7 @@ where
|
|||
StyleResolverForElement::new(*ancestor, context, rule_inclusion)
|
||||
.resolve_primary_style(
|
||||
style.as_ref().map(|s| &**s),
|
||||
layout_parent_style.as_ref().map(|s| &**s)
|
||||
layout_parent_style.as_ref().map(|s| &***s)
|
||||
);
|
||||
|
||||
let is_display_contents = primary_style.style.is_display_contents();
|
||||
|
@ -502,7 +502,7 @@ where
|
|||
StyleResolverForElement::new(element, context, rule_inclusion)
|
||||
.resolve_style(
|
||||
style.as_ref().map(|s| &**s),
|
||||
layout_parent_style.as_ref().map(|s| &**s)
|
||||
layout_parent_style.as_ref().map(|s| &***s)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use font_metrics::FontMetricsProvider;
|
|||
use media_queries::Device;
|
||||
#[cfg(feature = "gecko")]
|
||||
use properties;
|
||||
use properties::{ComputedValues, StyleBuilder};
|
||||
use properties::{ComputedValuesInner, StyleBuilder};
|
||||
use std::f32;
|
||||
use std::f64;
|
||||
use std::f64::consts::PI;
|
||||
|
@ -72,13 +72,13 @@ pub struct Context<'a> {
|
|||
pub device: &'a Device,
|
||||
|
||||
/// The style we're inheriting from.
|
||||
pub inherited_style: &'a ComputedValues,
|
||||
pub inherited_style: &'a ComputedValuesInner,
|
||||
|
||||
/// The style of the layout parent node. This will almost always be
|
||||
/// `inherited_style`, except when `display: contents` is at play, in which
|
||||
/// case it's the style of the last ancestor with a `display` value that
|
||||
/// isn't `contents`.
|
||||
pub layout_parent_style: &'a ComputedValues,
|
||||
pub layout_parent_style: &'a ComputedValuesInner,
|
||||
|
||||
/// Values accessed through this need to be in the properties "computed
|
||||
/// early": color, text-decoration, font-size, display, position, float,
|
||||
|
@ -115,7 +115,7 @@ impl<'a> Context<'a> {
|
|||
/// The current viewport size.
|
||||
pub fn viewport_size(&self) -> Size2D<Au> { self.device.au_viewport_size() }
|
||||
/// The style we're inheriting from.
|
||||
pub fn inherited_style(&self) -> &ComputedValues { &self.inherited_style }
|
||||
pub fn inherited_style(&self) -> &ComputedValuesInner { &self.inherited_style }
|
||||
/// The current style. Note that only "eager" properties should be accessed
|
||||
/// from here, see the comment in the member.
|
||||
pub fn style(&self) -> &StyleBuilder { &self.style }
|
||||
|
|
|
@ -39,7 +39,7 @@ use style::gecko_bindings::bindings::{RawServoNamespaceRule, RawServoNamespaceRu
|
|||
use style::gecko_bindings::bindings::{RawServoPageRule, RawServoPageRuleBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoStyleSetBorrowed, RawServoStyleSetOwned};
|
||||
use style::gecko_bindings::bindings::{RawServoStyleSheetContentsBorrowed, ServoComputedValuesBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoStyleSheetContentsStrong, ServoComputedValuesStrong};
|
||||
use style::gecko_bindings::bindings::{RawServoStyleSheetContentsStrong, ServoStyleContextBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoSupportsRule, RawServoSupportsRuleBorrowed};
|
||||
use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong};
|
||||
use style::gecko_bindings::bindings::{nsACString, nsAString, nsCSSPropertyIDSetBorrowedMut};
|
||||
|
@ -61,13 +61,14 @@ use style::gecko_bindings::bindings::RawServoAnimationValueMapBorrowedMut;
|
|||
use style::gecko_bindings::bindings::RawServoAnimationValueStrong;
|
||||
use style::gecko_bindings::bindings::RawServoStyleRuleBorrowed;
|
||||
use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||
use style::gecko_bindings::bindings::ServoStyleContextBorrowedOrNull;
|
||||
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
|
||||
use style::gecko_bindings::bindings::nsTimingFunctionBorrowed;
|
||||
use style::gecko_bindings::bindings::nsTimingFunctionBorrowedMut;
|
||||
use style::gecko_bindings::structs;
|
||||
use style::gecko_bindings::structs::{CSSPseudoElementType, CompositeOperation, Loader};
|
||||
use style::gecko_bindings::structs::{RawServoStyleRule, ServoStyleSheet};
|
||||
use style::gecko_bindings::structs::{SheetParsingMode, nsIAtom, nsCSSPropertyID};
|
||||
use style::gecko_bindings::structs::{RawServoStyleRule, ServoStyleContextStrong};
|
||||
use style::gecko_bindings::structs::{ServoStyleSheet, SheetParsingMode, nsIAtom, nsCSSPropertyID};
|
||||
use style::gecko_bindings::structs::{nsCSSFontFaceRule, nsCSSCounterStyleRule};
|
||||
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair};
|
||||
use style::gecko_bindings::structs::IterationCompositeOperation;
|
||||
|
@ -90,9 +91,9 @@ use style::invalidation::element::restyle_hints::{self, RestyleHint};
|
|||
use style::media_queries::{MediaList, parse_media_query_list};
|
||||
use style::parallel;
|
||||
use style::parser::ParserContext;
|
||||
use style::properties::{ComputedValues, Importance, SourcePropertyDeclaration};
|
||||
use style::properties::{ComputedValues, ComputedValuesInner, Importance, SourcePropertyDeclaration};
|
||||
use style::properties::{LonghandIdSet, PropertyDeclaration, PropertyDeclarationBlock, PropertyId, StyleBuilder};
|
||||
use style::properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
|
||||
use style::properties::{SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, PseudoInfo, ParentStyleContextInfo};
|
||||
use style::properties::animated_properties::{Animatable, AnimatableLonghand, AnimationValue};
|
||||
use style::properties::parse_one_declaration_into;
|
||||
use style::rule_tree::StyleSource;
|
||||
|
@ -101,7 +102,7 @@ use style::sequential;
|
|||
use style::shared_lock::{SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked};
|
||||
use style::string_cache::Atom;
|
||||
use style::style_adjuster::StyleAdjuster;
|
||||
use style::stylearc::Arc;
|
||||
use style::stylearc::{Arc, RawOffsetArc};
|
||||
use style::stylesheets::{CssRule, CssRules, CssRuleType, CssRulesHelpers, DocumentRule};
|
||||
use style::stylesheets::{ImportRule, KeyframesRule, MallocSizeOfWithGuard, MediaRule};
|
||||
use style::stylesheets::{NamespaceRule, Origin, PageRule, StyleRule, SupportsRule};
|
||||
|
@ -429,7 +430,7 @@ pub extern "C" fn Servo_AnimationCompose(raw_value_map: RawServoAnimationValueMa
|
|||
let previous_composed_value = value_map.get(&property).cloned();
|
||||
previous_composed_value.or_else(|| {
|
||||
let raw_base_style = unsafe { Gecko_AnimationGetBaseStyle(base_values, css_property) };
|
||||
AnimationValue::arc_from_borrowed(&raw_base_style).map(|v| v.as_ref()).cloned()
|
||||
AnimationValue::arc_from_borrowed(&raw_base_style).map(|v| &**v).cloned()
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
@ -459,7 +460,7 @@ pub extern "C" fn Servo_AnimationCompose(raw_value_map: RawServoAnimationValueMa
|
|||
|
||||
// Composite with underlying value.
|
||||
// A return value of None means, "Just use keyframe_value as-is."
|
||||
let composite_endpoint = |keyframe_value: Option<&Arc<AnimationValue>>,
|
||||
let composite_endpoint = |keyframe_value: Option<&RawOffsetArc<AnimationValue>>,
|
||||
composite_op: CompositeOperation| -> Option<AnimationValue> {
|
||||
match keyframe_value {
|
||||
Some(keyframe_value) => {
|
||||
|
@ -498,7 +499,7 @@ pub extern "C" fn Servo_AnimationCompose(raw_value_map: RawServoAnimationValueMa
|
|||
let raw_last_value;
|
||||
let last_value = if !last_segment.mToValue.mServo.mRawPtr.is_null() {
|
||||
raw_last_value = unsafe { &*last_segment.mToValue.mServo.mRawPtr };
|
||||
AnimationValue::as_arc(&raw_last_value).as_ref()
|
||||
&*AnimationValue::as_arc(&raw_last_value)
|
||||
} else {
|
||||
debug_assert!(need_underlying_value,
|
||||
"Should have detected we need an underlying value");
|
||||
|
@ -506,7 +507,7 @@ pub extern "C" fn Servo_AnimationCompose(raw_value_map: RawServoAnimationValueMa
|
|||
};
|
||||
|
||||
// As with composite_endpoint, a return value of None means, "Use keyframe_value as-is."
|
||||
let apply_iteration_composite = |keyframe_value: Option<&Arc<AnimationValue>>,
|
||||
let apply_iteration_composite = |keyframe_value: Option<&RawOffsetArc<AnimationValue>>,
|
||||
composited_value: Option<AnimationValue>|
|
||||
-> Option<AnimationValue> {
|
||||
let count = computed_timing.mCurrentIteration;
|
||||
|
@ -655,10 +656,10 @@ pub extern "C" fn Servo_AnimationValue_Uncompute(value: RawServoAnimationValueBo
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawServoStyleSetBorrowed,
|
||||
element: RawGeckoElementBorrowed,
|
||||
computed_values: ServoComputedValuesBorrowed,
|
||||
computed_values: ServoStyleContextBorrowed,
|
||||
snapshots: *const ServoElementSnapshotTable,
|
||||
pseudo_type: CSSPseudoElementType)
|
||||
-> ServoComputedValuesStrong
|
||||
-> ServoStyleContextStrong
|
||||
{
|
||||
use style::style_resolver::StyleResolverForElement;
|
||||
|
||||
|
@ -731,7 +732,6 @@ pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(computed_values: Se
|
|||
None => { return Strong::null(); }
|
||||
};
|
||||
|
||||
let computed_values = ComputedValues::as_arc(&computed_values);
|
||||
Arc::new(AnimationValue::from_computed_values(&property, computed_values)).into_strong()
|
||||
}
|
||||
|
||||
|
@ -1244,7 +1244,7 @@ pub extern "C" fn Servo_StyleRule_SetStyle(rule: RawServoStyleRuleBorrowed,
|
|||
declarations: RawServoDeclarationBlockBorrowed) {
|
||||
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||
write_locked_arc(rule, |rule: &mut StyleRule| {
|
||||
rule.block = declarations.clone();
|
||||
rule.block = declarations.clone_arc();
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1382,7 +1382,7 @@ pub extern "C" fn Servo_Keyframe_SetStyle(keyframe: RawServoKeyframeBorrowed,
|
|||
declarations: RawServoDeclarationBlockBorrowed) {
|
||||
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||
write_locked_arc(keyframe, |keyframe: &mut Keyframe| {
|
||||
keyframe.block = declarations.clone();
|
||||
keyframe.block = declarations.clone_arc();
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1480,7 +1480,7 @@ pub extern "C" fn Servo_PageRule_SetStyle(rule: RawServoPageRuleBorrowed,
|
|||
declarations: RawServoDeclarationBlockBorrowed) {
|
||||
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||
write_locked_arc(rule, |rule: &mut PageRule| {
|
||||
rule.block = declarations.clone();
|
||||
rule.block = declarations.clone_arc();
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1501,10 +1501,11 @@ pub extern "C" fn Servo_DocumentRule_GetConditionText(rule: RawServoDocumentRule
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: ServoComputedValuesBorrowedOrNull,
|
||||
pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: ServoStyleContextBorrowedOrNull,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
raw_data: RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong {
|
||||
-> ServoStyleContextStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let guards = StylesheetGuards::same(&guard);
|
||||
|
@ -1513,22 +1514,24 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
|||
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 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)
|
||||
data.stylist.precomputed_values_for_pseudo(&guards, &pseudo, parent_style_or_null.map(|x| &**x),
|
||||
cascade_flags, &metrics,
|
||||
(pseudo_tag, pseudo_type),
|
||||
parent_style_or_null)
|
||||
.into_strong()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
is_probe: bool,
|
||||
inherited_style: ServoComputedValuesBorrowedOrNull,
|
||||
parent_style_context: ServoStyleContextBorrowedOrNull,
|
||||
raw_data: RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong
|
||||
-> ServoStyleContextStrong
|
||||
{
|
||||
let element = GeckoElement(element);
|
||||
let data = unsafe { element.ensure_data() };
|
||||
|
@ -1543,7 +1546,9 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
|||
return if is_probe {
|
||||
Strong::null()
|
||||
} else {
|
||||
doc_data.default_computed_values().clone().into_strong()
|
||||
doc_data.default_computed_values()
|
||||
.clone().to_outer(doc_data.stylist.device(), parent_style_context,
|
||||
Some((pseudo_tag, pseudo_type))).into_strong()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1558,9 +1563,11 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
|||
&pseudo,
|
||||
RuleInclusion::All,
|
||||
&data.styles,
|
||||
ComputedValues::arc_from_borrowed(&inherited_style),
|
||||
inherited_style,
|
||||
&*doc_data,
|
||||
is_probe
|
||||
is_probe,
|
||||
(pseudo_tag, pseudo_type),
|
||||
parent_style_context
|
||||
);
|
||||
|
||||
match style {
|
||||
|
@ -1574,7 +1581,7 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_SetExplicitStyle(element: RawGeckoElementBorrowed,
|
||||
style: ServoComputedValuesBorrowed)
|
||||
style: ServoStyleContextBorrowed)
|
||||
{
|
||||
let element = GeckoElement(element);
|
||||
let style = ComputedValues::as_arc(&style);
|
||||
|
@ -1583,7 +1590,7 @@ pub extern "C" fn Servo_SetExplicitStyle(element: RawGeckoElementBorrowed,
|
|||
// work for other things, we just haven't had a reason to do so.
|
||||
debug_assert!(element.get_data().is_none());
|
||||
let mut data = unsafe { element.ensure_data() };
|
||||
data.styles.primary = Some(style.clone());
|
||||
data.styles.primary = Some(style.clone_arc());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -1612,9 +1619,11 @@ fn get_pseudo_style(
|
|||
pseudo: &PseudoElement,
|
||||
rule_inclusion: RuleInclusion,
|
||||
styles: &ElementStyles,
|
||||
inherited_styles: Option<&Arc<ComputedValues>>,
|
||||
inherited_styles: Option<&ComputedValuesInner>,
|
||||
doc_data: &PerDocumentStyleDataImpl,
|
||||
is_probe: bool,
|
||||
pseudo_info: PseudoInfo,
|
||||
parent_style_context: ParentStyleContextInfo,
|
||||
) -> Option<Arc<ComputedValues>> {
|
||||
let style = match pseudo.cascade_type() {
|
||||
PseudoElementCascadeType::Eager => {
|
||||
|
@ -1636,13 +1645,15 @@ fn get_pseudo_style(
|
|||
&inputs,
|
||||
&guards,
|
||||
inherited_styles,
|
||||
&metrics)
|
||||
&metrics,
|
||||
pseudo_info.clone(),
|
||||
parent_style_context)
|
||||
})
|
||||
},
|
||||
_ => {
|
||||
debug_assert!(inherited_styles.is_none() ||
|
||||
ptr::eq(&**inherited_styles.unwrap(),
|
||||
&**styles.primary()));
|
||||
ptr::eq(&*inherited_styles.unwrap(),
|
||||
&***styles.primary()));
|
||||
styles.pseudos.get(&pseudo).cloned()
|
||||
},
|
||||
}
|
||||
|
@ -1650,8 +1661,8 @@ fn get_pseudo_style(
|
|||
PseudoElementCascadeType::Precomputed => unreachable!("No anonymous boxes"),
|
||||
PseudoElementCascadeType::Lazy => {
|
||||
debug_assert!(inherited_styles.is_none() ||
|
||||
ptr::eq(&**inherited_styles.unwrap(),
|
||||
&**styles.primary()));
|
||||
ptr::eq(&*inherited_styles.unwrap(),
|
||||
&***styles.primary()));
|
||||
let base = if pseudo.inherits_from_default_values() {
|
||||
doc_data.default_computed_values()
|
||||
} else {
|
||||
|
@ -1667,7 +1678,9 @@ fn get_pseudo_style(
|
|||
rule_inclusion,
|
||||
base,
|
||||
is_probe,
|
||||
&metrics)
|
||||
&metrics,
|
||||
pseudo_info.clone(),
|
||||
parent_style_context)
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1676,24 +1689,26 @@ fn get_pseudo_style(
|
|||
}
|
||||
|
||||
Some(style.unwrap_or_else(|| {
|
||||
Arc::new(StyleBuilder::for_inheritance(
|
||||
StyleBuilder::for_inheritance(
|
||||
styles.primary(),
|
||||
doc_data.default_computed_values(),
|
||||
).build())
|
||||
).build().to_outer(doc_data.stylist.device(), parent_style_context,
|
||||
Some(pseudo_info))
|
||||
}))
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_Inherit(
|
||||
raw_data: RawServoStyleSetBorrowed,
|
||||
parent_style: ServoComputedValuesBorrowedOrNull,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
parent_style_context: ServoStyleContextBorrowedOrNull,
|
||||
target: structs::InheritTarget
|
||||
) -> ServoComputedValuesStrong {
|
||||
) -> ServoStyleContextStrong {
|
||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
let maybe_arc = ComputedValues::arc_from_borrowed(&parent_style);
|
||||
|
||||
let for_text = target == structs::InheritTarget::Text;
|
||||
let style = if let Some(reference) = maybe_arc.as_ref() {
|
||||
let style = if let Some(reference) = parent_style_context {
|
||||
let mut style =
|
||||
StyleBuilder::for_inheritance(reference,
|
||||
&data.default_computed_values());
|
||||
|
@ -1702,28 +1717,38 @@ pub extern "C" fn Servo_ComputedValues_Inherit(
|
|||
.adjust_for_text();
|
||||
}
|
||||
|
||||
Arc::new(style.build())
|
||||
style.build()
|
||||
} else {
|
||||
debug_assert!(!for_text);
|
||||
data.default_computed_values().clone()
|
||||
};
|
||||
|
||||
style.into_strong()
|
||||
let pseudo_info = if pseudo_tag.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some((pseudo_tag, pseudo_type))
|
||||
};
|
||||
|
||||
style.to_outer(data.stylist.device(), parent_style_context, pseudo_info).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(),
|
||||
None => Strong::null(),
|
||||
pub extern "C" fn Servo_StyleContext_NewContext(values: ServoComputedValuesBorrowed,
|
||||
parent: ServoStyleContextBorrowedOrNull,
|
||||
pres_context: bindings::RawGeckoPresContextBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom)
|
||||
-> ServoStyleContextStrong {
|
||||
unsafe {
|
||||
(*values).clone().to_outer_helper(pres_context, parent,
|
||||
pseudo_type, pseudo_tag).into_strong()
|
||||
}
|
||||
}
|
||||
|
||||
#[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;
|
||||
let flags = values.flags;
|
||||
let mut result = 0;
|
||||
if flags.contains(HAS_TEXT_DECORATION_LINES) {
|
||||
result |= structs::NS_STYLE_HAS_TEXT_DECORATION_LINES as u64;
|
||||
|
@ -1737,7 +1762,6 @@ pub extern "C" fn Servo_ComputedValues_GetStyleBits(values: ServoComputedValuesB
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_SpecifiesAnimationsOrTransitions(values: ServoComputedValuesBorrowed)
|
||||
-> bool {
|
||||
let values = ComputedValues::as_arc(&values);
|
||||
let b = values.get_box();
|
||||
b.specifies_animations() || b.specifies_transitions()
|
||||
}
|
||||
|
@ -1747,25 +1771,24 @@ pub extern "C" fn Servo_ComputedValues_EqualCustomProperties(
|
|||
first: ServoComputedValuesBorrowed,
|
||||
second: ServoComputedValuesBorrowed
|
||||
) -> bool {
|
||||
let first = ComputedValues::as_arc(&first);
|
||||
let second = ComputedValues::as_arc(&second);
|
||||
first.get_custom_properties() == second.get_custom_properties()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_GetStyleRuleList(values: ServoComputedValuesBorrowed,
|
||||
rules: RawGeckoServoStyleRuleListBorrowedMut) {
|
||||
let values = ComputedValues::as_arc(&values);
|
||||
if let Some(ref rule_node) = values.rules {
|
||||
let mut result = vec![];
|
||||
for node in rule_node.self_and_ancestors() {
|
||||
if let &StyleSource::Style(ref rule) = node.style_source() {
|
||||
result.push(Locked::<StyleRule>::arc_as_borrowed(&rule));
|
||||
result.push(rule);
|
||||
}
|
||||
}
|
||||
unsafe { rules.set_len(result.len() as u32) };
|
||||
for (&src, dest) in result.into_iter().zip(rules.iter_mut()) {
|
||||
*dest = src;
|
||||
for (ref src, ref mut dest) in result.into_iter().zip(rules.iter_mut()) {
|
||||
src.with_raw_offset_arc(|arc| {
|
||||
**dest = *Locked::<StyleRule>::arc_as_borrowed(arc);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2772,7 +2795,7 @@ pub extern "C" fn Servo_TakeChangeHint(element: RawGeckoElementBorrowed,
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
||||
_raw_data: RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong
|
||||
-> ServoStyleContextStrong
|
||||
{
|
||||
let element = GeckoElement(element);
|
||||
debug!("Servo_ResolveStyle: {:?}", element);
|
||||
|
@ -2789,10 +2812,12 @@ pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
parent_style_context: ServoStyleContextBorrowedOrNull,
|
||||
rule_inclusion: StyleRuleInclusion,
|
||||
snapshots: *const ServoElementSnapshotTable,
|
||||
raw_data: RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong
|
||||
-> ServoStyleContextStrong
|
||||
{
|
||||
debug_assert!(!snapshots.is_null());
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
|
@ -2813,6 +2838,8 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
|||
/* inherited_styles = */ None,
|
||||
&*data,
|
||||
/* is_probe = */ false,
|
||||
(pseudo_tag, pseudo_type),
|
||||
parent_style_context
|
||||
).expect("We're not probing, so we should always get a style \
|
||||
back")
|
||||
}
|
||||
|
@ -2866,16 +2893,17 @@ fn simulate_compute_values_failure(_: &PropertyValuePair) -> bool {
|
|||
|
||||
fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
|
||||
font_metrics_provider: &'a FontMetricsProvider,
|
||||
style: &'a ComputedValues,
|
||||
parent_style: &'a Option<&Arc<ComputedValues>>)
|
||||
style: &'a ComputedValuesInner,
|
||||
parent_style: &'a Option<&ComputedValuesInner>)
|
||||
-> Context<'a> {
|
||||
let default_values = per_doc_data.default_computed_values();
|
||||
let inherited_style = parent_style.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,
|
||||
|
@ -2896,12 +2924,11 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
|
|||
|
||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
let metrics = get_metrics_provider_for_product();
|
||||
let style = ComputedValues::as_arc(&style);
|
||||
|
||||
let element = GeckoElement(element);
|
||||
let parent_element = element.inheritance_parent();
|
||||
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary());
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &***x);
|
||||
|
||||
let mut context = create_context(&data, &metrics, style, &parent_style);
|
||||
|
||||
|
@ -2976,13 +3003,12 @@ pub extern "C" fn Servo_GetAnimationValues(declarations: RawServoDeclarationBloc
|
|||
raw_data: RawServoStyleSetBorrowed,
|
||||
animation_values: RawGeckoServoAnimationValueListBorrowedMut) {
|
||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
let style = ComputedValues::as_arc(&style);
|
||||
let metrics = get_metrics_provider_for_product();
|
||||
|
||||
let element = GeckoElement(element);
|
||||
let parent_element = element.inheritance_parent();
|
||||
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary());
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &***x);
|
||||
|
||||
let mut context = create_context(&data, &metrics, style, &parent_style);
|
||||
|
||||
|
@ -3005,13 +3031,12 @@ pub extern "C" fn Servo_AnimationValue_Compute(element: RawGeckoElementBorrowed,
|
|||
raw_data: RawServoStyleSetBorrowed)
|
||||
-> RawServoAnimationValueStrong {
|
||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
let style = ComputedValues::as_arc(&style);
|
||||
let metrics = get_metrics_provider_for_product();
|
||||
|
||||
let element = GeckoElement(element);
|
||||
let parent_element = element.inheritance_parent();
|
||||
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary());
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &***x);
|
||||
|
||||
let mut context = create_context(&data, &metrics, style, &parent_style);
|
||||
|
||||
|
@ -3255,16 +3280,16 @@ pub extern "C" fn Servo_StyleSet_GetCounterStyleRule(raw_data: RawServoStyleSetB
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSet_ResolveForDeclarations(
|
||||
raw_data: RawServoStyleSetBorrowed,
|
||||
parent_style_or_null: ServoComputedValuesBorrowedOrNull,
|
||||
declarations: RawServoDeclarationBlockBorrowed
|
||||
) -> ServoComputedValuesStrong {
|
||||
parent_style_context: ServoStyleContextBorrowedOrNull,
|
||||
declarations: RawServoDeclarationBlockBorrowed,
|
||||
) -> ServoStyleContextStrong {
|
||||
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,
|
||||
let parent_style = match parent_style_context {
|
||||
Some(parent) => &**parent,
|
||||
None => doc_data.default_computed_values(),
|
||||
};
|
||||
|
||||
|
@ -3272,7 +3297,8 @@ pub extern "C" fn Servo_StyleSet_ResolveForDeclarations(
|
|||
|
||||
doc_data.stylist.compute_for_declarations(&guards,
|
||||
parent_style,
|
||||
declarations.clone()).into_strong()
|
||||
declarations.clone_arc(),
|
||||
parent_style_context).into_strong()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -3332,7 +3358,7 @@ pub extern "C" fn Servo_StyleSet_HasStateDependency(
|
|||
pub extern "C" fn Servo_GetCustomPropertyValue(computed_values: ServoComputedValuesBorrowed,
|
||||
name: *const nsAString,
|
||||
value: *mut nsAString) -> bool {
|
||||
let custom_properties = match ComputedValues::as_arc(&computed_values).custom_properties() {
|
||||
let custom_properties = match computed_values.custom_properties() {
|
||||
Some(p) => p,
|
||||
None => return false,
|
||||
};
|
||||
|
@ -3349,7 +3375,7 @@ pub extern "C" fn Servo_GetCustomPropertyValue(computed_values: ServoComputedVal
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_GetCustomPropertiesCount(computed_values: ServoComputedValuesBorrowed) -> u32 {
|
||||
match ComputedValues::as_arc(&computed_values).custom_properties() {
|
||||
match computed_values.custom_properties() {
|
||||
Some(p) => p.len() as u32,
|
||||
None => 0,
|
||||
}
|
||||
|
@ -3359,7 +3385,7 @@ pub extern "C" fn Servo_GetCustomPropertiesCount(computed_values: ServoComputedV
|
|||
pub extern "C" fn Servo_GetCustomPropertyNameAt(computed_values: ServoComputedValuesBorrowed,
|
||||
index: u32,
|
||||
name: *mut nsAString) -> bool {
|
||||
let custom_properties = match ComputedValues::as_arc(&computed_values).custom_properties() {
|
||||
let custom_properties = match computed_values.custom_properties() {
|
||||
Some(p) => p,
|
||||
None => return false,
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@ use style::context::QuirksMode;
|
|||
use style::font_metrics::ServoMetricsProvider;
|
||||
use style::media_queries::{Device, MediaType};
|
||||
use style::parser::ParserContext;
|
||||
use style::properties::{ComputedValues, StyleBuilder};
|
||||
use style::properties::{ComputedValues, ComputedValuesInner, StyleBuilder};
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
use style::values::computed::{Context, ToComputedValue};
|
||||
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError};
|
||||
|
@ -49,7 +49,7 @@ fn assert_computed_serialization<C, F, T>(f: F, input: &'static str, output: &st
|
|||
T: ToComputedValue<ComputedValue=C>, C: ToCss
|
||||
{
|
||||
let viewport_size = TypedSize2D::new(0., 0.);
|
||||
let initial_style = ComputedValues::initial_values();
|
||||
let initial_style = ComputedValuesInner::initial_values();
|
||||
let device = Device::new(MediaType::Screen, viewport_size);
|
||||
|
||||
let context = Context {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue