Commit 3f5a3095 authored by Katie D's avatar Katie D Committed by Commit Bot

Read text in SVGs in DOM order as if it is in a single paragraph.

This makes Slides read more smoothly, but will not differentiate
between spaces between words and paragraphs in intonation.

DOM ordering is used rather than visual ordering, this is unchanged.

Bug: 809734
Change-Id: Ieb17eef53f4de360f2d1f13e8a561d3aa05af115
Reviewed-on: https://chromium-review.googlesource.com/c/1262086Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Katie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596881}
parent 8dd8aed3
......@@ -23,11 +23,12 @@ ParagraphUtils.getFirstBlockAncestor = function(node) {
if (parent == root) {
return parent;
}
if (parent.role == RoleType.PARAGRAPH) {
if (parent.role == RoleType.PARAGRAPH || parent.role == RoleType.SVG_ROOT) {
return parent;
}
if (parent.display !== undefined && parent.display != 'inline' &&
parent.role != RoleType.STATIC_TEXT) {
parent.role != RoleType.STATIC_TEXT &&
(parent.parent && parent.parent.role != RoleType.SVG_ROOT)) {
return parent;
}
parent = parent.parent;
......@@ -215,7 +216,8 @@ ParagraphUtils.buildNodeGroup = function(nodes, index) {
result.nodes.push(newNode);
}
}
if (!ParagraphUtils.inSameParagraph(node, next)) {
if (index + 1 >= nodes.length ||
!ParagraphUtils.inSameParagraph(node, next)) {
break;
}
index += 1;
......
......@@ -37,6 +37,20 @@ TEST_F('SelectToSpeakParagraphUnitTest', 'GetFirstBlockAncestor', function() {
assertEquals(div, ParagraphUtils.getFirstBlockAncestor(text4));
});
TEST_F('SelectToSpeakParagraphUnitTest', 'SVGRootIsBlockAncestor', function() {
let root = {role: 'rootWebArea'};
let svgRoot = {role: 'svgRoot', parent: root, root: root};
let text1 = {role: 'staticText', parent: svgRoot, root: root};
let inline1 = {role: 'inlineTextBox', parent: text1, root: root};
let text2 = {role: 'staticText', parent: svgRoot, root: root};
let inline2 = {role: 'inlineTextBox', parent: text2, root: root};
assertEquals(svgRoot, ParagraphUtils.getFirstBlockAncestor(text1));
assertEquals(svgRoot, ParagraphUtils.getFirstBlockAncestor(inline1));
assertEquals(svgRoot, ParagraphUtils.getFirstBlockAncestor(inline2));
assertTrue(ParagraphUtils.inSameParagraph(inline1, inline2));
});
TEST_F('SelectToSpeakParagraphUnitTest', 'InSameParagraph', function() {
let root = {role: 'rootWebArea'};
let paragraph1 = {role: 'paragraph', display: 'block', parent: 'rootWebArea',
......@@ -202,3 +216,17 @@ TEST_F('SelectToSpeakParagraphUnitTest', 'BuildNodeGroupNativeTextBox',
result = ParagraphUtils.buildNodeGroup([searchBar], 0);
assertEquals('Address and search bar ', result.text);
});
TEST_F('SelectToSpeakParagraphUnitTest', 'BuildNodeGroupWithSvg', function() {
let root = {role: 'rootWebArea'};
let svgRoot = {role: 'svgRoot', parent: root, root: root};
let text1 = {role: 'staticText', parent: svgRoot, root: root, name: 'Hello,'};
let inline1 = {role: 'inlineTextBox', parent: text1, root: root,
name: 'Hello,'};
let text2 = {role: 'staticText', parent: svgRoot, root: root, name: 'world!'};
let inline2 = {role: 'inlineTextBox', parent: text2, root: root,
name: 'world!'};
let result = ParagraphUtils.buildNodeGroup([inline1, inline2], 0);
assertEquals('Hello, world! ', result.text);
});
......@@ -635,8 +635,10 @@ SelectToSpeak.prototype = {
this.currentNodeGroupIndex_ += 1;
this.currentNode_ = next;
this.currentNodeWord_ = null;
next = nodeGroup.nodes[this.currentNodeGroupIndex_ + 1];
nodeUpdated = true;
if (this.currentNodeGroupIndex_ + 1 >= nodeGroup.nodes.length)
break;
next = nodeGroup.nodes[this.currentNodeGroupIndex_ + 1];
}
if (nodeUpdated) {
if (!this.prefsManager_.wordHighlightingEnabled()) {
......
......@@ -26,6 +26,7 @@ chrome.automation.RoleType = {
RADIO_BUTTON: 'radioButton',
ROOT_WEB_AREA: 'rootWebArea',
STATIC_TEXT: 'staticText',
SVG_ROOT: 'svgRoot',
TEXT_FIELD: 'textField',
WINDOW: 'window'
};
......
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