2017-05-12 20:28:25 +02:00
|
|
|
// Copyright 2017 The Chromium Embedded Framework Authors. Portions copyright
|
|
|
|
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
|
|
|
|
// governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Sample implementation for the NSAccessibility protocol for interacting with
|
|
|
|
// VoiceOver and other accessibility clients.
|
|
|
|
|
|
|
|
#include "tests/cefclient/browser/osr_accessibility_node.h"
|
|
|
|
|
|
|
|
#import <AppKit/NSAccessibility.h>
|
2017-05-17 11:29:28 +02:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
#include "tests/cefclient/browser/osr_accessibility_helper.h"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
NSString* AxRoleToNSAxRole(const std::string& role_string) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (role_string == "abbr") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "alertDialog") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "alert") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "annotation") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityUnknownRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "application") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "article") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "audio") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "banner") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "blockquote") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "busyIndicator") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityBusyIndicatorRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "button") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityButtonRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "buttonDropDown") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityButtonRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "canvas") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityImageRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "caption") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "checkBox") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityCheckBoxRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "colorWell") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityColorWellRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "column") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityColumnRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "comboBox") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityComboBoxRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "complementary") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "contentInfo") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "definition") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "descriptionListDetail") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "descriptionList") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityListRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "descriptionListTerm") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "details") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "dialog") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "directory") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityListRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "disclosureTriangle") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityDisclosureTriangleRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "div") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "document") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "embeddedObject") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "figcaption") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "figure") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "footer") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "form") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "genericContainer") {
|
2017-05-31 17:33:30 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "grid") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "group") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "iframe") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "iframePresentational") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "ignored") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityUnknownRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "imageMapLink") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityLinkRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "imageMap") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "image") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityImageRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "labelText") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "legend") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "link") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityLinkRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "listBoxOption") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityStaticTextRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "listBox") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityListRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "listItem") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "list") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityListRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "log") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "main") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "mark") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "marquee") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "math") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "menu") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityMenuRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "menuBar") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityMenuBarRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "menuButton") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityButtonRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "menuItem") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityMenuItemRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "menuItemCheckBox") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityMenuItemRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "menuItemRadio") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityMenuItemRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "menuListOption") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityMenuItemRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "menuListPopup") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityUnknownRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "meter") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityProgressIndicatorRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "navigation") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "note") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "outline") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityOutlineRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "paragraph") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "popUpButton") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityPopUpButtonRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "pre") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "presentational") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "progressIndicator") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityProgressIndicatorRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "radioButton") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityRadioButtonRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "radioGroup") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityRadioGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "region") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "row") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityRowRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "ruler") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityRulerRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "scrollBar") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityScrollBarRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "search") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "searchBox") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityTextFieldRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "slider") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilitySliderRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "sliderThumb") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityValueIndicatorRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "spinButton") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityIncrementorRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "splitter") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilitySplitterRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "staticText") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityStaticTextRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "status") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "svgRoot") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "switch") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityCheckBoxRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "tabGroup") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityTabGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "tabList") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityTabGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "tabPanel") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "tab") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityRadioButtonRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "tableHeaderContainer") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "table") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityTableRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "textField") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityTextFieldRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "time") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "timer") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "toggleButton") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityCheckBoxRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "toolbar") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityToolbarRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "treeGrid") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityTableRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "treeItem") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityRowRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "tree") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityOutlineRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "unknown") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityUnknownRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "tooltip") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "video") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityGroupRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (role_string == "window") {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityWindowRole;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-05-12 20:28:25 +02:00
|
|
|
return [NSString stringWithUTF8String:role_string.c_str()];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int MiddleX(const CefRect& rect) {
|
|
|
|
return rect.x + rect.width / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int MiddleY(const CefRect& rect) {
|
|
|
|
return rect.y + rect.height / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// OsrAXNodeObject is sample implementation for the NSAccessibility protocol
|
|
|
|
// for interacting with VoiceOver and other accessibility clients.
|
|
|
|
@interface OsrAXNodeObject : NSObject {
|
|
|
|
// OsrAXNode* proxy object
|
|
|
|
client::OsrAXNode* node_;
|
|
|
|
CefNativeAccessible* parent_;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (id)init:(client::OsrAXNode*)node;
|
|
|
|
+ (OsrAXNodeObject*)elementWithNode:(client::OsrAXNode*)node;
|
2017-05-12 20:28:25 +02:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation OsrAXNodeObject
|
|
|
|
- (id)init:(client::OsrAXNode*)node {
|
|
|
|
node_ = node;
|
|
|
|
parent_ = node_->GetParentAccessibleObject();
|
|
|
|
if (!parent_) {
|
|
|
|
parent_ = node_->GetWindowHandle();
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
+ (OsrAXNodeObject*)elementWithNode:(client::OsrAXNode*)node {
|
2017-05-12 20:28:25 +02:00
|
|
|
// We manage the release ourself
|
|
|
|
return [[OsrAXNodeObject alloc] init:node];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isEqual:(id)object {
|
|
|
|
if ([object isKindOfClass:[OsrAXNodeObject self]]) {
|
|
|
|
OsrAXNodeObject* other = object;
|
|
|
|
return (node_ == other->node_);
|
|
|
|
} else {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Utility methods to map AX information received from renderer
|
|
|
|
// to platform properties
|
2017-05-17 11:29:28 +02:00
|
|
|
- (NSString*)axRole {
|
2017-05-12 20:28:25 +02:00
|
|
|
// Get the Role from CefAccessibilityHelper and Map to NSRole
|
|
|
|
return AxRoleToNSAxRole(node_->AxRole());
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (NSString*)axDescription {
|
2017-05-12 20:28:25 +02:00
|
|
|
std::string desc = node_->AxDescription();
|
|
|
|
return [NSString stringWithUTF8String:desc.c_str()];
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (NSString*)axName {
|
2017-05-12 20:28:25 +02:00
|
|
|
std::string desc = node_->AxName();
|
|
|
|
return [NSString stringWithUTF8String:desc.c_str()];
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (NSString*)axValue {
|
2017-05-12 20:28:25 +02:00
|
|
|
std::string desc = node_->AxValue();
|
|
|
|
return [NSString stringWithUTF8String:desc.c_str()];
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (void)doMouseClick:(cef_mouse_button_type_t)type {
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRefPtr<CefBrowser> browser = node_->GetBrowser();
|
|
|
|
if (browser) {
|
|
|
|
CefMouseEvent mouse_event;
|
|
|
|
const CefRect& rect = node_->AxLocation();
|
|
|
|
mouse_event.x = MiddleX(rect);
|
|
|
|
mouse_event.y = MiddleY(rect);
|
|
|
|
|
|
|
|
mouse_event.modifiers = 0;
|
|
|
|
browser->GetHost()->SendMouseClickEvent(mouse_event, type, false, 1);
|
|
|
|
browser->GetHost()->SendMouseClickEvent(mouse_event, type, true, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (NSMutableArray*)getKids {
|
2017-05-12 20:28:25 +02:00
|
|
|
int numChilds = node_->GetChildCount();
|
|
|
|
if (numChilds > 0) {
|
|
|
|
NSMutableArray* kids = [NSMutableArray arrayWithCapacity:numChilds];
|
2017-05-17 11:29:28 +02:00
|
|
|
for (int index = 0; index < numChilds; index++) {
|
2017-05-12 20:28:25 +02:00
|
|
|
client::OsrAXNode* child = node_->ChildAtIndex(index);
|
2019-04-23 19:17:56 +02:00
|
|
|
[kids addObject:child ? CAST_CEF_NATIVE_ACCESSIBLE_TO_NSOBJECT(
|
|
|
|
child->GetNativeAccessibleObject(node_))
|
|
|
|
: nil];
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
return kids;
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (NSPoint)position {
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRect cef_rect = node_->AxLocation();
|
|
|
|
NSPoint origin = NSMakePoint(cef_rect.x, cef_rect.y);
|
|
|
|
NSSize size = NSMakeSize(cef_rect.width, cef_rect.height);
|
|
|
|
|
2019-04-23 19:17:56 +02:00
|
|
|
NSView* view = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(node_->GetWindowHandle());
|
2017-05-12 20:28:25 +02:00
|
|
|
origin.y = NSHeight([view bounds]) - origin.y;
|
|
|
|
NSPoint originInWindow = [view convertPoint:origin toView:nil];
|
|
|
|
|
|
|
|
NSRect point_rect = NSMakeRect(originInWindow.x, originInWindow.y, 0, 0);
|
2017-05-17 11:29:28 +02:00
|
|
|
NSPoint originInScreen =
|
|
|
|
[[view window] convertRectToScreen:point_rect].origin;
|
2017-05-12 20:28:25 +02:00
|
|
|
|
|
|
|
originInScreen.y = originInScreen.y - size.height;
|
|
|
|
return originInScreen;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (NSSize)size {
|
2017-05-12 20:28:25 +02:00
|
|
|
CefRect cef_rect = node_->AxLocation();
|
2017-05-17 11:29:28 +02:00
|
|
|
NSRect rect =
|
|
|
|
NSMakeRect(cef_rect.x, cef_rect.y, cef_rect.width, cef_rect.height);
|
2019-04-23 19:17:56 +02:00
|
|
|
NSView* view = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(node_->GetWindowHandle());
|
2017-05-17 11:29:28 +02:00
|
|
|
rect = [[view window] convertRectToScreen:rect];
|
2017-05-12 20:28:25 +02:00
|
|
|
return rect.size;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// accessibility protocol
|
|
|
|
//
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
|
|
|
- (BOOL)accessibilityIsIgnored {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (NSArray*)accessibilityAttributeNames {
|
2017-05-12 20:28:25 +02:00
|
|
|
static NSArray* attributes = nil;
|
|
|
|
if (attributes == nil) {
|
2017-05-17 11:29:28 +02:00
|
|
|
attributes = [[NSArray alloc]
|
|
|
|
initWithObjects:NSAccessibilityRoleAttribute,
|
|
|
|
NSAccessibilityRoleDescriptionAttribute,
|
|
|
|
NSAccessibilityChildrenAttribute,
|
|
|
|
NSAccessibilityValueAttribute,
|
|
|
|
NSAccessibilityTitleAttribute,
|
|
|
|
NSAccessibilityDescriptionAttribute,
|
|
|
|
NSAccessibilityFocusedAttribute,
|
|
|
|
NSAccessibilityParentAttribute,
|
|
|
|
NSAccessibilityWindowAttribute,
|
|
|
|
NSAccessibilityTopLevelUIElementAttribute,
|
|
|
|
NSAccessibilityPositionAttribute,
|
|
|
|
NSAccessibilitySizeAttribute, nil];
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
return attributes;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (id)accessibilityAttributeValue:(NSString*)attribute {
|
2019-04-23 19:17:56 +02:00
|
|
|
NSObject* typed_parent = CAST_CEF_NATIVE_ACCESSIBLE_TO_NSOBJECT(parent_);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!node_) {
|
2017-05-12 20:28:25 +02:00
|
|
|
return nil;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-05-12 20:28:25 +02:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) {
|
|
|
|
return [self axRole];
|
2017-05-17 11:29:28 +02:00
|
|
|
} else if ([attribute
|
|
|
|
isEqualToString:NSAccessibilityRoleDescriptionAttribute]) {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityRoleDescription([self axRole], nil);
|
|
|
|
} else if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) {
|
|
|
|
// Just check if the app thinks we're focused.
|
2017-05-17 11:29:28 +02:00
|
|
|
id focusedElement = [NSApp
|
|
|
|
accessibilityAttributeValue:NSAccessibilityFocusedUIElementAttribute];
|
2017-05-12 20:28:25 +02:00
|
|
|
return [NSNumber numberWithBool:[focusedElement isEqual:self]];
|
|
|
|
} else if ([attribute isEqualToString:NSAccessibilityParentAttribute]) {
|
2019-04-23 19:17:56 +02:00
|
|
|
return NSAccessibilityUnignoredAncestor(typed_parent);
|
2017-05-12 20:28:25 +02:00
|
|
|
} else if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
|
|
|
|
return NSAccessibilityUnignoredChildren([self getKids]);
|
|
|
|
} else if ([attribute isEqualToString:NSAccessibilityWindowAttribute]) {
|
|
|
|
// We're in the same window as our parent.
|
2019-04-23 19:17:56 +02:00
|
|
|
return [typed_parent
|
|
|
|
accessibilityAttributeValue:NSAccessibilityWindowAttribute];
|
2017-05-17 11:29:28 +02:00
|
|
|
} else if ([attribute
|
|
|
|
isEqualToString:NSAccessibilityTopLevelUIElementAttribute]) {
|
2017-05-12 20:28:25 +02:00
|
|
|
// We're in the same top level element as our parent.
|
2019-04-23 19:17:56 +02:00
|
|
|
return [typed_parent
|
2017-05-17 11:29:28 +02:00
|
|
|
accessibilityAttributeValue:NSAccessibilityTopLevelUIElementAttribute];
|
2017-05-12 20:28:25 +02:00
|
|
|
} else if ([attribute isEqualToString:NSAccessibilityPositionAttribute]) {
|
2017-05-17 11:29:28 +02:00
|
|
|
return [NSValue valueWithPoint:[self position]];
|
2017-05-12 20:28:25 +02:00
|
|
|
} else if ([attribute isEqualToString:NSAccessibilitySizeAttribute]) {
|
2017-05-17 11:29:28 +02:00
|
|
|
return [NSValue valueWithSize:[self size]];
|
2017-05-12 20:28:25 +02:00
|
|
|
} else if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) {
|
|
|
|
return [self axDescription];
|
|
|
|
} else if ([attribute isEqualToString:NSAccessibilityValueAttribute]) {
|
|
|
|
return [self axValue];
|
|
|
|
} else if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) {
|
|
|
|
return [self axName];
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)accessibilityHitTest:(NSPoint)point {
|
|
|
|
return NSAccessibilityUnignoredAncestor(self);
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (NSArray*)accessibilityActionNames {
|
2017-05-12 20:28:25 +02:00
|
|
|
return [NSArray arrayWithObject:NSAccessibilityPressAction];
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (NSString*)accessibilityActionDescription:(NSString*)action {
|
2017-05-12 20:28:25 +02:00
|
|
|
return NSAccessibilityActionDescription(action);
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
- (void)accessibilityPerformAction:(NSString*)action {
|
2017-05-12 20:28:25 +02:00
|
|
|
if ([action isEqualToString:NSAccessibilityPressAction]) {
|
|
|
|
// Do Click on Default action
|
|
|
|
[self doMouseClick:MBT_LEFT];
|
|
|
|
} else if ([action isEqualToString:NSAccessibilityShowMenuAction]) {
|
|
|
|
// Right click for Context Menu
|
|
|
|
[self doMouseClick:MBT_RIGHT];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)accessibilityFocusedUIElement {
|
|
|
|
return NSAccessibilityUnignoredAncestor(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)accessibilityNotifiesWhenDestroyed {
|
|
|
|
// Indicate that BrowserAccessibilityCocoa will post a notification when it's
|
|
|
|
// destroyed (see -detach). This allows VoiceOver to do some internal things
|
|
|
|
// more efficiently.
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
|
|
|
void OsrAXNode::NotifyAccessibilityEvent(std::string event_type) const {
|
2019-04-23 19:17:56 +02:00
|
|
|
NSView* view = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(GetWindowHandle());
|
2017-05-12 20:28:25 +02:00
|
|
|
if (event_type == "focus") {
|
2017-05-17 11:29:28 +02:00
|
|
|
NSAccessibilityPostNotification(
|
2019-04-23 19:17:56 +02:00
|
|
|
view, NSAccessibilityFocusedUIElementChangedNotification);
|
2017-05-12 20:28:25 +02:00
|
|
|
} else if (event_type == "textChanged") {
|
2019-04-23 19:17:56 +02:00
|
|
|
NSAccessibilityPostNotification(view,
|
2017-05-12 20:28:25 +02:00
|
|
|
NSAccessibilityTitleChangedNotification);
|
2017-05-17 11:29:28 +02:00
|
|
|
} else if (event_type == "valueChanged") {
|
2019-04-23 19:17:56 +02:00
|
|
|
NSAccessibilityPostNotification(view,
|
2017-05-12 20:28:25 +02:00
|
|
|
NSAccessibilityValueChangedNotification);
|
|
|
|
} else if (event_type == "textSelectionChanged") {
|
2019-04-23 19:17:56 +02:00
|
|
|
NSAccessibilityPostNotification(view,
|
2017-05-12 20:28:25 +02:00
|
|
|
NSAccessibilityValueChangedNotification);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OsrAXNode::Destroy() {
|
|
|
|
if (platform_accessibility_) {
|
2017-05-17 11:29:28 +02:00
|
|
|
NSAccessibilityPostNotification(
|
2019-04-23 19:17:56 +02:00
|
|
|
CAST_CEF_NATIVE_ACCESSIBLE_TO_NSOBJECT(platform_accessibility_),
|
|
|
|
NSAccessibilityUIElementDestroyedNotification);
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create and return NSAccessibility Implementation Object for Mac
|
|
|
|
CefNativeAccessible* OsrAXNode::GetNativeAccessibleObject(
|
|
|
|
client::OsrAXNode* parent) {
|
|
|
|
if (!platform_accessibility_) {
|
2019-04-23 19:17:56 +02:00
|
|
|
platform_accessibility_ = CAST_NSOBJECT_TO_CEF_NATIVE_ACCESSIBLE(
|
|
|
|
[OsrAXNodeObject elementWithNode:this]);
|
2017-05-12 20:28:25 +02:00
|
|
|
SetParent(parent);
|
|
|
|
}
|
|
|
|
return platform_accessibility_;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace client
|