diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-26 21:53:10 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-26 22:02:27 +0200 |
commit | f01af6231329249594451810927dda9ea94bf444 (patch) | |
tree | 9b7ab13d2d57746f0e5190c6e36549003c1b055f /Libraries/LibWeb/Layout/LayoutListItem.cpp | |
parent | 4e8bcda4d11c0b6fdca9d23bbf639eed9a35580f (diff) | |
download | serenity-f01af6231329249594451810927dda9ea94bf444.zip |
LibWeb: Basic support for display:inline-block with width:auto
We now implement the somewhat fuzzy shrink-to-fit algorithm when laying
out inline-block elements with both block and inline children.
Shrink-to-fit works by doing two speculative layouts of the entire
subtree inside the current block, to compute two things:
1. Preferred minimum width: If we made a line break at every chance we
had, how wide would the widest line be?
2. Preferred width: We break only when explicitly told to (e.g "<br>")
How wide would the widest line be?
We then shrink the width of the inline-block element to an appropriate
value based on the above, taking the available width in the containing
block into consideration (sans all the box model fluff.)
To make the speculative layouts possible, plumb a LayoutMode enum
throughout the layout system since it needs to be respected in various
places.
Note that this is quite hackish and I'm sure there are smarter ways to
do a lot of this. But it does kinda work! :^)
Diffstat (limited to 'Libraries/LibWeb/Layout/LayoutListItem.cpp')
-rw-r--r-- | Libraries/LibWeb/Layout/LayoutListItem.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Libraries/LibWeb/Layout/LayoutListItem.cpp b/Libraries/LibWeb/Layout/LayoutListItem.cpp index 2d14fb0ce6..c82c2cea08 100644 --- a/Libraries/LibWeb/Layout/LayoutListItem.cpp +++ b/Libraries/LibWeb/Layout/LayoutListItem.cpp @@ -38,14 +38,14 @@ LayoutListItem::~LayoutListItem() { } -void LayoutListItem::layout() +void LayoutListItem::layout(LayoutMode line_break_policy) { if (m_marker) { remove_child(*m_marker); m_marker = nullptr; } - LayoutBlock::layout(); + LayoutBlock::layout(line_break_policy); if (!m_marker) { m_marker = adopt(*new LayoutListItemMarker); |