LibWeb: Schedule repainting from EventLoop::process()

In this change, updating layout and painting are moved to the EventLoop
processing steps. This modification allows the addition of resize
observation dispatching that needs to happen in event loop processing
steps and must occur in the following order relative to layout and
painting:

1. Update layout.
2. Gather and broadcast resize observations.
3. Paint.
This commit is contained in:
Aliaksandr Kalenik 2024-02-18 19:40:11 +01:00 committed by Andreas Kling
parent fb8edcea00
commit 8ba18dfd40
Notes: sideshowbarker 2024-07-16 23:57:20 +09:00
6 changed files with 14 additions and 4 deletions

View file

@ -15,6 +15,7 @@
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HighResolutionTime/Performance.h>
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
#include <LibWeb/Page/Page.h>
#include <LibWeb/Platform/EventLoopPlugin.h>
#include <LibWeb/Platform/Timer.h>
@ -213,7 +214,12 @@ void EventLoop::process()
// FIXME: 15. Invoke the mark paint timing algorithm for each Document object in docs.
// FIXME: 16. For each fully active Document in docs, update the rendering or user interface of that Document and its browsing context to reflect the current state.
// 16. For each fully active Document in docs, update the rendering or user interface of that Document and its browsing context to reflect the current state.
for_each_fully_active_document_in_docs([&](DOM::Document& document) {
auto* browsing_context = document.browsing_context();
auto& page = browsing_context->page();
page.client().schedule_repaint();
});
// 13. If all of the following are true
// - this is a window event loop

View file

@ -302,6 +302,8 @@ public:
virtual void inspector_did_request_dom_tree_context_menu([[maybe_unused]] i32 node_id, [[maybe_unused]] CSSPixelPoint position, [[maybe_unused]] String const& type, [[maybe_unused]] Optional<String> const& tag, [[maybe_unused]] Optional<String> const& attribute_name, [[maybe_unused]] Optional<String> const& attribute_value) { }
virtual void inspector_did_execute_console_script([[maybe_unused]] String const& script) { }
virtual void schedule_repaint() = 0;
protected:
virtual ~PageClient() = default;
};

View file

@ -48,6 +48,7 @@ public:
virtual CSS::PreferredColorScheme preferred_color_scheme() const override { return m_host_page.client().preferred_color_scheme(); }
virtual void request_file(FileRequest) override { }
virtual void paint(DevicePixelRect const&, Gfx::Bitmap&, Web::PaintOptions = {}) override { }
virtual void schedule_repaint() override { }
private:
explicit SVGPageClient(Page& host_page)

View file

@ -222,12 +222,12 @@ void PageClient::paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap& ta
void PageClient::set_viewport_rect(Web::DevicePixelRect const& rect)
{
page().top_level_traversable()->set_viewport_rect(page().device_to_css_rect(rect));
schedule_repaint();
Web::HTML::main_thread_event_loop().schedule();
}
void PageClient::page_did_invalidate(Web::CSSPixelRect const&)
{
schedule_repaint();
Web::HTML::main_thread_event_loop().schedule();
}
void PageClient::page_did_request_cursor_change(Gfx::StandardCursor cursor)

View file

@ -28,7 +28,7 @@ public:
static void set_use_gpu_painter();
void schedule_repaint();
virtual void schedule_repaint() override;
virtual Web::Page& page() override { return *m_page; }
virtual Web::Page const& page() const override { return *m_page; }

View file

@ -30,6 +30,7 @@ public:
virtual Web::CSS::PreferredColorScheme preferred_color_scheme() const override;
virtual void paint(Web::DevicePixelRect const&, Gfx::Bitmap&, Web::PaintOptions = {}) override;
virtual void request_file(Web::FileRequest) override;
virtual void schedule_repaint() override {};
private:
explicit PageHost(ConnectionFromClient&);