OutOfProcessWebView.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/URL.h>
  9. #include <LibGUI/AbstractScrollableWidget.h>
  10. #include <LibGUI/Widget.h>
  11. #include <LibWeb/CSS/Selector.h>
  12. #include <LibWeb/HTML/ActivateTab.h>
  13. #include <LibWeb/Page/Page.h>
  14. #include <LibWebView/ViewImplementation.h>
  15. namespace Messages::WebContentServer {
  16. class WebdriverExecuteScriptResponse;
  17. }
  18. namespace WebView {
  19. class WebContentClient;
  20. class OutOfProcessWebView final
  21. : public GUI::AbstractScrollableWidget
  22. , public ViewImplementation {
  23. C_OBJECT(OutOfProcessWebView);
  24. using Super = GUI::AbstractScrollableWidget;
  25. public:
  26. virtual ~OutOfProcessWebView() override;
  27. ByteString dump_layout_tree();
  28. OrderedHashMap<String, String> get_local_storage_entries();
  29. OrderedHashMap<String, String> get_session_storage_entries();
  30. void set_content_filters(Vector<String>);
  31. void set_autoplay_allowed_on_all_websites();
  32. void set_autoplay_allowlist(Vector<String>);
  33. void set_proxy_mappings(Vector<ByteString> proxies, HashMap<ByteString, size_t> mappings);
  34. void connect_to_webdriver(ByteString const& webdriver_ipc_path);
  35. void set_window_position(Gfx::IntPoint);
  36. void set_window_size(Gfx::IntSize);
  37. void set_system_visibility_state(bool visible);
  38. // This is a hint that tells OOPWV that the content will scale to the viewport size.
  39. // In practice, this means that OOPWV may render scaled stale versions of the content while resizing.
  40. void set_content_scales_to_viewport(bool);
  41. private:
  42. OutOfProcessWebView();
  43. // ^Widget
  44. virtual void paint_event(GUI::PaintEvent&) override;
  45. virtual void resize_event(GUI::ResizeEvent&) override;
  46. virtual void mousedown_event(GUI::MouseEvent&) override;
  47. virtual void mouseup_event(GUI::MouseEvent&) override;
  48. virtual void mousemove_event(GUI::MouseEvent&) override;
  49. virtual void mousewheel_event(GUI::MouseEvent&) override;
  50. virtual void doubleclick_event(GUI::MouseEvent&) override;
  51. virtual void keydown_event(GUI::KeyEvent&) override;
  52. virtual void keyup_event(GUI::KeyEvent&) override;
  53. virtual void theme_change_event(GUI::ThemeChangeEvent&) override;
  54. virtual void screen_rects_change_event(GUI::ScreenRectsChangeEvent&) override;
  55. virtual void focusin_event(GUI::FocusEvent&) override;
  56. virtual void focusout_event(GUI::FocusEvent&) override;
  57. virtual void show_event(GUI::ShowEvent&) override;
  58. virtual void hide_event(GUI::HideEvent&) override;
  59. // ^AbstractScrollableWidget
  60. virtual void did_scroll() override;
  61. // ^WebView::ViewImplementation
  62. virtual void initialize_client(CreateNewClient) override;
  63. virtual void update_zoom() override;
  64. virtual Web::DevicePixelRect viewport_rect() const override;
  65. virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override;
  66. virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override;
  67. void enqueue_native_event(Web::MouseEvent::Type, GUI::MouseEvent const& event);
  68. void enqueue_native_event(Web::KeyEvent::Type, GUI::KeyEvent const& event);
  69. void finish_handling_key_event(Web::KeyEvent const&);
  70. bool m_content_scales_to_viewport { false };
  71. };
  72. }