aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/main/layout/float_context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/main/layout/float_context.rs')
-rw-r--r--src/components/main/layout/float_context.rs23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/components/main/layout/float_context.rs b/src/components/main/layout/float_context.rs
index 45e142b24b9..7a92554401c 100644
--- a/src/components/main/layout/float_context.rs
+++ b/src/components/main/layout/float_context.rs
@@ -3,12 +3,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use geom::point::Point2D;
-use geom::size::Size2D;
use geom::rect::Rect;
+use geom::size::Size2D;
use servo_util::geometry::{Au, max, min};
+use std::i32::max_value;
use std::util::replace;
use std::vec;
-use std::i32::max_value;
+use style::computed_values::float;
#[deriving(Clone)]
pub enum FloatType {
@@ -16,6 +17,16 @@ pub enum FloatType {
FloatRight
}
+impl FloatType {
+ pub fn from_property(property: float::T) -> FloatType {
+ match property {
+ float::none => fail!("can't create a float type from an unfloated property"),
+ float::left => FloatLeft,
+ float::right => FloatRight,
+ }
+ }
+}
+
pub enum ClearType {
ClearLeft,
ClearRight,
@@ -31,13 +42,13 @@ struct FloatContextBase {
}
#[deriving(Clone)]
-struct FloatData{
+struct FloatData {
bounds: Rect<Au>,
f_type: FloatType
}
/// All information necessary to place a float
-pub struct PlacementInfo{
+pub struct PlacementInfo {
width: Au, // The dimensions of the float
height: Au,
ceiling: Au, // The minimum top of the float, as determined by earlier elements
@@ -126,7 +137,7 @@ impl FloatContext {
}
}
-impl FloatContextBase{
+impl FloatContextBase {
fn new(num_floats: uint) -> FloatContextBase {
debug!("Creating float context of size {}", num_floats);
FloatContextBase {
@@ -335,7 +346,7 @@ impl FloatContextBase{
match maybe_location {
// If there are no floats blocking us, return the current location
- // TODO(eatknson): integrate with overflow
+ // TODO(eatkinson): integrate with overflow
None => return match info.f_type {
FloatLeft => Rect(Point2D(Au(0), float_y),
Size2D(info.max_width, Au(max_value))),