mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 07:09:47 +00:00
LibWeb/Layout: Simplified margin collapsing
Rather than accumulating margins into a vector, and then looping through them when resolving the margin, it's much simpler to just update two fields, and sum them when resolving.
This commit is contained in:
parent
6f52064c4f
commit
eafa70331d
Notes:
github-actions[bot]
2024-11-24 13:46:19 +00:00
Author: https://github.com/TUSF 🔰
Commit: eafa70331d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1887
2 changed files with 10 additions and 26 deletions
|
@ -126,13 +126,18 @@ private:
|
|||
};
|
||||
|
||||
struct BlockMarginState {
|
||||
Vector<CSSPixels> current_collapsible_margins;
|
||||
CSSPixels current_positive_collapsible_margin;
|
||||
CSSPixels current_negative_collapsible_margin;
|
||||
Function<void(CSSPixels)> block_container_y_position_update_callback;
|
||||
bool box_last_in_flow_child_margin_bottom_collapsed { false };
|
||||
|
||||
void add_margin(CSSPixels margin)
|
||||
{
|
||||
current_collapsible_margins.append(margin);
|
||||
if (margin < 0) {
|
||||
current_negative_collapsible_margin = min(margin, current_negative_collapsible_margin);
|
||||
} else {
|
||||
current_positive_collapsible_margin = max(margin, current_positive_collapsible_margin);
|
||||
}
|
||||
}
|
||||
|
||||
void register_block_container_y_position_update_callback(ESCAPING Function<void(CSSPixels)> callback)
|
||||
|
@ -158,7 +163,8 @@ private:
|
|||
void reset()
|
||||
{
|
||||
block_container_y_position_update_callback = {};
|
||||
current_collapsible_margins.clear();
|
||||
current_negative_collapsible_margin = 0;
|
||||
current_positive_collapsible_margin = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue