| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 if (node) | 175 if (node) |
| 176 current = cursors.Range.fromNode(node); | 176 current = cursors.Range.fromNode(node); |
| 177 break; | 177 break; |
| 178 case 'doDefault': | 178 case 'doDefault': |
| 179 if (this.currentRange_) | 179 if (this.currentRange_) |
| 180 this.currentRange_.getStart().getNode().doDefault(); | 180 this.currentRange_.getStart().getNode().doDefault(); |
| 181 break; | 181 break; |
| 182 case 'continuousRead': | 182 case 'continuousRead': |
| 183 global.isReadingContinuously = true; | 183 global.isReadingContinuously = true; |
| 184 var continueReading = function(prevRange) { | 184 var continueReading = function(prevRange) { |
| 185 if (!global.isReadingContinuously) | 185 if (!global.isReadingContinuously || !this.currentRange_) |
| 186 return; | 186 return; |
| 187 | 187 |
| 188 new Output().withSpeechAndBraille( | 188 new Output().withSpeechAndBraille( |
| 189 this.currentRange_, prevRange, Output.EventType.NAVIGATE) | 189 this.currentRange_, prevRange, Output.EventType.NAVIGATE) |
| 190 .onSpeechEnd(function() { continueReading(prevRange); }) | 190 .onSpeechEnd(function() { continueReading(prevRange); }) |
| 191 .go(); | 191 .go(); |
| 192 prevRange = this.currentRange_; | 192 prevRange = this.currentRange_; |
| 193 this.currentRange_ = | 193 this.currentRange_ = |
| 194 this.currentRange_.move(cursors.Unit.NODE, Dir.FORWARD); | 194 this.currentRange_.move(cursors.Unit.NODE, Dir.FORWARD); |
| 195 | 195 |
| 196 if (this.currentRange_.equals(prevRange)) | 196 if (!this.currentRange_ || this.currentRange_.equals(prevRange)) |
| 197 global.isReadingContinuously = false; | 197 global.isReadingContinuously = false; |
| 198 }.bind(this); | 198 }.bind(this); |
| 199 | 199 |
| 200 continueReading(null); | 200 continueReading(null); |
| 201 return; | 201 return; |
| 202 } | 202 } |
| 203 | 203 |
| 204 if (pred) { | 204 if (pred) { |
| 205 var node = AutomationUtil.findNextNode( | 205 var node = AutomationUtil.findNextNode( |
| 206 current.getBound(dir).getNode(), dir, pred); | 206 current.getBound(dir).getNode(), dir, pred); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 }.bind(this)); | 435 }.bind(this)); |
| 436 } | 436 } |
| 437 }.bind(this)); | 437 }.bind(this)); |
| 438 } | 438 } |
| 439 }; | 439 }; |
| 440 | 440 |
| 441 /** @type {Background} */ | 441 /** @type {Background} */ |
| 442 global.backgroundObj = new Background(); | 442 global.backgroundObj = new Background(); |
| 443 | 443 |
| 444 }); // goog.scope | 444 }); // goog.scope |
| OLD | NEW |