1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:47:46 +00:00

LibWeb: Implement Accessible Name and Description Calculation

This is an initial implementation of the accname standard. There is
still some of the algorithm left unimplemented that we will need
to implement in the future. However, as is, this implementation is
sufficient for basic pages.
This commit is contained in:
Jonah 2023-02-05 11:21:59 -06:00 committed by Linus Groh
parent fc3ee471ed
commit da5c9189b2
2 changed files with 254 additions and 0 deletions

View file

@ -35,6 +35,11 @@ enum class NodeType : u16 {
NOTATION_NODE = 12
};
enum class NameOrDescription {
Name,
Description
};
struct GetRootNodeOptions {
bool composed { false };
};
@ -617,6 +622,9 @@ public:
return false;
}
ErrorOr<String> accessible_name(Document const&) const;
ErrorOr<String> accessible_description(Document const&) const;
protected:
Node(JS::Realm&, Document&, NodeType);
Node(Document&, NodeType);
@ -638,6 +646,8 @@ protected:
void build_accessibility_tree(AccessibilityTreeNode& parent) const;
ErrorOr<String> name_or_description(NameOrDescription, Document const&, HashTable<i32>&) const;
private:
void queue_tree_mutation_record(JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling);
@ -645,6 +655,12 @@ private:
void append_child_impl(JS::NonnullGCPtr<Node>);
void remove_child_impl(JS::NonnullGCPtr<Node>);
static Optional<StringView> first_valid_id(DeprecatedString const&, Document const&);
static ErrorOr<void> append_without_space(StringBuilder, StringView const&);
static ErrorOr<void> append_with_space(StringBuilder, StringView const&);
static ErrorOr<void> prepend_without_space(StringBuilder, StringView const&);
static ErrorOr<void> prepend_with_space(StringBuilder, StringView const&);
JS::GCPtr<Node> m_parent;
JS::GCPtr<Node> m_first_child;
JS::GCPtr<Node> m_last_child;