Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
flutter::FlutterPlatformNodeDelegate Class Reference

#include <flutter_platform_node_delegate.h>

Inheritance diagram for flutter::FlutterPlatformNodeDelegate:
ui::AXPlatformNodeDelegateBase ui::AXPlatformNodeDelegate flutter::FlutterPlatformNodeDelegateMac flutter::FlutterPlatformNodeDelegateWindows

Classes

class  OwnerBridge
 

Public Member Functions

 FlutterPlatformNodeDelegate ()
 
virtual ~FlutterPlatformNodeDelegate () override
 
const ui::AXUniqueIdGetUniqueId () const override
 
const ui::AXNodeDataGetData () const override
 
bool AccessibilityPerformAction (const ui::AXActionData &data) override
 
gfx::NativeViewAccessible GetParent () override
 
gfx::NativeViewAccessible GetFocus () override
 
int GetChildCount () const override
 
gfx::NativeViewAccessible ChildAtIndex (int index) override
 
gfx::Rect GetBoundsRect (const ui::AXCoordinateSystem coordinate_system, const ui::AXClippingBehavior clipping_behavior, ui::AXOffscreenResult *offscreen_result) const override
 
gfx::NativeViewAccessible GetLowestPlatformAncestor () const override
 
ui::AXNodePosition::AXPositionInstance CreateTextPositionAt (int offset) const override
 
virtual void Init (std::weak_ptr< OwnerBridge > bridge, ui::AXNode *node)
 Called only once, immediately after construction. The constructor doesn't take any arguments because in the Windows subclass we use a special function to construct a COM object. Subclasses must call super.
 
ui::AXNodeGetAXNode () const
 Gets the underlying ax node for this platform node delegate.
 
std::weak_ptr< OwnerBridgeGetOwnerBridge () const
 Gets the owner of this platform node delegate. This is useful when you want to get the information about surrounding nodes of this platform node delegate, e.g. the global rect of this platform node delegate. This pointer is only safe in the platform thread.
 
virtual ui::AXPlatformNodeGetPlatformNode () const
 
virtual ui::AXPlatformNodeGetFromNodeID (int32_t id) override
 
virtual ui::AXPlatformNodeGetFromTreeIDAndNodeID (const ui::AXTreeID &tree_id, int32_t node_id) override
 
virtual const ui::AXTree::Selection GetUnignoredSelection () const override
 
- Public Member Functions inherited from ui::AXPlatformNodeDelegateBase
 AXPlatformNodeDelegateBase ()
 
 ~AXPlatformNodeDelegateBase () override
 
const AXTreeDataGetTreeData () const override
 
std::u16string GetInnerText () const override
 
gfx::NativeViewAccessible GetNSWindow () override
 
gfx::NativeViewAccessible GetNativeViewAccessible () override
 
int GetIndexInParent () override
 
bool HasModalDialog () const override
 
gfx::NativeViewAccessible GetFirstChild () override
 
gfx::NativeViewAccessible GetLastChild () override
 
gfx::NativeViewAccessible GetNextSibling () override
 
gfx::NativeViewAccessible GetPreviousSibling () override
 
bool IsChildOfLeaf () const override
 
bool IsChildOfPlainTextField () const override
 
bool IsLeaf () const override
 
bool IsToplevelBrowserWindow () override
 
gfx::NativeViewAccessible GetClosestPlatformObject () const override
 
std::unique_ptr< AXPlatformNodeDelegate::ChildIteratorChildrenBegin () override
 
std::unique_ptr< AXPlatformNodeDelegate::ChildIteratorChildrenEnd () override
 
std::string GetName () const override
 
std::u16string GetHypertext () const override
 
bool SetHypertextSelection (int start_offset, int end_offset) override
 
TextAttributeMap ComputeTextAttributeMap (const TextAttributeList &default_attributes) const override
 
std::string GetInheritedFontFamilyName () const override
 
gfx::Rect GetHypertextRangeBoundsRect (const int start_offset, const int end_offset, const AXCoordinateSystem coordinate_system, const AXClippingBehavior clipping_behavior, AXOffscreenResult *offscreen_result) const override
 
