mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibDevTools: Implement enough of the protocol to inspect tabs
There is a lot needed all at once to actually inspect a tab's DOM tree. It begins with requesting a "watcher" from a TabActor. It seems there can be many types of watchers, but here we implement the "frame" watcher only. The watcher creates an "inspector", which in turn creates a "walker", which is the actor ultimately responsible for serializing and inspecting the DOM tree. In between all that, the DevTools client will send a handful of other informational requests. If we do not reply to these, the client will not move forward with the walker. For example, the CSSPropertiesActor will be asked for a list of all known CSS properties.
This commit is contained in:
parent
b974e91731
commit
5ed91dc915
Notes:
github-actions[bot]
2025-02-19 13:47:12 +00:00
Author: https://github.com/trflynn89
Commit: 5ed91dc915
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3589
Reviewed-by: https://github.com/ADKaster
25 changed files with 1278 additions and 0 deletions
58
Libraries/LibDevTools/Actors/CSSPropertiesActor.cpp
Normal file
58
Libraries/LibDevTools/Actors/CSSPropertiesActor.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/JsonArray.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <LibDevTools/Actors/CSSPropertiesActor.h>
|
||||
#include <LibDevTools/DevToolsDelegate.h>
|
||||
#include <LibDevTools/DevToolsServer.h>
|
||||
|
||||
namespace DevTools {
|
||||
|
||||
NonnullRefPtr<CSSPropertiesActor> CSSPropertiesActor::create(DevToolsServer& devtools, ByteString name)
|
||||
{
|
||||
return adopt_ref(*new CSSPropertiesActor(devtools, move(name)));
|
||||
}
|
||||
|
||||
CSSPropertiesActor::CSSPropertiesActor(DevToolsServer& devtools, ByteString name)
|
||||
: Actor(devtools, move(name))
|
||||
{
|
||||
}
|
||||
|
||||
CSSPropertiesActor::~CSSPropertiesActor() = default;
|
||||
|
||||
void CSSPropertiesActor::handle_message(StringView type, JsonObject const&)
|
||||
{
|
||||
JsonObject response;
|
||||
response.set("from"sv, name());
|
||||
|
||||
if (type == "getCSSDatabase"sv) {
|
||||
auto css_property_list = devtools().delegate().css_property_list();
|
||||
|
||||
JsonObject properties;
|
||||
|
||||
for (auto const& css_property : css_property_list) {
|
||||
JsonArray subproperties;
|
||||
subproperties.must_append(css_property.name);
|
||||
|
||||
JsonObject property;
|
||||
property.set("isInherited"sv, css_property.is_inherited);
|
||||
property.set("supports"sv, JsonArray {});
|
||||
property.set("values"sv, JsonArray {});
|
||||
property.set("subproperties"sv, move(subproperties));
|
||||
|
||||
properties.set(css_property.name, move(property));
|
||||
}
|
||||
|
||||
response.set("properties"sv, move(properties));
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue