| OLD | NEW |
| 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 A class for walking tables. | 6 * @fileoverview A class for walking tables. |
| 7 * NOTE: This class has a very different interface than the other walkers. | 7 * NOTE: This class has a very different interface than the other walkers. |
| 8 * This means it does not lend itself easily to e.g. decorators. | 8 * This means it does not lend itself easily to e.g. decorators. |
| 9 * TODO (stoarca): This might be able to be fixed by breaking it up into | 9 * TODO (stoarca): This might be able to be fixed by breaking it up into |
| 10 * separate walkers for cell, row and column. | 10 * separate walkers for cell, row and column. |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 /** | 377 /** |
| 378 * Wrapper for going to somewhere so that boilerplate is not repeated. | 378 * Wrapper for going to somewhere so that boilerplate is not repeated. |
| 379 * @param {!cvox.CursorSelection} sel The selection from which to base the | 379 * @param {!cvox.CursorSelection} sel The selection from which to base the |
| 380 * movement. | 380 * movement. |
| 381 * @param {function(Array<number>):boolean} f The function to use for moving. | 381 * @param {function(Array<number>):boolean} f The function to use for moving. |
| 382 * Returns true on success and false on failure. | 382 * Returns true on success and false on failure. |
| 383 * @return {cvox.CursorSelection} The resulting selection. | 383 * @return {cvox.CursorSelection} The resulting selection. |
| 384 * @private | 384 * @private |
| 385 */ | 385 */ |
| 386 cvox.TableWalker.prototype.goTo_ = function(sel, f) { | 386 cvox.TableWalker.prototype.goTo_ = function(sel, f) { |
| 387 if (!sel.end.node) { |
| 388 return null; |
| 389 } |
| 387 this.tt.initialize(this.getTableNode_(sel)); | 390 this.tt.initialize(this.getTableNode_(sel)); |
| 388 var position = this.tt.findNearestCursor(sel.end.node); | 391 var position = this.tt.findNearestCursor(sel.end.node); |
| 389 if (!position) { | 392 if (!position) { |
| 390 return null; | 393 return null; |
| 391 } | 394 } |
| 392 this.tt.goToCell(position); | 395 this.tt.goToCell(position); |
| 393 if (!f(position)) { | 396 if (!f(position)) { |
| 394 return null; | 397 return null; |
| 395 } | 398 } |
| 396 return cvox.CursorSelection.fromNode(this.tt.getCell()). | 399 return cvox.CursorSelection.fromNode(this.tt.getCell()). |
| (...skipping 16 matching lines...) Expand all Loading... |
| 413 * @return {Array<number>} The position [x, y] of the selection. | 416 * @return {Array<number>} The position [x, y] of the selection. |
| 414 * @private | 417 * @private |
| 415 */ | 418 */ |
| 416 cvox.TableWalker.prototype.syncPosition_ = function(sel) { | 419 cvox.TableWalker.prototype.syncPosition_ = function(sel) { |
| 417 var tableNode = this.getTableNode_(sel); | 420 var tableNode = this.getTableNode_(sel); |
| 418 this.tt.initialize(tableNode); | 421 this.tt.initialize(tableNode); |
| 419 // we need to align the TraverseTable with our sel because our walker | 422 // we need to align the TraverseTable with our sel because our walker |
| 420 // uses parts of it (for example isSpanned relies on being at a specific cell) | 423 // uses parts of it (for example isSpanned relies on being at a specific cell) |
| 421 return this.tt.findNearestCursor(sel.end.node); | 424 return this.tt.findNearestCursor(sel.end.node); |
| 422 }; | 425 }; |
| OLD | NEW |