From 725484d61944542debd483e27b2608c1e2fda53e Mon Sep 17 00:00:00 2001 From: Gilles Leblanc Date: Wed, 21 Oct 2015 22:43:37 -0400 Subject: [PATCH 1/2] Compute value of float according to position value According to CSS2 Section 9.7, if 'position' has a value of 'absolute' or 'fixed' the computed value of 'float' should be 'none'. This changes the float to a single_keyword_computed which checks the positioned value of the element to compute the float value. Fixes #8002 --- components/style/properties.mako.rs | 20 +++++++++++++- tests/wpt/mozilla/meta/MANIFEST.json | 6 +++++ .../tests/css/float_relative_to_position.html | 27 +++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/mozilla/tests/css/float_relative_to_position.html diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index c8f1834b1ac..1c85d48aab5 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -546,7 +546,25 @@ pub mod longhands { ${single_keyword("position", "static absolute relative fixed")} - ${single_keyword("float", "none left right")} + + <%self:single_keyword_computed name="float" values="none left right"> + use values::computed::Context; + + impl ToComputedValue for SpecifiedValue { + type ComputedValue = computed_value::T; + + #[inline] + fn to_computed_value(&self, context: &Context) -> computed_value::T { + if context.positioned { + SpecifiedValue::none + } else { + *self + } + } + } + + + ${single_keyword("clear", "none left right both")} <%self:longhand name="-servo-display-for-hypothetical-box" derived_from="display"> diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 3e6f6494f7d..2dda2060389 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -3961,6 +3961,12 @@ ] }, "testharness": { + "css/float_relative_to_position.html": [ + { + "path": "css/float_relative_to_position.html", + "url": "/_mozilla/css/float_relative_to_position.html" + } + ], "css/test_variable_legal_values.html": [ { "path": "css/test_variable_legal_values.html", diff --git a/tests/wpt/mozilla/tests/css/float_relative_to_position.html b/tests/wpt/mozilla/tests/css/float_relative_to_position.html new file mode 100644 index 00000000000..d72f26ed342 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/float_relative_to_position.html @@ -0,0 +1,27 @@ + + + + +Tests the relationship between float and position + + +
+ + + + + + + From 595f11dbd2a57dac9c650dd6eabc82f291bf6320 Mon Sep 17 00:00:00 2001 From: Gilles Leblanc Date: Thu, 22 Oct 2015 20:15:50 -0400 Subject: [PATCH 2/2] Modify wpt test following review comment --- .../tests/css/float_relative_to_position.html | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/wpt/mozilla/tests/css/float_relative_to_position.html b/tests/wpt/mozilla/tests/css/float_relative_to_position.html index d72f26ed342..bdeb133ef11 100644 --- a/tests/wpt/mozilla/tests/css/float_relative_to_position.html +++ b/tests/wpt/mozilla/tests/css/float_relative_to_position.html @@ -3,24 +3,37 @@ Tests the relationship between float and position + -
+