mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
cargo fix --edition-idioms
This commit is contained in:
parent
b1fd6237d1
commit
2012be4a8b
203 changed files with 665 additions and 1281 deletions
|
@ -163,7 +163,7 @@ pub fn update_animation_state<E>(
|
|||
/// lock held.
|
||||
pub fn recalc_style_for_animations<E>(
|
||||
context: &LayoutContext,
|
||||
flow: &mut Flow,
|
||||
flow: &mut dyn Flow,
|
||||
animations: &FxHashMap<OpaqueNode, Vec<Animation>>,
|
||||
) where
|
||||
E: TElement,
|
||||
|
|
|
@ -546,7 +546,7 @@ pub struct AbsoluteAssignBSizesTraversal<'a>(pub &'a SharedStyleContext<'a>);
|
|||
|
||||
impl<'a> PreorderFlowTraversal for AbsoluteAssignBSizesTraversal<'a> {
|
||||
#[inline]
|
||||
fn process(&self, flow: &mut Flow) {
|
||||
fn process(&self, flow: &mut dyn Flow) {
|
||||
if !flow.is_block_like() {
|
||||
return;
|
||||
}
|
||||
|
@ -938,7 +938,7 @@ impl BlockFlow {
|
|||
layout_context: &LayoutContext,
|
||||
mut fragmentation_context: Option<FragmentationContext>,
|
||||
margins_may_collapse: MarginsMayCollapseFlag,
|
||||
) -> Option<Arc<Flow>> {
|
||||
) -> Option<Arc<dyn Flow>> {
|
||||
let _scope = layout_debug_scope!("assign_block_size_block_base {:x}", self.base.debug_id());
|
||||
|
||||
let mut break_at = None;
|
||||
|
@ -1272,7 +1272,7 @@ impl BlockFlow {
|
|||
}
|
||||
}
|
||||
|
||||
if (&*self as &Flow).contains_roots_of_absolute_flow_tree() {
|
||||
if (&*self as &dyn Flow).contains_roots_of_absolute_flow_tree() {
|
||||
// Assign block-sizes for all flows in this absolute flow tree.
|
||||
// This is preorder because the block-size of an absolute flow may depend on
|
||||
// the block-size of its containing block, which may also be an absolute flow.
|
||||
|
@ -1307,7 +1307,7 @@ impl BlockFlow {
|
|||
if let Some(child) = child_remaining {
|
||||
children.push_front_arc(child);
|
||||
}
|
||||
Some(Arc::new(self.clone_with_children(children)) as Arc<Flow>)
|
||||
Some(Arc::new(self.clone_with_children(children)) as Arc<dyn Flow>)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -1592,7 +1592,7 @@ impl BlockFlow {
|
|||
content_inline_size: Au,
|
||||
mut callback: F,
|
||||
) where
|
||||
F: FnMut(&mut Flow, usize, Au, WritingMode, &mut Au, &mut Au),
|
||||
F: FnMut(&mut dyn Flow, usize, Au, WritingMode, &mut Au, &mut Au),
|
||||
{
|
||||
let flags = self.base.flags.clone();
|
||||
|
||||
|
@ -2246,7 +2246,7 @@ impl Flow for BlockFlow {
|
|||
self.assign_inline_position_for_formatting_context(layout_context, content_box);
|
||||
}
|
||||
|
||||
if (self as &Flow).floats_might_flow_through() {
|
||||
if (self as &dyn Flow).floats_might_flow_through() {
|
||||
self.base.thread_id = parent_thread_id;
|
||||
if self
|
||||
.base
|
||||
|
@ -2283,7 +2283,7 @@ impl Flow for BlockFlow {
|
|||
&mut self,
|
||||
layout_context: &LayoutContext,
|
||||
fragmentation_context: Option<FragmentationContext>,
|
||||
) -> Option<Arc<Flow>> {
|
||||
) -> Option<Arc<dyn Flow>> {
|
||||
if self.fragment.is_replaced() {
|
||||
let _scope = layout_debug_scope!(
|
||||
"assign_replaced_block_size_if_necessary {:x}",
|
||||
|
@ -2613,7 +2613,7 @@ impl Flow for BlockFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -2641,7 +2641,7 @@ impl Flow for BlockFlow {
|
|||
);
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
(*mutator)(&mut self.fragment)
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ pub struct LayoutContext<'a> {
|
|||
pub style_context: SharedStyleContext<'a>,
|
||||
|
||||
/// Reference to the script thread image cache.
|
||||
pub image_cache: Arc<ImageCache>,
|
||||
pub image_cache: Arc<dyn ImageCache>,
|
||||
|
||||
/// Interface to the font cache thread.
|
||||
pub font_cache_thread: Mutex<FontCacheThread>,
|
||||
|
@ -77,7 +77,7 @@ pub struct LayoutContext<'a> {
|
|||
>,
|
||||
|
||||
/// Paint worklets
|
||||
pub registered_painters: &'a RegisteredPainters,
|
||||
pub registered_painters: &'a dyn RegisteredPainters,
|
||||
|
||||
/// A list of in-progress image loads to be shared with the script thread.
|
||||
/// A None value means that this layout was not initiated by the script thread.
|
||||
|
@ -197,5 +197,5 @@ pub trait RegisteredPainter: RegisteredSpeculativePainter + Painter {}
|
|||
/// A set of registered painters
|
||||
pub trait RegisteredPainters: Sync {
|
||||
/// Look up a painter
|
||||
fn get(&self, name: &Atom) -> Option<&RegisteredPainter>;
|
||||
fn get(&self, name: &Atom) -> Option<&dyn RegisteredPainter>;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ struct FlexItem {
|
|||
}
|
||||
|
||||
impl FlexItem {
|
||||
pub fn new(index: usize, flow: &Flow) -> FlexItem {
|
||||
pub fn new(index: usize, flow: &dyn Flow) -> FlexItem {
|
||||
let style = &flow.as_block().fragment.style;
|
||||
let flex_grow = style.get_position().flex_grow;
|
||||
let flex_shrink = style.get_position().flex_shrink;
|
||||
|
@ -140,7 +140,7 @@ impl FlexItem {
|
|||
/// Initialize the used flex base size, minimal main size and maximal main size.
|
||||
/// For block mode container this method should be called in assign_block_size()
|
||||
/// pass so that the item has already been layouted.
|
||||
pub fn init_sizes(&mut self, flow: &mut Flow, containing_length: Au, direction: Direction) {
|
||||
pub fn init_sizes(&mut self, flow: &mut dyn Flow, containing_length: Au, direction: Direction) {
|
||||
let block = flow.as_mut_block();
|
||||
match direction {
|
||||
// TODO(stshine): the definition of min-{width, height} in style component
|
||||
|
@ -207,7 +207,7 @@ impl FlexItem {
|
|||
|
||||
/// Returns the outer main size of the item, including paddings and margins,
|
||||
/// clamped by max and min size.
|
||||
pub fn outer_main_size(&self, flow: &Flow, direction: Direction) -> Au {
|
||||
pub fn outer_main_size(&self, flow: &dyn Flow, direction: Direction) -> Au {
|
||||
let ref fragment = flow.as_block().fragment;
|
||||
let outer_width = match direction {
|
||||
Direction::Inline => {
|
||||
|
@ -223,7 +223,7 @@ impl FlexItem {
|
|||
}
|
||||
|
||||
/// Returns the number of auto margins in given direction.
|
||||
pub fn auto_margin_count(&self, flow: &Flow, direction: Direction) -> i32 {
|
||||
pub fn auto_margin_count(&self, flow: &dyn Flow, direction: Direction) -> i32 {
|
||||
let margin = flow.as_block().fragment.style.logical_margin();
|
||||
let mut margin_count = 0;
|
||||
match direction {
|
||||
|
@ -577,7 +577,7 @@ impl FlexFlow {
|
|||
|
||||
debug!("content_inline_size = {:?}", content_inline_size);
|
||||
|
||||
let child_count = ImmutableFlowUtils::child_count(self as &Flow) as i32;
|
||||
let child_count = ImmutableFlowUtils::child_count(self as &dyn Flow) as i32;
|
||||
debug!("child_count = {:?}", child_count);
|
||||
if child_count == 0 {
|
||||
return;
|
||||
|
@ -1055,7 +1055,7 @@ impl Flow for FlexFlow {
|
|||
CollapsibleMargins::Collapse(block_start, block_end);
|
||||
|
||||
// TODO(stshine): assign proper static position for absolute descendants.
|
||||
if (&*self as &Flow).contains_roots_of_absolute_flow_tree() {
|
||||
if (&*self as &dyn Flow).contains_roots_of_absolute_flow_tree() {
|
||||
// Assign block-sizes for all flows in this absolute flow tree.
|
||||
// This is preorder because the block-size of an absolute flow may depend on
|
||||
// the block-size of its containing block, which may also be an absolute flow.
|
||||
|
@ -1124,7 +1124,7 @@ impl Flow for FlexFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -1135,7 +1135,7 @@ impl Flow for FlexFlow {
|
|||
);
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
self.block_flow.mutate_fragments(mutator);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -494,7 +494,7 @@ impl SpeculatedFloatPlacement {
|
|||
|
||||
/// Given the speculated inline size of the floats out for the inorder predecessor of this
|
||||
/// flow, computes the speculated inline size of the floats flowing in.
|
||||
pub fn compute_floats_in(&mut self, flow: &mut Flow) {
|
||||
pub fn compute_floats_in(&mut self, flow: &mut dyn Flow) {
|
||||
let base_flow = flow.base();
|
||||
if base_flow.flags.contains(FlowFlags::CLEARS_LEFT) {
|
||||
self.left = Au(0)
|
||||
|
@ -506,7 +506,7 @@ impl SpeculatedFloatPlacement {
|
|||
|
||||
/// Given the speculated inline size of the floats out for this flow's last child, computes the
|
||||
/// speculated inline size of the floats out for this flow.
|
||||
pub fn compute_floats_out(&mut self, flow: &mut Flow) {
|
||||
pub fn compute_floats_out(&mut self, flow: &mut dyn Flow) {
|
||||
if flow.is_block_like() {
|
||||
let block_flow = flow.as_block();
|
||||
if block_flow.formatting_context_type() != FormattingContextType::None {
|
||||
|
@ -564,7 +564,9 @@ impl SpeculatedFloatPlacement {
|
|||
}
|
||||
|
||||
/// Given a flow, computes the speculated inline size of the floats in of its first child.
|
||||
pub fn compute_floats_in_for_first_child(parent_flow: &mut Flow) -> SpeculatedFloatPlacement {
|
||||
pub fn compute_floats_in_for_first_child(
|
||||
parent_flow: &mut dyn Flow,
|
||||
) -> SpeculatedFloatPlacement {
|
||||
if !parent_flow.is_block_like() {
|
||||
return parent_flow.base().speculated_float_placement_in;
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
|
|||
&mut self,
|
||||
layout_context: &LayoutContext,
|
||||
_fragmentation_context: Option<FragmentationContext>,
|
||||
) -> Option<Arc<Flow>> {
|
||||
) -> Option<Arc<dyn Flow>> {
|
||||
fn recursive_assign_block_size<F: ?Sized + Flow + GetBaseFlow>(
|
||||
flow: &mut F,
|
||||
ctx: &LayoutContext,
|
||||
|
@ -423,13 +423,13 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
|
|||
/// depth of the flow tree during fragment iteration.
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
);
|
||||
|
||||
/// Mutably iterates through fragments in this flow.
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment));
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment));
|
||||
|
||||
fn compute_collapsible_block_start_margin(
|
||||
&mut self,
|
||||
|
@ -813,8 +813,8 @@ pub struct AbsoluteDescendantIter<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Iterator for AbsoluteDescendantIter<'a> {
|
||||
type Item = &'a mut Flow;
|
||||
fn next(&mut self) -> Option<&'a mut Flow> {
|
||||
type Item = &'a mut dyn Flow;
|
||||
fn next(&mut self) -> Option<&'a mut dyn Flow> {
|
||||
self.iter
|
||||
.next()
|
||||
.map(|info| FlowRef::deref_mut(&mut info.flow))
|
||||
|
@ -1245,7 +1245,7 @@ impl BaseFlow {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> ImmutableFlowUtils for &'a Flow {
|
||||
impl<'a> ImmutableFlowUtils for &'a dyn Flow {
|
||||
/// Returns true if this flow is a block flow or subclass thereof.
|
||||
fn is_block_like(self) -> bool {
|
||||
self.class().is_block_like()
|
||||
|
@ -1419,7 +1419,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> MutableFlowUtils for &'a mut Flow {
|
||||
impl<'a> MutableFlowUtils for &'a mut dyn 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: &crate::ServoArc<ComputedValues>) {
|
||||
|
@ -1550,8 +1550,8 @@ impl ContainingBlockLink {
|
|||
pub struct OpaqueFlow(pub usize);
|
||||
|
||||
impl OpaqueFlow {
|
||||
pub fn from_flow(flow: &Flow) -> OpaqueFlow {
|
||||
let object_ptr: *const Flow = flow;
|
||||
pub fn from_flow(flow: &dyn Flow) -> OpaqueFlow {
|
||||
let object_ptr: *const dyn Flow = flow;
|
||||
let data_ptr = object_ptr as *const ();
|
||||
OpaqueFlow(data_ptr as usize)
|
||||
}
|
||||
|
|
|
@ -69,11 +69,11 @@ impl FlowList {
|
|||
self.flows.push_back(new_tail);
|
||||
}
|
||||
|
||||
pub fn push_back_arc(&mut self, new_head: Arc<Flow>) {
|
||||
pub fn push_back_arc(&mut self, new_head: Arc<dyn Flow>) {
|
||||
self.flows.push_back(FlowRef::new(new_head));
|
||||
}
|
||||
|
||||
pub fn back(&self) -> Option<&Flow> {
|
||||
pub fn back(&self) -> Option<&dyn Flow> {
|
||||
self.flows.back().map(|x| &**x)
|
||||
}
|
||||
|
||||
|
@ -84,15 +84,15 @@ impl FlowList {
|
|||
self.flows.push_front(new_head);
|
||||
}
|
||||
|
||||
pub fn push_front_arc(&mut self, new_head: Arc<Flow>) {
|
||||
pub fn push_front_arc(&mut self, new_head: Arc<dyn Flow>) {
|
||||
self.flows.push_front(FlowRef::new(new_head));
|
||||
}
|
||||
|
||||
pub fn pop_front_arc(&mut self) -> Option<Arc<Flow>> {
|
||||
pub fn pop_front_arc(&mut self) -> Option<Arc<dyn Flow>> {
|
||||
self.flows.pop_front().map(FlowRef::into_arc)
|
||||
}
|
||||
|
||||
pub fn front(&self) -> Option<&Flow> {
|
||||
pub fn front(&self) -> Option<&dyn Flow> {
|
||||
self.flows.front().map(|x| &**x)
|
||||
}
|
||||
|
||||
|
@ -161,21 +161,21 @@ impl FlowList {
|
|||
}
|
||||
|
||||
impl<'a> DoubleEndedIterator for FlowListIterator<'a> {
|
||||
fn next_back(&mut self) -> Option<&'a Flow> {
|
||||
fn next_back(&mut self) -> Option<&'a dyn Flow> {
|
||||
self.it.next_back().map(Deref::deref)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DoubleEndedIterator for MutFlowListIterator<'a> {
|
||||
fn next_back(&mut self) -> Option<&'a mut Flow> {
|
||||
fn next_back(&mut self) -> Option<&'a mut dyn Flow> {
|
||||
self.it.next_back().map(FlowRef::deref_mut)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Iterator for FlowListIterator<'a> {
|
||||
type Item = &'a Flow;
|
||||
type Item = &'a dyn Flow;
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a Flow> {
|
||||
fn next(&mut self) -> Option<&'a dyn Flow> {
|
||||
self.it.next().map(Deref::deref)
|
||||
}
|
||||
|
||||
|
@ -186,9 +186,9 @@ impl<'a> Iterator for FlowListIterator<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Iterator for MutFlowListIterator<'a> {
|
||||
type Item = &'a mut Flow;
|
||||
type Item = &'a mut dyn Flow;
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a mut Flow> {
|
||||
fn next(&mut self) -> Option<&'a mut dyn Flow> {
|
||||
self.it.next().map(FlowRef::deref_mut)
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ pub struct FlowListRandomAccessMut<'a> {
|
|||
}
|
||||
|
||||
impl<'a> FlowListRandomAccessMut<'a> {
|
||||
pub fn get<'b>(&'b mut self, index: usize) -> &'b mut Flow {
|
||||
pub fn get<'b>(&'b mut self, index: usize) -> &'b mut dyn Flow {
|
||||
while index >= self.cache.len() {
|
||||
match self.iterator.next() {
|
||||
None => panic!("Flow index out of range!"),
|
||||
|
|
|
@ -13,11 +13,11 @@ use std::ops::Deref;
|
|||
use std::sync::{Arc, Weak};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct FlowRef(Arc<Flow>);
|
||||
pub struct FlowRef(Arc<dyn Flow>);
|
||||
|
||||
impl Deref for FlowRef {
|
||||
type Target = Flow;
|
||||
fn deref(&self) -> &Flow {
|
||||
type Target = dyn Flow;
|
||||
fn deref(&self) -> &dyn Flow {
|
||||
self.0.deref()
|
||||
}
|
||||
}
|
||||
|
@ -25,19 +25,19 @@ impl Deref for FlowRef {
|
|||
impl FlowRef {
|
||||
/// `FlowRef`s can only be made available to the traversal code.
|
||||
/// See https://github.com/servo/servo/issues/14014 for more details.
|
||||
pub fn new(mut r: Arc<Flow>) -> Self {
|
||||
pub fn new(mut r: Arc<dyn Flow>) -> Self {
|
||||
// This assertion checks that this `FlowRef` does not alias normal `Arc`s.
|
||||
// If that happens, we're in trouble.
|
||||
assert!(Arc::get_mut(&mut r).is_some());
|
||||
FlowRef(r)
|
||||
}
|
||||
pub fn get_mut(this: &mut FlowRef) -> Option<&mut Flow> {
|
||||
pub fn get_mut(this: &mut FlowRef) -> Option<&mut dyn Flow> {
|
||||
Arc::get_mut(&mut this.0)
|
||||
}
|
||||
pub fn downgrade(this: &FlowRef) -> WeakFlowRef {
|
||||
WeakFlowRef(Arc::downgrade(&this.0))
|
||||
}
|
||||
pub fn into_arc(mut this: FlowRef) -> Arc<Flow> {
|
||||
pub fn into_arc(mut this: FlowRef) -> Arc<dyn Flow> {
|
||||
// This assertion checks that this `FlowRef` does not alias normal `Arc`s.
|
||||
// If that happens, we're in trouble.
|
||||
assert!(FlowRef::get_mut(&mut this).is_some());
|
||||
|
@ -48,14 +48,14 @@ impl FlowRef {
|
|||
/// See https://github.com/servo/servo/issues/6503
|
||||
/// Use Arc::get_mut instead when possible (e.g. on an Arc that was just created).
|
||||
#[allow(unsafe_code)]
|
||||
pub fn deref_mut(this: &mut FlowRef) -> &mut Flow {
|
||||
let ptr: *const Flow = &*this.0;
|
||||
unsafe { &mut *(ptr as *mut Flow) }
|
||||
pub fn deref_mut(this: &mut FlowRef) -> &mut dyn Flow {
|
||||
let ptr: *const dyn Flow = &*this.0;
|
||||
unsafe { &mut *(ptr as *mut dyn Flow) }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct WeakFlowRef(Weak<Flow>);
|
||||
pub struct WeakFlowRef(Weak<dyn Flow>);
|
||||
|
||||
impl WeakFlowRef {
|
||||
pub fn upgrade(&self) -> Option<FlowRef> {
|
||||
|
|
|
@ -152,7 +152,7 @@ impl<'a> ResolveGeneratedContent<'a> {
|
|||
|
||||
impl<'a> InorderFlowTraversal for ResolveGeneratedContent<'a> {
|
||||
#[inline]
|
||||
fn process(&mut self, flow: &mut Flow, level: u32) {
|
||||
fn process(&mut self, flow: &mut dyn Flow, level: u32) {
|
||||
let mut mutator = ResolveGeneratedContentFragmentMutator {
|
||||
traversal: self,
|
||||
level: level,
|
||||
|
@ -163,7 +163,7 @@ impl<'a> InorderFlowTraversal for ResolveGeneratedContent<'a> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn should_process_subtree(&mut self, flow: &mut Flow) -> bool {
|
||||
fn should_process_subtree(&mut self, flow: &mut dyn Flow) -> bool {
|
||||
flow.base()
|
||||
.restyle_damage
|
||||
.intersects(ServoRestyleDamage::RESOLVE_GENERATED_CONTENT) ||
|
||||
|
|
|
@ -27,7 +27,7 @@ pub trait LayoutDamageComputation {
|
|||
fn reflow_entire_document(self);
|
||||
}
|
||||
|
||||
impl<'a> LayoutDamageComputation for &'a mut Flow {
|
||||
impl<'a> LayoutDamageComputation for &'a mut dyn Flow {
|
||||
fn compute_layout_damage(self) -> SpecialRestyleDamage {
|
||||
let mut special_damage = SpecialRestyleDamage::empty();
|
||||
let is_absolutely_positioned = self
|
||||
|
@ -53,7 +53,7 @@ impl<'a> LayoutDamageComputation for &'a mut Flow {
|
|||
.damage_for_child(is_absolutely_positioned, child_is_absolutely_positioned),
|
||||
);
|
||||
{
|
||||
let kid: &mut Flow = kid;
|
||||
let kid: &mut dyn Flow = kid;
|
||||
special_damage.insert(kid.compute_layout_damage());
|
||||
}
|
||||
self_base.restyle_damage.insert(
|
||||
|
|
|
@ -1854,7 +1854,7 @@ impl Flow for InlineFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -1888,7 +1888,7 @@ impl Flow for InlineFlow {
|
|||
}
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
for fragment in &mut self.fragments.fragments {
|
||||
(*mutator)(fragment)
|
||||
}
|
||||
|
|
|
@ -4,49 +4,16 @@
|
|||
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
extern crate app_units;
|
||||
extern crate atomic_refcell;
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
extern crate canvas_traits;
|
||||
extern crate euclid;
|
||||
extern crate fnv;
|
||||
extern crate fxhash;
|
||||
extern crate gfx;
|
||||
extern crate gfx_traits;
|
||||
#[macro_use]
|
||||
extern crate html5ever;
|
||||
extern crate ipc_channel;
|
||||
extern crate libc;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate malloc_size_of;
|
||||
extern crate msg;
|
||||
extern crate net_traits;
|
||||
extern crate ordered_float;
|
||||
extern crate parking_lot;
|
||||
extern crate profile_traits;
|
||||
#[macro_use]
|
||||
extern crate range;
|
||||
extern crate rayon;
|
||||
extern crate script_layout_interface;
|
||||
extern crate script_traits;
|
||||
#[macro_use]
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
extern crate servo_arc;
|
||||
extern crate servo_atoms;
|
||||
extern crate servo_channel;
|
||||
extern crate servo_config;
|
||||
extern crate servo_geometry;
|
||||
extern crate servo_url;
|
||||
extern crate smallvec;
|
||||
extern crate style;
|
||||
extern crate style_traits;
|
||||
extern crate unicode_bidi;
|
||||
extern crate unicode_script;
|
||||
extern crate webrender_api;
|
||||
extern crate xi_unicode;
|
||||
|
||||
#[macro_use]
|
||||
pub mod layout_debug;
|
||||
|
|
|
@ -231,7 +231,7 @@ impl Flow for ListItemFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -266,7 +266,7 @@ impl Flow for ListItemFlow {
|
|||
}
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
self.block_flow.mutate_fragments(mutator);
|
||||
|
||||
for marker in &mut self.marker_fragments {
|
||||
|
|
|
@ -241,7 +241,7 @@ impl Flow for MulticolFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -252,7 +252,7 @@ impl Flow for MulticolFlow {
|
|||
);
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
self.block_flow.mutate_fragments(mutator);
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ impl Flow for MulticolColumnFlow {
|
|||
&mut self,
|
||||
layout_context: &LayoutContext,
|
||||
fragmentation_context: Option<FragmentationContext>,
|
||||
) -> Option<Arc<Flow>> {
|
||||
) -> Option<Arc<dyn Flow>> {
|
||||
Flow::fragment(&mut self.block_flow, layout_context, fragmentation_context)
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ impl Flow for MulticolColumnFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -356,7 +356,7 @@ impl Flow for MulticolColumnFlow {
|
|||
);
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
self.block_flow.mutate_fragments(mutator);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ pub type FlowList = SmallVec<[UnsafeFlow; CHUNK_SIZE]>;
|
|||
|
||||
/// Vtable + pointer representation of a Flow trait object.
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
pub struct UnsafeFlow(*const Flow);
|
||||
pub struct UnsafeFlow(*const dyn Flow);
|
||||
|
||||
unsafe impl Sync for UnsafeFlow {}
|
||||
unsafe impl Send for UnsafeFlow {}
|
||||
|
@ -73,7 +73,7 @@ impl FlowParallelInfo {
|
|||
fn bottom_up_flow(mut unsafe_flow: UnsafeFlow, assign_bsize_traversal: &AssignBSizes) {
|
||||
loop {
|
||||
// Get a real flow.
|
||||
let flow: &mut Flow = unsafe { mem::transmute(unsafe_flow) };
|
||||
let flow: &mut dyn Flow = unsafe { mem::transmute(unsafe_flow) };
|
||||
|
||||
// Perform the appropriate traversal.
|
||||
if assign_bsize_traversal.should_process(flow) {
|
||||
|
@ -97,7 +97,7 @@ fn bottom_up_flow(mut unsafe_flow: UnsafeFlow, assign_bsize_traversal: &AssignBS
|
|||
// No, we're not at the root yet. Then are we the last child
|
||||
// of our parent to finish processing? If so, we can continue
|
||||
// on with our parent; otherwise, we've gotta wait.
|
||||
let parent: &mut Flow = unsafe { &mut *(unsafe_parent.0 as *mut Flow) };
|
||||
let parent: &mut dyn Flow = unsafe { &mut *(unsafe_parent.0 as *mut dyn Flow) };
|
||||
let parent_base = parent.mut_base();
|
||||
if parent_base
|
||||
.parallel
|
||||
|
@ -127,7 +127,7 @@ fn top_down_flow<'scope>(
|
|||
let mut had_children = false;
|
||||
unsafe {
|
||||
// Get a real flow.
|
||||
let flow: &mut Flow = mem::transmute(*unsafe_flow);
|
||||
let flow: &mut dyn Flow = mem::transmute(*unsafe_flow);
|
||||
flow.mut_base().thread_id = pool.current_thread_index().unwrap() as u8;
|
||||
|
||||
if assign_isize_traversal.should_process(flow) {
|
||||
|
@ -191,7 +191,7 @@ fn top_down_flow<'scope>(
|
|||
|
||||
/// Run the main layout passes in parallel.
|
||||
pub fn reflow(
|
||||
root: &mut Flow,
|
||||
root: &mut dyn Flow,
|
||||
profiler_metadata: Option<TimerMetadata>,
|
||||
time_profiler_chan: time::ProfilerChan,
|
||||
context: &LayoutContext,
|
||||
|
|
|
@ -77,7 +77,7 @@ where
|
|||
|
||||
pub struct PersistentListIterator<'a, T>
|
||||
where
|
||||
T: 'a + Send + Sync,
|
||||
T: Send + Sync,
|
||||
{
|
||||
entry: Option<&'a PersistentListEntry<T>>,
|
||||
}
|
||||
|
|
|
@ -366,7 +366,7 @@ impl FragmentBorderBoxIterator for MarginRetrievingFragmentBorderBoxIterator {
|
|||
|
||||
pub fn process_content_box_request<N: LayoutNode>(
|
||||
requested_node: N,
|
||||
layout_root: &mut Flow,
|
||||
layout_root: &mut dyn Flow,
|
||||
) -> Option<Rect<Au>> {
|
||||
// FIXME(pcwalton): This has not been updated to handle the stacking context relative
|
||||
// stuff. So the position is wrong in most cases.
|
||||
|
@ -377,7 +377,7 @@ pub fn process_content_box_request<N: LayoutNode>(
|
|||
|
||||
pub fn process_content_boxes_request<N: LayoutNode>(
|
||||
requested_node: N,
|
||||
layout_root: &mut Flow,
|
||||
layout_root: &mut dyn Flow,
|
||||
) -> Vec<Rect<Au>> {
|
||||
// FIXME(pcwalton): This has not been updated to handle the stacking context relative
|
||||
// stuff. So the position is wrong in most cases.
|
||||
|
@ -671,7 +671,7 @@ impl FragmentBorderBoxIterator for ParentOffsetBorderBoxIterator {
|
|||
|
||||
pub fn process_node_geometry_request<N: LayoutNode>(
|
||||
requested_node: N,
|
||||
layout_root: &mut Flow,
|
||||
layout_root: &mut dyn Flow,
|
||||
) -> Rect<i32> {
|
||||
let mut iterator = FragmentLocatingFragmentIterator::new(requested_node.opaque());
|
||||
sequential::iterate_through_flow_tree_fragment_border_boxes(layout_root, &mut iterator);
|
||||
|
@ -689,7 +689,7 @@ pub fn process_node_scroll_id_request<N: LayoutNode>(
|
|||
/// https://drafts.csswg.org/cssom-view/#scrolling-area
|
||||
pub fn process_node_scroll_area_request<N: LayoutNode>(
|
||||
requested_node: N,
|
||||
layout_root: &mut Flow,
|
||||
layout_root: &mut dyn Flow,
|
||||
) -> Rect<i32> {
|
||||
let mut iterator = UnioningFragmentScrollAreaIterator::new(requested_node.opaque());
|
||||
sequential::iterate_through_flow_tree_fragment_border_boxes(layout_root, &mut iterator);
|
||||
|
@ -742,7 +742,7 @@ pub fn process_resolved_style_request<'a, N>(
|
|||
node: N,
|
||||
pseudo: &Option<PseudoElement>,
|
||||
property: &PropertyId,
|
||||
layout_root: &mut Flow,
|
||||
layout_root: &mut dyn Flow,
|
||||
) -> String
|
||||
where
|
||||
N: LayoutNode,
|
||||
|
@ -791,7 +791,7 @@ fn process_resolved_style_request_internal<'a, N>(
|
|||
requested_node: N,
|
||||
pseudo: &Option<PseudoElement>,
|
||||
property: &PropertyId,
|
||||
layout_root: &mut Flow,
|
||||
layout_root: &mut dyn Flow,
|
||||
) -> String
|
||||
where
|
||||
N: LayoutNode,
|
||||
|
@ -843,7 +843,7 @@ where
|
|||
|
||||
fn used_value_for_position_property<N: LayoutNode>(
|
||||
layout_el: <N::ConcreteThreadSafeLayoutNode as ThreadSafeLayoutNode>::ConcreteThreadSafeLayoutElement,
|
||||
layout_root: &mut Flow,
|
||||
layout_root: &mut dyn Flow,
|
||||
requested_node: N,
|
||||
longhand_id: LonghandId,
|
||||
) -> String {
|
||||
|
@ -934,7 +934,7 @@ where
|
|||
|
||||
pub fn process_offset_parent_query<N: LayoutNode>(
|
||||
requested_node: N,
|
||||
layout_root: &mut Flow,
|
||||
layout_root: &mut dyn Flow,
|
||||
) -> OffsetParentResponse {
|
||||
let mut iterator = ParentOffsetBorderBoxIterator::new(requested_node.opaque());
|
||||
sequential::iterate_through_flow_tree_fragment_border_boxes(layout_root, &mut iterator);
|
||||
|
|
|
@ -19,14 +19,14 @@ use servo_config::opts;
|
|||
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||
use webrender_api::LayoutPoint;
|
||||
|
||||
pub fn resolve_generated_content(root: &mut Flow, layout_context: &LayoutContext) {
|
||||
pub fn resolve_generated_content(root: &mut dyn Flow, layout_context: &LayoutContext) {
|
||||
ResolveGeneratedContent::new(&layout_context).traverse(root, 0);
|
||||
}
|
||||
|
||||
/// Run the main layout passes sequentially.
|
||||
pub fn reflow(root: &mut Flow, layout_context: &LayoutContext, relayout_mode: RelayoutMode) {
|
||||
pub fn reflow(root: &mut dyn Flow, layout_context: &LayoutContext, relayout_mode: RelayoutMode) {
|
||||
fn doit(
|
||||
flow: &mut Flow,
|
||||
flow: &mut dyn Flow,
|
||||
assign_inline_sizes: AssignISizes,
|
||||
assign_block_sizes: AssignBSizes,
|
||||
relayout_mode: RelayoutMode,
|
||||
|
@ -70,7 +70,7 @@ pub fn reflow(root: &mut Flow, layout_context: &LayoutContext, relayout_mode: Re
|
|||
}
|
||||
|
||||
pub fn build_display_list_for_subtree<'a>(
|
||||
flow_root: &mut Flow,
|
||||
flow_root: &mut dyn Flow,
|
||||
layout_context: &'a LayoutContext,
|
||||
) -> DisplayListBuildState<'a> {
|
||||
let mut state = StackingContextCollectionState::new(layout_context.id);
|
||||
|
@ -83,13 +83,13 @@ pub fn build_display_list_for_subtree<'a>(
|
|||
}
|
||||
|
||||
pub fn iterate_through_flow_tree_fragment_border_boxes(
|
||||
root: &mut Flow,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
root: &mut dyn Flow,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
) {
|
||||
fn doit(
|
||||
flow: &mut Flow,
|
||||
flow: &mut dyn Flow,
|
||||
level: i32,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
flow.iterate_through_fragment_border_boxes(iterator, level, stacking_context_position);
|
||||
|
@ -119,7 +119,7 @@ pub fn iterate_through_flow_tree_fragment_border_boxes(
|
|||
doit(root, 0, iterator, &Point2D::zero());
|
||||
}
|
||||
|
||||
pub fn store_overflow(layout_context: &LayoutContext, flow: &mut Flow) {
|
||||
pub fn store_overflow(layout_context: &LayoutContext, flow: &mut dyn Flow) {
|
||||
if !flow
|
||||
.base()
|
||||
.restyle_damage
|
||||
|
@ -142,7 +142,7 @@ pub fn store_overflow(layout_context: &LayoutContext, flow: &mut Flow) {
|
|||
/// Guesses how much inline size will be taken up by floats on the left and right sides of the
|
||||
/// given flow. This is needed to speculatively calculate the inline sizes of block formatting
|
||||
/// contexts. The speculation typically succeeds, but if it doesn't we have to lay it out again.
|
||||
pub fn guess_float_placement(flow: &mut Flow) {
|
||||
pub fn guess_float_placement(flow: &mut dyn Flow) {
|
||||
if !flow
|
||||
.base()
|
||||
.restyle_damage
|
||||
|
|
|
@ -611,7 +611,7 @@ impl Flow for TableFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -622,7 +622,7 @@ impl Flow for TableFlow {
|
|||
)
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
self.block_flow.mutate_fragments(mutator)
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ impl Flow for TableCaptionFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -126,7 +126,7 @@ impl Flow for TableCaptionFlow {
|
|||
)
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
self.block_flow.mutate_fragments(mutator)
|
||||
}
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ impl Flow for TableCellFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -345,7 +345,7 @@ impl Flow for TableCellFlow {
|
|||
)
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
self.block_flow.mutate_fragments(mutator)
|
||||
}
|
||||
|
||||
|
|
|
@ -112,13 +112,13 @@ impl Flow for TableColGroupFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
_: &mut FragmentBorderBoxIterator,
|
||||
_: &mut dyn FragmentBorderBoxIterator,
|
||||
_: i32,
|
||||
_: &Point2D<Au>,
|
||||
) {
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, _: &mut FnMut(&mut Fragment)) {}
|
||||
fn mutate_fragments(&mut self, _: &mut dyn FnMut(&mut Fragment)) {}
|
||||
}
|
||||
|
||||
impl fmt::Debug for TableColGroupFlow {
|
||||
|
|
|
@ -650,7 +650,7 @@ impl Flow for TableRowFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -661,7 +661,7 @@ impl Flow for TableRowFlow {
|
|||
)
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
self.block_flow.mutate_fragments(mutator)
|
||||
}
|
||||
|
||||
|
@ -907,7 +907,7 @@ impl CollapsedBorder {
|
|||
|
||||
/// Pushes column inline size, incoming rowspan, and border collapse info down to a child.
|
||||
pub fn propagate_column_inline_sizes_to_child(
|
||||
child_flow: &mut Flow,
|
||||
child_flow: &mut dyn Flow,
|
||||
table_writing_mode: WritingMode,
|
||||
column_computed_inline_sizes: &[ColumnComputedInlineSize],
|
||||
border_spacing: &BorderSpacing,
|
||||
|
@ -975,7 +975,7 @@ pub fn propagate_column_inline_sizes_to_child(
|
|||
|
||||
/// Lay out table cells inline according to the computer column sizes.
|
||||
fn set_inline_position_of_child_flow(
|
||||
child_flow: &mut Flow,
|
||||
child_flow: &mut dyn Flow,
|
||||
child_index: usize,
|
||||
column_index: &mut usize,
|
||||
incoming_rowspan: &[u32],
|
||||
|
|
|
@ -246,7 +246,7 @@ impl Flow for TableRowGroupFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -257,7 +257,7 @@ impl Flow for TableRowGroupFlow {
|
|||
)
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
self.block_flow.mutate_fragments(mutator)
|
||||
}
|
||||
|
||||
|
|
|
@ -531,7 +531,7 @@ impl Flow for TableWrapperFlow {
|
|||
|
||||
fn iterate_through_fragment_border_boxes(
|
||||
&self,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
iterator: &mut dyn FragmentBorderBoxIterator,
|
||||
level: i32,
|
||||
stacking_context_position: &Point2D<Au>,
|
||||
) {
|
||||
|
@ -542,7 +542,7 @@ impl Flow for TableWrapperFlow {
|
|||
)
|
||||
}
|
||||
|
||||
fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) {
|
||||
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)) {
|
||||
self.block_flow.mutate_fragments(mutator)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#![cfg(target_pointer_width = "64")]
|
||||
|
||||
extern crate layout;
|
||||
#[macro_use]
|
||||
extern crate size_of_test;
|
||||
|
||||
|
|
|
@ -90,23 +90,23 @@ where
|
|||
/// A top-down traversal.
|
||||
pub trait PreorderFlowTraversal {
|
||||
/// The operation to perform. Return true to continue or false to stop.
|
||||
fn process(&self, flow: &mut Flow);
|
||||
fn process(&self, flow: &mut dyn Flow);
|
||||
|
||||
/// Returns true if this node should be processed and false if neither this node nor its
|
||||
/// descendants should be processed.
|
||||
fn should_process_subtree(&self, _flow: &mut Flow) -> bool {
|
||||
fn should_process_subtree(&self, _flow: &mut dyn Flow) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Returns true if this node must be processed in-order. If this returns false,
|
||||
/// we skip the operation for this node, but continue processing the descendants.
|
||||
/// This is called *after* parent nodes are visited.
|
||||
fn should_process(&self, _flow: &mut Flow) -> bool {
|
||||
fn should_process(&self, _flow: &mut dyn Flow) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Traverses the tree in preorder.
|
||||
fn traverse(&self, flow: &mut Flow) {
|
||||
fn traverse(&self, flow: &mut dyn Flow) {
|
||||
if !self.should_process_subtree(flow) {
|
||||
return;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ pub trait PreorderFlowTraversal {
|
|||
/// their direct absolute descendants.
|
||||
///
|
||||
/// Return true if the traversal is to continue or false to stop.
|
||||
fn traverse_absolute_flows(&self, flow: &mut Flow) {
|
||||
fn traverse_absolute_flows(&self, flow: &mut dyn Flow) {
|
||||
if self.should_process(flow) {
|
||||
self.process(flow);
|
||||
}
|
||||
|
@ -137,17 +137,17 @@ pub trait PreorderFlowTraversal {
|
|||
/// A bottom-up traversal, with a optional in-order pass.
|
||||
pub trait PostorderFlowTraversal {
|
||||
/// The operation to perform. Return true to continue or false to stop.
|
||||
fn process(&self, flow: &mut Flow);
|
||||
fn process(&self, flow: &mut dyn Flow);
|
||||
|
||||
/// Returns false if this node must be processed in-order. If this returns false, we skip the
|
||||
/// operation for this node, but continue processing the ancestors. This is called *after*
|
||||
/// child nodes are visited.
|
||||
fn should_process(&self, _flow: &mut Flow) -> bool {
|
||||
fn should_process(&self, _flow: &mut dyn Flow) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Traverses the tree in postorder.
|
||||
fn traverse(&self, flow: &mut Flow) {
|
||||
fn traverse(&self, flow: &mut dyn Flow) {
|
||||
for kid in flow.mut_base().child_iter_mut() {
|
||||
self.traverse(kid);
|
||||
}
|
||||
|
@ -160,16 +160,16 @@ pub trait PostorderFlowTraversal {
|
|||
/// An in-order (sequential only) traversal.
|
||||
pub trait InorderFlowTraversal {
|
||||
/// The operation to perform. Returns the level of the tree we're at.
|
||||
fn process(&mut self, flow: &mut Flow, level: u32);
|
||||
fn process(&mut self, flow: &mut dyn Flow, level: u32);
|
||||
|
||||
/// Returns true if this node should be processed and false if neither this node nor its
|
||||
/// descendants should be processed.
|
||||
fn should_process_subtree(&mut self, _flow: &mut Flow) -> bool {
|
||||
fn should_process_subtree(&mut self, _flow: &mut dyn Flow) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Traverses the tree in-order.
|
||||
fn traverse(&mut self, flow: &mut Flow, level: u32) {
|
||||
fn traverse(&mut self, flow: &mut dyn Flow, level: u32) {
|
||||
if !self.should_process_subtree(flow) {
|
||||
return;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ pub struct BubbleISizes<'a> {
|
|||
|
||||
impl<'a> PostorderFlowTraversal for BubbleISizes<'a> {
|
||||
#[inline]
|
||||
fn process(&self, flow: &mut Flow) {
|
||||
fn process(&self, flow: &mut dyn Flow) {
|
||||
flow.bubble_inline_sizes();
|
||||
flow.mut_base()
|
||||
.restyle_damage
|
||||
|
@ -246,7 +246,7 @@ impl<'a> PostorderFlowTraversal for BubbleISizes<'a> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn should_process(&self, flow: &mut Flow) -> bool {
|
||||
fn should_process(&self, flow: &mut dyn Flow) -> bool {
|
||||
flow.base()
|
||||
.restyle_damage
|
||||
.contains(ServoRestyleDamage::BUBBLE_ISIZES)
|
||||
|
@ -261,12 +261,12 @@ pub struct AssignISizes<'a> {
|
|||
|
||||
impl<'a> PreorderFlowTraversal for AssignISizes<'a> {
|
||||
#[inline]
|
||||
fn process(&self, flow: &mut Flow) {
|
||||
fn process(&self, flow: &mut dyn Flow) {
|
||||
flow.assign_inline_sizes(self.layout_context);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn should_process(&self, flow: &mut Flow) -> bool {
|
||||
fn should_process(&self, flow: &mut dyn Flow) -> bool {
|
||||
flow.base()
|
||||
.restyle_damage
|
||||
.intersects(ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW)
|
||||
|
@ -283,7 +283,7 @@ pub struct AssignBSizes<'a> {
|
|||
|
||||
impl<'a> PostorderFlowTraversal for AssignBSizes<'a> {
|
||||
#[inline]
|
||||
fn process(&self, flow: &mut Flow) {
|
||||
fn process(&self, flow: &mut dyn Flow) {
|
||||
// Can't do anything with anything that floats might flow through until we reach their
|
||||
// inorder parent.
|
||||
//
|
||||
|
@ -297,7 +297,7 @@ impl<'a> PostorderFlowTraversal for AssignBSizes<'a> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn should_process(&self, flow: &mut Flow) -> bool {
|
||||
fn should_process(&self, flow: &mut dyn Flow) -> bool {
|
||||
let base = flow.base();
|
||||
base.restyle_damage.intersects(ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW) &&
|
||||
// The fragmentation countainer is responsible for calling
|
||||
|
@ -312,14 +312,14 @@ pub struct ComputeStackingRelativePositions<'a> {
|
|||
|
||||
impl<'a> PreorderFlowTraversal for ComputeStackingRelativePositions<'a> {
|
||||
#[inline]
|
||||
fn should_process_subtree(&self, flow: &mut Flow) -> bool {
|
||||
fn should_process_subtree(&self, flow: &mut dyn Flow) -> bool {
|
||||
flow.base()
|
||||
.restyle_damage
|
||||
.contains(ServoRestyleDamage::REPOSITION)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn process(&self, flow: &mut Flow) {
|
||||
fn process(&self, flow: &mut dyn Flow) {
|
||||
flow.compute_stacking_relative_position(self.layout_context);
|
||||
flow.mut_base()
|
||||
.restyle_damage
|
||||
|
@ -333,7 +333,7 @@ pub struct BuildDisplayList<'a> {
|
|||
|
||||
impl<'a> BuildDisplayList<'a> {
|
||||
#[inline]
|
||||
pub fn traverse(&mut self, flow: &mut Flow) {
|
||||
pub fn traverse(&mut self, flow: &mut dyn Flow) {
|
||||
let parent_stacking_context_id = self.state.current_stacking_context_id;
|
||||
self.state.current_stacking_context_id = flow.base().stacking_context_id;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue