1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:47:35 +00:00

LibWeb: Improve placement of abspos boxes with dual-auto insets

When an absolutely positioned box has auto insets on both sides of an
axis, it's placed according to the "static position rectangle". This is,
roughly, the rectangle a box would occupy if it were position:static
instead of position:absolute or position:fixed.

This patch implements a rough, but still significantly better,
estimation of such static positions. It gets pretty hairy in the case
where an abspos box has a parent whose children are inline.
This commit is contained in:
Andreas Kling 2022-10-01 13:48:28 +02:00
parent 74840c5537
commit de6d012367
3 changed files with 71 additions and 17 deletions

View file

@ -70,7 +70,7 @@ public:
void run_intrinsic_sizing(Box const&);
float compute_box_y_position_with_respect_to_siblings(Box const&, LayoutState::UsedValues const&);
float compute_box_y_position_with_respect_to_siblings(Box const&) const;
float calculate_stretch_fit_width(Box const&, AvailableSize const&) const;
@ -78,6 +78,8 @@ public:
virtual void determine_width_of_child(Box const&, AvailableSpace const&) { }
virtual void determine_height_of_child(Box const&, AvailableSpace const&) { }
virtual Gfx::FloatPoint calculate_static_position(Box const&) const;
protected:
FormattingContext(Type, LayoutState&, Box const&, FormattingContext* parent = nullptr);