gfx::Rect GetInnerTextRangeBoundsRect (const int start_offset, const int end_offset, const AXCoordinateSystem coordinate_system, const AXClippingBehavior clipping_behavior, AXOffscreenResult *offscreen_result) const override
 
gfx::Rect GetClippedScreenBoundsRect (AXOffscreenResult *offscreen_result=nullptr) const override
 
gfx::Rect GetUnclippedScreenBoundsRect (AXOffscreenResult *offscreen_result=nullptr) const
 
gfx::NativeViewAccessible HitTestSync (int screen_physical_pixel_x, int screen_physical_pixel_y) const override
 
bool IsOffscreen () const override
 
bool IsMinimized () const override
 
bool IsText () const override
 
bool IsWebContent () const override
 
bool HasVisibleCaretOrSelection () const override
 
AXPlatformNodeGetTargetNodeForRelation (ax::mojom::IntAttribute attr) override
 
std::vector< AXPlatformNode * > GetTargetNodesForRelation (ax::mojom::IntListAttribute attr) override
 
std::set< AXPlatformNode * > GetReverseRelations (ax::mojom::IntAttribute attr) override
 
std::set< AXPlatformNode * > GetReverseRelations (ax::mojom::IntListAttribute attr) override
 
std::u16string GetAuthorUniqueId () const override
 
std::optional< intFindTextBoundary (ax::mojom::TextBoundary boundary, int offset, ax::mojom::MoveDirection direction, ax::mojom::TextAffinity affinity) const override
 
const std::vector< gfx::NativeViewAccessibleGetUIADescendants () const override
 
std::string GetLanguage () const override
 
bool IsTable () const override
 
std::optional< intGetTableColCount () const override
 
std::optional< intGetTableRowCount () const override
 
std::optional< intGetTableAriaColCount () const override
 
std::optional< intGetTableAriaRowCount () const override
 
std::optional< intGetTableCellCount () const override
 
std::optional< bool > GetTableHasColumnOrRowHeaderNode () const override
 
std::vector< int32_t > GetColHeaderNodeIds () const override
 
std::vector< int32_t > GetColHeaderNodeIds (int col_index) const override
 
std::vector< int32_t > GetRowHeaderNodeIds () const override
 
std::vector< int32_t > GetRowHeaderNodeIds (int row_index) const override
 
AXPlatformNodeGetTableCaption () const override
 
bool IsTableRow () const override
 
std::optional< intGetTableRowRowIndex () const override
 
bool IsTableCellOrHeader () const override
 
std::optional< intGetTableCellIndex () const override
 
std::optional< intGetTableCellColIndex () const override
 
std::optional< intGetTableCellRowIndex () const override
 
std::optional< intGetTableCellColSpan () const override
 
std::optional< intGetTableCellRowSpan () const override
 
std::optional< intGetTableCellAriaColIndex () const override
 
std::optional< intGetTableCellAriaRowIndex () const override
 
std::optional< int32_t > GetCellId (int row_index, int col_index) const override
 
std::optional< int32_t > CellIndexToId (int cell_index) const override
 
bool IsCellOrHeaderOfARIATable () const override
 
bool IsCellOrHeaderOfARIAGrid () const override
 
bool IsOrderedSetItem () const override
 
bool IsOrderedSet () const override
 
std::optional< intGetPosInSet () const override
 
std::optional< intGetSetSize () const override
 
gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent () override
 
std::u16string GetLocalizedStringForImageAnnotationStatus (ax::mojom::ImageAnnotationStatus status) const override
 
std::u16string GetLocalizedRoleDescriptionForUnlabeledImage () const override
 
std::u16string GetLocalizedStringForLandmarkType () const override
 
std::u16string GetLocalizedStringForRoleDescription () const override
 
std::u16string GetStyleNameAttributeAsLocalizedString () const override
 
bool ShouldIgnoreHoveredStateForTesting () override
 
