| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2023-05-14 18:57:14 +02:00
										 |  |  |  * Copyright (c) 2022-2023, Andreas Kling <kling@serenityos.org> | 
					
						
							| 
									
										
										
										
											2023-01-12 14:39:53 +00:00
										 |  |  |  * Copyright (c) 2023, Linus Groh <linusg@serenityos.org> | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "WebContentView.h"
 | 
					
						
							| 
									
										
										
										
											2023-08-05 10:42:26 -06:00
										 |  |  | #include "StringUtils.h"
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | #include <AK/Assertions.h>
 | 
					
						
							|  |  |  | #include <AK/ByteBuffer.h>
 | 
					
						
							|  |  |  | #include <AK/Format.h>
 | 
					
						
							|  |  |  | #include <AK/HashTable.h>
 | 
					
						
							|  |  |  | #include <AK/LexicalPath.h>
 | 
					
						
							|  |  |  | #include <AK/NonnullOwnPtr.h>
 | 
					
						
							|  |  |  | #include <AK/StringBuilder.h>
 | 
					
						
							|  |  |  | #include <AK/Types.h>
 | 
					
						
							|  |  |  | #include <Kernel/API/KeyCode.h>
 | 
					
						
							| 
									
										
										
										
											2023-08-05 10:42:26 -06:00
										 |  |  | #include <Ladybird/HelperProcess.h>
 | 
					
						
							|  |  |  | #include <Ladybird/Utilities.h>
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | #include <LibCore/ArgsParser.h>
 | 
					
						
							|  |  |  | #include <LibCore/EventLoop.h>
 | 
					
						
							| 
									
										
										
										
											2023-11-05 09:46:28 -05:00
										 |  |  | #include <LibCore/Resource.h>
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | #include <LibCore/System.h>
 | 
					
						
							|  |  |  | #include <LibCore/Timer.h>
 | 
					
						
							|  |  |  | #include <LibGfx/Bitmap.h>
 | 
					
						
							|  |  |  | #include <LibGfx/Font/FontDatabase.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-21 14:58:06 -04:00
										 |  |  | #include <LibGfx/ImageFormats/PNGWriter.h>
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | #include <LibGfx/Painter.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-15 22:56:47 +01:00
										 |  |  | #include <LibGfx/Palette.h>
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | #include <LibGfx/Rect.h>
 | 
					
						
							| 
									
										
										
										
											2022-12-18 00:50:53 +00:00
										 |  |  | #include <LibGfx/SystemTheme.h>
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | #include <LibMain/Main.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-16 18:35:19 +03:00
										 |  |  | #include <LibWeb/Crypto/Crypto.h>
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | #include <LibWeb/Loader/ContentFilter.h>
 | 
					
						
							| 
									
										
										
										
											2024-01-06 13:13:59 -07:00
										 |  |  | #include <LibWeb/Worker/WebWorkerClient.h>
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | #include <LibWebView/WebContentClient.h>
 | 
					
						
							|  |  |  | #include <QApplication>
 | 
					
						
							|  |  |  | #include <QCursor>
 | 
					
						
							| 
									
										
										
										
											2023-06-12 12:52:44 +02:00
										 |  |  | #include <QGuiApplication>
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | #include <QIcon>
 | 
					
						
							|  |  |  | #include <QLineEdit>
 | 
					
						
							| 
									
										
										
										
											2023-01-07 17:40:04 +01:00
										 |  |  | #include <QMimeData>
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | #include <QMouseEvent>
 | 
					
						
							|  |  |  | #include <QPaintEvent>
 | 
					
						
							|  |  |  | #include <QPainter>
 | 
					
						
							| 
									
										
										
										
											2023-03-15 22:56:47 +01:00
										 |  |  | #include <QPalette>
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | #include <QScrollBar>
 | 
					
						
							|  |  |  | #include <QTextEdit>
 | 
					
						
							|  |  |  | #include <QTimer>
 | 
					
						
							|  |  |  | #include <QToolTip>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-02 11:52:59 -06:00
										 |  |  | namespace Ladybird { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-29 18:35:06 +02:00
										 |  |  | bool is_using_dark_system_theme(QWidget&); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-30 09:12:14 -07:00
										 |  |  | WebContentView::WebContentView(WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, RefPtr<WebView::WebContentClient> parent_client, size_t page_index) | 
					
						
							| 
									
										
										
										
											2023-12-01 12:18:40 -05:00
										 |  |  |     : m_web_content_options(web_content_options) | 
					
						
							| 
									
										
										
										
											2023-07-22 12:41:25 +02:00
										 |  |  |     , m_webdriver_content_ipc_path(webdriver_content_ipc_path) | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-01-30 09:12:14 -07:00
										 |  |  |     m_client_state.client = parent_client; | 
					
						
							|  |  |  |     m_client_state.page_index = page_index; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |     setMouseTracking(true); | 
					
						
							| 
									
										
										
										
											2023-01-07 17:40:04 +01:00
										 |  |  |     setAcceptDrops(true); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-11 11:38:03 +02:00
										 |  |  |     setFocusPolicy(Qt::FocusPolicy::StrongFocus); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-12 14:39:05 +00:00
										 |  |  |     m_device_pixel_ratio = devicePixelRatio(); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     verticalScrollBar()->setSingleStep(24); | 
					
						
							|  |  |  |     horizontalScrollBar()->setSingleStep(24); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QObject::connect(verticalScrollBar(), &QScrollBar::valueChanged, [this](int) { | 
					
						
							|  |  |  |         update_viewport_rect(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     QObject::connect(horizontalScrollBar(), &QScrollBar::valueChanged, [this](int) { | 
					
						
							|  |  |  |         update_viewport_rect(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-30 09:12:14 -07:00
										 |  |  |     initialize_client((parent_client == nullptr) ? CreateNewClient::Yes : CreateNewClient::No); | 
					
						
							| 
									
										
										
										
											2023-05-20 10:50:05 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-23 10:33:26 -04:00
										 |  |  |     on_did_layout = [this](auto content_size) { | 
					
						
							|  |  |  |         verticalScrollBar()->setMinimum(0); | 
					
						
							|  |  |  |         verticalScrollBar()->setMaximum(content_size.height() - m_viewport_rect.height()); | 
					
						
							|  |  |  |         verticalScrollBar()->setPageStep(m_viewport_rect.height()); | 
					
						
							|  |  |  |         horizontalScrollBar()->setMinimum(0); | 
					
						
							|  |  |  |         horizontalScrollBar()->setMaximum(content_size.width() - m_viewport_rect.width()); | 
					
						
							|  |  |  |         horizontalScrollBar()->setPageStep(m_viewport_rect.width()); | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-20 10:50:05 -04:00
										 |  |  |     on_ready_to_paint = [this]() { | 
					
						
							|  |  |  |         viewport()->update(); | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2023-08-23 10:43:27 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-23 10:57:09 -04:00
										 |  |  |     on_scroll_by_delta = [this](auto x_delta, auto y_delta) { | 
					
						
							|  |  |  |         horizontalScrollBar()->setValue(max(0, horizontalScrollBar()->value() + x_delta)); | 
					
						
							|  |  |  |         verticalScrollBar()->setValue(max(0, verticalScrollBar()->value() + y_delta)); | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     on_scroll_to_point = [this](auto position) { | 
					
						
							|  |  |  |         horizontalScrollBar()->setValue(position.x()); | 
					
						
							|  |  |  |         verticalScrollBar()->setValue(position.y()); | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-23 10:43:27 -04:00
										 |  |  |     on_cursor_change = [this](auto cursor) { | 
					
						
							|  |  |  |         update_cursor(cursor); | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:39 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-04 09:55:47 -05:00
										 |  |  |     on_enter_tooltip_area = [this](auto position, auto const& tooltip) { | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:39 -04:00
										 |  |  |         QToolTip::showText( | 
					
						
							|  |  |  |             mapToGlobal(QPoint(position.x(), position.y())), | 
					
						
							| 
									
										
										
										
											2023-12-04 09:55:47 -05:00
										 |  |  |             qstring_from_ak_string(tooltip), | 
					
						
							| 
									
										
										
										
											2023-08-23 11:11:39 -04:00
										 |  |  |             this); | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     on_leave_tooltip_area = []() { | 
					
						
							|  |  |  |         QToolTip::hideText(); | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2024-01-06 13:13:59 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     on_request_worker_agent = []() { | 
					
						
							|  |  |  |         auto worker_client = MUST(launch_web_worker_process(MUST(get_paths_for_helper_process("WebWorker"sv)))); | 
					
						
							|  |  |  |         return worker_client->dup_sockets(); | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | WebContentView::~WebContentView() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_client_state.client) | 
					
						
							|  |  |  |         m_client_state.client->unregister_view(m_client_state.page_index); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-04 20:47:35 +02:00
										 |  |  | unsigned get_button_from_qt_event(QSinglePointEvent const& event) | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     if (event.button() == Qt::MouseButton::LeftButton) | 
					
						
							|  |  |  |         return 1; | 
					
						
							|  |  |  |     if (event.button() == Qt::MouseButton::RightButton) | 
					
						
							|  |  |  |         return 2; | 
					
						
							|  |  |  |     if (event.button() == Qt::MouseButton::MiddleButton) | 
					
						
							|  |  |  |         return 4; | 
					
						
							|  |  |  |     if (event.button() == Qt::MouseButton::BackButton) | 
					
						
							|  |  |  |         return 8; | 
					
						
							|  |  |  |     if (event.buttons() == Qt::MouseButton::ForwardButton) | 
					
						
							|  |  |  |         return 16; | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-04 20:47:35 +02:00
										 |  |  | unsigned get_buttons_from_qt_event(QSinglePointEvent const& event) | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     unsigned buttons = 0; | 
					
						
							|  |  |  |     if (event.buttons() & Qt::MouseButton::LeftButton) | 
					
						
							|  |  |  |         buttons |= 1; | 
					
						
							|  |  |  |     if (event.buttons() & Qt::MouseButton::RightButton) | 
					
						
							|  |  |  |         buttons |= 2; | 
					
						
							|  |  |  |     if (event.buttons() & Qt::MouseButton::MiddleButton) | 
					
						
							|  |  |  |         buttons |= 4; | 
					
						
							|  |  |  |     if (event.buttons() & Qt::MouseButton::BackButton) | 
					
						
							|  |  |  |         buttons |= 8; | 
					
						
							|  |  |  |     if (event.buttons() & Qt::MouseButton::ForwardButton) | 
					
						
							|  |  |  |         buttons |= 16; | 
					
						
							|  |  |  |     return buttons; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-04 20:47:35 +02:00
										 |  |  | unsigned get_modifiers_from_qt_mouse_event(QSinglePointEvent const& event) | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     unsigned modifiers = 0; | 
					
						
							|  |  |  |     if (event.modifiers() & Qt::Modifier::ALT) | 
					
						
							|  |  |  |         modifiers |= 1; | 
					
						
							|  |  |  |     if (event.modifiers() & Qt::Modifier::CTRL) | 
					
						
							|  |  |  |         modifiers |= 2; | 
					
						
							|  |  |  |     if (event.modifiers() & Qt::Modifier::SHIFT) | 
					
						
							|  |  |  |         modifiers |= 4; | 
					
						
							|  |  |  |     return modifiers; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | unsigned get_modifiers_from_qt_keyboard_event(QKeyEvent const& event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto modifiers = 0; | 
					
						
							|  |  |  |     if (event.modifiers().testFlag(Qt::AltModifier)) | 
					
						
							|  |  |  |         modifiers |= KeyModifier::Mod_Alt; | 
					
						
							|  |  |  |     if (event.modifiers().testFlag(Qt::ControlModifier)) | 
					
						
							|  |  |  |         modifiers |= KeyModifier::Mod_Ctrl; | 
					
						
							|  |  |  |     if (event.modifiers().testFlag(Qt::MetaModifier)) | 
					
						
							|  |  |  |         modifiers |= KeyModifier::Mod_Super; | 
					
						
							|  |  |  |     if (event.modifiers().testFlag(Qt::ShiftModifier)) | 
					
						
							|  |  |  |         modifiers |= KeyModifier::Mod_Shift; | 
					
						
							|  |  |  |     if (event.modifiers().testFlag(Qt::AltModifier)) | 
					
						
							|  |  |  |         modifiers |= KeyModifier::Mod_AltGr; | 
					
						
							| 
									
										
										
										
											2023-07-08 16:01:32 -04:00
										 |  |  |     if (event.modifiers().testFlag(Qt::KeypadModifier)) | 
					
						
							|  |  |  |         modifiers |= KeyModifier::Mod_Keypad; | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |     return modifiers; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | KeyCode get_keycode_from_qt_keyboard_event(QKeyEvent const& event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     struct Mapping { | 
					
						
							|  |  |  |         constexpr Mapping(Qt::Key q, KeyCode s) | 
					
						
							|  |  |  |             : qt_key(q) | 
					
						
							|  |  |  |             , serenity_key(s) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         Qt::Key qt_key; | 
					
						
							|  |  |  |         KeyCode serenity_key; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-08 16:58:22 -04:00
										 |  |  |     // https://doc.qt.io/qt-6/qt.html#Key-enum
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |     constexpr Mapping mappings[] = { | 
					
						
							|  |  |  |         { Qt::Key_0, Key_0 }, | 
					
						
							|  |  |  |         { Qt::Key_1, Key_1 }, | 
					
						
							|  |  |  |         { Qt::Key_2, Key_2 }, | 
					
						
							|  |  |  |         { Qt::Key_3, Key_3 }, | 
					
						
							|  |  |  |         { Qt::Key_4, Key_4 }, | 
					
						
							|  |  |  |         { Qt::Key_5, Key_5 }, | 
					
						
							|  |  |  |         { Qt::Key_6, Key_6 }, | 
					
						
							|  |  |  |         { Qt::Key_7, Key_7 }, | 
					
						
							|  |  |  |         { Qt::Key_8, Key_8 }, | 
					
						
							|  |  |  |         { Qt::Key_9, Key_9 }, | 
					
						
							|  |  |  |         { Qt::Key_A, Key_A }, | 
					
						
							|  |  |  |         { Qt::Key_Alt, Key_Alt }, | 
					
						
							|  |  |  |         { Qt::Key_Ampersand, Key_Ampersand }, | 
					
						
							|  |  |  |         { Qt::Key_Apostrophe, Key_Apostrophe }, | 
					
						
							|  |  |  |         { Qt::Key_AsciiCircum, Key_Circumflex }, | 
					
						
							|  |  |  |         { Qt::Key_AsciiTilde, Key_Tilde }, | 
					
						
							|  |  |  |         { Qt::Key_Asterisk, Key_Asterisk }, | 
					
						
							|  |  |  |         { Qt::Key_At, Key_AtSign }, | 
					
						
							|  |  |  |         { Qt::Key_B, Key_B }, | 
					
						
							|  |  |  |         { Qt::Key_Backslash, Key_Backslash }, | 
					
						
							|  |  |  |         { Qt::Key_Backspace, Key_Backspace }, | 
					
						
							|  |  |  |         { Qt::Key_Bar, Key_Pipe }, | 
					
						
							|  |  |  |         { Qt::Key_BraceLeft, Key_LeftBrace }, | 
					
						
							|  |  |  |         { Qt::Key_BraceRight, Key_RightBrace }, | 
					
						
							|  |  |  |         { Qt::Key_BracketLeft, Key_LeftBracket }, | 
					
						
							|  |  |  |         { Qt::Key_BracketRight, Key_RightBracket }, | 
					
						
							|  |  |  |         { Qt::Key_C, Key_C }, | 
					
						
							|  |  |  |         { Qt::Key_CapsLock, Key_CapsLock }, | 
					
						
							|  |  |  |         { Qt::Key_Colon, Key_Colon }, | 
					
						
							|  |  |  |         { Qt::Key_Comma, Key_Comma }, | 
					
						
							|  |  |  |         { Qt::Key_Control, Key_Control }, | 
					
						
							|  |  |  |         { Qt::Key_D, Key_D }, | 
					
						
							|  |  |  |         { Qt::Key_Delete, Key_Delete }, | 
					
						
							|  |  |  |         { Qt::Key_Dollar, Key_Dollar }, | 
					
						
							|  |  |  |         { Qt::Key_Down, Key_Down }, | 
					
						
							|  |  |  |         { Qt::Key_E, Key_E }, | 
					
						
							|  |  |  |         { Qt::Key_End, Key_End }, | 
					
						
							|  |  |  |         { Qt::Key_Equal, Key_Equal }, | 
					
						
							| 
									
										
										
										
											2023-07-08 16:58:22 -04:00
										 |  |  |         { Qt::Key_Enter, Key_Return }, | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |         { Qt::Key_Escape, Key_Escape }, | 
					
						
							| 
									
										
										
										
											2023-07-08 16:58:22 -04:00
										 |  |  |         { Qt::Key_Exclam, Key_ExclamationPoint }, | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |         { Qt::Key_exclamdown, Key_ExclamationPoint }, | 
					
						
							|  |  |  |         { Qt::Key_F, Key_F }, | 
					
						
							|  |  |  |         { Qt::Key_F1, Key_F1 }, | 
					
						
							|  |  |  |         { Qt::Key_F10, Key_F10 }, | 
					
						
							|  |  |  |         { Qt::Key_F11, Key_F11 }, | 
					
						
							|  |  |  |         { Qt::Key_F12, Key_F12 }, | 
					
						
							|  |  |  |         { Qt::Key_F2, Key_F2 }, | 
					
						
							|  |  |  |         { Qt::Key_F3, Key_F3 }, | 
					
						
							|  |  |  |         { Qt::Key_F4, Key_F4 }, | 
					
						
							|  |  |  |         { Qt::Key_F5, Key_F5 }, | 
					
						
							|  |  |  |         { Qt::Key_F6, Key_F6 }, | 
					
						
							|  |  |  |         { Qt::Key_F7, Key_F7 }, | 
					
						
							|  |  |  |         { Qt::Key_F8, Key_F8 }, | 
					
						
							|  |  |  |         { Qt::Key_F9, Key_F9 }, | 
					
						
							|  |  |  |         { Qt::Key_G, Key_G }, | 
					
						
							|  |  |  |         { Qt::Key_Greater, Key_GreaterThan }, | 
					
						
							|  |  |  |         { Qt::Key_H, Key_H }, | 
					
						
							|  |  |  |         { Qt::Key_Home, Key_Home }, | 
					
						
							|  |  |  |         { Qt::Key_I, Key_I }, | 
					
						
							|  |  |  |         { Qt::Key_Insert, Key_Insert }, | 
					
						
							|  |  |  |         { Qt::Key_J, Key_J }, | 
					
						
							|  |  |  |         { Qt::Key_K, Key_K }, | 
					
						
							|  |  |  |         { Qt::Key_L, Key_L }, | 
					
						
							|  |  |  |         { Qt::Key_Left, Key_Left }, | 
					
						
							|  |  |  |         { Qt::Key_Less, Key_LessThan }, | 
					
						
							|  |  |  |         { Qt::Key_M, Key_M }, | 
					
						
							|  |  |  |         { Qt::Key_Menu, Key_Menu }, | 
					
						
							| 
									
										
										
										
											2023-07-08 16:58:22 -04:00
										 |  |  |         { Qt::Key_Meta, Key_Super }, | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |         { Qt::Key_Minus, Key_Minus }, | 
					
						
							|  |  |  |         { Qt::Key_N, Key_N }, | 
					
						
							| 
									
										
										
										
											2023-07-08 16:58:22 -04:00
										 |  |  |         { Qt::Key_NumberSign, Key_Hashtag }, | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |         { Qt::Key_NumLock, Key_NumLock }, | 
					
						
							|  |  |  |         { Qt::Key_O, Key_O }, | 
					
						
							|  |  |  |         { Qt::Key_P, Key_P }, | 
					
						
							|  |  |  |         { Qt::Key_PageDown, Key_PageDown }, | 
					
						
							|  |  |  |         { Qt::Key_PageUp, Key_PageUp }, | 
					
						
							|  |  |  |         { Qt::Key_ParenLeft, Key_LeftParen }, | 
					
						
							|  |  |  |         { Qt::Key_ParenRight, Key_RightParen }, | 
					
						
							|  |  |  |         { Qt::Key_Percent, Key_Percent }, | 
					
						
							|  |  |  |         { Qt::Key_Period, Key_Period }, | 
					
						
							|  |  |  |         { Qt::Key_Plus, Key_Plus }, | 
					
						
							|  |  |  |         { Qt::Key_Print, Key_PrintScreen }, | 
					
						
							|  |  |  |         { Qt::Key_Q, Key_Q }, | 
					
						
							|  |  |  |         { Qt::Key_Question, Key_QuestionMark }, | 
					
						
							|  |  |  |         { Qt::Key_QuoteDbl, Key_DoubleQuote }, | 
					
						
							| 
									
										
										
										
											2023-07-08 16:58:22 -04:00
										 |  |  |         { Qt::Key_QuoteLeft, Key_Backtick }, | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |         { Qt::Key_R, Key_R }, | 
					
						
							|  |  |  |         { Qt::Key_Return, Key_Return }, | 
					
						
							|  |  |  |         { Qt::Key_Right, Key_Right }, | 
					
						
							|  |  |  |         { Qt::Key_S, Key_S }, | 
					
						
							|  |  |  |         { Qt::Key_ScrollLock, Key_ScrollLock }, | 
					
						
							|  |  |  |         { Qt::Key_Semicolon, Key_Semicolon }, | 
					
						
							|  |  |  |         { Qt::Key_Shift, Key_LeftShift }, | 
					
						
							|  |  |  |         { Qt::Key_Slash, Key_Slash }, | 
					
						
							|  |  |  |         { Qt::Key_Space, Key_Space }, | 
					
						
							|  |  |  |         { Qt::Key_Super_L, Key_Super }, | 
					
						
							| 
									
										
										
										
											2023-07-08 16:58:22 -04:00
										 |  |  |         { Qt::Key_Super_R, Key_Super }, | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |         { Qt::Key_SysReq, Key_SysRq }, | 
					
						
							|  |  |  |         { Qt::Key_T, Key_T }, | 
					
						
							|  |  |  |         { Qt::Key_Tab, Key_Tab }, | 
					
						
							|  |  |  |         { Qt::Key_U, Key_U }, | 
					
						
							|  |  |  |         { Qt::Key_Underscore, Key_Underscore }, | 
					
						
							|  |  |  |         { Qt::Key_Up, Key_Up }, | 
					
						
							|  |  |  |         { Qt::Key_V, Key_V }, | 
					
						
							|  |  |  |         { Qt::Key_W, Key_W }, | 
					
						
							|  |  |  |         { Qt::Key_X, Key_X }, | 
					
						
							|  |  |  |         { Qt::Key_Y, Key_Y }, | 
					
						
							|  |  |  |         { Qt::Key_Z, Key_Z }, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (auto const& mapping : mappings) { | 
					
						
							|  |  |  |         if (event.key() == mapping.qt_key) | 
					
						
							|  |  |  |             return mapping.serenity_key; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return Key_Invalid; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentView::mouseMoveEvent(QMouseEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-12-16 11:49:16 +01:00
										 |  |  |     Gfx::IntPoint position(event->position().x() * m_device_pixel_ratio, event->position().y() * m_device_pixel_ratio); | 
					
						
							|  |  |  |     Gfx::IntPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |     auto buttons = get_buttons_from_qt_event(*event); | 
					
						
							|  |  |  |     auto modifiers = get_modifiers_from_qt_mouse_event(*event); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_mouse_move(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, 0, buttons, modifiers); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentView::mousePressEvent(QMouseEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-12-16 11:49:16 +01:00
										 |  |  |     Gfx::IntPoint position(event->position().x() * m_device_pixel_ratio, event->position().y() * m_device_pixel_ratio); | 
					
						
							|  |  |  |     Gfx::IntPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |     auto button = get_button_from_qt_event(*event); | 
					
						
							|  |  |  |     if (button == 0) { | 
					
						
							|  |  |  |         // We could not convert Qt buttons to something that Lagom can
 | 
					
						
							|  |  |  |         // recognize - don't even bother propagating this to the web engine
 | 
					
						
							|  |  |  |         // as it will not handle it anyway, and it will (currently) assert
 | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     auto modifiers = get_modifiers_from_qt_mouse_event(*event); | 
					
						
							|  |  |  |     auto buttons = get_buttons_from_qt_event(*event); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_mouse_down(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentView::mouseReleaseEvent(QMouseEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-12-16 11:49:16 +01:00
										 |  |  |     Gfx::IntPoint position(event->position().x() * m_device_pixel_ratio, event->position().y() * m_device_pixel_ratio); | 
					
						
							|  |  |  |     Gfx::IntPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |     auto button = get_button_from_qt_event(*event); | 
					
						
							| 
									
										
										
										
											2022-11-08 02:00:24 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (event->button() & Qt::MouseButton::BackButton) { | 
					
						
							| 
									
										
										
										
											2023-08-18 18:33:25 -04:00
										 |  |  |         if (on_navigate_back) | 
					
						
							|  |  |  |             on_navigate_back(); | 
					
						
							| 
									
										
										
										
											2022-11-08 02:00:24 +01:00
										 |  |  |     } else if (event->button() & Qt::MouseButton::ForwardButton) { | 
					
						
							| 
									
										
										
										
											2023-08-18 18:33:25 -04:00
										 |  |  |         if (on_navigate_forward) | 
					
						
							|  |  |  |             on_navigate_forward(); | 
					
						
							| 
									
										
										
										
											2022-11-08 02:00:24 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |     if (button == 0) { | 
					
						
							|  |  |  |         // We could not convert Qt buttons to something that Lagom can
 | 
					
						
							|  |  |  |         // recognize - don't even bother propagating this to the web engine
 | 
					
						
							|  |  |  |         // as it will not handle it anyway, and it will (currently) assert
 | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     auto modifiers = get_modifiers_from_qt_mouse_event(*event); | 
					
						
							|  |  |  |     auto buttons = get_buttons_from_qt_event(*event); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_mouse_up(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers); | 
					
						
							| 
									
										
										
										
											2023-12-15 17:46:09 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentView::wheelEvent(QWheelEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!event->modifiers().testFlag(Qt::ControlModifier)) { | 
					
						
							| 
									
										
										
										
											2023-12-16 11:49:16 +01:00
										 |  |  |         Gfx::IntPoint position(event->position().x() * m_device_pixel_ratio, event->position().y() * m_device_pixel_ratio); | 
					
						
							|  |  |  |         Gfx::IntPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); | 
					
						
							| 
									
										
										
										
											2023-12-15 17:46:09 +01:00
										 |  |  |         auto button = get_button_from_qt_event(*event); | 
					
						
							|  |  |  |         auto buttons = get_buttons_from_qt_event(*event); | 
					
						
							|  |  |  |         auto modifiers = get_modifiers_from_qt_mouse_event(*event); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         auto num_pixels = -event->pixelDelta(); | 
					
						
							|  |  |  |         if (!num_pixels.isNull()) { | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |             client().async_mouse_wheel(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint(screen_position), button, buttons, modifiers, num_pixels.x(), num_pixels.y()); | 
					
						
							| 
									
										
										
										
											2023-12-15 17:46:09 +01:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             auto num_degrees = -event->angleDelta(); | 
					
						
							|  |  |  |             float delta_x = -num_degrees.x() / 120; | 
					
						
							|  |  |  |             float delta_y = num_degrees.y() / 120; | 
					
						
							|  |  |  |             auto step_x = delta_x * QApplication::wheelScrollLines() * m_device_pixel_ratio; | 
					
						
							|  |  |  |             auto step_y = delta_y * QApplication::wheelScrollLines() * m_device_pixel_ratio; | 
					
						
							|  |  |  |             int scroll_step_size = verticalScrollBar()->singleStep(); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |             client().async_mouse_wheel(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint(screen_position), button, buttons, modifiers, step_x * scroll_step_size, step_y * scroll_step_size); | 
					
						
							| 
									
										
										
										
											2023-12-15 17:46:09 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         event->accept(); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     event->ignore(); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-13 15:55:10 +01:00
										 |  |  | void WebContentView::mouseDoubleClickEvent(QMouseEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-12-16 11:49:16 +01:00
										 |  |  |     Gfx::IntPoint position(event->position().x() * m_device_pixel_ratio, event->position().y() * m_device_pixel_ratio); | 
					
						
							|  |  |  |     Gfx::IntPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); | 
					
						
							| 
									
										
										
										
											2023-05-13 15:55:10 +01:00
										 |  |  |     auto button = get_button_from_qt_event(*event); | 
					
						
							|  |  |  |     if (button == 0) { | 
					
						
							|  |  |  |         // We could not convert Qt buttons to something that Lagom can
 | 
					
						
							|  |  |  |         // recognize - don't even bother propagating this to the web engine
 | 
					
						
							|  |  |  |         // as it will not handle it anyway, and it will (currently) assert
 | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     auto modifiers = get_modifiers_from_qt_mouse_event(*event); | 
					
						
							|  |  |  |     auto buttons = get_buttons_from_qt_event(*event); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_doubleclick(m_client_state.page_index, Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers); | 
					
						
							| 
									
										
										
										
											2023-05-13 15:55:10 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-07 17:40:04 +01:00
										 |  |  | void WebContentView::dragEnterEvent(QDragEnterEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (event->mimeData()->hasUrls()) | 
					
						
							|  |  |  |         event->acceptProposedAction(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentView::dropEvent(QDropEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     VERIFY(event->mimeData()->hasUrls()); | 
					
						
							|  |  |  |     emit urls_dropped(event->mimeData()->urls()); | 
					
						
							|  |  |  |     event->acceptProposedAction(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | void WebContentView::keyPressEvent(QKeyEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     switch (event->key()) { | 
					
						
							|  |  |  |     case Qt::Key_Left: | 
					
						
							|  |  |  |     case Qt::Key_Right: | 
					
						
							|  |  |  |     case Qt::Key_Up: | 
					
						
							|  |  |  |     case Qt::Key_Down: | 
					
						
							|  |  |  |     case Qt::Key_PageUp: | 
					
						
							|  |  |  |     case Qt::Key_PageDown: | 
					
						
							|  |  |  |         QAbstractScrollArea::keyPressEvent(event); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-11 17:17:49 +02:00
										 |  |  |     if (event->key() == Qt::Key_Backtab) { | 
					
						
							|  |  |  |         // NOTE: Qt transforms Shift+Tab into a "Backtab", so we undo that transformation here.
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |         client().async_key_down(m_client_state.page_index, KeyCode::Key_Tab, Mod_Shift, '\t'); | 
					
						
							| 
									
										
										
										
											2022-10-11 17:17:49 +02:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |     auto text = event->text(); | 
					
						
							| 
									
										
										
										
											2023-07-02 22:18:47 -07:00
										 |  |  |     auto point = text.isEmpty() ? 0u : event->text()[0].unicode(); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |     auto keycode = get_keycode_from_qt_keyboard_event(*event); | 
					
						
							|  |  |  |     auto modifiers = get_modifiers_from_qt_keyboard_event(*event); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_key_down(m_client_state.page_index, keycode, modifiers, point); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentView::keyReleaseEvent(QKeyEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto text = event->text(); | 
					
						
							| 
									
										
										
										
											2023-07-02 22:18:47 -07:00
										 |  |  |     auto point = text.isEmpty() ? 0u : event->text()[0].unicode(); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |     auto keycode = get_keycode_from_qt_keyboard_event(*event); | 
					
						
							|  |  |  |     auto modifiers = get_modifiers_from_qt_keyboard_event(*event); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_key_up(m_client_state.page_index, keycode, modifiers, point); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-11 11:38:03 +02:00
										 |  |  | void WebContentView::focusInEvent(QFocusEvent*) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_set_has_focus(m_client_state.page_index, true); | 
					
						
							| 
									
										
										
										
											2022-10-11 11:38:03 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentView::focusOutEvent(QFocusEvent*) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_set_has_focus(m_client_state.page_index, false); | 
					
						
							| 
									
										
										
										
											2022-10-11 11:38:03 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | void WebContentView::paintEvent(QPaintEvent*) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QPainter painter(viewport()); | 
					
						
							| 
									
										
										
										
											2023-12-13 19:10:05 +01:00
										 |  |  |     painter.scale(1 / m_device_pixel_ratio, 1 / m_device_pixel_ratio); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-14 18:57:14 +02:00
										 |  |  |     Gfx::Bitmap const* bitmap = nullptr; | 
					
						
							|  |  |  |     Gfx::IntSize bitmap_size; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_client_state.has_usable_bitmap) { | 
					
						
							|  |  |  |         bitmap = m_client_state.front_bitmap.bitmap.ptr(); | 
					
						
							| 
									
										
										
										
											2023-12-14 07:17:00 +01:00
										 |  |  |         bitmap_size = m_client_state.front_bitmap.last_painted_size.to_type<int>(); | 
					
						
							| 
									
										
										
										
											2023-05-14 18:57:14 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         bitmap = m_backup_bitmap.ptr(); | 
					
						
							| 
									
										
										
										
											2023-12-14 07:17:00 +01:00
										 |  |  |         bitmap_size = m_backup_bitmap_size.to_type<int>(); | 
					
						
							| 
									
										
										
										
											2023-05-14 18:57:14 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (bitmap) { | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |         QImage q_image(bitmap->scanline_u8(0), bitmap->width(), bitmap->height(), QImage::Format_RGB32); | 
					
						
							| 
									
										
										
										
											2023-05-14 18:57:14 +02:00
										 |  |  |         painter.drawImage(QPoint(0, 0), q_image, QRect(0, 0, bitmap_size.width(), bitmap_size.height())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (bitmap_size.width() < width()) { | 
					
						
							|  |  |  |             painter.fillRect(bitmap_size.width(), 0, width() - bitmap_size.width(), bitmap->height(), palette().base()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (bitmap_size.height() < height()) { | 
					
						
							|  |  |  |             painter.fillRect(0, bitmap_size.height(), width(), height() - bitmap_size.height(), palette().base()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     painter.fillRect(rect(), palette().base()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentView::resizeEvent(QResizeEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QAbstractScrollArea::resizeEvent(event); | 
					
						
							|  |  |  |     update_viewport_rect(); | 
					
						
							| 
									
										
										
										
											2023-05-15 07:59:51 +02:00
										 |  |  |     handle_resize(); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-30 23:38:19 +03:00
										 |  |  | void WebContentView::set_viewport_rect(Gfx::IntRect rect) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_viewport_rect = rect; | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_set_viewport_rect(m_client_state.page_index, rect.to_type<Web::DevicePixels>()); | 
					
						
							| 
									
										
										
										
											2023-01-30 23:38:19 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-08 23:57:24 +03:00
										 |  |  | void WebContentView::set_window_size(Gfx::IntSize size) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_set_window_size(m_client_state.page_index, size.to_type<Web::DevicePixels>()); | 
					
						
							| 
									
										
										
										
											2023-03-08 23:57:24 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentView::set_window_position(Gfx::IntPoint position) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_set_window_position(m_client_state.page_index, position.to_type<Web::DevicePixels>()); | 
					
						
							| 
									
										
										
										
											2023-03-08 23:57:24 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-13 19:10:05 +01:00
										 |  |  | void WebContentView::set_device_pixel_ratio(double device_pixel_ratio) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_device_pixel_ratio = device_pixel_ratio; | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_set_device_pixels_per_css_pixel(m_client_state.page_index, m_device_pixel_ratio * m_zoom_level); | 
					
						
							| 
									
										
										
										
											2023-12-13 19:10:05 +01:00
										 |  |  |     update_viewport_rect(); | 
					
						
							|  |  |  |     handle_resize(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | void WebContentView::update_viewport_rect() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-12-13 19:10:05 +01:00
										 |  |  |     auto scaled_width = int(viewport()->width() * m_device_pixel_ratio); | 
					
						
							|  |  |  |     auto scaled_height = int(viewport()->height() * m_device_pixel_ratio); | 
					
						
							| 
									
										
										
										
											2023-05-14 17:26:40 +02:00
										 |  |  |     Gfx::IntRect rect(max(0, horizontalScrollBar()->value()), max(0, verticalScrollBar()->value()), scaled_width, scaled_height); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-30 23:38:19 +03:00
										 |  |  |     set_viewport_rect(rect); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-12 14:39:53 +00:00
										 |  |  | void WebContentView::update_zoom() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_set_device_pixels_per_css_pixel(m_client_state.page_index, m_device_pixel_ratio * m_zoom_level); | 
					
						
							| 
									
										
										
										
											2023-01-12 14:39:53 +00:00
										 |  |  |     update_viewport_rect(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | void WebContentView::showEvent(QShowEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QAbstractScrollArea::showEvent(event); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_set_system_visibility_state(m_client_state.page_index, true); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentView::hideEvent(QHideEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QAbstractScrollArea::hideEvent(event); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_set_system_visibility_state(m_client_state.page_index, false); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-22 21:57:08 -04:00
										 |  |  | static Core::AnonymousBuffer make_system_theme_from_qt_palette(QWidget& widget, WebContentView::PaletteMode mode) | 
					
						
							| 
									
										
										
										
											2023-03-15 22:56:47 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     auto qt_palette = widget.palette(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-22 21:57:08 -04:00
										 |  |  |     auto theme_file = mode == WebContentView::PaletteMode::Default ? "Default"sv : "Dark"sv; | 
					
						
							| 
									
										
										
										
											2023-11-05 09:46:28 -05:00
										 |  |  |     auto theme_ini = MUST(Core::Resource::load_from_uri(MUST(String::formatted("resource://themes/{}.ini", theme_file)))); | 
					
						
							| 
									
										
										
										
											2023-12-16 17:49:34 +03:30
										 |  |  |     auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_byte_string()).release_value_but_fixme_should_propagate_errors(); | 
					
						
							| 
									
										
										
										
											2023-11-05 09:46:28 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-15 22:56:47 +01:00
										 |  |  |     auto palette_impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme); | 
					
						
							|  |  |  |     auto palette = Gfx::Palette(move(palette_impl)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto translate = [&](Gfx::ColorRole gfx_color_role, QPalette::ColorRole qt_color_role) { | 
					
						
							|  |  |  |         auto new_color = Gfx::Color::from_argb(qt_palette.color(qt_color_role).rgba()); | 
					
						
							|  |  |  |         palette.set_color(gfx_color_role, new_color); | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     translate(Gfx::ColorRole::ThreedHighlight, QPalette::ColorRole::Light); | 
					
						
							|  |  |  |     translate(Gfx::ColorRole::ThreedShadow1, QPalette::ColorRole::Mid); | 
					
						
							|  |  |  |     translate(Gfx::ColorRole::ThreedShadow2, QPalette::ColorRole::Dark); | 
					
						
							|  |  |  |     translate(Gfx::ColorRole::HoverHighlight, QPalette::ColorRole::Light); | 
					
						
							|  |  |  |     translate(Gfx::ColorRole::Link, QPalette::ColorRole::Link); | 
					
						
							|  |  |  |     translate(Gfx::ColorRole::VisitedLink, QPalette::ColorRole::LinkVisited); | 
					
						
							|  |  |  |     translate(Gfx::ColorRole::Button, QPalette::ColorRole::Button); | 
					
						
							|  |  |  |     translate(Gfx::ColorRole::ButtonText, QPalette::ColorRole::ButtonText); | 
					
						
							|  |  |  |     translate(Gfx::ColorRole::Selection, QPalette::ColorRole::Highlight); | 
					
						
							|  |  |  |     translate(Gfx::ColorRole::SelectionText, QPalette::ColorRole::HighlightedText); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-29 18:35:06 +02:00
										 |  |  |     palette.set_flag(Gfx::FlagRole::IsDark, is_using_dark_system_theme(widget)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-15 22:56:47 +01:00
										 |  |  |     return theme; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-22 21:57:08 -04:00
										 |  |  | void WebContentView::update_palette(PaletteMode mode) | 
					
						
							| 
									
										
										
										
											2023-03-15 22:56:47 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_update_system_theme(m_client_state.page_index, make_system_theme_from_qt_palette(*this, mode)); | 
					
						
							| 
									
										
										
										
											2023-03-15 22:56:47 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-30 09:12:14 -07:00
										 |  |  | void WebContentView::initialize_client(WebView::ViewImplementation::CreateNewClient create_new_client) | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-01-30 09:12:14 -07:00
										 |  |  |     if (create_new_client == CreateNewClient::Yes) { | 
					
						
							|  |  |  |         m_client_state = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         auto candidate_web_content_paths = get_paths_for_helper_process("WebContent"sv).release_value_but_fixme_should_propagate_errors(); | 
					
						
							|  |  |  |         auto new_client = launch_web_content_process(*this, candidate_web_content_paths, m_web_content_options).release_value_but_fixme_should_propagate_errors(); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-30 09:12:14 -07:00
										 |  |  |         m_client_state.client = new_client; | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } else { | 
					
						
							|  |  |  |         m_client_state.client->register_view(m_client_state.page_index, *this); | 
					
						
							| 
									
										
										
										
											2024-01-30 09:12:14 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_client_state.client->on_web_content_process_crash = [this] { | 
					
						
							| 
									
										
										
										
											2023-04-24 18:02:29 +02:00
										 |  |  |         Core::deferred_invoke([this] { | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |             handle_web_content_process_crash(); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-16 18:35:19 +03:00
										 |  |  |     m_client_state.client_handle = Web::Crypto::generate_random_uuid().release_value_but_fixme_should_propagate_errors(); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_set_window_handle(m_client_state.page_index, m_client_state.client_handle); | 
					
						
							| 
									
										
										
										
											2023-03-16 18:35:19 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_set_device_pixels_per_css_pixel(m_client_state.page_index, m_device_pixel_ratio); | 
					
						
							| 
									
										
										
										
											2023-03-15 22:56:47 +01:00
										 |  |  |     update_palette(); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     client().async_update_system_fonts(m_client_state.page_index, Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query(), Gfx::FontDatabase::window_title_font_query()); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-12 12:52:44 +02:00
										 |  |  |     auto screens = QGuiApplication::screens(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!screens.empty()) { | 
					
						
							| 
									
										
										
										
											2023-12-14 07:17:00 +01:00
										 |  |  |         Vector<Web::DevicePixelRect> screen_rects; | 
					
						
							| 
									
										
										
										
											2023-06-12 12:52:44 +02:00
										 |  |  |         for (auto const& screen : screens) { | 
					
						
							|  |  |  |             auto geometry = screen->geometry(); | 
					
						
							| 
									
										
										
										
											2023-12-14 07:17:00 +01:00
										 |  |  |             screen_rects.append(Web::DevicePixelRect(geometry.x(), geometry.y(), geometry.width(), geometry.height())); | 
					
						
							| 
									
										
										
										
											2023-06-12 12:52:44 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // FIXME: Update the screens again when QGuiApplication::screenAdded/Removed signals are emitted
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // NOTE: The first item in QGuiApplication::screens is always the primary screen.
 | 
					
						
							|  |  |  |         //       This is not specified in the documentation but QGuiApplication::primaryScreen
 | 
					
						
							|  |  |  |         //       always returns the first item in the list if it isn't empty.
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |         client().async_update_screen_rects(m_client_state.page_index, screen_rects, 0); | 
					
						
							| 
									
										
										
										
											2023-06-12 12:52:44 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-03-16 08:50:22 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (!m_webdriver_content_ipc_path.is_empty()) | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |         client().async_connect_to_webdriver(m_client_state.page_index, m_webdriver_content_ipc_path); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-23 10:43:27 -04:00
										 |  |  | void WebContentView::update_cursor(Gfx::StandardCursor cursor) | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     switch (cursor) { | 
					
						
							| 
									
										
										
										
											2023-04-13 20:07:54 -04:00
										 |  |  |     case Gfx::StandardCursor::Hidden: | 
					
						
							|  |  |  |         setCursor(Qt::BlankCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::Arrow: | 
					
						
							|  |  |  |         setCursor(Qt::ArrowCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::Crosshair: | 
					
						
							|  |  |  |         setCursor(Qt::CrossCursor); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::IBeam: | 
					
						
							|  |  |  |         setCursor(Qt::IBeamCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2023-04-13 20:07:54 -04:00
										 |  |  |     case Gfx::StandardCursor::ResizeHorizontal: | 
					
						
							|  |  |  |         setCursor(Qt::SizeHorCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::ResizeVertical: | 
					
						
							|  |  |  |         setCursor(Qt::SizeVerCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::ResizeDiagonalTLBR: | 
					
						
							|  |  |  |         setCursor(Qt::SizeFDiagCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::ResizeDiagonalBLTR: | 
					
						
							|  |  |  |         setCursor(Qt::SizeBDiagCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::ResizeColumn: | 
					
						
							|  |  |  |         setCursor(Qt::SplitHCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::ResizeRow: | 
					
						
							|  |  |  |         setCursor(Qt::SplitVCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::Hand: | 
					
						
							|  |  |  |         setCursor(Qt::PointingHandCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::Help: | 
					
						
							|  |  |  |         setCursor(Qt::WhatsThisCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::Drag: | 
					
						
							|  |  |  |         setCursor(Qt::ClosedHandCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::DragCopy: | 
					
						
							|  |  |  |         setCursor(Qt::DragCopyCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::Move: | 
					
						
							|  |  |  |         setCursor(Qt::DragMoveCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::Wait: | 
					
						
							|  |  |  |         setCursor(Qt::BusyCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::Disallowed: | 
					
						
							|  |  |  |         setCursor(Qt::ForbiddenCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Gfx::StandardCursor::Eyedropper: | 
					
						
							|  |  |  |     case Gfx::StandardCursor::Zoom: | 
					
						
							|  |  |  |         // FIXME: No corresponding Qt cursors, default to Arrow
 | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  |     default: | 
					
						
							|  |  |  |         setCursor(Qt::ArrowCursor); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-14 07:17:00 +01:00
										 |  |  | Web::DevicePixelRect WebContentView::viewport_rect() const | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-12-14 07:17:00 +01:00
										 |  |  |     return m_viewport_rect.to_type<Web::DevicePixels>(); | 
					
						
							| 
									
										
										
										
											2022-10-05 15:23:41 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-10-11 17:17:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-17 10:12:13 -04:00
										 |  |  | Gfx::IntPoint WebContentView::to_content_position(Gfx::IntPoint widget_position) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return widget_position.translated(max(0, horizontalScrollBar()->value()), max(0, verticalScrollBar()->value())); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Gfx::IntPoint WebContentView::to_widget_position(Gfx::IntPoint content_position) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return content_position.translated(-(max(0, horizontalScrollBar()->value())), -(max(0, verticalScrollBar()->value()))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-11 17:17:49 +02:00
										 |  |  | bool WebContentView::event(QEvent* event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // NOTE: We have to implement event() manually as Qt's focus navigation mechanism
 | 
					
						
							|  |  |  |     //       eats all the Tab key presses by default.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (event->type() == QEvent::KeyPress) { | 
					
						
							|  |  |  |         keyPressEvent(static_cast<QKeyEvent*>(event)); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (event->type() == QEvent::KeyRelease) { | 
					
						
							|  |  |  |         keyReleaseEvent(static_cast<QKeyEvent*>(event)); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-03-15 22:56:47 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (event->type() == QEvent::PaletteChange) { | 
					
						
							|  |  |  |         update_palette(); | 
					
						
							|  |  |  |         return QAbstractScrollArea::event(event); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-11 17:17:49 +02:00
										 |  |  |     return QAbstractScrollArea::event(event); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-11-21 16:36:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-27 10:41:24 +01:00
										 |  |  | ErrorOr<String> WebContentView::dump_layout_tree() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     return String::from_byte_string(client().dump_layout_tree(m_client_state.page_index)); | 
					
						
							| 
									
										
										
										
											2023-01-27 10:41:24 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2023-08-02 11:52:59 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |