Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2365)

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js

Issue 2144593003: Merge dom node and node unit types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js
index b855f90952ceefe7645cd876159344e5175d1d11..5d0eeb16de6dd19539a69ef6ac48035f18f6a6e0 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js
@@ -37,10 +37,10 @@ cursors.Unit = {
/** A leaf node. */
NODE: 'node',
- /** A leaf DOM-node. */
- DOM_NODE: 'dom_node',
-
- /** Formed by a set of leaf nodes that are inline. */
+ /**
+ * A node or in line textbox that immediately precedes or follows a visual
+ * line break.
+ */
LINE: 'line'
};
@@ -218,8 +218,7 @@ cursors.Cursor.prototype = {
var newNode = originalNode;
var newIndex = this.index_;
- if ((unit != Unit.NODE || unit != Unit.DOM_NODE) &&
- newIndex === cursors.NODE_INDEX)
+ if (unit != Unit.NODE && newIndex === cursors.NODE_INDEX)
newIndex = 0;
switch (unit) {
@@ -307,16 +306,13 @@ cursors.Cursor.prototype = {
}
break;
case Unit.NODE:
- case Unit.DOM_NODE:
switch (movement) {
case Movement.BOUND:
newIndex = dir == Dir.FORWARD ? this.getText().length - 1 : 0;
break;
case Movement.DIRECTIONAL:
- var pred = unit == Unit.NODE ?
- AutomationPredicate.leaf : AutomationPredicate.object;
newNode = AutomationUtil.findNextNode(
- newNode, dir, pred) || originalNode;
+ newNode, dir, AutomationPredicate.object) || originalNode;
newIndex = cursors.NODE_INDEX;
break;
}
@@ -387,9 +383,15 @@ cursors.WrappingCursor.prototype = {
return this;
// Regular movement.
- if (!AutomationPredicate.root(this.node) || dir == Dir.FORWARD)
+ if (!AutomationPredicate.root(this.node) ||
+ dir == Dir.FORWARD ||
+ movement == Movement.BOUND)
result = cursors.Cursor.prototype.move.call(this, unit, movement, dir);
+ // Moving to the bounds of a unit never wraps.
+ if (movement == Movement.BOUND)
+ return new cursors.WrappingCursor(result.node, result.index);
+
// There are two cases for wrapping:
// 1. moving forwards from the last element.
// 2. moving backwards from the first element.
@@ -398,7 +400,7 @@ cursors.WrappingCursor.prototype = {
// For 2, place range on the root (if not already there). If at root,
// try to descend to the first leaf-like object.
if (movement == Movement.DIRECTIONAL && result.equals(this)) {
- var pred = unit == Unit.DOM_NODE ?
+ var pred = unit == Unit.NODE ?
AutomationPredicate.object : AutomationPredicate.leaf;
var endpoint = this.node;
if (!endpoint)
@@ -568,7 +570,6 @@ cursors.Range.prototype = {
newEnd = newStart.move(unit, Movement.BOUND, Dir.FORWARD);
break;
case Unit.NODE:
- case Unit.DOM_NODE:
newStart = newStart.move(unit, Movement.DIRECTIONAL, dir);
newEnd = newStart;
break;

Powered by Google App Engine
This is Rietveld 408576698