mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
This is enough for Firefox to display the Accessibility tab, containing our accessibility tree which can be inspected. Most information is blank for now. There's quite a bit of duplication between AccessibilityWalkerActor and WalkerActor - it might be worth trying to make a base class once the details are figured out. Frustratingly, the two don't work quite the same: for a lot of messages that would be sent to WalkerActor, the accessibility equivalent is sent to the AccessibilityNodeActor instead. Co-authored-by: Tim Flynn <trflynn89@pm.me>
59 lines
1.7 KiB
C++
59 lines
1.7 KiB
C++
/*
|
|
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibDevTools/Actors/AccessibilityActor.h>
|
|
#include <LibDevTools/Actors/ParentAccessibilityActor.h>
|
|
#include <LibDevTools/DevToolsServer.h>
|
|
|
|
namespace DevTools {
|
|
|
|
NonnullRefPtr<ParentAccessibilityActor> ParentAccessibilityActor::create(DevToolsServer& devtools, String name)
|
|
{
|
|
return adopt_ref(*new ParentAccessibilityActor(devtools, move(name)));
|
|
}
|
|
|
|
ParentAccessibilityActor::ParentAccessibilityActor(DevToolsServer& devtools, String name)
|
|
: Actor(devtools, move(name))
|
|
{
|
|
}
|
|
|
|
ParentAccessibilityActor::~ParentAccessibilityActor() = default;
|
|
|
|
void ParentAccessibilityActor::handle_message(Message const& message)
|
|
{
|
|
if (message.type == "bootstrap"sv) {
|
|
JsonObject state;
|
|
state.set("canBeDisabled"sv, true);
|
|
state.set("canBeEnabled"sv, true);
|
|
|
|
JsonObject response;
|
|
response.set("state"sv, move(state));
|
|
send_response(message, move(response));
|
|
return;
|
|
}
|
|
|
|
if (message.type == "enable"sv) {
|
|
// First, a change event
|
|
JsonObject response;
|
|
response.set("canBeDisabled"sv, true);
|
|
response.set("type"sv, "canBeDisabledChange"sv);
|
|
send_response(message, move(response));
|
|
|
|
// Then a blank message is expected
|
|
send_message(JsonObject {});
|
|
|
|
// Then each AccessibilityActor is enabled and sends an "init" message
|
|
for (auto const& [name, actor] : devtools().actor_registry()) {
|
|
if (auto* accessibility_actor = as_if<AccessibilityActor>(*actor))
|
|
accessibility_actor->enable();
|
|
}
|
|
return;
|
|
}
|
|
|
|
send_unrecognized_packet_type_error(message);
|
|
}
|
|
|
|
}
|