mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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
|
@ -10,7 +10,7 @@ use construct::ConstructionResult;
|
|||
use context::SharedLayoutContext;
|
||||
use flow::{mod, Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUtils};
|
||||
use flow_ref::FlowRef;
|
||||
use fragment::{Fragment, FragmentOverflowIterator};
|
||||
use fragment::{Fragment, FragmentBorderBoxIterator};
|
||||
use incremental::{LayoutDamageComputation, REFLOW, REFLOW_ENTIRE_DOCUMENT, REPAINT};
|
||||
use layout_debug;
|
||||
use parallel::{mod, UnsafeFlow};
|
||||
|
@ -604,8 +604,8 @@ impl LayoutTask {
|
|||
// FIXME(pcwalton): This has not been updated to handle the stacking context relative
|
||||
// stuff. So the position is wrong in most cases.
|
||||
let requested_node: OpaqueNode = OpaqueNodeMethods::from_script_node(requested_node);
|
||||
let mut iterator = UnioningFragmentOverflowIterator::new(requested_node);
|
||||
sequential::iterate_through_flow_tree_fragment_bounds(layout_root, &mut iterator);
|
||||
let mut iterator = UnioningFragmentBorderBoxIterator::new(requested_node);
|
||||
sequential::iterate_through_flow_tree_fragment_border_boxes(layout_root, &mut iterator);
|
||||
rw_data.content_box_response = iterator.rect;
|
||||
}
|
||||
|
||||
|
@ -616,8 +616,8 @@ impl LayoutTask {
|
|||
// FIXME(pcwalton): This has not been updated to handle the stacking context relative
|
||||
// stuff. So the position is wrong in most cases.
|
||||
let requested_node: OpaqueNode = OpaqueNodeMethods::from_script_node(requested_node);
|
||||
let mut iterator = CollectingFragmentOverflowIterator::new(requested_node);
|
||||
sequential::iterate_through_flow_tree_fragment_bounds(layout_root, &mut iterator);
|
||||
let mut iterator = CollectingFragmentBorderBoxIterator::new(requested_node);
|
||||
sequential::iterate_through_flow_tree_fragment_border_boxes(layout_root, &mut iterator);
|
||||
rw_data.content_boxes_response = iterator.rects;
|
||||
}
|
||||
|
||||
|
@ -1017,26 +1017,26 @@ impl LayoutRPC for LayoutRPCImpl {
|
|||
}
|
||||
}
|
||||
|
||||
struct UnioningFragmentOverflowIterator {
|
||||
struct UnioningFragmentBorderBoxIterator {
|
||||
node_address: OpaqueNode,
|
||||
rect: Rect<Au>,
|
||||
}
|
||||
|
||||
impl UnioningFragmentOverflowIterator {
|
||||
fn new(node_address: OpaqueNode) -> UnioningFragmentOverflowIterator {
|
||||
UnioningFragmentOverflowIterator {
|
||||
impl UnioningFragmentBorderBoxIterator {
|
||||
fn new(node_address: OpaqueNode) -> UnioningFragmentBorderBoxIterator {
|
||||
UnioningFragmentBorderBoxIterator {
|
||||
node_address: node_address,
|
||||
rect: Rect::zero(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FragmentOverflowIterator for UnioningFragmentOverflowIterator {
|
||||
fn process(&mut self, _: &Fragment, bounds: Rect<Au>) {
|
||||
if self.rect.is_empty() {
|
||||
self.rect = bounds;
|
||||
impl FragmentBorderBoxIterator for UnioningFragmentBorderBoxIterator {
|
||||
fn process(&mut self, _: &Fragment, border_box: &Rect<Au>) {
|
||||
self.rect = if self.rect.is_empty() {
|
||||
*border_box
|
||||
} else {
|
||||
self.rect = self.rect.union(&bounds);
|
||||
self.rect.union(border_box)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1045,23 +1045,23 @@ impl FragmentOverflowIterator for UnioningFragmentOverflowIterator {
|
|||
}
|
||||
}
|
||||
|
||||
struct CollectingFragmentOverflowIterator {
|
||||
struct CollectingFragmentBorderBoxIterator {
|
||||
node_address: OpaqueNode,
|
||||
rects: Vec<Rect<Au>>,
|
||||
}
|
||||
|
||||
impl CollectingFragmentOverflowIterator {
|
||||
fn new(node_address: OpaqueNode) -> CollectingFragmentOverflowIterator {
|
||||
CollectingFragmentOverflowIterator {
|
||||
impl CollectingFragmentBorderBoxIterator {
|
||||
fn new(node_address: OpaqueNode) -> CollectingFragmentBorderBoxIterator {
|
||||
CollectingFragmentBorderBoxIterator {
|
||||
node_address: node_address,
|
||||
rects: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FragmentOverflowIterator for CollectingFragmentOverflowIterator {
|
||||
fn process(&mut self, _: &Fragment, bounds: Rect<Au>) {
|
||||
self.rects.push(bounds);
|
||||
impl FragmentBorderBoxIterator for CollectingFragmentBorderBoxIterator {
|
||||
fn process(&mut self, _: &Fragment, border_box: &Rect<Au>) {
|
||||
self.rects.push(*border_box);
|
||||
}
|
||||
|
||||
fn should_process(&mut self, fragment: &Fragment) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue