mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 02:17:34 +00:00
LibWeb: Improve inline flow around floating boxes
This patch combines a number of techniques to make inline content flow more correctly around floats: - During inline layout, BFC now lets LineBuilder decide the Y coordinate when inserting a new float. LineBuilder has more information about the currently accumulated line, and can make better breaking decisions. - When inserting a float on one side, and the top of the newly inserted float is below the bottommost float on the opposite side, we now reset the opposite side back to the start of that edge. This improves breaking behavior between opposite-side floats. - After inserting a float during inline layout, we now recalculate the available space on the line, but don't adjust X offsets of already existing fragments. This is handled by update_last_line() anyway, so it was pointless busywork. - When measuring whether a line can fit at a given Y coordinate, we now consider both the top and bottom Y values of the line. This fixes an issue where the bottom part of a line would bleed over other content (since we had only checked that the top Y coordinate of that line would fit.) There are some pretty brain-dead algorithms in here that we need to make smarter, but I didn't want to complicate this any further so I've left FIXMEs about them instead.
This commit is contained in:
parent
54e7359243
commit
412b2313f3
6 changed files with 185 additions and 32 deletions
|
@ -39,11 +39,13 @@ public:
|
|||
void remove_last_line_if_empty();
|
||||
|
||||
float current_y() const { return m_current_y; }
|
||||
void set_current_y(float y) { m_current_y = y; }
|
||||
|
||||
void adjust_last_line_after_inserting_floating_box(Badge<BlockFormattingContext>, CSS::Float, float space_used_by_float);
|
||||
void recalculate_available_space();
|
||||
float y_for_float_to_be_inserted_here(Box const&);
|
||||
|
||||
private:
|
||||
void begin_new_line(bool increment_y);
|
||||
void begin_new_line(bool increment_y, bool is_first_break_in_sequence = true);
|
||||
|
||||
bool should_break(float next_item_width);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue