servo: Merge #14848 - Stop using global initial styles for stylo; the initial styles need to be per-document (from bzbarsky:initial-styles); r=bholley
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix https://bugzilla.mozilla.org/show_bug.cgi?id=1298588 <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests on the servo side because behavior is unchanged. Gecko-side tests probably exist. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 143dfc879e609603839502d61bc064fba96cc80f
This commit is contained in:
@@ -54,7 +54,6 @@ use style::logical_geometry::Direction;
|
||||
use style::properties::{self, ServoComputedValues};
|
||||
use style::selector_parser::{PseudoElement, RestyleDamage};
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW};
|
||||
use style::stylist::Stylist;
|
||||
use style::values::Either;
|
||||
use table::TableFlow;
|
||||
use table_caption::TableCaptionFlow;
|
||||
@@ -470,7 +469,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||
}
|
||||
|
||||
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(
|
||||
@@ -503,7 +502,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||
legalizer,
|
||||
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);
|
||||
}
|
||||
@@ -537,7 +536,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||
node);
|
||||
|
||||
// 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.
|
||||
@@ -662,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)
|
||||
@@ -1094,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,
|
||||
@@ -1123,7 +1123,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||
caption_side::T::top);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1889,16 +1889,16 @@ impl Legalizer {
|
||||
|
||||
/// Makes the `child` flow a new child of `parent`. Anonymous flows are automatically inserted
|
||||
/// 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() {
|
||||
if self.try_to_add_child(stylist, parent, &mut child) {
|
||||
if self.try_to_add_child(context, parent, &mut child) {
|
||||
return
|
||||
}
|
||||
self.flush_top_of_stack(parent)
|
||||
}
|
||||
|
||||
while !self.try_to_add_child(stylist, parent, &mut child) {
|
||||
self.push_next_anonymous_flow(stylist, parent)
|
||||
while !self.try_to_add_child(context, parent, &mut child) {
|
||||
self.push_next_anonymous_flow(context, parent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1915,7 +1915,7 @@ impl Legalizer {
|
||||
/// 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
|
||||
/// 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 {
|
||||
let mut parent = self.stack.last_mut().unwrap_or(parent);
|
||||
let (parent_class, child_class) = (parent.class(), child.class());
|
||||
@@ -1947,7 +1947,7 @@ impl Legalizer {
|
||||
(FlowClass::Flex, FlowClass::Inline) => {
|
||||
flow::mut_base(FlowRef::deref_mut(child)).flags.insert(MARGINS_CANNOT_COLLAPSE);
|
||||
let mut block_wrapper =
|
||||
Legalizer::create_anonymous_flow(stylist,
|
||||
Legalizer::create_anonymous_flow(context,
|
||||
parent,
|
||||
&[PseudoElement::ServoAnonymousBlock],
|
||||
SpecificFragmentInfo::Generic,
|
||||
@@ -1999,32 +1999,32 @@ impl Legalizer {
|
||||
|
||||
/// Adds the anonymous flow that would be necessary to make an illegal child of `parent` legal
|
||||
/// 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();
|
||||
match parent_class {
|
||||
FlowClass::TableRow => {
|
||||
self.push_new_anonymous_flow(stylist,
|
||||
self.push_new_anonymous_flow(context,
|
||||
parent,
|
||||
&[PseudoElement::ServoAnonymousTableCell],
|
||||
SpecificFragmentInfo::TableCell,
|
||||
TableCellFlow::from_fragment)
|
||||
}
|
||||
FlowClass::Table | FlowClass::TableRowGroup => {
|
||||
self.push_new_anonymous_flow(stylist,
|
||||
self.push_new_anonymous_flow(context,
|
||||
parent,
|
||||
&[PseudoElement::ServoAnonymousTableRow],
|
||||
SpecificFragmentInfo::TableRow,
|
||||
TableRowFlow::from_fragment)
|
||||
}
|
||||
FlowClass::TableWrapper => {
|
||||
self.push_new_anonymous_flow(stylist,
|
||||
self.push_new_anonymous_flow(context,
|
||||
parent,
|
||||
&[PseudoElement::ServoAnonymousTable],
|
||||
SpecificFragmentInfo::Table,
|
||||
TableFlow::from_fragment)
|
||||
}
|
||||
_ => {
|
||||
self.push_new_anonymous_flow(stylist,
|
||||
self.push_new_anonymous_flow(context,
|
||||
parent,
|
||||
&[PseudoElement::ServoTableWrapper,
|
||||
PseudoElement::ServoAnonymousTableWrapper],
|
||||
@@ -2036,13 +2036,13 @@ impl Legalizer {
|
||||
|
||||
/// Creates an anonymous flow and pushes it onto the stack.
|
||||
fn push_new_anonymous_flow<F>(&mut self,
|
||||
stylist: &Stylist,
|
||||
context: &SharedStyleContext,
|
||||
reference: &FlowRef,
|
||||
pseudos: &[PseudoElement],
|
||||
specific_fragment_info: SpecificFragmentInfo,
|
||||
constructor: extern "Rust" fn(Fragment) -> F)
|
||||
where F: Flow {
|
||||
let new_flow = Legalizer::create_anonymous_flow(stylist,
|
||||
let new_flow = Legalizer::create_anonymous_flow(context,
|
||||
reference,
|
||||
pseudos,
|
||||
specific_fragment_info,
|
||||
@@ -2055,7 +2055,7 @@ impl Legalizer {
|
||||
///
|
||||
/// This method invokes the supplied constructor function on the given specific fragment info
|
||||
/// in order to actually generate the flow.
|
||||
fn create_anonymous_flow<F>(stylist: &Stylist,
|
||||
fn create_anonymous_flow<F>(context: &SharedStyleContext,
|
||||
reference: &FlowRef,
|
||||
pseudos: &[PseudoElement],
|
||||
specific_fragment_info: SpecificFragmentInfo,
|
||||
@@ -2065,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 = 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,
|
||||
|
||||
Reference in New Issue
Block a user