| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 * Helper that binds the |this| object to a method to create a callback. | 6 * Helper that binds the |this| object to a method to create a callback. |
| 7 */ | 7 */ |
| 8 Function.prototype.bind = function(thisObj) { | 8 Function.prototype.bind = function(thisObj) { |
| 9 var func = this; | 9 var func = this; |
| 10 var args = Array.prototype.slice.call(arguments, 1); | 10 var args = Array.prototype.slice.call(arguments, 1); |
| 11 return function() { | 11 return function() { |
| 12 return func.apply(thisObj, | 12 return func.apply(thisObj, |
| 13 args.concat(Array.prototype.slice.call(arguments, 0))) | 13 args.concat(Array.prototype.slice.call(arguments, 0))) |
| 14 }; | 14 }; |
| 15 }; | 15 }; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Inherit the prototype methods from one constructor into another. |
| 19 */ |
| 20 function inherits(childCtor, parentCtor) { |
| 21 function tempCtor() {}; |
| 22 tempCtor.prototype = parentCtor.prototype; |
| 23 childCtor.superClass_ = parentCtor.prototype; |
| 24 childCtor.prototype = new tempCtor(); |
| 25 childCtor.prototype.constructor = childCtor; |
| 26 }; |
| 27 |
| 28 /** |
| 18 * Sets the width (in pixels) on a DOM node. | 29 * Sets the width (in pixels) on a DOM node. |
| 19 */ | 30 */ |
| 20 function setNodeWidth(node, widthPx) { | 31 function setNodeWidth(node, widthPx) { |
| 21 node.style.width = widthPx.toFixed(0) + "px"; | 32 node.style.width = widthPx.toFixed(0) + "px"; |
| 22 } | 33 } |
| 23 | 34 |
| 24 /** | 35 /** |
| 25 * Sets the height (in pixels) on a DOM node. | 36 * Sets the height (in pixels) on a DOM node. |
| 26 */ | 37 */ |
| 27 function setNodeHeight(node, heightPx) { | 38 function setNodeHeight(node, heightPx) { |
| 28 node.style.height = heightPx.toFixed(0) + "px"; | 39 node.style.height = heightPx.toFixed(0) + "px"; |
| 29 } | 40 } |
| 30 | 41 |
| 31 /** | 42 /** |
| 32 * Sets the position and size of a DOM node (in pixels). | 43 * Sets the position and size of a DOM node (in pixels). |
| 33 */ | 44 */ |
| 34 function setNodePosition(node, leftPx, topPx, widthPx, heightPx) { | 45 function setNodePosition(node, leftPx, topPx, widthPx, heightPx) { |
| 35 node.style.left = leftPx.toFixed(0) + "px"; | 46 node.style.left = leftPx.toFixed(0) + "px"; |
| 36 node.style.top = topPx.toFixed(0) + "px"; | 47 node.style.top = topPx.toFixed(0) + "px"; |
| 37 setNodeWidth(node, widthPx); | 48 setNodeWidth(node, widthPx); |
| 38 setNodeHeight(node, heightPx); | 49 setNodeHeight(node, heightPx); |
| 39 } | 50 } |
| 40 | 51 |
| 41 /** | 52 /** |
| 53 * Sets the visibility for a DOM node. |
| 54 */ |
| 55 function setNodeDisplay(node, isVisible) { |
| 56 node.style.display = isVisible ? '' : 'none'; |
| 57 } |
| 58 |
| 59 /** |
| 42 * Adds a node to |parentNode|, of type |tagName|. | 60 * Adds a node to |parentNode|, of type |tagName|. |
| 43 */ | 61 */ |
| 44 function addNode(parentNode, tagName) { | 62 function addNode(parentNode, tagName) { |
| 45 var elem = parentNode.ownerDocument.createElement(tagName); | 63 var elem = parentNode.ownerDocument.createElement(tagName); |
| 46 parentNode.appendChild(elem); | 64 parentNode.appendChild(elem); |
| 47 return elem; | 65 return elem; |
| 48 } | 66 } |
| 49 | 67 |
| 50 /** | 68 /** |
| 51 * Adds text to node |parentNode|. | 69 * Adds text to node |parentNode|. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 79 node.className = currentNames.join(" "); | 97 node.className = currentNames.join(" "); |
| 80 } | 98 } |
| 81 | 99 |
| 82 function getKeyWithValue(map, value) { | 100 function getKeyWithValue(map, value) { |
| 83 for (key in map) { | 101 for (key in map) { |
| 84 if (map[key] == value) | 102 if (map[key] == value) |
| 85 return key; | 103 return key; |
| 86 } | 104 } |
| 87 return '?'; | 105 return '?'; |
| 88 } | 106 } |
| OLD | NEW |