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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 return null; | 827 return null; |
828 if (descendantCount === 1) | 828 if (descendantCount === 1) |
829 return WebInspector.UIString("%d descendant with forced state", desc
endantCount); | 829 return WebInspector.UIString("%d descendant with forced state", desc
endantCount); |
830 return WebInspector.UIString("%d descendants with forced state", descend
antCount); | 830 return WebInspector.UIString("%d descendants with forced state", descend
antCount); |
831 } | 831 } |
832 } | 832 } |
833 | 833 |
834 /** | 834 /** |
835 * @constructor | 835 * @constructor |
836 * @extends {TreeElement} | 836 * @extends {TreeElement} |
| 837 * @param {!WebInspector.DOMNode} node |
837 * @param {boolean=} elementCloseTag | 838 * @param {boolean=} elementCloseTag |
838 */ | 839 */ |
839 WebInspector.ElementsTreeElement = function(node, elementCloseTag) | 840 WebInspector.ElementsTreeElement = function(node, elementCloseTag) |
840 { | 841 { |
841 // The title will be updated in onattach. | 842 // The title will be updated in onattach. |
842 TreeElement.call(this, "", node); | 843 TreeElement.call(this, "", node); |
843 this._node = node; | 844 this._node = node; |
844 | 845 |
845 this._elementCloseTag = elementCloseTag; | 846 this._elementCloseTag = elementCloseTag; |
846 this._updateHasChildren(); | 847 this._updateHasChildren(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 * @param {boolean=} fullRefresh | 1053 * @param {boolean=} fullRefresh |
1053 */ | 1054 */ |
1054 updateChildren: function(fullRefresh) | 1055 updateChildren: function(fullRefresh) |
1055 { | 1056 { |
1056 if (this._elementCloseTag) | 1057 if (this._elementCloseTag) |
1057 return; | 1058 return; |
1058 this._node.getChildNodes(this._updateChildren.bind(this, fullRefresh)); | 1059 this._node.getChildNodes(this._updateChildren.bind(this, fullRefresh)); |
1059 }, | 1060 }, |
1060 | 1061 |
1061 /** | 1062 /** |
| 1063 * @param {!WebInspector.DOMNode} child |
| 1064 * @param {number} index |
1062 * @param {boolean=} closingTag | 1065 * @param {boolean=} closingTag |
1063 * @return {!WebInspector.ElementsTreeElement} | 1066 * @return {!WebInspector.ElementsTreeElement} |
1064 */ | 1067 */ |
1065 insertChildElement: function(child, index, closingTag) | 1068 insertChildElement: function(child, index, closingTag) |
1066 { | 1069 { |
1067 var newElement = new WebInspector.ElementsTreeElement(child, closingTag)
; | 1070 var newElement = new WebInspector.ElementsTreeElement(child, closingTag)
; |
1068 newElement.selectable = this.treeOutline._selectEnabled; | 1071 newElement.selectable = this.treeOutline._selectEnabled; |
1069 this.insertChild(newElement, index); | 1072 this.insertChild(newElement, index); |
1070 return newElement; | 1073 return newElement; |
1071 }, | 1074 }, |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 } | 1664 } |
1662 | 1665 |
1663 tagNameElement.addEventListener('keyup', keyupListener, false); | 1666 tagNameElement.addEventListener('keyup', keyupListener, false); |
1664 | 1667 |
1665 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind(
this), editingCancelled.bind(this), tagName); | 1668 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind(
this), editingCancelled.bind(this), tagName); |
1666 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement,
config); | 1669 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement,
config); |
1667 window.getSelection().setBaseAndExtent(tagNameElement, 0, tagNameElement
, 1); | 1670 window.getSelection().setBaseAndExtent(tagNameElement, 0, tagNameElement
, 1); |
1668 return true; | 1671 return true; |
1669 }, | 1672 }, |
1670 | 1673 |
| 1674 /** |
| 1675 * @param {function(string, string)} commitCallback |
| 1676 * @param {?Protocol.Error} error |
| 1677 * @param {string} initialValue |
| 1678 */ |
1671 _startEditingAsHTML: function(commitCallback, error, initialValue) | 1679 _startEditingAsHTML: function(commitCallback, error, initialValue) |
1672 { | 1680 { |
1673 if (error) | 1681 if (error) |
1674 return; | 1682 return; |
1675 if (this._editing) | 1683 if (this._editing) |
1676 return; | 1684 return; |
1677 | 1685 |
1678 function consume(event) | 1686 function consume(event) |
1679 { | 1687 { |
1680 if (event.eventPhase === Event.AT_TARGET) | 1688 if (event.eventPhase === Event.AT_TARGET) |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2144 /** | 2152 /** |
2145 * @param {function(string, string, string, boolean=, string=)=} linkify | 2153 * @param {function(string, string, string, boolean=, string=)=} linkify |
2146 */ | 2154 */ |
2147 _nodeTitleInfo: function(linkify) | 2155 _nodeTitleInfo: function(linkify) |
2148 { | 2156 { |
2149 var node = this._node; | 2157 var node = this._node; |
2150 var info = {titleDOM: document.createDocumentFragment(), hasChildren: th
is.hasChildren}; | 2158 var info = {titleDOM: document.createDocumentFragment(), hasChildren: th
is.hasChildren}; |
2151 | 2159 |
2152 switch (node.nodeType()) { | 2160 switch (node.nodeType()) { |
2153 case Node.ATTRIBUTE_NODE: | 2161 case Node.ATTRIBUTE_NODE: |
2154 this._buildAttributeDOM(info.titleDOM, node.name, node.value, tr
ue); | 2162 this._buildAttributeDOM(info.titleDOM, /** @type {string} */ (no
de.name), /** @type {string} */ (node.value), true); |
2155 break; | 2163 break; |
2156 | 2164 |
2157 case Node.ELEMENT_NODE: | 2165 case Node.ELEMENT_NODE: |
2158 if (node.pseudoType()) { | 2166 var pseudoType = node.pseudoType(); |
2159 this._buildPseudoElementDOM(info.titleDOM, node.pseudoType()
); | 2167 if (pseudoType) { |
| 2168 this._buildPseudoElementDOM(info.titleDOM, pseudoType); |
2160 info.hasChildren = false; | 2169 info.hasChildren = false; |
2161 break; | 2170 break; |
2162 } | 2171 } |
2163 | 2172 |
2164 var tagName = node.nodeNameInCorrectCase(); | 2173 var tagName = node.nodeNameInCorrectCase(); |
2165 if (this._elementCloseTag) { | 2174 if (this._elementCloseTag) { |
2166 this._buildTagDOM(info.titleDOM, tagName, true, true); | 2175 this._buildTagDOM(info.titleDOM, tagName, true, true); |
2167 info.hasChildren = false; | 2176 info.hasChildren = false; |
2168 break; | 2177 break; |
2169 } | 2178 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2279 | 2288 |
2280 remove: function() | 2289 remove: function() |
2281 { | 2290 { |
2282 if (this._node.pseudoType()) | 2291 if (this._node.pseudoType()) |
2283 return; | 2292 return; |
2284 var parentElement = this.parent; | 2293 var parentElement = this.parent; |
2285 if (!parentElement) | 2294 if (!parentElement) |
2286 return; | 2295 return; |
2287 | 2296 |
2288 var self = this; | 2297 var self = this; |
2289 function removeNodeCallback(error, removedNodeId) | 2298 function removeNodeCallback(error) |
2290 { | 2299 { |
2291 if (error) | 2300 if (error) |
2292 return; | 2301 return; |
2293 | 2302 |
2294 parentElement.removeChild(self); | 2303 parentElement.removeChild(self); |
2295 parentElement._adjustCollapsedRange(); | 2304 parentElement._adjustCollapsedRange(); |
2296 } | 2305 } |
2297 | 2306 |
2298 if (!this._node.parentNode || this._node.parentNode.nodeType() === Node.
DOCUMENT_NODE) | 2307 if (!this._node.parentNode || this._node.parentNode.nodeType() === Node.
DOCUMENT_NODE) |
2299 return; | 2308 return; |
2300 this._node.removeNode(removeNodeCallback); | 2309 this._node.removeNode(removeNodeCallback); |
2301 }, | 2310 }, |
2302 | 2311 |
2303 _editAsHTML: function() | 2312 _editAsHTML: function() |
2304 { | 2313 { |
2305 var node = this._node; | 2314 var node = this._node; |
2306 if (node.pseudoType()) | 2315 if (node.pseudoType()) |
2307 return; | 2316 return; |
2308 | 2317 |
2309 var treeOutline = this.treeOutline; | 2318 var treeOutline = this.treeOutline; |
2310 var parentNode = node.parentNode; | 2319 var parentNode = node.parentNode; |
2311 var index = node.index; | 2320 var index = node.index; |
2312 var wasExpanded = this.expanded; | 2321 var wasExpanded = this.expanded; |
2313 | 2322 |
2314 function selectNode(error, nodeId) | 2323 /** |
| 2324 * @param {?Protocol.Error} error |
| 2325 */ |
| 2326 function selectNode(error) |
2315 { | 2327 { |
2316 if (error) | 2328 if (error) |
2317 return; | 2329 return; |
2318 | 2330 |
2319 // Select it and expand if necessary. We force tree update so that i
t processes dom events and is up to date. | 2331 // Select it and expand if necessary. We force tree update so that i
t processes dom events and is up to date. |
2320 treeOutline._updateModifiedNodes(); | 2332 treeOutline._updateModifiedNodes(); |
2321 | 2333 |
2322 var newNode = parentNode ? parentNode.children()[index] || parentNod
e : null; | 2334 var newNode = parentNode ? parentNode.children()[index] || parentNod
e : null; |
2323 if (!newNode) | 2335 if (!newNode) |
2324 return; | 2336 return; |
2325 | 2337 |
2326 treeOutline.selectDOMNode(newNode, true); | 2338 treeOutline.selectDOMNode(newNode, true); |
2327 | 2339 |
2328 if (wasExpanded) { | 2340 if (wasExpanded) { |
2329 var newTreeItem = treeOutline.findTreeElement(newNode); | 2341 var newTreeItem = treeOutline.findTreeElement(newNode); |
2330 if (newTreeItem) | 2342 if (newTreeItem) |
2331 newTreeItem.expand(); | 2343 newTreeItem.expand(); |
2332 } | 2344 } |
2333 } | 2345 } |
2334 | 2346 |
| 2347 /** |
| 2348 * @param {string} initialValue |
| 2349 * @param {string} value |
| 2350 */ |
2335 function commitChange(initialValue, value) | 2351 function commitChange(initialValue, value) |
2336 { | 2352 { |
2337 if (initialValue !== value) | 2353 if (initialValue !== value) |
2338 node.setOuterHTML(value, selectNode); | 2354 node.setOuterHTML(value, selectNode); |
2339 else | |
2340 return; | |
2341 } | 2355 } |
2342 | 2356 |
2343 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange)); | 2357 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange)); |
2344 }, | 2358 }, |
2345 | 2359 |
2346 _copyHTML: function() | 2360 _copyHTML: function() |
2347 { | 2361 { |
2348 this._node.copyNode(); | 2362 this._node.copyNode(); |
2349 }, | 2363 }, |
2350 | 2364 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 } | 2414 } |
2401 | 2415 |
2402 if (object) | 2416 if (object) |
2403 object.callFunction(scrollIntoView); | 2417 object.callFunction(scrollIntoView); |
2404 } | 2418 } |
2405 | 2419 |
2406 this._node.resolveToObject("", scrollIntoViewCallback); | 2420 this._node.resolveToObject("", scrollIntoViewCallback); |
2407 }, | 2421 }, |
2408 | 2422 |
2409 /** | 2423 /** |
2410 * @return {!Array.<!WebInspector.DOMModel>} | 2424 * @return {!Array.<!WebInspector.DOMNode>} |
2411 */ | 2425 */ |
2412 _visibleShadowRoots: function() | 2426 _visibleShadowRoots: function() |
2413 { | 2427 { |
2414 var roots = this._node.shadowRoots(); | 2428 var roots = this._node.shadowRoots(); |
2415 if (roots.length && !WebInspector.settings.showUAShadowDOM.get()) { | 2429 if (roots.length && !WebInspector.settings.showUAShadowDOM.get()) { |
2416 roots = roots.filter(function(root) { | 2430 roots = roots.filter(function(root) { |
2417 return root.shadowRootType() === WebInspector.DOMNode.ShadowRoot
Types.Author; | 2431 return root.shadowRootType() === WebInspector.DOMNode.ShadowRoot
Types.Author; |
2418 }); | 2432 }); |
2419 } | 2433 } |
2420 return roots; | 2434 return roots; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2667 var treeOutline = new WebInspector.ElementsTreeOutline(node.target(), fa
lse, false); | 2681 var treeOutline = new WebInspector.ElementsTreeOutline(node.target(), fa
lse, false); |
2668 treeOutline.rootDOMNode = node; | 2682 treeOutline.rootDOMNode = node; |
2669 treeOutline.element.classList.add("outline-disclosure"); | 2683 treeOutline.element.classList.add("outline-disclosure"); |
2670 if (!treeOutline.children[0].hasChildren) | 2684 if (!treeOutline.children[0].hasChildren) |
2671 treeOutline.element.classList.add("single-node"); | 2685 treeOutline.element.classList.add("single-node"); |
2672 treeOutline.setVisible(true); | 2686 treeOutline.setVisible(true); |
2673 treeOutline.element.treeElementForTest = treeOutline.children[0]; | 2687 treeOutline.element.treeElementForTest = treeOutline.children[0]; |
2674 return treeOutline.element; | 2688 return treeOutline.element; |
2675 } | 2689 } |
2676 } | 2690 } |
OLD | NEW |