| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 */ | 33 */ |
| 34 function TreeOutline(nonFocusable) | 34 function TreeOutline(nonFocusable) |
| 35 { | 35 { |
| 36 this._createRootElement(); | 36 this._createRootElement(); |
| 37 | 37 |
| 38 this.selectedTreeElement = null; | 38 this.selectedTreeElement = null; |
| 39 this.expandTreeElementsWhenArrowing = false; | 39 this.expandTreeElementsWhenArrowing = false; |
| 40 /** @type {?function(!TreeElement, !TreeElement):number} */ | 40 /** @type {?function(!TreeElement, !TreeElement):number} */ |
| 41 this._comparator = null; | 41 this._comparator = null; |
| 42 | 42 |
| 43 this._contentElement = this._rootElement._childrenListNode; | 43 this.contentElement = this._rootElement._childrenListNode; |
| 44 this._contentElement.addEventListener("keydown", this._treeKeyDown.bind(this
), true); | 44 this.contentElement.addEventListener("keydown", this._treeKeyDown.bind(this)
, true); |
| 45 | 45 |
| 46 this.setFocusable(!nonFocusable); | 46 this.setFocusable(!nonFocusable); |
| 47 | 47 |
| 48 this.element = this._contentElement; | 48 this.element = this.contentElement; |
| 49 } | 49 } |
| 50 | 50 |
| 51 TreeOutline.Events = { | 51 TreeOutline.Events = { |
| 52 ElementAttached: "ElementAttached", | 52 ElementAttached: "ElementAttached", |
| 53 ElementExpanded: "ElementExpanded", | 53 ElementExpanded: "ElementExpanded", |
| 54 ElementCollapsed: "ElementCollapsed", | 54 ElementCollapsed: "ElementCollapsed", |
| 55 ElementSelected: "ElementSelected" | 55 ElementSelected: "ElementSelected" |
| 56 } | 56 } |
| 57 | 57 |
| 58 TreeOutline.prototype = { | 58 TreeOutline.prototype = { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 this._rootElement.removeChildren(); | 112 this._rootElement.removeChildren(); |
| 113 }, | 113 }, |
| 114 | 114 |
| 115 /** | 115 /** |
| 116 * @param {number} x | 116 * @param {number} x |
| 117 * @param {number} y | 117 * @param {number} y |
| 118 * @return {?TreeElement} | 118 * @return {?TreeElement} |
| 119 */ | 119 */ |
| 120 treeElementFromPoint: function(x, y) | 120 treeElementFromPoint: function(x, y) |
| 121 { | 121 { |
| 122 var node = this._contentElement.ownerDocument.deepElementFromPoint(x, y)
; | 122 var node = this.contentElement.ownerDocument.deepElementFromPoint(x, y); |
| 123 if (!node) | 123 if (!node) |
| 124 return null; | 124 return null; |
| 125 | 125 |
| 126 var listNode = node.enclosingNodeOrSelfWithNodeNameInArray(["ol", "li"])
; | 126 var listNode = node.enclosingNodeOrSelfWithNodeNameInArray(["ol", "li"])
; |
| 127 if (listNode) | 127 if (listNode) |
| 128 return listNode.parentTreeElement || listNode.treeElement; | 128 return listNode.parentTreeElement || listNode.treeElement; |
| 129 return null; | 129 return null; |
| 130 }, | 130 }, |
| 131 | 131 |
| 132 /** | 132 /** |
| (...skipping 12 matching lines...) Expand all Loading... |
| 145 { | 145 { |
| 146 this._comparator = comparator; | 146 this._comparator = comparator; |
| 147 }, | 147 }, |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * @param {boolean} focusable | 150 * @param {boolean} focusable |
| 151 */ | 151 */ |
| 152 setFocusable: function(focusable) | 152 setFocusable: function(focusable) |
| 153 { | 153 { |
| 154 if (focusable) | 154 if (focusable) |
| 155 this._contentElement.setAttribute("tabIndex", 0); | 155 this.contentElement.setAttribute("tabIndex", 0); |
| 156 else | 156 else |
| 157 this._contentElement.removeAttribute("tabIndex"); | 157 this.contentElement.removeAttribute("tabIndex"); |
| 158 }, | 158 }, |
| 159 | 159 |
| 160 focus: function() | 160 focus: function() |
| 161 { | 161 { |
| 162 this._contentElement.focus(); | 162 this.contentElement.focus(); |
| 163 }, | 163 }, |
| 164 | 164 |
| 165 /** | 165 /** |
| 166 * @param {!TreeElement} element | 166 * @param {!TreeElement} element |
| 167 */ | 167 */ |
| 168 _bindTreeElement: function(element) | 168 _bindTreeElement: function(element) |
| 169 { | 169 { |
| 170 if (element.treeOutline) | 170 if (element.treeOutline) |
| 171 console.error("Binding element for the second time: " + new Error().
stack); | 171 console.error("Binding element for the second time: " + new Error().
stack); |
| 172 element.treeOutline = this; | 172 element.treeOutline = this; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 return true; | 216 return true; |
| 217 } | 217 } |
| 218 return false; | 218 return false; |
| 219 }, | 219 }, |
| 220 | 220 |
| 221 /** | 221 /** |
| 222 * @param {!Event} event | 222 * @param {!Event} event |
| 223 */ | 223 */ |
| 224 _treeKeyDown: function(event) | 224 _treeKeyDown: function(event) |
| 225 { | 225 { |
| 226 if (event.target !== this._contentElement) | 226 if (event.target !== this.contentElement) |
| 227 return; | 227 return; |
| 228 | 228 |
| 229 if (!this.selectedTreeElement || event.shiftKey || event.metaKey || even
t.ctrlKey) | 229 if (!this.selectedTreeElement || event.shiftKey || event.metaKey || even
t.ctrlKey) |
| 230 return; | 230 return; |
| 231 | 231 |
| 232 var handled = false; | 232 var handled = false; |
| 233 var nextSelectedElement; | 233 var nextSelectedElement; |
| 234 if (event.keyIdentifier === "Up" && !event.altKey) { | 234 if (event.keyIdentifier === "Up" && !event.altKey) { |
| 235 handled = this.selectPrevious(); | 235 handled = this.selectPrevious(); |
| 236 } else if (event.keyIdentifier === "Down" && !event.altKey) { | 236 } else if (event.keyIdentifier === "Down" && !event.altKey) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 __proto__: WebInspector.Object.prototype | 310 __proto__: WebInspector.Object.prototype |
| 311 } | 311 } |
| 312 | 312 |
| 313 /** | 313 /** |
| 314 * @constructor | 314 * @constructor |
| 315 * @extends {TreeOutline} | 315 * @extends {TreeOutline} |
| 316 */ | 316 */ |
| 317 function TreeOutlineInShadow() | 317 function TreeOutlineInShadow() |
| 318 { | 318 { |
| 319 TreeOutline.call(this); | 319 TreeOutline.call(this); |
| 320 var innerElement = this.element; | 320 this.contentElement.classList.add("tree-outline"); |
| 321 innerElement.classList.add("tree-outline"); | |
| 322 | 321 |
| 323 // Redefine element to the external one. | 322 // Redefine element to the external one. |
| 324 this.element = createElement("div"); | 323 this.element = createElement("div"); |
| 325 this._shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element,
"ui/treeoutline.css"); | 324 this._shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element,
"ui/treeoutline.css"); |
| 326 this._disclosureElement = this._shadowRoot.createChild("div", "tree-outline-
disclosure"); | 325 this._disclosureElement = this._shadowRoot.createChild("div", "tree-outline-
disclosure"); |
| 327 this._disclosureElement.appendChild(innerElement); | 326 this._disclosureElement.appendChild(this.contentElement); |
| 328 this._renderSelection = true; | 327 this._renderSelection = true; |
| 329 } | 328 } |
| 330 | 329 |
| 331 TreeOutlineInShadow.prototype = { | 330 TreeOutlineInShadow.prototype = { |
| 332 /** | 331 /** |
| 333 * @param {string} cssFile | 332 * @param {string} cssFile |
| 334 */ | 333 */ |
| 335 registerRequiredCSS: function(cssFile) | 334 registerRequiredCSS: function(cssFile) |
| 336 { | 335 { |
| 337 WebInspector.appendStyle(this._shadowRoot, cssFile); | 336 WebInspector.appendStyle(this._shadowRoot, cssFile); |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 isEventWithinDisclosureTriangle: function(event) | 1163 isEventWithinDisclosureTriangle: function(event) |
| 1165 { | 1164 { |
| 1166 // FIXME: We should not use getComputedStyle(). For that we need to get
rid of using ::before for disclosure triangle. (http://webk.it/74446) | 1165 // FIXME: We should not use getComputedStyle(). For that we need to get
rid of using ::before for disclosure triangle. (http://webk.it/74446) |
| 1167 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddi
ngLeft; | 1166 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddi
ngLeft; |
| 1168 console.assert(paddingLeftValue.endsWith("px")); | 1167 console.assert(paddingLeftValue.endsWith("px")); |
| 1169 var computedLeftPadding = parseFloat(paddingLeftValue); | 1168 var computedLeftPadding = parseFloat(paddingLeftValue); |
| 1170 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; | 1169 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; |
| 1171 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowTo
ggleWidth && this._expandable; | 1170 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowTo
ggleWidth && this._expandable; |
| 1172 } | 1171 } |
| 1173 } | 1172 } |
| OLD | NEW |