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

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: Created 4 years, 7 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 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 }, 1231 },
1232 1232
1233 /** 1233 /**
1234 * @param {!cursors.Range} range 1234 * @param {!cursors.Range} range
1235 * @param {cursors.Range} prevRange 1235 * @param {cursors.Range} prevRange
1236 * @param {EventType|Output.EventType} type 1236 * @param {EventType|Output.EventType} type
1237 * @param {!Array<Spannable>} rangeBuff 1237 * @param {!Array<Spannable>} rangeBuff
1238 * @private 1238 * @private
1239 */ 1239 */
1240 range_: function(range, prevRange, type, rangeBuff) { 1240 range_: function(range, prevRange, type, rangeBuff) {
1241 if (!range.start.node || !range.end.node)
1242 return;
1243
1241 if (!prevRange) 1244 if (!prevRange)
1242 prevRange = cursors.Range.fromNode(range.start.node.root); 1245 prevRange = cursors.Range.fromNode(range.start.node.root);
1243 var cursor = cursors.Cursor.fromNode(range.start.node); 1246 var cursor = cursors.Cursor.fromNode(range.start.node);
1244 var prevNode = prevRange.start.node; 1247 var prevNode = prevRange.start.node;
1245 1248
1246 var formatNodeAndAncestors = function(node, prevNode) { 1249 var formatNodeAndAncestors = function(node, prevNode) {
1247 var buff = []; 1250 var buff = [];
1248 var outputContextFirst = localStorage['outputContextFirst'] == 'true'; 1251 var outputContextFirst = localStorage['outputContextFirst'] == 'true';
1249 if (outputContextFirst) 1252 if (outputContextFirst)
1250 this.ancestry_(node, prevNode, type, buff); 1253 this.ancestry_(node, prevNode, type, buff);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 * @param {EventType|Output.EventType} type 1366 * @param {EventType|Output.EventType} type
1364 * @param {!Array<Spannable>} buff 1367 * @param {!Array<Spannable>} buff
1365 * @private 1368 * @private
1366 */ 1369 */
1367 subNode_: function(range, prevRange, type, buff) { 1370 subNode_: function(range, prevRange, type, buff) {
1368 if (!prevRange) 1371 if (!prevRange)
1369 prevRange = range; 1372 prevRange = range;
1370 var dir = cursors.Range.getDirection(prevRange, range); 1373 var dir = cursors.Range.getDirection(prevRange, range);
1371 var node = range.start.node; 1374 var node = range.start.node;
1372 var prevNode = prevRange.getBound(dir).node; 1375 var prevNode = prevRange.getBound(dir).node;
1376 if (!node || !prevNode)
1377 return;
1378
1373 var options = {annotation: ['name'], isUnique: true}; 1379 var options = {annotation: ['name'], isUnique: true};
1374 var startIndex = range.start.index; 1380 var startIndex = range.start.index;
1375 var endIndex = range.end.index; 1381 var endIndex = range.end.index;
1376 if (this.formatOptions_.braille) { 1382 if (this.formatOptions_.braille) {
1377 options.annotation.push(new Output.NodeSpan(node)); 1383 options.annotation.push(new Output.NodeSpan(node));
1378 var selStart = node.textSelStart; 1384 var selStart = node.textSelStart;
1379 var selEnd = node.textSelEnd; 1385 var selEnd = node.textSelEnd;
1380 if (selStart !== undefined && 1386 if (selStart !== undefined &&
1381 (selEnd >= startIndex && selStart <= endIndex)) { 1387 (selEnd >= startIndex && selStart <= endIndex)) {
1382 options.annotation.push(new Output.SelectionSpan( 1388 options.annotation.push(new Output.SelectionSpan(
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 break; 1581 break;
1576 } 1582 }
1577 earconFinder = earconFinder.parent; 1583 earconFinder = earconFinder.parent;
1578 } 1584 }
1579 } 1585 }
1580 return null; 1586 return null;
1581 } 1587 }
1582 }; 1588 };
1583 1589
1584 }); // goog.scope 1590 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698