CSS Normal Flow Inline Context #1431
Replies: 1 comment
-
I did some further reading this morning which seems to suggest that the LineBox isn't necessarily part of the Box Tree. I also went ahead and ran the HTML doc using the LadyBird browser. Below is a dump of the layout tree it generated:
Granted not all browsers will use the same data structures (and further granted that LadyBird is in early development), it seems to me as though a LineBox is used as a data structure to keep track of where fragments for a particular node should be placed, and the placement of text and background rects for a fragment are recorded as Lines are created/flushed/split. Further, the BlockContainer breaks the flow of the Line data structure (as expected) and that once the break is processed, any un-finished inline element is recreated and has its fragments processed accordingly. Finally, Inline elements with children generate Inline Blocks with children, retaining a nested structure. I can't say I fully understand the spec but this seems to have given me a bit more understanding. I think a point of confusion comes into play due to the multiple trees that are using by rendering engines (and overlapping/ambiguous syntax). Still, any input and further resources are appreciated! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am putting the TLDR at the top of this question since its kinda long. TLDR: is there any place where I can find examples that show definitively how to go from a DOM to a Box Tree in Normal Flow? I am not entirely certain on how Inline Boxes should be mapped to Line Boxes in such a way that backgrounds/borders are preserved, inline-block layout can be supported and vertical align used.
NOTE: All of what I mention below is with respect to normal flow.
I have been reading through the CSS 2 documentation for the Visual formatting model and have found it to be rather confusing. Every time I read through it I seem to answer some questions but come up with new ones which has made it more difficult to rework my own implementation to be inline with the specification.
Inline Boxes in particular seem to be tricky to understand. Per the spec:
So we have this concept of an Inline Box and a Line Box (for simplicity I will be ignoring anonymous boxes). Say I have the below html:
This would generate the following (in Brave):
An idea on how to implement this would be to start generating lines using the text from inline elements
This could give us something akin to:
As lines are generated however, un-finished Inline elements are placed on a stack that records the line an Inline Box portion of the element was on generated on (and a reference to that Box). Then, once the element is closed, all of those Inline Box portions for a single element can be updated to have their background/border coordinates stretch to the ends of the lines as necessary (to ensure that things are rendered correctly). One thing to fix however, is the order in which backgrounds are painted (since the background for
span class="c3"
should not be covered by that ofspan class ="c1"
).I am not sure if this the way I should be interpreting the docs. I have read through a bit of the layout overview for Firefox but that didn't help me all that much, nor did looking at the source code for LadyBird or WeaslyPrint.
Beta Was this translation helpful? Give feedback.
All reactions