mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +00:00
LibWeb: Reorganize layout algorithms around available space
This is a big and messy change, and here's the gist: - AvaliableSpace is now 2x AvailableSize (width and height) - Layout algorithms are redesigned around the idea of available space - When doing layout across nested formatting contexts, the parent context tells the child context how much space is available for the child's root box in both axes. - "Available space" replaces "containing block width" in most places. - The width and height in a box's UsedValues are considered to be definite after they're assigned to. Marking something as having definite size is no longer a separate step, This probably introduces various regressions, but the big win here is that our layout system now works with available space, just like the specs are written. Fixing issues will be much easier going forward, since you don't need to do nearly as much conversion from "spec logic" to "LibWeb logic" as you previously did.
This commit is contained in:
parent
b55c4ccdf7
commit
9c44634ca5
19 changed files with 651 additions and 652 deletions
|
@ -23,8 +23,9 @@ public:
|
|||
|
||||
BlockContainer const& containing_block() const { return static_cast<BlockContainer const&>(context_box()); }
|
||||
|
||||
virtual void run(Box const&, LayoutMode, AvailableSpace const& available_width, AvailableSpace const& available_height) override;
|
||||
virtual void run(Box const&, LayoutMode, AvailableSpace const&) override;
|
||||
virtual float automatic_content_height() const override;
|
||||
virtual float automatic_content_width() const override;
|
||||
|
||||
void dimension_box_on_line(Box const&, LayoutMode);
|
||||
|
||||
|
@ -33,14 +34,16 @@ public:
|
|||
bool any_floats_intrude_at_y(float y) const;
|
||||
bool can_fit_new_line_at_y(float y) const;
|
||||
|
||||
float effective_containing_block_width() const { return m_effective_containing_block_width; }
|
||||
|
||||
private:
|
||||
void generate_line_boxes(LayoutMode);
|
||||
void apply_justification_to_fragments(CSS::TextJustify, LineBox&, bool is_last_line);
|
||||
|
||||
LayoutState::UsedValues const& m_containing_block_state;
|
||||
float m_effective_containing_block_width { 0 };
|
||||
|
||||
Optional<AvailableSpace> m_available_space;
|
||||
|
||||
float m_automatic_content_width { 0 };
|
||||
float m_automatic_content_height { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue