diff options
author | Eric Atkinson <eatkinson@mozilla.com> | 2013-06-24 09:37:09 -0700 |
---|---|---|
committer | Eric Atkinson <eatkinson@mozilla.com> | 2013-06-24 16:07:02 -0700 |
commit | 0c63dda2904a77116218b07532d2f80cb159ae7d (patch) | |
tree | 000c22b26ecc114f360c62c820c7e08884929bb7 /src/components/main/layout/float_context.rs | |
parent | 94e7a86b7efe8b8c8d8ede0f3104c3893ff9a37a (diff) | |
download | servo-0c63dda2904a77116218b07532d2f80cb159ae7d.tar.gz servo-0c63dda2904a77116218b07532d2f80cb159ae7d.zip |
Allow floats to have specified heights
Diffstat (limited to 'src/components/main/layout/float_context.rs')
-rw-r--r-- | src/components/main/layout/float_context.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/components/main/layout/float_context.rs b/src/components/main/layout/float_context.rs index dd35b4f91cb..0d026ecc942 100644 --- a/src/components/main/layout/float_context.rs +++ b/src/components/main/layout/float_context.rs @@ -55,7 +55,7 @@ impl FloatContext { } #[inline(always)] - fn with_base<R>(&mut self, callback: &fn(&mut FloatContextBase) -> R) -> R { + fn with_mut_base<R>(&mut self, callback: &fn(&mut FloatContextBase) -> R) -> R { match *self { Invalid => fail!("Float context no longer available"), Valid(ref mut base) => callback(base) @@ -72,7 +72,7 @@ impl FloatContext { #[inline(always)] pub fn translate(&mut self, trans: Point2D<Au>) -> FloatContext { - do self.with_base |base| { + do self.with_mut_base |base| { base.translate(trans); } replace(self, Invalid) @@ -87,11 +87,18 @@ impl FloatContext { #[inline(always)] pub fn add_float(&mut self, info: &PlacementInfo) -> FloatContext{ - do self.with_base |base| { + do self.with_mut_base |base| { base.add_float(info); } replace(self, Invalid) } + + #[inline(always)] + pub fn last_float_pos(&mut self) -> Point2D<Au> { + do self.with_base |base| { + base.last_float_pos() + } + } } impl FloatContextBase{ @@ -110,6 +117,15 @@ impl FloatContextBase{ self.offset += trans; } + fn last_float_pos(&self) -> Point2D<Au> { + assert!(self.floats_used > 0, "Error: tried to access FloatContext with no floats in it"); + + match self.float_data[self.floats_used - 1] { + None => fail!("FloatContext error: floats should never be None here"), + Some(float) => float.bounds.origin + } + } + /// Returns a rectangle that encloses the region from top to top + height, /// with width small enough that it doesn't collide with any floats. max_x /// is the x-coordinate beyond which floats have no effect (generally |