mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-18 16:57:29 +03:00
LibWeb: Add basic implementation of has_a_rendering_opportunity()
Return true only if we are ready to repaint. This fixes the issue where requestAnimationFrame() was invoked more than once between repaints.
This commit is contained in:
parent
e800605ad3
commit
e3e6af39bc
Notes:
sideshowbarker
2024-07-16 23:54:15 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/e3e6af39bc Pull-request: https://github.com/SerenityOS/serenity/pull/23629
@ -2073,8 +2073,11 @@ bool Navigable::has_a_rendering_opportunity() const
|
||||
// or whether the document's visibility state is "visible".
|
||||
// Rendering opportunities typically occur at regular intervals.
|
||||
|
||||
// FIXME: We should at the very least say `false` here if we're an inactive browser tab.
|
||||
return true;
|
||||
// FIXME: Return `false` here if we're an inactive browser tab.
|
||||
auto browsing_context = const_cast<Navigable*>(this)->active_browsing_context();
|
||||
if (!browsing_context)
|
||||
return false;
|
||||
return browsing_context->page().client().is_ready_to_paint();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#inform-the-navigation-api-about-aborting-navigation
|
||||
|
@ -307,6 +307,7 @@ public:
|
||||
virtual void inspector_did_execute_console_script([[maybe_unused]] String const& script) { }
|
||||
|
||||
virtual void schedule_repaint() = 0;
|
||||
virtual bool is_ready_to_paint() const = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PageClient() = default;
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
virtual void request_file(FileRequest) override { }
|
||||
virtual void paint(DevicePixelRect const&, Gfx::Bitmap&, Web::PaintOptions = {}) override { }
|
||||
virtual void schedule_repaint() override { }
|
||||
virtual bool is_ready_to_paint() const override { return true; }
|
||||
|
||||
private:
|
||||
explicit SVGPageClient(Page& host_page)
|
||||
|
@ -96,6 +96,11 @@ void PageClient::schedule_repaint()
|
||||
m_repaint_timer->start();
|
||||
}
|
||||
|
||||
bool PageClient::is_ready_to_paint() const
|
||||
{
|
||||
return m_paint_state == PaintState::Ready;
|
||||
}
|
||||
|
||||
void PageClient::ready_to_paint()
|
||||
{
|
||||
auto old_paint_state = exchange(m_paint_state, PaintState::Ready);
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
static void set_use_gpu_painter();
|
||||
|
||||
virtual void schedule_repaint() override;
|
||||
virtual bool is_ready_to_paint() const override;
|
||||
|
||||
virtual Web::Page& page() override { return *m_page; }
|
||||
virtual Web::Page const& page() const override { return *m_page; }
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
virtual void paint(Web::DevicePixelRect const&, Gfx::Bitmap&, Web::PaintOptions = {}) override;
|
||||
virtual void request_file(Web::FileRequest) override;
|
||||
virtual void schedule_repaint() override {};
|
||||
virtual bool is_ready_to_paint() const override { return true; }
|
||||
|
||||
private:
|
||||
explicit PageHost(ConnectionFromClient&);
|
||||
|
Loading…
Reference in New Issue
Block a user