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

Side by Side Diff: ui/webui/resources/js/cr.js

Issue 2603443002: Clang format JS: Disallow single line functions, conditionals, loops, and switch statements (Closed)
Patch Set: more options Created 4 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * The global object. 6 * The global object.
7 * @type {!Object} 7 * @type {!Object}
8 * @const 8 * @const
9 */ 9 */
10 var global = this; 10 var global = this;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 * Helper function for defineProperty that returns the getter to use for the 102 * Helper function for defineProperty that returns the getter to use for the
103 * property. 103 * property.
104 * @param {string} name The name of the property. 104 * @param {string} name The name of the property.
105 * @param {PropertyKind} kind The kind of the property. 105 * @param {PropertyKind} kind The kind of the property.
106 * @return {function():*} The getter for the property. 106 * @return {function():*} The getter for the property.
107 */ 107 */
108 function getGetter(name, kind) { 108 function getGetter(name, kind) {
109 switch (kind) { 109 switch (kind) {
110 case PropertyKind.JS: 110 case PropertyKind.JS:
111 var privateName = name + '_'; 111 var privateName = name + '_';
112 return function() { return this[privateName]; }; 112 return function() {
113 return this[privateName];
114 };
113 case PropertyKind.ATTR: 115 case PropertyKind.ATTR:
114 var attributeName = getAttributeName(name); 116 var attributeName = getAttributeName(name);
115 return function() { return this.getAttribute(attributeName); }; 117 return function() {
118 return this.getAttribute(attributeName);
119 };
116 case PropertyKind.BOOL_ATTR: 120 case PropertyKind.BOOL_ATTR:
117 var attributeName = getAttributeName(name); 121 var attributeName = getAttributeName(name);
118 return function() { return this.hasAttribute(attributeName); }; 122 return function() {
123 return this.hasAttribute(attributeName);
124 };
119 } 125 }
120 126
121 // TODO(dbeam): replace with assertNotReached() in assert.js when I can coax 127 // TODO(dbeam): replace with assertNotReached() in assert.js when I can coax
122 // the browser/unit tests to preprocess this file through grit. 128 // the browser/unit tests to preprocess this file through grit.
123 throw 'not reached'; 129 throw 'not reached';
124 } 130 }
125 131
126 /** 132 /**
127 * Helper function for defineProperty that returns the setter of the right 133 * Helper function for defineProperty that returns the setter of the right
128 * kind. 134 * kind.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 213 }
208 214
209 /** 215 /**
210 * Counter for use with createUid 216 * Counter for use with createUid
211 */ 217 */
212 var uidCounter = 1; 218 var uidCounter = 1;
213 219
214 /** 220 /**
215 * @return {number} A new unique ID. 221 * @return {number} A new unique ID.
216 */ 222 */
217 function createUid() { return uidCounter++; } 223 function createUid() {
224 return uidCounter++;
225 }
218 226
219 /** 227 /**
220 * Returns a unique ID for the item. This mutates the item so it needs to be 228 * Returns a unique ID for the item. This mutates the item so it needs to be
221 * an object 229 * an object
222 * @param {!Object} item The item to get the unique ID for. 230 * @param {!Object} item The item to get the unique ID for.
223 * @return {number} The unique ID for the item. 231 * @return {number} The unique ID for the item.
224 */ 232 */
225 function getUid(item) { 233 function getUid(item) {
226 if (item.hasOwnProperty('uid')) 234 if (item.hasOwnProperty('uid'))
227 return item.uid; 235 return item.uid;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 makePublic: makePublic, 441 makePublic: makePublic,
434 PropertyKind: PropertyKind, 442 PropertyKind: PropertyKind,
435 443
436 // C++ <-> JS communication related methods. 444 // C++ <-> JS communication related methods.
437 addWebUIListener: addWebUIListener, 445 addWebUIListener: addWebUIListener,
438 removeWebUIListener: removeWebUIListener, 446 removeWebUIListener: removeWebUIListener,
439 sendWithPromise: sendWithPromise, 447 sendWithPromise: sendWithPromise,
440 webUIListenerCallback: webUIListenerCallback, 448 webUIListenerCallback: webUIListenerCallback,
441 webUIResponse: webUIResponse, 449 webUIResponse: webUIResponse,
442 450
443 get doc() { return document; }, 451 get doc() {
452 return document;
453 },
444 454
445 /** Whether we are using a Mac or not. */ 455 /** Whether we are using a Mac or not. */
446 get isMac() { return /Mac/.test(navigator.platform); }, 456 get isMac() {
457 return /Mac/.test(navigator.platform);
458 },
447 459
448 /** Whether this is on the Windows platform or not. */ 460 /** Whether this is on the Windows platform or not. */
449 get isWindows() { return /Win/.test(navigator.platform); }, 461 get isWindows() {
462 return /Win/.test(navigator.platform);
463 },
450 464
451 /** Whether this is on chromeOS or not. */ 465 /** Whether this is on chromeOS or not. */
452 get isChromeOS() { return /CrOS/.test(navigator.userAgent); }, 466 get isChromeOS() {
467 return /CrOS/.test(navigator.userAgent);
468 },
453 469
454 /** Whether this is on vanilla Linux (not chromeOS). */ 470 /** Whether this is on vanilla Linux (not chromeOS). */
455 get isLinux() { return /Linux/.test(navigator.userAgent); }, 471 get isLinux() {
472 return /Linux/.test(navigator.userAgent);
473 },
456 474
457 /** Whether this is on Android. */ 475 /** Whether this is on Android. */
458 get isAndroid() { return /Android/.test(navigator.userAgent); }, 476 get isAndroid() {
477 return /Android/.test(navigator.userAgent);
478 },
459 479
460 /** Whether this is on iOS. */ 480 /** Whether this is on iOS. */
461 get isIOS() { return /iPad|iPhone|iPod/.test(navigator.platform); } 481 get isIOS() {
482 return /iPad|iPhone|iPod/.test(navigator.platform);
483 }
462 }; 484 };
463 }(); 485 }();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698