mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #15730 - emilio:adjust-float, r=SimonSapin
style: Adjust float if the element is positioned per CSS 2.1 section 9.7 We've found crashes related to this in Gecko. r? @simonsapin or @heycam <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15730) <!-- Reviewable:end -->
This commit is contained in:
commit
eb281531f8
3 changed files with 47 additions and 4 deletions
|
@ -1960,10 +1960,14 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
|||
% endif
|
||||
computed_values::display::T::flex |
|
||||
computed_values::display::T::inline_flex);
|
||||
let (blockify_root, blockify_item) = match flags.contains(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) {
|
||||
false => (is_root_element, is_item),
|
||||
true => (false, false),
|
||||
};
|
||||
|
||||
let (blockify_root, blockify_item) =
|
||||
if flags.contains(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) {
|
||||
(false, false)
|
||||
} else {
|
||||
(is_root_element, is_item)
|
||||
};
|
||||
|
||||
if positioned || floated || blockify_root || blockify_item {
|
||||
use computed_values::display::T;
|
||||
|
||||
|
@ -2020,6 +2024,15 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
|||
}
|
||||
}
|
||||
|
||||
// CSS 2.1 section 9.7:
|
||||
//
|
||||
// If 'position' has the value 'absolute' or 'fixed', [...] the computed
|
||||
// value of 'float' is 'none'.
|
||||
//
|
||||
if positioned && floated {
|
||||
style.mutate_box().set_float(longhands::float::computed_value::T::none);
|
||||
}
|
||||
|
||||
// This implements an out-of-date spec. The new spec moves the handling of
|
||||
// this to layout, which Gecko implements but Servo doesn't.
|
||||
//
|
||||
|
|
|
@ -11036,6 +11036,12 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"css/float-abspos.html": [
|
||||
[
|
||||
"/_mozilla/css/float-abspos.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"css/float_relative_to_position.html": [
|
||||
[
|
||||
"/_mozilla/css/float_relative_to_position.html",
|
||||
|
@ -20895,6 +20901,10 @@
|
|||
"2712a0a76b5eeb4d0f2b4a45277d04791a8ff206",
|
||||
"support"
|
||||
],
|
||||
"css/float-abspos.html": [
|
||||
"d34a9ce0be290bc3c46aa80eb136a91460957346",
|
||||
"testharness"
|
||||
],
|
||||
"css/float_clearance_a.html": [
|
||||
"372652bf4c345098f864cfc52ad0fb274308b22c",
|
||||
"reftest"
|
||||
|
|
20
tests/wpt/mozilla/tests/css/float-abspos.html
Normal file
20
tests/wpt/mozilla/tests/css/float-abspos.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>A positioned element's float value computes to "none"</title>
|
||||
<link rel="help" href="https://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo">
|
||||
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="test" style="float: left"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var elem = document.getElementById('test');
|
||||
assert_equals(getComputedStyle(elem).float, "left");
|
||||
elem.style.position = "absolute";
|
||||
assert_equals(getComputedStyle(elem).float, "none");
|
||||
elem.style.position = "";
|
||||
assert_equals(getComputedStyle(elem).float, "left");
|
||||
elem.style.position = "fixed";
|
||||
assert_equals(getComputedStyle(elem).float, "none");
|
||||
}, "A positioned element's float value computes to none");
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue