mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:57:35 +00:00
LibWeb: Let subframes propagate paint invalidations via host element
When a paint invalidation occurs inside a subframe, it bubbles up to Frame::set_needs_display(). From there, we call PageView if this is the main frame, or otherwise invalidate the subframe host element.
This commit is contained in:
parent
59f9b32a44
commit
3ae3729b4e
5 changed files with 30 additions and 17 deletions
|
@ -79,11 +79,6 @@ void HTMLIFrameElement::load_src(const String& value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hosted_frame->on_set_needs_display = [this](auto&) {
|
|
||||||
if (layout_node())
|
|
||||||
layout_node()->set_needs_display();
|
|
||||||
};
|
|
||||||
|
|
||||||
m_hosted_frame->loader().load(url);
|
m_hosted_frame->loader().load(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,9 +93,14 @@ void Frame::set_needs_display(const Gfx::Rect& rect)
|
||||||
if (!m_viewport_rect.intersects(rect))
|
if (!m_viewport_rect.intersects(rect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!on_set_needs_display)
|
if (is_main_frame()) {
|
||||||
|
if (page_view())
|
||||||
|
page_view()->notify_needs_display({}, *this, rect);
|
||||||
return;
|
return;
|
||||||
on_set_needs_display(rect);
|
}
|
||||||
|
|
||||||
|
if (host_element() && host_element()->layout_node())
|
||||||
|
host_element()->layout_node()->set_needs_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::did_scroll(Badge<PageView>)
|
void Frame::did_scroll(Badge<PageView>)
|
||||||
|
|
|
@ -60,7 +60,6 @@ public:
|
||||||
|
|
||||||
void set_needs_display(const Gfx::Rect&);
|
void set_needs_display(const Gfx::Rect&);
|
||||||
|
|
||||||
Function<void(const Gfx::Rect&)> on_set_needs_display;
|
|
||||||
Function<void(const String&)> on_title_change;
|
Function<void(const String&)> on_title_change;
|
||||||
Function<void(const URL&)> on_load_start;
|
Function<void(const URL&)> on_load_start;
|
||||||
Function<void(const Gfx::Bitmap&)> on_favicon_change;
|
Function<void(const Gfx::Bitmap&)> on_favicon_change;
|
||||||
|
|
|
@ -72,15 +72,6 @@ PageView::PageView()
|
||||||
if (on_load_start)
|
if (on_load_start)
|
||||||
on_load_start(url);
|
on_load_start(url);
|
||||||
};
|
};
|
||||||
main_frame().on_set_needs_display = [this](auto& content_rect) {
|
|
||||||
if (content_rect.is_empty()) {
|
|
||||||
update();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Gfx::Rect adjusted_rect = content_rect;
|
|
||||||
adjusted_rect.set_location(to_widget_position(content_rect.location()));
|
|
||||||
update(adjusted_rect);
|
|
||||||
};
|
|
||||||
|
|
||||||
set_should_hide_unnecessary_scrollbars(true);
|
set_should_hide_unnecessary_scrollbars(true);
|
||||||
set_background_role(ColorRole::Base);
|
set_background_role(ColorRole::Base);
|
||||||
|
@ -334,6 +325,22 @@ Gfx::Point PageView::to_screen_position(const Web::Frame& frame, const Gfx::Poin
|
||||||
return screen_relative_rect().location().translated(offset).translated(frame_position);
|
return screen_relative_rect().location().translated(offset).translated(frame_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Gfx::Rect PageView::to_widget_rect(const Web::Frame& frame, const Gfx::Rect& frame_rect) const
|
||||||
|
{
|
||||||
|
Gfx::Point offset;
|
||||||
|
for (auto* f = &frame; f; f = f->parent()) {
|
||||||
|
if (!f->host_element())
|
||||||
|
return {};
|
||||||
|
if (!f->host_element()->layout_node())
|
||||||
|
return {};
|
||||||
|
auto f_position = f->host_element()->layout_node()->box_type_agnostic_position().to_int_point();
|
||||||
|
offset.move_by(f_position);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto content_position = frame_rect.location().translated(offset);
|
||||||
|
return { to_widget_position(content_position), frame_rect.size() };
|
||||||
|
}
|
||||||
|
|
||||||
void PageView::notify_link_context_menu_request(Badge<EventHandler>, Web::Frame& frame, const Gfx::Point& content_position, const String& href, const String&, unsigned)
|
void PageView::notify_link_context_menu_request(Badge<EventHandler>, Web::Frame& frame, const Gfx::Point& content_position, const String& href, const String&, unsigned)
|
||||||
{
|
{
|
||||||
if (on_link_context_menu_request)
|
if (on_link_context_menu_request)
|
||||||
|
@ -356,4 +363,9 @@ void PageView::notify_tooltip_area_leave(Badge<EventHandler>, Web::Frame&)
|
||||||
GUI::Application::the().hide_tooltip();
|
GUI::Application::the().hide_tooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PageView::notify_needs_display(Badge<Web::Frame>, Web::Frame& frame, const Gfx::Rect& rect)
|
||||||
|
{
|
||||||
|
update(to_widget_rect(frame, rect));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ public:
|
||||||
void notify_link_hover(Badge<EventHandler>, Web::Frame&, const String& href);
|
void notify_link_hover(Badge<EventHandler>, Web::Frame&, const String& href);
|
||||||
void notify_tooltip_area_enter(Badge<EventHandler>, Web::Frame&, const Gfx::Point& content_position, const String& title);
|
void notify_tooltip_area_enter(Badge<EventHandler>, Web::Frame&, const Gfx::Point& content_position, const String& title);
|
||||||
void notify_tooltip_area_leave(Badge<EventHandler>, Web::Frame&);
|
void notify_tooltip_area_leave(Badge<EventHandler>, Web::Frame&);
|
||||||
|
void notify_needs_display(Badge<Web::Frame>, Web::Frame&, const Gfx::Rect&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PageView();
|
PageView();
|
||||||
|
@ -97,6 +98,7 @@ private:
|
||||||
virtual void did_scroll() override;
|
virtual void did_scroll() override;
|
||||||
|
|
||||||
Gfx::Point to_screen_position(const Web::Frame&, const Gfx::Point&) const;
|
Gfx::Point to_screen_position(const Web::Frame&, const Gfx::Point&) const;
|
||||||
|
Gfx::Rect to_widget_rect(const Web::Frame&, const Gfx::Rect&) const;
|
||||||
|
|
||||||
void layout_and_sync_size();
|
void layout_and_sync_size();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue