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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js

Issue 2007183002: Make ChromeVox cursor robust to deleted nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Provides output services for ChromeVox. 6 * @fileoverview Provides output services for ChromeVox.
7 */ 7 */
8 8
9 goog.provide('Output'); 9 goog.provide('Output');
10 goog.provide('Output.EventType'); 10 goog.provide('Output.EventType');
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 }, 1247 },
1248 1248
1249 /** 1249 /**
1250 * @param {!cursors.Range} range 1250 * @param {!cursors.Range} range
1251 * @param {cursors.Range} prevRange 1251 * @param {cursors.Range} prevRange
1252 * @param {EventType|Output.EventType} type 1252 * @param {EventType|Output.EventType} type
1253 * @param {!Array<Spannable>} rangeBuff 1253 * @param {!Array<Spannable>} rangeBuff
1254 * @private 1254 * @private
1255 */ 1255 */
1256 range_: function(range, prevRange, type, rangeBuff) { 1256 range_: function(range, prevRange, type, rangeBuff) {
1257 if (!range.start.node || !range.end.node)
1258 return;
1259
1257 if (!prevRange) 1260 if (!prevRange)
1258 prevRange = cursors.Range.fromNode(range.start.node.root); 1261 prevRange = cursors.Range.fromNode(range.start.node.root);
1259 var cursor = cursors.Cursor.fromNode(range.start.node); 1262 var cursor = cursors.Cursor.fromNode(range.start.node);
1260 var prevNode = prevRange.start.node; 1263 var prevNode = prevRange.start.node;
1261 1264
1262 var formatNodeAndAncestors = function(node, prevNode) { 1265 var formatNodeAndAncestors = function(node, prevNode) {
1263 var buff = []; 1266 var buff = [];
1264 var outputContextFirst = localStorage['outputContextFirst'] == 'true'; 1267 var outputContextFirst = localStorage['outputContextFirst'] == 'true';
1265 if (outputContextFirst) 1268 if (outputContextFirst)
1266 this.ancestry_(node, prevNode, type, buff); 1269 this.ancestry_(node, prevNode, type, buff);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 * @param {EventType|Output.EventType} type 1382 * @param {EventType|Output.EventType} type
1380 * @param {!Array<Spannable>} buff 1383 * @param {!Array<Spannable>} buff
1381 * @private 1384 * @private
1382 */ 1385 */
1383 subNode_: function(range, prevRange, type, buff) { 1386 subNode_: function(range, prevRange, type, buff) {
1384 if (!prevRange) 1387 if (!prevRange)
1385 prevRange = range; 1388 prevRange = range;
1386 var dir = cursors.Range.getDirection(prevRange, range); 1389 var dir = cursors.Range.getDirection(prevRange, range);
1387 var node = range.start.node; 1390 var node = range.start.node;
1388 var prevNode = prevRange.getBound(dir).node; 1391 var prevNode = prevRange.getBound(dir).node;
1392 if (!node || !prevNode)
1393 return;
1394
1389 var options = {annotation: ['name'], isUnique: true}; 1395 var options = {annotation: ['name'], isUnique: true};
1390 var startIndex = range.start.index; 1396 var startIndex = range.start.index;
1391 var endIndex = range.end.index; 1397 var endIndex = range.end.index;
1392 if (this.formatOptions_.braille) { 1398 if (this.formatOptions_.braille) {
1393 options.annotation.push(new Output.NodeSpan(node)); 1399 options.annotation.push(new Output.NodeSpan(node));
1394 var selStart = node.textSelStart; 1400 var selStart = node.textSelStart;
1395 var selEnd = node.textSelEnd; 1401 var selEnd = node.textSelEnd;
1396 if (selStart !== undefined && 1402 if (selStart !== undefined &&
1397 (selEnd >= startIndex && selStart <= endIndex)) { 1403 (selEnd >= startIndex && selStart <= endIndex)) {
1398 options.annotation.push(new Output.SelectionSpan( 1404 options.annotation.push(new Output.SelectionSpan(
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 break; 1597 break;
1592 } 1598 }
1593 earconFinder = earconFinder.parent; 1599 earconFinder = earconFinder.parent;
1594 } 1600 }
1595 } 1601 }
1596 return null; 1602 return null;
1597 } 1603 }
1598 }; 1604 };
1599 1605
1600 }); // goog.scope 1606 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698