mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
LibWeb: Add Painting::Box and move things from Layout::Box into it
The "paintable" state in Layout::Box was actually not safe to access until after layout had been performed. As a first step towards making this harder to mess up accidentally, this patch moves painting information from Layout::Box to a new class: Painting::Box. Every layout can have a corresponding paint box, and it holds the final used metrics determined by layout. The paint box is created and populated by FormattingState::commit(). I've also added DOM::Node::paint_box() as a convenient way to access the paint box (if available) of a given DOM node. Going forward, I believe this will allow us to better separate data that belongs to layout vs painting, and also open up opportunities for naturally invalidating caches in the paint box (since it's reconstituted by every layout.)
This commit is contained in:
parent
db404af6df
commit
a4d51b3dc2
35 changed files with 365 additions and 293 deletions
|
@ -27,22 +27,10 @@ public:
|
|||
BlockContainer* next_sibling() { return verify_cast<BlockContainer>(Node::next_sibling()); }
|
||||
const BlockContainer* next_sibling() const { return verify_cast<BlockContainer>(Node::next_sibling()); }
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_fragment(Callback);
|
||||
template<typename Callback>
|
||||
void for_each_fragment(Callback) const;
|
||||
|
||||
bool is_scrollable() const;
|
||||
const Gfx::FloatPoint& scroll_offset() const { return m_scroll_offset; }
|
||||
void set_scroll_offset(const Gfx::FloatPoint&);
|
||||
|
||||
const Vector<LineBox>& line_boxes() const { return m_line_boxes; }
|
||||
|
||||
void set_line_boxes(Vector<LineBox>&& line_boxes) { m_line_boxes = move(line_boxes); }
|
||||
|
||||
protected:
|
||||
Vector<LineBox> m_line_boxes;
|
||||
|
||||
private:
|
||||
virtual bool is_block_container() const final { return true; }
|
||||
virtual bool wants_mouse_events() const override { return false; }
|
||||
|
@ -56,26 +44,4 @@ private:
|
|||
template<>
|
||||
inline bool Node::fast_is<BlockContainer>() const { return is_block_container(); }
|
||||
|
||||
template<typename Callback>
|
||||
void BlockContainer::for_each_fragment(Callback callback)
|
||||
{
|
||||
for (auto& line_box : line_boxes()) {
|
||||
for (auto& fragment : line_box.fragments()) {
|
||||
if (callback(fragment) == IterationDecision::Break)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
void BlockContainer::for_each_fragment(Callback callback) const
|
||||
{
|
||||
for (auto& line_box : line_boxes()) {
|
||||
for (auto& fragment : line_box.fragments()) {
|
||||
if (callback(fragment) == IterationDecision::Break)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue