servo/components/layout_2020
Patrick Walton 362b64aa68 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
2020-07-22 19:58:28 -07:00
..
display_list Implement visibility for layout_2020 2020-06-14 00:31:37 +02:00
flexbox flex 2020: Handle positioning flex item based on align-self 2020-07-20 20:16:23 -07:00
flow Use the size of the containing block, not the size of the block formatting 2020-07-22 19:58:28 -07:00
tests Use the size of the containing block, not the size of the block formatting 2020-07-22 19:58:28 -07:00
Cargo.toml Add an implementation of the core float and clear placement logic in layout 2020-07-20 12:42:34 -07:00
cell.rs Implement Default for ArcRefCell 2020-03-17 11:15:17 -07:00
context.rs Implement cross origin resource policy check 2020-05-08 19:15:24 +02:00
data.rs Replace OpaqueStyleAndLayoutData by StyleAndOpaqueLayoutData 2020-04-06 23:06:13 +02:00
dom_traversal.rs Bump rust to 1.46.0-nightly (a8cf39911 2020-06-21) 2020-06-23 19:13:36 +02:00
element_data.rs Flex items in the box tree 2020-06-04 13:19:53 +02:00
formatting_contexts.rs First pass at implementing the Flex Layout Algorithm 2020-06-23 00:41:27 +02:00
fragments.rs layout_2020: Tag fragments with their pseudo content type 2020-06-06 17:25:08 +02:00
geom.rs Add an implementation of the core float and clear placement logic in layout 2020-07-20 12:42:34 -07:00
layout_debug.rs Rename BoxTreeRoot/FragmentTreeRoot to BoxTree/FragmentTree 2020-05-15 13:25:35 +02:00
lib.rs Add an implementation of the core float and clear placement logic in layout 2020-07-20 12:42:34 -07:00
opaque_node.rs Remove layout_2020::display_list, use WebRender display lists instead 2019-09-07 19:38:44 +02:00
positioned.rs Compute content sizes lazily in layout 2020 2020-06-18 14:11:02 +02:00
query.rs Fix ./mach build --release --with-layout-2020 2020-06-10 22:34:24 +05:30
replaced.rs Add WebGPU to Layout-2020 2020-06-14 11:05:36 +05:30
sizing.rs Parallelize BlockContainer::inline_content_sizes 2020-06-19 15:38:15 +02:00
style_ext.rs Use the writing mode of the containing block when accessing CSS properties 2020-06-10 09:03:18 +02:00
traversal.rs Remove postorder traversal from layout 2020 during styling 2020-04-06 12:40:05 +02:00
wrapper.rs Replace OpaqueStyleAndLayoutData by StyleAndOpaqueLayoutData 2020-04-06 23:06:13 +02:00