mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Allow CalculateStackingRelativePositions to short-circuit
This commit is contained in:
parent
832b811198
commit
ca300d6424
5 changed files with 23 additions and 23 deletions
|
@ -56,7 +56,7 @@ use style::computed_values::{position, text_align};
|
|||
use style::context::SharedStyleContext;
|
||||
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::ComputedValues;
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION};
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW};
|
||||
use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage};
|
||||
use style::values::computed::LengthOrPercentageOrAuto;
|
||||
use traversal::PreorderFlowTraversal;
|
||||
|
@ -2084,8 +2084,6 @@ impl Flow for BlockFlow {
|
|||
flow::mut_base(kid).late_absolute_position_info =
|
||||
late_absolute_position_info_for_children;
|
||||
}
|
||||
|
||||
self.base.restyle_damage.remove(REPOSITION)
|
||||
}
|
||||
|
||||
fn mark_as_root(&mut self) {
|
||||
|
|
|
@ -54,7 +54,7 @@ use style::context::SharedStyleContext;
|
|||
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::ComputedValues;
|
||||
use style::selector_parser::RestyleDamage;
|
||||
use style::servo::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION};
|
||||
use style::servo::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT};
|
||||
use style::values::computed::LengthOrPercentageOrAuto;
|
||||
use table::TableFlow;
|
||||
use table_caption::TableCaptionFlow;
|
||||
|
@ -343,7 +343,6 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static {
|
|||
/// in coordinates relative to the nearest ancestor stacking context).
|
||||
fn compute_stacking_relative_position(&mut self, _: &LayoutContext) {
|
||||
// The default implementation is a no-op.
|
||||
mut_base(self).restyle_damage.remove(REPOSITION)
|
||||
}
|
||||
|
||||
/// Phase 5 of reflow: builds display lists.
|
||||
|
|
|
@ -33,7 +33,7 @@ use style::computed_values::{display, overflow_x, position, text_align, text_jus
|
|||
use style::computed_values::{vertical_align, white_space};
|
||||
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::{longhands, ComputedValues};
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION, RESOLVE_GENERATED_CONTENT};
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, RESOLVE_GENERATED_CONTENT};
|
||||
use text;
|
||||
use traversal::PreorderFlowTraversal;
|
||||
use unicode_bidi as bidi;
|
||||
|
@ -1649,8 +1649,6 @@ impl Flow for InlineFlow {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
self.base.restyle_damage.remove(REPOSITION)
|
||||
}
|
||||
|
||||
fn update_late_computed_inline_position_if_necessary(&mut self, _: Au) {}
|
||||
|
|
|
@ -14,7 +14,7 @@ use style::context::{SharedStyleContext, StyleContext};
|
|||
use style::data::ElementData;
|
||||
use style::dom::{NodeInfo, TElement, TNode};
|
||||
use style::selector_parser::RestyleDamage;
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT};
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION};
|
||||
use style::traversal::{DomTraversal, TraversalDriver, recalc_style_at};
|
||||
use style::traversal::PerLevelTraversalData;
|
||||
use wrapper::{GetRawData, LayoutNodeLayoutData};
|
||||
|
@ -96,6 +96,12 @@ pub trait PreorderFlowTraversal {
|
|||
/// The operation to perform. Return true to continue or false to stop.
|
||||
fn process(&self, flow: &mut 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 {
|
||||
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.
|
||||
|
@ -105,6 +111,9 @@ pub trait PreorderFlowTraversal {
|
|||
|
||||
/// Traverses the tree in preorder.
|
||||
fn traverse(&self, flow: &mut Flow) {
|
||||
if !self.should_process_subtree(flow) {
|
||||
return;
|
||||
}
|
||||
if self.should_process(flow) {
|
||||
self.process(flow);
|
||||
}
|
||||
|
@ -283,15 +292,20 @@ impl<'a> PostorderFlowTraversal for AssignBSizes<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct ComputeStackingRelativePositions<'a> {
|
||||
pub layout_context: &'a LayoutContext<'a>,
|
||||
}
|
||||
|
||||
impl<'a> PreorderFlowTraversal for ComputeStackingRelativePositions<'a> {
|
||||
#[inline]
|
||||
fn should_process_subtree(&self, flow: &mut Flow) -> bool {
|
||||
flow::base(flow).restyle_damage.contains(REPOSITION)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn process(&self, flow: &mut Flow) {
|
||||
flow.compute_stacking_relative_position(self.layout_context);
|
||||
flow::mut_base(flow).restyle_damage.remove(REPOSITION)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,10 +323,8 @@ impl<'a> BuildDisplayList<'a> {
|
|||
self.state.current_clip_and_scroll_info =
|
||||
flow.clip_and_scroll_info(self.state.layout_context.id);
|
||||
|
||||
if self.should_process() {
|
||||
flow.build_display_list(&mut self.state);
|
||||
flow::mut_base(flow).restyle_damage.remove(REPAINT);
|
||||
}
|
||||
flow.build_display_list(&mut self.state);
|
||||
flow::mut_base(flow).restyle_damage.remove(REPAINT);
|
||||
|
||||
for kid in flow::child_iter_mut(flow) {
|
||||
self.traverse(kid);
|
||||
|
@ -321,9 +333,4 @@ impl<'a> BuildDisplayList<'a> {
|
|||
self.state.current_stacking_context_id = parent_stacking_context_id;
|
||||
self.state.current_clip_and_scroll_info = parent_clip_and_scroll_info;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn should_process(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -974,10 +974,8 @@ impl LayoutThread {
|
|||
|
||||
flow::mut_base(layout_root).clip = data.page_clip_rect;
|
||||
|
||||
if flow::base(layout_root).restyle_damage.contains(REPOSITION) {
|
||||
let traversal = ComputeStackingRelativePositions { layout_context: layout_context };
|
||||
traversal.traverse(layout_root);
|
||||
}
|
||||
let traversal = ComputeStackingRelativePositions { layout_context: layout_context };
|
||||
traversal.traverse(layout_root);
|
||||
|
||||
if flow::base(layout_root).restyle_damage.contains(REPAINT) ||
|
||||
rw_data.display_list.is_none() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue