mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 07:07:34 +00:00
LibWeb: Store overflow data in the FormattingState
This commit is contained in:
parent
92266d2247
commit
2615728d6b
4 changed files with 15 additions and 14 deletions
|
@ -528,6 +528,7 @@ void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_m
|
||||||
auto viewport_rect = root().browsing_context().viewport_rect();
|
auto viewport_rect = root().browsing_context().viewport_rect();
|
||||||
|
|
||||||
auto& icb = verify_cast<Layout::InitialContainingBlock>(root());
|
auto& icb = verify_cast<Layout::InitialContainingBlock>(root());
|
||||||
|
auto& icb_state = m_state.ensure(icb);
|
||||||
|
|
||||||
VERIFY(!icb.children_are_inline());
|
VERIFY(!icb.children_are_inline());
|
||||||
layout_block_level_children(root(), layout_mode);
|
layout_block_level_children(root(), layout_mode);
|
||||||
|
@ -546,13 +547,10 @@ void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_m
|
||||||
|
|
||||||
if (bottom_edge >= viewport_rect.height() || right_edge >= viewport_rect.width()) {
|
if (bottom_edge >= viewport_rect.height() || right_edge >= viewport_rect.width()) {
|
||||||
// FIXME: Move overflow data to FormattingState!
|
// FIXME: Move overflow data to FormattingState!
|
||||||
auto& overflow_data = const_cast<InitialContainingBlock&>(icb).ensure_overflow_data();
|
auto& overflow_data = icb_state.ensure_overflow_data();
|
||||||
overflow_data.scrollable_overflow_rect = viewport_rect.to_type<float>();
|
overflow_data.scrollable_overflow_rect = viewport_rect.to_type<float>();
|
||||||
// NOTE: The edges are *within* the rectangle, so we add 1 to get the width and height.
|
// NOTE: The edges are *within* the rectangle, so we add 1 to get the width and height.
|
||||||
overflow_data.scrollable_overflow_rect.set_size(right_edge + 1, bottom_edge + 1);
|
overflow_data.scrollable_overflow_rect.set_size(right_edge + 1, bottom_edge + 1);
|
||||||
} else {
|
|
||||||
// FIXME: Move overflow data to FormattingState!
|
|
||||||
const_cast<InitialContainingBlock&>(icb).clear_overflow_data();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,14 +113,7 @@ public:
|
||||||
return m_overflow_data->scrollable_overflow_rect;
|
return m_overflow_data->scrollable_overflow_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
OverflowData& ensure_overflow_data()
|
void set_overflow_data(OwnPtr<OverflowData> data) { m_overflow_data = move(data); }
|
||||||
{
|
|
||||||
if (!m_overflow_data)
|
|
||||||
m_overflow_data = make<OverflowData>();
|
|
||||||
return *m_overflow_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_overflow_data() { m_overflow_data = nullptr; }
|
|
||||||
|
|
||||||
virtual void before_children_paint(PaintContext&, PaintPhase) override;
|
virtual void before_children_paint(PaintContext&, PaintPhase) override;
|
||||||
virtual void after_children_paint(PaintContext&, PaintPhase) override;
|
virtual void after_children_paint(PaintContext&, PaintPhase) override;
|
||||||
|
|
|
@ -21,11 +21,12 @@ void FormattingState::commit()
|
||||||
node.box_model().border = { node_state.border_top, node_state.border_right, node_state.border_bottom, node_state.border_left };
|
node.box_model().border = { node_state.border_top, node_state.border_right, node_state.border_bottom, node_state.border_left };
|
||||||
node.box_model().margin = { node_state.margin_top, node_state.margin_right, node_state.margin_bottom, node_state.margin_left };
|
node.box_model().margin = { node_state.margin_top, node_state.margin_right, node_state.margin_bottom, node_state.margin_left };
|
||||||
|
|
||||||
// For boxes, transfer relative offset and size.
|
// For boxes, transfer relative offset, size, and overflow data.
|
||||||
if (is<Layout::Box>(node)) {
|
if (is<Layout::Box>(node)) {
|
||||||
auto& box = static_cast<Layout::Box&>(node);
|
auto& box = static_cast<Layout::Box&>(node);
|
||||||
box.set_offset(node_state.offset);
|
box.set_offset(node_state.offset);
|
||||||
box.set_content_size(node_state.content_width, node_state.content_height);
|
box.set_content_size(node_state.content_width, node_state.content_height);
|
||||||
|
box.set_overflow_data(move(node_state.overflow_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For block containers, transfer line boxes.
|
// For block containers, transfer line boxes.
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
#include <AK/HashMap.h>
|
#include <AK/HashMap.h>
|
||||||
#include <LibGfx/Point.h>
|
#include <LibGfx/Point.h>
|
||||||
|
#include <LibWeb/Layout/Box.h>
|
||||||
#include <LibWeb/Layout/LineBox.h>
|
#include <LibWeb/Layout/LineBox.h>
|
||||||
#include <LibWeb/Layout/Node.h>
|
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
@ -53,6 +53,15 @@ struct FormattingState {
|
||||||
|
|
||||||
float border_box_width() const { return border_box_left() + content_width + border_box_right(); }
|
float border_box_width() const { return border_box_left() + content_width + border_box_right(); }
|
||||||
float border_box_height() const { return border_box_top() + content_height + border_box_bottom(); }
|
float border_box_height() const { return border_box_top() + content_height + border_box_bottom(); }
|
||||||
|
|
||||||
|
OwnPtr<Layout::Box::OverflowData> overflow_data;
|
||||||
|
|
||||||
|
Layout::Box::OverflowData& ensure_overflow_data()
|
||||||
|
{
|
||||||
|
if (!overflow_data)
|
||||||
|
overflow_data = make<Layout::Box::OverflowData>();
|
||||||
|
return *overflow_data;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void commit();
|
void commit();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue