mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-26 04:52:56 +00:00
When working on the Inspector's HTML, it's often kind of tricky to debug when an element is styled / positioned incorrectly. We don't have a way to inspect the Inspector itself. This adds a button to the Inspector to export its HTML/CSS/JS contents to the downloads directory. This allows for more easily testing changes, especially by opening the exported HTML in another browser's dev tools. We will ultimately likely remove this button (or make it hidden) by the time we are production-ready. But it's quite useful for now.
42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2023-2024, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Forward.h>
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
#include <LibWeb/WebIDL/Types.h>
|
|
|
|
namespace Web::Internals {
|
|
|
|
class Inspector final : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(Inspector, Bindings::PlatformObject);
|
|
JS_DECLARE_ALLOCATOR(Inspector);
|
|
|
|
public:
|
|
virtual ~Inspector() override;
|
|
|
|
void inspector_loaded();
|
|
void inspect_dom_node(i32 node_id, Optional<i32> const& pseudo_element);
|
|
|
|
void set_dom_node_text(i32 node_id, String const& text);
|
|
void set_dom_node_tag(i32 node_id, String const& tag);
|
|
void add_dom_node_attributes(i32 node_id, JS::NonnullGCPtr<DOM::NamedNodeMap> attributes);
|
|
void replace_dom_node_attribute(i32 node_id, WebIDL::UnsignedLongLong attribute_index, JS::NonnullGCPtr<DOM::NamedNodeMap> replacement_attributes);
|
|
|
|
void request_dom_tree_context_menu(i32 node_id, i32 client_x, i32 client_y, String const& type, Optional<String> const& tag, Optional<WebIDL::UnsignedLongLong> const& attribute_index);
|
|
|
|
void execute_console_script(String const& script);
|
|
|
|
void export_inspector_html(String const& html);
|
|
|
|
private:
|
|
explicit Inspector(JS::Realm&);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
};
|
|
|
|
}
|