Bug 1298588 part 8. Pass a SharedStyleContext, not a Stylist, to Legalizer methods. r=bholley

This commit is contained in:
Boris Zbarsky 2017-01-04 13:46:41 -05:00
parent d3e34db508
commit 09c74190b9

View file

@ -54,7 +54,6 @@ use style::logical_geometry::Direction;
use style::properties::{self, ServoComputedValues}; use style::properties::{self, ServoComputedValues};
use style::selector_parser::{PseudoElement, RestyleDamage}; use style::selector_parser::{PseudoElement, RestyleDamage};
use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW}; use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW};
use style::stylist::Stylist;
use style::values::Either; use style::values::Either;
use table::TableFlow; use table::TableFlow;
use table_caption::TableCaptionFlow; use table_caption::TableCaptionFlow;
@ -470,7 +469,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
} }
inline_flow_ref.finish(); inline_flow_ref.finish();
legalizer.add_child(&self.style_context().stylist, flow, inline_flow_ref) legalizer.add_child(self.style_context(), flow, inline_flow_ref)
} }
fn build_block_flow_using_construction_result_of_child( fn build_block_flow_using_construction_result_of_child(
@ -503,7 +502,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
legalizer, legalizer,
node); node);
} }
legalizer.add_child(&self.style_context().stylist, flow, kid_flow) legalizer.add_child(self.style_context(), flow, kid_flow)
} }
abs_descendants.push_descendants(kid_abs_descendants); abs_descendants.push_descendants(kid_abs_descendants);
} }
@ -537,7 +536,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
node); node);
// Push the flow generated by the {ib} split onto our list of flows. // Push the flow generated by the {ib} split onto our list of flows.
legalizer.add_child(&self.style_context().stylist, flow, kid_flow) legalizer.add_child(self.style_context(), flow, kid_flow)
} }
// Add the fragments to the list we're maintaining. // Add the fragments to the list we're maintaining.
@ -1123,7 +1122,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
caption_side::T::top); caption_side::T::top);
if let ConstructionResult::Flow(table_flow, table_abs_descendants) = construction_result { if let ConstructionResult::Flow(table_flow, table_abs_descendants) = construction_result {
legalizer.add_child(&self.style_context().stylist, &mut wrapper_flow, table_flow); legalizer.add_child(self.style_context(), &mut wrapper_flow, table_flow);
abs_descendants.push_descendants(table_abs_descendants); abs_descendants.push_descendants(table_abs_descendants);
} }
@ -1889,16 +1888,16 @@ impl Legalizer {
/// Makes the `child` flow a new child of `parent`. Anonymous flows are automatically inserted /// Makes the `child` flow a new child of `parent`. Anonymous flows are automatically inserted
/// to keep the tree legal. /// to keep the tree legal.
fn add_child(&mut self, stylist: &Stylist, parent: &mut FlowRef, mut child: FlowRef) { fn add_child(&mut self, context: &SharedStyleContext, parent: &mut FlowRef, mut child: FlowRef) {
while !self.stack.is_empty() { while !self.stack.is_empty() {
if self.try_to_add_child(stylist, parent, &mut child) { if self.try_to_add_child(context, parent, &mut child) {
return return
} }
self.flush_top_of_stack(parent) self.flush_top_of_stack(parent)
} }
while !self.try_to_add_child(stylist, parent, &mut child) { while !self.try_to_add_child(context, parent, &mut child) {
self.push_next_anonymous_flow(stylist, parent) self.push_next_anonymous_flow(context, parent)
} }
} }
@ -1915,7 +1914,7 @@ impl Legalizer {
/// This method attempts to create anonymous blocks in between `parent` and `child` if and only /// This method attempts to create anonymous blocks in between `parent` and `child` if and only
/// if those blocks will only ever have `child` as their sole child. At present, this is only /// if those blocks will only ever have `child` as their sole child. At present, this is only
/// true for anonymous block children of flex flows. /// true for anonymous block children of flex flows.
fn try_to_add_child(&mut self, stylist: &Stylist, parent: &mut FlowRef, child: &mut FlowRef) fn try_to_add_child(&mut self, context: &SharedStyleContext, parent: &mut FlowRef, child: &mut FlowRef)
-> bool { -> bool {
let mut parent = self.stack.last_mut().unwrap_or(parent); let mut parent = self.stack.last_mut().unwrap_or(parent);
let (parent_class, child_class) = (parent.class(), child.class()); let (parent_class, child_class) = (parent.class(), child.class());
@ -1947,7 +1946,7 @@ impl Legalizer {
(FlowClass::Flex, FlowClass::Inline) => { (FlowClass::Flex, FlowClass::Inline) => {
flow::mut_base(FlowRef::deref_mut(child)).flags.insert(MARGINS_CANNOT_COLLAPSE); flow::mut_base(FlowRef::deref_mut(child)).flags.insert(MARGINS_CANNOT_COLLAPSE);
let mut block_wrapper = let mut block_wrapper =
Legalizer::create_anonymous_flow(stylist, Legalizer::create_anonymous_flow(context,
parent, parent,
&[PseudoElement::ServoAnonymousBlock], &[PseudoElement::ServoAnonymousBlock],
SpecificFragmentInfo::Generic, SpecificFragmentInfo::Generic,
@ -1999,32 +1998,32 @@ impl Legalizer {
/// Adds the anonymous flow that would be necessary to make an illegal child of `parent` legal /// Adds the anonymous flow that would be necessary to make an illegal child of `parent` legal
/// to the stack. /// to the stack.
fn push_next_anonymous_flow(&mut self, stylist: &Stylist, parent: &FlowRef) { fn push_next_anonymous_flow(&mut self, context: &SharedStyleContext, parent: &FlowRef) {
let parent_class = self.stack.last().unwrap_or(parent).class(); let parent_class = self.stack.last().unwrap_or(parent).class();
match parent_class { match parent_class {
FlowClass::TableRow => { FlowClass::TableRow => {
self.push_new_anonymous_flow(stylist, self.push_new_anonymous_flow(context,
parent, parent,
&[PseudoElement::ServoAnonymousTableCell], &[PseudoElement::ServoAnonymousTableCell],
SpecificFragmentInfo::TableCell, SpecificFragmentInfo::TableCell,
TableCellFlow::from_fragment) TableCellFlow::from_fragment)
} }
FlowClass::Table | FlowClass::TableRowGroup => { FlowClass::Table | FlowClass::TableRowGroup => {
self.push_new_anonymous_flow(stylist, self.push_new_anonymous_flow(context,
parent, parent,
&[PseudoElement::ServoAnonymousTableRow], &[PseudoElement::ServoAnonymousTableRow],
SpecificFragmentInfo::TableRow, SpecificFragmentInfo::TableRow,
TableRowFlow::from_fragment) TableRowFlow::from_fragment)
} }
FlowClass::TableWrapper => { FlowClass::TableWrapper => {
self.push_new_anonymous_flow(stylist, self.push_new_anonymous_flow(context,
parent, parent,
&[PseudoElement::ServoAnonymousTable], &[PseudoElement::ServoAnonymousTable],
SpecificFragmentInfo::Table, SpecificFragmentInfo::Table,
TableFlow::from_fragment) TableFlow::from_fragment)
} }
_ => { _ => {
self.push_new_anonymous_flow(stylist, self.push_new_anonymous_flow(context,
parent, parent,
&[PseudoElement::ServoTableWrapper, &[PseudoElement::ServoTableWrapper,
PseudoElement::ServoAnonymousTableWrapper], PseudoElement::ServoAnonymousTableWrapper],
@ -2036,13 +2035,13 @@ impl Legalizer {
/// Creates an anonymous flow and pushes it onto the stack. /// Creates an anonymous flow and pushes it onto the stack.
fn push_new_anonymous_flow<F>(&mut self, fn push_new_anonymous_flow<F>(&mut self,
stylist: &Stylist, context: &SharedStyleContext,
reference: &FlowRef, reference: &FlowRef,
pseudos: &[PseudoElement], pseudos: &[PseudoElement],
specific_fragment_info: SpecificFragmentInfo, specific_fragment_info: SpecificFragmentInfo,
constructor: extern "Rust" fn(Fragment) -> F) constructor: extern "Rust" fn(Fragment) -> F)
where F: Flow { where F: Flow {
let new_flow = Legalizer::create_anonymous_flow(stylist, let new_flow = Legalizer::create_anonymous_flow(context,
reference, reference,
pseudos, pseudos,
specific_fragment_info, specific_fragment_info,
@ -2055,7 +2054,7 @@ impl Legalizer {
/// ///
/// This method invokes the supplied constructor function on the given specific fragment info /// This method invokes the supplied constructor function on the given specific fragment info
/// in order to actually generate the flow. /// in order to actually generate the flow.
fn create_anonymous_flow<F>(stylist: &Stylist, fn create_anonymous_flow<F>(context: &SharedStyleContext,
reference: &FlowRef, reference: &FlowRef,
pseudos: &[PseudoElement], pseudos: &[PseudoElement],
specific_fragment_info: SpecificFragmentInfo, specific_fragment_info: SpecificFragmentInfo,
@ -2065,7 +2064,7 @@ impl Legalizer {
let reference_block = reference.as_block(); let reference_block = reference.as_block();
let mut new_style = reference_block.fragment.style.clone(); let mut new_style = reference_block.fragment.style.clone();
for pseudo in pseudos { for pseudo in pseudos {
new_style = stylist.style_for_anonymous_box(pseudo, &new_style) new_style = context.stylist.style_for_anonymous_box(pseudo, &new_style)
} }
let fragment = reference_block.fragment let fragment = reference_block.fragment
.create_similar_anonymous_fragment(new_style, .create_similar_anonymous_fragment(new_style,