mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibWeb: Rework the layout engine to use relative offsets
The box tree and line boxes now all store a relative offset from their containing block, instead of an absolute (document-relative) position. This removes a huge pain point from the layout system which was having to adjust offsets recursively when something moved. It also makes some layout logic significantly simpler. Every box can still find its absolute position by walking its chain of containing blocks and accumulating the translation from the root. This is currently what we do both for rendering and hit testing.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibWeb/Layout/LineBoxFragment.h>
|
||||
|
||||
@@ -33,19 +34,20 @@ namespace Web {
|
||||
|
||||
class LineBox {
|
||||
public:
|
||||
LineBox() {}
|
||||
LineBox() { }
|
||||
|
||||
float width() const { return m_width; }
|
||||
|
||||
void add_fragment(const LayoutNode& layout_node, int start, int length, int width, int height);
|
||||
|
||||
const Vector<LineBoxFragment>& fragments() const { return m_fragments; }
|
||||
Vector<LineBoxFragment>& fragments() { return m_fragments; }
|
||||
const NonnullOwnPtrVector<LineBoxFragment>& fragments() const { return m_fragments; }
|
||||
NonnullOwnPtrVector<LineBoxFragment>& fragments() { return m_fragments; }
|
||||
|
||||
void trim_trailing_whitespace();
|
||||
|
||||
private:
|
||||
friend class LayoutBlock;
|
||||
Vector<LineBoxFragment> m_fragments;
|
||||
NonnullOwnPtrVector<LineBoxFragment> m_fragments;
|
||||
float m_width { 0 };
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user