Commit c0fd3c06 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Added paragraph navigation and whole page caret browsing on Mac

A few text marker attributes are still missing from our Mac implementation.
This patch adds the missing attributes for paragraph and caret browsing.
This patch also declares any missing attributes for text markers in the form of constants,
instead of using text strings.
This is the full set of text marker attributes supported by Safari.
R=aleventhal@chromium.org
Bug: 990931

Change-Id: I9839f2f1f419c14b7730573ac1f7c1f3306f36c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1732692
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Auto-Submit: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684462}
parent a46c813c
......@@ -115,13 +115,91 @@ NSString* const NSAccessibilityStartTextMarkerForBoundsParameterizedAttribute =
NSString* const
NSAccessibilityLineTextMarkerRangeForTextMarkerParameterizedAttribute =
@"AXLineTextMarkerRangeForTextMarker";
NSString* const NSAccessibilitySelectTextWithCriteriaParameterizedAttribute =
@"AXSelectTextWithCriteria";
// TODO(nektar): Implement programmatic text operations.
//
// NSString* const NSAccessibilityTextOperationMarkerRanges =
// @"AXTextOperationMarkerRanges";
NSString* const NSAccessibilityUIElementForTextMarkerParameterizedAttribute =
@"AXUIElementForTextMarker";
NSString* const
NSAccessibilityTextMarkerRangeForUIElementParameterizedAttribute =
@"AXTextMarkerRangeForUIElement";
NSString* const NSAccessibilityLineForTextMarkerParameterizedAttribute =
@"AXLineForTextMarker";
NSString* const NSAccessibilityTextMarkerRangeForLineParameterizedAttribute =
@"AXTextMarkerRangeForLine";
NSString* const NSAccessibilityStringForTextMarkerRangeParameterizedAttribute =
@"AXStringForTextMarkerRange";
NSString* const NSAccessibilityTextMarkerForPositionParameterizedAttribute =
@"AXTextMarkerForPosition";
NSString* const NSAccessibilityBoundsForTextMarkerRangeParameterizedAttribute =
@"AXBoundsForTextMarkerRange";
NSString* const
NSAccessibilityAttributedStringForTextMarkerRangeParameterizedAttribute =
@"AXAttributedStringForTextMarkerRange";
NSString* const
NSAccessibilityAttributedStringForTextMarkerRangeWithOptionsParameterizedAttribute =
@"AXAttributedStringForTextMarkerRangeWithOptions";
NSString* const
NSAccessibilityTextMarkerRangeForUnorderedTextMarkersParameterizedAttribute =
@"AXTextMarkerRangeForUnorderedTextMarkers";
NSString* const
NSAccessibilityNextTextMarkerForTextMarkerParameterizedAttribute =
@"AXNextTextMarkerForTextMarker";
NSString* const
NSAccessibilityPreviousTextMarkerForTextMarkerParameterizedAttribute =
@"AXPreviousTextMarkerForTextMarker";
NSString* const
NSAccessibilityLeftWordTextMarkerRangeForTextMarkerParameterizedAttribute =
@"AXLeftWordTextMarkerRangeForTextMarker";
NSString* const
NSAccessibilityRightWordTextMarkerRangeForTextMarkerParameterizedAttribute =
@"AXRightWordTextMarkerRangeForTextMarker";
NSString* const
NSAccessibilityLeftLineTextMarkerRangeForTextMarkerParameterizedAttribute =
@"AXLeftLineTextMarkerRangeForTextMarker";
NSString* const
NSAccessibilityRightLineTextMarkerRangeForTextMarkerParameterizedAttribute =
@"AXRightLineTextMarkerRangeForTextMarker";
NSString* const
NSAccessibilitySentenceTextMarkerRangeForTextMarkerParameterizedAttribute =
@"AXSentenceTextMarkerRangeForTextMarker";
NSString* const
NSAccessibilityParagraphTextMarkerRangeForTextMarkerParameterizedAttribute =
@"AXParagraphTextMarkerRangeForTextMarker";
NSString* const
NSAccessibilityNextWordEndTextMarkerForTextMarkerParameterizedAttribute =
@"AXNextWordEndTextMarkerForTextMarker";
NSString* const
NSAccessibilityPreviousWordStartTextMarkerForTextMarkerParameterizedAttribute =
@"AXPreviousWordStartTextMarkerForTextMarker";
NSString* const
NSAccessibilityNextLineEndTextMarkerForTextMarkerParameterizedAttribute =
@"AXNextLineEndTextMarkerForTextMarker";
NSString* const
NSAccessibilityPreviousLineStartTextMarkerForTextMarkerParameterizedAttribute =
@"AXPreviousLineStartTextMarkerForTextMarker";
NSString* const
NSAccessibilityNextSentenceEndTextMarkerForTextMarkerParameterizedAttribute =
@"AXNextSentenceEndTextMarkerForTextMarker";
NSString* const
NSAccessibilityPreviousSentenceStartTextMarkerForTextMarkerParameterizedAttribute =
@"AXPreviousSentenceStartTextMarkerForTextMarker";
NSString* const
NSAccessibilityNextParagraphEndTextMarkerForTextMarkerParameterizedAttribute =
@"AXNextParagraphEndTextMarkerForTextMarker";
NSString* const
NSAccessibilityPreviousParagraphStartTextMarkerForTextMarkerParameterizedAttribute =
@"AXPreviousParagraphStartTextMarkerForTextMarker";
NSString* const
NSAccessibilityStyleTextMarkerRangeForTextMarkerParameterizedAttribute =
@"AXStyleTextMarkerRangeForTextMarker";
NSString* const NSAccessibilityLengthForTextMarkerRangeParameterizedAttribute =
@"AXLengthForTextMarkerRange";
// Other private attributes.
NSString* const NSAccessibilitySelectTextWithCriteriaParameterizedAttribute =
@"AXSelectTextWithCriteria";
NSString* const NSAccessibilityIndexForChildUIElementParameterizedAttribute =
@"AXIndexForChildUIElement";
NSString* const NSAccessibilityValueAutofillAvailableAttribute =
......@@ -2484,7 +2562,9 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
return ToBrowserAccessibilityCocoa(cell);
}
if ([attribute isEqualToString:@"AXUIElementForTextMarker"]) {
if ([attribute
isEqualToString:
NSAccessibilityUIElementForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (!position->IsNullPosition())
......@@ -2493,7 +2573,9 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
return nil;
}
if ([attribute isEqualToString:@"AXTextMarkerRangeForUIElement"]) {
if ([attribute
isEqualToString:
NSAccessibilityTextMarkerRangeForUIElementParameterizedAttribute]) {
BrowserAccessibilityPositionInstance startPosition =
owner_->CreatePositionAt(0);
BrowserAccessibilityPositionInstance endPosition =
......@@ -2503,13 +2585,19 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
return CreateTextMarkerRange(std::move(range));
}
if ([attribute isEqualToString:@"AXStringForTextMarkerRange"])
if ([attribute
isEqualToString:
NSAccessibilityStringForTextMarkerRangeParameterizedAttribute])
return GetTextForTextMarkerRange(parameter);
if ([attribute isEqualToString:@"AXAttributedStringForTextMarkerRange"])
if ([attribute
isEqualToString:
NSAccessibilityAttributedStringForTextMarkerRangeParameterizedAttribute])
return GetAttributedTextForTextMarkerRange(parameter);
if ([attribute isEqualToString:@"AXNextTextMarkerForTextMarker"]) {
if ([attribute
isEqualToString:
NSAccessibilityNextTextMarkerForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
......@@ -2518,7 +2606,9 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
ui::AXBoundaryBehavior::CrossBoundary));
}
if ([attribute isEqualToString:@"AXPreviousTextMarkerForTextMarker"]) {
if ([attribute
isEqualToString:
NSAccessibilityPreviousTextMarkerForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
......@@ -2527,7 +2617,9 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
ui::AXBoundaryBehavior::CrossBoundary));
}
if ([attribute isEqualToString:@"AXLeftWordTextMarkerRangeForTextMarker"]) {
if ([attribute
isEqualToString:
NSAccessibilityLeftWordTextMarkerRangeForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance endPosition =
CreatePositionFromTextMarker(parameter);
if (endPosition->IsNullPosition())
......@@ -2546,7 +2638,9 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
return CreateTextMarkerRange(std::move(range));
}
if ([attribute isEqualToString:@"AXRightWordTextMarkerRangeForTextMarker"]) {
if ([attribute
isEqualToString:
NSAccessibilityRightWordTextMarkerRangeForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance startPosition =
CreatePositionFromTextMarker(parameter);
if (startPosition->IsNullPosition())
......@@ -2565,7 +2659,9 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
return CreateTextMarkerRange(std::move(range));
}
if ([attribute isEqualToString:@"AXNextWordEndTextMarkerForTextMarker"]) {
if ([attribute
isEqualToString:
NSAccessibilityNextWordEndTextMarkerForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
......@@ -2575,7 +2671,8 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
}
if ([attribute
isEqualToString:@"AXPreviousWordStartTextMarkerForTextMarker"]) {
isEqualToString:
NSAccessibilityPreviousWordStartTextMarkerForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
......@@ -2584,7 +2681,9 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
ui::AXBoundaryBehavior::CrossBoundary));
}
if ([attribute isEqualToString:@"AXTextMarkerRangeForLine"]) {
if ([attribute
isEqualToString:
NSAccessibilityTextMarkerRangeForLineParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
......@@ -2600,7 +2699,9 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
return CreateTextMarkerRange(std::move(range));
}
if ([attribute isEqualToString:@"AXLeftLineTextMarkerRangeForTextMarker"]) {
if ([attribute
isEqualToString:
NSAccessibilityLeftLineTextMarkerRangeForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance endPosition =
CreatePositionFromTextMarker(parameter);
if (endPosition->IsNullPosition())
......@@ -2619,7 +2720,9 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
return CreateTextMarkerRange(std::move(range));
}
if ([attribute isEqualToString:@"AXRightLineTextMarkerRangeForTextMarker"]) {
if ([attribute
isEqualToString:
NSAccessibilityRightLineTextMarkerRangeForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance startPosition =
CreatePositionFromTextMarker(parameter);
if (startPosition->IsNullPosition())
......@@ -2638,7 +2741,9 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
return CreateTextMarkerRange(std::move(range));
}
if ([attribute isEqualToString:@"AXNextLineEndTextMarkerForTextMarker"]) {
if ([attribute
isEqualToString:
NSAccessibilityNextLineEndTextMarkerForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
......@@ -2648,7 +2753,8 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
}
if ([attribute
isEqualToString:@"AXPreviousLineStartTextMarkerForTextMarker"]) {
isEqualToString:
NSAccessibilityPreviousLineStartTextMarkerForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
......@@ -2657,9 +2763,97 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
ui::AXBoundaryBehavior::CrossBoundary));
}
if ([attribute isEqualToString:@"AXLengthForTextMarkerRange"]) {
if ([attribute
isEqualToString:
NSAccessibilityParagraphTextMarkerRangeForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
return nil;
BrowserAccessibilityPositionInstance startPosition =
position->CreatePreviousParagraphStartPosition(
ui::AXBoundaryBehavior::StopIfAlreadyAtBoundary);
BrowserAccessibilityPositionInstance endPosition =
position->CreateNextParagraphEndPosition(
ui::AXBoundaryBehavior::StopIfAlreadyAtBoundary);
AXPlatformRange range(std::move(startPosition), std::move(endPosition));
return CreateTextMarkerRange(std::move(range));
}
if ([attribute
isEqualToString:
NSAccessibilityNextParagraphEndTextMarkerForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
return nil;
return CreateTextMarker(position->CreateNextParagraphEndPosition(
ui::AXBoundaryBehavior::CrossBoundary));
}
if ([attribute
isEqualToString:
NSAccessibilityPreviousParagraphStartTextMarkerForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
return nil;
return CreateTextMarker(position->CreatePreviousParagraphStartPosition(
ui::AXBoundaryBehavior::CrossBoundary));
}
if ([attribute
isEqualToString:
NSAccessibilityStyleTextMarkerRangeForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
return nil;
BrowserAccessibilityPositionInstance startPosition =
position->CreatePositionAtFormatBoundary(
ui::AXBoundaryBehavior::StopIfAlreadyAtBoundary,
/*forwards*/ false);
BrowserAccessibilityPositionInstance endPosition =
position->CreatePositionAtFormatBoundary(
ui::AXBoundaryBehavior::StopIfAlreadyAtBoundary, /*forwards*/ true);
AXPlatformRange range(std::move(startPosition), std::move(endPosition));
return CreateTextMarkerRange(std::move(range));
}
if ([attribute
isEqualToString:
NSAccessibilityLengthForTextMarkerRangeParameterizedAttribute]) {
NSString* text = GetTextForTextMarkerRange(parameter);
return [NSNumber numberWithInt:[text length]];
return @([text length]);
}
if ([attribute isEqualToString:
NSAccessibilityTextMarkerIsValidParameterizedAttribute]) {
return @(CreatePositionFromTextMarker(parameter)->IsNullPosition());
}
if ([attribute isEqualToString:
NSAccessibilityIndexForTextMarkerParameterizedAttribute]) {
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (position->IsNullPosition())
return nil;
return @(position->AsTextPosition()->text_offset());
}
if ([attribute isEqualToString:
NSAccessibilityTextMarkerForIndexParameterizedAttribute]) {
int index = [static_cast<NSNumber*>(parameter) intValue];
if (index < 0)
return nil;
const BrowserAccessibility* root = owner_->manager()->GetRoot();
if (!root)
return nil;
return CreateTextMarker(root->CreatePositionAt(index));
}
if ([attribute isEqualToString:
......@@ -2787,37 +2981,42 @@ NSString* const NSAccessibilityRequiredAttributeChrome = @"AXRequired";
// General attributes.
NSMutableArray* ret = [NSMutableArray
arrayWithObjects:
@"AXUIElementForTextMarker", @"AXTextMarkerRangeForUIElement",
@"AXLineForTextMarker", @"AXTextMarkerRangeForLine",
@"AXStringForTextMarkerRange", @"AXTextMarkerForPosition",
@"AXAttributedStringForTextMarkerRange",
@"AXNextTextMarkerForTextMarker",
@"AXPreviousTextMarkerForTextMarker",
@"AXLeftWordTextMarkerRangeForTextMarker",
@"AXRightWordTextMarkerRangeForTextMarker",
@"AXLeftLineTextMarkerRangeForTextMarker",
@"AXRightLineTextMarkerRangeForTextMarker",
@"AXSentenceTextMarkerRangeForTextMarker",
@"AXParagraphTextMarkerRangeForTextMarker",
@"AXNextWordEndTextMarkerForTextMarker",
@"AXPreviousWordStartTextMarkerForTextMarker",
@"AXNextLineEndTextMarkerForTextMarker",
@"AXPreviousLineStartTextMarkerForTextMarker",
@"AXNextSentenceEndTextMarkerForTextMarker",
@"AXPreviousSentenceStartTextMarkerForTextMarker",
@"AXNextParagraphEndTextMarkerForTextMarker",
@"AXPreviousParagraphStartTextMarkerForTextMarker",
@"AXStyleTextMarkerRangeForTextMarker", @"AXLengthForTextMarkerRange",
NSAccessibilityUIElementForTextMarkerParameterizedAttribute,
NSAccessibilityTextMarkerRangeForUIElementParameterizedAttribute,
NSAccessibilityLineForTextMarkerParameterizedAttribute,
NSAccessibilityTextMarkerRangeForLineParameterizedAttribute,
NSAccessibilityStringForTextMarkerRangeParameterizedAttribute,
NSAccessibilityTextMarkerForPositionParameterizedAttribute,
NSAccessibilityBoundsForTextMarkerRangeParameterizedAttribute,
NSAccessibilityAttributedStringForTextMarkerRangeParameterizedAttribute,
NSAccessibilityAttributedStringForTextMarkerRangeWithOptionsParameterizedAttribute,
NSAccessibilityTextMarkerRangeForUnorderedTextMarkersParameterizedAttribute,
NSAccessibilityNextTextMarkerForTextMarkerParameterizedAttribute,
NSAccessibilityPreviousTextMarkerForTextMarkerParameterizedAttribute,
NSAccessibilityLeftWordTextMarkerRangeForTextMarkerParameterizedAttribute,
NSAccessibilityRightWordTextMarkerRangeForTextMarkerParameterizedAttribute,
NSAccessibilityLeftLineTextMarkerRangeForTextMarkerParameterizedAttribute,
NSAccessibilityRightLineTextMarkerRangeForTextMarkerParameterizedAttribute,
NSAccessibilitySentenceTextMarkerRangeForTextMarkerParameterizedAttribute,
NSAccessibilityParagraphTextMarkerRangeForTextMarkerParameterizedAttribute,
NSAccessibilityNextWordEndTextMarkerForTextMarkerParameterizedAttribute,
NSAccessibilityPreviousWordStartTextMarkerForTextMarkerParameterizedAttribute,
NSAccessibilityNextLineEndTextMarkerForTextMarkerParameterizedAttribute,
NSAccessibilityPreviousLineStartTextMarkerForTextMarkerParameterizedAttribute,
NSAccessibilityNextSentenceEndTextMarkerForTextMarkerParameterizedAttribute,
NSAccessibilityPreviousSentenceStartTextMarkerForTextMarkerParameterizedAttribute,
NSAccessibilityNextParagraphEndTextMarkerForTextMarkerParameterizedAttribute,
NSAccessibilityPreviousParagraphStartTextMarkerForTextMarkerParameterizedAttribute,
NSAccessibilityStyleTextMarkerRangeForTextMarkerParameterizedAttribute,
NSAccessibilityLengthForTextMarkerRangeParameterizedAttribute,
NSAccessibilityEndTextMarkerForBoundsParameterizedAttribute,
NSAccessibilityStartTextMarkerForBoundsParameterizedAttribute,
NSAccessibilityLineTextMarkerRangeForTextMarkerParameterizedAttribute,
NSAccessibilityIndexForChildUIElementParameterizedAttribute,
NSAccessibilityBoundsForRangeParameterizedAttribute,
NSAccessibilityStringForRangeParameterizedAttribute,
NSAccessibilityUIElementCountForSearchPredicateParameterizedAttribute,
NSAccessibilityUIElementsForSearchPredicateParameterizedAttribute,
NSAccessibilityEndTextMarkerForBoundsParameterizedAttribute,
NSAccessibilityStartTextMarkerForBoundsParameterizedAttribute,
NSAccessibilityLineTextMarkerRangeForTextMarkerParameterizedAttribute,
NSAccessibilitySelectTextWithCriteriaParameterizedAttribute, nil];
if ([[self role] isEqualToString:NSAccessibilityTableRole] ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment