/* * Copyright (c) 2023, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include #include #include #include namespace Web::Internals { JS_DEFINE_ALLOCATOR(Inspector); Inspector::Inspector(JS::Realm& realm) : Bindings::PlatformObject(realm) { } Inspector::~Inspector() = default; void Inspector::initialize(JS::Realm& realm) { Base::initialize(realm); Object::set_prototype(&Bindings::ensure_web_prototype(realm, "Inspector"_fly_string)); } void Inspector::inspector_loaded() { if (auto* page = global_object().browsing_context()->page()) page->client().inspector_did_load(); } void Inspector::inspect_dom_node(i32 node_id, Optional const& pseudo_element) { if (auto* page = global_object().browsing_context()->page()) { page->client().inspector_did_select_dom_node(node_id, pseudo_element.map([](auto value) { VERIFY(value < to_underlying(Web::CSS::Selector::PseudoElement::PseudoElementCount)); return static_cast(value); })); } } void Inspector::execute_console_script(String const& script) { if (auto* page = global_object().browsing_context()->page()) page->client().inspector_did_execute_console_script(script); } }