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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/common/focuser.js

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 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 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 Implements the setFocus function. 6 * @fileoverview Implements the setFocus function.
7 */ 7 */
8 8
9 goog.provide('cvox.Focuser'); 9 goog.provide('cvox.Focuser');
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // with .focus() which causes the page to be redrawn incorrectly if 66 // with .focus() which causes the page to be redrawn incorrectly if
67 // not in setTimeout. 67 // not in setTimeout.
68 if (cvox.ChromeVoxEventSuspender.areEventsSuspended()) { 68 if (cvox.ChromeVoxEventSuspender.areEventsSuspended()) {
69 if (cvox.Focuser.shouldEnterSuspendEvents_(targetNode)) { 69 if (cvox.Focuser.shouldEnterSuspendEvents_(targetNode)) {
70 cvox.ChromeVoxEventSuspender.enterSuspendEvents(); 70 cvox.ChromeVoxEventSuspender.enterSuspendEvents();
71 } 71 }
72 window.setTimeout(function() { 72 window.setTimeout(function() {
73 targetNode.focus(); 73 targetNode.focus();
74 cvox.ChromeVoxEventSuspender.exitSuspendEvents(); 74 cvox.ChromeVoxEventSuspender.exitSuspendEvents();
75 }, 0); 75 }, 0);
76 } 76 } else {
77 else {
78 window.setTimeout(function() { 77 window.setTimeout(function() {
79 targetNode.focus(); 78 targetNode.focus();
80 }, 0); 79 }, 0);
81 } 80 }
82 } 81 }
83 } else if (document.activeElement && 82 } else if (
84 document.activeElement.tagName != 'BODY') { 83 document.activeElement && document.activeElement.tagName != 'BODY') {
85 document.activeElement.blur(); 84 document.activeElement.blur();
86 } 85 }
87 86
88 // Restore the selection, unless the focused item is a text box. 87 // Restore the selection, unless the focused item is a text box.
89 if (cvox.DomUtil.isInputTypeText(targetNode)) { 88 if (cvox.DomUtil.isInputTypeText(targetNode)) {
90 targetNode.select(); 89 targetNode.select();
91 } else if (range) { 90 } else if (range) {
92 sel.removeAllRanges(); 91 sel.removeAllRanges();
93 sel.addRange(range); 92 sel.addRange(range);
94 } 93 }
95 }; 94 };
96 95
97 /** 96 /**
98 * Rules for whether or not enterSuspendEvents should be called. 97 * Rules for whether or not enterSuspendEvents should be called.
99 * In general, we should not enterSuspendEvents if the targetNode will get some 98 * In general, we should not enterSuspendEvents if the targetNode will get some
100 * special handlers attached when a focus event is received for it; otherwise, 99 * special handlers attached when a focus event is received for it; otherwise,
101 * the special handlers will not get attached. 100 * the special handlers will not get attached.
102 * 101 *
103 * @param {Node} targetNode The node that is being focused. 102 * @param {Node} targetNode The node that is being focused.
104 * @return {boolean} True if enterSuspendEvents should be called. 103 * @return {boolean} True if enterSuspendEvents should be called.
105 */ 104 */
106 cvox.Focuser.shouldEnterSuspendEvents_ = function(targetNode){ 105 cvox.Focuser.shouldEnterSuspendEvents_ = function(targetNode) {
107 if (targetNode.constructor && targetNode.constructor == HTMLVideoElement) { 106 if (targetNode.constructor && targetNode.constructor == HTMLVideoElement) {
108 return false; 107 return false;
109 } 108 }
110 if (targetNode.hasAttribute) { 109 if (targetNode.hasAttribute) {
111 switch (targetNode.getAttribute('type')) { 110 switch (targetNode.getAttribute('type')) {
112 case 'time': 111 case 'time':
113 case 'date': 112 case 'date':
114 case 'week': 113 case 'week':
115 case 'month': 114 case 'month':
116 return false; 115 return false;
117 } 116 }
118 } 117 }
119 return true; 118 return true;
120 }; 119 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698