| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 drop-down menu in the ChromeVox panel. | 6 * @fileoverview A drop-down menu in the ChromeVox panel. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('PanelMenu'); | 9 goog.provide('PanelMenu'); |
| 10 goog.provide('PanelNodeMenu'); | 10 goog.provide('PanelNodeMenu'); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 findMoreNodes_: function() { | 303 findMoreNodes_: function() { |
| 304 while (this.walker_.next().node) { | 304 while (this.walker_.next().node) { |
| 305 var node = this.walker_.node; | 305 var node = this.walker_.node; |
| 306 if (node == this.node_) | 306 if (node == this.node_) |
| 307 this.selectNext_ = true; | 307 this.selectNext_ = true; |
| 308 if (this.pred_(node)) { | 308 if (this.pred_(node)) { |
| 309 var output = new Output(); | 309 var output = new Output(); |
| 310 var range = cursors.Range.fromNode(node); | 310 var range = cursors.Range.fromNode(node); |
| 311 output.withSpeech(range, range, Output.EventType.NAVIGATE); | 311 output.withSpeech(range, range, Output.EventType.NAVIGATE); |
| 312 var label = output.toString(); | 312 var label = output.toString(); |
| 313 this.addMenuItem(label, '', '', function() { | 313 this.addMenuItem(label, '', '', (function() { |
| 314 chrome.extension.getBackgroundPage().ChromeVoxState | 314 var savedNode = node; |
| 315 .instance['navigateToRange'](cursors.Range.fromNode(node)); | 315 return function() { |
| 316 }); | 316 chrome.extension.getBackgroundPage().ChromeVoxState |
| 317 .instance['navigateToRange'](cursors.Range.fromNode(savedNode)); |
| 318 }; |
| 319 }())); |
| 320 |
| 317 if (this.selectNext_) { | 321 if (this.selectNext_) { |
| 318 this.activateItem(this.items_.length - 1); | 322 this.activateItem(this.items_.length - 1); |
| 319 this.selectNext_ = false; | 323 this.selectNext_ = false; |
| 320 } | 324 } |
| 321 } | 325 } |
| 322 | 326 |
| 323 if (this.async_) { | 327 if (this.async_) { |
| 324 this.nodeCount_++; | 328 this.nodeCount_++; |
| 325 if (this.nodeCount_ >= PanelNodeMenu.MAX_NODES_BEFORE_ASYNC) { | 329 if (this.nodeCount_ >= PanelNodeMenu.MAX_NODES_BEFORE_ASYNC) { |
| 326 this.nodeCount_ = 0; | 330 this.nodeCount_ = 0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 338 * @private | 342 * @private |
| 339 */ | 343 */ |
| 340 finish_: function() { | 344 finish_: function() { |
| 341 if (!this.items_.length) { | 345 if (!this.items_.length) { |
| 342 this.addMenuItem( | 346 this.addMenuItem( |
| 343 Msgs.getMsg('panel_menu_item_none'), '', '', function() {}); | 347 Msgs.getMsg('panel_menu_item_none'), '', '', function() {}); |
| 344 this.activateItem(0); | 348 this.activateItem(0); |
| 345 } | 349 } |
| 346 } | 350 } |
| 347 }; | 351 }; |
| OLD | NEW |