Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js

Issue 2813743002: Switch to selected 8-dot braille table in email and url text fields (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 Processes events related to editing text and emits the 6 * @fileoverview Processes events related to editing text and emits the
7 * appropriate spoken and braille feedback. 7 * appropriate spoken and braille feedback.
8 */ 8 */
9 9
10 goog.provide('editing.TextEditHandler'); 10 goog.provide('editing.TextEditHandler');
(...skipping 20 matching lines...) Expand all
31 31
32 /** 32 /**
33 * A handler for automation events in a focused text field or editable root 33 * A handler for automation events in a focused text field or editable root
34 * such as a |contenteditable| subtree. 34 * such as a |contenteditable| subtree.
35 * @constructor 35 * @constructor
36 * @param {!AutomationNode} node 36 * @param {!AutomationNode} node
37 */ 37 */
38 editing.TextEditHandler = function(node) { 38 editing.TextEditHandler = function(node) {
39 /** @const {!AutomationNode} @private */ 39 /** @const {!AutomationNode} @private */
40 this.node_ = node; 40 this.node_ = node;
41
42 // Braille translation changes depending on the input type of |node|.
43 var originalBrailleTable = localStorage['brailleTable'];
44 var originalBrailleTableType = localStorage['brailleTableType'];
45
46 if (node.inputType == 'email' || node.inputType == 'url') {
47 localStorage['brailleTable'] = localStorage['brailleTable8'];
dmazzoni 2017/04/10 22:47:33 Maybe I'm not understanding what's happening here,
David Tseng 2017/04/11 17:38:39 I extracted all code in refresh that relies upon l
48 localStorage['brailleTableType'] = 'brailleTable8';
49 window['braille_translator_manager'].refresh();
dmazzoni 2017/04/10 22:47:33 Why is this hack needed here, is this for Closure?
David Tseng 2017/04/11 17:38:39 Not really a hack since it's exported on window. U
50
51 // Restore previous values for when this handler becomes invalidated or the
52 // next time ChromeVox refreshes (e.g. on startup).
53 localStorage['brailleTable'] = originalBrailleTable;
54 localStorage['brailleTableType'] = originalBrailleTableType;
55 }
41 }; 56 };
42 57
43 editing.TextEditHandler.prototype = { 58 editing.TextEditHandler.prototype = {
44 /** @return {!AutomationNode} */ 59 /** @return {!AutomationNode} */
45 get node() { 60 get node() {
46 return this.node_; 61 return this.node_;
47 }, 62 },
48 63
49 /** 64 /**
65 * Invalidates this handler. A caller must invalidate this handler for it to
66 * properly reset any intermediate actions it took on behalf of a user.
67 */
68 invalidate: function() {
69 window['braille_translator_manager'].refresh();
70 },
71
72 /**
50 * Receives the following kinds of events when the node provided to the 73 * Receives the following kinds of events when the node provided to the
51 * constructor is focuse: |focus|, |textChanged|, |textSelectionChanged| and 74 * constructor is focuse: |focus|, |textChanged|, |textSelectionChanged| and
52 * |valueChanged|. 75 * |valueChanged|.
53 * An implementation of this method should emit the appropritate braille and 76 * An implementation of this method should emit the appropritate braille and
54 * spoken feedback for the event. 77 * spoken feedback for the event.
55 * @param {!(AutomationEvent|CustomAutomationEvent)} evt 78 * @param {!(AutomationEvent|CustomAutomationEvent)} evt
56 */ 79 */
57 onEvent: goog.abstractMethod, 80 onEvent: goog.abstractMethod,
58 }; 81 };
59 82
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 testNode = testNode.parent; 236 testNode = testNode.parent;
214 } while (testNode); 237 } while (testNode);
215 238
216 if (rootFocusedEditable) 239 if (rootFocusedEditable)
217 return new TextFieldTextEditHandler(rootFocusedEditable); 240 return new TextFieldTextEditHandler(rootFocusedEditable);
218 241
219 return null; 242 return null;
220 }; 243 };
221 244
222 }); 245 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698