mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Add LayoutNode::frame() reference getter
Any live layout tree always has a corresponding live Frame, as we will never create a layout tree for a frameless document.
This commit is contained in:
parent
a93fb7299f
commit
62615dfc31
Notes:
sideshowbarker
2024-07-19 05:39:06 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/62615dfc31f
5 changed files with 19 additions and 11 deletions
|
@ -260,11 +260,8 @@ HitTestResult LayoutBox::hit_test(const Gfx::IntPoint& position) const
|
|||
|
||||
void LayoutBox::set_needs_display()
|
||||
{
|
||||
auto* frame = document().frame();
|
||||
ASSERT(frame);
|
||||
|
||||
if (!is_inline()) {
|
||||
const_cast<Frame*>(frame)->set_needs_display(enclosing_int_rect(absolute_rect()));
|
||||
frame().set_needs_display(enclosing_int_rect(absolute_rect()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,7 @@ LayoutDocument::~LayoutDocument()
|
|||
|
||||
void LayoutDocument::layout(LayoutMode layout_mode)
|
||||
{
|
||||
ASSERT(document().frame());
|
||||
set_width(document().frame()->size().width());
|
||||
set_width(frame().size().width());
|
||||
|
||||
LayoutNode::layout(layout_mode);
|
||||
|
||||
|
|
|
@ -111,6 +111,18 @@ HitTestResult LayoutNode::hit_test(const Gfx::IntPoint& position) const
|
|||
return result;
|
||||
}
|
||||
|
||||
const Frame& LayoutNode::frame() const
|
||||
{
|
||||
ASSERT(document().frame());
|
||||
return *document().frame();
|
||||
}
|
||||
|
||||
Frame& LayoutNode::frame()
|
||||
{
|
||||
ASSERT(document().frame());
|
||||
return *document().frame();
|
||||
}
|
||||
|
||||
const Document& LayoutNode::document() const
|
||||
{
|
||||
if (is_anonymous())
|
||||
|
@ -151,13 +163,10 @@ void LayoutNode::split_into_lines(LayoutBlock& container, LayoutMode layout_mode
|
|||
|
||||
void LayoutNode::set_needs_display()
|
||||
{
|
||||
auto* frame = document().frame();
|
||||
ASSERT(frame);
|
||||
|
||||
if (auto* block = containing_block()) {
|
||||
block->for_each_fragment([&](auto& fragment) {
|
||||
if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) {
|
||||
const_cast<Frame*>(frame)->set_needs_display(enclosing_int_rect(fragment.absolute_rect()));
|
||||
frame().set_needs_display(enclosing_int_rect(fragment.absolute_rect()));
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
|
|
@ -103,6 +103,9 @@ public:
|
|||
Document& document();
|
||||
const Document& document() const;
|
||||
|
||||
const Frame& frame() const;
|
||||
Frame& frame();
|
||||
|
||||
const LayoutDocument& root() const;
|
||||
LayoutDocument& root();
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ void LayoutWidget::did_set_rect()
|
|||
void LayoutWidget::update_widget()
|
||||
{
|
||||
auto adjusted_widget_position = absolute_rect().location().to_int_point();
|
||||
auto& page_view = static_cast<const PageView&>(document().frame()->page().client());
|
||||
auto& page_view = static_cast<const PageView&>(frame().page().client());
|
||||
adjusted_widget_position.move_by(-page_view.horizontal_scrollbar().value(), -page_view.vertical_scrollbar().value());
|
||||
widget().move_to(adjusted_widget_position);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue