diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 1d9c1212ad6..7c039d38729 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -661,7 +661,8 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> if node_is_input_or_text_area { style = self.style_context() .stylist - .style_for_anonymous_box(&PseudoElement::ServoInputText, &style) + .style_for_anonymous_box(&PseudoElement::ServoInputText, &style, + &self.style_context().default_computed_values) } self.create_fragments_for_node_text_content(&mut initial_fragments, node, &style) @@ -1093,7 +1094,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> let wrapper_style = self.style_context() .stylist .style_for_anonymous_box(&PseudoElement::ServoTableWrapper, - &table_style); + &table_style, &self.style_context().default_computed_values); let wrapper_fragment = Fragment::from_opaque_node_and_style(node.opaque(), PseudoElementType::Normal, @@ -2064,7 +2065,7 @@ impl Legalizer { let reference_block = reference.as_block(); let mut new_style = reference_block.fragment.style.clone(); for pseudo in pseudos { - new_style = context.stylist.style_for_anonymous_box(pseudo, &new_style) + new_style = context.stylist.style_for_anonymous_box(pseudo, &new_style, &context.default_computed_values) } let fragment = reference_block.fragment .create_similar_anonymous_fragment(new_style, diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs index 77414fa48d5..0103b185096 100644 --- a/components/script_layout_interface/wrapper_traits.rs +++ b/components/script_layout_interface/wrapper_traits.rs @@ -391,6 +391,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug + context.stylist.precomputed_values_for_pseudo( &style_pseudo, Some(&data.styles().primary.values), + &context.default_computed_values, false); data.styles_mut().pseudos .insert(style_pseudo.clone(), new_style.unwrap()); @@ -407,7 +408,8 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug + .lazily_compute_pseudo_element_style( self, &style_pseudo, - &data.styles().primary.values); + &data.styles().primary.values, + &context.default_computed_values); data.styles_mut().pseudos .insert(style_pseudo.clone(), new_style.unwrap()); } diff --git a/components/style/matching.rs b/components/style/matching.rs index af8cd4bf627..f8d019ea775 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -470,6 +470,7 @@ trait PrivateMatchMethods: TElement { cascade(shared_context.viewport_size, rule_node, Some(&***parent_style), + &shared_context.default_computed_values, Some(&mut cascade_info), shared_context.error_reporter.clone(), cascade_flags) @@ -478,6 +479,7 @@ trait PrivateMatchMethods: TElement { cascade(shared_context.viewport_size, rule_node, None, + &shared_context.default_computed_values, Some(&mut cascade_info), shared_context.error_reporter.clone(), cascade_flags) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 647a5e7539d..66a8e158582 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1714,13 +1714,14 @@ bitflags! { pub fn cascade(viewport_size: Size2D, rule_node: &StrongRuleNode, parent_style: Option<<&ComputedValues>, + default_style: &Arc, cascade_info: Option<<&mut CascadeInfo>, error_reporter: StdBox, flags: CascadeFlags) -> ComputedValues { let (is_root_element, inherited_style) = match parent_style { Some(parent_style) => (false, parent_style), - None => (true, ComputedValues::initial_values()), + None => (true, &**default_style), }; // Hold locks until after the apply_declarations() call returns. // Use filter_map because the root node has no style source. diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 1a1dfabaf3d..e0c6bf3f68d 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -274,6 +274,7 @@ impl Stylist { pub fn precomputed_values_for_pseudo(&self, pseudo: &PseudoElement, parent: Option<&Arc>, + default: &Arc, inherit_all: bool) -> Option { debug_assert!(SelectorImpl::pseudo_element_cascade_type(pseudo).is_precomputed()); @@ -293,6 +294,7 @@ impl Stylist { properties::cascade(self.device.au_viewport_size(), &rule_node, parent.map(|p| &**p), + default, None, Box::new(StdoutErrorReporter), flags); @@ -306,7 +308,8 @@ impl Stylist { #[cfg(feature = "servo")] pub fn style_for_anonymous_box(&self, pseudo: &PseudoElement, - parent_style: &Arc) + parent_style: &Arc, + default_style: &Arc) -> Arc { // For most (but not all) pseudo-elements, we inherit all values from the parent. let inherit_all = match *pseudo { @@ -325,7 +328,7 @@ impl Stylist { unreachable!("That pseudo doesn't represent an anonymous box!") } }; - self.precomputed_values_for_pseudo(&pseudo, Some(parent_style), inherit_all) + self.precomputed_values_for_pseudo(&pseudo, Some(parent_style), default_style, inherit_all) .expect("style_for_anonymous_box(): No precomputed values for that pseudo!") .values } @@ -340,7 +343,8 @@ impl Stylist { pub fn lazily_compute_pseudo_element_style(&self, element: &E, pseudo: &PseudoElement, - parent: &Arc) + parent: &Arc, + default: &Arc) -> Option where E: ElementExt + fmt::Debug + @@ -368,6 +372,7 @@ impl Stylist { properties::cascade(self.device.au_viewport_size(), &rule_node, Some(&**parent), + default, None, Box::new(StdoutErrorReporter), CascadeFlags::empty()); diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 49625543e73..9c947fc73f7 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -531,7 +531,8 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: let maybe_parent = ComputedValues::arc_from_borrowed(&parent_style_or_null); - let new_computed = data.stylist.precomputed_values_for_pseudo(&pseudo, maybe_parent, false) + let new_computed = data.stylist.precomputed_values_for_pseudo(&pseudo, maybe_parent, + &data.default_computed_values, false) .map(|styles| styles.values); new_computed.map_or(Strong::null(), |c| c.into_strong()) } @@ -574,7 +575,7 @@ fn get_pseudo_style(element: GeckoElement, pseudo_tag: *mut nsIAtom, PseudoElementCascadeType::Lazy => { let d = doc_data.borrow_mut(); let base = &styles.primary.values; - d.stylist.lazily_compute_pseudo_element_style(&element, &pseudo, base) + d.stylist.lazily_compute_pseudo_element_style(&element, &pseudo, base, &d.default_computed_values) .map(|s| s.values.clone()) }, }