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

#import <ax_platform_node_mac.h>

Inheritance diagram for AXPlatformNodeCocoa:

Instance Methods

(instancetype) - initWithNode:
 
(void) - detach
 
(NSString *) - getStringAttribute: [implementation]
 
(NSString *) - getAXValueAsString [implementation]
 
(NSString *) - getName [implementation]
 
(std::unique_ptr< AnnouncementSpec >) - announcementForEvent: [implementation]
 
(void) - scheduleLiveRegionAnnouncement: [implementation]
 
(BOOL- accessibilityIsIgnored [implementation]
 
(id- accessibilityHitTest: [implementation]
 
(BOOL- accessibilityNotifiesWhenDestroyed [implementation]
 
(id- accessibilityFocusedUIElement [implementation]
 
(NSArray *) - accessibilityActionNames [implementation]
 
(void) - accessibilityPerformAction: [implementation]
 
(NSString *) - AXRoleInternal [implementation]
 
(NSString *) - AXRoleDescriptionInternal [implementation]
 
(NSString *) - AXSubroleInternal [implementation]
 
(NSString *) - AXHelpInternal [implementation]
 
(id- AXValueInternal [implementation]
 
(NSNumber *) - AXEnabledInternal [implementation]
 
(NSNumber *) - AXFocusedInternal [implementation]
 
(id- AXParentInternal [implementation]
 
(NSArray *) - AXChildrenInternal [implementation]
 
(id- AXWindowInternal [implementation]
 
(id- AXTopLevelUIElementInternal [implementation]
 
(NSValue *) - AXPositionInternal [implementation]
 
(NSValue *) - AXSizeInternal [implementation]
 
(NSString *) - AXTitleInternal [implementation]
 
(NSNumber *) - AXSelectedInternal [implementation]
 
(NSString *) - AXPlaceholderValueInternal [implementation]
 
(NSString *) - AXMenuItemMarkChar [implementation]
 
(NSString *) - AXSelectedTextInternal [implementation]
 
(NSValue *) - AXSelectedTextRangeInternal [implementation]
 
(NSNumber *) - AXNumberOfCharactersInternal [implementation]
 
(NSValue *) - AXVisibleCharacterRangeInternal [implementation]
 
(NSNumber *) - AXInsertionPointLineNumberInternal [implementation]
 
(NSString *) - description [implementation]
 
(NSArray *) - accessibilityChildren [implementation]
 
(BOOL- isAccessibilityElement [implementation]
 
(BOOL- isAccessibilityEnabled [implementation]
 
(NSRect) - accessibilityFrame [implementation]
 
(NSString *) - accessibilityLabel [implementation]
 
(NSString *) - accessibilityTitle [implementation]
 
(id- accessibilityValue [implementation]
 
(NSAccessibilityRole) - accessibilityRole [implementation]
 
(NSString *) - accessibilityRoleDescription [implementation]
 
(NSAccessibilitySubrole) - accessibilitySubrole [implementation]
 
(NSString *) - accessibilityHelp [implementation]
 
(id- accessibilityParent [implementation]
 
(id- accessibilityWindow [implementation]
 
(id- accessibilityTopLevelUIElement [implementation]
 
(BOOL- accessibilitySelected [implementation]
 
(BOOL- isAccessibilitySelectorAllowed: [implementation]
 
(void) - setAccessibilityValue: [implementation]
 
(void) - setAccessibilityFocused: [implementation]
 
(void) - setAccessibilitySelectedText: [implementation]
 
(void) - setAccessibilitySelectedTextRange: [implementation]
 
(NSInteger) - accessibilityInsertionPointLineNumber [implementation]
 
(NSInteger) - accessibilityNumberOfCharacters [implementation]
 
(NSString *) - accessibilityPlaceholderValue [implementation]
 
(NSString *) - accessibilitySelectedText [implementation]
 
(NSRange) - accessibilitySelectedTextRange [implementation]
 
(NSArray *) - accessibilitySelectedTextRanges [implementation]
 
(NSRange) - accessibilitySharedCharacterRange [implementation]
 
(NSArray *) - accessibilitySharedTextUIElements [implementation]
 
(NSRange) - accessibilityVisibleCharacterRange [implementation]
 
(NSString *) - accessibilityStringForRange: [implementation]
 
(NSAttributedString *) - accessibilityAttributedStringForRange: [implementation]
 
(NSData *) - accessibilityRTFForRange: [implementation]
 
(NSRect) - accessibilityFrameForRange: [implementation]
 
(NSInteger) - accessibilityLineForIndex: [implementation]
 
(NSRange) - accessibilityRangeForIndex: [implementation]
 
(NSRange) - accessibilityStyleRangeForIndex: [implementation]
 
(NSRange) - accessibilityRangeForLine: [implementation]
 
(NSRange) - accessibilityRangeForPosition: [implementation]
 
(NSArray *) - accessibilitySharedFocusElements [implementation]
 
(id- accessibilityFocusedWindow [implementation]
 
(id- accessibilityApplicationFocusedUIElement [implementation]
 
(BOOL- isAccessibilityFocused [implementation]
 

Class Methods

(NSString *) + nativeRoleFromAXRole:
 
(NSString *) + nativeSubroleFromAXRole:
 
(NSString *) + nativeNotificationFromAXEvent:
 

Properties

NSRect boundsInScreen
 
ui::AXPlatformNodeBasenode
 

Detailed Description

Definition at line 54 of file ax_platform_node_mac.h.

Method Documentation

◆ accessibilityActionNames

- (NSArray *) accessibilityActionNames
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

497 {
498 if (!_node)
499 return @[];
500
501 base::scoped_nsobject<NSMutableArray> axActions([[NSMutableArray alloc] init]);
502
503 const ui::AXNodeData& data = _node->GetData();
504 const ActionList& action_list = GetActionList();
505
506 // VoiceOver expects the "press" action to be first. Note that some roles
507 // should be given a press action implicitly.
508 BASE_DCHECK([action_list[0].second isEqualToString:NSAccessibilityPressAction]);
509 for (const auto& item : action_list) {
510 if (data.HasAction(item.first) || HasImplicitAction(data, item.first))
511 [axActions addObject:item.second];
512 }
513
514 if (AlsoUseShowMenuActionForDefaultAction(data))
515 [axActions addObject:NSAccessibilityShowMenuAction];
516
517 return axActions.autorelease();
518}
static bool init()
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
#define BASE_DCHECK(condition)
Definition: logging.h:63

◆ accessibilityApplicationFocusedUIElement

- (id) accessibilityApplicationFocusedUIElement
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

1038 {
1039 if (![[self AXFocusedInternal] boolValue])
1040 return nil;
1041 return self;
1042}

◆ accessibilityAttributedStringForRange:

- (NSAttributedString *) accessibilityAttributedStringForRange: (NSRange)  range
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

972 :(NSRange)range {
973 if (!_node)
974 return nil;
975 // TODO(https://crbug.com/958811): Implement this for real.
977 [[NSAttributedString alloc] initWithString:[self accessibilityStringForRange:range]]);
978 return attributedString.autorelease();
979}

◆ accessibilityChildren

- (NSArray *) accessibilityChildren
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

748 {
749 return [self AXChildrenInternal];
750}

◆ accessibilityFocusedUIElement

- (id) accessibilityFocusedUIElement
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

490 {
491 return _node ? _node->GetDelegate()->GetFocus() : nil;
492}

◆ accessibilityFocusedWindow

- (id) accessibilityFocusedWindow
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

1033 {
1034 if (![[self AXFocusedInternal] boolValue])
1035 return nil;
1036 return self;
1037}

◆ accessibilityFrame

- (NSRect) accessibilityFrame
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

761 {
762 return [self boundsInScreen];
763}

◆ accessibilityFrameForRange:

- (NSRect) accessibilityFrameForRange: (NSRange)  range
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

985 :(NSRange)range {
986 return NSZeroRect;
987}

◆ accessibilityHelp

- (NSString *) accessibilityHelp
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

793 {
794 return [self AXHelpInternal];
795}

◆ accessibilityHitTest:

- (id) accessibilityHitTest: (NSPoint)  point
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

471 :(NSPoint)point {
472 if (!NSPointInRect(point, [self boundsInScreen]))
473 return nil;
474
475 for (id child in [[self AXChildrenInternal] reverseObjectEnumerator]) {
476 if (!NSPointInRect(point, [child accessibilityFrame]))
477 continue;
478 if (id foundChild = [child accessibilityHitTest:point])
479 return foundChild;
480 }
481
482 // Hit self, but not any child.
483 return NSAccessibilityUnignoredAncestor(self);
484}

◆ accessibilityInsertionPointLineNumber

- (NSInteger) accessibilityInsertionPointLineNumber
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

902 {
903 return [[self AXInsertionPointLineNumberInternal] integerValue];
904}

◆ accessibilityIsIgnored

- (BOOL) accessibilityIsIgnored
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

463 {
464 if (!_node)
465 return YES;
466
467 return [[self AXRoleInternal] isEqualToString:NSAccessibilityUnknownRole] ||
468 _node->GetData().HasState(ax::mojom::State::kInvisible);
469}

◆ accessibilityLabel

- (NSString *) accessibilityLabel
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

765 {
766 // accessibilityLabel is "a short description of the accessibility element",
767 // and accessibilityTitle is "the title of the accessibility element"; at
768 // least in Chromium, the title usually is a short description of the element,
769 // so it also functions as a label.
770 return [self AXTitleInternal];
771}

◆ accessibilityLineForIndex:

- (NSInteger) accessibilityLineForIndex: (NSInteger)  index
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

989 :(NSInteger)index {
990 // Views textfields are single-line.
991 return 0;
992}

◆ accessibilityNotifiesWhenDestroyed

- (BOOL) accessibilityNotifiesWhenDestroyed
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

486 {
487 return YES;
488}

◆ accessibilityNumberOfCharacters

- (NSInteger) accessibilityNumberOfCharacters
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

906 {
907 if (!_node)
908 return 0;
909 return [[self AXNumberOfCharactersInternal] integerValue];
910}

◆ accessibilityParent

- (id) accessibilityParent
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

797 {
798 return [self AXParentInternal];
799}

◆ accessibilityPerformAction:

- (void) accessibilityPerformAction: (NSString*)  action
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

520 :(NSString*)action {
521 // Actions are performed asynchronously, so it's always possible for an object
522 // to change its mind after previously reporting an action as available.
523 if (![[self accessibilityActionNames] containsObject:action])
524 return;
525
527 if ([action isEqualToString:NSAccessibilityShowMenuAction] &&
528 AlsoUseShowMenuActionForDefaultAction(_node->GetData())) {
530 } else {
531 for (const ActionList::value_type& entry : GetActionList()) {
532 if ([action isEqualToString:entry.second]) {
533 data.action = entry.first;
534 break;
535 }
536 }
537 }
538
539 // Note ui::AX_ACTIONs which are just overwriting an accessibility attribute
540 // are already implemented in -accessibilitySetValue:forAttribute:, so ignore
541 // those here.
542
543 if (data.action != ax::mojom::Action::kNone)
544 _node->GetDelegate()->AccessibilityPerformAction(data);
545}

◆ accessibilityPlaceholderValue

- (NSString *) accessibilityPlaceholderValue
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

912 {
913 if (!_node)
914 return nil;
915
916 return [self AXPlaceholderValueInternal];
917}

◆ accessibilityRangeForIndex:

- (NSRange) accessibilityRangeForIndex: (NSInteger)  index
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

994 :(NSInteger)index {
996 return NSMakeRange(0, 0);
997}
#define BASE_UNREACHABLE()
Definition: logging.h:69

◆ accessibilityRangeForLine:

- (NSRange) accessibilityRangeForLine: (NSInteger)  line
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

1007 :(NSInteger)line {
1008 if (!_node)
1009 return NSMakeRange(0, 0);
1010
1011 if (line != 0) {
1012 BASE_LOG() << "Views textfields are single-line.";
1014 }
1015 return NSMakeRange(0, [self accessibilityNumberOfCharacters]);
1016}
NSInteger accessibilityNumberOfCharacters()
#define BASE_LOG()
Definition: logging.h:54

◆ accessibilityRangeForPosition:

- (NSRange) accessibilityRangeForPosition: (NSPoint)  point
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

1018 :(NSPoint)point {
1019 // TODO(a-wallen): Framework needs to send Text Metrics
1020 // to the AXTree in order for a NSPoint (x, y) to be
1021 // translated to the appropriate range of UTF-16 chars.
1022 return NSMakeRange(0, 0);
1023}

◆ accessibilityRole

- (NSAccessibilityRole) accessibilityRole
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

781 {
782 return [self AXRoleInternal];
783}

◆ accessibilityRoleDescription

- (NSString *) accessibilityRoleDescription
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

785 {
786 return [self AXRoleDescriptionInternal];
787}

◆ accessibilityRTFForRange:

- (NSData *) accessibilityRTFForRange: (NSRange)  range
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

981 :(NSRange)range {
982 return nil;
983}

◆ accessibilitySelected

- (BOOL) accessibilitySelected
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

809 {
810 return [[self AXSelectedInternal] boolValue];
811}

◆ accessibilitySelectedText

- (NSString *) accessibilitySelectedText
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

919 {
920 if (!_node)
921 return nil;
922
923 return [self AXSelectedTextInternal];
924}

◆ accessibilitySelectedTextRange

- (NSRange) accessibilitySelectedTextRange
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

926 {
927 if (!_node)
928 return NSMakeRange(0, 0);
929
930 NSRange r;
931 [[self AXSelectedTextRangeInternal] getValue:&r];
932 return r;
933}

◆ accessibilitySelectedTextRanges

- (NSArray *) accessibilitySelectedTextRanges
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

935 {
936 if (!_node)
937 return nil;
938
939 return @[ [self AXSelectedTextRangeInternal] ];
940}

◆ accessibilitySharedCharacterRange

- (NSRange) accessibilitySharedCharacterRange
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

942 {
943 if (!_node)
944 return NSMakeRange(0, 0);
945
946 NSRange r;
947 [[self AXSelectedTextRangeInternal] getValue:&r];
948 return r;
949}

◆ accessibilitySharedFocusElements

- (NSArray *) accessibilitySharedFocusElements
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

1028 {
1029 if (![[self AXFocusedInternal] boolValue])
1030 return nil;
1031 return @[ self ];
1032}

◆ accessibilitySharedTextUIElements

- (NSArray *) accessibilitySharedTextUIElements
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

951 {
952 if (!_node)
953 return nil;
954
955 return @[ self ];
956}

◆ accessibilityStringForRange:

- (NSString *) accessibilityStringForRange: (NSRange)  range
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

965 :(NSRange)range {
966 if (!_node)
967 return nil;
968
969 return [[self getAXValueAsString] substringWithRange:range];
970}

◆ accessibilityStyleRangeForIndex:

- (NSRange) accessibilityStyleRangeForIndex: (NSInteger)  index
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

999 :(NSInteger)index {
1000 if (!_node)
1001 return NSMakeRange(0, 0);
1002
1003 // TODO(https://crbug.com/958811): Implement this for real.
1004 return NSMakeRange(0, [self accessibilityNumberOfCharacters]);
1005}

◆ accessibilitySubrole

- (NSAccessibilitySubrole) accessibilitySubrole
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

789 {
790 return [self AXSubroleInternal];
791}

◆ accessibilityTitle

- (NSString *) accessibilityTitle
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

773 {
774 return [self AXTitleInternal];
775}

◆ accessibilityTopLevelUIElement

- (id) accessibilityTopLevelUIElement
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

805 {
806 return [self AXTopLevelUIElementInternal];
807}

◆ accessibilityValue

- (id) accessibilityValue
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

777 {
778 return [self AXValueInternal];
779}

◆ accessibilityVisibleCharacterRange

- (NSRange) accessibilityVisibleCharacterRange
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

958 {
959 if (!_node)
960 return NSMakeRange(0, 0);
961
962 return [[self AXVisibleCharacterRangeInternal] rangeValue];
963}

◆ accessibilityWindow

- (id) accessibilityWindow
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

801 {
802 return [self AXWindowInternal];
803}

◆ announcementForEvent:

- (unique_ptr< AnnouncementSpec >) AXPlatformNodeCocoa: (ax::mojom::Event eventType
implementation

Provided by category AXPlatformNodeCocoa(Private).

Definition at line 359 of file ax_platform_node_mac.mm.

419 :(ax::mojom::Event)eventType {
420 // Only alerts and live region changes should be announced.
423 std::string liveStatus = _node->GetStringAttribute(ax::mojom::StringAttribute::kLiveStatus);
424 // If live status is explicitly set to off, don't announce.
425 if (liveStatus == "off")
426 return nullptr;
427
428 NSString* name = [self getName];
429 NSString* announcementText = name;
430 if ([announcementText length] <= 0) {
431 announcementText = @(base::UTF16ToUTF8(_node->GetInnerText()).data());
432 }
433 if ([announcementText length] == 0)
434 return nullptr;
435
436 auto announcement = std::make_unique<AnnouncementSpec>();
437 announcement->announcement = base::scoped_nsobject<NSString>([announcementText retain]);
438 announcement->window = base::scoped_nsobject<NSWindow>([[self AXWindowInternal] retain]);
439 announcement->is_polite = liveStatus != "assertive";
440 return announcement;
441}
size_t length
std::string UTF16ToUTF8(std::u16string src)
Definition: string_utils.cc:71
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ AXChildrenInternal

- (NSArray *) AXChildrenInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

643 {
644 if (!_node)
645 return @[];
646
647 int count = _node->GetChildCount();
648 NSMutableArray* children = [NSMutableArray arrayWithCapacity:count];
649 for (auto child_iterator_ptr = _node->GetDelegate()->ChildrenBegin();
650 *child_iterator_ptr != *_node->GetDelegate()->ChildrenEnd(); ++(*child_iterator_ptr)) {
651 [children addObject:child_iterator_ptr->GetNativeViewAccessible()];
652 }
653 return NSAccessibilityUnignoredChildren(children);
654}
int count
Definition: FontMgrTest.cpp:50

◆ AXEnabledInternal

- (NSNumber *) AXEnabledInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

627 {
628 return @(_node->GetData().GetRestriction() != ax::mojom::Restriction::kDisabled);
629}

◆ AXFocusedInternal

- (NSNumber *) AXFocusedInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

631 {
632 if (_node->GetData().HasState(ax::mojom::State::kFocusable))
633 return @(_node->GetDelegate()->GetFocus() == _node->GetNativeViewAccessible());
634 return @NO;
635}

◆ AXHelpInternal

- (NSString *) AXHelpInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

585 {
586 // TODO(aleventhal) Key shortcuts attribute should eventually get
587 // its own field. Follow what WebKit does for aria-keyshortcuts, see
588 // https://bugs.webkit.org/show_bug.cgi?id=159215 (WebKit bug).
589 NSString* desc = [self getStringAttribute:ax::mojom::StringAttribute::kDescription];
590 NSString* key = [self getStringAttribute:ax::mojom::StringAttribute::kKeyShortcuts];
591 if (!desc.length)
592 return key.length ? key : @"";
593 if (!key.length)
594 return desc;
595 return [NSString stringWithFormat:@"%@ %@", desc, key];
596}

◆ AXInsertionPointLineNumberInternal

- (NSNumber *) AXInsertionPointLineNumberInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

727 {
728 // Multiline is not supported on views.
729 return @0;
730}

◆ AXMenuItemMarkChar

- (NSString *) AXMenuItemMarkChar
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

687 {
688 if (!ui::IsMenuItem(_node->GetData().role))
689 return nil;
690
691 const auto checkedState = static_cast<ax::mojom::CheckedState>(
692 _node->GetIntAttribute(ax::mojom::IntAttribute::kCheckedState));
693 if (checkedState == ax::mojom::CheckedState::kTrue) {
694 return @"\xE2\x9C\x93"; // UTF-8 for unicode 0x2713, "check mark"
695 }
696
697 return @"";
698}
bool IsMenuItem(ax::mojom::Role role)

◆ AXNumberOfCharactersInternal

- (NSNumber *) AXNumberOfCharactersInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

719 {
720 return @([[self getAXValueAsString] length]);
721}

◆ AXParentInternal

- (id) AXParentInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

637 {
638 if (!_node)
639 return nil;
640 return NSAccessibilityUnignoredAncestor(_node->GetParent());
641}

◆ AXPlaceholderValueInternal

- (NSString *) AXPlaceholderValueInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

683 {
684 return [self getStringAttribute:ax::mojom::StringAttribute::kPlaceholder];
685}

◆ AXPositionInternal

- (NSValue *) AXPositionInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

664 {
665 return [NSValue valueWithPoint:self.boundsInScreen.origin];
666}

◆ AXRoleDescriptionInternal

- (NSString *) AXRoleDescriptionInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

554 {
555 switch (_node->GetData().role) {
557 // There is no NSAccessibilityTabRole or similar (AXRadioButton is used
558 // instead). Do the same as NSTabView and put "tab" in the description.
559 // return [l10n_util::GetNSStringWithFixup(IDS_ACCNAME_TAB_ROLE_DESCRIPTION)
560 // lowercaseString];
561 return nil;
563 // return [l10n_util::GetNSStringWithFixup(
564 // IDS_ACCNAME_DISCLOSURE_TRIANGLE_ROLE_DESCRIPTION) lowercaseString];
565 return nil;
566 default:
567 break;
568 }
569 return NSAccessibilityRoleDescription([self AXRoleInternal], [self AXSubroleInternal]);
570}

◆ AXRoleInternal

- (NSString *) AXRoleInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

547 {
548 if (!_node)
549 return nil;
550
551 return [[self class] nativeRoleFromAXRole:_node->GetData().role];
552}

◆ AXSelectedInternal

- (NSNumber *) AXSelectedInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

679 {
680 return @(_node->GetData().GetBoolAttribute(ax::mojom::BoolAttribute::kSelected));
681}

◆ AXSelectedTextInternal

- (NSString *) AXSelectedTextInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

700 {
701 NSRange selectedTextRange;
702 [[self AXSelectedTextRangeInternal] getValue:&selectedTextRange];
703 return [[self getAXValueAsString] substringWithRange:selectedTextRange];
704}
API_AVAILABLE(ios(13.0)) @interface FlutterTextPlaceholder UITextRange * selectedTextRange

◆ AXSelectedTextRangeInternal

- (NSValue *) AXSelectedTextRangeInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

706 {
707 int start = _node->GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart);
708 int end = _node->GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd);
709 NSAssert((start >= 0 && end >= 0) || (start == -1 && end == -1), @"selection is invalid");
710
711 if (start == -1 && end == -1) {
712 return [NSValue valueWithRange:{NSNotFound, 0}];
713 }
714 // NSRange cannot represent the direction the text was selected in.
715 return [NSValue valueWithRange:{static_cast<NSUInteger>(std::min(start, end)),
716 static_cast<NSUInteger>(abs(end - start))}];
717}
glong glong end

◆ AXSizeInternal

- (NSValue *) AXSizeInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

668 {
669 return [NSValue valueWithSize:self.boundsInScreen.size];
670}

◆ AXSubroleInternal

- (NSString *) AXSubroleInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

572 {
573 ax::mojom::Role role = _node->GetData().role;
574 switch (role) {
576 if (_node->GetData().HasState(ax::mojom::State::kProtected))
577 return NSAccessibilitySecureTextFieldSubrole;
578 break;
579 default:
580 break;
581 }
583}
NSString * nativeSubroleFromAXRole:(ax::mojom::Role role)

◆ AXTitleInternal

- (NSString *) AXTitleInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

672 {
673 if (ui::IsNameExposedInAXValueForRole(_node->GetData().role))
674 return @"";
675
676 return [self getName];
677}
AX_EXPORT bool IsNameExposedInAXValueForRole(ax::mojom::Role role)

◆ AXTopLevelUIElementInternal

- (id) AXTopLevelUIElementInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

660 {
661 return [self AXWindowInternal];
662}

◆ AXValueInternal

- (id) AXValueInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

598 {
599 ax::mojom::Role role = _node->GetData().role;
600 if (role == ax::mojom::Role::kTab)
601 return [self AXSelectedInternal];
602
604 if (role == ax::mojom::Role::kStaticText) {
605 // Static texts may store their texts in the value attributes. For
606 // example, the selectable text stores its text in value instead of
607 // name.
608 NSString* value = [self getName];
609 if (value.length == 0) {
610 value = [self getStringAttribute:ax::mojom::StringAttribute::kValue];
611 }
612 return value;
613 }
614 return [self getName];
615 }
616
617 if (_node->IsPlatformCheckable()) {
618 // Mixed checkbox state not currently supported in views, but could be.
619 // See browser_accessibility_cocoa.mm for details.
620 const auto checkedState = static_cast<ax::mojom::CheckedState>(
621 _node->GetIntAttribute(ax::mojom::IntAttribute::kCheckedState));
622 return checkedState == ax::mojom::CheckedState::kTrue ? @1 : @0;
623 }
624 return [self getStringAttribute:ax::mojom::StringAttribute::kValue];
625}
uint8_t value

◆ AXVisibleCharacterRangeInternal

- (NSValue *) AXVisibleCharacterRangeInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

723 {
724 return [NSValue valueWithRange:{0, [[self getAXValueAsString] length]}];
725}

◆ AXWindowInternal

- (id) AXWindowInternal
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

656 {
657 return _node->GetDelegate()->GetNSWindow();
658}

◆ description

- (NSString *) description
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

734 {
735 return [NSString stringWithFormat:@"%@ - %@ (%@)", [super description], [self AXTitleInternal],
736 [self AXRoleInternal]];
737}

◆ detach

- (void) detach

Definition at line 359 of file ax_platform_node_mac.mm.

389 {
390 if (!_node)
391 return;
392 _node = nil;
393 NSAccessibilityPostNotification(self, NSAccessibilityUIElementDestroyedNotification);
394}

◆ getAXValueAsString

- (NSString *) getAXValueAsString
implementation

Provided by category AXPlatformNodeCocoa(Private).

Definition at line 359 of file ax_platform_node_mac.mm.

410 {
411 id value = [self AXValueInternal];
412 return [value isKindOfClass:[NSString class]] ? value : nil;
413}

◆ getName

- (NSString *) getName
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

415 {
416 return @(_node->GetName().data());
417}

◆ getStringAttribute:

- (NSString *) getStringAttribute: (ax::mojom::StringAttribute attribute
implementation

Provided by category AXPlatformNodeCocoa(Private).

Definition at line 359 of file ax_platform_node_mac.mm.

403 :(ax::mojom::StringAttribute)attribute {
404 std::string attributeValue;
405 if (_node->GetStringAttribute(attribute, &attributeValue))
406 return @(attributeValue.data());
407 return nil;
408}
StringAttribute
Definition: ax_enums.h:521

◆ initWithNode:

- (instancetype) initWithNode: (ui::AXPlatformNodeBase*)  node

Definition at line 359 of file ax_platform_node_mac.mm.

383 if ((self = [super init])) {
384 _node = node;
385 }
386 return self;
387}
ui::AXPlatformNodeBase * node

◆ isAccessibilityElement

- (BOOL) isAccessibilityElement
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

752 {
753 if (!_node)
754 return NO;
755 return (![[self AXRoleInternal] isEqualToString:NSAccessibilityUnknownRole] &&
756 !_node->GetData().HasState(ax::mojom::State::kInvisible));
757}

◆ isAccessibilityEnabled

- (BOOL) isAccessibilityEnabled
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

758 {
759 return [[self AXEnabledInternal] boolValue];
760}

◆ isAccessibilityFocused

- (BOOL) isAccessibilityFocused
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

1043 {
1044 return [[self AXFocusedInternal] boolValue];
1045}

◆ isAccessibilitySelectorAllowed:

- (BOOL) isAccessibilitySelectorAllowed: (SEL)  selector
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

813 :(SEL)selector {
814 if (!_node)
815 return NO;
816
817 const ax::mojom::Restriction restriction = _node->GetData().GetRestriction();
818 if (restriction == ax::mojom::Restriction::kDisabled)
819 return NO;
820
821 if (selector == @selector(setAccessibilityValue:)) {
822 // Tabs use the radio button role on Mac, so they are selected by calling
823 // setSelected on an individual tab, rather than by setting the selected
824 // element on the tabstrip as a whole.
825 if (_node->GetData().role == ax::mojom::Role::kTab) {
826 return !_node->GetData().GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
827 }
828 return restriction != ax::mojom::Restriction::kReadOnly;
829 }
830
831 // TODO(https://crbug.com/692362): Once the underlying bug in
832 // views::Textfield::SetSelectionRange() described in that bug is fixed,
833 // remove the check here; right now, this check serves to prevent
834 // accessibility clients from trying to set the selection range, which won't
835 // work because of 692362.
836 if (selector == @selector(setAccessibilitySelectedText:) ||
837 selector == @selector(setAccessibilitySelectedTextRange:) ||
838 selector == @selector(setAccessibilitySelectedTextMarkerRange:)) {
839 return restriction != ax::mojom::Restriction::kReadOnly;
840 }
841
842 if (selector == @selector(setAccessibilityFocused:))
843 return _node->GetData().HasState(ax::mojom::State::kFocusable);
844
845 // TODO(https://crbug.com/386671): What about role-specific selectors?
846 return [super isAccessibilitySelectorAllowed:selector];
847}

◆ nativeNotificationFromAXEvent:

+ (NSString *) nativeNotificationFromAXEvent: (ax::mojom::Event event

Definition at line 359 of file ax_platform_node_mac.mm.

377 static const base::NoDestructor<EventMap> event_map(BuildEventMap());
378 EventMap::const_iterator it = event_map->find(event);
379 return it != event_map->end() ? it->second : nil;
380}
FlKeyEvent * event

◆ nativeRoleFromAXRole:

+ (NSString *) nativeRoleFromAXRole: (ax::mojom::Role role

Definition at line 359 of file ax_platform_node_mac.mm.

364 :(ax::mojom::Role)role {
365 static const base::NoDestructor<RoleMap> role_map(BuildRoleMap());
366 RoleMap::const_iterator it = role_map->find(role);
367 return it != role_map->end() ? it->second : NSAccessibilityUnknownRole;
368}

◆ nativeSubroleFromAXRole:

+ (NSString *) nativeSubroleFromAXRole: (ax::mojom::Role role

Definition at line 359 of file ax_platform_node_mac.mm.

370 :(ax::mojom::Role)role {
371 static const base::NoDestructor<RoleMap> subrole_map(BuildSubroleMap());
372 RoleMap::const_iterator it = subrole_map->find(role);
373 return it != subrole_map->end() ? it->second : nil;
374}

◆ scheduleLiveRegionAnnouncement:

- (void) scheduleLiveRegionAnnouncement: (std::unique_ptr<AnnouncementSpec>)  announcement
implementation

Provided by category AXPlatformNodeCocoa(Private).

Definition at line 359 of file ax_platform_node_mac.mm.

443 :(std::unique_ptr<AnnouncementSpec>)announcement {
445 // An announcement is already in flight, so just reset the contents. This is
446 // threadsafe because the dispatch is on the main queue.
447 _pendingAnnouncement = std::move(announcement);
448 return;
449 }
450
451 _pendingAnnouncement = std::move(announcement);
452 dispatch_after(kLiveRegionDebounceMillis * NSEC_PER_MSEC, dispatch_get_main_queue(), ^{
454 return;
455 }
456 PostAnnouncementNotification(_pendingAnnouncement->announcement, _pendingAnnouncement->window,
457 _pendingAnnouncement->is_polite);
458 _pendingAnnouncement.reset();
459 });
460}
std::unique_ptr< AnnouncementSpec > _pendingAnnouncement

◆ setAccessibilityFocused:

- (void) setAccessibilityFocused: (BOOL isFocused
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

869 :(BOOL)isFocused {
870 if (!_node)
871 return;
874 _node->GetDelegate()->AccessibilityPerformAction(data);
875}
int BOOL
Definition: windows_types.h:37

◆ setAccessibilitySelectedText:

- (void) setAccessibilitySelectedText: (NSString*)  text
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

877 :(NSString*)text {
878 if (!_node)
879 return;
882 data.value = std::string([text UTF8String]);
883
884 _node->GetDelegate()->AccessibilityPerformAction(data);
885}
std::u16string text

◆ setAccessibilitySelectedTextRange:

- (void) setAccessibilitySelectedTextRange: (NSRange)  range
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

887 :(NSRange)range {
888 if (!_node)
889 return;
892 data.anchor_offset = range.location;
893 data.focus_offset = NSMaxRange(range);
894 _node->GetDelegate()->AccessibilityPerformAction(data);
895}

◆ setAccessibilityValue:

- (void) setAccessibilityValue: (id value
implementation

Definition at line 359 of file ax_platform_node_mac.mm.

849 :(id)value {
850 if (!_node)
851 return;
852
854 data.action = _node->GetData().role == ax::mojom::Role::kTab ? ax::mojom::Action::kSetSelection
856 if ([value isKindOfClass:[NSString class]]) {
857 data.value = std::string([value UTF8String]);
858 } else if ([value isKindOfClass:[NSValue class]]) {
859 // TODO(https://crbug.com/386671): Is this case actually needed? The
860 // NSObject accessibility implementation supported this, but can it actually
861 // occur?
862 NSRange range = [value rangeValue];
863 data.anchor_offset = range.location;
864 data.focus_offset = NSMaxRange(range);
865 }
866 _node->GetDelegate()->AccessibilityPerformAction(data);
867}
const uintptr_t id

Property Documentation

◆ boundsInScreen

- (NSRect) boundsInScreen
readnonatomicassign

Definition at line 69 of file ax_platform_node_mac.h.

◆ node

- (AXPlatformNodeBase*) AXPlatformNodeCocoa:
readnonatomicassign

Definition at line 70 of file ax_platform_node_mac.h.


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