Bug 1298588 part 9, servo piece. Pass through useful default styles to cascade(). r=bholley

This commit is contained in:
Boris Zbarsky 2017-01-04 13:48:23 -05:00
parent 09c74190b9
commit 61f6025dc3
6 changed files with 22 additions and 10 deletions

View file

@ -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,

View file

@ -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());
}

View file

@ -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)

View file

@ -1714,13 +1714,14 @@ bitflags! {
pub fn cascade(viewport_size: Size2D<Au>,
rule_node: &StrongRuleNode,
parent_style: Option<<&ComputedValues>,
default_style: &Arc<ComputedValues>,
cascade_info: Option<<&mut CascadeInfo>,
error_reporter: StdBox<ParseErrorReporter + Send>,
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.

View file

@ -274,6 +274,7 @@ impl Stylist {
pub fn precomputed_values_for_pseudo(&self,
pseudo: &PseudoElement,
parent: Option<&Arc<ComputedValues>>,
default: &Arc<ComputedValues>,
inherit_all: bool)
-> Option<ComputedStyle> {
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<ComputedValues>)
parent_style: &Arc<ComputedValues>,
default_style: &Arc<ComputedValues>)
-> Arc<ComputedValues> {
// 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<E>(&self,
element: &E,
pseudo: &PseudoElement,
parent: &Arc<ComputedValues>)
parent: &Arc<ComputedValues>,
default: &Arc<ComputedValues>)
-> Option<ComputedStyle>
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());

View file

@ -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())
},
}