mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:27:34 +00:00
LibWeb: Move set_needs_display() from layout node to paintable
For this method, there is no need to go through the layout node when we can directly reach the paintable.
This commit is contained in:
parent
814bed33b4
commit
7c2713c14f
21 changed files with 97 additions and 87 deletions
|
@ -73,6 +73,11 @@ HTML::BrowsingContext& Paintable::browsing_context()
|
|||
return m_browsing_context;
|
||||
}
|
||||
|
||||
JS::GCPtr<HTML::Navigable> Paintable::navigable() const
|
||||
{
|
||||
return document().navigable();
|
||||
}
|
||||
|
||||
Paintable::DispatchEventOfSameName Paintable::handle_mousedown(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned)
|
||||
{
|
||||
return DispatchEventOfSameName::Yes;
|
||||
|
@ -118,6 +123,31 @@ void Paintable::invalidate_stacking_context()
|
|||
m_stacking_context = nullptr;
|
||||
}
|
||||
|
||||
void Paintable::set_needs_display() const
|
||||
{
|
||||
auto* containing_block = this->containing_block();
|
||||
if (!containing_block)
|
||||
return;
|
||||
if (!containing_block->paintable_box())
|
||||
return;
|
||||
auto navigable = this->navigable();
|
||||
if (!navigable)
|
||||
return;
|
||||
|
||||
if (is<Painting::InlinePaintable>(*this)) {
|
||||
auto const& fragments = static_cast<Painting::InlinePaintable const*>(this)->fragments();
|
||||
for (auto const& fragment : fragments)
|
||||
navigable->set_needs_display(fragment.absolute_rect());
|
||||
}
|
||||
|
||||
if (!is<Painting::PaintableWithLines>(*containing_block->paintable_box()))
|
||||
return;
|
||||
static_cast<Painting::PaintableWithLines const&>(*containing_block->paintable_box()).for_each_fragment([&](auto& fragment) {
|
||||
navigable->set_needs_display(fragment.absolute_rect());
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
||||
PaintableBox const* Paintable::nearest_scrollable_ancestor_within_stacking_context() const
|
||||
{
|
||||
auto* ancestor = parent();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue