aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flow/mod.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2020-07-22 19:07:36 -0700
committerPatrick Walton <pcwalton@mimiga.net>2020-07-22 19:58:28 -0700
commit362b64aa68f256016506e82747edb846f93d371a (patch)
tree994e0859242f91014bc2af1d3cf4b9c2f3d19a04 /components/layout_2020/flow/mod.rs
parent6a9aac3e654d4498c8c2605ebe8a24b609770e21 (diff)
downloadservo-362b64aa68f256016506e82747edb846f93d371a.tar.gz
servo-362b64aa68f256016506e82747edb846f93d371a.zip
Use the size of the containing block, not the size of the block formatting
context, to place floats in layout 2020. The containing block for a float is not necessarily the same as the block formatting context the float is in per CSS 2.1 [1]: "For other elements, if the element’s position is relative or static, the containing block is formed by the content edge of the nearest block container ancestor box." This shows up in the simplest case: <html> <body> <div style="float: left">Hello</div> </body> </html> In this case, the `<html>` element is the block formatting context with inline size equal to the width of the window, but the `<body>` element with nonzero inline margins is the containing block for the float. The float placement must respect the content box of the `<body>` element (i.e. floats must not overlap the `<body>` element's margins), not that of the `<html>` element. Because a single block formatting context may contain floats with different containing blocks, the left and right "walls" of that containing block become properties of individual floats at the time of placement, not properties of the float context itself. Additionally, this commit generalizes the float placement logic a bit to allow the placement of arbitrary objects, not just floats. This is intended to support inline layout and block formatting context placement. This commit updates the `FloatContext` and associated tests only and doesn't actually wire the context up to the rest of layout, so floats in pages still aren't actually laid out. [1]: https://drafts.csswg.org/css2/#containing-block-details
Diffstat (limited to 'components/layout_2020/flow/mod.rs')
-rw-r--r--components/layout_2020/flow/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs
index f042f814dd3..b5898fc6146 100644
--- a/components/layout_2020/flow/mod.rs
+++ b/components/layout_2020/flow/mod.rs
@@ -80,7 +80,7 @@ impl BlockFormattingContext {
) -> IndependentLayout {
let mut float_context;
let float_context = if self.contains_floats {
- float_context = FloatContext::new(containing_block.inline_size);
+ float_context = FloatContext::new();
Some(&mut float_context)
} else {
None