- Public Member Functions inherited from ui::AXPlatformNodeDelegate
virtual ~AXPlatformNodeDelegate ()=default
 
std::string ToString ()
 
std::string SubtreeToString ()
 

Additional Inherited Members

- Protected Member Functions inherited from ui::AXPlatformNodeDelegateBase
std::string SubtreeToStringHelper (size_t level) override
 
std::set< ui::AXPlatformNode * > GetNodesForNodeIds (const std::set< int32_t > &ids)
 
AXPlatformNodeDelegateGetParentDelegate ()
 
- Protected Member Functions inherited from ui::AXPlatformNodeDelegate
 AXPlatformNodeDelegate ()=default
 

Detailed Description

The platform node delegate to be used in accessibility bridge. This class is responsible for providing native accessibility object with appropriate information, such as accessibility label/value/bounds.

While most methods have default implementations and are ready to be used as-is, the subclasses must override the GetNativeViewAccessible to return native accessibility objects. To do that, subclasses should create and maintain AXPlatformNode[s] which delegate their accessibility attributes to this class.

For desktop platforms, subclasses also need to override the GetBoundsRect to apply window-to-screen transform.

This class transforms bounds assuming the device pixel ratio is 1.0. See the https://github.com/flutter/flutter/issues/74283 for more information.

Definition at line 33 of file flutter_platform_node_delegate.h.

Constructor & Destructor Documentation

◆ FlutterPlatformNodeDelegate()

flutter::FlutterPlatformNodeDelegate::FlutterPlatformNodeDelegate ( )
default

◆ ~FlutterPlatformNodeDelegate()

flutter::FlutterPlatformNodeDelegate::~FlutterPlatformNodeDelegate ( )
overridevirtualdefault

Member Function Documentation

◆ AccessibilityPerformAction()

bool flutter::FlutterPlatformNodeDelegate::AccessibilityPerformAction ( const ui::AXActionData data)
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Definition at line 30 of file flutter_platform_node_delegate.cc.

31 {
32 AccessibilityNodeId target = ax_node_->id();
33 auto bridge_ptr = bridge_.lock();
34 BASE_DCHECK(bridge_ptr);
35 switch (data.action) {
37 bridge_ptr->DispatchAccessibilityAction(
39 return true;
41 bridge_ptr->SetLastFocusedId(target);
42 bridge_ptr->DispatchAccessibilityAction(
43 target,
46 {});
47 return true;
49 bridge_ptr->DispatchAccessibilityAction(
51 {});
52 return true;
53 // TODO(chunhtai): support more actions.
54 default:
55 return false;
56 }
57 return false;
58}
AXID id() const
Definition ax_node.h:110
FlutterSemanticsAction
Definition embedder.h:113
@ kFlutterSemanticsActionShowOnScreen
A request to fully show the semantics node on screen.
Definition embedder.h:138
@ kFlutterSemanticsActionDidGainAccessibilityFocus
Indicate that the node has gained accessibility focus.
Definition embedder.h:152
@ kFlutterSemanticsActionTap
Definition embedder.h:116
uint32_t * target
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
ui::AXNode::AXID AccessibilityNodeId
#define BASE_DCHECK(condition)
Definition logging.h:63

◆ ChildAtIndex()

gfx::NativeViewAccessible flutter::FlutterPlatformNodeDelegate::ChildAtIndex ( int  index)
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Definition at line 87 of file flutter_platform_node_delegate.cc.

87 {
88 auto bridge_ptr = bridge_.lock();
89 BASE_DCHECK(bridge_ptr);
90 AccessibilityNodeId child = ax_node_->GetUnignoredChildAtIndex(index)->id();
91 return bridge_ptr->GetNativeAccessibleFromId(child);
92}
AXNode * GetUnignoredChildAtIndex(size_t index) const
Definition ax_node.cc:47

◆ CreateTextPositionAt()

ui::AXNodePosition::AXPositionInstance flutter::FlutterPlatformNodeDelegate::CreateTextPositionAt ( int  offset) const
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Definition at line 136 of file flutter_platform_node_delegate.cc.

136 {
138}
static AXPositionInstance CreatePosition(const AXNode &node, int child_index_or_text_offset, ax::mojom::TextAffinity affinity=ax::mojom::TextAffinity::kDownstream)
Point offset

◆ GetAXNode()

ui::AXNode * flutter::FlutterPlatformNodeDelegate::GetAXNode ( ) const

Gets the underlying ax node for this platform node delegate.

Definition at line 26 of file flutter_platform_node_delegate.cc.

26 {
27 return ax_node_;
28}

◆ GetBoundsRect()

gfx::Rect flutter::FlutterPlatformNodeDelegate::GetBoundsRect ( const ui::AXCoordinateSystem  coordinate_system,
const ui::AXClippingBehavior  clipping_behavior,
ui::AXOffscreenResult offscreen_result 
) const
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Reimplemented in flutter::FlutterPlatformNodeDelegateMac, and flutter::FlutterPlatformNodeDelegateWindows.

Definition at line 94 of file flutter_platform_node_delegate.cc.

97 {
98 auto bridge_ptr = bridge_.lock();
99 BASE_DCHECK(bridge_ptr);
100 // TODO(chunhtai): We need to apply screen dpr in here.
101 // https://github.com/flutter/flutter/issues/74283
102 const bool clip_bounds =
103 clipping_behavior == ui::AXClippingBehavior::kClipped;
104 bool offscreen = false;
106 bridge_ptr->RelativeToGlobalBounds(ax_node_, offscreen, clip_bounds);
107 if (offscreen_result != nullptr) {
108 *offscreen_result = offscreen ? ui::AXOffscreenResult::kOffscreen
110 }
111 return gfx::ToEnclosingRect(bounds);
112}
Optional< SkRect > bounds
Definition SkRecords.h:189
Rect ToEnclosingRect(const RectF &r)

◆ GetChildCount()

int flutter::FlutterPlatformNodeDelegate::GetChildCount ( ) const
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Definition at line 83 of file flutter_platform_node_delegate.cc.

83 {
84 return static_cast<int>(ax_node_->GetUnignoredChildCount());
85}
size_t GetUnignoredChildCount() const
Definition ax_node.cc:37

◆ GetData()

const ui::AXNodeData & flutter::FlutterPlatformNodeDelegate::GetData ( ) const
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Definition at line 60 of file flutter_platform_node_delegate.cc.

60 {
61 return ax_node_->data();
62}
const AXNodeData & data() const
Definition ax_node.h:112

◆ GetFocus()

gfx::NativeViewAccessible flutter::FlutterPlatformNodeDelegate::GetFocus ( )
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Definition at line 73 of file flutter_platform_node_delegate.cc.

73 {
74 auto bridge_ptr = bridge_.lock();
75 BASE_DCHECK(bridge_ptr);
76 AccessibilityNodeId last_focused = bridge_ptr->GetLastFocusedId();
77 if (last_focused == ui::AXNode::kInvalidAXID) {
78 return nullptr;
79 }
80 return bridge_ptr->GetNativeAccessibleFromId(last_focused);
81}
static constexpr AXID kInvalidAXID
Definition ax_node.h:41

◆ GetFromNodeID()

ui::AXPlatformNode * flutter::FlutterPlatformNodeDelegate::GetFromNodeID ( int32_t  id)
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Definition at line 140 of file flutter_platform_node_delegate.cc.

141 {
142 ui::AXTreeManager* tree_manager =
144 ax_node_->tree()->GetAXTreeID());
145 AccessibilityBridge* platform_manager =
146 static_cast<AccessibilityBridge*>(tree_manager);
147 return platform_manager->GetPlatformNodeFromTree(node_id);
148}
virtual AXTreeID GetAXTreeID() const =0
OwnerTree * tree() const
Definition ax_node.h:109
AXTreeManager * GetManager(AXTreeID tree_id)
static AXTreeManagerMap & GetInstance()

◆ GetFromTreeIDAndNodeID()

