Skip to content

Commit

Permalink
Revert "Reland: "mac_merge: remove BrowserAccessibilityCocoa accessib…
Browse files Browse the repository at this point in the history
…ilityFrame in favor of AXPlatformNodeCocoa""

This reverts commit 32a8a89.

Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=1345985

Original change's description:
> Reland: "mac_merge: remove BrowserAccessibilityCocoa accessibilityFrame in favor of AXPlatformNodeCocoa"
>
> This is a reland of commit I0a4464d3c74f52e9bd290aa8a70047ff2cd51cb5
>
> In the previous commit, the test of accessibilityFrame API caused a failure on the Mac 10.13 bot:
> https://chromium-review.googlesource.com/c/chromium/src/+/3687274
>
> These changes now filter out the "position" from the test of the API in order to prevent test flakiness. In order to do this, support for
> NSRect has been added to the @MAC-SCRIPT test framework.
>
> Original description:
> > mac_merge: remove BrowserAccessibilityCocoa accessibilityFrame in favor of AXPlatformNodeCocoa
> >
> > Bug: 939860
> > Change-Id: I4509c45f95ee16635208cb0368fae81f73347402
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3580034
> > Reviewed-by: Nektarios Paisios <nektar@chromium.org>
> > Commit-Queue: Valerie Young <spectranaut@igalia.com>
> > Cr-Commit-Position: refs/heads/main@{#1010359}
>
> Bug: 939860
> Change-Id: I726abfd86ef1890e588b638b43a318bf82824d40
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698783
> Commit-Queue: Valerie Young <spectranaut@igalia.com>
> Reviewed-by: Nektarios Paisios <nektar@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1024762}

Bug: 939860
Change-Id: I6bebd18c77edf4dd1bf71b83e278cc9d884a3389
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3777323
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Aaron Leventhal <aleventhal@chromium.org>
Commit-Queue: Valerie Young <spectranaut@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1026317}
  • Loading branch information
spectranaut authored and Chromium LUCI CQ committed Jul 20, 2022
1 parent d631d17 commit c9d2d58
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 69 deletions.
15 changes: 15 additions & 0 deletions content/browser/accessibility/browser_accessibility_cocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2645,6 +2645,21 @@ - (BOOL)isAccessibilityEnabled {
ax::mojom::Restriction::kDisabled;
}

- (NSRect)accessibilityFrame {
if (![self instanceActive])
return NSZeroRect;

BrowserAccessibilityManager* manager = _owner->manager();
auto rect = _owner->GetBoundsRect(ui::AXCoordinateSystem::kScreenDIPs,
ui::AXClippingBehavior::kClipped);

// TODO(vmpstr): GetBoundsRect() call above should account for this instead.
auto result_rect =
ScaleToRoundedRect(rect, 1.f / manager->device_scale_factor());

return gfx::ScreenRectToNSRect(result_rect);
}

- (BOOL)isCheckable {
if (![self instanceActive])
return NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,6 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest,
RunTypedTest<kMacMethods>("accessibility-column-header-ui-elements.html");
}

IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AccessibilityFrame) {
RunTypedTest<kMacMethods>("accessibility-frame.html");
}

IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AccessibilityIsIgnored) {
RunTypedTest<kMacMethods>("accessibility-is-ignored.html");
}
Expand Down

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions ui/accessibility/platform/ax_platform_node_cocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ AX_EXPORT
- (instancetype)initWithNode:(ui::AXPlatformNodeBase*)node;
- (void)detach;

@property(nonatomic, readonly) NSRect boundsInScreen;
@property(nonatomic, readonly) ui::AXPlatformNodeBase* node;
@property(nonatomic, readonly) ui::AXPlatformNodeDelegate* nodeDelegate;

Expand Down
18 changes: 11 additions & 7 deletions ui/accessibility/platform/ax_platform_node_cocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,13 @@ - (void)detach {
self, NSAccessibilityUIElementDestroyedNotification);
}

- (NSRect)boundsInScreen {
if (!_node || !_node->GetDelegate())
return NSZeroRect;
return gfx::ScreenRectToNSRect(_node->GetDelegate()->GetBoundsRect(
ui::AXCoordinateSystem::kScreenDIPs, ui::AXClippingBehavior::kClipped));
}

- (NSString*)getStringAttribute:(ax::mojom::StringAttribute)attribute {
std::string attributeValue;
if (_node->GetStringAttribute(attribute, &attributeValue))
Expand Down Expand Up @@ -763,7 +770,7 @@ - (BOOL)accessibilityIsIgnored {
}

- (id)accessibilityHitTest:(NSPoint)point {
if (!NSPointInRect(point, [self accessibilityFrame]))
if (!NSPointInRect(point, [self boundsInScreen]))
return nil;

for (id child in [[self AXChildren] reverseObjectEnumerator]) {
Expand Down Expand Up @@ -1572,11 +1579,11 @@ - (id)AXTopLevelUIElement {
}

- (NSValue*)AXPosition {
return [NSValue valueWithPoint:self.accessibilityFrame.origin];
return [NSValue valueWithPoint:self.boundsInScreen.origin];
}

- (NSValue*)AXSize {
return [NSValue valueWithSize:self.accessibilityFrame.size];
return [NSValue valueWithSize:self.boundsInScreen.size];
}

- (NSString*)AXTitle {
Expand Down Expand Up @@ -1761,10 +1768,7 @@ - (BOOL)isAccessibilityEnabled {
}

- (NSRect)accessibilityFrame {
if (!_node || !_node->GetDelegate())
return NSZeroRect;
return gfx::ScreenRectToNSRect(_node->GetDelegate()->GetBoundsRect(
ui::AXCoordinateSystem::kScreenDIPs, ui::AXClippingBehavior::kClipped));
return [self boundsInScreen];
}

- (NSString*)accessibilityLabel {
Expand Down
2 changes: 0 additions & 2 deletions ui/accessibility/platform/ax_utils_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ namespace ui {

class AXPlatformNodeCocoa;

AX_EXPORT bool IsNSRect(id object);

// An AXTextMarker is used by applications like Chrome to store a position in
// the accessibility tree's text representation. It is a data structure whose
// contents are opaque to the system but whose allocation and deallocation is
Expand Down
8 changes: 0 additions & 8 deletions ui/accessibility/platform/ax_utils_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ AXTextMarkerRangeRef AXTextMarkerRangeCreate(CFAllocatorRef,

namespace ui {

bool IsNSRect(id object) {
if (object == nil || ![object isKindOfClass:[NSValue class]])
return false;
if (0 == strcmp([object objCType], @encode(NSRect)))
return true;
return false;
}

bool IsAXTextMarker(id object) {
if (object == nil)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ class AX_EXPORT AXCallStatementInvoker final {
const id target,
const AXPropertyNode& property_node) const;

// Invokes a property node for a given NSRect.
AXOptionalNSObject InvokeForRect(const id target,
const AXPropertyNode& property_node) const;

// Invokes setAccessibilityFocused method.
AXOptionalNSObject InvokeSetAccessibilityFocused(
const id target,
Expand Down
26 changes: 0 additions & 26 deletions ui/accessibility/platform/inspect/ax_call_statement_invoker_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,6 @@
return InvokeForAXTextMarkerRange(target, property_node);
}

if (IsNSRect(target)) {
return InvokeForRect(target, property_node);
}

if ([target isKindOfClass:[NSArray class]])
return InvokeForArray(target, property_node);

Expand Down Expand Up @@ -402,28 +398,6 @@
return AXOptionalNSObject::NotNullOrError(dictionary[key]);
}

AXOptionalNSObject AXCallStatementInvoker::InvokeForRect(
const id target,
const AXPropertyNode& property_node) const {
NSValue* value = target;
NSRect rect = value.rectValue;

if (property_node.name_or_value == "size") {
NSValue* size = [NSValue valueWithSize:rect.size];
return AXOptionalNSObject(size);
}

if (property_node.name_or_value == "position") {
NSValue* position = [NSValue valueWithPoint:rect.origin];
return AXOptionalNSObject(position);
}

LOG(ERROR) << "Unrecognized '" << property_node.name_or_value
<< "' attribute called on NSRect in '"
<< property_node.ToFlatString() << "' statement";
return AXOptionalNSObject::Error();
}

AXOptionalNSObject AXCallStatementInvoker::InvokeSetAccessibilityFocused(
const id target,
const AXPropertyNode& property_node) const {
Expand Down

0 comments on commit c9d2d58

Please sign in to comment.