Commit Graph

15 Commits

Author SHA1 Message Date
Andreas Kling
54beb7433e LibWeb: Place block-level boxes vertically before formatting them inside
Block placement is now divided into a vertical and horizontal step. The
vertical step runs before formatting boxes internally. The horizontal
step still runs after (since we may need the final width value.)

This solves a long-standing architectural problem where IFC didn't know
its origin Y position within the BFC root box. This is required for
figuring out how to flow around floating objects. (Floating objects are
always relative to the BFC root.)
2022-01-24 02:09:17 +01:00
Andreas Kling
bb6af641d4 LibWeb: Unify placement of replaced and non-replaced elements in BFC
Seems like we can share the code for these.
2022-01-24 02:09:17 +01:00
Andreas Kling
d58f60c953 LibWeb: Unify code for assigning vertical box model metrics in BFC
We were doing the exact same thing for both replaced and non-replaced
elements, so let's share the code. :^)
2022-01-24 02:09:17 +01:00
Andreas Kling
f5c5efa067 LibWeb: Allow CSS floating objects to flow across multiple lines
If we run out of horizontal space when placing floating objects,
we now perform a "break" and continue with a new line of floats
below the bottommost margin edge of the current line.

This is definitely not 100% to-spec yet, but a huge improvement
on ACID1 already. :^)
2022-01-23 01:22:41 +01:00
Andreas Kling
0ea438e45b LibWeb: Put BFC floating object state into a struct
This patch adds a BFC::FloatSideData struct so we can contain left and
right floating object layout state in a struct. This is preparation for
adding more per-side state.
2022-01-23 01:22:41 +01:00
Sam Atkins
7879b98f60 LibWeb: Use W3C urls for CSS-DISPLAY spec links 2021-10-15 21:05:35 +01:00
Andreas Kling
f73aa8e2bd LibWeb: Move line boxes from Layout::Box to BlockContainer
Per the spec, only a BlockContainer" can have line boxes, so let's not
clutter up every Layout::Box with line boxes.

This also allows us to establish an invariant that BFC and IFC always
operate on a Layout::BlockContainer.

Note that if BlockContainer has all block-level children, its line boxes
are not used for anything. They are only used in the all inline-level
children scenario.
2021-10-06 21:53:25 +02:00
Andreas Kling
5408913b22 LibWeb: Add BlockFormattingContext::root()
The CSS spec uses the name "block formatting context root" when talking
about a box that establishes a BFC. So let's call it BFC::root() in our
code as well, instead of the less specific BFC::context_box().
2021-10-06 20:10:36 +02:00
Tobias Christiansen
6e1f6bd684 LibWeb: Add transform: translateY() support
This is very naive.
2021-09-18 21:53:37 +02:00
Tobias Christiansen
c51dbb4372 LibWeb: Expose size calculation of BlockFormattingContext
This is a hack for the FlexFormattingContext
2021-06-06 01:46:06 +04:30
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Egor Ananyin
1d343116a9 LibWeb: Fix height calculation for absolutely positioned boxes
This commit fixes algorithm for computing auto height (CSS 2.2 10.6.7)
by including floating boxes into computation and implements one of the cases
for computing the height of absolutely positioned, non-replaced elements (10.6.4 rule 3)
2021-04-17 09:48:27 +02:00
Timothy Flynn
deda7c8995 LibWeb: Compute position of relative block elements
Section 10.3 "Calculating widths and margins" indicates that the 'left'
and 'right' properties of relatively positioned elements should be set
in accordance with the rules of section 9.4.3.
2021-03-29 19:56:23 +02:00
Andreas Kling
968ad0f8d1 LibWeb: Some improvements to CSS height:auto computation for blocks
Auto block heights are now computed according to something that kinda
resembles the specification.

Blocks with inline children and height:auto have their height computed
based on the top of the first line box and the bottom of the last line
box. Very straightforward.

Blocks with block children and height:auto have their height computed
based on the top of the first in-flow block child's margin box, and the
bottom of the last in-flow block child's margin box.
2021-03-08 22:53:28 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00