Explorar el Código

LibWebView+UI: Handle worker agent requests from within LibWebView

There is no longer any UI-specific facilities needed to launch a worker
agent.
Timothy Flynn hace 8 meses
padre
commit
44d6601dc5

+ 0 - 1
Libraries/LibWebView/ViewImplementation.h

@@ -230,7 +230,6 @@ public:
     Function<void(size_t, Gfx::IntPoint)> on_inspector_requested_cookie_context_menu;
     Function<void(String const&)> on_inspector_executed_console_script;
     Function<void(String const&)> on_inspector_exported_inspector_html;
-    Function<IPC::File()> on_request_worker_agent;
 
     virtual Web::DevicePixelSize viewport_size() const = 0;
     virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const = 0;

+ 3 - 2
Libraries/LibWebView/WebContentClient.cpp

@@ -9,6 +9,7 @@
 #include "ViewImplementation.h"
 #include <LibWeb/Cookie/ParsedCookie.h>
 #include <LibWebView/CookieJar.h>
+#include <LibWebView/HelperProcess.h>
 
 namespace WebView {
 
@@ -667,8 +668,8 @@ void WebContentClient::inspector_did_export_inspector_html(u64 page_id, String c
 Messages::WebContentClient::RequestWorkerAgentResponse WebContentClient::request_worker_agent(u64 page_id)
 {
     if (auto view = view_for_page_id(page_id); view.has_value()) {
-        if (view->on_request_worker_agent)
-            return view->on_request_worker_agent();
+        auto worker_client = MUST(WebView::launch_web_worker_process());
+        return worker_client->clone_transport();
     }
 
     return IPC::File {};

+ 0 - 6
UI/AppKit/Interface/LadybirdWebView.mm

@@ -12,7 +12,6 @@
 #include <LibURL/URL.h>
 #include <LibWeb/HTML/SelectedFile.h>
 #include <LibWebView/Application.h>
-#include <LibWebView/HelperProcess.h>
 #include <LibWebView/SearchEngine.h>
 #include <LibWebView/SourceHighlighter.h>
 #include <LibWebView/URL.h>
@@ -345,11 +344,6 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
         return [self.observer onCreateNewTab:{} activateTab:activate_tab];
     };
 
-    m_web_view_bridge->on_request_worker_agent = []() {
-        auto worker_client = MUST(WebView::launch_web_worker_process());
-        return worker_client->clone_transport();
-    };
-
     m_web_view_bridge->on_activate_tab = [weak_self]() {
         LadybirdWebView* self = weak_self;
         if (self == nil) {

+ 0 - 5
UI/Headless/HeadlessWebView.cpp

@@ -30,11 +30,6 @@ HeadlessWebView::HeadlessWebView(Core::AnonymousBuffer theme, Web::DevicePixelSi
         return web_view.handle();
     };
 
-    on_request_worker_agent = []() {
-        auto worker_client = MUST(WebView::launch_web_worker_process());
-        return worker_client->clone_transport();
-    };
-
     on_reposition_window = [this](auto position) {
         client().async_set_window_position(m_client_state.page_index, position.template to_type<Web::DevicePixels>());
 

+ 0 - 5
UI/Qt/WebContentView.cpp

@@ -126,11 +126,6 @@ WebContentView::WebContentView(QWidget* window, RefPtr<WebView::WebContentClient
         finish_handling_drag_event(event);
     };
 
-    on_request_worker_agent = [&]() {
-        auto worker_client = MUST(WebView::launch_web_worker_process());
-        return worker_client->clone_transport();
-    };
-
     m_select_dropdown = new QMenu("Select Dropdown", this);
     QObject::connect(m_select_dropdown, &QMenu::aboutToHide, this, [this]() {
         if (!m_select_dropdown->activeAction())