ui::AXPlatformNode * flutter::FlutterPlatformNodeDelegate::GetFromTreeIDAndNodeID ( const ui::AXTreeID tree_id,
int32_t  node_id 
)
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Definition at line 150 of file flutter_platform_node_delegate.cc.

152 {
153 ui::AXTreeManager* tree_manager =
155 AccessibilityBridge* platform_manager =
156 static_cast<AccessibilityBridge*>(tree_manager);
157 return platform_manager->GetPlatformNodeFromTree(node_id);
158}

◆ GetLowestPlatformAncestor()

gfx::NativeViewAccessible flutter::FlutterPlatformNodeDelegate::GetLowestPlatformAncestor ( ) const
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Definition at line 124 of file flutter_platform_node_delegate.cc.

124 {
125 auto bridge_ptr = bridge_.lock();
126 BASE_DCHECK(bridge_ptr);
127 auto lowest_platform_ancestor = ax_node_->GetLowestPlatformAncestor();
128 if (lowest_platform_ancestor) {
129 return bridge_ptr->GetNativeAccessibleFromId(
130 ax_node_->GetLowestPlatformAncestor()->id());
131 }
132 return nullptr;
133}
AXNode * GetLowestPlatformAncestor() const
Definition ax_node.cc:1202

◆ GetOwnerBridge()

std::weak_ptr< FlutterPlatformNodeDelegate::OwnerBridge > flutter::FlutterPlatformNodeDelegate::GetOwnerBridge ( ) const

Gets the owner of this platform node delegate. This is useful when you want to get the information about surrounding nodes of this platform node delegate, e.g. the global rect of this platform node delegate. This pointer is only safe in the platform thread.

Definition at line 115 of file flutter_platform_node_delegate.cc.

115 {
116 return bridge_;
117}

◆ GetParent()

gfx::NativeViewAccessible flutter::FlutterPlatformNodeDelegate::GetParent ( )
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Reimplemented in flutter::FlutterPlatformNodeDelegateMac.

Definition at line 64 of file flutter_platform_node_delegate.cc.

64 {
65 if (!ax_node_->parent()) {
66 return nullptr;
67 }
68 auto bridge_ptr = bridge_.lock();
69 BASE_DCHECK(bridge_ptr);
70 return bridge_ptr->GetNativeAccessibleFromId(ax_node_->parent()->id());
71}
AXNode * parent() const
Definition ax_node.h:111

◆ GetPlatformNode()

ui::AXPlatformNode * flutter::FlutterPlatformNodeDelegate::GetPlatformNode ( ) const
virtual

Reimplemented in flutter::FlutterPlatformNodeDelegateWindows.

Definition at line 119 of file flutter_platform_node_delegate.cc.

119 {
120 return nullptr;
121}

◆ GetUnignoredSelection()

const ui::AXTree::Selection flutter::FlutterPlatformNodeDelegate::GetUnignoredSelection ( ) const
overridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Definition at line 160 of file flutter_platform_node_delegate.cc.

161 {
162 return ax_node_->GetUnignoredSelection();
163}
OwnerTree::Selection GetUnignoredSelection() const
Definition ax_node.cc:1260

◆ GetUniqueId()

const ui::AXUniqueId & flutter::FlutterPlatformNodeDelegate::GetUniqueId ( ) const
inlineoverridevirtual

Reimplemented from ui::AXPlatformNodeDelegateBase.

Definition at line 102 of file flutter_platform_node_delegate.h.

102{ return unique_id_; }

◆ Init()

void flutter::FlutterPlatformNodeDelegate::Init ( std::weak_ptr< OwnerBridge bridge,
ui::AXNode node 
)
virtual

Called only once, immediately after construction. The constructor doesn't take any arguments because in the Windows subclass we use a special function to construct a COM object. Subclasses must call super.

Reimplemented in flutter::FlutterPlatformNodeDelegateMac, and flutter::FlutterPlatformNodeDelegateWindows.

Definition at line 20 of file flutter_platform_node_delegate.cc.

21 {
22 bridge_ = std::move(bridge);
23 ax_node_ = node;
24}

The documentation for this class was generated from the following files: