| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 this._includeRootDOMNode = !omitRootDOMNode; | 66 this._includeRootDOMNode = !omitRootDOMNode; |
| 67 this._selectEnabled = selectEnabled; | 67 this._selectEnabled = selectEnabled; |
| 68 /** @type {?WebInspector.DOMNode} */ | 68 /** @type {?WebInspector.DOMNode} */ |
| 69 this._rootDOMNode = null; | 69 this._rootDOMNode = null; |
| 70 /** @type {?WebInspector.DOMNode} */ | 70 /** @type {?WebInspector.DOMNode} */ |
| 71 this._selectedDOMNode = null; | 71 this._selectedDOMNode = null; |
| 72 | 72 |
| 73 this._visible = false; | 73 this._visible = false; |
| 74 this._pickNodeMode = false; | 74 this._pickNodeMode = false; |
| 75 | 75 |
| 76 this._createNodeDecorators(); | |
| 77 | |
| 78 this._popoverHelper = new WebInspector.PopoverHelper(this._element, this._ge
tPopoverAnchor.bind(this), this._showPopover.bind(this)); | 76 this._popoverHelper = new WebInspector.PopoverHelper(this._element, this._ge
tPopoverAnchor.bind(this), this._showPopover.bind(this)); |
| 79 this._popoverHelper.setTimeout(0); | 77 this._popoverHelper.setTimeout(0); |
| 80 | 78 |
| 81 /** @type {!Map<!WebInspector.DOMNode, !WebInspector.ElementsTreeOutline.Upd
ateRecord>} */ | 79 /** @type {!Map<!WebInspector.DOMNode, !WebInspector.ElementsTreeOutline.Upd
ateRecord>} */ |
| 82 this._updateRecords = new Map(); | 80 this._updateRecords = new Map(); |
| 83 /** @type {!Set<!WebInspector.ElementsTreeElement>} */ | 81 /** @type {!Set<!WebInspector.ElementsTreeElement>} */ |
| 84 this._treeElementsBeingUpdated = new Set(); | 82 this._treeElementsBeingUpdated = new Set(); |
| 83 |
| 84 this._domModel.addEventListener(WebInspector.DOMModel.Events.MarkersChanged,
this._markersChanged, this); |
| 85 } | 85 } |
| 86 | 86 |
| 87 /** @typedef {{node: !WebInspector.DOMNode, isCut: boolean}} */ | 87 /** @typedef {{node: !WebInspector.DOMNode, isCut: boolean}} */ |
| 88 WebInspector.ElementsTreeOutline.ClipboardData; | 88 WebInspector.ElementsTreeOutline.ClipboardData; |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * @enum {string} | 91 * @enum {string} |
| 92 */ | 92 */ |
| 93 WebInspector.ElementsTreeOutline.Events = { | 93 WebInspector.ElementsTreeOutline.Events = { |
| 94 NodePicked: "NodePicked", | 94 NodePicked: "NodePicked", |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 * @param {number} width | 223 * @param {number} width |
| 224 */ | 224 */ |
| 225 setVisibleWidth: function(width) | 225 setVisibleWidth: function(width) |
| 226 { | 226 { |
| 227 this._visibleWidth = width; | 227 this._visibleWidth = width; |
| 228 if (this._multilineEditing) | 228 if (this._multilineEditing) |
| 229 this._multilineEditing.setWidth(this._visibleWidth); | 229 this._multilineEditing.setWidth(this._visibleWidth); |
| 230 }, | 230 }, |
| 231 | 231 |
| 232 /** | 232 /** |
| 233 * @return {!Array<!WebInspector.ElementsTreeOutline.ElementDecorator>} | |
| 234 */ | |
| 235 nodeDecorators: function() | |
| 236 { | |
| 237 return this._nodeDecorators; | |
| 238 }, | |
| 239 | |
| 240 _createNodeDecorators: function() | |
| 241 { | |
| 242 this._nodeDecorators = []; | |
| 243 this._nodeDecorators.push(new WebInspector.ElementsTreeOutline.PseudoSta
teDecorator()); | |
| 244 }, | |
| 245 | |
| 246 /** | |
| 247 * @param {?WebInspector.ElementsTreeOutline.ClipboardData} data | 233 * @param {?WebInspector.ElementsTreeOutline.ClipboardData} data |
| 248 */ | 234 */ |
| 249 _setClipboardData: function(data) | 235 _setClipboardData: function(data) |
| 250 { | 236 { |
| 251 if (this._clipboardNodeData) { | 237 if (this._clipboardNodeData) { |
| 252 var treeElement = this.findTreeElement(this._clipboardNodeData.node)
; | 238 var treeElement = this.findTreeElement(this._clipboardNodeData.node)
; |
| 253 if (treeElement) | 239 if (treeElement) |
| 254 treeElement.setInClipboard(false); | 240 treeElement.setInClipboard(false); |
| 255 delete this._clipboardNodeData; | 241 delete this._clipboardNodeData; |
| 256 } | 242 } |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 * @param {!WebInspector.DOMNode} node | 1026 * @param {!WebInspector.DOMNode} node |
| 1041 * @param {function(?WebInspector.RemoteObject, boolean=)=} userCallback | 1027 * @param {function(?WebInspector.RemoteObject, boolean=)=} userCallback |
| 1042 */ | 1028 */ |
| 1043 toggleHideElement: function(node, userCallback) | 1029 toggleHideElement: function(node, userCallback) |
| 1044 { | 1030 { |
| 1045 var pseudoType = node.pseudoType(); | 1031 var pseudoType = node.pseudoType(); |
| 1046 var effectiveNode = pseudoType ? node.parentNode : node; | 1032 var effectiveNode = pseudoType ? node.parentNode : node; |
| 1047 if (!effectiveNode) | 1033 if (!effectiveNode) |
| 1048 return; | 1034 return; |
| 1049 | 1035 |
| 1036 var hidden = node.marker("hidden-marker"); |
| 1037 |
| 1050 function resolvedNode(object) | 1038 function resolvedNode(object) |
| 1051 { | 1039 { |
| 1052 if (!object) | 1040 if (!object) |
| 1053 return; | 1041 return; |
| 1054 | 1042 |
| 1055 /** | 1043 /** |
| 1056 * @param {?string} pseudoType | 1044 * @param {?string} pseudoType |
| 1045 * @param {boolean} hidden |
| 1057 * @suppressGlobalPropertiesCheck | 1046 * @suppressGlobalPropertiesCheck |
| 1058 * @suppressReceiverCheck | 1047 * @suppressReceiverCheck |
| 1059 * @this {!Element} | 1048 * @this {!Element} |
| 1060 */ | 1049 */ |
| 1061 function toggleClassAndInjectStyleRule(pseudoType) | 1050 function toggleClassAndInjectStyleRule(pseudoType, hidden) |
| 1062 { | 1051 { |
| 1063 const classNamePrefix = "__web-inspector-hide"; | 1052 const classNamePrefix = "__web-inspector-hide"; |
| 1064 const classNameSuffix = "-shortcut__"; | 1053 const classNameSuffix = "-shortcut__"; |
| 1065 const styleTagId = "__web-inspector-hide-shortcut-style__"; | 1054 const styleTagId = "__web-inspector-hide-shortcut-style__"; |
| 1066 var selectors = []; | 1055 var selectors = []; |
| 1067 selectors.push(".__web-inspector-hide-shortcut__"); | 1056 selectors.push(".__web-inspector-hide-shortcut__"); |
| 1068 selectors.push(".__web-inspector-hide-shortcut__ *"); | 1057 selectors.push(".__web-inspector-hide-shortcut__ *"); |
| 1069 selectors.push(".__web-inspector-hidebefore-shortcut__::before")
; | 1058 selectors.push(".__web-inspector-hidebefore-shortcut__::before")
; |
| 1070 selectors.push(".__web-inspector-hideafter-shortcut__::after"); | 1059 selectors.push(".__web-inspector-hideafter-shortcut__::after"); |
| 1071 var selector = selectors.join(", "); | 1060 var selector = selectors.join(", "); |
| 1072 var ruleBody = " visibility: hidden !important;"; | 1061 var ruleBody = " visibility: hidden !important;"; |
| 1073 var rule = "\n" + selector + "\n{\n" + ruleBody + "\n}\n"; | 1062 var rule = "\n" + selector + "\n{\n" + ruleBody + "\n}\n"; |
| 1074 var className = classNamePrefix + (pseudoType || "") + className
Suffix; | 1063 var className = classNamePrefix + (pseudoType || "") + className
Suffix; |
| 1075 this.classList.toggle(className); | 1064 this.classList.toggle(className, hidden); |
| 1076 | 1065 |
| 1077 var localRoot = this; | 1066 var localRoot = this; |
| 1078 while (localRoot.parentNode) | 1067 while (localRoot.parentNode) |
| 1079 localRoot = localRoot.parentNode; | 1068 localRoot = localRoot.parentNode; |
| 1080 if (localRoot.nodeType === Node.DOCUMENT_NODE) | 1069 if (localRoot.nodeType === Node.DOCUMENT_NODE) |
| 1081 localRoot = document.head; | 1070 localRoot = document.head; |
| 1082 | 1071 |
| 1083 var style = localRoot.querySelector("style#" + styleTagId); | 1072 var style = localRoot.querySelector("style#" + styleTagId); |
| 1084 if (style) | 1073 if (style) |
| 1085 return; | 1074 return; |
| 1086 | 1075 |
| 1087 style = document.createElement("style"); | 1076 style = document.createElement("style"); |
| 1088 style.id = styleTagId; | 1077 style.id = styleTagId; |
| 1089 style.type = "text/css"; | 1078 style.type = "text/css"; |
| 1090 style.textContent = rule; | 1079 style.textContent = rule; |
| 1091 | 1080 |
| 1092 localRoot.appendChild(style); | 1081 localRoot.appendChild(style); |
| 1093 } | 1082 } |
| 1094 | 1083 |
| 1095 object.callFunction(toggleClassAndInjectStyleRule, [{ value: pseudoT
ype }], userCallback); | 1084 object.callFunction(toggleClassAndInjectStyleRule, [{ value: pseudoT
ype }, { value: !hidden}], userCallback); |
| 1096 object.release(); | 1085 object.release(); |
| 1086 node.setMarker("hidden-marker", hidden ? null : true); |
| 1097 } | 1087 } |
| 1098 | 1088 |
| 1099 effectiveNode.resolveToObject("", resolvedNode); | 1089 effectiveNode.resolveToObject("", resolvedNode); |
| 1100 }, | 1090 }, |
| 1101 | 1091 |
| 1092 /** |
| 1093 * @param {!WebInspector.DOMNode} node |
| 1094 * @return {boolean} |
| 1095 */ |
| 1096 isToggledToHidden: function(node) |
| 1097 { |
| 1098 return !!node.marker("hidden-marker"); |
| 1099 }, |
| 1100 |
| 1102 _reset: function() | 1101 _reset: function() |
| 1103 { | 1102 { |
| 1104 this.rootDOMNode = null; | 1103 this.rootDOMNode = null; |
| 1105 this.selectDOMNode(null, false); | 1104 this.selectDOMNode(null, false); |
| 1106 this._popoverHelper.hidePopover(); | 1105 this._popoverHelper.hidePopover(); |
| 1107 delete this._clipboardNodeData; | 1106 delete this._clipboardNodeData; |
| 1108 WebInspector.DOMModel.hideDOMNodeHighlight(); | 1107 WebInspector.DOMModel.hideDOMNodeHighlight(); |
| 1109 this._updateRecords.clear(); | 1108 this._updateRecords.clear(); |
| 1110 }, | 1109 }, |
| 1111 | 1110 |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 treeElement.appendChild(new WebInspector.ElementsTreeOutline.Sho
rtcutTreeElement(distributedNode)); | 1574 treeElement.appendChild(new WebInspector.ElementsTreeOutline.Sho
rtcutTreeElement(distributedNode)); |
| 1576 } | 1575 } |
| 1577 | 1576 |
| 1578 // Insert close tag. | 1577 // Insert close tag. |
| 1579 if (node.nodeType() === Node.ELEMENT_NODE && treeElement.isExpandable()) | 1578 if (node.nodeType() === Node.ELEMENT_NODE && treeElement.isExpandable()) |
| 1580 this.insertChildElement(treeElement, node, treeElement.childCount(),
true); | 1579 this.insertChildElement(treeElement, node, treeElement.childCount(),
true); |
| 1581 | 1580 |
| 1582 this._treeElementsBeingUpdated.delete(treeElement); | 1581 this._treeElementsBeingUpdated.delete(treeElement); |
| 1583 }, | 1582 }, |
| 1584 | 1583 |
| 1584 /** |
| 1585 * @param {!WebInspector.Event} event |
| 1586 */ |
| 1587 _markersChanged: function(event) |
| 1588 { |
| 1589 var node = /** @type {!WebInspector.DOMNode} */ (event.data); |
| 1590 var treeElement = node[this._treeElementSymbol]; |
| 1591 if (treeElement) |
| 1592 treeElement.updateDecorations(); |
| 1593 }, |
| 1594 |
| 1585 __proto__: TreeOutline.prototype | 1595 __proto__: TreeOutline.prototype |
| 1586 } | 1596 } |
| 1587 | 1597 |
| 1588 /** | 1598 /** |
| 1589 * @interface | |
| 1590 */ | |
| 1591 WebInspector.ElementsTreeOutline.ElementDecorator = function() | |
| 1592 { | |
| 1593 } | |
| 1594 | |
| 1595 WebInspector.ElementsTreeOutline.ElementDecorator.prototype = { | |
| 1596 /** | |
| 1597 * @param {!WebInspector.DOMNode} node | |
| 1598 * @return {?string} | |
| 1599 */ | |
| 1600 decorate: function(node) | |
| 1601 { | |
| 1602 }, | |
| 1603 | |
| 1604 /** | |
| 1605 * @param {!WebInspector.DOMNode} node | |
| 1606 * @return {?string} | |
| 1607 */ | |
| 1608 decorateAncestor: function(node) | |
| 1609 { | |
| 1610 } | |
| 1611 } | |
| 1612 | |
| 1613 /** | |
| 1614 * @constructor | |
| 1615 * @implements {WebInspector.ElementsTreeOutline.ElementDecorator} | |
| 1616 */ | |
| 1617 WebInspector.ElementsTreeOutline.PseudoStateDecorator = function() | |
| 1618 { | |
| 1619 WebInspector.ElementsTreeOutline.ElementDecorator.call(this); | |
| 1620 } | |
| 1621 | |
| 1622 WebInspector.ElementsTreeOutline.PseudoStateDecorator.prototype = { | |
| 1623 /** | |
| 1624 * @override | |
| 1625 * @param {!WebInspector.DOMNode} node | |
| 1626 * @return {?string} | |
| 1627 */ | |
| 1628 decorate: function(node) | |
| 1629 { | |
| 1630 if (node.nodeType() !== Node.ELEMENT_NODE) | |
| 1631 return null; | |
| 1632 var propertyValue = node.getUserProperty(WebInspector.CSSStyleModel.Pseu
doStatePropertyName); | |
| 1633 if (!propertyValue) | |
| 1634 return null; | |
| 1635 return WebInspector.UIString("Element state: %s", ":" + propertyValue.jo
in(", :")); | |
| 1636 }, | |
| 1637 | |
| 1638 /** | |
| 1639 * @override | |
| 1640 * @param {!WebInspector.DOMNode} node | |
| 1641 * @return {?string} | |
| 1642 */ | |
| 1643 decorateAncestor: function(node) | |
| 1644 { | |
| 1645 if (node.nodeType() !== Node.ELEMENT_NODE) | |
| 1646 return null; | |
| 1647 | |
| 1648 var descendantCount = node.descendantUserPropertyCount(WebInspector.CSSS
tyleModel.PseudoStatePropertyName); | |
| 1649 if (!descendantCount) | |
| 1650 return null; | |
| 1651 if (descendantCount === 1) | |
| 1652 return WebInspector.UIString("%d descendant with forced state", desc
endantCount); | |
| 1653 return WebInspector.UIString("%d descendants with forced state", descend
antCount); | |
| 1654 } | |
| 1655 } | |
| 1656 | |
| 1657 /** | |
| 1658 * @constructor | 1599 * @constructor |
| 1659 */ | 1600 */ |
| 1660 WebInspector.ElementsTreeOutline.UpdateRecord = function() | 1601 WebInspector.ElementsTreeOutline.UpdateRecord = function() |
| 1661 { | 1602 { |
| 1662 } | 1603 } |
| 1663 | 1604 |
| 1664 WebInspector.ElementsTreeOutline.UpdateRecord.prototype = { | 1605 WebInspector.ElementsTreeOutline.UpdateRecord.prototype = { |
| 1665 /** | 1606 /** |
| 1666 * @param {string} attrName | 1607 * @param {string} attrName |
| 1667 */ | 1608 */ |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 if (node) { | 1824 if (node) { |
| 1884 this.treeOutline._selectedDOMNode = node; | 1825 this.treeOutline._selectedDOMNode = node; |
| 1885 this.treeOutline._selectedNodeChanged(); | 1826 this.treeOutline._selectedNodeChanged(); |
| 1886 } | 1827 } |
| 1887 } | 1828 } |
| 1888 return true; | 1829 return true; |
| 1889 }, | 1830 }, |
| 1890 | 1831 |
| 1891 __proto__: TreeElement.prototype | 1832 __proto__: TreeElement.prototype |
| 1892 } | 1833 } |
| OLD | NEW |