| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 cvox.TableWalker.prototype.getGranularityMsg = goog.abstractMethod; | 95 cvox.TableWalker.prototype.getGranularityMsg = goog.abstractMethod; |
| 96 | 96 |
| 97 | 97 |
| 98 /** Table Actions. */ | 98 /** Table Actions. */ |
| 99 | 99 |
| 100 | 100 |
| 101 /** | 101 /** |
| 102 * Returns the first cell of the table that this selection is inside. | 102 * Returns the first cell of the table that this selection is inside. |
| 103 * @param {!cvox.CursorSelection} sel The selection. | 103 * @param {!cvox.CursorSelection} sel The selection. |
| 104 * @return {cvox.CursorSelection} The selection for first cell of the table. | 104 * @return {cvox.CursorSelection} The selection for first cell of the table. |
| 105 * @expose | 105 * @export |
| 106 */ | 106 */ |
| 107 cvox.TableWalker.prototype.goToFirstCell = function(sel) { | 107 cvox.TableWalker.prototype.goToFirstCell = function(sel) { |
| 108 return this.goTo_(sel, goog.bind(function(position) { | 108 return this.goTo_(sel, goog.bind(function(position) { |
| 109 return this.tt.goToCell([0, 0]); | 109 return this.tt.goToCell([0, 0]); |
| 110 }, this)); | 110 }, this)); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * Returns the last cell of the table that this selection is inside. | 114 * Returns the last cell of the table that this selection is inside. |
| 115 * @param {!cvox.CursorSelection} sel The selection. | 115 * @param {!cvox.CursorSelection} sel The selection. |
| 116 * @return {cvox.CursorSelection} The selection for the last cell of the table. | 116 * @return {cvox.CursorSelection} The selection for the last cell of the table. |
| 117 * @expose | 117 * @export |
| 118 */ | 118 */ |
| 119 cvox.TableWalker.prototype.goToLastCell = function(sel) { | 119 cvox.TableWalker.prototype.goToLastCell = function(sel) { |
| 120 return this.goTo_(sel, goog.bind(function(position) { | 120 return this.goTo_(sel, goog.bind(function(position) { |
| 121 return this.tt.goToLastCell(); | 121 return this.tt.goToLastCell(); |
| 122 }, this)); | 122 }, this)); |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 /** | 125 /** |
| 126 * Returns the first cell of the row that the selection is in. | 126 * Returns the first cell of the row that the selection is in. |
| 127 * @param {!cvox.CursorSelection} sel The selection. | 127 * @param {!cvox.CursorSelection} sel The selection. |
| 128 * @return {cvox.CursorSelection} The selection for the first cell in the row. | 128 * @return {cvox.CursorSelection} The selection for the first cell in the row. |
| 129 * @expose | 129 * @export |
| 130 */ | 130 */ |
| 131 cvox.TableWalker.prototype.goToRowFirstCell = function(sel) { | 131 cvox.TableWalker.prototype.goToRowFirstCell = function(sel) { |
| 132 return this.goTo_(sel, goog.bind(function(position) { | 132 return this.goTo_(sel, goog.bind(function(position) { |
| 133 return this.tt.goToCell([position[0], 0]); | 133 return this.tt.goToCell([position[0], 0]); |
| 134 }, this)); | 134 }, this)); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 /** | 137 /** |
| 138 * Returns the last cell of the row that the selection is in. | 138 * Returns the last cell of the row that the selection is in. |
| 139 * @param {!cvox.CursorSelection} sel The selection. | 139 * @param {!cvox.CursorSelection} sel The selection. |
| 140 * @return {cvox.CursorSelection} The selection for the last cell in the row. | 140 * @return {cvox.CursorSelection} The selection for the last cell in the row. |
| 141 * @expose | 141 * @export |
| 142 */ | 142 */ |
| 143 cvox.TableWalker.prototype.goToRowLastCell = function(sel) { | 143 cvox.TableWalker.prototype.goToRowLastCell = function(sel) { |
| 144 return this.goTo_(sel, goog.bind(function(position) { | 144 return this.goTo_(sel, goog.bind(function(position) { |
| 145 return this.tt.goToRowLastCell(); | 145 return this.tt.goToRowLastCell(); |
| 146 }, this)); | 146 }, this)); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * Returns the first cell of the column that the selection is in. | 150 * Returns the first cell of the column that the selection is in. |
| 151 * @param {!cvox.CursorSelection} sel The selection. | 151 * @param {!cvox.CursorSelection} sel The selection. |
| 152 * @return {cvox.CursorSelection} The selection for the first cell in the col. | 152 * @return {cvox.CursorSelection} The selection for the first cell in the col. |
| 153 * @expose | 153 * @export |
| 154 */ | 154 */ |
| 155 cvox.TableWalker.prototype.goToColFirstCell = function(sel) { | 155 cvox.TableWalker.prototype.goToColFirstCell = function(sel) { |
| 156 return this.goTo_(sel, goog.bind(function(position) { | 156 return this.goTo_(sel, goog.bind(function(position) { |
| 157 return this.tt.goToCell([0, position[1]]); | 157 return this.tt.goToCell([0, position[1]]); |
| 158 }, this)); | 158 }, this)); |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 /** | 161 /** |
| 162 * Returns the last cell of the column that the selection is in. | 162 * Returns the last cell of the column that the selection is in. |
| 163 * @param {!cvox.CursorSelection} sel The selection. | 163 * @param {!cvox.CursorSelection} sel The selection. |
| 164 * @return {cvox.CursorSelection} The selection for the last cell in the col. | 164 * @return {cvox.CursorSelection} The selection for the last cell in the col. |
| 165 * @expose | 165 * @export |
| 166 */ | 166 */ |
| 167 cvox.TableWalker.prototype.goToColLastCell = function(sel) { | 167 cvox.TableWalker.prototype.goToColLastCell = function(sel) { |
| 168 return this.goTo_(sel, goog.bind(function(position) { | 168 return this.goTo_(sel, goog.bind(function(position) { |
| 169 return this.tt.goToColLastCell(); | 169 return this.tt.goToColLastCell(); |
| 170 }, this)); | 170 }, this)); |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * Returns the first cell in the row after the current selection. | 174 * Returns the first cell in the row after the current selection. |
| 175 * @param {!cvox.CursorSelection} sel The selection. | 175 * @param {!cvox.CursorSelection} sel The selection. |
| 176 * @return {cvox.CursorSelection} The selection for the first cell in the next | 176 * @return {cvox.CursorSelection} The selection for the first cell in the next |
| 177 * row. | 177 * row. |
| 178 * @expose | 178 * @export |
| 179 */ | 179 */ |
| 180 cvox.TableWalker.prototype.nextRow = function(sel) { | 180 cvox.TableWalker.prototype.nextRow = function(sel) { |
| 181 return this.goTo_(sel, goog.bind(function(position) { | 181 return this.goTo_(sel, goog.bind(function(position) { |
| 182 return this.tt.goToCell([position[0] + (sel.isReversed() ? -1 : 1), | 182 return this.tt.goToCell([position[0] + (sel.isReversed() ? -1 : 1), |
| 183 position[1]]); | 183 position[1]]); |
| 184 }, this)); | 184 }, this)); |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 /** | 187 /** |
| 188 * Returns the first cell in the column after the current selection. | 188 * Returns the first cell in the column after the current selection. |
| 189 * @param {!cvox.CursorSelection} sel The selection. | 189 * @param {!cvox.CursorSelection} sel The selection. |
| 190 * @return {cvox.CursorSelection} The selection for the first cell in the | 190 * @return {cvox.CursorSelection} The selection for the first cell in the |
| 191 * next col. | 191 * next col. |
| 192 * @expose | 192 * @export |
| 193 */ | 193 */ |
| 194 cvox.TableWalker.prototype.nextCol = function(sel) { | 194 cvox.TableWalker.prototype.nextCol = function(sel) { |
| 195 return this.goTo_(sel, goog.bind(function(position) { | 195 return this.goTo_(sel, goog.bind(function(position) { |
| 196 return this.tt.goToCell([position[0], | 196 return this.tt.goToCell([position[0], |
| 197 position[1] + (sel.isReversed() ? -1 : 1)]); | 197 position[1] + (sel.isReversed() ? -1 : 1)]); |
| 198 }, this)); | 198 }, this)); |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 /** | 201 /** |
| 202 * @param {!cvox.CursorSelection} sel The current selection. | 202 * @param {!cvox.CursorSelection} sel The current selection. |
| 203 * @return {cvox.CursorSelection} The resulting selection. | 203 * @return {cvox.CursorSelection} The resulting selection. |
| 204 * @expose | 204 * @export |
| 205 */ | 205 */ |
| 206 cvox.TableWalker.prototype.announceHeaders = function(sel) { | 206 cvox.TableWalker.prototype.announceHeaders = function(sel) { |
| 207 cvox.ChromeVox.tts.speak(this.getHeaderText_(sel), | 207 cvox.ChromeVox.tts.speak(this.getHeaderText_(sel), |
| 208 cvox.QueueMode.FLUSH, | 208 cvox.QueueMode.FLUSH, |
| 209 cvox.AbstractTts.PERSONALITY_ANNOTATION); | 209 cvox.AbstractTts.PERSONALITY_ANNOTATION); |
| 210 return sel; | 210 return sel; |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 /** | 213 /** |
| 214 * @param {!cvox.CursorSelection} sel The current selection. | 214 * @param {!cvox.CursorSelection} sel The current selection. |
| 215 * @return {cvox.CursorSelection} The resulting selection. | 215 * @return {cvox.CursorSelection} The resulting selection. |
| 216 * @expose | 216 * @export |
| 217 */ | 217 */ |
| 218 cvox.TableWalker.prototype.speakTableLocation = function(sel) { | 218 cvox.TableWalker.prototype.speakTableLocation = function(sel) { |
| 219 cvox.ChromeVox.navigationManager.speakDescriptionArray( | 219 cvox.ChromeVox.navigationManager.speakDescriptionArray( |
| 220 this.getLocationDescription_(sel), | 220 this.getLocationDescription_(sel), |
| 221 cvox.QueueMode.FLUSH, | 221 cvox.QueueMode.FLUSH, |
| 222 null); | 222 null); |
| 223 return sel; | 223 return sel; |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 | 226 |
| 227 /** | 227 /** |
| 228 * @param {!cvox.CursorSelection} sel The current selection. | 228 * @param {!cvox.CursorSelection} sel The current selection. |
| 229 * @return {cvox.CursorSelection} The resulting selection. | 229 * @return {cvox.CursorSelection} The resulting selection. |
| 230 * @expose | 230 * @export |
| 231 */ | 231 */ |
| 232 cvox.TableWalker.prototype.exitShifterContent = function(sel) { | 232 cvox.TableWalker.prototype.exitShifterContent = function(sel) { |
| 233 var tableNode = this.getTableNode_(sel); | 233 var tableNode = this.getTableNode_(sel); |
| 234 if (!tableNode) { | 234 if (!tableNode) { |
| 235 return null; | 235 return null; |
| 236 } | 236 } |
| 237 var nextNode = cvox.DomUtil.directedNextLeafNode(tableNode, false); | 237 var nextNode = cvox.DomUtil.directedNextLeafNode(tableNode, false); |
| 238 return cvox.CursorSelection.fromNode(nextNode); | 238 return cvox.CursorSelection.fromNode(nextNode); |
| 239 }; | 239 }; |
| 240 | 240 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 * @return {Array<number>} The position [x, y] of the selection. | 413 * @return {Array<number>} The position [x, y] of the selection. |
| 414 * @private | 414 * @private |
| 415 */ | 415 */ |
| 416 cvox.TableWalker.prototype.syncPosition_ = function(sel) { | 416 cvox.TableWalker.prototype.syncPosition_ = function(sel) { |
| 417 var tableNode = this.getTableNode_(sel); | 417 var tableNode = this.getTableNode_(sel); |
| 418 this.tt.initialize(tableNode); | 418 this.tt.initialize(tableNode); |
| 419 // we need to align the TraverseTable with our sel because our walker | 419 // 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) | 420 // uses parts of it (for example isSpanned relies on being at a specific cell) |
| 421 return this.tt.findNearestCursor(sel.end.node); | 421 return this.tt.findNearestCursor(sel.end.node); |
| 422 }; | 422 }; |
| OLD | NEW |