class SemanticTree

Defined at line 35 of file ../../src/ui/a11y/lib/semantics/semantic_tree.h

A Semantic Tree represents the relationship of elements on an UI in the form of Semantic Nodes,

which are provided by runtimes and normally consumed by assistive technology.

This tree is always in a valid state, and accepts changes via calls to

Update(). An update can be applied to the tree if it leaves the tree in a

valid state, or rejected, if it leads to an invalid one.

It is also true for a tree to be considered valid:

1. It can be either empty or starts with a root which id is equal to kRootNodeId.

2. The tree is acyclic.

3. Every child id pointed by its parent must exist in the tree.

Public Members

static const uint32_t kRootNodeId
static const char[] kUpdateCountInspectNodeName
static const char[] kTreeDumpInspectPropertyName
static const char[] kTreeDumpFailedError

Public Methods

void ~SemanticTree ()

Defined at line 79 of file ../../src/ui/a11y/lib/semantics/semantic_tree.h

void set_action_handler (ActionHandlerCallback action_handler)

The two methods below set the handlers for dealing with assistive technology requests.

Defined at line 82 of file ../../src/ui/a11y/lib/semantics/semantic_tree.h

void set_hit_testing_handler (HitTestingHandlerCallback hit_testing_handler)

Defined at line 85 of file ../../src/ui/a11y/lib/semantics/semantic_tree.h

void set_semantics_event_callback (SemanticsEventCallback semantics_event_callback)

Sets callback invoked on semantics events.

Defined at line 90 of file ../../src/ui/a11y/lib/semantics/semantic_tree.h

size_t Size ()

Returns the number of nodes in this tree.

Defined at line 146 of file ../../src/ui/a11y/lib/semantics/semantic_tree.h

void SemanticTree (inspect::Node inspect_node)

A SemanticTree object is normally maintained by a semantics provider while

being consumed by a semantics consumer (such as a screen reader).

Defined at line 188 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

const fuchsia::accessibility::semantics::Node * GetNode (uint32_t node_id)

Returns the node with |node_id|, nullptr otherwise.

Defined at line 213 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

const fuchsia::accessibility::semantics::Node * GetNextNode (uint32_t node_id, a11y::NodeFilter filter)

Returns the next node for which |filter| returns true (in depth first manner) from the node

with |node_id|, or nullptr if none exists.

Note: Currently O(N). TODO(https://fxbug.dev/42060491): improve this.

Defined at line 221 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

const fuchsia::accessibility::semantics::Node * GetNextNode (uint32_t node_id, a11y::NodeFilterWithParent filter)

Defined at line 228 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

const fuchsia::accessibility::semantics::Node * GetPreviousNode (uint32_t node_id, a11y::NodeFilter filter)

Returns the previous node for which |filter| returns true (in depth first manner) from the node

with |node_id|, or nullptr if none exists.

Note: Currently O(N). TODO(https://fxbug.dev/42060491): improve this.

Defined at line 277 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

const fuchsia::accessibility::semantics::Node * GetPreviousNode (uint32_t node_id, a11y::NodeFilterWithParent filter)

Defined at line 284 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

const fuchsia::accessibility::semantics::Node * GetParentNode (uint32_t node_id)

Returns the parent node of the node with |node_id| if found, nullptr otherwise.

Currently O(N). TODO(https://fxbug.dev/42059816): improve this.

Defined at line 333 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

std::optional<SemanticTransform> GetNodeToRootTransform (uint32_t node_id)

Returns a SemanticTransform to transform node-local coordinates to

view logical space.

Defined at line 347 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

bool Update (TreeUpdates updates)

Applies the node updates in |updates| if they leave the final resulting

tree in a valid state, returning true if the operation was successful. If

the updates leave the resulting tree in an invalid state, the updates are

not applied and this method returns false.

A node can be either a full or a partial node. A full node is one where all

its values are filled. A partial node omits some field values, and is

intended to be merged with an existing one.

Updates can be loosely classified in three main categories:

1. Insertions: a new full node is being added with an node id that isn't

present on the tree.

2. Node partial update: a node which already exists on the tree is being

updated with new information. The new node is merged with the old one such

as all fields are copied from the new node if present, keeping the old ones

if not.

3. Deletion: a node is marked to be deleted from the tree.

Defined at line 483 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

void Clear ()

Clears all nodes of the tree.

Defined at line 588 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

void PerformAccessibilityAction (uint32_t node_id, fuchsia::accessibility::semantics::Action action, fuchsia::accessibility::semantics::SemanticListener::OnAccessibilityActionRequestedCallback callback)

Performs accessibility action on this tree. This request is passed to

|action_handler_| which is received at construction time.

Defined at line 594 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

void PerformHitTesting (fuchsia::math::PointF local_point, fuchsia::accessibility::semantics::SemanticListener::HitTestCallback callback)

Performs hit testing on this tree. This request is passed to

|hit_testing_handler_| which is received at construction time.

Defined at line 601 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

void OnSemanticsEvent (SemanticsEventInfo event_info)

Processes a semantic event that refers to this tree. The semantic event is passed to

|semantic_event_handler| to be processed, which is normally set in this object during

construction time.

Defined at line 931 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

std::string ToString ()

Debug aid.

- Do not rely on the concrete format for testing or any other purpose.

- Do not rely on this function being runtime efficient; it is not guaranteed to be.

Defined at line 881 of file ../../src/ui/a11y/lib/semantics/semantic_tree.cc

Records