Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Unified Diff: ui/accessibility/platform/text_marker_helper_mac.mm

Issue 2956593002: cl format
Patch Set: Sash - text markers not needed :/ Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/accessibility/platform/text_marker_helper_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/platform/text_marker_helper_mac.mm
diff --git a/ui/accessibility/platform/text_marker_helper_mac.mm b/ui/accessibility/platform/text_marker_helper_mac.mm
index a4d3025b1cb39370aa1c335b37649aa8ca99df28..94b497ce7940cde3c4ae339846cc9e5f5d21247c 100644
--- a/ui/accessibility/platform/text_marker_helper_mac.mm
+++ b/ui/accessibility/platform/text_marker_helper_mac.mm
@@ -8,6 +8,7 @@
#import "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
+#include "base/mac/scoped_nsobject.h"
#include "ui/accessibility/ax_position.h"
#include "ui/accessibility/ax_range.h"
@@ -103,30 +104,109 @@ AXPositionPointer FirstOf(AXPositionPointer a, AXPositionPointer b) {
return self;
}
-- (id)startTextMarker {
- AXPositionPointer root = factory_->GetRoot();
- return root ? CreateTextMarker(root->PositionAtStartOfAnchor()) : nil;
++ (NSArray*)getSupportedAttributes {
+ return @[
+ @"AXEndTextMarker",
+ @"AXSelectedTextMarkerRange",
+ @"AXStartTextMarker",
+ ];
+}
+
++ (NSArray*)getSupportedParameterizedAttributesExtended:(BOOL)extended {
+ static NSArray* const generalAttributes = [@[
+ @"AXAttributedStringForTextMarkerRange",
+ @"AXBoundsForTextMarkerRange",
+ @"AXEndTextMarkerForBounds",
+ @"AXLeftLineTextMarkerRangeForTextMarker", // Done.
+ @"AXLeftWordTextMarkerRangeForTextMarker", // Done.
+ @"AXLengthForTextMarkerRange",
+ @"AXLineForTextMarker",
+ @"AXLineTextMarkerRangeForTextMarker", // Done.
+ @"AXNextLineEndTextMarkerForTextMarker", // Done.
+ @"AXNextParagraphEndTextMarkerForTextMarker",
+ @"AXNextSentenceEndTextMarkerForTextMarker",
+ @"AXNextTextMarkerForTextMarker", // Done.
+ @"AXNextWordEndTextMarkerForTextMarker", // Done.
+ @"AXParagraphTextMarkerRangeForTextMarker",
+ @"AXPreviousLineStartTextMarkerForTextMarker", // Done.
+ @"AXPreviousParagraphStartTextMarkerForTextMarker",
+ @"AXPreviousSentenceStartTextMarkerForTextMarker",
+ @"AXPreviousTextMarkerForTextMarker", // Done.
+ @"AXPreviousWordStartTextMarkerForTextMarker", // Done.
+ @"AXRightLineTextMarkerRangeForTextMarker", // Done.
+ @"AXRightWordTextMarkerRangeForTextMarker", // Done.
+ @"AXSentenceTextMarkerRangeForTextMarker",
+ @"AXStartTextMarkerForBounds",
+ @"AXStringForTextMarkerRange",
+ @"AXStyleTextMarkerRangeForTextMarker",
+ @"AXTextMarkerForPosition",
+ @"AXTextMarkerRangeForLine", // Done.
+ @"AXTextMarkerRangeForUIElement", // Done.
+ @"AXTextMarkerRangeForUnorderedTextMarkers", // Done.
+ @"AXUIElementForTextMarker", // Done.
+ ] retain];
+ static NSArray* const extendedAttributes = [@[
+ @"AXTextMarkerIsValid",
+ @"AXIndexForTextMarker",
+ @"AXTextMarkerForIndex",
+ ] retain];
+ base::scoped_nsobject<NSMutableArray> ret([[NSMutableArray alloc] init]);
+ [ret addObjectsFromArray:generalAttributes];
+ if (extended)
+ [ret addObjectsFromArray:extendedAttributes];
+ return ret.autorelease();
+}
+
++ (BOOL)getRangeDataFromMarkerRange:(id)parameter
+ start:(ui::AXPositionData*)start
+ end:(ui::AXPositionData*)end {
+ AXTextMarkerRangeRef markerRange =
+ base::mac::CFCastStrict<AXTextMarkerRangeRef>(parameter);
+ DCHECK(markerRange);
+
+ base::ScopedCFTypeRef<AXTextMarkerRef> startMarker(
+ AXTextMarkerRangeCopyStartMarker(markerRange));
+ base::ScopedCFTypeRef<AXTextMarkerRef> endMarker(
+ AXTextMarkerRangeCopyEndMarker(markerRange));
+ if (!startMarker || !endMarker)
+ return NO;
+
+ return ExtractData(startMarker, start) && ExtractData(endMarker, end);
+}
+
+- (AXPositionPointer)extractFrom:(id)parameter {
+ AXPositionData data;
+ if (ExtractData(base::mac::CFCastStrict<AXTextMarkerRef>(parameter), &data))
+ return factory_->GetFromData(data);
+ return factory_->GetFromData(ui::AXAbstractPosition::kNullData);
}
-- (id)endTextMarker {
+// Non-parameterized attributes. Keep sorted.
+
+// Returns a text marker that points to the last character in the document that
+// can be selected with VoiceOver.
+- (id)AXEndTextMarker {
AXPositionPointer root = factory_->GetRoot();
return root ? CreateTextMarker(root->PositionAtEndOfAnchor()) : nil;
}
-- (id)selectedTextMarkerRange {
+// Returns a text marker range corresponding to the current selection.
+- (id)AXSelectedTextMarkerRange {
AXRangePointer selection = factory_->GetSelection();
if (!selection.first || !selection.second)
return nil;
return CreateTextMarkerRange(std::move(selection));
}
-- (AXPositionPointer)extractFrom:(id)parameter {
- AXPositionData data;
- if (ExtractData(base::mac::CFCastStrict<AXTextMarkerRef>(parameter), &data))
- return factory_->GetFromData(data);
- return factory_->GetFromData(ui::AXAbstractPosition::kNullData);
+// Returns a text marker that points to the first character in the document that
+// can be selected with VoiceOver.
+- (id)AXStartTextMarker {
+ AXPositionPointer root = factory_->GetRoot();
+ return root ? CreateTextMarker(root->PositionAtStartOfAnchor()) : nil;
}
+// Parameterized attributes. TOOD(tapted): Sort these.
+
- (id)AXTextMarkerRangeForUIElement:(id)parameter {
AXPositionPointer startPosition = factory_->GetRoot();
AXPositionPointer endPosition = startPosition->PositionAtEndOfAnchor();
@@ -273,21 +353,4 @@ AXPositionPointer FirstOf(AXPositionPointer a, AXPositionPointer b) {
AXRangePointer(std::move(startPosition), std::move(endPosition)));
}
-+ (BOOL)getRangeDataFromMarkerRange:(id)parameter
- start:(ui::AXPositionData*)start
- end:(ui::AXPositionData*)end {
- AXTextMarkerRangeRef markerRange =
- base::mac::CFCastStrict<AXTextMarkerRangeRef>(parameter);
- DCHECK(markerRange);
-
- base::ScopedCFTypeRef<AXTextMarkerRef> startMarker(
- AXTextMarkerRangeCopyStartMarker(markerRange));
- base::ScopedCFTypeRef<AXTextMarkerRef> endMarker(
- AXTextMarkerRangeCopyEndMarker(markerRange));
- if (!startMarker || !endMarker)
- return NO;
-
- return ExtractData(startMarker, start) && ExtractData(endMarker, end);
-}
-
@end
« no previous file with comments | « ui/accessibility/platform/text_marker_helper_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698