Flutter Engine
The Flutter Engine
Instance Methods | Class Methods | Properties | List of all members
SemanticsObjectContainer Class Reference

#import <SemanticsObject.h>

Inheritance diagram for SemanticsObjectContainer:

Instance Methods

(instancetype) - NS_UNAVAILABLE
 
(instancetype) - initWithAccessibilityContainer:
 
(instancetype) - initWithSemanticsObject:bridge:
 
(NSInteger) - accessibilityElementCount [implementation]
 
(nullable id- accessibilityElementAtIndex: [implementation]
 
(NSInteger) - indexOfAccessibilityElement: [implementation]
 
(BOOL- isAccessibilityElement [implementation]
 
(CGRect) - accessibilityFrame [implementation]
 
(id- accessibilityContainer [implementation]
 
(BOOL- accessibilityScroll: [implementation]
 

Class Methods

(instancetype) + NS_UNAVAILABLE
 

Properties

SemanticsObjectsemanticsObject
 

Detailed Description

Represents a semantics object that has children and hence has to be presented to the OS as a UIAccessibilityContainer.

The SemanticsObject class cannot implement the UIAccessibilityContainer protocol because an object that returns YES for isAccessibilityElement cannot also implement UIAccessibilityContainer.

With the help of SemanticsObjectContainer, the hierarchy of semantic objects received from the framework, such as:

SemanticsObject1 SemanticsObject2 SemanticsObject3 SemanticsObject4

is translated into the following hierarchy, which is understood by iOS:

SemanticsObjectContainer1 SemanticsObject1 SemanticsObjectContainer2 SemanticsObject2 SemanticsObject3 SemanticsObject4

From Flutter's view of the world (the first tree seen above), we construct iOS's view of the world (second tree) as follows: We replace each SemanticsObjects that has children with a SemanticsObjectContainer, which has the original SemanticsObject and its children as children.

SemanticsObjects have semantic information attached to them which is interpreted by VoiceOver (they return YES for isAccessibilityElement). The SemanticsObjectContainers are just there for structure and they don't provide any semantic information to VoiceOver (they return NO for isAccessibilityElement).

Definition at line 226 of file SemanticsObject.h.

Method Documentation

◆ accessibilityContainer

- (id) accessibilityContainer
implementation

Definition at line 830 of file SemanticsObject.mm.

922 {
923 if (!_bridge) {
924 return nil;
925 }
926 return ([self.semanticsObject uid] == kRootNodeId)
927 ? _bridge->view()
928 : self.semanticsObject.parent.accessibilityContainer;
929}
constexpr int32_t kRootNodeId
SemanticsObject * semanticsObject
std::shared_ptr< flutter::AccessibilityBridgeMac > _bridge

◆ accessibilityElementAtIndex:

- (nullable id) accessibilityElementAtIndex: (NSInteger)  index
implementation

Definition at line 830 of file SemanticsObject.mm.

880 :(NSInteger)index {
881 if (index < 0 || index >= [self accessibilityElementCount]) {
882 return nil;
883 }
884 if (index == 0) {
885 return self.semanticsObject.nativeAccessibility;
886 }
887
888 SemanticsObject* child = self.semanticsObject.children[index - 1];
889
890 if ([child hasChildren]) {
891 return child.accessibilityContainer;
892 }
893 return child.nativeAccessibility;
894}
NSArray< SemanticsObject * > * children

◆ accessibilityElementCount

- (NSInteger) accessibilityElementCount
implementation

Definition at line 830 of file SemanticsObject.mm.

876 {
877 return self.semanticsObject.children.count + 1;
878}

◆ accessibilityFrame

- (CGRect) accessibilityFrame
implementation

Definition at line 830 of file SemanticsObject.mm.

918 {
919 return self.semanticsObject.accessibilityFrame;
920}

◆ accessibilityScroll:

- (BOOL) accessibilityScroll: (UIAccessibilityScrollDirection)  direction
implementation

Definition at line 830 of file SemanticsObject.mm.

933 :(UIAccessibilityScrollDirection)direction {
934 return [self.semanticsObject accessibilityScroll:direction];
935}

◆ indexOfAccessibilityElement:

- (NSInteger) indexOfAccessibilityElement: (id element
implementation

Definition at line 830 of file SemanticsObject.mm.

896 :(id)element {
897 if (element == self.semanticsObject.nativeAccessibility) {
898 return 0;
899 }
900
901 NSArray<SemanticsObject*>* children = self.semanticsObject.children;
902 for (size_t i = 0; i < [children count]; i++) {
903 SemanticsObject* child = children[i];
904 if ((![child hasChildren] && child.nativeAccessibility == element) ||
905 ([child hasChildren] && [child.nativeAccessibility accessibilityContainer] == element)) {
906 return i + 1;
907 }
908 }
909 return NSNotFound;
910}
const uintptr_t id

◆ initWithAccessibilityContainer:

- (instancetype) initWithAccessibilityContainer: (id NS_UNAVAILABLE

◆ initWithSemanticsObject:bridge:

- (instancetype) initWithSemanticsObject: (SemanticsObject*)  semanticsObject
bridge: (fml::WeakPtr<flutter::AccessibilityBridgeIos>)  NS_DESIGNATED_INITIALIZER 
Initial value:

Definition at line 830 of file SemanticsObject.mm.

859 FML_DCHECK(semanticsObject) << "semanticsObject must be set";
860 // Initialize with the UIView as the container.
861 // The UIView will not necessarily be accessibility parent for this object.
862 // The bridge informs the OS of the actual structure via
863 // `accessibilityContainer` and `accessibilityElementAtIndex`.
864 self = [super initWithAccessibilityContainer:bridge->view()];
865
866 if (self) {
867 _semanticsObject = semanticsObject;
868 _bridge = bridge;
869 }
870
871 return self;
872}
#define FML_DCHECK(condition)
Definition: logging.h:103

◆ isAccessibilityElement

- (BOOL) isAccessibilityElement
implementation

Definition at line 830 of file SemanticsObject.mm.

914 {
915 return NO;
916}

◆ NS_UNAVAILABLE [1/2]

- (instancetype) NS_UNAVAILABLE

◆ NS_UNAVAILABLE [2/2]

+ (instancetype) NS_UNAVAILABLE

Property Documentation

◆ semanticsObject

- (SemanticsObject*) semanticsObject
readwritenonatomicweak

Definition at line 234 of file SemanticsObject.h.


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