mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
LibWeb+LibWebView+WebContent: Add an Inspector IDL object to the Window
This is an internal object that must be explicitly enabled by the chrome before it is added to the Window. The Inspector object will be used by a special WebView that will replace all chrome-specific inspector windows. The IDL defines methods that this WebView will need to inform the chrome of various events, such as the user clicking a DOM node.
This commit is contained in:
parent
30e96749de
commit
ffdc2d8add
21 changed files with 156 additions and 1 deletions
50
Userland/Libraries/LibWeb/Internals/Inspector.cpp
Normal file
50
Userland/Libraries/LibWeb/Internals/Inspector.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Bindings/InspectorPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Internals/Inspector.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
|
||||
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<Bindings::InspectorPrototype>(realm, "Inspector"));
|
||||
}
|
||||
|
||||
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<i32> 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<Web::CSS::Selector::PseudoElement>(value);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue