Commit fcc6bc93 authored by David Tseng's avatar David Tseng Committed by Chromium LUCI CQ

Fix ChromeVox Closure compiler errors

The cursors package was moved to accessibility/common, but did not
trigger presubmit upload Closure errors because no files were
technically touched in chromevox/ (deletion/move appears not to count).

@private means "private to that file" (aka, all classes can access
private members of other classes if they're in the same file).

cursor.js and range.js were split out from cursors.js leading to the
Closure errors.

R=akihiroota@chromium.org

AX-Relnotes: n/a
Change-Id: I140dfd153e307e0c3c8a244b57be7f3ac542231d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2643572
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846447}
parent b9347324
......@@ -192,9 +192,8 @@ cursors.Cursor = class {
/**
* A node appropriate for making selections.
* @return {AutomationNode}
* @private
*/
get selectionNode_() {
get selectionNode() {
let adjustedNode = this.node;
if (!adjustedNode) {
return null;
......@@ -233,9 +232,8 @@ cursors.Cursor = class {
* cursors.NODE_INDEX index, the selection index is a node offset e.g. the
* index in parent. If not, the index is a character offset.
* @return {number}
* @private
*/
get selectionIndex_() {
get selectionIndex() {
let adjustedIndex = this.index_;
if (!this.node) {
......@@ -272,7 +270,7 @@ cursors.Cursor = class {
do {
adjustedIndex = childOfSelection.indexInParent || 0;
childOfSelection = childOfSelection.parent;
} while (childOfSelection && childOfSelection !== this.selectionNode_);
} while (childOfSelection && childOfSelection !== this.selectionNode);
}
// A character offset into content is the remaining case. It requires no
// adjustment.
......
......@@ -443,23 +443,23 @@ TEST_F(
let secondLineCursor = new cursors.Cursor(secondLine, -1);
// The selected node moves to the static text node.
assertEquals(
secondLineCursor.node.parent, secondLineCursor.selectionNode_);
secondLineCursor.node.parent, secondLineCursor.selectionNode);
// This selects the entire node via a character offset.
assertEquals(6, secondLineCursor.selectionIndex_);
assertEquals(6, secondLineCursor.selectionIndex);
// Index into the characters.
secondLineCursor = new cursors.Cursor(secondLine, 1);
assertEquals(7, secondLineCursor.selectionIndex_);
assertEquals(7, secondLineCursor.selectionIndex);
// Now, try selecting via node offsets.
let cursor = new cursors.Cursor(root.firstChild, -1);
assertEquals(root, cursor.selectionNode_);
assertEquals(0, cursor.selectionIndex_);
assertEquals(root, cursor.selectionNode);
assertEquals(0, cursor.selectionIndex);
cursor = new cursors.Cursor(root.firstChild.nextSibling, -1);
assertEquals(root, cursor.selectionNode_);
assertEquals(1, cursor.selectionIndex_);
assertEquals(root, cursor.selectionNode);
assertEquals(1, cursor.selectionIndex);
});
});
......@@ -492,14 +492,14 @@ TEST_F('AccessibilityExtensionCursorsTest', 'InlineElementOffset', function() {
const ofSelectionNode = root.lastChild.lastChild;
const cur = new cursors.Cursor(ofSelectionNode, 0);
assertEquals('of selection', cur.selectionNode_.name);
assertEquals(RoleType.STATIC_TEXT, cur.selectionNode_.role);
assertEquals(0, cur.selectionIndex_);
assertEquals('of selection', cur.selectionNode.name);
assertEquals(RoleType.STATIC_TEXT, cur.selectionNode.role);
assertEquals(0, cur.selectionIndex);
const curIntoO = new cursors.Cursor(ofSelectionNode, 1);
assertEquals('of selection', curIntoO.selectionNode_.name);
assertEquals(RoleType.STATIC_TEXT, curIntoO.selectionNode_.role);
assertEquals(1, curIntoO.selectionIndex_);
assertEquals('of selection', curIntoO.selectionNode.name);
assertEquals(RoleType.STATIC_TEXT, curIntoO.selectionNode.role);
assertEquals(1, curIntoO.selectionIndex);
const oRange = new cursors.Range(cur, curIntoO);
oRange.select();
......@@ -628,38 +628,38 @@ TEST_F(
// Ranges by default surround a node. Ensure it results in a
// collapsed selection.
let range = cursors.Range.fromNode(staticText);
assertEquals(0, range.start.selectionIndex_);
assertEquals(0, range.end.selectionIndex_);
assertEquals(paragraph, range.start.selectionNode_);
assertEquals(paragraph, range.end.selectionNode_);
assertEquals(0, range.start.selectionIndex);
assertEquals(0, range.end.selectionIndex);
assertEquals(paragraph, range.start.selectionNode);
assertEquals(paragraph, range.end.selectionNode);
// Text selection.
range = new cursors.Range(
new cursors.Cursor(staticText, 2),
new cursors.Cursor(staticText, 4));
assertEquals(2, range.start.selectionIndex_);
assertEquals(4, range.end.selectionIndex_);
assertEquals(staticText, range.start.selectionNode_);
assertEquals(staticText, range.end.selectionNode_);
assertEquals(2, range.start.selectionIndex);
assertEquals(4, range.end.selectionIndex);
assertEquals(staticText, range.start.selectionNode);
assertEquals(staticText, range.end.selectionNode);
// Tree selection.
range = cursors.Range.fromNode(paragraph);
assertEquals(0, range.start.selectionIndex_);
assertEquals(0, range.end.selectionIndex_);
assertEquals(textField, range.start.selectionNode_);
assertEquals(textField, range.end.selectionNode_);
assertEquals(0, range.start.selectionIndex);
assertEquals(0, range.end.selectionIndex);
assertEquals(textField, range.start.selectionNode);
assertEquals(textField, range.end.selectionNode);
range = cursors.Range.fromNode(otherStaticText);
assertEquals(0, range.start.selectionIndex_);
assertEquals(0, range.end.selectionIndex_);
assertEquals(otherParagraph, range.start.selectionNode_);
assertEquals(otherParagraph, range.end.selectionNode_);
assertEquals(0, range.start.selectionIndex);
assertEquals(0, range.end.selectionIndex);
assertEquals(otherParagraph, range.start.selectionNode);
assertEquals(otherParagraph, range.end.selectionNode);
range = cursors.Range.fromNode(otherParagraph);
assertEquals(1, range.start.selectionIndex_);
assertEquals(1, range.end.selectionIndex_);
assertEquals(textField, range.start.selectionNode_);
assertEquals(textField, range.end.selectionNode_);
assertEquals(1, range.start.selectionIndex);
assertEquals(1, range.end.selectionIndex);
assertEquals(textField, range.start.selectionNode);
assertEquals(textField, range.end.selectionNode);
});
});
......@@ -675,19 +675,19 @@ TEST_F(
const testEditable = function(edit) {
// Occurs as part of ordinary (non-text) navigation.
let range = cursors.Range.fromNode(edit);
assertEquals(-1, range.start.selectionIndex_);
assertEquals(-1, range.end.selectionIndex_);
assertEquals(edit, range.start.selectionNode_);
assertEquals(edit, range.end.selectionNode_);
assertEquals(-1, range.start.selectionIndex);
assertEquals(-1, range.end.selectionIndex);
assertEquals(edit, range.start.selectionNode);
assertEquals(edit, range.end.selectionNode);
// Occurs as a result of explicit text nav e.g. nextCharacter
// command.
range = new cursors.Range(
new cursors.Cursor(edit, 2), new cursors.Cursor(edit, 3));
assertEquals(2, range.start.selectionIndex_);
assertEquals(3, range.end.selectionIndex_);
assertEquals(edit, range.start.selectionNode_);
assertEquals(edit, range.end.selectionNode_);
assertEquals(2, range.start.selectionIndex);
assertEquals(3, range.end.selectionIndex);
assertEquals(edit, range.start.selectionNode);
assertEquals(edit, range.end.selectionNode);
};
const textField = root.firstChild.firstChild;
......
......@@ -207,8 +207,8 @@ cursors.Range = class {
start = this.end;
end = this.start;
}
const startNode = start.selectionNode_;
const endNode = end.selectionNode_;
const startNode = start.selectionNode;
const endNode = end.selectionNode;
if (!startNode || !endNode) {
return;
......@@ -219,10 +219,9 @@ cursors.Range = class {
startNode.root === endNode.root) {
// We want to adjust to select the entire node for node offsets;
// otherwise, use the plain character offset.
const startIndex = start.selectionIndex_;
let endIndex = end.index_ === cursors.NODE_INDEX ?
end.selectionIndex_ + 1 :
end.selectionIndex_;
const startIndex = start.selectionIndex;
let endIndex = end.index === cursors.NODE_INDEX ? end.selectionIndex + 1 :
end.selectionIndex;
// Richly editables should always set a caret, but not select. This
// makes it possible to navigate through content editables using
......
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