browser/devtools/tilt/tilt-utils.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6 "use strict";
michael@0 7
michael@0 8 const {Cc, Ci, Cu} = require("chrome");
michael@0 9
michael@0 10 Cu.import("resource://gre/modules/Services.jsm");
michael@0 11 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0 12 Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
michael@0 13
michael@0 14 const STACK_THICKNESS = 15;
michael@0 15
michael@0 16 /**
michael@0 17 * Module containing various helper functions used throughout Tilt.
michael@0 18 */
michael@0 19 this.TiltUtils = {};
michael@0 20 module.exports = this.TiltUtils;
michael@0 21
michael@0 22 /**
michael@0 23 * Various console/prompt output functions required by the engine.
michael@0 24 */
michael@0 25 TiltUtils.Output = {
michael@0 26
michael@0 27 /**
michael@0 28 * Logs a message to the console.
michael@0 29 *
michael@0 30 * @param {String} aMessage
michael@0 31 * the message to be logged
michael@0 32 */
michael@0 33 log: function TUO_log(aMessage)
michael@0 34 {
michael@0 35 if (this.suppressLogs) {
michael@0 36 return;
michael@0 37 }
michael@0 38 // get the console service
michael@0 39 let consoleService = Cc["@mozilla.org/consoleservice;1"]
michael@0 40 .getService(Ci.nsIConsoleService);
michael@0 41
michael@0 42 // log the message
michael@0 43 consoleService.logStringMessage(aMessage);
michael@0 44 },
michael@0 45
michael@0 46 /**
michael@0 47 * Logs an error to the console.
michael@0 48 *
michael@0 49 * @param {String} aMessage
michael@0 50 * the message to be logged
michael@0 51 * @param {Object} aProperties
michael@0 52 * and object containing script error initialization details
michael@0 53 */
michael@0 54 error: function TUO_error(aMessage, aProperties)
michael@0 55 {
michael@0 56 if (this.suppressErrors) {
michael@0 57 return;
michael@0 58 }
michael@0 59 // make sure the properties parameter is a valid object
michael@0 60 aProperties = aProperties || {};
michael@0 61
michael@0 62 // get the console service
michael@0 63 let consoleService = Cc["@mozilla.org/consoleservice;1"]
michael@0 64 .getService(Ci.nsIConsoleService);
michael@0 65
michael@0 66 // get the script error service
michael@0 67 let scriptError = Cc["@mozilla.org/scripterror;1"]
michael@0 68 .createInstance(Ci.nsIScriptError);
michael@0 69
michael@0 70 // initialize a script error
michael@0 71 scriptError.init(aMessage,
michael@0 72 aProperties.sourceName || "",
michael@0 73 aProperties.sourceLine || "",
michael@0 74 aProperties.lineNumber || 0,
michael@0 75 aProperties.columnNumber || 0,
michael@0 76 aProperties.flags || 0,
michael@0 77 aProperties.category || "");
michael@0 78
michael@0 79 // log the error
michael@0 80 consoleService.logMessage(scriptError);
michael@0 81 },
michael@0 82
michael@0 83 /**
michael@0 84 * Shows a modal alert message popup.
michael@0 85 *
michael@0 86 * @param {String} aTitle
michael@0 87 * the title of the popup
michael@0 88 * @param {String} aMessage
michael@0 89 * the message to be logged
michael@0 90 */
michael@0 91 alert: function TUO_alert(aTitle, aMessage)
michael@0 92 {
michael@0 93 if (this.suppressAlerts) {
michael@0 94 return;
michael@0 95 }
michael@0 96 if (!aMessage) {
michael@0 97 aMessage = aTitle;
michael@0 98 aTitle = "";
michael@0 99 }
michael@0 100
michael@0 101 // get the prompt service
michael@0 102 let prompt = Cc["@mozilla.org/embedcomp/prompt-service;1"]
michael@0 103 .getService(Ci.nsIPromptService);
michael@0 104
michael@0 105 // show the alert message
michael@0 106 prompt.alert(null, aTitle, aMessage);
michael@0 107 }
michael@0 108 };
michael@0 109
michael@0 110 /**
michael@0 111 * Helper functions for managing preferences.
michael@0 112 */
michael@0 113 TiltUtils.Preferences = {
michael@0 114
michael@0 115 /**
michael@0 116 * Gets a custom Tilt preference.
michael@0 117 * If the preference does not exist, undefined is returned. If it does exist,
michael@0 118 * but the type is not correctly specified, null is returned.
michael@0 119 *
michael@0 120 * @param {String} aPref
michael@0 121 * the preference name
michael@0 122 * @param {String} aType
michael@0 123 * either "boolean", "string" or "integer"
michael@0 124 *
michael@0 125 * @return {Boolean | String | Number} the requested preference
michael@0 126 */
michael@0 127 get: function TUP_get(aPref, aType)
michael@0 128 {
michael@0 129 if (!aPref || !aType) {
michael@0 130 return;
michael@0 131 }
michael@0 132
michael@0 133 try {
michael@0 134 let prefs = this._branch;
michael@0 135
michael@0 136 switch(aType) {
michael@0 137 case "boolean":
michael@0 138 return prefs.getBoolPref(aPref);
michael@0 139 case "string":
michael@0 140 return prefs.getCharPref(aPref);
michael@0 141 case "integer":
michael@0 142 return prefs.getIntPref(aPref);
michael@0 143 }
michael@0 144 return null;
michael@0 145
michael@0 146 } catch(e) {
michael@0 147 // handle any unexpected exceptions
michael@0 148 TiltUtils.Output.error(e.message);
michael@0 149 return undefined;
michael@0 150 }
michael@0 151 },
michael@0 152
michael@0 153 /**
michael@0 154 * Sets a custom Tilt preference.
michael@0 155 * If the preference already exists, it is overwritten.
michael@0 156 *
michael@0 157 * @param {String} aPref
michael@0 158 * the preference name
michael@0 159 * @param {String} aType
michael@0 160 * either "boolean", "string" or "integer"
michael@0 161 * @param {String} aValue
michael@0 162 * a new preference value
michael@0 163 *
michael@0 164 * @return {Boolean} true if the preference was set successfully
michael@0 165 */
michael@0 166 set: function TUP_set(aPref, aType, aValue)
michael@0 167 {
michael@0 168 if (!aPref || !aType || aValue === undefined || aValue === null) {
michael@0 169 return;
michael@0 170 }
michael@0 171
michael@0 172 try {
michael@0 173 let prefs = this._branch;
michael@0 174
michael@0 175 switch(aType) {
michael@0 176 case "boolean":
michael@0 177 return prefs.setBoolPref(aPref, aValue);
michael@0 178 case "string":
michael@0 179 return prefs.setCharPref(aPref, aValue);
michael@0 180 case "integer":
michael@0 181 return prefs.setIntPref(aPref, aValue);
michael@0 182 }
michael@0 183 } catch(e) {
michael@0 184 // handle any unexpected exceptions
michael@0 185 TiltUtils.Output.error(e.message);
michael@0 186 }
michael@0 187 return false;
michael@0 188 },
michael@0 189
michael@0 190 /**
michael@0 191 * Creates a custom Tilt preference.
michael@0 192 * If the preference already exists, it is left unchanged.
michael@0 193 *
michael@0 194 * @param {String} aPref
michael@0 195 * the preference name
michael@0 196 * @param {String} aType
michael@0 197 * either "boolean", "string" or "integer"
michael@0 198 * @param {String} aValue
michael@0 199 * the initial preference value
michael@0 200 *
michael@0 201 * @return {Boolean} true if the preference was initialized successfully
michael@0 202 */
michael@0 203 create: function TUP_create(aPref, aType, aValue)
michael@0 204 {
michael@0 205 if (!aPref || !aType || aValue === undefined || aValue === null) {
michael@0 206 return;
michael@0 207 }
michael@0 208
michael@0 209 try {
michael@0 210 let prefs = this._branch;
michael@0 211
michael@0 212 if (!prefs.prefHasUserValue(aPref)) {
michael@0 213 switch(aType) {
michael@0 214 case "boolean":
michael@0 215 return prefs.setBoolPref(aPref, aValue);
michael@0 216 case "string":
michael@0 217 return prefs.setCharPref(aPref, aValue);
michael@0 218 case "integer":
michael@0 219 return prefs.setIntPref(aPref, aValue);
michael@0 220 }
michael@0 221 }
michael@0 222 } catch(e) {
michael@0 223 // handle any unexpected exceptions
michael@0 224 TiltUtils.Output.error(e.message);
michael@0 225 }
michael@0 226 return false;
michael@0 227 },
michael@0 228
michael@0 229 /**
michael@0 230 * The preferences branch for this extension.
michael@0 231 */
michael@0 232 _branch: (function(aBranch) {
michael@0 233 return Cc["@mozilla.org/preferences-service;1"]
michael@0 234 .getService(Ci.nsIPrefService)
michael@0 235 .getBranch(aBranch);
michael@0 236
michael@0 237 }("devtools.tilt."))
michael@0 238 };
michael@0 239
michael@0 240 /**
michael@0 241 * Easy way to access the string bundle.
michael@0 242 */
michael@0 243 TiltUtils.L10n = {
michael@0 244
michael@0 245 /**
michael@0 246 * The string bundle element.
michael@0 247 */
michael@0 248 stringBundle: null,
michael@0 249
michael@0 250 /**
michael@0 251 * Returns a string in the string bundle.
michael@0 252 * If the string bundle is not found, null is returned.
michael@0 253 *
michael@0 254 * @param {String} aName
michael@0 255 * the string name in the bundle
michael@0 256 *
michael@0 257 * @return {String} the equivalent string from the bundle
michael@0 258 */
michael@0 259 get: function TUL_get(aName)
michael@0 260 {
michael@0 261 // check to see if the parent string bundle document element is valid
michael@0 262 if (!this.stringBundle || !aName) {
michael@0 263 return null;
michael@0 264 }
michael@0 265 return this.stringBundle.GetStringFromName(aName);
michael@0 266 },
michael@0 267
michael@0 268 /**
michael@0 269 * Returns a formatted string using the string bundle.
michael@0 270 * If the string bundle is not found, null is returned.
michael@0 271 *
michael@0 272 * @param {String} aName
michael@0 273 * the string name in the bundle
michael@0 274 * @param {Array} aArgs
michael@0 275 * an array of arguments for the formatted string
michael@0 276 *
michael@0 277 * @return {String} the equivalent formatted string from the bundle
michael@0 278 */
michael@0 279 format: function TUL_format(aName, aArgs)
michael@0 280 {
michael@0 281 // check to see if the parent string bundle document element is valid
michael@0 282 if (!this.stringBundle || !aName || !aArgs) {
michael@0 283 return null;
michael@0 284 }
michael@0 285 return this.stringBundle.formatStringFromName(aName, aArgs, aArgs.length);
michael@0 286 }
michael@0 287 };
michael@0 288
michael@0 289 /**
michael@0 290 * Utilities for accessing and manipulating a document.
michael@0 291 */
michael@0 292 TiltUtils.DOM = {
michael@0 293
michael@0 294 /**
michael@0 295 * Current parent node object used when creating canvas elements.
michael@0 296 */
michael@0 297 parentNode: null,
michael@0 298
michael@0 299 /**
michael@0 300 * Helper method, allowing to easily create and manage a canvas element.
michael@0 301 * If the width and height params are falsy, they default to the parent node
michael@0 302 * client width and height.
michael@0 303 *
michael@0 304 * @param {Document} aParentNode
michael@0 305 * the parent node used to create the canvas
michael@0 306 * if not specified, it will be reused from the cache
michael@0 307 * @param {Object} aProperties
michael@0 308 * optional, object containing some of the following props:
michael@0 309 * {Boolean} focusable
michael@0 310 * optional, true to make the canvas focusable
michael@0 311 * {Boolean} append
michael@0 312 * optional, true to append the canvas to the parent node
michael@0 313 * {Number} width
michael@0 314 * optional, specifies the width of the canvas
michael@0 315 * {Number} height
michael@0 316 * optional, specifies the height of the canvas
michael@0 317 * {String} id
michael@0 318 * optional, id for the created canvas element
michael@0 319 *
michael@0 320 * @return {HTMLCanvasElement} the newly created canvas element
michael@0 321 */
michael@0 322 initCanvas: function TUD_initCanvas(aParentNode, aProperties)
michael@0 323 {
michael@0 324 // check to see if the parent node element is valid
michael@0 325 if (!(aParentNode = aParentNode || this.parentNode)) {
michael@0 326 return null;
michael@0 327 }
michael@0 328
michael@0 329 // make sure the properties parameter is a valid object
michael@0 330 aProperties = aProperties || {};
michael@0 331
michael@0 332 // cache this parent node so that it can be reused
michael@0 333 this.parentNode = aParentNode;
michael@0 334
michael@0 335 // create the canvas element
michael@0 336 let canvas = aParentNode.ownerDocument.
michael@0 337 createElementNS("http://www.w3.org/1999/xhtml", "canvas");
michael@0 338
michael@0 339 let width = aProperties.width || aParentNode.clientWidth;
michael@0 340 let height = aProperties.height || aParentNode.clientHeight;
michael@0 341 let id = aProperties.id || null;
michael@0 342
michael@0 343 canvas.setAttribute("style", "min-width: 1px; min-height: 1px;");
michael@0 344 canvas.setAttribute("width", width);
michael@0 345 canvas.setAttribute("height", height);
michael@0 346 canvas.setAttribute("id", id);
michael@0 347
michael@0 348 // the canvas is unfocusable by default, we may require otherwise
michael@0 349 if (aProperties.focusable) {
michael@0 350 canvas.setAttribute("tabindex", "1");
michael@0 351 canvas.style.outline = "none";
michael@0 352 }
michael@0 353
michael@0 354 // append the canvas element to the current parent node, if specified
michael@0 355 if (aProperties.append) {
michael@0 356 aParentNode.appendChild(canvas);
michael@0 357 }
michael@0 358
michael@0 359 return canvas;
michael@0 360 },
michael@0 361
michael@0 362 /**
michael@0 363 * Gets the full webpage dimensions (width and height).
michael@0 364 *
michael@0 365 * @param {Window} aContentWindow
michael@0 366 * the content window holding the document
michael@0 367 *
michael@0 368 * @return {Object} an object containing the width and height coords
michael@0 369 */
michael@0 370 getContentWindowDimensions: function TUD_getContentWindowDimensions(
michael@0 371 aContentWindow)
michael@0 372 {
michael@0 373 return {
michael@0 374 width: aContentWindow.innerWidth + aContentWindow.scrollMaxX,
michael@0 375 height: aContentWindow.innerHeight + aContentWindow.scrollMaxY
michael@0 376 };
michael@0 377 },
michael@0 378
michael@0 379 /**
michael@0 380 * Calculates the position and depth to display a node, this can be overriden
michael@0 381 * to change the visualization.
michael@0 382 *
michael@0 383 * @param {Window} aContentWindow
michael@0 384 * the window content holding the document
michael@0 385 * @param {Node} aNode
michael@0 386 * the node to get the position for
michael@0 387 * @param {Object} aParentPosition
michael@0 388 * the position of the parent node, as returned by this
michael@0 389 * function
michael@0 390 *
michael@0 391 * @return {Object} an object describing the node's position in 3D space
michael@0 392 * containing the following properties:
michael@0 393 * {Number} top
michael@0 394 * distance along the x axis
michael@0 395 * {Number} left
michael@0 396 * distance along the y axis
michael@0 397 * {Number} depth
michael@0 398 * distance along the z axis
michael@0 399 * {Number} width
michael@0 400 * width of the node
michael@0 401 * {Number} height
michael@0 402 * height of the node
michael@0 403 * {Number} thickness
michael@0 404 * thickness of the node
michael@0 405 */
michael@0 406 getNodePosition: function TUD_getNodePosition(aContentWindow, aNode,
michael@0 407 aParentPosition) {
michael@0 408 let lh = new LayoutHelpers(aContentWindow);
michael@0 409 // get the x, y, width and height coordinates of the node
michael@0 410 let coord = lh.getRect(aNode, aContentWindow);
michael@0 411 if (!coord) {
michael@0 412 return null;
michael@0 413 }
michael@0 414
michael@0 415 coord.depth = aParentPosition ? (aParentPosition.depth + aParentPosition.thickness) : 0;
michael@0 416 coord.thickness = STACK_THICKNESS;
michael@0 417
michael@0 418 return coord;
michael@0 419 },
michael@0 420
michael@0 421 /**
michael@0 422 * Traverses a document object model & calculates useful info for each node.
michael@0 423 *
michael@0 424 * @param {Window} aContentWindow
michael@0 425 * the window content holding the document
michael@0 426 * @param {Object} aProperties
michael@0 427 * optional, an object containing the following properties:
michael@0 428 * {Function} nodeCallback
michael@0 429 * a function to call instead of TiltUtils.DOM.getNodePosition
michael@0 430 * to get the position and depth to display nodes
michael@0 431 * {Object} invisibleElements
michael@0 432 * elements which should be ignored
michael@0 433 * {Number} minSize
michael@0 434 * the minimum dimensions needed for a node to be traversed
michael@0 435 * {Number} maxX
michael@0 436 * the maximum left position of an element
michael@0 437 * {Number} maxY
michael@0 438 * the maximum top position of an element
michael@0 439 *
michael@0 440 * @return {Array} list containing nodes positions and local names
michael@0 441 */
michael@0 442 traverse: function TUD_traverse(aContentWindow, aProperties)
michael@0 443 {
michael@0 444 // make sure the properties parameter is a valid object
michael@0 445 aProperties = aProperties || {};
michael@0 446
michael@0 447 let aInvisibleElements = aProperties.invisibleElements || {};
michael@0 448 let aMinSize = aProperties.minSize || -1;
michael@0 449 let aMaxX = aProperties.maxX || Number.MAX_VALUE;
michael@0 450 let aMaxY = aProperties.maxY || Number.MAX_VALUE;
michael@0 451
michael@0 452 let nodeCallback = aProperties.nodeCallback || this.getNodePosition.bind(this);
michael@0 453
michael@0 454 let nodes = aContentWindow.document.childNodes;
michael@0 455 let store = { info: [], nodes: [] };
michael@0 456 let depth = 0;
michael@0 457
michael@0 458 let queue = [
michael@0 459 { parentPosition: null, nodes: aContentWindow.document.childNodes }
michael@0 460 ]
michael@0 461
michael@0 462 while (queue.length) {
michael@0 463 let { nodes, parentPosition } = queue.shift();
michael@0 464
michael@0 465 for (let node of nodes) {
michael@0 466 // skip some nodes to avoid visualization meshes that are too bloated
michael@0 467 let name = node.localName;
michael@0 468 if (!name || aInvisibleElements[name]) {
michael@0 469 continue;
michael@0 470 }
michael@0 471
michael@0 472 let coord = nodeCallback(aContentWindow, node, parentPosition);
michael@0 473 if (!coord) {
michael@0 474 continue;
michael@0 475 }
michael@0 476
michael@0 477 // the maximum size slices the traversal where needed
michael@0 478 if (coord.left > aMaxX || coord.top > aMaxY) {
michael@0 479 continue;
michael@0 480 }
michael@0 481
michael@0 482 // use this node only if it actually has visible dimensions
michael@0 483 if (coord.width > aMinSize && coord.height > aMinSize) {
michael@0 484
michael@0 485 // save the necessary details into a list to be returned later
michael@0 486 store.info.push({ coord: coord, name: name });
michael@0 487 store.nodes.push(node);
michael@0 488 }
michael@0 489
michael@0 490 let childNodes = (name === "iframe" || name === "frame") ? node.contentDocument.childNodes : node.childNodes;
michael@0 491 if (childNodes.length > 0)
michael@0 492 queue.push({ parentPosition: coord, nodes: childNodes });
michael@0 493 }
michael@0 494 }
michael@0 495
michael@0 496 return store;
michael@0 497 }
michael@0 498 };
michael@0 499
michael@0 500 /**
michael@0 501 * Binds a new owner object to the child functions.
michael@0 502 * If the new parent is not specified, it will default to the passed scope.
michael@0 503 *
michael@0 504 * @param {Object} aScope
michael@0 505 * the object from which all functions will be rebound
michael@0 506 * @param {String} aRegex
michael@0 507 * a regular expression to identify certain functions
michael@0 508 * @param {Object} aParent
michael@0 509 * the new parent for the object's functions
michael@0 510 */
michael@0 511 TiltUtils.bindObjectFunc = function TU_bindObjectFunc(aScope, aRegex, aParent)
michael@0 512 {
michael@0 513 if (!aScope) {
michael@0 514 return;
michael@0 515 }
michael@0 516
michael@0 517 for (let i in aScope) {
michael@0 518 try {
michael@0 519 if ("function" === typeof aScope[i] && (aRegex ? i.match(aRegex) : 1)) {
michael@0 520 aScope[i] = aScope[i].bind(aParent || aScope);
michael@0 521 }
michael@0 522 } catch(e) {
michael@0 523 TiltUtils.Output.error(e);
michael@0 524 }
michael@0 525 }
michael@0 526 };
michael@0 527
michael@0 528 /**
michael@0 529 * Destroys an object and deletes all members.
michael@0 530 *
michael@0 531 * @param {Object} aScope
michael@0 532 * the object from which all children will be destroyed
michael@0 533 */
michael@0 534 TiltUtils.destroyObject = function TU_destroyObject(aScope)
michael@0 535 {
michael@0 536 if (!aScope) {
michael@0 537 return;
michael@0 538 }
michael@0 539
michael@0 540 // objects in Tilt usually use a function to handle internal destruction
michael@0 541 if ("function" === typeof aScope._finalize) {
michael@0 542 aScope._finalize();
michael@0 543 }
michael@0 544 for (let i in aScope) {
michael@0 545 if (aScope.hasOwnProperty(i)) {
michael@0 546 delete aScope[i];
michael@0 547 }
michael@0 548 }
michael@0 549 };
michael@0 550
michael@0 551 /**
michael@0 552 * Retrieve the unique ID of a window object.
michael@0 553 *
michael@0 554 * @param {Window} aWindow
michael@0 555 * the window to get the ID from
michael@0 556 *
michael@0 557 * @return {Number} the window ID
michael@0 558 */
michael@0 559 TiltUtils.getWindowId = function TU_getWindowId(aWindow)
michael@0 560 {
michael@0 561 if (!aWindow) {
michael@0 562 return;
michael@0 563 }
michael@0 564
michael@0 565 return aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
michael@0 566 .getInterface(Ci.nsIDOMWindowUtils)
michael@0 567 .currentInnerWindowID;
michael@0 568 };
michael@0 569
michael@0 570 /**
michael@0 571 * Sets the markup document viewer zoom for the currently selected browser.
michael@0 572 *
michael@0 573 * @param {Window} aChromeWindow
michael@0 574 * the top-level browser window
michael@0 575 *
michael@0 576 * @param {Number} the zoom ammount
michael@0 577 */
michael@0 578 TiltUtils.setDocumentZoom = function TU_setDocumentZoom(aChromeWindow, aZoom) {
michael@0 579 aChromeWindow.gBrowser.selectedBrowser.markupDocumentViewer.fullZoom = aZoom;
michael@0 580 };
michael@0 581
michael@0 582 /**
michael@0 583 * Performs a garbage collection.
michael@0 584 *
michael@0 585 * @param {Window} aChromeWindow
michael@0 586 * the top-level browser window
michael@0 587 */
michael@0 588 TiltUtils.gc = function TU_gc(aChromeWindow)
michael@0 589 {
michael@0 590 aChromeWindow.QueryInterface(Ci.nsIInterfaceRequestor)
michael@0 591 .getInterface(Ci.nsIDOMWindowUtils)
michael@0 592 .garbageCollect();
michael@0 593 };
michael@0 594
michael@0 595 /**
michael@0 596 * Clears the cache and sets all the variables to null.
michael@0 597 */
michael@0 598 TiltUtils.clearCache = function TU_clearCache()
michael@0 599 {
michael@0 600 TiltUtils.DOM.parentNode = null;
michael@0 601 };
michael@0 602
michael@0 603 // bind the owner object to the necessary functions
michael@0 604 TiltUtils.bindObjectFunc(TiltUtils.Output);
michael@0 605 TiltUtils.bindObjectFunc(TiltUtils.Preferences);
michael@0 606 TiltUtils.bindObjectFunc(TiltUtils.L10n);
michael@0 607 TiltUtils.bindObjectFunc(TiltUtils.DOM);
michael@0 608
michael@0 609 // set the necessary string bundle
michael@0 610 XPCOMUtils.defineLazyGetter(TiltUtils.L10n, "stringBundle", function() {
michael@0 611 return Services.strings.createBundle(
michael@0 612 "chrome://browser/locale/devtools/tilt.properties");
michael@0 613 });

mercurial