Chromium Code Reviews| 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 The entry point for all ChromeVox2 related code for the | 6 * @fileoverview The entry point for all ChromeVox2 related code for the |
| 7 * background page. | 7 * background page. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 goog.provide('Background'); | 10 goog.provide('Background'); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 var pred = null; | 137 var pred = null; |
| 138 switch (command) { | 138 switch (command) { |
| 139 case 'nextHeading': | 139 case 'nextHeading': |
| 140 dir = Dir.FORWARD; | 140 dir = Dir.FORWARD; |
| 141 pred = AutomationPredicate.heading; | 141 pred = AutomationPredicate.heading; |
| 142 break; | 142 break; |
| 143 case 'previousHeading': | 143 case 'previousHeading': |
| 144 dir = Dir.BACKWARD; | 144 dir = Dir.BACKWARD; |
| 145 pred = AutomationPredicate.heading; | 145 pred = AutomationPredicate.heading; |
| 146 break; | 146 break; |
| 147 case 'nextCharacter': | |
| 148 current = current.move(cursors.Unit.CHARACTER, Dir.FORWARD); | |
| 149 break; | |
| 150 case 'previousCharacter': | |
| 151 current = current.move(cursors.Unit.CHARACTER, Dir.BACKWARD); | |
| 152 break; | |
| 153 case 'nextWord': | |
| 154 current = current.move(cursors.Unit.WORD, Dir.FORWARD); | |
| 155 break; | |
| 156 case 'previousWord': | |
| 157 current = current.move(cursors.Unit.WORD, Dir.BACKWARD); | |
| 158 break; | |
| 147 case 'nextLine': | 159 case 'nextLine': |
| 148 current = current.move(cursors.Unit.LINE, Dir.FORWARD); | 160 current = current.move(cursors.Unit.LINE, Dir.FORWARD); |
| 149 break; | 161 break; |
| 150 case 'previousLine': | 162 case 'previousLine': |
| 151 current = current.move(cursors.Unit.LINE, Dir.BACKWARD); | 163 current = current.move(cursors.Unit.LINE, Dir.BACKWARD); |
| 152 break; | 164 break; |
| 153 case 'nextLink': | 165 case 'nextLink': |
| 154 dir = Dir.FORWARD; | 166 dir = Dir.FORWARD; |
| 155 pred = AutomationPredicate.link; | 167 pred = AutomationPredicate.link; |
| 156 break; | 168 break; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 var nodeLocations = []; | 323 var nodeLocations = []; |
| 312 while (cursor.getNode() != range.getEnd().getNode()) { | 324 while (cursor.getNode() != range.getEnd().getNode()) { |
| 313 output += getCursorDesc(cursor); | 325 output += getCursorDesc(cursor); |
| 314 nodeLocations.push(cursor.getNode().location); | 326 nodeLocations.push(cursor.getNode().location); |
| 315 cursor = cursor.move( | 327 cursor = cursor.move( |
| 316 cursors.Unit.NODE, cursors.Movement.DIRECTIONAL, Dir.FORWARD); | 328 cursors.Unit.NODE, cursors.Movement.DIRECTIONAL, Dir.FORWARD); |
| 317 } | 329 } |
| 318 output += getCursorDesc(range.getEnd()); | 330 output += getCursorDesc(range.getEnd()); |
| 319 nodeLocations.push(range.getEnd().getNode().location); | 331 nodeLocations.push(range.getEnd().getNode().location); |
| 320 | 332 |
| 333 // Read subnode ranges. | |
| 334 if (range.getStart().getNode() === range.getEnd().getNode()) { | |
|
dmazzoni
2014/10/27 07:06:20
Suppose I'm moving by words and I move from the la
| |
| 335 var startIndex = range.getStart().getIndex(); | |
| 336 var endIndex = range.getEnd().getIndex(); | |
| 337 if (startIndex > -1 && endIndex > -1) | |
| 338 output = range.getStart().getText().substring(startIndex, endIndex); | |
| 339 } | |
| 340 | |
| 321 cvox.ChromeVox.tts.speak(output, cvox.QueueMode.FLUSH); | 341 cvox.ChromeVox.tts.speak(output, cvox.QueueMode.FLUSH); |
| 322 cvox.ChromeVox.braille.write(cvox.NavBraille.fromText(output)); | 342 cvox.ChromeVox.braille.write(cvox.NavBraille.fromText(output)); |
| 323 chrome.accessibilityPrivate.setFocusRing(nodeLocations); | 343 chrome.accessibilityPrivate.setFocusRing(nodeLocations); |
| 324 } | 344 } |
| 325 }; | 345 }; |
| 326 | 346 |
| 327 /** @type {Background} */ | 347 /** @type {Background} */ |
| 328 global.backgroundObj = new Background(); | 348 global.backgroundObj = new Background(); |
| 329 | 349 |
| 330 }); // goog.scope | 350 }); // goog.scope |
| OLD | NEW |