Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ deps = {
'src/third_party/libcxx': 'https://llvm.googlesource.com/llvm-project/libcxx@bd557f6f764d1e40b62528a13b124ce740624f8f',
'src/third_party/libcxxabi': 'https://llvm.googlesource.com/llvm-project/libcxxabi@a4dda1589d37a7e4b4f7a81ebad01b1083f2e726',
'src/third_party/googletest': 'https://github.com/google/googletest@7f036c5563af7d0329f20e8bb42effb04629f0c0',
'src/third_party/dart': 'https://dart.googlesource.com/sdk.git@2da4111d8d0cbf2a83c0662251508f017000da8a',
'src/third_party/dart': 'https://dart.googlesource.com/sdk.git@e927f58e327ae13d056a16bb2ebf618e071c20a7',
'src/third_party/clang': {
'packages': [
{
Expand Down
10 changes: 10 additions & 0 deletions flutter/shell/platform/common/accessibility_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,13 @@ void AccessibilityBridge::SetStringListAttributesFromFlutterUpdate(
}
}

void AccessibilityBridge::SetIdentifierFromFlutterUpdate(
ui::AXNodeData& node_data,
const SemanticsNode& node) {
node_data.AddStringAttribute(ax::mojom::StringAttribute::kIdentifier,
node.identifier);
}

void AccessibilityBridge::SetNameFromFlutterUpdate(ui::AXNodeData& node_data,
const SemanticsNode& node) {
node_data.SetName(node.label);
Expand Down Expand Up @@ -635,6 +642,9 @@ AccessibilityBridge::FromFlutterSemanticsNode(
flutter_node.custom_accessibility_actions +
flutter_node.custom_accessibility_actions_count);
}
if (flutter_node.identifier) {
result.identifier = std::string(flutter_node.identifier);
}
return result;
}

Expand Down
3 changes: 3 additions & 0 deletions flutter/shell/platform/common/accessibility_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class AccessibilityBridge
std::vector<int32_t> children_in_traversal_order;
std::vector<int32_t> custom_accessibility_actions;
int32_t heading_level;
std::string identifier;
} SemanticsNode;

// See FlutterSemanticsCustomAction in embedder.h
Expand Down Expand Up @@ -226,6 +227,8 @@ class AccessibilityBridge
const SemanticsNode& node);
void SetStringListAttributesFromFlutterUpdate(ui::AXNodeData& node_data,
const SemanticsNode& node);
void SetIdentifierFromFlutterUpdate(ui::AXNodeData& node_data,
const SemanticsNode& node);
void SetNameFromFlutterUpdate(ui::AXNodeData& node_data,
const SemanticsNode& node);
void SetValueFromFlutterUpdate(ui::AXNodeData& node_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <cassert>
#include <cstdint>
#include <map>
#include <optional>
#include <string>
#include <utility>
#include <variant>
Expand Down Expand Up @@ -216,6 +217,23 @@ class EncodableValue : public internal::EncodableValueVariant {
return std::get<int64_t>(*this);
}

// Convenience method to simplify handling objects received from Flutter
// where the values may be larger than 32-bit, since they have the same type
// on the Dart side, but will be either 32-bit or 64-bit here depending on
// the value.
//
// Calling this method if the value doesn't contain either an int32_t or an
// int64_t will return std::nullopt.
std::optional<int64_t> TryGetLongValue() const {
if (std::holds_alternative<int32_t>(*this)) {
return std::get<int32_t>(*this);
}
if (std::holds_alternative<int64_t>(*this)) {
return std::get<int64_t>(*this);
}
return std::nullopt;
}

// The C++ Standard Library implementations can get into issues with recursive
// constraint satisfaction when (among other things) objects of this type (which
// is an `std::variant` subclass) are put into containers like `std::vector`.
Expand Down
5 changes: 3 additions & 2 deletions flutter/shell/platform/common/windowing.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
namespace flutter {

// Types of windows.
// The value must match value from WindowType in the Dart code
// in packages/flutter/lib/src/widgets/window.dart
enum class WindowArchetype {
// Regular top-level window.
kRegular,

// Dialog window.
kDialog,
};

} // namespace flutter
Expand Down
7 changes: 7 additions & 0 deletions flutter/shell/platform/embedder/embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ typedef struct {
bool is_slider;
/// Whether the semantics node represents a keyboard key.
bool is_keyboard_key;
/// Whether to block a11y focus for the semantics node.
bool is_accessibility_focus_blocked;
} FlutterSemanticsFlags;

typedef enum {
Expand Down Expand Up @@ -1742,6 +1744,11 @@ typedef struct {
/// heading; higher values (1, 2, …) indicate the heading rank, with lower
/// numbers being higher-level headings.
int32_t heading_level;
/// An identifier for the semantics node in native accessibility hierarchy.
/// This value should not be exposed to the users of the app.
/// This is usually used for UI testing with tools that work by querying the
/// native accessibility, like UI Automator, XCUITest, or Appium.
const char* identifier;
} FlutterSemanticsNode2;

/// `FlutterSemanticsCustomAction` ID used as a sentinel to signal the end of a
Expand Down
1 change: 0 additions & 1 deletion flutter/third_party/accessibility/ax/ax_active_popup.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef UI_ACCESSIBILITY_AX_ACTIVE_POPUP_H_
#define UI_ACCESSIBILITY_AX_ACTIVE_POPUP_H_

#include <cstdint>
#include <optional>

#include "ax/ax_export.h"
Expand Down
5 changes: 5 additions & 0 deletions flutter/third_party/accessibility/ax/ax_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_ACCESSIBILITY_AX_CONSTANTS_H_
#define UI_ACCESSIBILITY_AX_CONSTANTS_H_

#include <cstdint>

namespace ax {
Expand All @@ -19,3 +22,5 @@ const int32_t kUnknownAriaColumnOrRowCount = -1;
} // namespace mojom

} // namespace ax

#endif // UI_ACCESSIBILITY_AX_CONSTANTS_H_
4 changes: 4 additions & 0 deletions flutter/third_party/accessibility/ax/ax_enum_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,8 @@ const char* ToString(ax::mojom::StringAttribute string_attribute) {
return "fontFamily";
case ax::mojom::StringAttribute::kHtmlTag:
return "htmlTag";
case ax::mojom::StringAttribute::kIdentifier:
return "identifier";
case ax::mojom::StringAttribute::kImageAnnotation:
return "imageAnnotation";
case ax::mojom::StringAttribute::kImageDataUrl:
Expand Down Expand Up @@ -1493,6 +1495,8 @@ ax::mojom::StringAttribute ParseStringAttribute(const char* string_attribute) {
return ax::mojom::StringAttribute::kFontFamily;
if (0 == strcmp(string_attribute, "htmlTag"))
return ax::mojom::StringAttribute::kHtmlTag;
if (0 == strcmp(string_attribute, "identifier"))
return ax::mojom::StringAttribute::kIdentifier;
if (0 == strcmp(string_attribute, "imageAnnotation"))
return ax::mojom::StringAttribute::kImageAnnotation;
if (0 == strcmp(string_attribute, "imageDataUrl"))
Expand Down
1 change: 1 addition & 0 deletions flutter/third_party/accessibility/ax/ax_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ enum class StringAttribute {
// Only present when different from parent.
kFontFamily,
kHtmlTag,
kIdentifier,
// Stores an automatic image annotation if one is available. Only valid on
// ax::mojom::Role::kImage. See kImageAnnotationStatus, too.
kImageAnnotation,
Expand Down
9 changes: 2 additions & 7 deletions flutter/third_party/accessibility/ax/ax_event_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,9 @@ class AX_EXPORT AXEventGenerator : public AXTreeObserver {
const EventParams& event_params;
};

class AX_EXPORT Iterator {
class AX_EXPORT Iterator
: public std::iterator<std::input_iterator_tag, TargetedEvent> {
public:
using iterator_category = std::input_iterator_tag;
using value_type = TargetedEvent;
using difference_type = std::ptrdiff_t;
using pointer = TargetedEvent*;
using reference = TargetedEvent&;

Iterator(
const std::map<AXNode*, std::set<EventParams>>& map,
const std::map<AXNode*, std::set<EventParams>>::const_iterator& head);
Expand Down
4 changes: 0 additions & 4 deletions flutter/third_party/accessibility/ax/ax_event_intent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ bool operator==(const AXEventIntent& a, const AXEventIntent& b) {
a.move_direction == b.move_direction;
}

bool operator!=(const AXEventIntent& a, const AXEventIntent& b) {
return !(a == b);
}

std::string AXEventIntent::ToString() const {
return std::string("AXEventIntent(") + ui::ToString(command) + ',' +
ui::ToString(text_boundary) + ',' + ui::ToString(move_direction) + ')';
Expand Down
2 changes: 0 additions & 2 deletions flutter/third_party/accessibility/ax/ax_event_intent.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ struct AX_BASE_EXPORT AXEventIntent final {

friend AX_BASE_EXPORT bool operator==(const AXEventIntent& a,
const AXEventIntent& b);
friend AX_BASE_EXPORT bool operator!=(const AXEventIntent& a,
const AXEventIntent& b);

ax::mojom::Command command = ax::mojom::Command::kType;
// TODO(nektar): Split TextBoundary into TextUnit and TextBoundary.
Expand Down
3 changes: 3 additions & 0 deletions flutter/third_party/accessibility/ax/ax_node_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,9 @@ std::string AXNodeData::ToString() const {
case ax::mojom::StringAttribute::kHtmlTag:
result += " html_tag=" + value;
break;
case ax::mojom::StringAttribute::kIdentifier:
result += " identifer=" + value;
break;
case ax::mojom::StringAttribute::kImageAnnotation:
result += " image_annotation=" + value;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "ax/ax_role_properties.h"
#include "ax/ax_tree_data.h"
#include "base/no_destructor.h"
#include "base/string_utils.h"

#include "ax_platform_node.h"
#include "ax_platform_node_base.h"
Expand Down Expand Up @@ -629,7 +630,7 @@ std::set<AXPlatformNode*> AXPlatformNodeDelegateBase::GetReverseRelations(
}

std::u16string AXPlatformNodeDelegateBase::GetAuthorUniqueId() const {
return std::u16string();
return base::UTF8ToUTF16(GetData().GetStringAttribute(ax::mojom::StringAttribute::kIdentifier));
}

const AXUniqueId& AXPlatformNodeDelegateBase::GetUniqueId() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#import <Cocoa/Cocoa.h>

#include "base/macros.h"
#include "base/platform/darwin/scoped_nsobject.h"

#include "ax/ax_export.h"

Expand Down Expand Up @@ -39,7 +38,7 @@ class AXPlatformNodeMac : public AXPlatformNodeBase {
private:
~AXPlatformNodeMac() override;

base::scoped_nsobject<AXPlatformNodeCocoa> native_node_;
AXPlatformNodeCocoa* native_node_;

BASE_DISALLOW_COPY_AND_ASSIGN(AXPlatformNodeMac);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
using ActionList = std::vector<std::pair<ax::mojom::Action, NSString*>>;

struct AnnouncementSpec {
base::scoped_nsobject<NSString> announcement;
base::scoped_nsobject<NSWindow> window;
NSString* announcement;
NSWindow* window;
bool is_polite;
};

Expand Down Expand Up @@ -434,8 +434,8 @@ - (NSString*)getName {
return nullptr;

auto announcement = std::make_unique<AnnouncementSpec>();
announcement->announcement = base::scoped_nsobject<NSString>([announcementText retain]);
announcement->window = base::scoped_nsobject<NSWindow>([[self AXWindowInternal] retain]);
announcement->announcement = announcementText;
announcement->window = [self AXWindowInternal];
announcement->is_polite = liveStatus != "assertive";
return announcement;
}
Expand Down Expand Up @@ -498,7 +498,7 @@ - (NSArray*)accessibilityActionNames {
if (!_node)
return @[];

base::scoped_nsobject<NSMutableArray> axActions([[NSMutableArray alloc] init]);
NSMutableArray* axActions = [[NSMutableArray alloc] init];

const ui::AXNodeData& data = _node->GetData();
const ActionList& action_list = GetActionList();
Expand All @@ -514,7 +514,7 @@ - (NSArray*)accessibilityActionNames {
if (AlsoUseShowMenuActionForDefaultAction(data))
[axActions addObject:NSAccessibilityShowMenuAction];

return axActions.autorelease();
return axActions;
}

- (void)accessibilityPerformAction:(NSString*)action {
Expand Down Expand Up @@ -834,8 +834,7 @@ - (BOOL)isAccessibilitySelectorAllowed:(SEL)selector {
// accessibility clients from trying to set the selection range, which won't
// work because of 692362.
if (selector == @selector(setAccessibilitySelectedText:) ||
selector == @selector(setAccessibilitySelectedTextRange:) ||
selector == @selector(setAccessibilitySelectedTextMarkerRange:)) {
selector == @selector(setAccessibilitySelectedTextRange:)) {
return restriction != ax::mojom::Restriction::kReadOnly;
}

Expand Down Expand Up @@ -973,9 +972,7 @@ - (NSAttributedString*)accessibilityAttributedStringForRange:(NSRange)range {
if (!_node)
return nil;
// TODO(https://crbug.com/958811): Implement this for real.
base::scoped_nsobject<NSAttributedString> attributedString(
[[NSAttributedString alloc] initWithString:[self accessibilityStringForRange:range]]);
return attributedString.autorelease();
return [[NSAttributedString alloc] initWithString:[self accessibilityStringForRange:range]];
}

- (NSData*)accessibilityRTFForRange:(NSRange)range {
Expand Down Expand Up @@ -1085,8 +1082,8 @@ - (BOOL)isAccessibilityFocused {

gfx::NativeViewAccessible AXPlatformNodeMac::GetNativeViewAccessible() {
if (!native_node_)
native_node_.reset([[AXPlatformNodeCocoa alloc] initWithNode:this]);
return native_node_.get();
native_node_ = [[AXPlatformNodeCocoa alloc] initWithNode:this];
return native_node_;
}

void AXPlatformNodeMac::NotifyAccessibilityEvent(ax::mojom::Event event_type) {
Expand Down
Loading