소스 검색

LibWeb+LibWebView+WebContent: Add an IPC call for Navigable::reload()

Aliaksandr Kalenik 1 년 전
부모
커밋
bfef08177e

+ 5 - 0
Userland/Libraries/LibWeb/Page/Page.cpp

@@ -74,6 +74,11 @@ void Page::load_html(StringView html)
         .user_involvement = HTML::UserNavigationInvolvement::BrowserUI });
 }
 
+void Page::reload()
+{
+    top_level_traversable()->reload();
+}
+
 Gfx::Palette Page::palette() const
 {
     return m_client->palette();

+ 2 - 0
Userland/Libraries/LibWeb/Page/Page.h

@@ -76,6 +76,8 @@ public:
 
     void load_html(StringView);
 
+    void reload();
+
     CSSPixelPoint device_to_css_point(DevicePixelPoint) const;
     DevicePixelPoint css_to_device_point(CSSPixelPoint) const;
     DevicePixelRect css_to_device_rect(CSSPixelRect) const;

+ 5 - 0
Userland/Libraries/LibWebView/ViewImplementation.cpp

@@ -90,6 +90,11 @@ void ViewImplementation::load_empty_document()
     load_html(""sv);
 }
 
+void ViewImplementation::reload()
+{
+    client().async_reload(page_id());
+}
+
 void ViewImplementation::zoom_in()
 {
     if (m_zoom_level >= ZOOM_MAX_LEVEL)

+ 1 - 0
Userland/Libraries/LibWebView/ViewImplementation.h

@@ -49,6 +49,7 @@ public:
     void load(URL::URL const&);
     void load_html(StringView);
     void load_empty_document();
+    void reload();
 
     void zoom_in();
     void zoom_out();

+ 6 - 0
Userland/Services/WebContent/ConnectionFromClient.cpp

@@ -156,6 +156,12 @@ void ConnectionFromClient::load_html(u64 page_id, ByteString const& html)
         page->page().load_html(html);
 }
 
+void ConnectionFromClient::reload(u64 page_id)
+{
+    if (auto page = this->page(page_id); page.has_value())
+        page->page().reload();
+}
+
 void ConnectionFromClient::set_viewport_rect(u64 page_id, Web::DevicePixelRect const& rect)
 {
     if (auto page = this->page(page_id); page.has_value())

+ 1 - 0
Userland/Services/WebContent/ConnectionFromClient.h

@@ -57,6 +57,7 @@ private:
     virtual void update_screen_rects(u64 page_id, Vector<Web::DevicePixelRect> const&, u32) override;
     virtual void load_url(u64 page_id, URL::URL const&) override;
     virtual void load_html(u64 page_id, ByteString const&) override;
+    virtual void reload(u64 page_id) override;
     virtual void set_viewport_rect(u64 page_id, Web::DevicePixelRect const&) override;
     virtual void key_event(u64 page_id, Web::KeyEvent const&) override;
     virtual void mouse_event(u64 page_id, Web::MouseEvent const&) override;

+ 1 - 0
Userland/Services/WebContent/WebContentServer.ipc

@@ -24,6 +24,7 @@ endpoint WebContentServer
 
     load_url(u64 page_id, URL::URL url) =|
     load_html(u64 page_id, ByteString html) =|
+    reload(u64 page_id) =|
 
     add_backing_store(u64 page_id, i32 front_bitmap_id, Gfx::ShareableBitmap front_bitmap, i32 back_bitmap_id, Gfx::ShareableBitmap back_bitmap) =|
     ready_to_paint(u64 page_id) =|