Commit 845e186a authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

ChromeVox: Add support for navigation by paragraph.

Adds ChromeVox jump commands to go to the next or previous paragraph.

Bug: 1002101
Change-Id: I9bfd6462cb2875a9867c6b0939f0700a277148ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850756Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711002}
parent 840c5167
......@@ -1056,6 +1056,24 @@
"keyCode": [80, 76]
}
}
},
{
"command": "nextParagraph",
"sequence": {
"cvoxModifier": true,
"keys": {
"keyCode": [78, 80]
}
}
},
{
"command": "previousParagraph",
"sequence": {
"cvoxModifier": true,
"keys": {
"keyCode": [80, 80]
}
}
}
]
}
......@@ -106,6 +106,8 @@ AutomationPredicate.table = AutomationPredicate.roles([Role.GRID, Role.TABLE]);
/** @type {AutomationPredicate.Unary} */
AutomationPredicate.listLike =
AutomationPredicate.roles([Role.LIST, Role.DESCRIPTION_LIST]);
/** @type {AutomationPredicate.Unary} */
AutomationPredicate.paragraph = AutomationPredicate.roles([Role.PARAGRAPH]);
/**
* @param {!AutomationNode} node
......
......@@ -2251,3 +2251,49 @@ TEST_F('ChromeVoxBackgroundTest', 'NoRepeatTitle', function() {
.replay();
});
});
TEST_F('ChromeVoxBackgroundTest', 'NavigationByParagraphTest', function() {
var mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(function() {/*!
<button>Start at top</button>
<p>Visit text inside paragraph tags.</p>
Skip text not enclosed by paragraph tags.
<p>A multiline paragraph<br>with boring text<br></p>
<a href="#">We should skip links</a>
<p>Visit me too.<p>
<div>Skip elements not explicitly labeled as paragraphs.</div>
*/}, function(root) {
mockFeedback.call(doCmd('jumpToTop'))
.call(doCmd('nextParagraph'))
.expectSpeech('Visit text inside paragraph tags.')
.call(doCmd('nextParagraph'))
.expectSpeech('A multiline paragraph')
.call(doCmd('nextParagraph'))
.expectSpeech('Visit me too.')
.call(doCmd('nextParagraph'))
.expectSpeech('Visit text inside paragraph tags.')
.call(doCmd('previousParagraph'))
.expectSpeech('Visit me too.')
.call(doCmd('previousParagraph'))
.expectSpeech('A multiline paragraph')
.call(doCmd('nextObject'))
.expectSpeech('with boring text')
// Ensure we go to the previous paragraph, not the top of the current one.
.call(doCmd('previousParagraph'))
.expectSpeech('Visit text inside paragraph tags.')
.replay();
});
});
TEST_F('ChromeVoxBackgroundTest', 'NoParagraphTest', function() {
var mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(function() {/*!
<button>Click me</button>
*/}, function(root) {
mockFeedback.call(doCmd('nextParagraph'))
.expectSpeech('No next paragraph.')
.call(doCmd('previousParagraph'))
.expectSpeech('No previous paragraph.');
mockFeedback.replay();
});
});
......@@ -533,6 +533,15 @@ CommandHandler.onCommand = function(command) {
predErrorMsg = 'no_previous_list';
skipInitialAncestry = false;
break;
case 'nextParagraph':
pred = AutomationPredicate.paragraph;
predErrorMsg = 'no_next_paragraph';
break;
case 'previousParagraph':
dir = Dir.BACKWARD;
pred = AutomationPredicate.paragraph;
predErrorMsg = 'no_previous_paragraph';
break;
case 'jumpToTop':
var node = AutomationUtil.findNodePost(
current.start.node.root, Dir.FORWARD, AutomationPredicate.object);
......
......@@ -3766,6 +3766,12 @@ If you're done with the tutorial, use ChromeVox to navigate to the Close button
<message desc="This is an abbreviated HTML description list detail element shown on a braille display. When translating, try to find a contracted form of the translation for 'description list detail' according to local conventions. If reasonable, use all lowercase and avoid punctuation to keep the number of characters as low as possible." name="IDS_CHROMEVOX_ROLE_DESCRIPTION_LIST_DETAIL_BRL">
dscrplst dtl
</message>
<message desc="Spoken if the user attempts to jump to the next paragraph when none exists." name="IDS_CHROMEVOX_NO_NEXT_PARAGRAPH">
No next paragraph.
</message>
<message desc="Spoken if the user attempts to jump to the previous paragraph when none exists." name="IDS_CHROMEVOX_NO_PREVIOUS_PARAGRAPH">
No previous paragraph.
</message>
</messages>
</release>
</grit>
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