OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. |
3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 return Common.ParsedURL.completeURL(frameOwnerCandidate.baseURL, url); | 833 return Common.ParsedURL.completeURL(frameOwnerCandidate.baseURL, url); |
834 } | 834 } |
835 return null; | 835 return null; |
836 } | 836 } |
837 | 837 |
838 /** | 838 /** |
839 * @param {string=} mode | 839 * @param {string=} mode |
840 * @param {!Protocol.Runtime.RemoteObjectId=} objectId | 840 * @param {!Protocol.Runtime.RemoteObjectId=} objectId |
841 */ | 841 */ |
842 highlight(mode, objectId) { | 842 highlight(mode, objectId) { |
843 this._domModel.highlightDOMNode(this.id, mode, undefined, objectId); | 843 this._domModel.overlayModel().highlightDOMNode(this.id, mode, undefined, obj
ectId); |
844 } | 844 } |
845 | 845 |
846 highlightForTwoSeconds() { | 846 highlightForTwoSeconds() { |
847 this._domModel.highlightDOMNodeForTwoSeconds(this.id); | 847 this._domModel.overlayModel().highlightDOMNodeForTwoSeconds(this.id); |
848 } | 848 } |
849 | 849 |
850 /** | 850 /** |
851 * @param {string=} objectGroup | 851 * @param {string=} objectGroup |
852 * @param {function(?SDK.RemoteObject)=} callback | 852 * @param {function(?SDK.RemoteObject)=} callback |
853 */ | 853 */ |
854 resolveToObject(objectGroup, callback) { | 854 resolveToObject(objectGroup, callback) { |
855 this._agent.resolveNode(this.id, objectGroup, mycallback.bind(this)); | 855 this._agent.resolveNode(this.id, objectGroup, mycallback.bind(this)); |
856 | 856 |
857 /** | 857 /** |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 | 1004 |
1005 /** | 1005 /** |
1006 * @return {number} | 1006 * @return {number} |
1007 */ | 1007 */ |
1008 backendNodeId() { | 1008 backendNodeId() { |
1009 return this._backendNodeId; | 1009 return this._backendNodeId; |
1010 } | 1010 } |
1011 | 1011 |
1012 highlight() { | 1012 highlight() { |
1013 if (this._domModel) | 1013 if (this._domModel) |
1014 this._domModel.highlightDOMNode(undefined, undefined, this._backendNodeId)
; | 1014 this._domModel.overlayModel().highlightDOMNode(undefined, undefined, this.
_backendNodeId); |
1015 } | 1015 } |
1016 }; | 1016 }; |
1017 | 1017 |
1018 /** | 1018 /** |
1019 * @unrestricted | 1019 * @unrestricted |
1020 */ | 1020 */ |
1021 SDK.DOMNodeShortcut = class { | 1021 SDK.DOMNodeShortcut = class { |
1022 /** | 1022 /** |
1023 * @param {!SDK.Target} target | 1023 * @param {!SDK.Target} target |
1024 * @param {number} backendNodeId | 1024 * @param {number} backendNodeId |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 this._agent = target.domAgent(); | 1061 this._agent = target.domAgent(); |
1062 | 1062 |
1063 /** @type {!Object.<number, !SDK.DOMNode>} */ | 1063 /** @type {!Object.<number, !SDK.DOMNode>} */ |
1064 this._idToDOMNode = {}; | 1064 this._idToDOMNode = {}; |
1065 /** @type {?SDK.DOMDocument} */ | 1065 /** @type {?SDK.DOMDocument} */ |
1066 this._document = null; | 1066 this._document = null; |
1067 /** @type {!Object.<number, boolean>} */ | 1067 /** @type {!Object.<number, boolean>} */ |
1068 this._attributeLoadNodeIds = {}; | 1068 this._attributeLoadNodeIds = {}; |
1069 target.registerDOMDispatcher(new SDK.DOMDispatcher(this)); | 1069 target.registerDOMDispatcher(new SDK.DOMDispatcher(this)); |
1070 | 1070 |
1071 this._inspectModeEnabled = false; | |
1072 this._runtimeModel = /** @type {!SDK.RuntimeModel} */ (target.model(SDK.Runt
imeModel)); | 1071 this._runtimeModel = /** @type {!SDK.RuntimeModel} */ (target.model(SDK.Runt
imeModel)); |
1073 | 1072 |
1074 this._defaultHighlighter = new SDK.DefaultDOMNodeHighlighter(this._agent); | |
1075 this._highlighter = this._defaultHighlighter; | |
1076 | |
1077 this._agent.enable(); | 1073 this._agent.enable(); |
1078 } | 1074 } |
1079 | 1075 |
1080 /** | 1076 /** |
1081 * @return {!SDK.RuntimeModel} | 1077 * @return {!SDK.RuntimeModel} |
1082 */ | 1078 */ |
1083 runtimeModel() { | 1079 runtimeModel() { |
1084 return this._runtimeModel; | 1080 return this._runtimeModel; |
1085 } | 1081 } |
1086 | 1082 |
1087 /** | 1083 /** |
1088 * @return {!SDK.CSSModel} | 1084 * @return {!SDK.CSSModel} |
1089 */ | 1085 */ |
1090 cssModel() { | 1086 cssModel() { |
1091 return /** @type {!SDK.CSSModel} */ (this.target().model(SDK.CSSModel)); | 1087 return /** @type {!SDK.CSSModel} */ (this.target().model(SDK.CSSModel)); |
1092 } | 1088 } |
1093 | 1089 |
1094 /** | 1090 /** |
1095 * @param {!SDK.RemoteObject} object | 1091 * @return {!SDK.OverlayModel} |
1096 */ | 1092 */ |
1097 static highlightObjectAsDOMNode(object) { | 1093 overlayModel() { |
1098 var domModel = object.runtimeModel().target().model(SDK.DOMModel); | 1094 return /** @type {!SDK.OverlayModel} */ (this.target().model(SDK.OverlayMode
l)); |
1099 if (domModel) | |
1100 domModel.highlightDOMNode(undefined, undefined, undefined, object.objectId
); | |
1101 } | |
1102 | |
1103 static hideDOMNodeHighlight() { | |
1104 for (var domModel of SDK.targetManager.models(SDK.DOMModel)) | |
1105 domModel.highlightDOMNode(0); | |
1106 } | |
1107 | |
1108 static muteHighlight() { | |
1109 SDK.DOMModel.hideDOMNodeHighlight(); | |
1110 SDK.DOMModel._highlightDisabled = true; | |
1111 } | |
1112 | |
1113 static unmuteHighlight() { | |
1114 SDK.DOMModel._highlightDisabled = false; | |
1115 } | 1095 } |
1116 | 1096 |
1117 static cancelSearch() { | 1097 static cancelSearch() { |
1118 for (var domModel of SDK.targetManager.models(SDK.DOMModel)) | 1098 for (var domModel of SDK.targetManager.models(SDK.DOMModel)) |
1119 domModel._cancelSearch(); | 1099 domModel._cancelSearch(); |
1120 } | 1100 } |
1121 | 1101 |
1122 /** | 1102 /** |
1123 * @param {!SDK.DOMNode} node | 1103 * @param {!SDK.DOMNode} node |
1124 */ | 1104 */ |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 for (var i = 0; i < node._shadowRoots.length; ++i) | 1514 for (var i = 0; i < node._shadowRoots.length; ++i) |
1535 this._unbind(node._shadowRoots[i]); | 1515 this._unbind(node._shadowRoots[i]); |
1536 var pseudoElements = node.pseudoElements(); | 1516 var pseudoElements = node.pseudoElements(); |
1537 for (var value of pseudoElements.values()) | 1517 for (var value of pseudoElements.values()) |
1538 this._unbind(value); | 1518 this._unbind(value); |
1539 if (node._templateContent) | 1519 if (node._templateContent) |
1540 this._unbind(node._templateContent); | 1520 this._unbind(node._templateContent); |
1541 } | 1521 } |
1542 | 1522 |
1543 /** | 1523 /** |
1544 * @param {!Protocol.DOM.BackendNodeId} backendNodeId | |
1545 */ | |
1546 _inspectNodeRequested(backendNodeId) { | |
1547 var deferredNode = new SDK.DeferredDOMNode(this.target(), backendNodeId); | |
1548 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeInspected, deferredNod
e); | |
1549 } | |
1550 | |
1551 /** | |
1552 * @param {string} query | 1524 * @param {string} query |
1553 * @param {boolean} includeUserAgentShadowDOM | 1525 * @param {boolean} includeUserAgentShadowDOM |
1554 * @param {function(number)} searchCallback | 1526 * @param {function(number)} searchCallback |
1555 */ | 1527 */ |
1556 performSearch(query, includeUserAgentShadowDOM, searchCallback) { | 1528 performSearch(query, includeUserAgentShadowDOM, searchCallback) { |
1557 SDK.DOMModel.cancelSearch(); | 1529 SDK.DOMModel.cancelSearch(); |
1558 | 1530 |
1559 /** | 1531 /** |
1560 * @param {?Protocol.Error} error | 1532 * @param {?Protocol.Error} error |
1561 * @param {string} searchId | 1533 * @param {string} searchId |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 /** | 1644 /** |
1673 * @param {!Protocol.DOM.NodeId} nodeId | 1645 * @param {!Protocol.DOM.NodeId} nodeId |
1674 * @param {string} selectors | 1646 * @param {string} selectors |
1675 * @param {function(!Array.<!Protocol.DOM.NodeId>=)=} callback | 1647 * @param {function(!Array.<!Protocol.DOM.NodeId>=)=} callback |
1676 */ | 1648 */ |
1677 querySelectorAll(nodeId, selectors, callback) { | 1649 querySelectorAll(nodeId, selectors, callback) { |
1678 this._agent.querySelectorAll(nodeId, selectors, this._wrapClientCallback(cal
lback)); | 1650 this._agent.querySelectorAll(nodeId, selectors, this._wrapClientCallback(cal
lback)); |
1679 } | 1651 } |
1680 | 1652 |
1681 /** | 1653 /** |
1682 * @param {!Protocol.DOM.NodeId=} nodeId | |
1683 * @param {string=} mode | |
1684 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId | |
1685 * @param {!Protocol.Runtime.RemoteObjectId=} objectId | |
1686 */ | |
1687 highlightDOMNode(nodeId, mode, backendNodeId, objectId) { | |
1688 this.highlightDOMNodeWithConfig(nodeId, {mode: mode}, backendNodeId, objectI
d); | |
1689 } | |
1690 | |
1691 /** | |
1692 * @param {!Protocol.DOM.NodeId=} nodeId | |
1693 * @param {!{mode: (string|undefined), showInfo: (boolean|undefined), selector
s: (string|undefined)}=} config | |
1694 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId | |
1695 * @param {!Protocol.Runtime.RemoteObjectId=} objectId | |
1696 */ | |
1697 highlightDOMNodeWithConfig(nodeId, config, backendNodeId, objectId) { | |
1698 if (SDK.DOMModel._highlightDisabled) | |
1699 return; | |
1700 config = config || {mode: 'all', showInfo: undefined, selectors: undefined}; | |
1701 if (this._hideDOMNodeHighlightTimeout) { | |
1702 clearTimeout(this._hideDOMNodeHighlightTimeout); | |
1703 delete this._hideDOMNodeHighlightTimeout; | |
1704 } | |
1705 var highlightConfig = this._buildHighlightConfig(config.mode); | |
1706 if (typeof config.showInfo !== 'undefined') | |
1707 highlightConfig.showInfo = config.showInfo; | |
1708 if (typeof config.selectors !== 'undefined') | |
1709 highlightConfig.selectorList = config.selectors; | |
1710 this._highlighter.highlightDOMNode(this.nodeForId(nodeId || 0), highlightCon
fig, backendNodeId, objectId); | |
1711 } | |
1712 | |
1713 /** | |
1714 * @param {!Protocol.DOM.NodeId} nodeId | |
1715 */ | |
1716 highlightDOMNodeForTwoSeconds(nodeId) { | |
1717 this.highlightDOMNode(nodeId); | |
1718 this._hideDOMNodeHighlightTimeout = setTimeout(SDK.DOMModel.hideDOMNodeHighl
ight.bind(SDK.DOMModel), 2000); | |
1719 } | |
1720 | |
1721 /** | |
1722 * @param {!Protocol.Page.FrameId} frameId | |
1723 */ | |
1724 highlightFrame(frameId) { | |
1725 if (SDK.DOMModel._highlightDisabled) | |
1726 return; | |
1727 this._highlighter.highlightFrame(frameId); | |
1728 } | |
1729 | |
1730 /** | |
1731 * @param {!Protocol.DOM.InspectMode} mode | |
1732 * @param {function(?Protocol.Error)=} callback | |
1733 */ | |
1734 setInspectMode(mode, callback) { | |
1735 /** | |
1736 * @this {SDK.DOMModel} | |
1737 */ | |
1738 function onDocumentAvailable() { | |
1739 this._inspectModeEnabled = mode !== Protocol.DOM.InspectMode.None; | |
1740 this.dispatchEventToListeners(SDK.DOMModel.Events.InspectModeWillBeToggled
, this); | |
1741 this._highlighter.setInspectMode(mode, this._buildHighlightConfig(), callb
ack); | |
1742 } | |
1743 this.requestDocument(onDocumentAvailable.bind(this)); | |
1744 } | |
1745 | |
1746 /** | |
1747 * @return {boolean} | |
1748 */ | |
1749 inspectModeEnabled() { | |
1750 return this._inspectModeEnabled; | |
1751 } | |
1752 | |
1753 /** | |
1754 * @param {string=} mode | |
1755 * @return {!Protocol.DOM.HighlightConfig} | |
1756 */ | |
1757 _buildHighlightConfig(mode) { | |
1758 mode = mode || 'all'; | |
1759 var showRulers = Common.moduleSetting('showMetricsRulers').get(); | |
1760 var highlightConfig = {showInfo: mode === 'all', showRulers: showRulers, sho
wExtensionLines: showRulers}; | |
1761 if (mode === 'all' || mode === 'content') | |
1762 highlightConfig.contentColor = Common.Color.PageHighlight.Content.toProtoc
olRGBA(); | |
1763 | |
1764 if (mode === 'all' || mode === 'padding') | |
1765 highlightConfig.paddingColor = Common.Color.PageHighlight.Padding.toProtoc
olRGBA(); | |
1766 | |
1767 if (mode === 'all' || mode === 'border') | |
1768 highlightConfig.borderColor = Common.Color.PageHighlight.Border.toProtocol
RGBA(); | |
1769 | |
1770 if (mode === 'all' || mode === 'margin') | |
1771 highlightConfig.marginColor = Common.Color.PageHighlight.Margin.toProtocol
RGBA(); | |
1772 | |
1773 if (mode === 'all') { | |
1774 highlightConfig.eventTargetColor = Common.Color.PageHighlight.EventTarget.
toProtocolRGBA(); | |
1775 highlightConfig.shapeColor = Common.Color.PageHighlight.Shape.toProtocolRG
BA(); | |
1776 highlightConfig.shapeMarginColor = Common.Color.PageHighlight.ShapeMargin.
toProtocolRGBA(); | |
1777 highlightConfig.displayAsMaterial = true; | |
1778 } | |
1779 return highlightConfig; | |
1780 } | |
1781 | |
1782 /** | |
1783 * @param {!SDK.DOMNode} node | 1654 * @param {!SDK.DOMNode} node |
1784 * @param {function(?Protocol.Error, ...)=} callback | 1655 * @param {function(?Protocol.Error, ...)=} callback |
1785 * @return {function(...)} | 1656 * @return {function(...)} |
1786 * @template T | 1657 * @template T |
1787 */ | 1658 */ |
1788 _markRevision(node, callback) { | 1659 _markRevision(node, callback) { |
1789 /** | 1660 /** |
1790 * @param {?Protocol.Error} error | 1661 * @param {?Protocol.Error} error |
1791 * @this {SDK.DOMModel} | 1662 * @this {SDK.DOMModel} |
1792 */ | 1663 */ |
(...skipping 19 matching lines...) Expand all Loading... |
1812 } | 1683 } |
1813 | 1684 |
1814 /** | 1685 /** |
1815 * @param {function(?Protocol.Error)=} callback | 1686 * @param {function(?Protocol.Error)=} callback |
1816 */ | 1687 */ |
1817 redo(callback) { | 1688 redo(callback) { |
1818 this._agent.redo(callback); | 1689 this._agent.redo(callback); |
1819 } | 1690 } |
1820 | 1691 |
1821 /** | 1692 /** |
1822 * @param {?SDK.DOMNodeHighlighter} highlighter | |
1823 */ | |
1824 setHighlighter(highlighter) { | |
1825 this._highlighter = highlighter || this._defaultHighlighter; | |
1826 } | |
1827 | |
1828 /** | |
1829 * @param {number} x | 1693 * @param {number} x |
1830 * @param {number} y | 1694 * @param {number} y |
1831 * @param {boolean} includeUserAgentShadowDOM | 1695 * @param {boolean} includeUserAgentShadowDOM |
1832 * @param {function(?SDK.DOMNode)} callback | 1696 * @param {function(?SDK.DOMNode)} callback |
1833 */ | 1697 */ |
1834 nodeForLocation(x, y, includeUserAgentShadowDOM, callback) { | 1698 nodeForLocation(x, y, includeUserAgentShadowDOM, callback) { |
1835 this._agent.getNodeForLocation(x, y, includeUserAgentShadowDOM, mycallback.b
ind(this)); | 1699 this._agent.getNodeForLocation(x, y, includeUserAgentShadowDOM, mycallback.b
ind(this)); |
1836 | 1700 |
1837 /** | 1701 /** |
1838 * @param {?Protocol.Error} error | 1702 * @param {?Protocol.Error} error |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1893 return new Promise(promiseBody.bind(this)); | 1757 return new Promise(promiseBody.bind(this)); |
1894 | 1758 |
1895 /** | 1759 /** |
1896 * @param {function()} fulfill | 1760 * @param {function()} fulfill |
1897 * @this {SDK.DOMModel} | 1761 * @this {SDK.DOMModel} |
1898 */ | 1762 */ |
1899 function promiseBody(fulfill) { | 1763 function promiseBody(fulfill) { |
1900 this._agent.enable(fulfill); | 1764 this._agent.enable(fulfill); |
1901 } | 1765 } |
1902 } | 1766 } |
1903 | |
1904 /** | |
1905 * @param {!Protocol.DOM.NodeId} nodeId | |
1906 */ | |
1907 nodeHighlightRequested(nodeId) { | |
1908 var node = this.nodeForId(nodeId); | |
1909 if (!node) | |
1910 return; | |
1911 | |
1912 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeHighlightedInOverlay,
node); | |
1913 } | |
1914 }; | 1767 }; |
1915 | 1768 |
1916 SDK.SDKModel.register(SDK.DOMModel, SDK.Target.Capability.DOM, true); | 1769 SDK.SDKModel.register(SDK.DOMModel, SDK.Target.Capability.DOM, true); |
1917 | 1770 |
1918 /** @enum {symbol} */ | 1771 /** @enum {symbol} */ |
1919 SDK.DOMModel.Events = { | 1772 SDK.DOMModel.Events = { |
1920 AttrModified: Symbol('AttrModified'), | 1773 AttrModified: Symbol('AttrModified'), |
1921 AttrRemoved: Symbol('AttrRemoved'), | 1774 AttrRemoved: Symbol('AttrRemoved'), |
1922 CharacterDataModified: Symbol('CharacterDataModified'), | 1775 CharacterDataModified: Symbol('CharacterDataModified'), |
1923 DOMMutated: Symbol('DOMMutated'), | 1776 DOMMutated: Symbol('DOMMutated'), |
1924 NodeInserted: Symbol('NodeInserted'), | 1777 NodeInserted: Symbol('NodeInserted'), |
1925 NodeInspected: Symbol('NodeInspected'), | |
1926 NodeHighlightedInOverlay: Symbol('NodeHighlightedInOverlay'), | |
1927 NodeRemoved: Symbol('NodeRemoved'), | 1778 NodeRemoved: Symbol('NodeRemoved'), |
1928 DocumentUpdated: Symbol('DocumentUpdated'), | 1779 DocumentUpdated: Symbol('DocumentUpdated'), |
1929 ChildNodeCountUpdated: Symbol('ChildNodeCountUpdated'), | 1780 ChildNodeCountUpdated: Symbol('ChildNodeCountUpdated'), |
1930 DistributedNodesChanged: Symbol('DistributedNodesChanged'), | 1781 DistributedNodesChanged: Symbol('DistributedNodesChanged'), |
1931 InspectModeWillBeToggled: Symbol('InspectModeWillBeToggled'), | |
1932 MarkersChanged: Symbol('MarkersChanged') | 1782 MarkersChanged: Symbol('MarkersChanged') |
1933 }; | 1783 }; |
1934 | 1784 |
1935 | 1785 |
1936 /** | 1786 /** |
1937 * @implements {Protocol.DOMDispatcher} | 1787 * @implements {Protocol.DOMDispatcher} |
1938 * @unrestricted | 1788 * @unrestricted |
1939 */ | 1789 */ |
1940 SDK.DOMDispatcher = class { | 1790 SDK.DOMDispatcher = class { |
1941 /** | 1791 /** |
1942 * @param {!SDK.DOMModel} domModel | 1792 * @param {!SDK.DOMModel} domModel |
1943 */ | 1793 */ |
1944 constructor(domModel) { | 1794 constructor(domModel) { |
1945 this._domModel = domModel; | 1795 this._domModel = domModel; |
1946 } | 1796 } |
1947 | 1797 |
1948 /** | 1798 /** |
1949 * @override | 1799 * @override |
1950 */ | 1800 */ |
1951 documentUpdated() { | 1801 documentUpdated() { |
1952 this._domModel._documentUpdated(); | 1802 this._domModel._documentUpdated(); |
1953 } | 1803 } |
1954 | 1804 |
1955 /** | 1805 /** |
1956 * @override | 1806 * @override |
1957 * @param {!Protocol.DOM.NodeId} nodeId | 1807 * @param {!Protocol.DOM.NodeId} nodeId |
1958 */ | |
1959 inspectNodeRequested(nodeId) { | |
1960 this._domModel._inspectNodeRequested(nodeId); | |
1961 } | |
1962 | |
1963 /** | |
1964 * @override | |
1965 * @param {!Protocol.DOM.NodeId} nodeId | |
1966 * @param {string} name | 1808 * @param {string} name |
1967 * @param {string} value | 1809 * @param {string} value |
1968 */ | 1810 */ |
1969 attributeModified(nodeId, name, value) { | 1811 attributeModified(nodeId, name, value) { |
1970 this._domModel._attributeModified(nodeId, name, value); | 1812 this._domModel._attributeModified(nodeId, name, value); |
1971 } | 1813 } |
1972 | 1814 |
1973 /** | 1815 /** |
1974 * @override | 1816 * @override |
1975 * @param {!Protocol.DOM.NodeId} nodeId | 1817 * @param {!Protocol.DOM.NodeId} nodeId |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2070 } | 1912 } |
2071 | 1913 |
2072 /** | 1914 /** |
2073 * @override | 1915 * @override |
2074 * @param {!Protocol.DOM.NodeId} insertionPointId | 1916 * @param {!Protocol.DOM.NodeId} insertionPointId |
2075 * @param {!Array.<!Protocol.DOM.BackendNode>} distributedNodes | 1917 * @param {!Array.<!Protocol.DOM.BackendNode>} distributedNodes |
2076 */ | 1918 */ |
2077 distributedNodesUpdated(insertionPointId, distributedNodes) { | 1919 distributedNodesUpdated(insertionPointId, distributedNodes) { |
2078 this._domModel._distributedNodesUpdated(insertionPointId, distributedNodes); | 1920 this._domModel._distributedNodesUpdated(insertionPointId, distributedNodes); |
2079 } | 1921 } |
2080 | |
2081 /** | |
2082 * @override | |
2083 * @param {!Protocol.DOM.NodeId} nodeId | |
2084 */ | |
2085 nodeHighlightRequested(nodeId) { | |
2086 this._domModel.nodeHighlightRequested(nodeId); | |
2087 } | |
2088 }; | 1922 }; |
2089 | |
2090 /** | |
2091 * @interface | |
2092 */ | |
2093 SDK.DOMNodeHighlighter = function() {}; | |
2094 | |
2095 SDK.DOMNodeHighlighter.prototype = { | |
2096 /** | |
2097 * @param {?SDK.DOMNode} node | |
2098 * @param {!Protocol.DOM.HighlightConfig} config | |
2099 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId | |
2100 * @param {!Protocol.Runtime.RemoteObjectId=} objectId | |
2101 */ | |
2102 highlightDOMNode(node, config, backendNodeId, objectId) {}, | |
2103 | |
2104 /** | |
2105 * @param {!Protocol.DOM.InspectMode} mode | |
2106 * @param {!Protocol.DOM.HighlightConfig} config | |
2107 * @param {function(?Protocol.Error)=} callback | |
2108 */ | |
2109 setInspectMode(mode, config, callback) {}, | |
2110 | |
2111 /** | |
2112 * @param {!Protocol.Page.FrameId} frameId | |
2113 */ | |
2114 highlightFrame(frameId) {} | |
2115 }; | |
2116 | |
2117 /** | |
2118 * @implements {SDK.DOMNodeHighlighter} | |
2119 * @unrestricted | |
2120 */ | |
2121 SDK.DefaultDOMNodeHighlighter = class { | |
2122 /** | |
2123 * @param {!Protocol.DOMAgent} agent | |
2124 */ | |
2125 constructor(agent) { | |
2126 this._agent = agent; | |
2127 } | |
2128 | |
2129 /** | |
2130 * @override | |
2131 * @param {?SDK.DOMNode} node | |
2132 * @param {!Protocol.DOM.HighlightConfig} config | |
2133 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId | |
2134 * @param {!Protocol.Runtime.RemoteObjectId=} objectId | |
2135 */ | |
2136 highlightDOMNode(node, config, backendNodeId, objectId) { | |
2137 if (objectId || node || backendNodeId) | |
2138 this._agent.highlightNode(config, (objectId || backendNodeId) ? undefined
: node.id, backendNodeId, objectId); | |
2139 else | |
2140 this._agent.hideHighlight(); | |
2141 } | |
2142 | |
2143 /** | |
2144 * @override | |
2145 * @param {!Protocol.DOM.InspectMode} mode | |
2146 * @param {!Protocol.DOM.HighlightConfig} config | |
2147 * @param {function(?Protocol.Error)=} callback | |
2148 */ | |
2149 setInspectMode(mode, config, callback) { | |
2150 this._agent.setInspectMode(mode, config, callback); | |
2151 } | |
2152 | |
2153 /** | |
2154 * @override | |
2155 * @param {!Protocol.Page.FrameId} frameId | |
2156 */ | |
2157 highlightFrame(frameId) { | |
2158 this._agent.highlightFrame( | |
2159 frameId, Common.Color.PageHighlight.Content.toProtocolRGBA(), | |
2160 Common.Color.PageHighlight.ContentOutline.toProtocolRGBA()); | |
2161 } | |
2162 }; | |
OLD | NEW |