mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-24 00:49:46 +00:00
LibDevTools: Pull DOMNode type and related code into new Node.h
Accessibility nodes will share this code, so make it available, and rename DOMNode to Node.
This commit is contained in:
parent
eeb5446c1b
commit
d5fe7f7a98
Notes:
github-actions[bot]
2025-10-20 09:52:37 +00:00
Author: https://github.com/AtkinsSJ
Commit: d5fe7f7a98
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6462
Reviewed-by: https://github.com/trflynn89
5 changed files with 57 additions and 34 deletions
47
Libraries/LibDevTools/Node.h
Normal file
47
Libraries/LibDevTools/Node.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/JsonObject.h>
|
||||
#include <LibDevTools/Actors/TabActor.h>
|
||||
#include <LibDevTools/Forward.h>
|
||||
#include <LibWeb/CSS/PseudoElement.h>
|
||||
#include <LibWeb/DOM/NodeType.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace DevTools {
|
||||
|
||||
struct DEVTOOLS_API NodeIdentifier {
|
||||
static NodeIdentifier for_node(JsonObject const& node);
|
||||
|
||||
bool operator==(NodeIdentifier const&) const = default;
|
||||
|
||||
Web::UniqueNodeID id { 0 };
|
||||
Optional<Web::CSS::PseudoElement> pseudo_element;
|
||||
};
|
||||
|
||||
struct DEVTOOLS_API Node {
|
||||
JsonObject const& node;
|
||||
NodeIdentifier identifier;
|
||||
NonnullRefPtr<TabActor> tab;
|
||||
};
|
||||
|
||||
static constexpr Web::DOM::NodeType parse_dom_node_type(StringView type)
|
||||
{
|
||||
if (type == "document"sv)
|
||||
return Web::DOM::NodeType::DOCUMENT_NODE;
|
||||
if (type == "element"sv)
|
||||
return Web::DOM::NodeType::ELEMENT_NODE;
|
||||
if (type == "text"sv)
|
||||
return Web::DOM::NodeType::TEXT_NODE;
|
||||
if (type == "comment"sv)
|
||||
return Web::DOM::NodeType::COMMENT_NODE;
|
||||
return Web::DOM::NodeType::INVALID;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue