OutOfProcessWebView.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/Queue.h>
  9. #include <AK/URL.h>
  10. #include <LibGUI/AbstractScrollableWidget.h>
  11. #include <LibGUI/Widget.h>
  12. #include <LibWeb/CSS/Selector.h>
  13. #include <LibWeb/HTML/ActivateTab.h>
  14. #include <LibWeb/Page/Page.h>
  15. #include <LibWebView/ViewImplementation.h>
  16. namespace Messages::WebContentServer {
  17. class WebdriverExecuteScriptResponse;
  18. }
  19. namespace WebView {
  20. class WebContentClient;
  21. class OutOfProcessWebView final
  22. : public GUI::AbstractScrollableWidget
  23. , public ViewImplementation {
  24. C_OBJECT(OutOfProcessWebView);
  25. using Super = GUI::AbstractScrollableWidget;
  26. public:
  27. virtual ~OutOfProcessWebView() override;
  28. DeprecatedString dump_layout_tree();
  29. OrderedHashMap<DeprecatedString, DeprecatedString> get_local_storage_entries();
  30. OrderedHashMap<DeprecatedString, DeprecatedString> get_session_storage_entries();
  31. void set_content_filters(Vector<String>);
  32. void set_autoplay_allowed_on_all_websites();
  33. void set_autoplay_allowlist(Vector<String>);
  34. void set_proxy_mappings(Vector<DeprecatedString> proxies, HashMap<DeprecatedString, size_t> mappings);
  35. void connect_to_webdriver(DeprecatedString const& webdriver_ipc_path);
  36. void set_window_position(Gfx::IntPoint);
  37. void set_window_size(Gfx::IntSize);
  38. void set_system_visibility_state(bool visible);
  39. // This is a hint that tells OOPWV that the content will scale to the viewport size.
  40. // In practice, this means that OOPWV may render scaled stale versions of the content while resizing.
  41. void set_content_scales_to_viewport(bool);
  42. void set_user_style_sheet(String source);
  43. private:
  44. OutOfProcessWebView();
  45. // ^Widget
  46. virtual void paint_event(GUI::PaintEvent&) override;
  47. virtual void resize_event(GUI::ResizeEvent&) override;
  48. virtual void mousedown_event(GUI::MouseEvent&) override;
  49. virtual void mouseup_event(GUI::MouseEvent&) override;
  50. virtual void mousemove_event(GUI::MouseEvent&) override;
  51. virtual void mousewheel_event(GUI::MouseEvent&) override;
  52. virtual void doubleclick_event(GUI::MouseEvent&) override;
  53. virtual void keydown_event(GUI::KeyEvent&) override;
  54. virtual void keyup_event(GUI::KeyEvent&) override;
  55. virtual void theme_change_event(GUI::ThemeChangeEvent&) override;
  56. virtual void screen_rects_change_event(GUI::ScreenRectsChangeEvent&) override;
  57. virtual void focusin_event(GUI::FocusEvent&) override;
  58. virtual void focusout_event(GUI::FocusEvent&) override;
  59. virtual void show_event(GUI::ShowEvent&) override;
  60. virtual void hide_event(GUI::HideEvent&) override;
  61. // ^AbstractScrollableWidget
  62. virtual void did_scroll() override;
  63. // ^WebView::ViewImplementation
  64. virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) override;
  65. virtual void update_zoom() override;
  66. virtual void notify_server_did_layout(Badge<WebContentClient>, Gfx::IntSize content_size) override;
  67. virtual void notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id, Gfx::IntSize) override;
  68. virtual void notify_server_did_invalidate_content_rect(Badge<WebContentClient>, Gfx::IntRect const&) override;
  69. virtual void notify_server_did_change_selection(Badge<WebContentClient>) override;
  70. virtual void notify_server_did_request_cursor_change(Badge<WebContentClient>, Gfx::StandardCursor cursor) override;
  71. virtual void notify_server_did_request_scroll(Badge<WebContentClient>, i32, i32) override;
  72. virtual void notify_server_did_request_scroll_to(Badge<WebContentClient>, Gfx::IntPoint) override;
  73. virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) override;
  74. virtual void notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint, DeprecatedString const&) override;
  75. virtual void notify_server_did_leave_tooltip_area(Badge<WebContentClient>) override;
  76. virtual void notify_server_did_request_alert(Badge<WebContentClient>, String const& message) override;
  77. virtual void notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) override;
  78. virtual void notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) override;
  79. virtual void notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message) override;
  80. virtual void notify_server_did_request_accept_dialog(Badge<WebContentClient>) override;
  81. virtual void notify_server_did_request_dismiss_dialog(Badge<WebContentClient>) override;
  82. virtual void notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32) override;
  83. virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
  84. virtual Gfx::IntRect viewport_rect() const override;
  85. virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override;
  86. virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override;
  87. using InputEvent = Variant<GUI::KeyEvent, GUI::MouseEvent>;
  88. void enqueue_input_event(InputEvent const&);
  89. void process_next_input_event();
  90. RefPtr<GUI::Dialog> m_dialog;
  91. bool m_is_awaiting_response_for_input_event { false };
  92. Queue<InputEvent> m_pending_input_events;
  93. bool m_content_scales_to_viewport { false };
  94. };
  95. }