Chromium Code Reviews| 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 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1191 var links = this.listItemElement.querySelectorAll("li .webkit-html-tag > .webkit-html-attribute > .webkit-html-external-link, li .webkit-html-tag > .web kit-html-attribute > .webkit-html-resource-link"); | 1191 var links = this.listItemElement.querySelectorAll("li .webkit-html-tag > .webkit-html-attribute > .webkit-html-external-link, li .webkit-html-tag > .web kit-html-attribute > .webkit-html-resource-link"); |
| 1192 if (!links) | 1192 if (!links) |
| 1193 return; | 1193 return; |
| 1194 | 1194 |
| 1195 for (var i = 0; i < links.length; ++i) | 1195 for (var i = 0; i < links.length; ++i) |
| 1196 links[i].preventFollowOnDoubleClick = true; | 1196 links[i].preventFollowOnDoubleClick = true; |
| 1197 }, | 1197 }, |
| 1198 | 1198 |
| 1199 onpopulate: function() | 1199 onpopulate: function() |
| 1200 { | 1200 { |
| 1201 if (this.children.length || this._showInlineText() || this._elementClose Tag) | 1201 this.populated = true; |
| 1202 if (this.children.length || !this.hasChildren) | |
| 1202 return; | 1203 return; |
| 1203 | 1204 |
| 1204 this.updateChildren(); | 1205 this.updateChildren(); |
| 1205 }, | 1206 }, |
| 1206 | 1207 |
| 1207 /** | 1208 /** |
| 1208 * @param {boolean=} fullRefresh | 1209 * @param {boolean=} fullRefresh |
| 1209 */ | 1210 */ |
| 1210 updateChildren: function(fullRefresh) | 1211 updateChildren: function(fullRefresh) |
| 1211 { | 1212 { |
| 1212 if (this._elementCloseTag) | 1213 if (!this.hasChildren) |
| 1213 return; | 1214 return; |
| 1215 console.assert(!this._elementCloseTag); | |
| 1214 this._node.getChildNodes(this._updateChildren.bind(this, fullRefresh)); | 1216 this._node.getChildNodes(this._updateChildren.bind(this, fullRefresh)); |
| 1215 }, | 1217 }, |
| 1216 | 1218 |
| 1217 /** | 1219 /** |
| 1218 * @param {!WebInspector.DOMNode} child | 1220 * @param {!WebInspector.DOMNode} child |
| 1219 * @param {number} index | 1221 * @param {number} index |
| 1220 * @param {boolean=} closingTag | 1222 * @param {boolean=} closingTag |
| 1221 * @return {!WebInspector.ElementsTreeElement} | 1223 * @return {!WebInspector.ElementsTreeElement} |
| 1222 */ | 1224 */ |
| 1223 insertChildElement: function(child, index, closingTag) | 1225 insertChildElement: function(child, index, closingTag) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1317 this.select(); | 1319 this.select(); |
| 1318 | 1320 |
| 1319 this.removeChildAtIndex(i); | 1321 this.removeChildAtIndex(i); |
| 1320 } | 1322 } |
| 1321 | 1323 |
| 1322 var elementToSelect = updateChildrenOfNode.call(this); | 1324 var elementToSelect = updateChildrenOfNode.call(this); |
| 1323 this.updateTitle(); | 1325 this.updateTitle(); |
| 1324 this._adjustCollapsedRange(); | 1326 this._adjustCollapsedRange(); |
| 1325 | 1327 |
| 1326 var lastChild = this.children[this.children.length - 1]; | 1328 var lastChild = this.children[this.children.length - 1]; |
| 1327 if (this._node.nodeType() == Node.ELEMENT_NODE && (!lastChild || !lastCh ild._elementCloseTag)) | 1329 if (this._node.nodeType() == Node.ELEMENT_NODE && this.hasChildren) |
|
apavlov
2014/08/13 14:39:19
===
| |
| 1328 this.insertChildElement(this._node, this.children.length, true); | 1330 this.insertChildElement(this._node, this.children.length, true); |
| 1329 | 1331 |
| 1330 // We want to restore the original selection and tree scroll position af ter a full refresh, if possible. | 1332 // We want to restore the original selection and tree scroll position af ter a full refresh, if possible. |
| 1331 if (fullRefresh && elementToSelect) { | 1333 if (fullRefresh && elementToSelect) { |
| 1332 elementToSelect.select(); | 1334 elementToSelect.select(); |
| 1333 if (treeOutlineContainerElement && originalScrollTop <= treeOutlineC ontainerElement.scrollHeight) | 1335 if (treeOutlineContainerElement && originalScrollTop <= treeOutlineC ontainerElement.scrollHeight) |
| 1334 treeOutlineContainerElement.scrollTop = originalScrollTop; | 1336 treeOutlineContainerElement.scrollTop = originalScrollTop; |
| 1335 } | 1337 } |
| 1336 | 1338 |
| 1337 delete this._updateChildrenInProgress; | 1339 delete this._updateChildrenInProgress; |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2341 textNodeElement.textContent = "\u2026"; | 2343 textNodeElement.textContent = "\u2026"; |
| 2342 info.titleDOM.appendChild(document.createTextNode("\u200 B")); | 2344 info.titleDOM.appendChild(document.createTextNode("\u200 B")); |
| 2343 } | 2345 } |
| 2344 this._buildTagDOM(info.titleDOM, tagName, true, false); | 2346 this._buildTagDOM(info.titleDOM, tagName, true, false); |
| 2345 } | 2347 } |
| 2346 | 2348 |
| 2347 // If this element only has a single child that is a text node, | 2349 // If this element only has a single child that is a text node, |
| 2348 // just show that text and the closing tag inline rather than | 2350 // just show that text and the closing tag inline rather than |
| 2349 // create a subtree for them | 2351 // create a subtree for them |
| 2350 if (showInlineText) { | 2352 if (showInlineText) { |
| 2353 console.assert(!this.hasChildren); | |
| 2351 var textNodeElement = info.titleDOM.createChild("span", "web kit-html-text-node"); | 2354 var textNodeElement = info.titleDOM.createChild("span", "web kit-html-text-node"); |
| 2352 var result = this._convertWhitespaceToEntities(node.firstChi ld.nodeValue()); | 2355 var result = this._convertWhitespaceToEntities(node.firstChi ld.nodeValue()); |
| 2353 textNodeElement.textContent = result.text; | 2356 textNodeElement.textContent = result.text; |
| 2354 WebInspector.highlightRangesWithStyleClass(textNodeElement, result.entityRanges, "webkit-html-entity-value"); | 2357 WebInspector.highlightRangesWithStyleClass(textNodeElement, result.entityRanges, "webkit-html-entity-value"); |
| 2355 info.titleDOM.appendChild(document.createTextNode("\u200B")) ; | 2358 info.titleDOM.appendChild(document.createTextNode("\u200B")) ; |
| 2356 this._buildTagDOM(info.titleDOM, tagName, true, false); | 2359 this._buildTagDOM(info.titleDOM, tagName, true, false); |
| 2357 info.hasChildren = false; | 2360 info.hasChildren = false; |
| 2358 } | 2361 } |
| 2359 break; | 2362 break; |
| 2360 | 2363 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2656 this._domModel.removeEventListener(WebInspector.DOMModel.Events.NodeInse rted, this._nodeInserted, this); | 2659 this._domModel.removeEventListener(WebInspector.DOMModel.Events.NodeInse rted, this._nodeInserted, this); |
| 2657 this._domModel.removeEventListener(WebInspector.DOMModel.Events.NodeRemo ved, this._nodeRemoved, this); | 2660 this._domModel.removeEventListener(WebInspector.DOMModel.Events.NodeRemo ved, this._nodeRemoved, this); |
| 2658 this._domModel.removeEventListener(WebInspector.DOMModel.Events.AttrModi fied, this._attributesUpdated, this); | 2661 this._domModel.removeEventListener(WebInspector.DOMModel.Events.AttrModi fied, this._attributesUpdated, this); |
| 2659 this._domModel.removeEventListener(WebInspector.DOMModel.Events.AttrRemo ved, this._attributesUpdated, this); | 2662 this._domModel.removeEventListener(WebInspector.DOMModel.Events.AttrRemo ved, this._attributesUpdated, this); |
| 2660 this._domModel.removeEventListener(WebInspector.DOMModel.Events.Characte rDataModified, this._characterDataModified, this); | 2663 this._domModel.removeEventListener(WebInspector.DOMModel.Events.Characte rDataModified, this._characterDataModified, this); |
| 2661 this._domModel.removeEventListener(WebInspector.DOMModel.Events.Document Updated, this._documentUpdated, this); | 2664 this._domModel.removeEventListener(WebInspector.DOMModel.Events.Document Updated, this._documentUpdated, this); |
| 2662 this._domModel.removeEventListener(WebInspector.DOMModel.Events.ChildNod eCountUpdated, this._childNodeCountUpdated, this); | 2665 this._domModel.removeEventListener(WebInspector.DOMModel.Events.ChildNod eCountUpdated, this._childNodeCountUpdated, this); |
| 2663 }, | 2666 }, |
| 2664 | 2667 |
| 2665 /** | 2668 /** |
| 2666 * @param {!WebInspector.DOMNode} parentNode | 2669 * @param {?WebInspector.DOMNode} parentNode |
| 2667 */ | 2670 */ |
| 2668 _parentNodeModified: function(parentNode) | 2671 _parentNodeModified: function(parentNode) |
| 2669 { | 2672 { |
| 2673 if (!parentNode) | |
| 2674 return; | |
| 2675 this._recentlyModifiedParentNodes.add(parentNode); | |
| 2676 | |
| 2677 var treeElement = this._treeOutline.findTreeElement(parentNode); | |
| 2678 if (treeElement) { | |
| 2679 var oldHasChildren = treeElement.hasChildren; | |
| 2680 var oldShowInlineText = treeElement._showInlineText(); | |
| 2681 treeElement._updateHasChildren(); | |
| 2682 if (treeElement.hasChildren !== oldHasChildren || oldShowInlineText || treeElement._showInlineText()) | |
| 2683 this._nodeModified(parentNode); | |
| 2684 } | |
| 2685 | |
| 2670 if (this._treeOutline._visible) | 2686 if (this._treeOutline._visible) |
| 2671 this._updateModifiedNodesSoon(); | 2687 this._updateModifiedNodesSoon(); |
| 2672 this._recentlyModifiedParentNodes.add(parentNode); | |
| 2673 }, | 2688 }, |
| 2674 | 2689 |
| 2675 /** | 2690 /** |
| 2676 * @param {!WebInspector.DOMNode} node | 2691 * @param {!WebInspector.DOMNode} node |
| 2677 */ | 2692 */ |
| 2678 _nodeModified: function(node) | 2693 _nodeModified: function(node) |
| 2679 { | 2694 { |
| 2695 this._recentlyModifiedNodes.add(node); | |
| 2680 if (this._treeOutline._visible) | 2696 if (this._treeOutline._visible) |
| 2681 this._updateModifiedNodesSoon(); | 2697 this._updateModifiedNodesSoon(); |
| 2682 this._recentlyModifiedNodes.add(node); | |
| 2683 }, | 2698 }, |
| 2684 | 2699 |
| 2685 /** | 2700 /** |
| 2686 * @param {!WebInspector.Event} event | 2701 * @param {!WebInspector.Event} event |
| 2687 */ | 2702 */ |
| 2688 _documentUpdated: function(event) | 2703 _documentUpdated: function(event) |
| 2689 { | 2704 { |
| 2690 var inspectedRootDocument = event.data; | 2705 var inspectedRootDocument = event.data; |
| 2691 | 2706 |
| 2692 this._reset(); | 2707 this._reset(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2705 var node = /** @type {!WebInspector.DOMNode} */ (event.data.node); | 2720 var node = /** @type {!WebInspector.DOMNode} */ (event.data.node); |
| 2706 this._nodeModified(node); | 2721 this._nodeModified(node); |
| 2707 }, | 2722 }, |
| 2708 | 2723 |
| 2709 /** | 2724 /** |
| 2710 * @param {!WebInspector.Event} event | 2725 * @param {!WebInspector.Event} event |
| 2711 */ | 2726 */ |
| 2712 _characterDataModified: function(event) | 2727 _characterDataModified: function(event) |
| 2713 { | 2728 { |
| 2714 var node = /** @type {!WebInspector.DOMNode} */ (event.data); | 2729 var node = /** @type {!WebInspector.DOMNode} */ (event.data); |
| 2730 this._parentNodeModified(node.parentNode); | |
| 2715 this._nodeModified(node); | 2731 this._nodeModified(node); |
| 2716 }, | 2732 }, |
| 2717 | 2733 |
| 2718 /** | 2734 /** |
| 2719 * @param {!WebInspector.Event} event | 2735 * @param {!WebInspector.Event} event |
| 2720 */ | 2736 */ |
| 2721 _nodeInserted: function(event) | 2737 _nodeInserted: function(event) |
| 2722 { | 2738 { |
| 2723 var node = /** @type {!WebInspector.DOMNode} */ (event.data); | 2739 var node = /** @type {!WebInspector.DOMNode} */ (event.data); |
| 2724 var parentNode = /** @type {!WebInspector.DOMNode} */ (node.parentNode); | 2740 this._parentNodeModified(node.parentNode); |
| 2725 this._parentNodeModified(parentNode); | |
| 2726 }, | 2741 }, |
| 2727 | 2742 |
| 2728 /** | 2743 /** |
| 2729 * @param {!WebInspector.Event} event | 2744 * @param {!WebInspector.Event} event |
| 2730 */ | 2745 */ |
| 2731 _nodeRemoved: function(event) | 2746 _nodeRemoved: function(event) |
| 2732 { | 2747 { |
| 2733 var node = /** @type {!WebInspector.DOMNode} */ (event.data.node); | 2748 var node = /** @type {!WebInspector.DOMNode} */ (event.data.node); |
| 2734 var parentNode = /** @type {!WebInspector.DOMNode} */ (event.data.parent ); | 2749 var parentNode = /** @type {!WebInspector.DOMNode} */ (event.data.parent ); |
| 2735 this._treeOutline._resetClipboardIfNeeded(node); | 2750 this._treeOutline._resetClipboardIfNeeded(node); |
| 2736 this._parentNodeModified(parentNode); | 2751 this._parentNodeModified(parentNode); |
| 2737 }, | 2752 }, |
| 2738 | 2753 |
| 2739 /** | 2754 /** |
| 2740 * @param {!WebInspector.Event} event | 2755 * @param {!WebInspector.Event} event |
| 2741 */ | 2756 */ |
| 2742 _childNodeCountUpdated: function(event) | 2757 _childNodeCountUpdated: function(event) |
| 2743 { | 2758 { |
| 2744 var node = /** @type {!WebInspector.DOMNode} */ (event.data); | 2759 var node = /** @type {!WebInspector.DOMNode} */ (event.data); |
| 2745 var treeElement = this._treeOutline.findTreeElement(node); | 2760 this._parentNodeModified(node); |
| 2746 if (treeElement) { | |
| 2747 var oldHasChildren = treeElement.hasChildren; | |
| 2748 treeElement._updateHasChildren(); | |
| 2749 if (treeElement.hasChildren !== oldHasChildren) | |
| 2750 treeElement.updateTitle(); | |
| 2751 } | |
| 2752 }, | 2761 }, |
| 2753 | 2762 |
| 2754 _updateModifiedNodesSoon: function() | 2763 _updateModifiedNodesSoon: function() |
| 2755 { | 2764 { |
| 2756 if (this._updateModifiedNodesTimeout) | 2765 if (this._updateModifiedNodesTimeout) |
| 2757 return; | 2766 return; |
| 2758 this._updateModifiedNodesTimeout = setTimeout(this._updateModifiedNodes. bind(this), 50); | 2767 this._updateModifiedNodesTimeout = setTimeout(this._updateModifiedNodes. bind(this), 50); |
| 2759 }, | 2768 }, |
| 2760 | 2769 |
| 2761 _updateModifiedNodes: function() | 2770 _updateModifiedNodes: function() |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2780 var nodes = this._recentlyModifiedNodes.values(); | 2789 var nodes = this._recentlyModifiedNodes.values(); |
| 2781 for (var i = 0, size = nodes.length; i < size; ++i) { | 2790 for (var i = 0, size = nodes.length; i < size; ++i) { |
| 2782 var nodeItem = this._treeOutline.findTreeElement(nodes[i]); | 2791 var nodeItem = this._treeOutline.findTreeElement(nodes[i]); |
| 2783 if (nodeItem) | 2792 if (nodeItem) |
| 2784 nodeItem.updateTitle(); | 2793 nodeItem.updateTitle(); |
| 2785 } | 2794 } |
| 2786 | 2795 |
| 2787 var parentNodes = this._recentlyModifiedParentNodes.values(); | 2796 var parentNodes = this._recentlyModifiedParentNodes.values(); |
| 2788 for (var i = 0, size = parentNodes.length; i < size; ++i) { | 2797 for (var i = 0, size = parentNodes.length; i < size; ++i) { |
| 2789 var parentNodeItem = this._treeOutline.findTreeElement(parentNod es[i]); | 2798 var parentNodeItem = this._treeOutline.findTreeElement(parentNod es[i]); |
| 2790 if (parentNodeItem) | 2799 if (parentNodeItem && parentNodeItem.populated) |
| 2791 parentNodeItem.updateChildren(); | 2800 parentNodeItem.updateChildren(); |
| 2792 } | 2801 } |
| 2793 } | 2802 } |
| 2794 | 2803 |
| 2795 if (hidePanelWhileUpdating) { | 2804 if (hidePanelWhileUpdating) { |
| 2796 this._treeOutline.element.classList.remove("hidden"); | 2805 this._treeOutline.element.classList.remove("hidden"); |
| 2797 if (originalScrollTop) | 2806 if (originalScrollTop) |
| 2798 treeOutlineContainerElement.scrollTop = originalScrollTop; | 2807 treeOutlineContainerElement.scrollTop = originalScrollTop; |
| 2799 this._treeOutline.updateSelection(); | 2808 this._treeOutline.updateSelection(); |
| 2800 } | 2809 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2835 var treeOutline = new WebInspector.ElementsTreeOutline(node.target(), fa lse, false); | 2844 var treeOutline = new WebInspector.ElementsTreeOutline(node.target(), fa lse, false); |
| 2836 treeOutline.rootDOMNode = node; | 2845 treeOutline.rootDOMNode = node; |
| 2837 treeOutline.element.classList.add("outline-disclosure"); | 2846 treeOutline.element.classList.add("outline-disclosure"); |
| 2838 if (!treeOutline.children[0].hasChildren) | 2847 if (!treeOutline.children[0].hasChildren) |
| 2839 treeOutline.element.classList.add("single-node"); | 2848 treeOutline.element.classList.add("single-node"); |
| 2840 treeOutline.setVisible(true); | 2849 treeOutline.setVisible(true); |
| 2841 treeOutline.element.treeElementForTest = treeOutline.children[0]; | 2850 treeOutline.element.treeElementForTest = treeOutline.children[0]; |
| 2842 return treeOutline.element; | 2851 return treeOutline.element; |
| 2843 } | 2852 } |
| 2844 } | 2853 } |
| OLD | NEW |