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

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

Issue 13375003: Fixing iframe jank in the local omnibox popup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comments. Created 7 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 | Annotate | Revision Log
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 <include src="assert.js"></include>
Dan Beam 2013/04/09 03:56:05 nit: and here, too (no </include>)
Jered 2013/04/09 21:59:38 Done.
6
5 /** 7 /**
6 * The global object. 8 * The global object.
7 * @type {!Object} 9 * @type {!Object}
8 * @const 10 * @const
9 */ 11 */
10 var global = this; 12 var global = this;
11 13
12 /** 14 /**
13 * Alias for document.getElementById. 15 * Alias for document.getElementById.
14 * @param {string} id The ID of the element to find. 16 * @param {string} id The ID of the element to find.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 193
192 /** 194 /**
193 * Check the directionality of the page. 195 * Check the directionality of the page.
194 * @return {boolean} True if Chrome is running an RTL UI. 196 * @return {boolean} True if Chrome is running an RTL UI.
195 */ 197 */
196 function isRTL() { 198 function isRTL() {
197 return document.documentElement.dir == 'rtl'; 199 return document.documentElement.dir == 'rtl';
198 } 200 }
199 201
200 /** 202 /**
201 * Simple common assertion API
202 * @param {*} condition The condition to test. Note that this may be used to
203 * test whether a value is defined or not, and we don't want to force a
204 * cast to Boolean.
205 * @param {string=} opt_message A message to use in any error.
206 */
207 function assert(condition, opt_message) {
208 'use strict';
209 if (!condition) {
210 var msg = 'Assertion failed';
211 if (opt_message)
212 msg = msg + ': ' + opt_message;
213 throw new Error(msg);
214 }
215 }
216
217 /**
218 * Get an element that's known to exist by its ID. We use this instead of just 203 * Get an element that's known to exist by its ID. We use this instead of just
219 * calling getElementById and not checking the result because this lets us 204 * calling getElementById and not checking the result because this lets us
220 * satisfy the JSCompiler type system. 205 * satisfy the JSCompiler type system.
221 * @param {string} id The identifier name. 206 * @param {string} id The identifier name.
222 * @return {!Element} the Element. 207 * @return {!Element} the Element.
223 */ 208 */
224 function getRequiredElement(id) { 209 function getRequiredElement(id) {
225 var element = $(id); 210 var element = $(id);
226 assert(element, 'Missing required element: ' + id); 211 assert(element, 'Missing required element: ' + id);
227 return element; 212 return element;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 * Creates an element of a specified type with a specified class name. 297 * Creates an element of a specified type with a specified class name.
313 * @param {string} type The node type. 298 * @param {string} type The node type.
314 * @param {string} className The class name to use. 299 * @param {string} className The class name to use.
315 * @return {Element} The created element. 300 * @return {Element} The created element.
316 */ 301 */
317 function createElementWithClassName(type, className) { 302 function createElementWithClassName(type, className) {
318 var elm = document.createElement(type); 303 var elm = document.createElement(type);
319 elm.className = className; 304 elm.className = className;
320 return elm; 305 return elm;
321 } 306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698