OutOfProcessWebView.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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<String, String> get_local_storage_entries();
  30. OrderedHashMap<String, String> 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. private:
  43. OutOfProcessWebView();
  44. // ^Widget
  45. virtual void paint_event(GUI::PaintEvent&) override;
  46. virtual void resize_event(GUI::ResizeEvent&) override;
  47. virtual void mousedown_event(GUI::MouseEvent&) override;
  48. virtual void mouseup_event(GUI::MouseEvent&) override;
  49. virtual void mousemove_event(GUI::MouseEvent&) override;
  50. virtual void mousewheel_event(GUI::MouseEvent&) override;
  51. virtual void doubleclick_event(GUI::MouseEvent&) override;
  52. virtual void keydown_event(GUI::KeyEvent&) override;
  53. virtual void keyup_event(GUI::KeyEvent&) override;
  54. virtual void theme_change_event(GUI::ThemeChangeEvent&) override;
  55. virtual void screen_rects_change_event(GUI::ScreenRectsChangeEvent&) override;
  56. virtual void focusin_event(GUI::FocusEvent&) override;
  57. virtual void focusout_event(GUI::FocusEvent&) override;
  58. virtual void show_event(GUI::ShowEvent&) override;
  59. virtual void hide_event(GUI::HideEvent&) override;
  60. // ^AbstractScrollableWidget
  61. virtual void did_scroll() override;
  62. // ^WebView::ViewImplementation
  63. virtual void create_client() override;
  64. virtual void update_zoom() override;
  65. virtual Web::DevicePixelRect viewport_rect() const override;
  66. virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override;
  67. virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override;
  68. using InputEvent = Variant<GUI::KeyEvent, GUI::MouseEvent>;
  69. void enqueue_input_event(InputEvent const&);
  70. void process_next_input_event();
  71. void did_finish_handling_input_event(bool event_was_accepted);
  72. bool m_is_awaiting_response_for_input_event { false };
  73. Queue<InputEvent> m_pending_input_events;
  74. bool m_content_scales_to_viewport { false };
  75. };
  76. }