Bug 1737869 - Fix build with the macOS 12 SDK, by using AXTextMarker(Range)Ref instead of id and by ifdefing the declarations that are now public in the new SDK. r=eeejay

I think this patch is functionally neutral.
I'm not completely sure about the best way to do these casts - the __bridge may not be
necessary since we don't use ARC yet. But it's probably fine to add it anyway.
Also, returning autoreleased CFTypeRef objects seems a bit weird, but it's what we've
already been doing and it's probably fine.
And some of these nils should maybe be nullptrs, but the compiler doesn't seem to care.

Differential Revision: https://phabricator.services.mozilla.com/D129559
This commit is contained in:
Markus Stange 2021-10-27 20:38:07 +00:00
parent 739d179b38
commit b0068bfe22
8 changed files with 181 additions and 130 deletions

View File

@ -9,8 +9,12 @@
#ifndef _GeckoTextMarker_H_
#define _GeckoTextMarker_H_
typedef CFTypeRef AXTextMarkerRef;
typedef CFTypeRef AXTextMarkerRangeRef;
#include <ApplicationServices/ApplicationServices.h>
#include <Foundation/Foundation.h>
#include "HyperTextAccessibleWrap.h"
#include "PlatformExtTypes.h"
#include "SDKDeclarations.h"
namespace mozilla {
namespace a11y {
@ -32,7 +36,7 @@ class GeckoTextMarker final {
static GeckoTextMarker MarkerFromIndex(Accessible* aRoot, int32_t aIndex);
id CreateAXTextMarker();
AXTextMarkerRef CreateAXTextMarker();
bool Next();
@ -77,7 +81,7 @@ class GeckoTextMarkerRange final {
explicit GeckoTextMarkerRange(Accessible* aAccessible);
id CreateAXTextMarkerRange();
AXTextMarkerRangeRef CreateAXTextMarkerRange();
bool IsValid() const { return !!mStart.mContainer && !!mEnd.mContainer; };

View File

@ -5,38 +5,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#import "GeckoTextMarker.h"
#include "DocAccessible.h"
#include "DocAccessibleParent.h"
#include "AccAttributes.h"
#include "nsCocoaUtils.h"
#include "MOXAccessibleBase.h"
#include "mozAccessible.h"
#include "mozilla/a11y/DocAccessiblePlatformExtParent.h"
#import "GeckoTextMarker.h"
extern "C" {
CFTypeID AXTextMarkerGetTypeID();
AXTextMarkerRef AXTextMarkerCreate(CFAllocatorRef allocator, const UInt8* bytes,
CFIndex length);
const UInt8* AXTextMarkerGetBytePtr(AXTextMarkerRef text_marker);
size_t AXTextMarkerGetLength(AXTextMarkerRef text_marker);
CFTypeID AXTextMarkerRangeGetTypeID();
AXTextMarkerRangeRef AXTextMarkerRangeCreate(CFAllocatorRef allocator,
AXTextMarkerRef start_marker,
AXTextMarkerRef end_marker);
AXTextMarkerRef AXTextMarkerRangeCopyStartMarker(
AXTextMarkerRangeRef text_marker_range);
AXTextMarkerRef AXTextMarkerRangeCopyEndMarker(
AXTextMarkerRangeRef text_marker_range);
}
namespace mozilla {
namespace a11y {
@ -123,7 +102,7 @@ GeckoTextMarker GeckoTextMarker::MarkerFromIndex(Accessible* aRoot,
return GeckoTextMarker();
}
id GeckoTextMarker::CreateAXTextMarker() {
AXTextMarkerRef GeckoTextMarker::CreateAXTextMarker() {
if (!IsValid()) {
return nil;
}
@ -146,7 +125,7 @@ id GeckoTextMarker::CreateAXTextMarker() {
kCFAllocatorDefault, reinterpret_cast<const UInt8*>(&opaqueMarker),
sizeof(OpaqueGeckoTextMarker));
return [static_cast<id>(cf_text_marker) autorelease];
return (__bridge AXTextMarkerRef)[(__bridge id)(cf_text_marker)autorelease];
}
bool GeckoTextMarker::operator<(const GeckoTextMarker& aPoint) const {
@ -380,7 +359,7 @@ GeckoTextMarkerRange::GeckoTextMarkerRange(Accessible* aAccessible) {
}
}
id GeckoTextMarkerRange::CreateAXTextMarkerRange() {
AXTextMarkerRangeRef GeckoTextMarkerRange::CreateAXTextMarkerRange() {
if (!IsValid()) {
return nil;
}
@ -388,7 +367,9 @@ id GeckoTextMarkerRange::CreateAXTextMarkerRange() {
AXTextMarkerRangeRef cf_text_marker_range =
AXTextMarkerRangeCreate(kCFAllocatorDefault, mStart.CreateAXTextMarker(),
mEnd.CreateAXTextMarker());
return [static_cast<id>(cf_text_marker_range) autorelease];
return (__bridge AXTextMarkerRangeRef)[(__bridge id)(
cf_text_marker_range)autorelease];
}
NSString* GeckoTextMarkerRange::Text() const {

View File

@ -5,7 +5,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "SDKDeclarations.h"
@protocol MOXTextMarkerSupport;
@protocol mozAccessible;
// This protocol's primary use is for abstracting the NSAccessibility informal
// protocol into a formal internal API. Conforming classes get to choose a
@ -418,89 +421,101 @@
#pragma mark - TextAttributeGetters
// AXStartTextMarker
- (id _Nullable)moxStartTextMarker;
- (AXTextMarkerRef _Nullable)moxStartTextMarker;
// AXEndTextMarker
- (id _Nullable)moxEndTextMarker;
- (AXTextMarkerRef _Nullable)moxEndTextMarker;
// AXSelectedTextMarkerRange
- (id _Nullable)moxSelectedTextMarkerRange;
- (AXTextMarkerRangeRef _Nullable)moxSelectedTextMarkerRange;
#pragma mark - ParameterizedTextAttributeGetters
// AXLengthForTextMarkerRange
- (NSNumber* _Nullable)moxLengthForTextMarkerRange:(id _Nonnull)textMarkerRange;
- (NSNumber* _Nullable)moxLengthForTextMarkerRange:
(AXTextMarkerRangeRef _Nonnull)textMarkerRange;
// AXStringForTextMarkerRange
- (NSString* _Nullable)moxStringForTextMarkerRange:(id _Nonnull)textMarkerRange;
- (NSString* _Nullable)moxStringForTextMarkerRange:
(AXTextMarkerRangeRef _Nonnull)textMarkerRange;
// AXTextMarkerRangeForUnorderedTextMarkers
- (id _Nullable)moxTextMarkerRangeForUnorderedTextMarkers:
- (AXTextMarkerRangeRef _Nullable)moxTextMarkerRangeForUnorderedTextMarkers:
(NSArray* _Nonnull)textMarkers;
// AXLeftWordTextMarkerRangeForTextMarker
- (id _Nullable)moxLeftWordTextMarkerRangeForTextMarker:(id _Nonnull)textMarker;
- (AXTextMarkerRangeRef _Nullable)moxLeftWordTextMarkerRangeForTextMarker:
(AXTextMarkerRef _Nonnull)textMarker;
// AXRightWordTextMarkerRangeForTextMarker
- (id _Nullable)moxRightWordTextMarkerRangeForTextMarker:
(id _Nonnull)textMarker;
- (AXTextMarkerRangeRef _Nullable)moxRightWordTextMarkerRangeForTextMarker:
(AXTextMarkerRef _Nonnull)textMarker;
// AXStartTextMarkerForTextMarkerRange
- (id _Nullable)moxStartTextMarkerForTextMarkerRange:
(id _Nonnull)textMarkerRange;
- (AXTextMarkerRef _Nullable)moxStartTextMarkerForTextMarkerRange:
(AXTextMarkerRangeRef _Nonnull)textMarkerRange;
// AXEndTextMarkerForTextMarkerRange
- (id _Nullable)moxEndTextMarkerForTextMarkerRange:(id _Nonnull)textMarkerRange;
- (AXTextMarkerRef _Nullable)moxEndTextMarkerForTextMarkerRange:
(AXTextMarkerRangeRef _Nonnull)textMarkerRange;
// AXNextTextMarkerForTextMarker
- (id _Nullable)moxNextTextMarkerForTextMarker:(id _Nonnull)textMarker;
- (AXTextMarkerRef _Nullable)moxNextTextMarkerForTextMarker:
(AXTextMarkerRef _Nonnull)textMarker;
// AXPreviousTextMarkerForTextMarker
- (id _Nullable)moxPreviousTextMarkerForTextMarker:(id _Nonnull)textMarker;
- (AXTextMarkerRef _Nullable)moxPreviousTextMarkerForTextMarker:
(AXTextMarkerRef _Nonnull)textMarker;
// AXAttributedStringForTextMarkerRange
- (NSAttributedString* _Nullable)moxAttributedStringForTextMarkerRange:
(id _Nonnull)textMarkerRange;
(AXTextMarkerRangeRef _Nonnull)textMarkerRange;
// AXBoundsForTextMarkerRange
- (NSValue* _Nullable)moxBoundsForTextMarkerRange:(id _Nonnull)textMarkerRange;
- (NSValue* _Nullable)moxBoundsForTextMarkerRange:
(AXTextMarkerRangeRef _Nonnull)textMarkerRange;
// AXIndexForTextMarker
- (NSNumber* _Nullable)moxIndexForTextMarker:(id _Nonnull)textMarker;
- (NSNumber* _Nullable)moxIndexForTextMarker:
(AXTextMarkerRef _Nonnull)textMarker;
// AXTextMarkerForIndex
- (id _Nullable)moxTextMarkerForIndex:(NSNumber* _Nonnull)index;
- (AXTextMarkerRef _Nullable)moxTextMarkerForIndex:(NSNumber* _Nonnull)index;
// AXUIElementForTextMarker
- (id _Nullable)moxUIElementForTextMarker:(id _Nonnull)textMarker;
- (id _Nullable)moxUIElementForTextMarker:(AXTextMarkerRef _Nonnull)textMarker;
// AXTextMarkerRangeForUIElement
- (id _Nullable)moxTextMarkerRangeForUIElement:(id _Nonnull)element;
- (AXTextMarkerRangeRef _Nullable)moxTextMarkerRangeForUIElement:
(id _Nonnull)element;
// AXLineTextMarkerRangeForTextMarker
- (id _Nullable)moxLineTextMarkerRangeForTextMarker:(id _Nonnull)textMarker;
- (AXTextMarkerRangeRef _Nullable)moxLineTextMarkerRangeForTextMarker:
(AXTextMarkerRef _Nonnull)textMarker;
// AXLeftLineTextMarkerRangeForTextMarker
- (id _Nullable)moxLeftLineTextMarkerRangeForTextMarker:(id _Nonnull)textMarker;
- (AXTextMarkerRangeRef _Nullable)moxLeftLineTextMarkerRangeForTextMarker:
(AXTextMarkerRef _Nonnull)textMarker;
// AXRightLineTextMarkerRangeForTextMarker
- (id _Nullable)moxRightLineTextMarkerRangeForTextMarker:
(id _Nonnull)textMarker;
- (AXTextMarkerRangeRef _Nullable)moxRightLineTextMarkerRangeForTextMarker:
(AXTextMarkerRef _Nonnull)textMarker;
// AXParagraphTextMarkerRangeForTextMarker
- (id _Nullable)moxParagraphTextMarkerRangeForTextMarker:
(id _Nonnull)textMarker;
- (AXTextMarkerRangeRef _Nullable)moxParagraphTextMarkerRangeForTextMarker:
(AXTextMarkerRef _Nonnull)textMarker;
// AXStyleTextMarkerRangeForTextMarker
- (id _Nullable)moxStyleTextMarkerRangeForTextMarker:(id _Nonnull)textMarker;
- (AXTextMarkerRangeRef _Nullable)moxStyleTextMarkerRangeForTextMarker:
(AXTextMarkerRef _Nonnull)textMarker;
// AXMozDebugDescriptionForTextMarker
- (NSString* _Nullable)moxMozDebugDescriptionForTextMarker:
(id _Nonnull)textMarker;
(AXTextMarkerRef _Nonnull)textMarker;
// AXMozDebugDescriptionForTextMarkerRange
- (NSString* _Nullable)moxMozDebugDescriptionForTextMarkerRange:
(id _Nonnull)textMarkerRange;
(AXTextMarkerRangeRef _Nonnull)textMarkerRange;
#pragma mark - TextAttributeSetters

View File

@ -12,9 +12,9 @@
@interface MOXTextMarkerDelegate : NSObject <MOXTextMarkerSupport> {
mozilla::a11y::Accessible* mGeckoDocAccessible;
id mSelection;
id mCaret;
id mPrevCaret;
AXTextMarkerRangeRef mSelection;
AXTextMarkerRef mCaret;
AXTextMarkerRef mPrevCaret;
}
+ (id)getOrCreateForDoc:(mozilla::a11y::Accessible*)aDoc;
@ -39,74 +39,85 @@
- (mozilla::a11y::GeckoTextMarkerRange)selection;
// override
- (id)moxStartTextMarker;
- (AXTextMarkerRef)moxStartTextMarker;
// override
- (id)moxEndTextMarker;
- (AXTextMarkerRef)moxEndTextMarker;
// override
- (id)moxSelectedTextMarkerRange;
- (AXTextMarkerRangeRef)moxSelectedTextMarkerRange;
// override
- (NSNumber*)moxLengthForTextMarkerRange:(id)textMarkerRange;
- (NSNumber*)moxLengthForTextMarkerRange:(AXTextMarkerRangeRef)textMarkerRange;
// override
- (NSString*)moxStringForTextMarkerRange:(id)textMarkerRange;
- (NSString*)moxStringForTextMarkerRange:(AXTextMarkerRangeRef)textMarkerRange;
// override
- (id)moxTextMarkerRangeForUnorderedTextMarkers:(NSArray*)textMarkers;
- (AXTextMarkerRangeRef)moxTextMarkerRangeForUnorderedTextMarkers:
(NSArray*)textMarkers;
// override
- (id)moxStartTextMarkerForTextMarkerRange:(id)textMarkerRange;
- (AXTextMarkerRef)moxStartTextMarkerForTextMarkerRange:
(AXTextMarkerRangeRef)textMarkerRange;
// override
- (id)moxEndTextMarkerForTextMarkerRange:(id)textMarkerRange;
- (AXTextMarkerRef)moxEndTextMarkerForTextMarkerRange:
(AXTextMarkerRangeRef)textMarkerRange;
// override
- (id)moxLeftWordTextMarkerRangeForTextMarker:(id)textMarker;
- (AXTextMarkerRangeRef)moxLeftWordTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker;
// override
- (id)moxRightWordTextMarkerRangeForTextMarker:(id)textMarker;
- (AXTextMarkerRangeRef)moxRightWordTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker;
// override
- (id)moxLineTextMarkerRangeForTextMarker:(id)textMarker;
- (AXTextMarkerRangeRef)moxLineTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker;
// override
- (id)moxLeftLineTextMarkerRangeForTextMarker:(id)textMarker;
- (AXTextMarkerRangeRef)moxLeftLineTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker;
// override
- (id)moxRightLineTextMarkerRangeForTextMarker:(id)textMarker;
- (AXTextMarkerRangeRef)moxRightLineTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker;
// override
- (id)moxParagraphTextMarkerRangeForTextMarker:(id)textMarker;
- (AXTextMarkerRangeRef)moxParagraphTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker;
// override
- (id)moxStyleTextMarkerRangeForTextMarker:(id)textMarker;
- (AXTextMarkerRangeRef)moxStyleTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker;
// override
- (id)moxNextTextMarkerForTextMarker:(id)textMarker;
- (AXTextMarkerRef)moxNextTextMarkerForTextMarker:(AXTextMarkerRef)textMarker;
// override
- (id)moxPreviousTextMarkerForTextMarker:(id)textMarker;
- (AXTextMarkerRef)moxPreviousTextMarkerForTextMarker:
(AXTextMarkerRef)textMarker;
// override
- (NSAttributedString*)moxAttributedStringForTextMarkerRange:
(id)textMarkerRange;
(AXTextMarkerRangeRef)textMarkerRange;
// override
- (NSValue*)moxBoundsForTextMarkerRange:(id)textMarkerRange;
- (NSValue*)moxBoundsForTextMarkerRange:(AXTextMarkerRangeRef)textMarkerRange;
// override
- (id)moxUIElementForTextMarker:(id)textMarker;
- (id)moxUIElementForTextMarker:(AXTextMarkerRef)textMarker;
// override
- (id)moxTextMarkerRangeForUIElement:(id)element;
- (AXTextMarkerRangeRef)moxTextMarkerRangeForUIElement:(id)element;
// override
- (NSString*)moxMozDebugDescriptionForTextMarker:(id)textMarker;
- (NSString*)moxMozDebugDescriptionForTextMarker:(AXTextMarkerRef)textMarker;
// override
- (void)moxSetSelectedTextMarkerRange:(id)textMarkerRange;
- (void)moxSetSelectedTextMarkerRange:(AXTextMarkerRangeRef)textMarkerRange;
@end

View File

@ -6,11 +6,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#import <Cocoa/Cocoa.h>
#include "mozilla/Preferences.h"
#include "DocAccessible.h"
#import "MOXTextMarkerDelegate.h"
#include "mozAccessible.h"
#include "mozilla/Preferences.h"
using namespace mozilla::a11y;
#define PREF_ACCESSIBILITY_MAC_DEBUG "accessibility.mac.debug"
@ -69,7 +71,8 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
// way to keep a weak reference - when we need to use the
// range we can convert it back to a GeckoTextMarkerRange
// and check that it's valid.
mSelection = [selection.CreateAXTextMarkerRange() retain];
mSelection = selection.CreateAXTextMarkerRange();
CFRetain(mSelection);
}
- (void)setCaretOffset:(mozilla::a11y::Accessible*)container
@ -77,7 +80,8 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
GeckoTextMarker caretMarker(container, offset);
mPrevCaret = mCaret;
mCaret = [caretMarker.CreateAXTextMarker() retain];
mCaret = caretMarker.CreateAXTextMarker();
CFRetain(mCaret);
}
// This returns an info object to pass with AX SelectedTextChanged events.
@ -94,8 +98,9 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
// This is the base info object, includes the selected marker range and
// the change type depending on the collapsed state of the selection.
NSMutableDictionary* info = [[@{
@"AXSelectedTextMarkerRange" : selectedGeckoRange.IsValid() ? mSelection
: [NSNull null],
@"AXSelectedTextMarkerRange" : selectedGeckoRange.IsValid()
? (__bridge id)mSelection
: [NSNull null],
@"AXTextStateChangeType" : @(stateChangeType),
} mutableCopy] autorelease];
@ -162,9 +167,9 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
}
- (void)invalidateSelection {
[mSelection release];
[mCaret release];
[mPrevCaret release];
CFRelease(mSelection);
CFRelease(mCaret);
CFRelease(mPrevCaret);
mSelection = nil;
}
@ -172,12 +177,12 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return mozilla::a11y::GeckoTextMarkerRange(mGeckoDocAccessible, mSelection);
}
- (id)moxStartTextMarker {
- (AXTextMarkerRef)moxStartTextMarker {
GeckoTextMarker geckoTextPoint(mGeckoDocAccessible, 0);
return geckoTextPoint.CreateAXTextMarker();
}
- (id)moxEndTextMarker {
- (AXTextMarkerRef)moxEndTextMarker {
uint32_t characterCount =
mGeckoDocAccessible->IsRemote()
? mGeckoDocAccessible->AsRemote()->CharacterCount()
@ -189,14 +194,14 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return geckoTextPoint.CreateAXTextMarker();
}
- (id)moxSelectedTextMarkerRange {
- (AXTextMarkerRangeRef)moxSelectedTextMarkerRange {
return mSelection &&
GeckoTextMarkerRange(mGeckoDocAccessible, mSelection).IsValid()
? mSelection
: nil;
}
- (NSString*)moxStringForTextMarkerRange:(id)textMarkerRange {
- (NSString*)moxStringForTextMarkerRange:(AXTextMarkerRangeRef)textMarkerRange {
mozilla::a11y::GeckoTextMarkerRange range(mGeckoDocAccessible,
textMarkerRange);
if (!range.IsValid()) {
@ -206,18 +211,21 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return range.Text();
}
- (NSNumber*)moxLengthForTextMarkerRange:(id)textMarkerRange {
- (NSNumber*)moxLengthForTextMarkerRange:(AXTextMarkerRangeRef)textMarkerRange {
return @([[self moxStringForTextMarkerRange:textMarkerRange] length]);
}
- (id)moxTextMarkerRangeForUnorderedTextMarkers:(NSArray*)textMarkers {
- (AXTextMarkerRangeRef)moxTextMarkerRangeForUnorderedTextMarkers:
(NSArray*)textMarkers {
if ([textMarkers count] != 2) {
// Don't allow anything but a two member array.
return nil;
}
GeckoTextMarker p1(mGeckoDocAccessible, textMarkers[0]);
GeckoTextMarker p2(mGeckoDocAccessible, textMarkers[1]);
GeckoTextMarker p1(mGeckoDocAccessible,
(__bridge AXTextMarkerRef)textMarkers[0]);
GeckoTextMarker p2(mGeckoDocAccessible,
(__bridge AXTextMarkerRef)textMarkers[1]);
if (!p1.IsValid() || !p2.IsValid()) {
// If either marker is invalid, return nil.
@ -230,21 +238,24 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return range.CreateAXTextMarkerRange();
}
- (id)moxStartTextMarkerForTextMarkerRange:(id)textMarkerRange {
- (AXTextMarkerRef)moxStartTextMarkerForTextMarkerRange:
(AXTextMarkerRangeRef)textMarkerRange {
mozilla::a11y::GeckoTextMarkerRange range(mGeckoDocAccessible,
textMarkerRange);
return range.IsValid() ? range.mStart.CreateAXTextMarker() : nil;
}
- (id)moxEndTextMarkerForTextMarkerRange:(id)textMarkerRange {
- (AXTextMarkerRef)moxEndTextMarkerForTextMarkerRange:
(AXTextMarkerRangeRef)textMarkerRange {
mozilla::a11y::GeckoTextMarkerRange range(mGeckoDocAccessible,
textMarkerRange);
return range.IsValid() ? range.mEnd.CreateAXTextMarker() : nil;
}
- (id)moxLeftWordTextMarkerRangeForTextMarker:(id)textMarker {
- (AXTextMarkerRangeRef)moxLeftWordTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker {
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
if (!geckoTextMarker.IsValid()) {
return nil;
@ -254,7 +265,8 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
.CreateAXTextMarkerRange();
}
- (id)moxRightWordTextMarkerRangeForTextMarker:(id)textMarker {
- (AXTextMarkerRangeRef)moxRightWordTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker {
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
if (!geckoTextMarker.IsValid()) {
return nil;
@ -264,7 +276,8 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
.CreateAXTextMarkerRange();
}
- (id)moxLineTextMarkerRangeForTextMarker:(id)textMarker {
- (AXTextMarkerRangeRef)moxLineTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker {
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
if (!geckoTextMarker.IsValid()) {
return nil;
@ -273,7 +286,8 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return geckoTextMarker.Range(EWhichRange::eLine).CreateAXTextMarkerRange();
}
- (id)moxLeftLineTextMarkerRangeForTextMarker:(id)textMarker {
- (AXTextMarkerRangeRef)moxLeftLineTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker {
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
if (!geckoTextMarker.IsValid()) {
return nil;
@ -283,7 +297,8 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
.CreateAXTextMarkerRange();
}
- (id)moxRightLineTextMarkerRangeForTextMarker:(id)textMarker {
- (AXTextMarkerRangeRef)moxRightLineTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker {
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
if (!geckoTextMarker.IsValid()) {
return nil;
@ -293,7 +308,8 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
.CreateAXTextMarkerRange();
}
- (id)moxParagraphTextMarkerRangeForTextMarker:(id)textMarker {
- (AXTextMarkerRangeRef)moxParagraphTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker {
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
if (!geckoTextMarker.IsValid()) {
return nil;
@ -304,7 +320,8 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
}
// override
- (id)moxStyleTextMarkerRangeForTextMarker:(id)textMarker {
- (AXTextMarkerRangeRef)moxStyleTextMarkerRangeForTextMarker:
(AXTextMarkerRef)textMarker {
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
if (!geckoTextMarker.IsValid()) {
return nil;
@ -313,7 +330,7 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return geckoTextMarker.Range(EWhichRange::eStyle).CreateAXTextMarkerRange();
}
- (id)moxNextTextMarkerForTextMarker:(id)textMarker {
- (AXTextMarkerRef)moxNextTextMarkerForTextMarker:(AXTextMarkerRef)textMarker {
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
if (!geckoTextMarker.IsValid()) {
return nil;
@ -326,7 +343,8 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return geckoTextMarker.CreateAXTextMarker();
}
- (id)moxPreviousTextMarkerForTextMarker:(id)textMarker {
- (AXTextMarkerRef)moxPreviousTextMarkerForTextMarker:
(AXTextMarkerRef)textMarker {
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
if (!geckoTextMarker.IsValid()) {
return nil;
@ -340,7 +358,7 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
}
- (NSAttributedString*)moxAttributedStringForTextMarkerRange:
(id)textMarkerRange {
(AXTextMarkerRangeRef)textMarkerRange {
mozilla::a11y::GeckoTextMarkerRange range(mGeckoDocAccessible,
textMarkerRange);
if (!range.IsValid()) {
@ -350,7 +368,7 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return range.AttributedText();
}
- (NSValue*)moxBoundsForTextMarkerRange:(id)textMarkerRange {
- (NSValue*)moxBoundsForTextMarkerRange:(AXTextMarkerRangeRef)textMarkerRange {
mozilla::a11y::GeckoTextMarkerRange range(mGeckoDocAccessible,
textMarkerRange);
if (!range.IsValid()) {
@ -360,7 +378,7 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return range.Bounds();
}
- (NSNumber*)moxIndexForTextMarker:(id)textMarker {
- (NSNumber*)moxIndexForTextMarker:(AXTextMarkerRef)textMarker {
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
if (!geckoTextMarker.IsValid()) {
return nil;
@ -372,7 +390,7 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return @(range.Length());
}
- (id)moxTextMarkerForIndex:(NSNumber*)index {
- (AXTextMarkerRef)moxTextMarkerForIndex:(NSNumber*)index {
GeckoTextMarker geckoTextMarker = GeckoTextMarker::MarkerFromIndex(
mGeckoDocAccessible, [index integerValue]);
if (!geckoTextMarker.IsValid()) {
@ -382,7 +400,7 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return geckoTextMarker.CreateAXTextMarker();
}
- (id)moxUIElementForTextMarker:(id)textMarker {
- (id)moxUIElementForTextMarker:(AXTextMarkerRef)textMarker {
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
if (!geckoTextMarker.IsValid()) {
return nil;
@ -396,17 +414,17 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
return GetNativeFromGeckoAccessible(leaf);
}
- (id)moxTextMarkerRangeForUIElement:(id)element {
- (AXTextMarkerRangeRef)moxTextMarkerRangeForUIElement:(id)element {
if (![element isKindOfClass:[mozAccessible class]]) {
return nil;
}
GeckoTextMarkerRange range([element geckoAccessible]);
GeckoTextMarkerRange range((Accessible*)[element geckoAccessible]);
return range.CreateAXTextMarkerRange();
}
- (NSString*)moxMozDebugDescriptionForTextMarker:(id)textMarker {
if (!Preferences::GetBool(PREF_ACCESSIBILITY_MAC_DEBUG)) {
- (NSString*)moxMozDebugDescriptionForTextMarker:(AXTextMarkerRef)textMarker {
if (!mozilla::Preferences::GetBool(PREF_ACCESSIBILITY_MAC_DEBUG)) {
return nil;
}
@ -420,8 +438,9 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
geckoTextMarker.mOffset];
}
- (NSString*)moxMozDebugDescriptionForTextMarkerRange:(id)textMarkerRange {
if (!Preferences::GetBool(PREF_ACCESSIBILITY_MAC_DEBUG)) {
- (NSString*)moxMozDebugDescriptionForTextMarkerRange:
(AXTextMarkerRangeRef)textMarkerRange {
if (!mozilla::Preferences::GetBool(PREF_ACCESSIBILITY_MAC_DEBUG)) {
return nil;
}
@ -437,7 +456,7 @@ static nsTHashMap<nsPtrHashKey<mozilla::a11y::Accessible>,
range.mEnd.mContainer, range.mEnd.mOffset];
}
- (void)moxSetSelectedTextMarkerRange:(id)textMarkerRange {
- (void)moxSetSelectedTextMarkerRange:(AXTextMarkerRangeRef)textMarkerRange {
mozilla::a11y::GeckoTextMarkerRange range(mGeckoDocAccessible,
textMarkerRange);
if (range.IsValid()) {

View File

@ -306,7 +306,8 @@ inline NSString* ToNSString(id aValue) {
@"AXTextStateChangeType" : @(AXTextStateChangeTypeEdit),
@"AXTextChangeValues" : @[ @{
@"AXTextChangeValue" : (change ? change : @""),
@"AXTextChangeValueStartMarker" : startMarker.CreateAXTextMarker(),
@"AXTextChangeValueStartMarker" :
(__bridge id)startMarker.CreateAXTextMarker(),
@"AXTextEditType" : isInserted ? @(AXTextEditTypeTyping)
: @(AXTextEditTypeDelete)
} ]

View File

@ -101,4 +101,23 @@ typedef NS_ENUM(NSInteger, NSTitlebarSeparatorStyle) {
#endif
#if !defined(MAC_OS_VERSION_12_0) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0
typedef CFTypeRef AXTextMarkerRef;
typedef CFTypeRef AXTextMarkerRangeRef;
extern "C" {
CFTypeID AXTextMarkerGetTypeID();
AXTextMarkerRef AXTextMarkerCreate(CFAllocatorRef allocator, const UInt8* bytes, CFIndex length);
const UInt8* AXTextMarkerGetBytePtr(AXTextMarkerRef text_marker);
CFIndex AXTextMarkerGetLength(AXTextMarkerRef text_marker);
CFTypeID AXTextMarkerRangeGetTypeID();
AXTextMarkerRangeRef AXTextMarkerRangeCreate(CFAllocatorRef allocator, AXTextMarkerRef start_marker,
AXTextMarkerRef end_marker);
AXTextMarkerRef AXTextMarkerRangeCopyStartMarker(AXTextMarkerRangeRef text_marker_range);
AXTextMarkerRef AXTextMarkerRangeCopyEndMarker(AXTextMarkerRangeRef text_marker_range);
}
#endif
#endif // SDKDefines_h

View File

@ -27,6 +27,7 @@ EXPORTS += [
"nsChangeObserver.h",
"nsCocoaFeatures.h",
"nsCocoaUtils.h",
"SDKDeclarations.h",
]
EXPORTS.mozilla.widget += [