diff options
author | Andreas Kling <kling@serenityos.org> | 2022-03-22 19:18:05 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-22 19:26:51 +0100 |
commit | de6f7f0029db116e81867245b4d38ad6fe4825bb (patch) | |
tree | c897cf38bed97b42475ad6c37da74a768a513c32 /Userland/Libraries/LibWeb/Layout/LineBuilder.cpp | |
parent | fa64a7f6cc9a2b89b03e26030fa294684bb8c243 (diff) | |
download | serenity-de6f7f0029db116e81867245b4d38ad6fe4825bb.zip |
LibWeb: Support CSS floats in inline flow
CSS floats are now emitted by the InlineLevelIterator. When this
happens, IFC coordinates with the parent BFC to float the box to the
side, using the current LineBuilder state for vertical placement.
This makes the "instructions" text on Acid3 render as a single
contiguous flow of inline content.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/LineBuilder.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/LineBuilder.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp b/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp index d5bc9499c4..1aae5583b8 100644 --- a/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp @@ -206,4 +206,20 @@ void LineBuilder::remove_last_line_if_empty() m_last_line_needs_update = false; } } + +void LineBuilder::adjust_last_line_after_inserting_floating_box(Badge<BlockFormattingContext>, CSS::Float float_, float space_used_by_float) +{ + // NOTE: LineBuilder generates lines from left-to-right, so if we've just added a left-side float, + // that means every fragment already on this line has to move towards the right. + if (float_ == CSS::Float::Left && !m_containing_block_state.line_boxes.is_empty()) { + for (auto& fragment : m_containing_block_state.line_boxes.last().fragments()) + fragment.set_offset(fragment.offset().translated(space_used_by_float, 0)); + m_containing_block_state.line_boxes.last().m_width += space_used_by_float; + } + + m_available_width_for_current_line -= space_used_by_float; + if (m_available_width_for_current_line < 0) + m_available_width_for_current_line = 0; +} + } |