aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Watson <gw@intuitionlibrary.com>2015-11-03 15:49:52 +1000
committerGlenn Watson <gw@intuitionlibrary.com>2015-11-03 20:10:06 +1000
commit695b7491fea505aad1179915b56a1fc295ccd9c3 (patch)
tree9577ffcf9de86288cbf29ee4f7f47307f14c6085
parent4f51710ed387baa1ad0a6e4cdb0fc5eee44093d5 (diff)
downloadservo-695b7491fea505aad1179915b56a1fc295ccd9c3.tar.gz
servo-695b7491fea505aad1179915b56a1fc295ccd9c3.zip
Change overflow calculation to be calculated after compute_absolute_position.
Also include absolutely positioned elements in the overflow rect calculation. Fixes #7797.
-rw-r--r--components/layout/block.rs47
-rw-r--r--components/layout/flow.rs40
-rw-r--r--components/layout/inline.rs9
-rw-r--r--components/layout/parallel.rs3
-rw-r--r--components/layout/sequential.rs2
-rw-r--r--components/layout/table.rs5
-rw-r--r--components/layout/traversal.rs4
-rw-r--r--tests/wpt/mozilla/meta/MANIFEST.json24
-rw-r--r--tests/wpt/mozilla/tests/css/abs-overflow-stackingcontext.html24
-rw-r--r--tests/wpt/mozilla/tests/css/abs-overflow-stackingcontext_ref.html22
10 files changed, 75 insertions, 105 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs
index 399b3e5a9f4..06b003862b4 100644
--- a/components/layout/block.rs
+++ b/components/layout/block.rs
@@ -42,7 +42,6 @@ use flow::{ImmutableFlowUtils, LateAbsolutePositionInfo, MutableFlowUtils, Opaqu
use flow::{LAYERS_NEEDED_FOR_DESCENDANTS, NEEDS_LAYER};
use flow::{PostorderFlowTraversal, PreorderFlowTraversal, mut_base};
use flow::{self, BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ForceNonfloatedFlag};
-use flow_ref;
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, HAS_LAYER};
use fragment::{SpecificFragmentInfo};
use gfx::display_list::{ClippingRegion, DisplayList};
@@ -478,45 +477,6 @@ impl<'a> PreorderFlowTraversal for AbsoluteAssignBSizesTraversal<'a> {
}
}
-/// The store-overflow traversal particular to absolute flows.
-///
-/// Propagate overflow up the Absolute flow tree and update overflow up to and
-/// not including the root of the Absolute flow tree.
-/// After that, it is up to the normal store-overflow traversal to propagate
-/// it further up.
-pub struct AbsoluteStoreOverflowTraversal<'a>{
- pub layout_context: &'a LayoutContext<'a>,
-}
-
-impl<'a> PostorderFlowTraversal for AbsoluteStoreOverflowTraversal<'a> {
- #[inline]
- fn process(&self, flow: &mut Flow) {
- {
- // This will be taken care of by the normal store-overflow traversal.
- let flow: &Flow = flow;
- if flow.contains_roots_of_absolute_flow_tree() {
- return;
- }
- }
-
- flow.mutate_fragments(&mut |f: &mut Fragment| {
- match f.specific {
- SpecificFragmentInfo::InlineBlock(ref mut info) => {
- let block = flow_ref::deref_mut(&mut info.flow_ref);
- (block.as_mut_block() as &mut Flow).early_store_overflow(self.layout_context);
- }
- SpecificFragmentInfo::InlineAbsolute(ref mut info) => {
- let block = flow_ref::deref_mut(&mut info.flow_ref);
- (block.as_mut_block() as &mut Flow).early_store_overflow(self.layout_context);
- }
- _ => (),
- }
- });
-
- flow.early_store_overflow(self.layout_context);
- }
-}
-
pub enum BlockType {
Replaced,
NonReplaced,
@@ -1016,7 +976,6 @@ impl BlockFlow {
relative_containing_block_size: self.fragment.content_box().size,
relative_containing_block_mode: self.fragment.style().writing_mode,
};
- kid.late_store_overflow(layout_context)
}
if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
@@ -1073,11 +1032,6 @@ impl BlockFlow {
// the block-size of its containing block, which may also be an absolute flow.
(&mut *self as &mut Flow).traverse_preorder_absolute_flows(
&mut AbsoluteAssignBSizesTraversal(layout_context));
- // Store overflow for all absolute descendants.
- (&mut *self as &mut Flow).traverse_postorder_absolute_flows(
- &mut AbsoluteStoreOverflowTraversal {
- layout_context: layout_context,
- });
}
// Don't remove the dirty bits yet if we're absolutely-positioned, since our final size
@@ -1795,7 +1749,6 @@ impl Flow for BlockFlow {
self.base.thread_id = parent_thread_id;
if self.base.restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW) {
self.assign_block_size(layout_context);
- (self as &mut Flow).early_store_overflow(layout_context);
// Don't remove the restyle damage; `assign_block_size` decides whether that is
// appropriate (which in the case of e.g. absolutely-positioned flows, it is not).
}
diff --git a/components/layout/flow.rs b/components/layout/flow.rs
index 5be4533dc6a..baaf450e92b 100644
--- a/components/layout/flow.rs
+++ b/components/layout/flow.rs
@@ -220,11 +220,6 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static {
if impacted {
mut_base(self).thread_id = parent_thread_id;
self.assign_block_size(layout_context);
- // FIXME(pcwalton): Should use `early_store_overflow()` here but that fails due to a
- // compiler bug (`Self` does not have a constant size).
- if !self.contains_relatively_positioned_fragments() {
- self.store_overflow(layout_context)
- }
mut_base(self).restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW);
}
impacted
@@ -252,9 +247,6 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static {
// FIXME(#2795): Get the real container size.
let container_size = Size2D::zero();
for kid in mut_base(self).children.iter_mut() {
- if base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED) {
- continue
- }
let kid_overflow = base(kid).overflow;
let kid_position = base(kid).position.to_physical(base(kid).writing_mode,
container_size);
@@ -461,11 +453,6 @@ pub trait ImmutableFlowUtils {
/// Returns true if this flow is an inline flow.
fn is_inline_flow(self) -> bool;
- /// Returns true if this flow can have its overflow area calculated early (during its
- /// block-size assignment) or false if it must have its overflow area calculated late (during
- /// its parent's block-size assignment).
- fn can_calculate_overflow_area_early(self) -> bool;
-
/// Dumps the flow tree for debugging.
fn dump(self);
@@ -502,12 +489,6 @@ pub trait MutableFlowUtils {
/// 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: &Arc<ComputedValues>);
-
- /// Calls `store_overflow()` if the overflow can be calculated early.
- fn early_store_overflow(self, layout_context: &LayoutContext);
-
- /// Calls `store_overflow()` if the overflow cannot be calculated early.
- fn late_store_overflow(self, layout_context: &LayoutContext);
}
pub trait MutableOwnedFlowUtils {
@@ -1310,13 +1291,6 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
}
}
- /// Returns true if this flow can have its overflow area calculated early (during its
- /// block-size assignment) or false if it must have its overflow area calculated late (during
- /// its parent's block-size assignment).
- fn can_calculate_overflow_area_early(self) -> bool {
- !self.contains_relatively_positioned_fragments()
- }
-
/// Dumps the flow tree for debugging.
fn dump(self) {
self.dump_with_level(0)
@@ -1395,20 +1369,6 @@ impl<'a> MutableFlowUtils for &'a mut Flow {
traversal.process(*self)
}
-
- /// Calls `store_overflow()` if the overflow can be calculated early.
- fn early_store_overflow(self, layout_context: &LayoutContext) {
- if self.can_calculate_overflow_area_early() {
- self.store_overflow(layout_context)
- }
- }
-
- /// Calls `store_overflow()` if the overflow cannot be calculated early.
- fn late_store_overflow(self, layout_context: &LayoutContext) {
- if !self.can_calculate_overflow_area_early() {
- self.store_overflow(layout_context)
- }
- }
}
impl MutableOwnedFlowUtils for FlowRef {
diff --git a/components/layout/inline.rs b/components/layout/inline.rs
index 8711881ffaf..fe798496e11 100644
--- a/components/layout/inline.rs
+++ b/components/layout/inline.rs
@@ -5,7 +5,7 @@
#![deny(unsafe_code)]
use app_units::Au;
-use block::{AbsoluteAssignBSizesTraversal, AbsoluteStoreOverflowTraversal};
+use block::AbsoluteAssignBSizesTraversal;
use context::LayoutContext;
use display_list_builder::{FragmentDisplayListBuilding, InlineFlowDisplayListBuilding};
use euclid::{Point2D, Rect, Size2D};
@@ -1598,11 +1598,6 @@ impl Flow for InlineFlow {
// the block-size of its containing block, which may also be an absolute flow.
(&mut *self as &mut Flow).traverse_preorder_absolute_flows(
&mut AbsoluteAssignBSizesTraversal(layout_context));
- // Store overflow for all absolute descendants.
- (&mut *self as &mut Flow).traverse_postorder_absolute_flows(
- &mut AbsoluteStoreOverflowTraversal {
- layout_context: layout_context,
- });
}
self.base.position.size.block = match self.lines.last() {
@@ -1627,7 +1622,6 @@ impl Flow for InlineFlow {
relative_containing_block_size: containing_block_size,
relative_containing_block_mode: writing_mode,
};
- (block.as_mut_block() as &mut Flow).late_store_overflow(layout_context);
}
SpecificFragmentInfo::InlineAbsolute(ref mut info) => {
let block = flow_ref::deref_mut(&mut info.flow_ref);
@@ -1635,7 +1629,6 @@ impl Flow for InlineFlow {
relative_containing_block_size: containing_block_size,
relative_containing_block_mode: writing_mode,
};
- (block.as_mut_block() as &mut Flow).late_store_overflow(layout_context);
}
_ => (),
}
diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs
index 1ea9bffeb51..eddac889c50 100644
--- a/components/layout/parallel.rs
+++ b/components/layout/parallel.rs
@@ -484,9 +484,6 @@ pub fn traverse_flow_tree_preorder(
})
});
}, shared_layout_context);
-
- let layout_context = LayoutContext::new(shared_layout_context);
- flow_ref::deref_mut(root).late_store_overflow(&layout_context);
}
pub fn build_display_list_for_subtree(
diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs
index 75f121ca2cc..9202ef2ea8a 100644
--- a/components/layout/sequential.rs
+++ b/components/layout/sequential.rs
@@ -98,8 +98,6 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
let assign_block_sizes = AssignBSizesAndStoreOverflow { layout_context: &layout_context };
doit(root, assign_inline_sizes, assign_block_sizes);
-
- root.late_store_overflow(&layout_context);
}
pub fn build_display_list_for_subtree(root: &mut FlowRef,
diff --git a/components/layout/table.rs b/components/layout/table.rs
index 62b8807de07..c3d7ec137d9 100644
--- a/components/layout/table.rs
+++ b/components/layout/table.rs
@@ -12,7 +12,7 @@ use block::{self, BlockFlow, CandidateBSizeIterator, ISizeAndMarginsComputer};
use context::LayoutContext;
use display_list_builder::{BlockFlowDisplayListBuilding, BorderPaintingMode};
use euclid::{Point2D, Rect};
-use flow::{IMPACTED_BY_RIGHT_FLOATS, ImmutableFlowUtils, MutableFlowUtils, OpaqueFlow};
+use flow::{IMPACTED_BY_RIGHT_FLOATS, ImmutableFlowUtils, OpaqueFlow};
use flow::{self, EarlyAbsolutePositionInfo, Flow, FlowClass, IMPACTED_BY_LEFT_FLOATS};
use fragment::{Fragment, FragmentBorderBoxIterator};
use gfx::display_list::DisplayList;
@@ -762,7 +762,7 @@ pub trait TableLikeFlow {
impl TableLikeFlow for BlockFlow {
fn assign_block_size_for_table_like_flow<'a>(&mut self,
- layout_context: &'a LayoutContext<'a>,
+ _: &'a LayoutContext<'a>,
block_direction_spacing: Au) {
debug_assert!(self.fragment.style.get_inheritedtable().border_collapse ==
border_collapse::T::separate || block_direction_spacing == Au(0));
@@ -842,7 +842,6 @@ impl TableLikeFlow for BlockFlow {
relative_containing_block_size: self.fragment.content_box().size,
relative_containing_block_mode: self.fragment.style().writing_mode,
};
- kid.late_store_overflow(layout_context)
}
}
diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs
index d833c240d63..34427b9d8d9 100644
--- a/components/layout/traversal.rs
+++ b/components/layout/traversal.rs
@@ -7,7 +7,7 @@
use construct::FlowConstructor;
use context::LayoutContext;
use css::matching::{ApplicableDeclarations, ElementMatchMethods, MatchMethods, StyleSharingResult};
-use flow::{MutableFlowUtils, PostorderFlowTraversal, PreorderFlowTraversal};
+use flow::{PostorderFlowTraversal, PreorderFlowTraversal};
use flow::{self, Flow};
use gfx::display_list::OpaqueNode;
use incremental::{self, BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, RestyleDamage};
@@ -360,7 +360,6 @@ impl<'a> PostorderFlowTraversal for AssignBSizesAndStoreOverflow<'a> {
}
flow.assign_block_size(self.layout_context);
- flow.early_store_overflow(self.layout_context);
}
#[inline]
@@ -378,6 +377,7 @@ impl<'a> PreorderFlowTraversal for ComputeAbsolutePositions<'a> {
#[inline]
fn process(&self, flow: &mut Flow) {
flow.compute_absolute_position(self.layout_context);
+ flow.store_overflow(self.layout_context);
}
}
diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json
index 10980937d89..da05b5bcb77 100644
--- a/tests/wpt/mozilla/meta/MANIFEST.json
+++ b/tests/wpt/mozilla/meta/MANIFEST.json
@@ -15,6 +15,18 @@
"deleted": [],
"items": {
"reftest": {
+ "css/abs-overflow-stackingcontext.html": [
+ {
+ "path": "css/abs-overflow-stackingcontext.html",
+ "references": [
+ [
+ "/_mozilla/css/abs-overflow-stackingcontext_ref.html",
+ "=="
+ ]
+ ],
+ "url": "/_mozilla/css/abs-overflow-stackingcontext.html"
+ }
+ ],
"css/abs_float_pref_width.html": [
{
"path": "css/abs_float_pref_width.html",
@@ -4750,6 +4762,18 @@
}
},
"reftest_nodes": {
+ "css/abs-overflow-stackingcontext.html": [
+ {
+ "path": "css/abs-overflow-stackingcontext.html",
+ "references": [
+ [
+ "/_mozilla/css/abs-overflow-stackingcontext_ref.html",
+ "=="
+ ]
+ ],
+ "url": "/_mozilla/css/abs-overflow-stackingcontext.html"
+ }
+ ],
"css/abs_float_pref_width.html": [
{
"path": "css/abs_float_pref_width.html",
diff --git a/tests/wpt/mozilla/tests/css/abs-overflow-stackingcontext.html b/tests/wpt/mozilla/tests/css/abs-overflow-stackingcontext.html
new file mode 100644
index 00000000000..264df01aa64
--- /dev/null
+++ b/tests/wpt/mozilla/tests/css/abs-overflow-stackingcontext.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <link rel='match' href='abs-overflow-stackingcontext_ref.html'>
+ <style>
+ html, body {
+ margin: 0;
+ perspective: 1000px;
+ }
+
+ div {
+ position: absolute;
+ top: 25vh;
+ left: 25vw;
+ width: 50vw;
+ height: 50vh;
+ background-color: green;
+ }
+ </style>
+ </head>
+ <body>
+ <div></div>
+ </body>
+</html>
diff --git a/tests/wpt/mozilla/tests/css/abs-overflow-stackingcontext_ref.html b/tests/wpt/mozilla/tests/css/abs-overflow-stackingcontext_ref.html
new file mode 100644
index 00000000000..f779e5a4233
--- /dev/null
+++ b/tests/wpt/mozilla/tests/css/abs-overflow-stackingcontext_ref.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style>
+ html, body {
+ margin: 0;
+ }
+
+ div {
+ position: absolute;
+ top: 25vh;
+ left: 25vw;
+ width: 50vw;
+ height: 50vh;
+ background-color: green;
+ }
+ </style>
+ </head>
+ <body>
+ <div></div>
+ </body>
+</html>