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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 /** @type {cursors.Range} */ | 142 /** @type {cursors.Range} */ |
143 get currentRange() { | 143 get currentRange() { |
144 return this.currentRange_; | 144 return this.currentRange_; |
145 }, | 145 }, |
146 | 146 |
147 set currentRange(value) { | 147 set currentRange(value) { |
148 if (!value) | 148 if (!value) |
149 return; | 149 return; |
150 | 150 |
151 this.currentRange_ = value; | 151 this.currentRange_ = value; |
| 152 |
| 153 if (this.currentRange_) |
| 154 this.currentRange_.start.node.makeVisible(); |
152 }, | 155 }, |
153 | 156 |
154 /** | 157 /** |
155 * Handles ChromeVox Next commands. | 158 * Handles ChromeVox Next commands. |
156 * @param {string} command | 159 * @param {string} command |
157 * @param {boolean=} opt_bypassModeCheck Always tries to execute the command | 160 * @param {boolean=} opt_bypassModeCheck Always tries to execute the command |
158 * regardless of mode. | 161 * regardless of mode. |
159 * @return {boolean} True if the command should propagate. | 162 * @return {boolean} True if the command should propagate. |
160 */ | 163 */ |
161 onGotCommand: function(command, opt_bypassModeCheck) { | 164 onGotCommand: function(command, opt_bypassModeCheck) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 global.isReadingContinuously = true; | 322 global.isReadingContinuously = true; |
320 var continueReading = function(prevRange) { | 323 var continueReading = function(prevRange) { |
321 if (!global.isReadingContinuously || !this.currentRange_) | 324 if (!global.isReadingContinuously || !this.currentRange_) |
322 return; | 325 return; |
323 | 326 |
324 new Output().withSpeechAndBraille( | 327 new Output().withSpeechAndBraille( |
325 this.currentRange_, prevRange, Output.EventType.NAVIGATE) | 328 this.currentRange_, prevRange, Output.EventType.NAVIGATE) |
326 .onSpeechEnd(function() { continueReading(prevRange); }) | 329 .onSpeechEnd(function() { continueReading(prevRange); }) |
327 .go(); | 330 .go(); |
328 prevRange = this.currentRange_; | 331 prevRange = this.currentRange_; |
329 this.currentRange_ = | 332 this.currentRange = |
330 this.currentRange_.move(cursors.Unit.NODE, Dir.FORWARD); | 333 this.currentRange.move(cursors.Unit.NODE, Dir.FORWARD); |
331 | 334 |
332 if (!this.currentRange_ || this.currentRange_.equals(prevRange)) | 335 if (!this.currentRange_ || this.currentRange_.equals(prevRange)) |
333 global.isReadingContinuously = false; | 336 global.isReadingContinuously = false; |
334 }.bind(this); | 337 }.bind(this); |
335 | 338 |
336 continueReading(null); | 339 continueReading(null); |
337 return false; | 340 return false; |
338 case 'showContextMenu': | 341 case 'showContextMenu': |
339 if (this.currentRange_) { | 342 if (this.currentRange_) { |
340 var actionNode = this.currentRange_.start.node; | 343 var actionNode = this.currentRange_.start.node; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 } | 399 } |
397 | 400 |
398 if (current) { | 401 if (current) { |
399 // TODO(dtseng): Figure out what it means to focus a range. | 402 // TODO(dtseng): Figure out what it means to focus a range. |
400 var actionNode = current.start.node; | 403 var actionNode = current.start.node; |
401 if (actionNode.role == RoleType.inlineTextBox) | 404 if (actionNode.role == RoleType.inlineTextBox) |
402 actionNode = actionNode.parent; | 405 actionNode = actionNode.parent; |
403 actionNode.focus(); | 406 actionNode.focus(); |
404 | 407 |
405 var prevRange = this.currentRange_; | 408 var prevRange = this.currentRange_; |
406 this.currentRange_ = current; | 409 this.currentRange = current; |
407 | 410 |
408 new Output().withSpeechAndBraille( | 411 new Output().withSpeechAndBraille( |
409 this.currentRange_, prevRange, Output.EventType.NAVIGATE) | 412 this.currentRange_, prevRange, Output.EventType.NAVIGATE) |
410 .go(); | 413 .go(); |
411 } | 414 } |
412 | 415 |
413 return false; | 416 return false; |
414 }, | 417 }, |
415 | 418 |
416 /** | 419 /** |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 689 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
687 .replace(/\*/g, '.*') | 690 .replace(/\*/g, '.*') |
688 .replace(/\?/g, '.'); | 691 .replace(/\?/g, '.'); |
689 }).join('|') + ')$'); | 692 }).join('|') + ')$'); |
690 }; | 693 }; |
691 | 694 |
692 /** @type {Background} */ | 695 /** @type {Background} */ |
693 global.backgroundObj = new Background(); | 696 global.backgroundObj = new Background(); |
694 | 697 |
695 }); // goog.scope | 698 }); // goog.scope |
OLD | NEW |