aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2016-03-25 15:27:28 -0700
committerPatrick Walton <pcwalton@mimiga.net>2016-03-25 15:29:17 -0700
commit24d81e95b4ea3be8db623e15944e7a70b9e202fd (patch)
treeb2ab71adca4757d5cc29794a3f4e4d199660b700 /components/layout
parenta211bd1a12254a6a08987bb61f30c8b0e5ce2830 (diff)
downloadservo-24d81e95b4ea3be8db623e15944e7a70b9e202fd.tar.gz
servo-24d81e95b4ea3be8db623e15944e7a70b9e202fd.zip
layout: Allow floats to have negative ceilings due to negative margins.
This fixes `margin-collapse-104.htm`, which is currently accidentally passing due to lack of #10085. When that PR lands, then that will become a representative test case.
Diffstat (limited to 'components/layout')
-rw-r--r--components/layout/floats.rs27
1 files changed, 15 insertions, 12 deletions
diff --git a/components/layout/floats.rs b/components/layout/floats.rs
index 44704b22230..4ef48fe8a7a 100644
--- a/components/layout/floats.rs
+++ b/components/layout/floats.rs
@@ -56,14 +56,14 @@ struct FloatList {
/// Information about each of the floats here.
floats: PersistentList<Float>,
/// Cached copy of the maximum block-start offset of the float.
- max_block_start: Au,
+ max_block_start: Option<Au>,
}
impl FloatList {
fn new() -> FloatList {
FloatList {
floats: PersistentList::new(),
- max_block_start: Au(0),
+ max_block_start: None,
}
}
@@ -247,15 +247,15 @@ impl Floats {
/// Adds a new float to the list.
pub fn add_float(&mut self, info: &PlacementInfo) {
- let new_info;
- {
- new_info = PlacementInfo {
- size: info.size,
- ceiling: max(info.ceiling, self.list.max_block_start + self.offset.block),
- max_inline_size: info.max_inline_size,
- kind: info.kind
- }
- }
+ let new_info = PlacementInfo {
+ size: info.size,
+ ceiling: match self.list.max_block_start {
+ None => info.ceiling,
+ Some(max_block_start) => max(info.ceiling, max_block_start + self.offset.block),
+ },
+ max_inline_size: info.max_inline_size,
+ kind: info.kind
+ };
debug!("add_float: added float with info {:?}", new_info);
@@ -269,7 +269,10 @@ impl Floats {
};
self.list.floats = self.list.floats.prepend_elem(new_float);
- self.list.max_block_start = max(self.list.max_block_start, new_float.bounds.start.b);
+ self.list.max_block_start = match self.list.max_block_start {
+ None => Some(new_float.bounds.start.b),
+ Some(max_block_start) => Some(max(max_block_start, new_float.bounds.start.b)),
+ }
}
/// Given the three sides of the bounding rectangle in the block-start direction, finds the