diff --git a/src/components/main/layout/block.rs b/src/components/main/layout/block.rs index e2d45002f65..72ae49e6a93 100644 --- a/src/components/main/layout/block.rs +++ b/src/components/main/layout/block.rs @@ -42,7 +42,8 @@ use std::fmt; use std::mem; use std::num::Zero; use style::computed_values::{LPA_Auto, LPA_Length, LPA_Percentage, LPN_Length, LPN_None}; -use style::computed_values::{LPN_Percentage, LP_Length, LP_Percentage, display, float, overflow}; +use style::computed_values::{LPN_Percentage, LP_Length, LP_Percentage}; +use style::computed_values::{display, direction, float, overflow}; use sync::Arc; /// Information specific to floated blocks. @@ -1717,6 +1718,7 @@ pub struct WidthConstraintInput { pub right: MaybeAuto, pub available_width: Au, pub static_x_offset: Au, + pub direction: direction::T, } impl WidthConstraintInput { @@ -1726,7 +1728,8 @@ impl WidthConstraintInput { left: MaybeAuto, right: MaybeAuto, available_width: Au, - static_x_offset: Au) + static_x_offset: Au, + direction: direction::T) -> WidthConstraintInput { WidthConstraintInput { computed_width: computed_width, @@ -1736,6 +1739,7 @@ impl WidthConstraintInput { right: right, available_width: available_width, static_x_offset: static_x_offset, + direction: direction, } } } @@ -1814,7 +1818,8 @@ pub trait WidthAndMarginsComputer { left, right, available_width, - block.static_x_offset()); + block.static_x_offset(), + style.get_inheritedbox().direction); } /// Set the used values for width and margins got from the relevant constraint equation. @@ -1940,9 +1945,12 @@ pub trait WidthAndMarginsComputer { // If direction is ltr, ignore the specified right margin and // solve for it. // If it is rtl, ignore the specified left margin. - // FIXME(eatkinson): this assumes the direction is ltr - (Specified(margin_l), Specified(width), Specified(_margin_r)) => - (margin_l, width, available_width - (margin_l + width )), + (Specified(margin_l), Specified(width), Specified(margin_r)) => { + match input.direction { + direction::ltr => (margin_l, width, available_width - (margin_l + width)), + direction::rtl => (available_width - (margin_r + width), width, margin_r), + } + }, // If exactly one value is 'auto', solve for it (Auto, Specified(width), Specified(margin_r)) => @@ -2004,6 +2012,7 @@ impl WidthAndMarginsComputer for AbsoluteNonReplaced { right, available_width, static_x_offset, + direction, } = input; // TODO: Check for direction of parent flow (NOT Containing Block) @@ -2152,6 +2161,7 @@ impl WidthAndMarginsComputer for AbsoluteReplaced { right, available_width, static_x_offset, + direction, } = input; // TODO: Check for direction of static-position Containing Block (aka // parent flow, _not_ the actual Containing Block) when right-to-left diff --git a/src/components/style/properties.rs.mako b/src/components/style/properties.rs.mako index 62292004817..fdd98a5ef08 100644 --- a/src/components/style/properties.rs.mako +++ b/src/components/style/properties.rs.mako @@ -321,8 +321,14 @@ pub mod longhands { ${single_keyword("float", "none left right")} ${single_keyword("clear", "none left right both")} + ${new_style_struct("InheritedBox", is_inherited=True)} + + ${single_keyword("direction", "ltr rtl")} + // CSS 2.1, Section 10 - Visual formatting model details + ${switch_to_style_struct("Box")} + ${predefined_type("width", "LengthOrPercentageOrAuto", "computed::LPA_Auto", "parse_non_negative")} @@ -364,7 +370,7 @@ pub mod longhands { "computed::LPN_None", "parse_non_negative")} - ${new_style_struct("InheritedBox", is_inherited=True)} + ${switch_to_style_struct("InheritedBox")} <%self:single_component_value name="line-height"> #[deriving(Clone)] diff --git a/src/test/ref/basic.list b/src/test/ref/basic.list index 047eab56c16..58215700bb6 100644 --- a/src/test/ref/basic.list +++ b/src/test/ref/basic.list @@ -74,3 +74,4 @@ == pseudo_element_a.html pseudo_element_b.html == linebreak_simple_a.html linebreak_simple_b.html == linebreak_inline_span_a.html linebreak_inline_span_b.html +== overconstrained_block.html overconstrained_block_ref.html diff --git a/src/test/ref/overconstrained_block.html b/src/test/ref/overconstrained_block.html new file mode 100644 index 00000000000..564232f4cd7 --- /dev/null +++ b/src/test/ref/overconstrained_block.html @@ -0,0 +1,15 @@ + +
+