Commit dbc89b9c authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

Preserve all meaningful space between inlines even if neighbor is focusable

After this should be better for Braille output, easier to predict for speech, and more accurately represents the format. 
For example 2 links on separate lines of HTML source will have a whitespace node between them -- this is rendered on the screen but until this CL did not show up in the a11y tree.
It also corrects the word boundary algorithm so that the start of a word does not occur in a whitespace-only node. ChromeVox's move-by-word algorithm was adjusted to be able to find the next node when the current one did not have a word stop.

Bug: None
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I4f7aa1624a2b5f7efb3d957656ec0b11fcc2a9af
Reviewed-on: https://chromium-review.googlesource.com/657561Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501625}
parent 7403f88c
......@@ -174,6 +174,23 @@ AutomationPredicate.leafWithText = function(node) {
return AutomationPredicate.leaf(node) && !!(node.name || node.value);
};
/**
* @param {!AutomationNode} node
* @return {boolean}
*/
AutomationPredicate.leafWithWordStop = function(node) {
function hasWordStop(node) {
if (node.role == Role.INLINE_TEXT_BOX)
return node.wordStarts && node.wordStarts.length;
// Non-text objects are treated as having a single word stop.
return true;
}
// Do not include static text leaves, which occur for an en end-of-line.
return AutomationPredicate.leaf(node) && !node.state[State.INVISIBLE] &&
node.role != Role.STATIC_TEXT && hasWordStop(node);
};
/**
* Matches against leaves or static text nodes. Useful when restricting
* traversal to non-inline textboxes while still allowing them if navigation
......
......@@ -64,6 +64,14 @@ BackgroundTest.prototype = {
<p>end<span>of test</span></p>
*/},
buttonDoc: function() {/*!
<p>start</p>
<button>hello button one</button>
cats
<button>hello button two</button>
<p>end</p>
*/},
formsDoc: function() {/*!
<select id="fruitSelect">
<option>apple</option>
......@@ -188,6 +196,10 @@ TEST_F('BackgroundTest', 'CaretNavigation', function() {
.expectSpeech('alpha', 'Link');
mockFeedback.call(doCmd('nextWord'))
.expectSpeech('beta', 'Link');
mockFeedback.call(doCmd('previousWord'))
.expectSpeech('alpha', 'Link');
mockFeedback.call(doCmd('nextWord'))
.expectSpeech('beta', 'Link');
mockFeedback.call(doCmd('nextWord'))
.expectSpeech('charlie', 'Heading 1');
mockFeedback.call(doCmd('nextLine'))
......@@ -218,6 +230,29 @@ TEST_F('BackgroundTest', 'CaretNavigation', function() {
});
});
/** Tests that individual buttons are stops for move-by-word functionality. */
TEST_F('BackgroundTest', 'CaretNavigationTreatsButtonAsWord', function() {
var mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(this.buttonDoc, function() {
mockFeedback.expectSpeech('start');
mockFeedback.call(doCmd('nextWord'))
.expectSpeech('hello button one', 'Button');
mockFeedback.call(doCmd('nextWord'))
.expectSpeech('cats');
mockFeedback.call(doCmd('nextWord'))
.expectSpeech('hello button two', 'Button');
mockFeedback.call(doCmd('nextWord'))
.expectSpeech('end');
mockFeedback.call(doCmd('previousWord'))
.expectSpeech('hello button two', 'Button');
mockFeedback.call(doCmd('previousWord'))
.expectSpeech('cats');
mockFeedback.call(doCmd('previousWord'))
.expectSpeech('hello button one', 'Button');
mockFeedback.replay();
});
});
TEST_F('BackgroundTest', 'SelectSingleBasic', function() {
var mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(this.formsDoc, function() {
......
......@@ -292,11 +292,10 @@ cursors.Cursor.prototype = {
var newNode = originalNode;
var newIndex = this.index_;
if (unit != Unit.NODE && newIndex === cursors.NODE_INDEX)
newIndex = 0;
switch (unit) {
case Unit.CHARACTER:
if (newIndex === cursors.NODE_INDEX)
newIndex = 0;
// BOUND and DIRECTIONAL are the same for characters.
var text = this.getText();
newIndex = dir == Dir.FORWARD ?
......@@ -317,12 +316,22 @@ cursors.Cursor.prototype = {
}
break;
case Unit.WORD:
if (newNode.role != RoleType.INLINE_TEXT_BOX) {
newNode = AutomationUtil.findNextNode(
newNode, Dir.FORWARD, AutomationPredicate.inlineTextBox,
{skipInitialSubtree: false}) ||
// If we're not already on a node with word stops, find the next one.
if (!AutomationPredicate.leafWithWordStop(newNode)) {
newNode =
AutomationUtil.findNextNode(
newNode, Dir.FORWARD, AutomationPredicate.leafWithWordStop,
{skipInitialSubtree: false}) ||
newNode;
}
// Ensure start position is on or after first word.
var firstWordStart = (newNode.wordStarts && newNode.wordStarts.length) ?
newNode.wordStarts[0] :
0;
if (newIndex < firstWordStart) // Also catches cursors.NODE_INDEX case.
newIndex = firstWordStart;
switch (movement) {
case Movement.BOUND:
if (newNode.role == RoleType.INLINE_TEXT_BOX) {
......@@ -338,44 +347,47 @@ cursors.Cursor.prototype = {
if (goog.isDef(start) && goog.isDef(end))
newIndex = dir == Dir.FORWARD ? end : start;
} else {
// TODO(dtseng): Figure out what to do in this case.
newIndex = cursors.NODE_INDEX;
}
break;
case Movement.DIRECTIONAL:
var start;
if (newNode.role == RoleType.INLINE_TEXT_BOX) {
var start, end;
// Go to the next word stop in the same piece of text.
for (var i = 0; i < newNode.wordStarts.length; i++) {
if (newIndex >= newNode.wordStarts[i] &&
newIndex <= newNode.wordEnds[i]) {
var nextIndex = dir == Dir.FORWARD ? i + 1 : i - 1;
start = newNode.wordStarts[nextIndex];
end = newNode.wordEnds[nextIndex];
break;
}
}
if (goog.isDef(start)) {
newIndex = start;
} else {
}
if (goog.isDef(start)) {
// Succesfully found the next word stop within the same text node.
newIndex = start;
} else {
// Use adjacent word in adjacent next node in direction |dir|.
if (dir == Dir.BACKWARD && newIndex > firstWordStart) {
// The backward case is special at the beginning of nodes.
if (dir == Dir.BACKWARD && newIndex != 0) {
newIndex = 0;
} else {
newNode = AutomationUtil.findNextNode(
newNode, dir, AutomationPredicate.leaf);
if (newNode) {
newIndex = 0;
if (dir == Dir.BACKWARD &&
newNode.role == RoleType.INLINE_TEXT_BOX) {
var starts = newNode.wordStarts;
newIndex = starts[starts.length - 1] || 0;
} else {
// TODO(dtseng): Figure out what to do for general nodes.
newIndex = firstWordStart;
} else {
newNode = AutomationUtil.findNextNode(
newNode, dir, AutomationPredicate.leafWithWordStop);
if (newNode) {
if (newNode.role == RoleType.INLINE_TEXT_BOX) {
var starts = newNode.wordStarts;
if (starts.length) {
newIndex = dir == Dir.BACKWARD ?
starts[starts.length - 1] :
starts[0];
}
} else {
// For non-text nodes, move by word = by object.
newIndex = cursors.NODE_INDEX;
}
}
}
} else {
// TODO(dtseng): Figure out what to do in this case.
}
}
break;
......
......@@ -2,9 +2,13 @@ rootWebArea
++link name='Section one'
++++staticText name='Section one'
++++++inlineTextBox name='Section one'
++staticText name=' '
++++inlineTextBox name=' '
++link name='Section two'
++++staticText name='Section two'
++++++inlineTextBox name='Section two'
++staticText name=' '
++++inlineTextBox name=' '
++link name='Section three' ariaCurrentState=location
++++staticText name='Section three'
++++++inlineTextBox name='Section three'
......@@ -31,4 +35,4 @@ rootWebArea
++++staticText name=' '
++++++inlineTextBox name=' '
++++staticText name='Span 3'
++++++inlineTextBox name='Span 3'
++++++inlineTextBox name='Span 3'
\ No newline at end of file
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++ROLE_SYSTEM_LINK name='Section one' FOCUSABLE
++++ROLE_SYSTEM_STATICTEXT name='Section one'
++ROLE_SYSTEM_STATICTEXT name=' '
++ROLE_SYSTEM_LINK name='Section two' FOCUSABLE
++++ROLE_SYSTEM_STATICTEXT name='Section two'
++ROLE_SYSTEM_STATICTEXT name=' '
++ROLE_SYSTEM_LINK name='Section three' FOCUSABLE current:location
++++ROLE_SYSTEM_STATICTEXT name='Section three'
++ROLE_SYSTEM_WHITESPACE name='<newline>'
......@@ -19,4 +21,4 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++++IA2_ROLE_SECTION current:true
++++++ROLE_SYSTEM_STATICTEXT name='Span 2'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_STATICTEXT name='Span 3'
++++ROLE_SYSTEM_STATICTEXT name='Span 3'
\ No newline at end of file
android.webkit.WebView focusable focused scrollable
++android.view.View role_description='link' clickable focusable link name='InnerText0'
++android.view.View name=' '
++android.view.View role_description='link' clickable focusable link name='InnerText1' hint='Title1'
++android.view.View name=' '
++android.view.View role_description='link' clickable focusable link name='Title2'
++android.view.View name=' '
++android.view.View role_description='link' clickable focusable link name='LabelledBy3'
++android.view.View role_description='link' clickable focusable link name='Title4'
++android.view.View role_description='link' clickable focusable link name='Label5'
......
......@@ -2,12 +2,18 @@ rootWebArea
++link name='InnerText0' nameFrom=contents
++++staticText name='InnerText0' nameFrom=contents
++++++inlineTextBox name='InnerText0' nameFrom=contents
++staticText name=' ' nameFrom=contents
++++inlineTextBox name=' ' nameFrom=contents
++link description='Title1' name='InnerText1' nameFrom=contents descriptionFrom=attribute
++++staticText name='InnerText1' nameFrom=contents
++++++inlineTextBox name='InnerText1' nameFrom=contents
++staticText name=' ' nameFrom=contents
++++inlineTextBox name=' ' nameFrom=contents
++link name='Title2' nameFrom=attribute
++++staticText name='InnerText2' nameFrom=contents
++++++inlineTextBox name='InnerText2' nameFrom=contents
++staticText name=' ' nameFrom=contents
++++inlineTextBox name=' ' nameFrom=contents
++link name='LabelledBy3' nameFrom=relatedElement
++++staticText name='InnerText3' nameFrom=contents
++++++inlineTextBox name='InnerText3' nameFrom=contents
......
......@@ -9,4 +9,5 @@ android.webkit.WebView focusable focused scrollable
++++android.view.View role_description='link' clickable focusable link name=' '
++++android.view.View role_description='link' clickable focusable link name=' '
++++android.view.View role_description='link' clickable focusable link name='greenbox'
++++android.view.View role_description='link' clickable focusable link name='greenbox'
++++android.view.View name=' '
++++android.view.View role_description='link' clickable focusable link name='greenbox'
\ No newline at end of file
......@@ -18,5 +18,7 @@ rootWebArea
++++++image
++++link
++++++image
++++staticText name=' '
++++++inlineTextBox name=' '
++++link
++++++image
++++++image
\ No newline at end of file
android.webkit.WebView focusable focused scrollable
++android.view.View
++++android.view.View role_description='link' clickable focusable link name='Link with image at start.'
++++android.view.View name=' '
++++android.view.View role_description='link' clickable focusable link name='Link with image in the middle.'
++++android.view.View name=' '
++++android.view.View role_description='link' clickable focusable link name='Link with broken in the middle.'
++++android.view.View name=' '
++++android.view.View role_description='link' clickable focusable link name='Link with image at the end'
\ No newline at end of file
......@@ -4,18 +4,24 @@ rootWebArea
++++++image linked name='Link'
++++++staticText linked name=' with image at start.'
++++++++inlineTextBox name=' with image at start.'
++++staticText name=' '
++++++inlineTextBox name=' '
++++link linked name='Link with image in the middle.'
++++++staticText linked name='Link with '
++++++++inlineTextBox name='Link with '
++++++image linked name='image'
++++++staticText linked name=' in the middle.'
++++++++inlineTextBox name=' in the middle.'
++++staticText name=' '
++++++inlineTextBox name=' '
++++link linked name='Link with broken in the middle.'
++++++staticText linked name='Link with '
++++++++inlineTextBox name='Link with '
++++++image linked name='broken'
++++++staticText linked name=' in the middle.'
++++++++inlineTextBox name=' in the middle.'
++++staticText name=' '
++++++inlineTextBox name=' '
++++link linked name='Link with image at the end'
++++++staticText linked name='Link with image at the '
++++++++inlineTextBox name='Link with image at the '
......
......@@ -3,14 +3,17 @@ AXWebArea
++++AXLink AXTitle='Link with image at start.'
++++++AXImage AXDescription='Link'
++++++AXStaticText AXValue=' with image at start.'
++++AXStaticText AXValue=' '
++++AXLink AXTitle='Link with image in the middle.'
++++++AXStaticText AXValue='Link with '
++++++AXImage AXDescription='image'
++++++AXStaticText AXValue=' in the middle.'
++++AXStaticText AXValue=' '
++++AXLink AXTitle='Link with broken in the middle.'
++++++AXStaticText AXValue='Link with '
++++++AXImage AXDescription='broken'
++++++AXStaticText AXValue=' in the middle.'
++++AXStaticText AXValue=' '
++++AXLink AXTitle='Link with image at the end'
++++++AXStaticText AXValue='Link with image at the '
++++++AXImage AXDescription='end'
++++++AXImage AXDescription='end'
\ No newline at end of file
......@@ -3,14 +3,17 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++++ROLE_SYSTEM_LINK name='Link with image at start.' FOCUSABLE
++++++ROLE_SYSTEM_GRAPHIC name='Link' READONLY
++++++ROLE_SYSTEM_STATICTEXT name=' with image at start.'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_LINK name='Link with image in the middle.' FOCUSABLE
++++++ROLE_SYSTEM_STATICTEXT name='Link with '
++++++ROLE_SYSTEM_GRAPHIC name='image' READONLY
++++++ROLE_SYSTEM_STATICTEXT name=' in the middle.'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_LINK name='Link with broken in the middle.' FOCUSABLE
++++++ROLE_SYSTEM_STATICTEXT name='Link with '
++++++ROLE_SYSTEM_GRAPHIC name='broken' READONLY
++++++ROLE_SYSTEM_STATICTEXT name=' in the middle.'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_LINK name='Link with image at the end' FOCUSABLE
++++++ROLE_SYSTEM_STATICTEXT name='Link with image at the '
++++++ROLE_SYSTEM_GRAPHIC name='end' READONLY
++++++ROLE_SYSTEM_GRAPHIC name='end' READONLY
\ No newline at end of file
android.webkit.WebView focusable focused scrollable
++android.view.View role_description='link' clickable focusable link name='Empty anchor'
++android.view.View name=' '
++android.view.View role_description='link' clickable focusable link name='Anchor with content'
++android.view.View name=' '
++android.view.View role_description='link' clickable focusable link name='Anchor with ID'
++android.view.View name=' '
++android.view.View role_description='link' clickable focusable link name='Empty span'
++android.view.View name=' '
++android.view.View role_description='link' clickable focusable link name='Span with content'
++android.view.View name=' '
++android.view.View role_description='link' clickable focusable link name='Paragraph with content'
++android.view.View
++++android.view.View clickable
......@@ -17,4 +22,4 @@ android.webkit.WebView focusable focused scrollable
++++android.view.View name='After empty span'
++android.view.View
++++android.view.View name='Span with content'
++android.view.View name='Paragraph with content'
++android.view.View name='Paragraph with content'
\ No newline at end of file
......@@ -2,18 +2,28 @@ rootWebArea
++link name='Empty anchor' inPageLinkTargetId=anchor
++++staticText name='Empty anchor'
++++++inlineTextBox name='Empty anchor'
++staticText name=' '
++++inlineTextBox name=' '
++link name='Anchor with content' inPageLinkTargetId=anchor
++++staticText name='Anchor with content'
++++++inlineTextBox name='Anchor with content'
++staticText name=' '
++++inlineTextBox name=' '
++link name='Anchor with ID' inPageLinkTargetId=anchor
++++staticText name='Anchor with ID'
++++++inlineTextBox name='Anchor with ID'
++staticText name=' '
++++inlineTextBox name=' '
++link name='Empty span' inPageLinkTargetId=genericContainer
++++staticText name='Empty span'
++++++inlineTextBox name='Empty span'
++staticText name=' '
++++inlineTextBox name=' '
++link name='Span with content' inPageLinkTargetId=genericContainer
++++staticText name='Span with content'
++++++inlineTextBox name='Span with content'
++staticText name=' '
++++inlineTextBox name=' '
++link name='Paragraph with content' inPageLinkTargetId=paragraph
++++staticText name='Paragraph with content'
++++++inlineTextBox name='Paragraph with content'
......@@ -39,4 +49,4 @@ rootWebArea
++++++++inlineTextBox name='Span with content'
++paragraph
++++staticText name='Paragraph with content'
++++++inlineTextBox name='Paragraph with content'
++++++inlineTextBox name='Paragraph with content'
\ No newline at end of file
AXWebArea
++AXLink AXTitle='Empty anchor' AXLinkedUIElements=["AXGroup"]
++++AXStaticText AXValue='Empty anchor'
++AXStaticText AXValue=' '
++AXLink AXTitle='Anchor with content' AXLinkedUIElements=["AXGroup Anchor with content"]
++++AXStaticText AXValue='Anchor with content'
++AXStaticText AXValue=' '
++AXLink AXTitle='Anchor with ID' AXLinkedUIElements=["AXGroup Anchor with ID"]
++++AXStaticText AXValue='Anchor with ID'
++AXStaticText AXValue=' '
++AXLink AXTitle='Empty span' AXLinkedUIElements=["AXGroup"]
++++AXStaticText AXValue='Empty span'
++AXStaticText AXValue=' '
++AXLink AXTitle='Span with content' AXLinkedUIElements=["AXGroup"]
++++AXStaticText AXValue='Span with content'
++AXStaticText AXValue=' '
++AXLink AXTitle='Paragraph with content' AXLinkedUIElements=["AXGroup"]
++++AXStaticText AXValue='Paragraph with content'
++AXGroup
......@@ -27,4 +32,4 @@ AXWebArea
++++AXGroup
++++++AXStaticText AXValue='Span with content'
++AXGroup
++++AXStaticText AXValue='Paragraph with content'
++++AXStaticText AXValue='Paragraph with content'
\ No newline at end of file
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++ROLE_SYSTEM_LINK name='Empty anchor' FOCUSABLE LINKED
++++ROLE_SYSTEM_STATICTEXT name='Empty anchor' LINKED
++ROLE_SYSTEM_STATICTEXT name=' '
++ROLE_SYSTEM_LINK name='Anchor with content' FOCUSABLE LINKED
++++ROLE_SYSTEM_STATICTEXT name='Anchor with content' LINKED
++ROLE_SYSTEM_STATICTEXT name=' '
++ROLE_SYSTEM_LINK name='Anchor with ID' FOCUSABLE LINKED
++++ROLE_SYSTEM_STATICTEXT name='Anchor with ID' LINKED
++ROLE_SYSTEM_STATICTEXT name=' '
++ROLE_SYSTEM_LINK name='Empty span' FOCUSABLE LINKED
++++ROLE_SYSTEM_STATICTEXT name='Empty span' LINKED
++ROLE_SYSTEM_STATICTEXT name=' '
++ROLE_SYSTEM_LINK name='Span with content' FOCUSABLE LINKED
++++ROLE_SYSTEM_STATICTEXT name='Span with content' LINKED
++ROLE_SYSTEM_STATICTEXT name=' '
++ROLE_SYSTEM_LINK name='Paragraph with content' FOCUSABLE LINKED
++++ROLE_SYSTEM_STATICTEXT name='Paragraph with content' LINKED
++IA2_ROLE_PARAGRAPH
......@@ -27,4 +32,4 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++++IA2_ROLE_SECTION
++++++ROLE_SYSTEM_STATICTEXT name='Span with content'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_STATICTEXT name='Paragraph with content'
++++ROLE_SYSTEM_STATICTEXT name='Paragraph with content'
\ No newline at end of file
......@@ -21,18 +21,24 @@ rootWebArea
++paragraph
++++staticText name='E1. Eat'
++++++inlineTextBox name='E1. Eat'
++++staticText name=' '
++++++inlineTextBox name=' '
++++link name='space'
++++++staticText name='space'
++++++++inlineTextBox name='space'
++paragraph
++++staticText name='E2. Eat'
++++++inlineTextBox name='E2. Eat'
++++staticText name=' '
++++++inlineTextBox name=' '
++++link name='space'
++++++staticText name='space'
++++++++inlineTextBox name='space'
++paragraph
++++staticText name='E3. Eat'
++++++inlineTextBox name='E3. Eat'
++++staticText name=' '
++++++inlineTextBox name=' '
++++link name='space'
++++++staticText name='space'
++++++++inlineTextBox name='space'
......@@ -40,18 +46,24 @@ rootWebArea
++++link name='E4. Eat'
++++++staticText name='E4. Eat'
++++++++inlineTextBox name='E4. Eat'
++++staticText name=' '
++++++inlineTextBox name=' '
++++staticText name='space'
++++++inlineTextBox name='space'
++paragraph
++++link name='E5. Eat'
++++++staticText name='E5. Eat'
++++++++inlineTextBox name='E5. Eat'
++++staticText name=' '
++++++inlineTextBox name=' '
++++staticText name='space'
++++++inlineTextBox name='space'
++paragraph
++++link name='E6. Eat'
++++++staticText name='E6. Eat'
++++++++inlineTextBox name='E6. Eat'
++++staticText name=' '
++++++inlineTextBox name=' '
++++staticText name='space'
++++++inlineTextBox name='space'
++paragraph
......@@ -74,4 +86,4 @@ rootWebArea
++++staticText name=' '
++++++inlineTextBox name=' '
++++staticText name='space'
++++++inlineTextBox name='space'
++++++inlineTextBox name='space'
\ No newline at end of file
......@@ -11,27 +11,33 @@ AXWebArea
++++AXStaticText AXValue='.'
++AXGroup
++++AXStaticText AXValue='E1. Eat'
++++AXStaticText AXValue=' '
++++AXLink
++++++AXStaticText AXValue='space'
++AXGroup
++++AXStaticText AXValue='E2. Eat'
++++AXStaticText AXValue=' '
++++AXLink
++++++AXStaticText AXValue='space'
++AXGroup
++++AXStaticText AXValue='E3. Eat'
++++AXStaticText AXValue=' '
++++AXLink
++++++AXStaticText AXValue='space'
++AXGroup
++++AXLink
++++++AXStaticText AXValue='E4. Eat'
++++AXStaticText AXValue=' '
++++AXStaticText AXValue='space'
++AXGroup
++++AXLink
++++++AXStaticText AXValue='E5. Eat'
++++AXStaticText AXValue=' '
++++AXStaticText AXValue='space'
++AXGroup
++++AXLink
++++++AXStaticText AXValue='E6. Eat'
++++AXStaticText AXValue=' '
++++AXStaticText AXValue='space'
++AXGroup
++++AXStaticText AXValue='K1. Keep'
......
......@@ -11,27 +11,33 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++++ROLE_SYSTEM_STATICTEXT name='.'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_STATICTEXT name='E1. Eat'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_LINK name='space' FOCUSABLE
++++++ROLE_SYSTEM_STATICTEXT name='space'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_STATICTEXT name='E2. Eat'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_LINK name='space' FOCUSABLE
++++++ROLE_SYSTEM_STATICTEXT name='space'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_STATICTEXT name='E3. Eat'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_LINK name='space' FOCUSABLE
++++++ROLE_SYSTEM_STATICTEXT name='space'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_LINK name='E4. Eat' FOCUSABLE
++++++ROLE_SYSTEM_STATICTEXT name='E4. Eat'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_STATICTEXT name='space'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_LINK name='E5. Eat' FOCUSABLE
++++++ROLE_SYSTEM_STATICTEXT name='E5. Eat'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_STATICTEXT name='space'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_LINK name='E6. Eat' FOCUSABLE
++++++ROLE_SYSTEM_STATICTEXT name='E6. Eat'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_STATICTEXT name='space'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_STATICTEXT name='K1. Keep'
......
......@@ -52,7 +52,7 @@
assert_equals(sel.startContainer.textContent, "this is a");
// Select the second child.
axRegion.setSelection(axRegion, 1, axRegion, 2);
axRegion.setSelection(axRegion, 1, axRegion, 3);
updateSelectedRangeFromPage();
assert_equals(sel.toString(), "test\n");
assert_false(sel.collapsed);
......@@ -65,7 +65,7 @@
assert_equals(sel.endContainer.textContent, "\n ");
// Next, another insertion point between second and third child.
axRegion.setSelection(axRegion, 2, axRegion, 2);
axRegion.setSelection(axRegion, 3, axRegion, 3);
updateSelectedRangeFromPage();
assert_equals(sel.toString(), "");
assert_true(sel.collapsed);
......@@ -74,7 +74,7 @@
assert_equals(sel.startContainer.textContent, "\n ");
// Select the third child.
axRegion.setSelection(axRegion, 2, axRegion, 3);
axRegion.setSelection(axRegion, 3, axRegion, 4);
updateSelectedRangeFromPage();
assert_equals(sel.toString(), "of selection");
assert_false(sel.collapsed);
......@@ -86,7 +86,7 @@
assert_equals(sel.endContainer.textContent, "of selection");
// Select the first and second children.
axRegion.setSelection(axRegion, 0, axRegion, 2);
axRegion.setSelection(axRegion, 0, axRegion, 3);
updateSelectedRangeFromPage();
assert_equals(sel.toString(), "this is atest\n");
assert_false(sel.collapsed);
......@@ -98,7 +98,7 @@
assert_equals(sel.endContainer.textContent, "\n ");
// Select the second and third children.
axRegion.setSelection(axRegion, 1, axRegion, 3);
axRegion.setSelection(axRegion, 1, axRegion, 4);
updateSelectedRangeFromPage();
assert_equals(sel.toString(), "test\n of selection");
assert_false(sel.collapsed);
......@@ -110,7 +110,7 @@
assert_equals(sel.endContainer.textContent, "of selection");
// Select everything.
axRegion.setSelection(axRegion, 0, axRegion, 3);
axRegion.setSelection(axRegion, 0, axRegion, 4);
updateSelectedRangeFromPage();
assert_equals(sel.toString(), "this is atest\n of selection");
assert_false(sel.collapsed);
......@@ -122,7 +122,7 @@
assert_equals(sel.endContainer.textContent, "of selection");
// Last, the insertion point after third child.
axRegion.setSelection(axRegion, 3, axRegion, 3);
axRegion.setSelection(axRegion, 4, axRegion, 4);
updateSelectedRangeFromPage();
assert_equals(sel.toString(), "");
assert_true(sel.collapsed);
......
......@@ -112,7 +112,7 @@ void AXInlineTextBox::TextCharacterOffsets(Vector<int>& offsets) const {
}
void AXInlineTextBox::GetWordBoundaries(Vector<AXRange>& words) const {
if (!inline_text_box_)
if (!inline_text_box_ || inline_text_box_->GetText().ContainsOnlyWhitespace())
return;
Vector<AbstractInlineTextBox::WordBoundaries> word_boundaries;
......
......@@ -733,15 +733,6 @@ bool AXLayoutObject::ComputeAccessibilityIsIgnored(
return true;
}
bool AXLayoutObject::IsFocusableByDefault(Element* elem) const {
// These are the only naturally focusable elements that are focusable without
// contenteditable or tabindex.
DCHECK(elem);
return elem->IsFormControlElement() || elem->HasTagName(aTag) ||
elem->HasTagName(audioTag) || elem->HasTagName(iframeTag) ||
elem->HasTagName(summaryTag) || elem->HasTagName(videoTag);
}
bool AXLayoutObject::HasAriaCellRole(Element* elem) const {
DCHECK(elem);
const AtomicString& aria_role_str = elem->FastGetAttribute(roleAttr);
......@@ -792,7 +783,7 @@ bool AXLayoutObject::CanIgnoreSpaceNextTo(LayoutObject* layout,
Node* node = layout->GetNode();
if (node && node->IsElementNode()) {
Element* elem = ToElement(node);
if (IsFocusableByDefault(elem) || HasAriaCellRole(elem))
if (HasAriaCellRole(elem))
return true;
}
......
......@@ -213,7 +213,6 @@ class MODULES_EXPORT AXLayoutObject : public AXNodeObject {
bool CanIgnoreTextAsEmpty() const;
bool CanIgnoreSpaceNextTo(LayoutObject*, bool is_after) const;
bool IsFocusableByDefault(Element*) const;
bool HasAriaCellRole(Element*) const;
};
......
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