Serenity Operating System
at master 613 lines 24 kB view raw
1/* 2 * Copyright (c) 2020-2023, Andreas Kling <kling@serenityos.org> 3 * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org> 4 * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org> 5 * Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org> 6 * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org> 7 * 8 * SPDX-License-Identifier: BSD-2-Clause 9 */ 10 11#include <AK/Debug.h> 12#include <AK/JsonObject.h> 13#include <AK/QuickSort.h> 14#include <LibGfx/Bitmap.h> 15#include <LibGfx/Font/FontDatabase.h> 16#include <LibGfx/SystemTheme.h> 17#include <LibJS/Console.h> 18#include <LibJS/Heap/Heap.h> 19#include <LibJS/Runtime/ConsoleObject.h> 20#include <LibWeb/Bindings/MainThreadVM.h> 21#include <LibWeb/DOM/Document.h> 22#include <LibWeb/Dump.h> 23#include <LibWeb/HTML/BrowsingContext.h> 24#include <LibWeb/HTML/Scripting/ClassicScript.h> 25#include <LibWeb/HTML/Storage.h> 26#include <LibWeb/HTML/Window.h> 27#include <LibWeb/Layout/Viewport.h> 28#include <LibWeb/Loader/ContentFilter.h> 29#include <LibWeb/Loader/ProxyMappings.h> 30#include <LibWeb/Loader/ResourceLoader.h> 31#include <LibWeb/Painting/PaintableBox.h> 32#include <LibWeb/Painting/StackingContext.h> 33#include <LibWeb/Platform/EventLoopPlugin.h> 34#include <WebContent/ConnectionFromClient.h> 35#include <WebContent/PageHost.h> 36#include <WebContent/WebContentClientEndpoint.h> 37#include <pthread.h> 38 39namespace WebContent { 40 41ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket) 42 : IPC::ConnectionFromClient<WebContentClientEndpoint, WebContentServerEndpoint>(*this, move(socket), 1) 43 , m_page_host(PageHost::create(*this)) 44{ 45 m_paint_flush_timer = Web::Platform::Timer::create_single_shot(0, [this] { flush_pending_paint_requests(); }); 46} 47 48void ConnectionFromClient::die() 49{ 50 Web::Platform::EventLoopPlugin::the().quit(); 51} 52 53Web::Page& ConnectionFromClient::page() 54{ 55 return m_page_host->page(); 56} 57 58Web::Page const& ConnectionFromClient::page() const 59{ 60 return m_page_host->page(); 61} 62 63void ConnectionFromClient::connect_to_webdriver(DeprecatedString const& webdriver_ipc_path) 64{ 65 // FIXME: Propagate this error back to the browser. 66 if (auto result = m_page_host->connect_to_webdriver(webdriver_ipc_path); result.is_error()) 67 dbgln("Unable to connect to the WebDriver process: {}", result.error()); 68} 69 70void ConnectionFromClient::update_system_theme(Core::AnonymousBuffer const& theme_buffer) 71{ 72 Gfx::set_system_theme(theme_buffer); 73 auto impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme_buffer); 74 m_page_host->set_palette_impl(*impl); 75} 76 77void ConnectionFromClient::update_system_fonts(DeprecatedString const& default_font_query, DeprecatedString const& fixed_width_font_query, DeprecatedString const& window_title_font_query) 78{ 79 Gfx::FontDatabase::set_default_font_query(default_font_query); 80 Gfx::FontDatabase::set_fixed_width_font_query(fixed_width_font_query); 81 Gfx::FontDatabase::set_window_title_font_query(window_title_font_query); 82} 83 84void ConnectionFromClient::update_screen_rects(Vector<Gfx::IntRect> const& rects, u32 main_screen) 85{ 86 m_page_host->set_screen_rects(rects, main_screen); 87} 88 89void ConnectionFromClient::load_url(const URL& url) 90{ 91 dbgln_if(SPAM_DEBUG, "handle: WebContentServer::LoadURL: url={}", url); 92 93#if defined(AK_OS_SERENITY) 94 DeprecatedString process_name; 95 if (url.host().is_empty()) 96 process_name = "WebContent"; 97 else 98 process_name = DeprecatedString::formatted("WebContent: {}", url.host()); 99 100 pthread_setname_np(pthread_self(), process_name.characters()); 101#endif 102 103 page().load(url); 104} 105 106void ConnectionFromClient::load_html(DeprecatedString const& html, const URL& url) 107{ 108 dbgln_if(SPAM_DEBUG, "handle: WebContentServer::LoadHTML: html={}, url={}", html, url); 109 page().load_html(html, url); 110} 111 112void ConnectionFromClient::set_viewport_rect(Gfx::IntRect const& rect) 113{ 114 dbgln_if(SPAM_DEBUG, "handle: WebContentServer::SetViewportRect: rect={}", rect); 115 m_page_host->set_viewport_rect(rect.to_type<Web::DevicePixels>()); 116} 117 118void ConnectionFromClient::add_backing_store(i32 backing_store_id, Gfx::ShareableBitmap const& bitmap) 119{ 120 m_backing_stores.set(backing_store_id, *const_cast<Gfx::ShareableBitmap&>(bitmap).bitmap()); 121} 122 123void ConnectionFromClient::remove_backing_store(i32 backing_store_id) 124{ 125 m_backing_stores.remove(backing_store_id); 126 m_pending_paint_requests.remove_all_matching([backing_store_id](auto& pending_repaint_request) { return pending_repaint_request.bitmap_id == backing_store_id; }); 127} 128 129void ConnectionFromClient::paint(Gfx::IntRect const& content_rect, i32 backing_store_id) 130{ 131 for (auto& pending_paint : m_pending_paint_requests) { 132 if (pending_paint.bitmap_id == backing_store_id) { 133 pending_paint.content_rect = content_rect; 134 return; 135 } 136 } 137 138 auto it = m_backing_stores.find(backing_store_id); 139 if (it == m_backing_stores.end()) { 140 did_misbehave("Client requested paint with backing store ID"); 141 return; 142 } 143 144 auto& bitmap = *it->value; 145 m_pending_paint_requests.append({ content_rect, bitmap, backing_store_id }); 146 m_paint_flush_timer->start(); 147} 148 149void ConnectionFromClient::flush_pending_paint_requests() 150{ 151 for (auto& pending_paint : m_pending_paint_requests) { 152 m_page_host->paint(pending_paint.content_rect.to_type<Web::DevicePixels>(), *pending_paint.bitmap); 153 async_did_paint(pending_paint.content_rect, pending_paint.bitmap_id); 154 } 155 m_pending_paint_requests.clear(); 156} 157 158void ConnectionFromClient::mouse_down(Gfx::IntPoint position, unsigned int button, unsigned int buttons, unsigned int modifiers) 159{ 160 report_finished_handling_input_event(page().handle_mousedown(position.to_type<Web::DevicePixels>(), button, buttons, modifiers)); 161} 162 163void ConnectionFromClient::mouse_move(Gfx::IntPoint position, [[maybe_unused]] unsigned int button, unsigned int buttons, unsigned int modifiers) 164{ 165 report_finished_handling_input_event(page().handle_mousemove(position.to_type<Web::DevicePixels>(), buttons, modifiers)); 166} 167 168void ConnectionFromClient::mouse_up(Gfx::IntPoint position, unsigned int button, unsigned int buttons, unsigned int modifiers) 169{ 170 report_finished_handling_input_event(page().handle_mouseup(position.to_type<Web::DevicePixels>(), button, buttons, modifiers)); 171} 172 173void ConnectionFromClient::mouse_wheel(Gfx::IntPoint position, unsigned int button, unsigned int buttons, unsigned int modifiers, i32 wheel_delta_x, i32 wheel_delta_y) 174{ 175 report_finished_handling_input_event(page().handle_mousewheel(position.to_type<Web::DevicePixels>(), button, buttons, modifiers, wheel_delta_x, wheel_delta_y)); 176} 177 178void ConnectionFromClient::doubleclick(Gfx::IntPoint position, unsigned int button, unsigned int buttons, unsigned int modifiers) 179{ 180 report_finished_handling_input_event(page().handle_doubleclick(position.to_type<Web::DevicePixels>(), button, buttons, modifiers)); 181} 182 183void ConnectionFromClient::key_down(i32 key, unsigned int modifiers, u32 code_point) 184{ 185 report_finished_handling_input_event(page().handle_keydown((KeyCode)key, modifiers, code_point)); 186} 187 188void ConnectionFromClient::key_up(i32 key, unsigned int modifiers, u32 code_point) 189{ 190 report_finished_handling_input_event(page().handle_keyup((KeyCode)key, modifiers, code_point)); 191} 192 193void ConnectionFromClient::report_finished_handling_input_event(bool event_was_handled) 194{ 195 async_did_finish_handling_input_event(event_was_handled); 196} 197 198void ConnectionFromClient::debug_request(DeprecatedString const& request, DeprecatedString const& argument) 199{ 200 if (request == "dump-dom-tree") { 201 if (auto* doc = page().top_level_browsing_context().active_document()) 202 Web::dump_tree(*doc); 203 } 204 205 if (request == "dump-layout-tree") { 206 if (auto* doc = page().top_level_browsing_context().active_document()) { 207 if (auto* viewport = doc->layout_node()) 208 Web::dump_tree(*viewport); 209 } 210 } 211 212 if (request == "dump-stacking-context-tree") { 213 if (auto* doc = page().top_level_browsing_context().active_document()) { 214 if (auto* viewport = doc->layout_node()) { 215 if (auto* stacking_context = viewport->paint_box()->stacking_context()) 216 stacking_context->dump(); 217 } 218 } 219 } 220 221 if (request == "dump-style-sheets") { 222 if (auto* doc = page().top_level_browsing_context().active_document()) { 223 for (auto& sheet : doc->style_sheets().sheets()) { 224 if (auto result = Web::dump_sheet(sheet); result.is_error()) 225 dbgln("Failed to dump style sheets: {}", result.error()); 226 } 227 } 228 } 229 230 if (request == "collect-garbage") { 231 Web::Bindings::main_thread_vm().heap().collect_garbage(JS::Heap::CollectionType::CollectGarbage, true); 232 } 233 234 if (request == "set-line-box-borders") { 235 bool state = argument == "on"; 236 m_page_host->set_should_show_line_box_borders(state); 237 page().top_level_browsing_context().set_needs_display(page().top_level_browsing_context().viewport_rect()); 238 } 239 240 if (request == "clear-cache") { 241 Web::ResourceLoader::the().clear_cache(); 242 } 243 244 if (request == "spoof-user-agent") { 245 Web::ResourceLoader::the().set_user_agent(argument); 246 } 247 248 if (request == "same-origin-policy") { 249 m_page_host->page().set_same_origin_policy_enabled(argument == "on"); 250 } 251 252 if (request == "scripting") { 253 m_page_host->page().set_is_scripting_enabled(argument == "on"); 254 } 255 256 if (request == "block-pop-ups") { 257 m_page_host->page().set_should_block_pop_ups(argument == "on"); 258 } 259 260 if (request == "dump-local-storage") { 261 if (auto* document = page().top_level_browsing_context().active_document()) 262 document->window().local_storage().release_value_but_fixme_should_propagate_errors()->dump(); 263 } 264} 265 266void ConnectionFromClient::get_source() 267{ 268 if (auto* doc = page().top_level_browsing_context().active_document()) { 269 async_did_get_source(doc->url(), doc->source()); 270 } 271} 272 273void ConnectionFromClient::inspect_dom_tree() 274{ 275 if (auto* doc = page().top_level_browsing_context().active_document()) { 276 async_did_get_dom_tree(doc->dump_dom_tree_as_json()); 277 } 278} 279 280Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement> const& pseudo_element) 281{ 282 auto& top_context = page().top_level_browsing_context(); 283 284 top_context.for_each_in_inclusive_subtree([&](auto& ctx) { 285 if (ctx.active_document() != nullptr) { 286 ctx.active_document()->set_inspected_node(nullptr); 287 } 288 return IterationDecision::Continue; 289 }); 290 291 Web::DOM::Node* node = Web::DOM::Node::from_id(node_id); 292 // Note: Nodes without layout (aka non-visible nodes, don't have style computed) 293 if (!node || !node->layout_node()) { 294 return { false, "", "", "", "" }; 295 } 296 297 // FIXME: Pass the pseudo-element here. 298 node->document().set_inspected_node(node); 299 300 if (node->is_element()) { 301 auto& element = verify_cast<Web::DOM::Element>(*node); 302 if (!element.computed_css_values()) 303 return { false, "", "", "", "" }; 304 305 auto serialize_json = [](Web::CSS::StyleProperties const& properties) -> DeprecatedString { 306 StringBuilder builder; 307 308 auto serializer = MUST(JsonObjectSerializer<>::try_create(builder)); 309 properties.for_each_property([&](auto property_id, auto& value) { 310 MUST(serializer.add(Web::CSS::string_from_property_id(property_id), value.to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string())); 311 }); 312 MUST(serializer.finish()); 313 314 return builder.to_deprecated_string(); 315 }; 316 317 auto serialize_custom_properties_json = [](Web::DOM::Element const& element) -> DeprecatedString { 318 StringBuilder builder; 319 auto serializer = MUST(JsonObjectSerializer<>::try_create(builder)); 320 HashTable<DeprecatedString> seen_properties; 321 322 auto const* element_to_check = &element; 323 while (element_to_check) { 324 for (auto const& property : element_to_check->custom_properties()) { 325 if (!seen_properties.contains(property.key)) { 326 seen_properties.set(property.key); 327 MUST(serializer.add(property.key, property.value.value->to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string())); 328 } 329 } 330 331 element_to_check = element_to_check->parent_element(); 332 } 333 334 MUST(serializer.finish()); 335 336 return builder.to_deprecated_string(); 337 }; 338 auto serialize_node_box_sizing_json = [](Web::Layout::Node const* layout_node) -> DeprecatedString { 339 if (!layout_node || !layout_node->is_box()) { 340 return "{}"; 341 } 342 auto* box = static_cast<Web::Layout::Box const*>(layout_node); 343 auto box_model = box->box_model(); 344 StringBuilder builder; 345 auto serializer = MUST(JsonObjectSerializer<>::try_create(builder)); 346 MUST(serializer.add("padding_top"sv, box_model.padding.top.value())); 347 MUST(serializer.add("padding_right"sv, box_model.padding.right.value())); 348 MUST(serializer.add("padding_bottom"sv, box_model.padding.bottom.value())); 349 MUST(serializer.add("padding_left"sv, box_model.padding.left.value())); 350 MUST(serializer.add("margin_top"sv, box_model.margin.top.value())); 351 MUST(serializer.add("margin_right"sv, box_model.margin.right.value())); 352 MUST(serializer.add("margin_bottom"sv, box_model.margin.bottom.value())); 353 MUST(serializer.add("margin_left"sv, box_model.margin.left.value())); 354 MUST(serializer.add("border_top"sv, box_model.border.top.value())); 355 MUST(serializer.add("border_right"sv, box_model.border.right.value())); 356 MUST(serializer.add("border_bottom"sv, box_model.border.bottom.value())); 357 MUST(serializer.add("border_left"sv, box_model.border.left.value())); 358 if (auto* paint_box = box->paint_box()) { 359 MUST(serializer.add("content_width"sv, paint_box->content_width().value())); 360 MUST(serializer.add("content_height"sv, paint_box->content_height().value())); 361 } else { 362 MUST(serializer.add("content_width"sv, 0)); 363 MUST(serializer.add("content_height"sv, 0)); 364 } 365 366 MUST(serializer.finish()); 367 return builder.to_deprecated_string(); 368 }; 369 370 if (pseudo_element.has_value()) { 371 auto pseudo_element_node = element.get_pseudo_element_node(pseudo_element.value()); 372 if (!pseudo_element_node) 373 return { false, "", "", "", "" }; 374 375 // FIXME: Pseudo-elements only exist as Layout::Nodes, which don't have style information 376 // in a format we can use. So, we run the StyleComputer again to get the specified 377 // values, and have to ignore the computed values and custom properties. 378 auto pseudo_element_style = MUST(page().focused_context().active_document()->style_computer().compute_style(element, pseudo_element)); 379 DeprecatedString computed_values = serialize_json(pseudo_element_style); 380 DeprecatedString resolved_values = "{}"; 381 DeprecatedString custom_properties_json = "{}"; 382 DeprecatedString node_box_sizing_json = serialize_node_box_sizing_json(pseudo_element_node.ptr()); 383 return { true, computed_values, resolved_values, custom_properties_json, node_box_sizing_json }; 384 } 385 386 DeprecatedString computed_values = serialize_json(*element.computed_css_values()); 387 DeprecatedString resolved_values_json = serialize_json(element.resolved_css_values()); 388 DeprecatedString custom_properties_json = serialize_custom_properties_json(element); 389 DeprecatedString node_box_sizing_json = serialize_node_box_sizing_json(element.layout_node()); 390 return { true, computed_values, resolved_values_json, custom_properties_json, node_box_sizing_json }; 391 } 392 393 return { false, "", "", "", "" }; 394} 395 396Messages::WebContentServer::GetHoveredNodeIdResponse ConnectionFromClient::get_hovered_node_id() 397{ 398 if (auto* document = page().top_level_browsing_context().active_document()) { 399 auto hovered_node = document->hovered_node(); 400 if (hovered_node) 401 return hovered_node->id(); 402 } 403 return (i32)0; 404} 405 406void ConnectionFromClient::initialize_js_console(Badge<PageHost>) 407{ 408 auto* document = page().top_level_browsing_context().active_document(); 409 auto realm = document->realm().make_weak_ptr(); 410 if (m_realm.ptr() == realm.ptr()) 411 return; 412 413 auto& console_object = *realm->intrinsics().console_object(); 414 m_realm = realm; 415 m_console_client = make<WebContentConsoleClient>(console_object.console(), *m_realm, *this); 416 console_object.console().set_client(*m_console_client.ptr()); 417} 418 419void ConnectionFromClient::js_console_input(DeprecatedString const& js_source) 420{ 421 if (m_console_client) 422 m_console_client->handle_input(js_source); 423} 424 425void ConnectionFromClient::run_javascript(DeprecatedString const& js_source) 426{ 427 auto* active_document = page().top_level_browsing_context().active_document(); 428 429 if (!active_document) 430 return; 431 432 // This is partially based on "execute a javascript: URL request" https://html.spec.whatwg.org/multipage/browsing-the-web.html#javascript-protocol 433 434 // Let settings be browsingContext's active document's relevant settings object. 435 auto& settings = active_document->relevant_settings_object(); 436 437 // Let baseURL be settings's API base URL. 438 auto base_url = settings.api_base_url(); 439 440 // Let script be the result of creating a classic script given scriptSource, settings, baseURL, and the default classic script fetch options. 441 // FIXME: This doesn't pass in "default classic script fetch options" 442 // FIXME: What should the filename be here? 443 auto script = Web::HTML::ClassicScript::create("(client connection run_javascript)", js_source, settings, move(base_url)); 444 445 // Let evaluationStatus be the result of running the classic script script. 446 auto evaluation_status = script->run(); 447 448 if (evaluation_status.is_error()) 449 dbgln("Exception :("); 450} 451 452void ConnectionFromClient::js_console_request_messages(i32 start_index) 453{ 454 if (m_console_client) 455 m_console_client->send_messages(start_index); 456} 457 458Messages::WebContentServer::TakeDocumentScreenshotResponse ConnectionFromClient::take_document_screenshot() 459{ 460 auto* document = page().top_level_browsing_context().active_document(); 461 if (!document || !document->document_element()) 462 return { {} }; 463 464 auto const& content_size = m_page_host->content_size(); 465 Web::DevicePixelRect rect { { 0, 0 }, content_size }; 466 467 auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, rect.size().to_type<int>()).release_value_but_fixme_should_propagate_errors(); 468 m_page_host->paint(rect, *bitmap); 469 470 return { bitmap->to_shareable_bitmap() }; 471} 472 473Messages::WebContentServer::GetSelectedTextResponse ConnectionFromClient::get_selected_text() 474{ 475 return page().focused_context().selected_text(); 476} 477 478void ConnectionFromClient::select_all() 479{ 480 page().focused_context().select_all(); 481 page().client().page_did_change_selection(); 482} 483 484Messages::WebContentServer::DumpLayoutTreeResponse ConnectionFromClient::dump_layout_tree() 485{ 486 auto* document = page().top_level_browsing_context().active_document(); 487 if (!document) 488 return DeprecatedString { "(no DOM tree)" }; 489 auto* layout_root = document->layout_node(); 490 if (!layout_root) 491 return DeprecatedString { "(no layout tree)" }; 492 StringBuilder builder; 493 Web::dump_tree(builder, *layout_root); 494 return builder.to_deprecated_string(); 495} 496 497void ConnectionFromClient::set_content_filters(Vector<DeprecatedString> const& filters) 498{ 499 for (auto& filter : filters) 500 Web::ContentFilter::the().add_pattern(filter); 501} 502 503void ConnectionFromClient::set_proxy_mappings(Vector<DeprecatedString> const& proxies, HashMap<DeprecatedString, size_t> const& mappings) 504{ 505 auto keys = mappings.keys(); 506 quick_sort(keys, [&](auto& a, auto& b) { return a.length() < b.length(); }); 507 508 OrderedHashMap<DeprecatedString, size_t> sorted_mappings; 509 for (auto& key : keys) { 510 auto value = *mappings.get(key); 511 if (value >= proxies.size()) 512 continue; 513 sorted_mappings.set(key, value); 514 } 515 516 Web::ProxyMappings::the().set_mappings(proxies, move(sorted_mappings)); 517} 518 519void ConnectionFromClient::set_preferred_color_scheme(Web::CSS::PreferredColorScheme const& color_scheme) 520{ 521 m_page_host->set_preferred_color_scheme(color_scheme); 522} 523 524void ConnectionFromClient::set_has_focus(bool has_focus) 525{ 526 m_page_host->set_has_focus(has_focus); 527} 528 529void ConnectionFromClient::set_is_scripting_enabled(bool is_scripting_enabled) 530{ 531 m_page_host->set_is_scripting_enabled(is_scripting_enabled); 532} 533 534void ConnectionFromClient::set_device_pixels_per_css_pixel(float device_pixels_per_css_pixel) 535{ 536 m_page_host->set_device_pixels_per_css_pixel(device_pixels_per_css_pixel); 537} 538 539void ConnectionFromClient::set_window_position(Gfx::IntPoint position) 540{ 541 m_page_host->set_window_position(position.to_type<Web::DevicePixels>()); 542} 543 544void ConnectionFromClient::set_window_size(Gfx::IntSize size) 545{ 546 m_page_host->set_window_size(size.to_type<Web::DevicePixels>()); 547} 548 549Messages::WebContentServer::GetLocalStorageEntriesResponse ConnectionFromClient::get_local_storage_entries() 550{ 551 auto* document = page().top_level_browsing_context().active_document(); 552 auto local_storage = document->window().local_storage().release_value_but_fixme_should_propagate_errors(); 553 return local_storage->map(); 554} 555 556Messages::WebContentServer::GetSessionStorageEntriesResponse ConnectionFromClient::get_session_storage_entries() 557{ 558 auto* document = page().top_level_browsing_context().active_document(); 559 auto session_storage = document->window().session_storage().release_value_but_fixme_should_propagate_errors(); 560 return session_storage->map(); 561} 562 563void ConnectionFromClient::handle_file_return(i32 error, Optional<IPC::File> const& file, i32 request_id) 564{ 565 auto file_request = m_requested_files.take(request_id); 566 567 VERIFY(file_request.has_value()); 568 VERIFY(file_request.value().on_file_request_finish); 569 570 file_request.value().on_file_request_finish(error != 0 ? Error::from_errno(error) : ErrorOr<i32> { file->take_fd() }); 571} 572 573void ConnectionFromClient::request_file(Web::FileRequest file_request) 574{ 575 i32 const id = last_id++; 576 577 auto path = file_request.path(); 578 m_requested_files.set(id, move(file_request)); 579 580 async_did_request_file(path, id); 581} 582 583void ConnectionFromClient::set_system_visibility_state(bool visible) 584{ 585 m_page_host->page().top_level_browsing_context().set_system_visibility_state( 586 visible 587 ? Web::HTML::VisibilityState::Visible 588 : Web::HTML::VisibilityState::Hidden); 589} 590 591void ConnectionFromClient::alert_closed() 592{ 593 m_page_host->alert_closed(); 594} 595 596void ConnectionFromClient::confirm_closed(bool accepted) 597{ 598 m_page_host->confirm_closed(accepted); 599} 600 601void ConnectionFromClient::prompt_closed(DeprecatedString const& response) 602{ 603 m_page_host->prompt_closed(response); 604} 605 606void ConnectionFromClient::inspect_accessibility_tree() 607{ 608 if (auto* doc = page().top_level_browsing_context().active_document()) { 609 async_did_get_accessibility_tree(doc->dump_accessibility_tree_as_json()); 610 } 611} 612 613}