mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:17:34 +00:00
LibWeb: Use coordinate instead of WeakPtr for box->fragment connection
Using WeakPtr to remember which LineBoxFragment owns which Box was imposing some annoying constraints on the layout code. Importantly, it was forcing us to heap-allocate fragments, which makes it much harder to clone a FormattingState. This patch replaces the WeakPtr with a coordinate system instead. Fragments are referred to by their line box index + fragment index within the line box.
This commit is contained in:
parent
726edd2d3b
commit
16a47165ee
5 changed files with 21 additions and 14 deletions
|
@ -82,7 +82,11 @@ public:
|
|||
|
||||
bool is_body() const;
|
||||
|
||||
void set_containing_line_box_fragment(LineBoxFragment&);
|
||||
struct LineBoxFragmentCoordinate {
|
||||
size_t line_box_index { 0 };
|
||||
size_t fragment_index { 0 };
|
||||
};
|
||||
void set_containing_line_box_fragment(LineBoxFragmentCoordinate);
|
||||
|
||||
StackingContext* stacking_context() { return m_stacking_context; }
|
||||
const StackingContext* stacking_context() const { return m_stacking_context; }
|
||||
|
@ -138,7 +142,7 @@ private:
|
|||
Gfx::FloatSize m_content_size;
|
||||
|
||||
// Some boxes hang off of line box fragments. (inline-block, inline-table, replaced, etc)
|
||||
WeakPtr<LineBoxFragment> m_containing_line_box_fragment;
|
||||
Optional<LineBoxFragmentCoordinate> m_containing_line_box_fragment;
|
||||
|
||||
OwnPtr<StackingContext> m_stacking_context;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue