fix: undisable AXTextMarker and related APIs on MAS (#32543)
This commit is contained in:
parent
6b41356868
commit
87b3f6db9d
1 changed files with 0 additions and 417 deletions
|
@ -6,423 +6,6 @@ Subject: mas: avoid some private APIs
|
|||
Guard usages in blink of private Mac APIs by MAS_BUILD, so they can be
|
||||
excluded for people who want to submit their apps to the Mac App store.
|
||||
|
||||
diff --git a/content/browser/accessibility/accessibility_tree_formatter_mac.mm b/content/browser/accessibility/accessibility_tree_formatter_mac.mm
|
||||
index dc33d3674d6c3cf794a401a4c41bd1980ccd9a51..b44a24bcde38e407f93b13e5699323055d4a8a62 100644
|
||||
--- a/content/browser/accessibility/accessibility_tree_formatter_mac.mm
|
||||
+++ b/content/browser/accessibility/accessibility_tree_formatter_mac.mm
|
||||
@@ -275,6 +275,7 @@
|
||||
return PopulateArray((NSArray*)value, indexer);
|
||||
}
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
// AXTextMarker
|
||||
if (content::IsAXTextMarker(value)) {
|
||||
return PopulateTextPosition(content::AXTextMarkerToAXPosition(value),
|
||||
@@ -284,6 +285,7 @@
|
||||
// AXTextMarkerRange
|
||||
if (content::IsAXTextMarkerRange(value))
|
||||
return PopulateTextMarkerRange(value, indexer);
|
||||
+#endif
|
||||
|
||||
return AXNSObjectToBaseValue(value, indexer);
|
||||
}
|
||||
@@ -322,7 +324,7 @@
|
||||
AXMakeConst(affinity));
|
||||
return set;
|
||||
}
|
||||
-
|
||||
+#ifndef MAS_BUILD
|
||||
base::Value AccessibilityTreeFormatterMac::PopulateTextMarkerRange(
|
||||
id marker_range,
|
||||
const AXTreeIndexerMac* indexer) const {
|
||||
@@ -338,7 +340,7 @@
|
||||
PopulateTextPosition(ax_range.focus()->Clone(), indexer));
|
||||
return dict;
|
||||
}
|
||||
-
|
||||
+#endif
|
||||
base::Value AccessibilityTreeFormatterMac::PopulateArray(
|
||||
NSArray* node_array,
|
||||
const AXTreeIndexerMac* indexer) const {
|
||||
diff --git a/content/browser/accessibility/accessibility_tree_formatter_utils_mac.h b/content/browser/accessibility/accessibility_tree_formatter_utils_mac.h
|
||||
index 2b05b9e3b9a5f4ad1951fbbbfa34adf129d8f408..0ca278cf6bb0ecc2127f5507941cf592449e2e61 100644
|
||||
--- a/content/browser/accessibility/accessibility_tree_formatter_utils_mac.h
|
||||
+++ b/content/browser/accessibility/accessibility_tree_formatter_utils_mac.h
|
||||
@@ -89,12 +89,14 @@ class CONTENT_EXPORT AttributeInvoker final {
|
||||
const ui::AXPropertyNode&,
|
||||
bool log_failure = true) const;
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
id DictNodeToTextMarker(const ui::AXPropertyNode&,
|
||||
bool log_failure = true) const;
|
||||
id PropertyNodeToTextMarker(const ui::AXPropertyNode&,
|
||||
bool log_failure = true) const;
|
||||
id PropertyNodeToTextMarkerRange(const ui::AXPropertyNode&,
|
||||
bool log_failure = true) const;
|
||||
+#endif
|
||||
|
||||
gfx::NativeViewAccessible LineIndexToNode(
|
||||
const std::u16string line_index) const;
|
||||
diff --git a/content/browser/accessibility/accessibility_tree_formatter_utils_mac.mm b/content/browser/accessibility/accessibility_tree_formatter_utils_mac.mm
|
||||
index 696d87b7aaf0c9de9c071bd97197192720752010..ebf3935d20ba22ccc0473252a1323be4bd003eec 100644
|
||||
--- a/content/browser/accessibility/accessibility_tree_formatter_utils_mac.mm
|
||||
+++ b/content/browser/accessibility/accessibility_tree_formatter_utils_mac.mm
|
||||
@@ -189,9 +189,11 @@
|
||||
if (IsNSAccessibilityElement(target) || IsAXUIElement(target))
|
||||
return InvokeForAXElement(target, property_node);
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
if (content::IsAXTextMarkerRange(target)) {
|
||||
return InvokeForAXTextMarkerRange(target, property_node);
|
||||
}
|
||||
+#endif
|
||||
|
||||
if ([target isKindOfClass:[NSArray class]])
|
||||
return InvokeForArray(target, property_node);
|
||||
@@ -389,6 +391,7 @@
|
||||
property_name == "AXTextMarkerRangeForUIElement") { // UIElement
|
||||
return OptionalNSObject::NotNullOrError(PropertyNodeToUIElement(arg_node));
|
||||
}
|
||||
+#ifndef MAS_BUILD
|
||||
if (property_name == "AXIndexForTextMarker" ||
|
||||
property_name == "AXNextWordEndTextMarkerForTextMarker" ||
|
||||
property_name ==
|
||||
@@ -400,6 +403,7 @@
|
||||
return OptionalNSObject::NotNullOrError(
|
||||
PropertyNodeToTextMarkerRange(arg_node));
|
||||
}
|
||||
+#endif
|
||||
|
||||
return OptionalNSObject::NotApplicable();
|
||||
}
|
||||
@@ -412,6 +416,7 @@
|
||||
return value;
|
||||
|
||||
// NSRange
|
||||
+#ifndef MAS_BUILD
|
||||
value = PropertyNodeToRange(property_node, false);
|
||||
if (value)
|
||||
return value;
|
||||
@@ -428,6 +433,10 @@
|
||||
|
||||
// TextMarkerRange
|
||||
return PropertyNodeToTextMarkerRange(property_node, false);
|
||||
+#else
|
||||
+
|
||||
+ return PropertyNodeToRange(property_node, false);
|
||||
+#endif
|
||||
}
|
||||
|
||||
// NSNumber. Format: integer.
|
||||
@@ -538,6 +547,7 @@
|
||||
return uielement;
|
||||
}
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
id AttributeInvoker::DictNodeToTextMarker(const AXPropertyNode& dictnode,
|
||||
bool log_failure) const {
|
||||
if (!dictnode.IsDict()) {
|
||||
@@ -627,6 +637,7 @@
|
||||
|
||||
return content::AXTextMarkerRangeFrom(anchor_textmarker, focus_textmarker);
|
||||
}
|
||||
+#endif
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace content
|
||||
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.h b/content/browser/accessibility/browser_accessibility_cocoa.h
|
||||
index 8ba9ceef621eaa8539d2e127ab75c23ab671f2a1..cdcf397f3fb4fb98b48fcd5080edb883eeb9b52e 100644
|
||||
--- a/content/browser/accessibility/browser_accessibility_cocoa.h
|
||||
+++ b/content/browser/accessibility/browser_accessibility_cocoa.h
|
||||
@@ -148,7 +148,9 @@ id AXTextMarkerRangeFrom(id anchor_text_marker, id focus_text_marker);
|
||||
@property(nonatomic, readonly) NSNumber* enabled;
|
||||
// Returns a text marker that points to the last character in the document that
|
||||
// can be selected with Voiceover.
|
||||
+#ifndef MAS_BUILD
|
||||
@property(nonatomic, readonly) id endTextMarker;
|
||||
+#endif
|
||||
@property(nonatomic, readonly) NSNumber* expanded;
|
||||
@property(nonatomic, readonly) NSNumber* focused;
|
||||
@property(nonatomic, readonly) NSNumber* grabbed;
|
||||
@@ -160,7 +162,9 @@ id AXTextMarkerRangeFrom(id anchor_text_marker, id focus_text_marker);
|
||||
// Index of a row, column, or tree item.
|
||||
@property(nonatomic, readonly) NSNumber* index;
|
||||
@property(nonatomic, readonly) NSNumber* treeItemRowIndex;
|
||||
+#ifndef MAS_BUILD
|
||||
@property(nonatomic, readonly) NSNumber* insertionPointLineNumber;
|
||||
+#endif
|
||||
@property(nonatomic, readonly) NSNumber* isMultiSelectable;
|
||||
@property(nonatomic, readonly) NSNumber* loaded;
|
||||
@property(nonatomic, readonly) NSNumber* loadingProgress;
|
||||
@@ -179,14 +183,18 @@ id AXTextMarkerRangeFrom(id anchor_text_marker, id focus_text_marker);
|
||||
// The object is selected as a whole.
|
||||
@property(nonatomic, readonly) NSNumber* selected;
|
||||
@property(nonatomic, readonly) NSArray* selectedChildren;
|
||||
+#ifndef MAS_BUILD
|
||||
@property(nonatomic, readonly) NSString* selectedText;
|
||||
@property(nonatomic, readonly) NSValue* selectedTextRange;
|
||||
@property(nonatomic, readonly) id selectedTextMarkerRange;
|
||||
+#endif
|
||||
@property(nonatomic, readonly) NSValue* size;
|
||||
@property(nonatomic, readonly) NSString* sortDirection;
|
||||
// Returns a text marker that points to the first character in the document that
|
||||
// can be selected with Voiceover.
|
||||
+#ifndef MAS_BUILD
|
||||
@property(nonatomic, readonly) id startTextMarker;
|
||||
+#endif
|
||||
// A string indicating the subrole of this object as far as accessibility
|
||||
// is concerned.
|
||||
@property(nonatomic, readonly) NSString* subrole;
|
||||
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm
|
||||
index 34fbe096ddcc84b156384f12a23f278c0f94e385..043c9b8113c4f15f0248839a69b7ee76e3da2794 100644
|
||||
--- a/content/browser/accessibility/browser_accessibility_cocoa.mm
|
||||
+++ b/content/browser/accessibility/browser_accessibility_cocoa.mm
|
||||
@@ -188,6 +188,7 @@
|
||||
|
||||
// Private attributes that can be used for testing text markers, e.g. in dump
|
||||
// tree tests.
|
||||
+#ifndef MAS_BUILD
|
||||
NSString* const
|
||||
NSAccessibilityTextMarkerDebugDescriptionParameterizedAttribute =
|
||||
@"AXTextMarkerDebugDescription";
|
||||
@@ -197,6 +198,7 @@
|
||||
NSString* const
|
||||
NSAccessibilityTextMarkerNodeDebugDescriptionParameterizedAttribute =
|
||||
@"AXTextMarkerNodeDebugDescription";
|
||||
+#endif
|
||||
|
||||
// Other private attributes.
|
||||
NSString* const NSAccessibilityIdentifierChromeAttribute = @"ChromeAXNodeId";
|
||||
@@ -224,6 +226,7 @@
|
||||
// The following are private accessibility APIs required for cursor navigation
|
||||
// and text selection. VoiceOver started relying on them in Mac OS X 10.11.
|
||||
// They are public as of the 12.0 SDK.
|
||||
+#ifndef MAS_BUILD
|
||||
#if !defined(MAC_OS_VERSION_12_0) || \
|
||||
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0
|
||||
using AXTextMarkerRangeRef = CFTypeRef;
|
||||
@@ -455,6 +458,7 @@ void AddMisspelledTextAttributes(const BrowserAccessibility::AXRange& ax_range,
|
||||
AddMisspelledTextAttributes(ax_range, attributed_text);
|
||||
return attributed_text;
|
||||
}
|
||||
+#endif
|
||||
|
||||
// Returns an autoreleased copy of the AXNodeData's attribute.
|
||||
NSString* NSStringForStringAttribute(BrowserAccessibility* browserAccessibility,
|
||||
@@ -716,6 +720,7 @@ bool IsSelectedStateRelevant(BrowserAccessibility* item) {
|
||||
0 == strcmp([value objCType], @encode(NSRange));
|
||||
}
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
bool content::IsAXTextMarker(id object) {
|
||||
if (object == nil)
|
||||
return false;
|
||||
@@ -760,6 +765,7 @@ bool IsSelectedStateRelevant(BrowserAccessibility* item) {
|
||||
static_cast<AXTextMarkerRef>(focus_textmarker));
|
||||
return [static_cast<id>(cf_marker_range) autorelease];
|
||||
}
|
||||
+#endif
|
||||
|
||||
@implementation BrowserAccessibilityCocoa
|
||||
|
||||
@@ -784,7 +790,9 @@ + (void)initialize {
|
||||
{NSAccessibilityEditableAncestorAttribute, @"editableAncestor"},
|
||||
{NSAccessibilityElementBusyAttribute, @"elementBusy"},
|
||||
{NSAccessibilityEnabledAttribute, @"enabled"},
|
||||
+#ifndef MAS_BUILD
|
||||
{NSAccessibilityEndTextMarkerAttribute, @"endTextMarker"},
|
||||
+#endif
|
||||
{NSAccessibilityExpandedAttribute, @"expanded"},
|
||||
{NSAccessibilityFocusableAncestorAttribute, @"focusableAncestor"},
|
||||
{NSAccessibilityFocusedAttribute, @"focused"},
|
||||
@@ -794,8 +802,10 @@ + (void)initialize {
|
||||
{NSAccessibilityHighestEditableAncestorAttribute,
|
||||
@"highestEditableAncestor"},
|
||||
{NSAccessibilityIndexAttribute, @"index"},
|
||||
+#ifndef MAS_BUILD
|
||||
{NSAccessibilityInsertionPointLineNumberAttribute,
|
||||
@"insertionPointLineNumber"},
|
||||
+#endif
|
||||
{NSAccessibilityIsMultiSelectableAttribute, @"isMultiSelectable"},
|
||||
{NSAccessibilityLanguageAttribute, @"language"},
|
||||
{NSAccessibilityLinkedUIElementsAttribute, @"linkedUIElements"},
|
||||
@@ -814,13 +824,17 @@ + (void)initialize {
|
||||
{NSAccessibilityRowsAttribute, @"rows"},
|
||||
// TODO(aboxhall): expose
|
||||
// NSAccessibilityServesAsTitleForUIElementsAttribute
|
||||
+#ifndef MAS_BUILD
|
||||
{NSAccessibilityStartTextMarkerAttribute, @"startTextMarker"},
|
||||
+#endif
|
||||
{NSAccessibilitySelectedAttribute, @"selected"},
|
||||
{NSAccessibilitySelectedChildrenAttribute, @"selectedChildren"},
|
||||
+#ifndef MAS_BUILD
|
||||
{NSAccessibilitySelectedTextAttribute, @"selectedText"},
|
||||
{NSAccessibilitySelectedTextRangeAttribute, @"selectedTextRange"},
|
||||
{NSAccessibilitySelectedTextMarkerRangeAttribute,
|
||||
@"selectedTextMarkerRange"},
|
||||
+#endif
|
||||
{NSAccessibilitySizeAttribute, @"size"},
|
||||
{NSAccessibilitySortDirectionAttribute, @"sortDirection"},
|
||||
{NSAccessibilitySubroleAttribute, @"subrole"},
|
||||
@@ -1160,12 +1174,14 @@ - (NSNumber*)enabled {
|
||||
|
||||
// Returns a text marker that points to the last character in the document that
|
||||
// can be selected with VoiceOver.
|
||||
+#ifndef MAS_BUILD
|
||||
- (id)endTextMarker {
|
||||
if (![self instanceActive])
|
||||
return nil;
|
||||
BrowserAccessibility::AXPosition position = _owner->CreateTextPositionAt(0);
|
||||
return CreateTextMarker(position->CreatePositionAtEndOfContent());
|
||||
}
|
||||
+#endif
|
||||
|
||||
- (NSNumber*)expanded {
|
||||
if (![self instanceActive])
|
||||
@@ -1338,6 +1354,7 @@ - (bool)findRowIndex:(BrowserAccessibilityCocoa*)toFind
|
||||
return false;
|
||||
}
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
- (NSNumber*)AXInsertionPointLineNumber {
|
||||
return [self insertionPointLineNumber];
|
||||
}
|
||||
@@ -1368,6 +1385,7 @@ - (NSNumber*)insertionPointLineNumber {
|
||||
caretPosition->AsTextPosition()->text_offset());
|
||||
return @(std::distance(lineStarts.begin(), iterator));
|
||||
}
|
||||
+#endif
|
||||
|
||||
// Returns whether or not this node should be ignored in the
|
||||
// accessibility tree.
|
||||
@@ -1692,8 +1710,12 @@ - (BOOL)shouldExposeTitleUIElement {
|
||||
return content::AXTextEdit(newValue, std::u16string(), nil);
|
||||
}
|
||||
}
|
||||
+#ifndef MAS_BUILD
|
||||
return content::AXTextEdit(insertedText, deletedText,
|
||||
CreateTextMarker(_owner->CreateTextPositionAt(i)));
|
||||
+#else
|
||||
+ return content::AXTextEdit(insertedText, deletedText, nil);
|
||||
+#endif
|
||||
}
|
||||
|
||||
// internal
|
||||
@@ -1881,6 +1903,7 @@ - (NSArray*)selectedChildren {
|
||||
return ret;
|
||||
}
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
- (NSString*)AXSelectedText {
|
||||
return [self selectedText];
|
||||
}
|
||||
@@ -1941,6 +1964,7 @@ - (id)selectedTextMarkerRange {
|
||||
// words correctly.
|
||||
return CreateTextMarkerRange(ax_range.AsBackwardRange());
|
||||
}
|
||||
+#endif
|
||||
|
||||
- (NSValue*)size {
|
||||
if (![self instanceActive])
|
||||
@@ -1975,12 +1999,14 @@ - (NSString*)sortDirection {
|
||||
|
||||
// Returns a text marker that points to the first character in the document that
|
||||
// can be selected with VoiceOver.
|
||||
+#ifndef MAS_BUILD
|
||||
- (id)startTextMarker {
|
||||
if (![self instanceActive])
|
||||
return nil;
|
||||
BrowserAccessibility::AXPosition position = _owner->CreateTextPositionAt(0);
|
||||
return CreateTextMarker(position->CreatePositionAtStartOfContent());
|
||||
}
|
||||
+#endif
|
||||
|
||||
- (NSString*)AXSubrole {
|
||||
return [self subrole];
|
||||
@@ -2308,12 +2334,14 @@ - (NSAttributedString*)attributedValueForRange:(NSRange)range {
|
||||
NSMutableAttributedString* attributedTextContent =
|
||||
[[[NSMutableAttributedString alloc]
|
||||
initWithString:base::SysUTF16ToNSString(textContent)] autorelease];
|
||||
+#ifndef MAS_BUILD
|
||||
if (!_owner->IsText()) {
|
||||
BrowserAccessibility::AXRange ax_range(
|
||||
_owner->CreateTextPositionAt(0),
|
||||
_owner->CreateTextPositionAt(static_cast<int>(textContent.length())));
|
||||
AddMisspelledTextAttributes(ax_range, attributedTextContent);
|
||||
}
|
||||
+#endif
|
||||
|
||||
return [attributedTextContent attributedSubstringFromRange:range];
|
||||
}
|
||||
@@ -2448,6 +2476,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
|
||||
return ToBrowserAccessibilityCocoa(cell);
|
||||
}
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
if ([attribute
|
||||
isEqualToString:
|
||||
NSAccessibilityUIElementForTextMarkerParameterizedAttribute]) {
|
||||
@@ -2786,6 +2815,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
|
||||
|
||||
return CreateTextMarker(root->CreateTextPositionAt(index));
|
||||
}
|
||||
+#endif
|
||||
|
||||
if ([attribute isEqualToString:
|
||||
NSAccessibilityBoundsForRangeParameterizedAttribute]) {
|
||||
@@ -2816,6 +2846,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
|
||||
return nil;
|
||||
}
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
if ([attribute
|
||||
isEqualToString:
|
||||
NSAccessibilityLineTextMarkerRangeForTextMarkerParameterizedAttribute]) {
|
||||
@@ -2935,6 +2966,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
|
||||
|
||||
return @(child->GetIndexInParent());
|
||||
}
|
||||
+#endif
|
||||
|
||||
return nil;
|
||||
}
|
||||
@@ -3453,6 +3485,7 @@ - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute {
|
||||
->AsTextSelectionPosition()));
|
||||
}
|
||||
}
|
||||
+#ifndef MAS_BUILD
|
||||
if ([attribute
|
||||
isEqualToString:NSAccessibilitySelectedTextMarkerRangeAttribute]) {
|
||||
BrowserAccessibility::AXRange range = CreateRangeFromTextMarkerRange(value);
|
||||
@@ -3463,6 +3496,7 @@ - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute {
|
||||
range.anchor()->AsTextSelectionPosition(),
|
||||
range.focus()->AsTextSelectionPosition()));
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
|
||||
- (id)accessibilityFocusedUIElement {
|
||||
diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.mm b/content/browser/accessibility/browser_accessibility_manager_mac.mm
|
||||
index 2084f4677670646ba769f2fe68797a5e5647f3f3..49914bdc1cbd8f55fcd55eaf912df04279d86bb7 100644
|
||||
--- a/content/browser/accessibility/browser_accessibility_manager_mac.mm
|
||||
+++ b/content/browser/accessibility/browser_accessibility_manager_mac.mm
|
||||
@@ -502,7 +502,7 @@ void PostAnnouncementNotification(NSString* announcement) {
|
||||
if (native_focus_object && [native_focus_object instanceActive]) {
|
||||
[user_info setObject:native_focus_object
|
||||
forKey:ui::NSAccessibilityTextChangeElement];
|
||||
-
|
||||
+#ifndef MAS_BUILD
|
||||
id selected_text = [native_focus_object selectedTextMarkerRange];
|
||||
if (selected_text) {
|
||||
NSString* const NSAccessibilitySelectedTextMarkerRangeAttribute =
|
||||
@@ -510,6 +510,7 @@ void PostAnnouncementNotification(NSString* announcement) {
|
||||
[user_info setObject:selected_text
|
||||
forKey:NSAccessibilitySelectedTextMarkerRangeAttribute];
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
|
||||
return user_info;
|
||||
diff --git a/content/common/pseudonymization_salt.cc b/content/common/pseudonymization_salt.cc
|
||||
index 28e003bef910abff022def659fe18d4cd0549f8a..530bcbdb5d350f6486dc1e8536f7b279be69e241 100644
|
||||
--- a/content/common/pseudonymization_salt.cc
|
||||
|
|
Loading…
Reference in a new issue