OLD | NEW |
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 cr.define('cr.ui', function() { | 5 cr.define('cr.ui', function() { |
6 // require cr.ui.define | 6 // require cr.ui.define |
7 // require cr.ui.limitInputWidth | 7 // require cr.ui.limitInputWidth |
8 | 8 |
9 /** | 9 /** |
10 * The number of pixels to indent per level. | 10 * The number of pixels to indent per level. |
11 * @type {number} | 11 * @type {number} |
12 * @const | 12 * @const |
13 */ | 13 */ |
14 var INDENT = 20; | 14 var INDENT = 20; |
15 | 15 |
16 /** | 16 /** |
17 * Returns the computed style for an element. | 17 * Returns the computed style for an element. |
18 * @param {!Element} el The element to get the computed style for. | 18 * @param {!Element} el The element to get the computed style for. |
19 * @return {!CSSStyleDeclaration} The computed style. | 19 * @return {!CSSStyleDeclaration} The computed style. |
20 */ | 20 */ |
21 function getComputedStyle(el) { | 21 function getComputedStyle(el) { |
22 return el.ownerDocument.defaultView.getComputedStyle(el); | 22 return assert(el.ownerDocument.defaultView.getComputedStyle(el)); |
23 } | 23 } |
24 | 24 |
25 /** | 25 /** |
26 * Helper function that finds the first ancestor tree item. | 26 * Helper function that finds the first ancestor tree item. |
27 * @param {Node} node The node to start searching from. | 27 * @param {Node} node The node to start searching from. |
28 * @return {cr.ui.TreeItem} The found tree item or null if not found. | 28 * @return {cr.ui.TreeItem} The found tree item or null if not found. |
29 */ | 29 */ |
30 function findTreeItem(node) { | 30 function findTreeItem(node) { |
31 while (node && !(node instanceof TreeItem)) { | 31 while (node && !(node instanceof TreeItem)) { |
32 node = node.parentNode; | 32 node = node.parentNode; |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 if (item.expanded && item.hasChildren) { | 696 if (item.expanded && item.hasChildren) { |
697 var lastChild = item.items[item.items.length - 1]; | 697 var lastChild = item.items[item.items.length - 1]; |
698 return getLastHelper(lastChild); | 698 return getLastHelper(lastChild); |
699 } | 699 } |
700 return item; | 700 return item; |
701 } | 701 } |
702 | 702 |
703 // Export | 703 // Export |
704 return {Tree: Tree, TreeItem: TreeItem}; | 704 return {Tree: Tree, TreeItem: TreeItem}; |
705 }); | 705 }); |
OLD | NEW |