ConnectionFromClient.cpp 21 KB

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