ConnectionFromClient.cpp 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. /*
  2. * Copyright (c) 2020-2023, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2021-2023, 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. * Copyright (c) 2023-2024, Andrew Kaster <akaster@serenityos.org>
  8. *
  9. * SPDX-License-Identifier: BSD-2-Clause
  10. */
  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/Heap/Heap.h>
  17. #include <LibJS/Runtime/ConsoleObject.h>
  18. #include <LibWeb/ARIA/RoleType.h>
  19. #include <LibWeb/Bindings/MainThreadVM.h>
  20. #include <LibWeb/CSS/StyleComputer.h>
  21. #include <LibWeb/DOM/Attr.h>
  22. #include <LibWeb/DOM/CharacterData.h>
  23. #include <LibWeb/DOM/Document.h>
  24. #include <LibWeb/DOM/Element.h>
  25. #include <LibWeb/DOM/ElementFactory.h>
  26. #include <LibWeb/DOM/Text.h>
  27. #include <LibWeb/Dump.h>
  28. #include <LibWeb/HTML/BrowsingContext.h>
  29. #include <LibWeb/HTML/HTMLInputElement.h>
  30. #include <LibWeb/HTML/SelectedFile.h>
  31. #include <LibWeb/HTML/Storage.h>
  32. #include <LibWeb/HTML/TraversableNavigable.h>
  33. #include <LibWeb/HTML/Window.h>
  34. #include <LibWeb/Infra/Strings.h>
  35. #include <LibWeb/Layout/Viewport.h>
  36. #include <LibWeb/Loader/ContentFilter.h>
  37. #include <LibWeb/Loader/ProxyMappings.h>
  38. #include <LibWeb/Loader/ResourceLoader.h>
  39. #include <LibWeb/Namespace.h>
  40. #include <LibWeb/Painting/StackingContext.h>
  41. #include <LibWeb/Painting/ViewportPaintable.h>
  42. #include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
  43. #include <LibWeb/Platform/EventLoopPlugin.h>
  44. #include <LibWebView/Attribute.h>
  45. #include <WebContent/ConnectionFromClient.h>
  46. #include <WebContent/PageClient.h>
  47. #include <WebContent/PageHost.h>
  48. #include <WebContent/WebContentClientEndpoint.h>
  49. #ifdef AK_OS_SERENITY
  50. # include <pthread.h>
  51. #endif
  52. namespace WebContent {
  53. ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket)
  54. : IPC::ConnectionFromClient<WebContentClientEndpoint, WebContentServerEndpoint>(*this, move(socket), 1)
  55. , m_page_host(PageHost::create(*this))
  56. {
  57. m_input_event_queue_timer = Web::Platform::Timer::create_single_shot(0, [this] { process_next_input_event(); });
  58. async_notify_process_information({ ::getpid() });
  59. }
  60. void ConnectionFromClient::die()
  61. {
  62. Web::Platform::EventLoopPlugin::the().quit();
  63. }
  64. Optional<PageClient&> ConnectionFromClient::page(u64 index, SourceLocation location)
  65. {
  66. if (auto page = m_page_host->page(index); page.has_value())
  67. return *page;
  68. dbgln("ConnectionFromClient::{}: Did not find a page with ID {}", location.function_name(), index);
  69. return {};
  70. }
  71. Optional<PageClient const&> ConnectionFromClient::page(u64 index, SourceLocation location) const
  72. {
  73. if (auto page = m_page_host->page(index); page.has_value())
  74. return *page;
  75. dbgln("ConnectionFromClient::{}: Did not find a page with ID {}", location.function_name(), index);
  76. return {};
  77. }
  78. Messages::WebContentServer::GetWindowHandleResponse ConnectionFromClient::get_window_handle(u64 page_id)
  79. {
  80. if (auto page = this->page(page_id); page.has_value())
  81. return page->page().top_level_traversable()->window_handle();
  82. return String {};
  83. }
  84. void ConnectionFromClient::set_window_handle(u64 page_id, String const& handle)
  85. {
  86. if (auto page = this->page(page_id); page.has_value())
  87. page->page().top_level_traversable()->set_window_handle(handle);
  88. }
  89. void ConnectionFromClient::connect_to_webdriver(u64 page_id, ByteString const& webdriver_ipc_path)
  90. {
  91. if (auto page = this->page(page_id); page.has_value()) {
  92. // FIXME: Propagate this error back to the browser.
  93. if (auto result = page->connect_to_webdriver(webdriver_ipc_path); result.is_error())
  94. dbgln("Unable to connect to the WebDriver process: {}", result.error());
  95. }
  96. }
  97. void ConnectionFromClient::update_system_theme(u64 page_id, Core::AnonymousBuffer const& theme_buffer)
  98. {
  99. auto page = this->page(page_id);
  100. if (!page.has_value())
  101. return;
  102. Gfx::set_system_theme(theme_buffer);
  103. auto impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme_buffer);
  104. page->set_palette_impl(*impl);
  105. }
  106. void ConnectionFromClient::update_screen_rects(u64 page_id, Vector<Web::DevicePixelRect> const& rects, u32 main_screen)
  107. {
  108. if (auto page = this->page(page_id); page.has_value())
  109. page->set_screen_rects(rects, main_screen);
  110. }
  111. void ConnectionFromClient::load_url(u64 page_id, const URL::URL& url)
  112. {
  113. auto page = this->page(page_id);
  114. if (!page.has_value())
  115. return;
  116. #if defined(AK_OS_SERENITY)
  117. ByteString process_name;
  118. if (url.host().has<Empty>() || url.host() == String {})
  119. process_name = "WebContent";
  120. else
  121. process_name = ByteString::formatted("WebContent: {}", url.serialized_host().release_value_but_fixme_should_propagate_errors());
  122. pthread_setname_np(pthread_self(), process_name.characters());
  123. #endif
  124. page->page().load(url);
  125. }
  126. void ConnectionFromClient::load_html(u64 page_id, ByteString const& html)
  127. {
  128. if (auto page = this->page(page_id); page.has_value())
  129. page->page().load_html(html);
  130. }
  131. void ConnectionFromClient::reload(u64 page_id)
  132. {
  133. if (auto page = this->page(page_id); page.has_value())
  134. page->page().reload();
  135. }
  136. void ConnectionFromClient::traverse_the_history_by_delta(u64 page_id, i32 delta)
  137. {
  138. if (auto page = this->page(page_id); page.has_value())
  139. page->page().traverse_the_history_by_delta(delta);
  140. }
  141. void ConnectionFromClient::set_viewport_size(u64 page_id, Web::DevicePixelSize const size)
  142. {
  143. if (auto page = this->page(page_id); page.has_value())
  144. page->set_viewport_size(size);
  145. }
  146. void ConnectionFromClient::add_backing_store(u64 page_id, i32 front_bitmap_id, Gfx::ShareableBitmap const& front_bitmap, i32 back_bitmap_id, Gfx::ShareableBitmap const& back_bitmap)
  147. {
  148. if (auto page = this->page(page_id); page.has_value())
  149. page->add_backing_store(front_bitmap_id, front_bitmap, back_bitmap_id, back_bitmap);
  150. }
  151. void ConnectionFromClient::ready_to_paint(u64 page_id)
  152. {
  153. if (auto page = this->page(page_id); page.has_value())
  154. page->ready_to_paint();
  155. }
  156. void ConnectionFromClient::process_next_input_event()
  157. {
  158. if (m_input_event_queue.is_empty())
  159. return;
  160. auto event = m_input_event_queue.dequeue();
  161. auto page = this->page(event.page_id);
  162. if (!page.has_value())
  163. return;
  164. auto handled = event.event.visit(
  165. [&](Web::KeyEvent const& event) {
  166. switch (event.type) {
  167. case Web::KeyEvent::Type::KeyDown:
  168. return page->page().handle_keydown(event.key, event.modifiers, event.code_point);
  169. case Web::KeyEvent::Type::KeyUp:
  170. return page->page().handle_keyup(event.key, event.modifiers, event.code_point);
  171. }
  172. VERIFY_NOT_REACHED();
  173. },
  174. [&](Web::MouseEvent const& event) {
  175. switch (event.type) {
  176. case Web::MouseEvent::Type::MouseDown:
  177. return page->page().handle_mousedown(event.position, event.screen_position, event.button, event.buttons, event.modifiers);
  178. case Web::MouseEvent::Type::MouseUp:
  179. return page->page().handle_mouseup(event.position, event.screen_position, event.button, event.buttons, event.modifiers);
  180. case Web::MouseEvent::Type::MouseMove:
  181. return page->page().handle_mousemove(event.position, event.screen_position, event.buttons, event.modifiers);
  182. case Web::MouseEvent::Type::MouseWheel:
  183. return page->page().handle_mousewheel(event.position, event.screen_position, event.button, event.buttons, event.modifiers, event.wheel_delta_x, event.wheel_delta_y);
  184. case Web::MouseEvent::Type::DoubleClick:
  185. return page->page().handle_doubleclick(event.position, event.screen_position, event.button, event.buttons, event.modifiers);
  186. }
  187. VERIFY_NOT_REACHED();
  188. });
  189. // We have to notify the client about coalesced events, so we do that by saying none of them were handled by the web page->
  190. for (size_t i = 0; i < event.coalesced_event_count; ++i)
  191. report_finished_handling_input_event(event.page_id, false);
  192. report_finished_handling_input_event(event.page_id, handled);
  193. if (!m_input_event_queue.is_empty())
  194. m_input_event_queue_timer->start();
  195. }
  196. void ConnectionFromClient::key_event(u64 page_id, Web::KeyEvent const& event)
  197. {
  198. enqueue_input_event({ page_id, move(const_cast<Web::KeyEvent&>(event)), 0 });
  199. }
  200. void ConnectionFromClient::mouse_event(u64 page_id, Web::MouseEvent const& event)
  201. {
  202. // OPTIMIZATION: Coalesce consecutive unprocessed mouse move and wheel events.
  203. auto event_to_coalesce = [&]() -> Web::MouseEvent const* {
  204. if (m_input_event_queue.is_empty())
  205. return nullptr;
  206. if (m_input_event_queue.tail().page_id != page_id)
  207. return nullptr;
  208. if (event.type != Web::MouseEvent::Type::MouseMove && event.type != Web::MouseEvent::Type::MouseWheel)
  209. return nullptr;
  210. if (auto const* mouse_event = m_input_event_queue.tail().event.get_pointer<Web::MouseEvent>()) {
  211. if (mouse_event->type == event.type)
  212. return mouse_event;
  213. }
  214. return nullptr;
  215. };
  216. if (auto const* last_mouse_event = event_to_coalesce()) {
  217. auto& mutable_event = const_cast<Web::MouseEvent&>(event);
  218. mutable_event.wheel_delta_x += last_mouse_event->wheel_delta_x;
  219. mutable_event.wheel_delta_y += last_mouse_event->wheel_delta_y;
  220. m_input_event_queue.tail().event = move(mutable_event);
  221. ++m_input_event_queue.tail().coalesced_event_count;
  222. return;
  223. }
  224. enqueue_input_event({ page_id, move(const_cast<Web::MouseEvent&>(event)), 0 });
  225. }
  226. void ConnectionFromClient::enqueue_input_event(QueuedInputEvent event)
  227. {
  228. m_input_event_queue.enqueue(move(event));
  229. m_input_event_queue_timer->start();
  230. }
  231. void ConnectionFromClient::report_finished_handling_input_event(u64 page_id, bool event_was_handled)
  232. {
  233. async_did_finish_handling_input_event(page_id, event_was_handled);
  234. }
  235. void ConnectionFromClient::debug_request(u64 page_id, ByteString const& request, ByteString const& argument)
  236. {
  237. auto page = this->page(page_id);
  238. if (!page.has_value())
  239. return;
  240. if (request == "dump-session-history") {
  241. auto const& traversable = page->page().top_level_traversable();
  242. Web::dump_tree(*traversable);
  243. }
  244. if (request == "dump-dom-tree") {
  245. if (auto* doc = page->page().top_level_browsing_context().active_document())
  246. Web::dump_tree(*doc);
  247. return;
  248. }
  249. if (request == "dump-layout-tree") {
  250. if (auto* doc = page->page().top_level_browsing_context().active_document()) {
  251. if (auto* viewport = doc->layout_node())
  252. Web::dump_tree(*viewport);
  253. }
  254. return;
  255. }
  256. if (request == "dump-paint-tree") {
  257. if (auto* doc = page->page().top_level_browsing_context().active_document()) {
  258. if (auto* paintable = doc->paintable())
  259. Web::dump_tree(*paintable);
  260. }
  261. return;
  262. }
  263. if (request == "dump-stacking-context-tree") {
  264. if (auto* doc = page->page().top_level_browsing_context().active_document()) {
  265. if (auto* viewport = doc->layout_node()) {
  266. if (auto* stacking_context = viewport->paintable_box()->stacking_context())
  267. stacking_context->dump();
  268. }
  269. }
  270. return;
  271. }
  272. if (request == "dump-style-sheets") {
  273. if (auto* doc = page->page().top_level_browsing_context().active_document()) {
  274. for (auto& sheet : doc->style_sheets().sheets()) {
  275. if (auto result = Web::dump_sheet(sheet); result.is_error())
  276. dbgln("Failed to dump style sheets: {}", result.error());
  277. }
  278. }
  279. return;
  280. }
  281. if (request == "dump-all-resolved-styles") {
  282. if (auto* doc = page->page().top_level_browsing_context().active_document()) {
  283. Queue<Web::DOM::Node*> elements_to_visit;
  284. elements_to_visit.enqueue(doc->document_element());
  285. while (!elements_to_visit.is_empty()) {
  286. auto element = elements_to_visit.dequeue();
  287. for (auto& child : element->children_as_vector())
  288. elements_to_visit.enqueue(child.ptr());
  289. if (element->is_element()) {
  290. auto styles = doc->style_computer().compute_style(*static_cast<Web::DOM::Element*>(element));
  291. dbgln("+ Element {}", element->debug_description());
  292. auto& properties = styles->properties();
  293. for (size_t i = 0; i < properties.size(); ++i)
  294. dbgln("| {} = {}", Web::CSS::string_from_property_id(static_cast<Web::CSS::PropertyID>(i)), properties[i].style ? properties[i].style->to_string() : ""_string);
  295. dbgln("---");
  296. }
  297. }
  298. }
  299. return;
  300. }
  301. if (request == "collect-garbage") {
  302. Web::Bindings::main_thread_vm().heap().collect_garbage(JS::Heap::CollectionType::CollectGarbage, true);
  303. return;
  304. }
  305. if (request == "set-line-box-borders") {
  306. bool state = argument == "on";
  307. page->set_should_show_line_box_borders(state);
  308. page->page().top_level_traversable()->set_needs_display(page->page().top_level_traversable()->viewport_rect());
  309. return;
  310. }
  311. if (request == "clear-cache") {
  312. Web::ResourceLoader::the().clear_cache();
  313. return;
  314. }
  315. if (request == "spoof-user-agent") {
  316. Web::ResourceLoader::the().set_user_agent(MUST(String::from_byte_string(argument)));
  317. return;
  318. }
  319. if (request == "same-origin-policy") {
  320. page->page().set_same_origin_policy_enabled(argument == "on");
  321. return;
  322. }
  323. if (request == "scripting") {
  324. page->page().set_is_scripting_enabled(argument == "on");
  325. return;
  326. }
  327. if (request == "block-pop-ups") {
  328. page->page().set_should_block_pop_ups(argument == "on");
  329. return;
  330. }
  331. if (request == "dump-local-storage") {
  332. if (auto* document = page->page().top_level_browsing_context().active_document())
  333. document->window()->local_storage().release_value_but_fixme_should_propagate_errors()->dump();
  334. return;
  335. }
  336. if (request == "load-reference-page") {
  337. if (auto* document = page->page().top_level_browsing_context().active_document()) {
  338. auto maybe_link = document->query_selector("link[rel=match]"sv);
  339. if (maybe_link.is_error() || !maybe_link.value()) {
  340. // To make sure that we fail the ref-test if the link is missing, load the error page->
  341. load_html(page_id, "<h1>Failed to find &lt;link rel=&quot;match&quot; /&gt; in ref test page!</h1> Make sure you added it.");
  342. } else {
  343. auto link = maybe_link.release_value();
  344. auto url = document->parse_url(link->get_attribute_value(Web::HTML::AttributeNames::href));
  345. load_url(page_id, url);
  346. }
  347. }
  348. return;
  349. }
  350. }
  351. void ConnectionFromClient::get_source(u64 page_id)
  352. {
  353. if (auto page = this->page(page_id); page.has_value()) {
  354. if (auto* doc = page->page().top_level_browsing_context().active_document())
  355. async_did_get_source(page_id, doc->url(), doc->source().to_byte_string());
  356. }
  357. }
  358. void ConnectionFromClient::inspect_dom_tree(u64 page_id)
  359. {
  360. if (auto page = this->page(page_id); page.has_value()) {
  361. if (auto* doc = page->page().top_level_browsing_context().active_document())
  362. async_did_inspect_dom_tree(page_id, doc->dump_dom_tree_as_json().to_byte_string());
  363. }
  364. }
  365. void ConnectionFromClient::inspect_dom_node(u64 page_id, i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> const& pseudo_element)
  366. {
  367. auto page = this->page(page_id);
  368. if (!page.has_value())
  369. return;
  370. auto& top_context = page->page().top_level_browsing_context();
  371. top_context.for_each_in_inclusive_subtree([&](auto& ctx) {
  372. if (ctx.active_document() != nullptr) {
  373. ctx.active_document()->set_inspected_node(nullptr, {});
  374. }
  375. return Web::TraversalDecision::Continue;
  376. });
  377. Web::DOM::Node* node = Web::DOM::Node::from_unique_id(node_id);
  378. // Note: Nodes without layout (aka non-visible nodes, don't have style computed)
  379. if (!node || !node->layout_node()) {
  380. async_did_inspect_dom_node(page_id, false, {}, {}, {}, {}, {});
  381. return;
  382. }
  383. node->document().set_inspected_node(node, pseudo_element);
  384. if (node->is_element()) {
  385. auto& element = verify_cast<Web::DOM::Element>(*node);
  386. if (!element.computed_css_values()) {
  387. async_did_inspect_dom_node(page_id, false, {}, {}, {}, {}, {});
  388. return;
  389. }
  390. auto serialize_json = [](Web::CSS::StyleProperties const& properties) -> ByteString {
  391. StringBuilder builder;
  392. auto serializer = MUST(JsonObjectSerializer<>::try_create(builder));
  393. properties.for_each_property([&](auto property_id, auto& value) {
  394. MUST(serializer.add(Web::CSS::string_from_property_id(property_id), value.to_string().to_byte_string()));
  395. });
  396. MUST(serializer.finish());
  397. return builder.to_byte_string();
  398. };
  399. auto serialize_custom_properties_json = [](Web::DOM::Element const& element, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element) -> ByteString {
  400. StringBuilder builder;
  401. auto serializer = MUST(JsonObjectSerializer<>::try_create(builder));
  402. HashTable<FlyString> seen_properties;
  403. auto const* element_to_check = &element;
  404. while (element_to_check) {
  405. for (auto const& property : element_to_check->custom_properties(pseudo_element)) {
  406. if (!seen_properties.contains(property.key)) {
  407. seen_properties.set(property.key);
  408. MUST(serializer.add(property.key, property.value.value->to_string()));
  409. }
  410. }
  411. element_to_check = element_to_check->parent_element();
  412. }
  413. MUST(serializer.finish());
  414. return builder.to_byte_string();
  415. };
  416. auto serialize_node_box_sizing_json = [](Web::Layout::Node const* layout_node) -> ByteString {
  417. if (!layout_node || !layout_node->is_box()) {
  418. return "{}";
  419. }
  420. auto* box = static_cast<Web::Layout::Box const*>(layout_node);
  421. auto box_model = box->box_model();
  422. StringBuilder builder;
  423. auto serializer = MUST(JsonObjectSerializer<>::try_create(builder));
  424. MUST(serializer.add("padding_top"sv, box_model.padding.top.to_double()));
  425. MUST(serializer.add("padding_right"sv, box_model.padding.right.to_double()));
  426. MUST(serializer.add("padding_bottom"sv, box_model.padding.bottom.to_double()));
  427. MUST(serializer.add("padding_left"sv, box_model.padding.left.to_double()));
  428. MUST(serializer.add("margin_top"sv, box_model.margin.top.to_double()));
  429. MUST(serializer.add("margin_right"sv, box_model.margin.right.to_double()));
  430. MUST(serializer.add("margin_bottom"sv, box_model.margin.bottom.to_double()));
  431. MUST(serializer.add("margin_left"sv, box_model.margin.left.to_double()));
  432. MUST(serializer.add("border_top"sv, box_model.border.top.to_double()));
  433. MUST(serializer.add("border_right"sv, box_model.border.right.to_double()));
  434. MUST(serializer.add("border_bottom"sv, box_model.border.bottom.to_double()));
  435. MUST(serializer.add("border_left"sv, box_model.border.left.to_double()));
  436. if (auto* paintable_box = box->paintable_box()) {
  437. MUST(serializer.add("content_width"sv, paintable_box->content_width().to_double()));
  438. MUST(serializer.add("content_height"sv, paintable_box->content_height().to_double()));
  439. } else {
  440. MUST(serializer.add("content_width"sv, 0));
  441. MUST(serializer.add("content_height"sv, 0));
  442. }
  443. MUST(serializer.finish());
  444. return builder.to_byte_string();
  445. };
  446. auto serialize_aria_properties_state_json = [](Web::DOM::Element const& element) -> ByteString {
  447. auto role_name = element.role_or_default();
  448. if (!role_name.has_value()) {
  449. return "";
  450. }
  451. auto aria_data = MUST(Web::ARIA::AriaData::build_data(element));
  452. auto role = MUST(Web::ARIA::RoleType::build_role_object(role_name.value(), element.is_focusable(), *aria_data));
  453. StringBuilder builder;
  454. auto serializer = MUST(JsonObjectSerializer<>::try_create(builder));
  455. MUST(role->serialize_as_json(serializer));
  456. MUST(serializer.finish());
  457. return builder.to_byte_string();
  458. };
  459. if (pseudo_element.has_value()) {
  460. auto pseudo_element_node = element.get_pseudo_element_node(pseudo_element.value());
  461. if (!pseudo_element_node) {
  462. async_did_inspect_dom_node(page_id, false, {}, {}, {}, {}, {});
  463. return;
  464. }
  465. // FIXME: Pseudo-elements only exist as Layout::Nodes, which don't have style information
  466. // in a format we can use. So, we run the StyleComputer again to get the specified
  467. // values, and have to ignore the computed values and custom properties.
  468. auto pseudo_element_style = page->page().focused_navigable().active_document()->style_computer().compute_style(element, pseudo_element);
  469. ByteString computed_values = serialize_json(pseudo_element_style);
  470. ByteString resolved_values = "{}";
  471. ByteString custom_properties_json = serialize_custom_properties_json(element, pseudo_element);
  472. ByteString node_box_sizing_json = serialize_node_box_sizing_json(pseudo_element_node.ptr());
  473. async_did_inspect_dom_node(page_id, true, move(computed_values), move(resolved_values), move(custom_properties_json), move(node_box_sizing_json), {});
  474. return;
  475. }
  476. ByteString computed_values = serialize_json(*element.computed_css_values());
  477. ByteString resolved_values = serialize_json(element.resolved_css_values());
  478. ByteString custom_properties_json = serialize_custom_properties_json(element, {});
  479. ByteString node_box_sizing_json = serialize_node_box_sizing_json(element.layout_node());
  480. ByteString aria_properties_state_json = serialize_aria_properties_state_json(element);
  481. async_did_inspect_dom_node(page_id, true, move(computed_values), move(resolved_values), move(custom_properties_json), move(node_box_sizing_json), move(aria_properties_state_json));
  482. return;
  483. }
  484. async_did_inspect_dom_node(page_id, false, {}, {}, {}, {}, {});
  485. }
  486. void ConnectionFromClient::inspect_accessibility_tree(u64 page_id)
  487. {
  488. if (auto page = this->page(page_id); page.has_value()) {
  489. if (auto* doc = page->page().top_level_browsing_context().active_document())
  490. async_did_inspect_accessibility_tree(page_id, doc->dump_accessibility_tree_as_json().to_byte_string());
  491. }
  492. }
  493. void ConnectionFromClient::get_hovered_node_id(u64 page_id)
  494. {
  495. auto page = this->page(page_id);
  496. if (!page.has_value())
  497. return;
  498. i32 node_id = 0;
  499. if (auto* document = page->page().top_level_browsing_context().active_document()) {
  500. if (auto* hovered_node = document->hovered_node())
  501. node_id = hovered_node->unique_id();
  502. }
  503. async_did_get_hovered_node_id(page_id, node_id);
  504. }
  505. void ConnectionFromClient::set_dom_node_text(u64 page_id, i32 node_id, String const& text)
  506. {
  507. auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
  508. if (!dom_node || (!dom_node->is_text() && !dom_node->is_comment())) {
  509. async_did_finish_editing_dom_node(page_id, {});
  510. return;
  511. }
  512. auto& character_data = static_cast<Web::DOM::CharacterData&>(*dom_node);
  513. character_data.set_data(text);
  514. async_did_finish_editing_dom_node(page_id, character_data.unique_id());
  515. }
  516. void ConnectionFromClient::set_dom_node_tag(u64 page_id, i32 node_id, String const& name)
  517. {
  518. auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
  519. if (!dom_node || !dom_node->is_element() || !dom_node->parent()) {
  520. async_did_finish_editing_dom_node(page_id, {});
  521. return;
  522. }
  523. auto& element = static_cast<Web::DOM::Element&>(*dom_node);
  524. auto new_element = Web::DOM::create_element(element.document(), name, element.namespace_uri(), element.prefix(), element.is_value()).release_value_but_fixme_should_propagate_errors();
  525. element.for_each_attribute([&](auto const& attribute) {
  526. new_element->set_attribute_value(attribute.local_name(), attribute.value(), attribute.prefix(), attribute.namespace_uri());
  527. });
  528. while (auto* child_node = element.first_child()) {
  529. MUST(element.remove_child(*child_node));
  530. MUST(new_element->append_child(*child_node));
  531. }
  532. element.parent()->replace_child(*new_element, element).release_value_but_fixme_should_propagate_errors();
  533. async_did_finish_editing_dom_node(page_id, new_element->unique_id());
  534. }
  535. void ConnectionFromClient::add_dom_node_attributes(u64 page_id, i32 node_id, Vector<WebView::Attribute> const& attributes)
  536. {
  537. auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
  538. if (!dom_node || !dom_node->is_element()) {
  539. async_did_finish_editing_dom_node(page_id, {});
  540. return;
  541. }
  542. auto& element = static_cast<Web::DOM::Element&>(*dom_node);
  543. for (auto const& attribute : attributes)
  544. element.set_attribute(attribute.name, attribute.value).release_value_but_fixme_should_propagate_errors();
  545. async_did_finish_editing_dom_node(page_id, element.unique_id());
  546. }
  547. void ConnectionFromClient::replace_dom_node_attribute(u64 page_id, i32 node_id, String const& name, Vector<WebView::Attribute> const& replacement_attributes)
  548. {
  549. auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
  550. if (!dom_node || !dom_node->is_element()) {
  551. async_did_finish_editing_dom_node(page_id, {});
  552. return;
  553. }
  554. auto& element = static_cast<Web::DOM::Element&>(*dom_node);
  555. bool should_remove_attribute = true;
  556. for (auto const& attribute : replacement_attributes) {
  557. if (should_remove_attribute && Web::Infra::is_ascii_case_insensitive_match(name, attribute.name))
  558. should_remove_attribute = false;
  559. element.set_attribute(attribute.name, attribute.value).release_value_but_fixme_should_propagate_errors();
  560. }
  561. if (should_remove_attribute)
  562. element.remove_attribute(name);
  563. async_did_finish_editing_dom_node(page_id, element.unique_id());
  564. }
  565. void ConnectionFromClient::create_child_element(u64 page_id, i32 node_id)
  566. {
  567. auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
  568. if (!dom_node) {
  569. async_did_finish_editing_dom_node(page_id, {});
  570. return;
  571. }
  572. auto element = Web::DOM::create_element(dom_node->document(), Web::HTML::TagNames::div, Web::Namespace::HTML).release_value_but_fixme_should_propagate_errors();
  573. dom_node->append_child(element).release_value_but_fixme_should_propagate_errors();
  574. async_did_finish_editing_dom_node(page_id, element->unique_id());
  575. }
  576. void ConnectionFromClient::create_child_text_node(u64 page_id, i32 node_id)
  577. {
  578. auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
  579. if (!dom_node) {
  580. async_did_finish_editing_dom_node(page_id, {});
  581. return;
  582. }
  583. auto text_node = dom_node->heap().allocate<Web::DOM::Text>(dom_node->realm(), dom_node->document(), "text"_string);
  584. dom_node->append_child(text_node).release_value_but_fixme_should_propagate_errors();
  585. async_did_finish_editing_dom_node(page_id, text_node->unique_id());
  586. }
  587. void ConnectionFromClient::clone_dom_node(u64 page_id, i32 node_id)
  588. {
  589. auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
  590. if (!dom_node || !dom_node->parent_node()) {
  591. async_did_finish_editing_dom_node(page_id, {});
  592. return;
  593. }
  594. auto dom_node_clone = dom_node->clone_node(nullptr, true);
  595. dom_node->parent_node()->insert_before(dom_node_clone, dom_node->next_sibling());
  596. async_did_finish_editing_dom_node(page_id, dom_node_clone->unique_id());
  597. }
  598. void ConnectionFromClient::remove_dom_node(u64 page_id, i32 node_id)
  599. {
  600. auto page = this->page(page_id);
  601. if (!page.has_value())
  602. return;
  603. auto* active_document = page->page().top_level_browsing_context().active_document();
  604. if (!active_document) {
  605. async_did_finish_editing_dom_node(page_id, {});
  606. return;
  607. }
  608. auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
  609. if (!dom_node) {
  610. async_did_finish_editing_dom_node(page_id, {});
  611. return;
  612. }
  613. auto* previous_dom_node = dom_node->previous_sibling();
  614. if (!previous_dom_node)
  615. previous_dom_node = dom_node->parent();
  616. dom_node->remove();
  617. async_did_finish_editing_dom_node(page_id, previous_dom_node->unique_id());
  618. }
  619. void ConnectionFromClient::get_dom_node_html(u64 page_id, i32 node_id)
  620. {
  621. auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
  622. if (!dom_node)
  623. return;
  624. String html;
  625. if (dom_node->is_element()) {
  626. auto const& element = static_cast<Web::DOM::Element const&>(*dom_node);
  627. html = element.outer_html().release_value_but_fixme_should_propagate_errors();
  628. } else if (dom_node->is_text() || dom_node->is_comment()) {
  629. auto const& character_data = static_cast<Web::DOM::CharacterData const&>(*dom_node);
  630. html = character_data.data();
  631. } else {
  632. return;
  633. }
  634. async_did_get_dom_node_html(page_id, move(html));
  635. }
  636. void ConnectionFromClient::take_document_screenshot(u64 page_id)
  637. {
  638. auto page = this->page(page_id);
  639. if (!page.has_value())
  640. return;
  641. auto* document = page->page().top_level_browsing_context().active_document();
  642. if (!document || !document->document_element()) {
  643. async_did_take_screenshot(page_id, {});
  644. return;
  645. }
  646. auto const& content_size = page->content_size();
  647. Web::DevicePixelRect rect { { 0, 0 }, content_size };
  648. auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, rect.size().to_type<int>()).release_value_but_fixme_should_propagate_errors();
  649. page->paint(rect, *bitmap);
  650. async_did_take_screenshot(page_id, bitmap->to_shareable_bitmap());
  651. }
  652. void ConnectionFromClient::take_dom_node_screenshot(u64 page_id, i32 node_id)
  653. {
  654. auto page = this->page(page_id);
  655. if (!page.has_value())
  656. return;
  657. auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
  658. if (!dom_node || !dom_node->paintable_box()) {
  659. async_did_take_screenshot(page_id, {});
  660. return;
  661. }
  662. auto rect = page->page().enclosing_device_rect(dom_node->paintable_box()->absolute_border_box_rect());
  663. auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, rect.size().to_type<int>()).release_value_but_fixme_should_propagate_errors();
  664. page->paint(rect, *bitmap, { .paint_overlay = Web::PaintOptions::PaintOverlay::No });
  665. async_did_take_screenshot(page_id, bitmap->to_shareable_bitmap());
  666. }
  667. Messages::WebContentServer::DumpGcGraphResponse ConnectionFromClient::dump_gc_graph(u64)
  668. {
  669. auto gc_graph_json = Web::Bindings::main_thread_vm().heap().dump_graph();
  670. return MUST(String::from_byte_string(gc_graph_json.to_byte_string()));
  671. }
  672. Messages::WebContentServer::GetSelectedTextResponse ConnectionFromClient::get_selected_text(u64 page_id)
  673. {
  674. if (auto page = this->page(page_id); page.has_value())
  675. return page->page().focused_navigable().selected_text().to_byte_string();
  676. return ByteString {};
  677. }
  678. void ConnectionFromClient::select_all(u64 page_id)
  679. {
  680. if (auto page = this->page(page_id); page.has_value())
  681. page->page().focused_navigable().select_all();
  682. }
  683. void ConnectionFromClient::find_in_page(u64 page_id, String const& query, CaseSensitivity case_sensitivity)
  684. {
  685. auto page = this->page(page_id);
  686. if (!page.has_value())
  687. return;
  688. auto result = page->page().find_in_page(query, case_sensitivity);
  689. async_did_find_in_page(page_id, result.current_match_index, result.total_match_count);
  690. }
  691. void ConnectionFromClient::find_in_page_next_match(u64 page_id)
  692. {
  693. auto page = this->page(page_id);
  694. if (!page.has_value())
  695. return;
  696. auto result = page->page().find_in_page_next_match();
  697. async_did_find_in_page(page_id, result.current_match_index, result.total_match_count);
  698. }
  699. void ConnectionFromClient::find_in_page_previous_match(u64 page_id)
  700. {
  701. auto page = this->page(page_id);
  702. if (!page.has_value())
  703. return;
  704. auto result = page->page().find_in_page_previous_match();
  705. async_did_find_in_page(page_id, result.current_match_index, result.total_match_count);
  706. }
  707. void ConnectionFromClient::paste(u64 page_id, String const& text)
  708. {
  709. if (auto page = this->page(page_id); page.has_value())
  710. page->page().focused_navigable().paste(text);
  711. }
  712. Messages::WebContentServer::DumpLayoutTreeResponse ConnectionFromClient::dump_layout_tree(u64 page_id)
  713. {
  714. auto page = this->page(page_id);
  715. if (!page.has_value())
  716. return ByteString { "(no page)" };
  717. auto* document = page->page().top_level_browsing_context().active_document();
  718. if (!document)
  719. return ByteString { "(no DOM tree)" };
  720. document->update_layout();
  721. auto* layout_root = document->layout_node();
  722. if (!layout_root)
  723. return ByteString { "(no layout tree)" };
  724. StringBuilder builder;
  725. Web::dump_tree(builder, *layout_root);
  726. return builder.to_byte_string();
  727. }
  728. Messages::WebContentServer::DumpPaintTreeResponse ConnectionFromClient::dump_paint_tree(u64 page_id)
  729. {
  730. auto page = this->page(page_id);
  731. if (!page.has_value())
  732. return ByteString { "(no page)" };
  733. auto* document = page->page().top_level_browsing_context().active_document();
  734. if (!document)
  735. return ByteString { "(no DOM tree)" };
  736. document->update_layout();
  737. auto* layout_root = document->layout_node();
  738. if (!layout_root)
  739. return ByteString { "(no layout tree)" };
  740. if (!layout_root->paintable())
  741. return ByteString { "(no paint tree)" };
  742. StringBuilder builder;
  743. Web::dump_tree(builder, *layout_root->paintable());
  744. return builder.to_byte_string();
  745. }
  746. Messages::WebContentServer::DumpTextResponse ConnectionFromClient::dump_text(u64 page_id)
  747. {
  748. auto page = this->page(page_id);
  749. if (!page.has_value())
  750. return ByteString { "(no page)" };
  751. auto* document = page->page().top_level_browsing_context().active_document();
  752. if (!document)
  753. return ByteString { "(no DOM tree)" };
  754. if (!document->body())
  755. return ByteString { "(no body)" };
  756. return document->body()->inner_text();
  757. }
  758. void ConnectionFromClient::set_content_filters(u64, Vector<String> const& filters)
  759. {
  760. Web::ContentFilter::the().set_patterns(filters).release_value_but_fixme_should_propagate_errors();
  761. }
  762. void ConnectionFromClient::set_autoplay_allowed_on_all_websites(u64)
  763. {
  764. auto& autoplay_allowlist = Web::PermissionsPolicy::AutoplayAllowlist::the();
  765. autoplay_allowlist.enable_globally();
  766. }
  767. void ConnectionFromClient::set_autoplay_allowlist(u64, Vector<String> const& allowlist)
  768. {
  769. auto& autoplay_allowlist = Web::PermissionsPolicy::AutoplayAllowlist::the();
  770. autoplay_allowlist.enable_for_origins(allowlist).release_value_but_fixme_should_propagate_errors();
  771. }
  772. void ConnectionFromClient::set_proxy_mappings(u64, Vector<ByteString> const& proxies, HashMap<ByteString, size_t> const& mappings)
  773. {
  774. auto keys = mappings.keys();
  775. quick_sort(keys, [&](auto& a, auto& b) { return a.length() < b.length(); });
  776. OrderedHashMap<ByteString, size_t> sorted_mappings;
  777. for (auto& key : keys) {
  778. auto value = *mappings.get(key);
  779. if (value >= proxies.size())
  780. continue;
  781. sorted_mappings.set(key, value);
  782. }
  783. Web::ProxyMappings::the().set_mappings(proxies, move(sorted_mappings));
  784. }
  785. void ConnectionFromClient::set_preferred_color_scheme(u64 page_id, Web::CSS::PreferredColorScheme const& color_scheme)
  786. {
  787. if (auto page = this->page(page_id); page.has_value())
  788. page->set_preferred_color_scheme(color_scheme);
  789. }
  790. void ConnectionFromClient::set_has_focus(u64 page_id, bool has_focus)
  791. {
  792. if (auto page = this->page(page_id); page.has_value())
  793. page->set_has_focus(has_focus);
  794. }
  795. void ConnectionFromClient::set_is_scripting_enabled(u64 page_id, bool is_scripting_enabled)
  796. {
  797. if (auto page = this->page(page_id); page.has_value())
  798. page->set_is_scripting_enabled(is_scripting_enabled);
  799. }
  800. void ConnectionFromClient::set_device_pixels_per_css_pixel(u64 page_id, float device_pixels_per_css_pixel)
  801. {
  802. if (auto page = this->page(page_id); page.has_value())
  803. page->set_device_pixels_per_css_pixel(device_pixels_per_css_pixel);
  804. }
  805. void ConnectionFromClient::set_window_position(u64 page_id, Web::DevicePixelPoint position)
  806. {
  807. if (auto page = this->page(page_id); page.has_value())
  808. page->set_window_position(position);
  809. }
  810. void ConnectionFromClient::set_window_size(u64 page_id, Web::DevicePixelSize size)
  811. {
  812. if (auto page = this->page(page_id); page.has_value())
  813. page->set_window_size(size);
  814. }
  815. Messages::WebContentServer::GetLocalStorageEntriesResponse ConnectionFromClient::get_local_storage_entries(u64 page_id)
  816. {
  817. auto page = this->page(page_id);
  818. if (!page.has_value())
  819. return OrderedHashMap<String, String> {};
  820. auto* document = page->page().top_level_browsing_context().active_document();
  821. auto local_storage = document->window()->local_storage().release_value_but_fixme_should_propagate_errors();
  822. return local_storage->map();
  823. }
  824. Messages::WebContentServer::GetSessionStorageEntriesResponse ConnectionFromClient::get_session_storage_entries(u64 page_id)
  825. {
  826. auto page = this->page(page_id);
  827. if (!page.has_value())
  828. return OrderedHashMap<String, String> {};
  829. auto* document = page->page().top_level_browsing_context().active_document();
  830. auto session_storage = document->window()->session_storage().release_value_but_fixme_should_propagate_errors();
  831. return session_storage->map();
  832. }
  833. void ConnectionFromClient::handle_file_return(u64, i32 error, Optional<IPC::File> const& file, i32 request_id)
  834. {
  835. auto file_request = m_requested_files.take(request_id);
  836. VERIFY(file_request.has_value());
  837. VERIFY(file_request.value().on_file_request_finish);
  838. file_request.value().on_file_request_finish(error != 0 ? Error::from_errno(error) : ErrorOr<i32> { file->take_fd() });
  839. }
  840. void ConnectionFromClient::request_file(u64 page_id, Web::FileRequest file_request)
  841. {
  842. i32 const id = last_id++;
  843. auto path = file_request.path();
  844. m_requested_files.set(id, move(file_request));
  845. async_did_request_file(page_id, path, id);
  846. }
  847. void ConnectionFromClient::set_system_visibility_state(u64 page_id, bool visible)
  848. {
  849. if (auto page = this->page(page_id); page.has_value()) {
  850. page->page().top_level_traversable()->set_system_visibility_state(
  851. visible
  852. ? Web::HTML::VisibilityState::Visible
  853. : Web::HTML::VisibilityState::Hidden);
  854. }
  855. }
  856. void ConnectionFromClient::js_console_input(u64 page_id, ByteString const& js_source)
  857. {
  858. auto page = this->page(page_id);
  859. if (!page.has_value())
  860. return;
  861. page->js_console_input(js_source);
  862. }
  863. void ConnectionFromClient::run_javascript(u64 page_id, ByteString const& js_source)
  864. {
  865. if (auto page = this->page(page_id); page.has_value())
  866. page->run_javascript(js_source);
  867. }
  868. void ConnectionFromClient::js_console_request_messages(u64 page_id, i32 start_index)
  869. {
  870. if (auto page = this->page(page_id); page.has_value())
  871. page->js_console_request_messages(start_index);
  872. }
  873. void ConnectionFromClient::alert_closed(u64 page_id)
  874. {
  875. if (auto page = this->page(page_id); page.has_value())
  876. page->page().alert_closed();
  877. }
  878. void ConnectionFromClient::confirm_closed(u64 page_id, bool accepted)
  879. {
  880. if (auto page = this->page(page_id); page.has_value())
  881. page->page().confirm_closed(accepted);
  882. }
  883. void ConnectionFromClient::prompt_closed(u64 page_id, Optional<String> const& response)
  884. {
  885. if (auto page = this->page(page_id); page.has_value())
  886. page->page().prompt_closed(response);
  887. }
  888. void ConnectionFromClient::color_picker_update(u64 page_id, Optional<Color> const& picked_color, Web::HTML::ColorPickerUpdateState const& state)
  889. {
  890. if (auto page = this->page(page_id); page.has_value())
  891. page->page().color_picker_update(picked_color, state);
  892. }
  893. void ConnectionFromClient::file_picker_closed(u64 page_id, Vector<Web::HTML::SelectedFile> const& selected_files)
  894. {
  895. if (auto page = this->page(page_id); page.has_value())
  896. page->page().file_picker_closed(const_cast<Vector<Web::HTML::SelectedFile>&>(selected_files));
  897. }
  898. void ConnectionFromClient::select_dropdown_closed(u64 page_id, Optional<u32> const& selected_item_id)
  899. {
  900. if (auto page = this->page(page_id); page.has_value())
  901. page->page().select_dropdown_closed(selected_item_id);
  902. }
  903. void ConnectionFromClient::toggle_media_play_state(u64 page_id)
  904. {
  905. if (auto page = this->page(page_id); page.has_value())
  906. page->page().toggle_media_play_state().release_value_but_fixme_should_propagate_errors();
  907. }
  908. void ConnectionFromClient::toggle_media_mute_state(u64 page_id)
  909. {
  910. if (auto page = this->page(page_id); page.has_value())
  911. page->page().toggle_media_mute_state();
  912. }
  913. void ConnectionFromClient::toggle_media_loop_state(u64 page_id)
  914. {
  915. if (auto page = this->page(page_id); page.has_value())
  916. page->page().toggle_media_loop_state().release_value_but_fixme_should_propagate_errors();
  917. }
  918. void ConnectionFromClient::toggle_media_controls_state(u64 page_id)
  919. {
  920. if (auto page = this->page(page_id); page.has_value())
  921. page->page().toggle_media_controls_state().release_value_but_fixme_should_propagate_errors();
  922. }
  923. void ConnectionFromClient::toggle_page_mute_state(u64 page_id)
  924. {
  925. if (auto page = this->page(page_id); page.has_value())
  926. page->page().toggle_page_mute_state();
  927. }
  928. void ConnectionFromClient::set_user_style(u64 page_id, String const& source)
  929. {
  930. if (auto page = this->page(page_id); page.has_value())
  931. page->page().set_user_style(source);
  932. }
  933. void ConnectionFromClient::enable_inspector_prototype(u64)
  934. {
  935. Web::HTML::Window::set_inspector_object_exposed(true);
  936. }
  937. }