mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
layout: Explicitly thread border box dimensions and relative offsets
through display list building. The old `flow_origin` concept was ill-defined (sometimes the border box plus the flow origin, sometimes including horizontal margins and sometimes not, sometimes including relative position and sometimes not), leading to brittleness and test failures. This commit reworks the logic to always pass border box origins in during display list building.
This commit is contained in:
parent
5ea2c6dcfd
commit
bf540d590a
20 changed files with 591 additions and 456 deletions
|
@ -5,11 +5,10 @@
|
|||
//! Implements sequential traversals over the DOM and flow trees.
|
||||
|
||||
use context::{LayoutContext, SharedLayoutContext};
|
||||
use flow::{Flow, MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal};
|
||||
use flow;
|
||||
use flow::{mod, Flow, ImmutableFlowUtils, MutableFlowUtils, PostorderFlowTraversal};
|
||||
use flow::{PreorderFlowTraversal};
|
||||
use flow_ref::FlowRef;
|
||||
use fragment::FragmentOverflowIterator;
|
||||
use servo_util::opts;
|
||||
use fragment::FragmentBorderBoxIterator;
|
||||
use traversal::{BubbleISizes, RecalcStyleForNode, ConstructFlows};
|
||||
use traversal::{AssignBSizesAndStoreOverflow, AssignISizes};
|
||||
use traversal::{ComputeAbsolutePositions, BuildDisplayList};
|
||||
|
@ -17,6 +16,10 @@ use wrapper::LayoutNode;
|
|||
use wrapper::{PostorderNodeMutTraversal};
|
||||
use wrapper::{PreorderDomTraversal, PostorderDomTraversal};
|
||||
|
||||
use geom::point::Point2D;
|
||||
use servo_util::geometry::{Au, ZERO_POINT};
|
||||
use servo_util::opts;
|
||||
|
||||
pub fn traverse_dom_preorder(root: LayoutNode,
|
||||
shared_layout_context: &SharedLayoutContext) {
|
||||
fn doit(node: LayoutNode, recalc_style: RecalcStyleForNode, construct_flows: ConstructFlows) {
|
||||
|
@ -94,15 +97,25 @@ pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
|||
doit(root.deref_mut(), compute_absolute_positions, build_display_list);
|
||||
}
|
||||
|
||||
pub fn iterate_through_flow_tree_fragment_bounds(root: &mut FlowRef,
|
||||
iterator: &mut FragmentOverflowIterator) {
|
||||
fn doit(flow: &mut Flow, iterator: &mut FragmentOverflowIterator) {
|
||||
flow.iterate_through_fragment_overflow(iterator);
|
||||
pub fn iterate_through_flow_tree_fragment_border_boxes(root: &mut FlowRef,
|
||||
iterator: &mut FragmentBorderBoxIterator) {
|
||||
fn doit(flow: &mut Flow,
|
||||
iterator: &mut FragmentBorderBoxIterator,
|
||||
stacking_context_position: &Point2D<Au>) {
|
||||
flow.iterate_through_fragment_border_boxes(iterator, stacking_context_position);
|
||||
|
||||
for kid in flow::mut_base(flow).child_iter() {
|
||||
doit(kid, iterator);
|
||||
let stacking_context_position =
|
||||
if kid.is_block_flow() && kid.as_block().fragment.establishes_stacking_context() {
|
||||
*stacking_context_position + flow::base(kid).stacking_relative_position
|
||||
} else {
|
||||
*stacking_context_position
|
||||
};
|
||||
|
||||
// FIXME(#2795): Get the real container size.
|
||||
doit(kid, iterator, &stacking_context_position);
|
||||
}
|
||||
}
|
||||
|
||||
doit(root.deref_mut(), iterator);
|
||||
doit(root.deref_mut(), iterator, &ZERO_POINT);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue