OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> |
4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 22 matching lines...) Expand all Loading... |
33 * @extends {TreeOutline} | 33 * @extends {TreeOutline} |
34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
35 * @param {boolean=} omitRootDOMNode | 35 * @param {boolean=} omitRootDOMNode |
36 * @param {boolean=} selectEnabled | 36 * @param {boolean=} selectEnabled |
37 * @param {function(!WebInspector.DOMNode, string, boolean)=} setPseudoClassCall
back | 37 * @param {function(!WebInspector.DOMNode, string, boolean)=} setPseudoClassCall
back |
38 */ | 38 */ |
39 WebInspector.ElementsTreeOutline = function(target, omitRootDOMNode, selectEnabl
ed, setPseudoClassCallback) | 39 WebInspector.ElementsTreeOutline = function(target, omitRootDOMNode, selectEnabl
ed, setPseudoClassCallback) |
40 { | 40 { |
41 this._target = target; | 41 this._target = target; |
42 this._domModel = target.domModel; | 42 this._domModel = target.domModel; |
43 var element = document.createElement("div"); | 43 var element = createElement("div"); |
44 | 44 |
45 this._shadowRoot = element.createShadowRoot(); | 45 this._shadowRoot = element.createShadowRoot(); |
46 this._shadowRoot.appendChild(WebInspector.View.createStyleElement("elementsT
reeOutline.css")); | 46 this._shadowRoot.appendChild(WebInspector.View.createStyleElement("elementsT
reeOutline.css")); |
47 | 47 |
48 var outlineDisclosureElement = this._shadowRoot.createChild("div", "componen
t-root outline-disclosure source-code"); | 48 var outlineDisclosureElement = this._shadowRoot.createChild("div", "componen
t-root outline-disclosure source-code"); |
49 this._element = outlineDisclosureElement.createChild("ol", "elements-tree-ou
tline"); | 49 this._element = outlineDisclosureElement.createChild("ol", "elements-tree-ou
tline"); |
50 this._element.addEventListener("mousedown", this._onmousedown.bind(this), fa
lse); | 50 this._element.addEventListener("mousedown", this._onmousedown.bind(this), fa
lse); |
51 this._element.addEventListener("mousemove", this._onmousemove.bind(this), fa
lse); | 51 this._element.addEventListener("mousemove", this._onmousemove.bind(this), fa
lse); |
52 this._element.addEventListener("mouseout", this._onmouseout.bind(this), fals
e); | 52 this._element.addEventListener("mouseout", this._onmouseout.bind(this), fals
e); |
53 this._element.addEventListener("dragstart", this._ondragstart.bind(this), fa
lse); | 53 this._element.addEventListener("dragstart", this._ondragstart.bind(this), fa
lse); |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 if (document.body.offsetWidth > 0) | 1185 if (document.body.offsetWidth > 0) |
1186 this._readyToUpdateSelection = true; | 1186 this._readyToUpdateSelection = true; |
1187 else { | 1187 else { |
1188 // The stylesheet hasn't loaded yet or the window is closed, | 1188 // The stylesheet hasn't loaded yet or the window is closed, |
1189 // so we can't calculate what we need. Return early. | 1189 // so we can't calculate what we need. Return early. |
1190 return; | 1190 return; |
1191 } | 1191 } |
1192 } | 1192 } |
1193 | 1193 |
1194 if (!this.selectionElement) { | 1194 if (!this.selectionElement) { |
1195 this.selectionElement = document.createElement("div"); | 1195 this.selectionElement = createElement("div"); |
1196 this.selectionElement.className = "selection selected"; | 1196 this.selectionElement.className = "selection selected"; |
1197 listItemElement.insertBefore(this.selectionElement, listItemElement.
firstChild); | 1197 listItemElement.insertBefore(this.selectionElement, listItemElement.
firstChild); |
1198 } | 1198 } |
1199 | 1199 |
1200 this.selectionElement.style.height = listItemElement.offsetHeight + "px"
; | 1200 this.selectionElement.style.height = listItemElement.offsetHeight + "px"
; |
1201 }, | 1201 }, |
1202 | 1202 |
1203 onattach: function() | 1203 onattach: function() |
1204 { | 1204 { |
1205 if (this._hovered) { | 1205 if (this._hovered) { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 const childNodeCount = visibleChildren.length; | 1376 const childNodeCount = visibleChildren.length; |
1377 | 1377 |
1378 // In case some nodes from the expanded range were removed, pull some no
des from the collapsed range into the expanded range at the bottom. | 1378 // In case some nodes from the expanded range were removed, pull some no
des from the collapsed range into the expanded range at the bottom. |
1379 for (var i = this.expandedChildCount, limit = Math.min(this.expandedChil
drenLimit, childNodeCount); i < limit; ++i) | 1379 for (var i = this.expandedChildCount, limit = Math.min(this.expandedChil
drenLimit, childNodeCount); i < limit; ++i) |
1380 this.insertChildElement(visibleChildren[i], i); | 1380 this.insertChildElement(visibleChildren[i], i); |
1381 | 1381 |
1382 const expandedChildCount = this.expandedChildCount; | 1382 const expandedChildCount = this.expandedChildCount; |
1383 if (childNodeCount > this.expandedChildCount) { | 1383 if (childNodeCount > this.expandedChildCount) { |
1384 var targetButtonIndex = expandedChildCount; | 1384 var targetButtonIndex = expandedChildCount; |
1385 if (!this.expandAllButtonElement) { | 1385 if (!this.expandAllButtonElement) { |
1386 var button = document.createElement("button"); | 1386 var button = createElement("button"); |
1387 button.className = "text-button"; | 1387 button.className = "text-button"; |
1388 button.value = ""; | 1388 button.value = ""; |
1389 var item = new TreeElement(button, null, false); | 1389 var item = new TreeElement(button, null, false); |
1390 item.selectable = false; | 1390 item.selectable = false; |
1391 item.expandAllButton = true; | 1391 item.expandAllButton = true; |
1392 this.insertChild(item, targetButtonIndex); | 1392 this.insertChild(item, targetButtonIndex); |
1393 this.expandAllButtonElement = item.listItemElement.firstChild; | 1393 this.expandAllButtonElement = item.listItemElement.firstChild; |
1394 this.expandAllButtonElement.__treeElement = item; | 1394 this.expandAllButtonElement.__treeElement = item; |
1395 this.expandAllButtonElement.addEventListener("click", this.handl
eLoadAllChildren.bind(this), false); | 1395 this.expandAllButtonElement.addEventListener("click", this.handl
eLoadAllChildren.bind(this), false); |
1396 } else if (!this.expandAllButtonElement.__treeElement.parent) | 1396 } else if (!this.expandAllButtonElement.__treeElement.parent) |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 if (textNode) | 1701 if (textNode) |
1702 return this._startEditingTextNode(textNode); | 1702 return this._startEditingTextNode(textNode); |
1703 return; | 1703 return; |
1704 } | 1704 } |
1705 }, | 1705 }, |
1706 | 1706 |
1707 _addNewAttribute: function() | 1707 _addNewAttribute: function() |
1708 { | 1708 { |
1709 // Cannot just convert the textual html into an element without | 1709 // Cannot just convert the textual html into an element without |
1710 // a parent node. Use a temporary span container for the HTML. | 1710 // a parent node. Use a temporary span container for the HTML. |
1711 var container = document.createElement("span"); | 1711 var container = createElement("span"); |
1712 this._buildAttributeDOM(container, " ", ""); | 1712 this._buildAttributeDOM(container, " ", ""); |
1713 var attr = container.firstElementChild; | 1713 var attr = container.firstElementChild; |
1714 attr.style.marginLeft = "2px"; // overrides the .editing margin rule | 1714 attr.style.marginLeft = "2px"; // overrides the .editing margin rule |
1715 attr.style.marginRight = "2px"; // overrides the .editing margin rule | 1715 attr.style.marginRight = "2px"; // overrides the .editing margin rule |
1716 | 1716 |
1717 var tag = this.listItemElement.getElementsByClassName("webkit-html-tag")
[0]; | 1717 var tag = this.listItemElement.getElementsByClassName("webkit-html-tag")
[0]; |
1718 this._insertInLastAttributePosition(tag, attr); | 1718 this._insertInLastAttributePosition(tag, attr); |
1719 attr.scrollIntoViewIfNeeded(true); | 1719 attr.scrollIntoViewIfNeeded(true); |
1720 return this._startEditingAttribute(attr, attr); | 1720 return this._startEditingAttribute(attr, attr); |
1721 }, | 1721 }, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 return; | 1895 return; |
1896 | 1896 |
1897 function consume(event) | 1897 function consume(event) |
1898 { | 1898 { |
1899 if (event.eventPhase === Event.AT_TARGET) | 1899 if (event.eventPhase === Event.AT_TARGET) |
1900 event.consume(true); | 1900 event.consume(true); |
1901 } | 1901 } |
1902 | 1902 |
1903 initialValue = this._convertWhitespaceToEntities(initialValue).text; | 1903 initialValue = this._convertWhitespaceToEntities(initialValue).text; |
1904 | 1904 |
1905 this._htmlEditElement = document.createElement("div"); | 1905 this._htmlEditElement = createElement("div"); |
1906 this._htmlEditElement.className = "source-code elements-tree-editor"; | 1906 this._htmlEditElement.className = "source-code elements-tree-editor"; |
1907 | 1907 |
1908 // Hide header items. | 1908 // Hide header items. |
1909 var child = this.listItemElement.firstChild; | 1909 var child = this.listItemElement.firstChild; |
1910 while (child) { | 1910 while (child) { |
1911 child.style.display = "none"; | 1911 child.style.display = "none"; |
1912 child = child.nextSibling; | 1912 child = child.nextSibling; |
1913 } | 1913 } |
1914 // Hide children item. | 1914 // Hide children item. |
1915 if (this._childrenListNode) | 1915 if (this._childrenListNode) |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2158 if (this._editing) | 2158 if (this._editing) |
2159 return; | 2159 return; |
2160 | 2160 |
2161 if (onlySearchQueryChanged) { | 2161 if (onlySearchQueryChanged) { |
2162 if (this._highlightResult) | 2162 if (this._highlightResult) |
2163 this._updateSearchHighlight(false); | 2163 this._updateSearchHighlight(false); |
2164 } else { | 2164 } else { |
2165 var nodeInfo = this._nodeTitleInfo(WebInspector.linkifyURLAsNode); | 2165 var nodeInfo = this._nodeTitleInfo(WebInspector.linkifyURLAsNode); |
2166 if (nodeInfo.shadowRoot) | 2166 if (nodeInfo.shadowRoot) |
2167 this.listItemElement.classList.add("shadow-root"); | 2167 this.listItemElement.classList.add("shadow-root"); |
2168 var highlightElement = document.createElement("span"); | 2168 var highlightElement = createElement("span"); |
2169 highlightElement.className = "highlight"; | 2169 highlightElement.className = "highlight"; |
2170 highlightElement.appendChild(nodeInfo.titleDOM); | 2170 highlightElement.appendChild(nodeInfo.titleDOM); |
2171 this.title = highlightElement; | 2171 this.title = highlightElement; |
2172 this._updateDecorations(); | 2172 this._updateDecorations(); |
2173 delete this._highlightResult; | 2173 delete this._highlightResult; |
2174 } | 2174 } |
2175 | 2175 |
2176 delete this.selectionElement; | 2176 delete this.selectionElement; |
2177 if (this.selected) | 2177 if (this.selected) |
2178 this.updateSelection(); | 2178 this.updateSelection(); |
(...skipping 20 matching lines...) Expand all Loading... |
2199 if (this.expanded || this._elementCloseTag) | 2199 if (this.expanded || this._elementCloseTag) |
2200 continue; | 2200 continue; |
2201 | 2201 |
2202 message = decorator.decorateAncestor(node); | 2202 message = decorator.decorateAncestor(node); |
2203 if (message) | 2203 if (message) |
2204 parentDecoratorMessages.push(message) | 2204 parentDecoratorMessages.push(message) |
2205 } | 2205 } |
2206 if (!decoratorMessages.length && !parentDecoratorMessages.length) | 2206 if (!decoratorMessages.length && !parentDecoratorMessages.length) |
2207 return null; | 2207 return null; |
2208 | 2208 |
2209 var decoratorElement = document.createElement("div"); | 2209 var decoratorElement = createElement("div"); |
2210 decoratorElement.classList.add("elements-gutter-decoration"); | 2210 decoratorElement.classList.add("elements-gutter-decoration"); |
2211 if (!decoratorMessages.length) | 2211 if (!decoratorMessages.length) |
2212 decoratorElement.classList.add("elements-has-decorated-children"); | 2212 decoratorElement.classList.add("elements-has-decorated-children"); |
2213 decoratorElement.title = decoratorMessages.concat(parentDecoratorMessage
s).join("\n"); | 2213 decoratorElement.title = decoratorMessages.concat(parentDecoratorMessage
s).join("\n"); |
2214 return decoratorElement; | 2214 return decoratorElement; |
2215 }, | 2215 }, |
2216 | 2216 |
2217 _updateDecorations: function() | 2217 _updateDecorations: function() |
2218 { | 2218 { |
2219 if (this._decoratorElement) | 2219 if (this._decoratorElement) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2283 | 2283 |
2284 /** | 2284 /** |
2285 * @this {WebInspector.ElementsTreeElement} | 2285 * @this {WebInspector.ElementsTreeElement} |
2286 * @param {string} value | 2286 * @param {string} value |
2287 * @return {!Element} | 2287 * @return {!Element} |
2288 */ | 2288 */ |
2289 function linkifyValue(value) | 2289 function linkifyValue(value) |
2290 { | 2290 { |
2291 var rewrittenHref = node.resolveURL(value); | 2291 var rewrittenHref = node.resolveURL(value); |
2292 if (rewrittenHref === null) { | 2292 if (rewrittenHref === null) { |
2293 var span = document.createElement("span"); | 2293 var span = createElement("span"); |
2294 setValueWithEntities.call(this, span, value); | 2294 setValueWithEntities.call(this, span, value); |
2295 return span; | 2295 return span; |
2296 } | 2296 } |
2297 value = value.replace(closingPunctuationRegex, "$&\u200B"); | 2297 value = value.replace(closingPunctuationRegex, "$&\u200B"); |
2298 if (value.startsWith("data:")) | 2298 if (value.startsWith("data:")) |
2299 value = value.trimMiddle(60); | 2299 value = value.trimMiddle(60); |
2300 return linkify(rewrittenHref, value, "", node.nodeName().toLowerCase
() === "a"); | 2300 return linkify(rewrittenHref, value, "", node.nodeName().toLowerCase
() === "a"); |
2301 } | 2301 } |
2302 | 2302 |
2303 if (linkify && (name === "src" || name === "href")) { | 2303 if (linkify && (name === "src" || name === "href")) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 result += text.substring(lastIndexAfterEntity); | 2387 result += text.substring(lastIndexAfterEntity); |
2388 return {text: result || text, entityRanges: entityRanges}; | 2388 return {text: result || text, entityRanges: entityRanges}; |
2389 }, | 2389 }, |
2390 | 2390 |
2391 /** | 2391 /** |
2392 * @param {function(string, string, string, boolean=, string=)=} linkify | 2392 * @param {function(string, string, string, boolean=, string=)=} linkify |
2393 */ | 2393 */ |
2394 _nodeTitleInfo: function(linkify) | 2394 _nodeTitleInfo: function(linkify) |
2395 { | 2395 { |
2396 var node = this._node; | 2396 var node = this._node; |
2397 var info = {titleDOM: document.createDocumentFragment(), hasChildren: th
is.hasChildren}; | 2397 var info = {titleDOM: createDocumentFragment(), hasChildren: this.hasChi
ldren}; |
2398 | 2398 |
2399 switch (node.nodeType()) { | 2399 switch (node.nodeType()) { |
2400 case Node.ATTRIBUTE_NODE: | 2400 case Node.ATTRIBUTE_NODE: |
2401 this._buildAttributeDOM(info.titleDOM, /** @type {string} */ (no
de.name), /** @type {string} */ (node.value), true); | 2401 this._buildAttributeDOM(info.titleDOM, /** @type {string} */ (no
de.name), /** @type {string} */ (node.value), true); |
2402 break; | 2402 break; |
2403 | 2403 |
2404 case Node.ELEMENT_NODE: | 2404 case Node.ELEMENT_NODE: |
2405 var pseudoType = node.pseudoType(); | 2405 var pseudoType = node.pseudoType(); |
2406 if (pseudoType) { | 2406 if (pseudoType) { |
2407 this._buildPseudoElementDOM(info.titleDOM, pseudoType); | 2407 this._buildPseudoElementDOM(info.titleDOM, pseudoType); |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2950 treeOutline.rootDOMNode = node; | 2950 treeOutline.rootDOMNode = node; |
2951 if (!treeOutline.children[0].hasChildren) | 2951 if (!treeOutline.children[0].hasChildren) |
2952 treeOutline._element.classList.add("single-node"); | 2952 treeOutline._element.classList.add("single-node"); |
2953 treeOutline.setVisible(true); | 2953 treeOutline.setVisible(true); |
2954 treeOutline.element.treeElementForTest = treeOutline.children[0]
; | 2954 treeOutline.element.treeElementForTest = treeOutline.children[0]
; |
2955 resolve(treeOutline.element); | 2955 resolve(treeOutline.element); |
2956 } | 2956 } |
2957 } | 2957 } |
2958 } | 2958 } |
2959 } | 2959 } |
OLD | NEW |