Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/DOMModel.js

Issue 2819183002: [DevTools] Consolidate overlay-related functionality in Overlay domain (Closed)
Patch Set: rebased bad merge Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 for (var i = 0; i < node._shadowRoots.length; ++i) 1512 for (var i = 0; i < node._shadowRoots.length; ++i)
1533 this._unbind(node._shadowRoots[i]); 1513 this._unbind(node._shadowRoots[i]);
1534 var pseudoElements = node.pseudoElements(); 1514 var pseudoElements = node.pseudoElements();
1535 for (var value of pseudoElements.values()) 1515 for (var value of pseudoElements.values())
1536 this._unbind(value); 1516 this._unbind(value);
1537 if (node._templateContent) 1517 if (node._templateContent)
1538 this._unbind(node._templateContent); 1518 this._unbind(node._templateContent);
1539 } 1519 }
1540 1520
1541 /** 1521 /**
1542 * @param {!Protocol.DOM.BackendNodeId} backendNodeId
1543 */
1544 _inspectNodeRequested(backendNodeId) {
1545 var deferredNode = new SDK.DeferredDOMNode(this.target(), backendNodeId);
1546 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeInspected, deferredNod e);
1547 }
1548
1549 /**
1550 * @param {string} query 1522 * @param {string} query
1551 * @param {boolean} includeUserAgentShadowDOM 1523 * @param {boolean} includeUserAgentShadowDOM
1552 * @param {function(number)} searchCallback 1524 * @param {function(number)} searchCallback
1553 */ 1525 */
1554 performSearch(query, includeUserAgentShadowDOM, searchCallback) { 1526 performSearch(query, includeUserAgentShadowDOM, searchCallback) {
1555 SDK.DOMModel.cancelSearch(); 1527 SDK.DOMModel.cancelSearch();
1556 1528
1557 /** 1529 /**
1558 * @param {?Protocol.Error} error 1530 * @param {?Protocol.Error} error
1559 * @param {string} searchId 1531 * @param {string} searchId
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 /** 1642 /**
1671 * @param {!Protocol.DOM.NodeId} nodeId 1643 * @param {!Protocol.DOM.NodeId} nodeId
1672 * @param {string} selectors 1644 * @param {string} selectors
1673 * @param {function(?Array<!Protocol.DOM.NodeId>)} callback 1645 * @param {function(?Array<!Protocol.DOM.NodeId>)} callback
1674 */ 1646 */
1675 querySelectorAll(nodeId, selectors, callback) { 1647 querySelectorAll(nodeId, selectors, callback) {
1676 this._agent.querySelectorAll(nodeId, selectors, this._wrapClientCallback(cal lback)); 1648 this._agent.querySelectorAll(nodeId, selectors, this._wrapClientCallback(cal lback));
1677 } 1649 }
1678 1650
1679 /** 1651 /**
1680 * @param {!Protocol.DOM.NodeId=} nodeId
1681 * @param {string=} mode
1682 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId
1683 * @param {!Protocol.Runtime.RemoteObjectId=} objectId
1684 */
1685 highlightDOMNode(nodeId, mode, backendNodeId, objectId) {
1686 this.highlightDOMNodeWithConfig(nodeId, {mode: mode}, backendNodeId, objectI d);
1687 }
1688
1689 /**
1690 * @param {!Protocol.DOM.NodeId=} nodeId
1691 * @param {!{mode: (string|undefined), showInfo: (boolean|undefined), selector s: (string|undefined)}=} config
1692 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId
1693 * @param {!Protocol.Runtime.RemoteObjectId=} objectId
1694 */
1695 highlightDOMNodeWithConfig(nodeId, config, backendNodeId, objectId) {
1696 if (SDK.DOMModel._highlightDisabled)
1697 return;
1698 config = config || {mode: 'all', showInfo: undefined, selectors: undefined};
1699 if (this._hideDOMNodeHighlightTimeout) {
1700 clearTimeout(this._hideDOMNodeHighlightTimeout);
1701 delete this._hideDOMNodeHighlightTimeout;
1702 }
1703 var highlightConfig = this._buildHighlightConfig(config.mode);
1704 if (typeof config.showInfo !== 'undefined')
1705 highlightConfig.showInfo = config.showInfo;
1706 if (typeof config.selectors !== 'undefined')
1707 highlightConfig.selectorList = config.selectors;
1708 this._highlighter.highlightDOMNode(this.nodeForId(nodeId || 0), highlightCon fig, backendNodeId, objectId);
1709 }
1710
1711 /**
1712 * @param {!Protocol.DOM.NodeId} nodeId
1713 */
1714 highlightDOMNodeForTwoSeconds(nodeId) {
1715 this.highlightDOMNode(nodeId);
1716 this._hideDOMNodeHighlightTimeout = setTimeout(SDK.DOMModel.hideDOMNodeHighl ight.bind(SDK.DOMModel), 2000);
1717 }
1718
1719 /**
1720 * @param {!Protocol.Page.FrameId} frameId
1721 */
1722 highlightFrame(frameId) {
1723 if (SDK.DOMModel._highlightDisabled)
1724 return;
1725 this._highlighter.highlightFrame(frameId);
1726 }
1727
1728 /**
1729 * @param {!Protocol.DOM.InspectMode} mode
1730 * @param {function(?Protocol.Error)=} callback
1731 */
1732 setInspectMode(mode, callback) {
1733 /**
1734 * @this {SDK.DOMModel}
1735 */
1736 function onDocumentAvailable() {
1737 this._inspectModeEnabled = mode !== Protocol.DOM.InspectMode.None;
1738 this.dispatchEventToListeners(SDK.DOMModel.Events.InspectModeWillBeToggled , this);
1739 this._highlighter.setInspectMode(mode, this._buildHighlightConfig(), callb ack);
1740 }
1741 this.requestDocument(onDocumentAvailable.bind(this));
1742 }
1743
1744 /**
1745 * @return {boolean}
1746 */
1747 inspectModeEnabled() {
1748 return this._inspectModeEnabled;
1749 }
1750
1751 /**
1752 * @param {string=} mode
1753 * @return {!Protocol.DOM.HighlightConfig}
1754 */
1755 _buildHighlightConfig(mode) {
1756 mode = mode || 'all';
1757 var showRulers = Common.moduleSetting('showMetricsRulers').get();
1758 var highlightConfig = {showInfo: mode === 'all', showRulers: showRulers, sho wExtensionLines: showRulers};
1759 if (mode === 'all' || mode === 'content')
1760 highlightConfig.contentColor = Common.Color.PageHighlight.Content.toProtoc olRGBA();
1761
1762 if (mode === 'all' || mode === 'padding')
1763 highlightConfig.paddingColor = Common.Color.PageHighlight.Padding.toProtoc olRGBA();
1764
1765 if (mode === 'all' || mode === 'border')
1766 highlightConfig.borderColor = Common.Color.PageHighlight.Border.toProtocol RGBA();
1767
1768 if (mode === 'all' || mode === 'margin')
1769 highlightConfig.marginColor = Common.Color.PageHighlight.Margin.toProtocol RGBA();
1770
1771 if (mode === 'all') {
1772 highlightConfig.eventTargetColor = Common.Color.PageHighlight.EventTarget. toProtocolRGBA();
1773 highlightConfig.shapeColor = Common.Color.PageHighlight.Shape.toProtocolRG BA();
1774 highlightConfig.shapeMarginColor = Common.Color.PageHighlight.ShapeMargin. toProtocolRGBA();
1775 highlightConfig.displayAsMaterial = true;
1776 }
1777 return highlightConfig;
1778 }
1779
1780 /**
1781 * @param {!SDK.DOMNode} node 1652 * @param {!SDK.DOMNode} node
1782 * @param {function(?Protocol.Error, ...)=} callback 1653 * @param {function(?Protocol.Error, ...)=} callback
1783 * @return {function(...)} 1654 * @return {function(...)}
1784 * @template T 1655 * @template T
1785 */ 1656 */
1786 _markRevision(node, callback) { 1657 _markRevision(node, callback) {
1787 /** 1658 /**
1788 * @param {?Protocol.Error} error 1659 * @param {?Protocol.Error} error
1789 * @this {SDK.DOMModel} 1660 * @this {SDK.DOMModel}
1790 */ 1661 */
(...skipping 19 matching lines...) Expand all
1810 } 1681 }
1811 1682
1812 /** 1683 /**
1813 * @param {function(?Protocol.Error)=} callback 1684 * @param {function(?Protocol.Error)=} callback
1814 */ 1685 */
1815 redo(callback) { 1686 redo(callback) {
1816 this._agent.redo(callback); 1687 this._agent.redo(callback);
1817 } 1688 }
1818 1689
1819 /** 1690 /**
1820 * @param {?SDK.DOMNodeHighlighter} highlighter
1821 */
1822 setHighlighter(highlighter) {
1823 this._highlighter = highlighter || this._defaultHighlighter;
1824 }
1825
1826 /**
1827 * @param {number} x 1691 * @param {number} x
1828 * @param {number} y 1692 * @param {number} y
1829 * @param {boolean} includeUserAgentShadowDOM 1693 * @param {boolean} includeUserAgentShadowDOM
1830 * @param {function(?SDK.DOMNode)} callback 1694 * @param {function(?SDK.DOMNode)} callback
1831 */ 1695 */
1832 nodeForLocation(x, y, includeUserAgentShadowDOM, callback) { 1696 nodeForLocation(x, y, includeUserAgentShadowDOM, callback) {
1833 this._agent.getNodeForLocation(x, y, includeUserAgentShadowDOM, mycallback.b ind(this)); 1697 this._agent.getNodeForLocation(x, y, includeUserAgentShadowDOM, mycallback.b ind(this));
1834 1698
1835 /** 1699 /**
1836 * @param {?Protocol.Error} error 1700 * @param {?Protocol.Error} error
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 return new Promise(promiseBody.bind(this)); 1755 return new Promise(promiseBody.bind(this));
1892 1756
1893 /** 1757 /**
1894 * @param {function()} fulfill 1758 * @param {function()} fulfill
1895 * @this {SDK.DOMModel} 1759 * @this {SDK.DOMModel}
1896 */ 1760 */
1897 function promiseBody(fulfill) { 1761 function promiseBody(fulfill) {
1898 this._agent.enable(fulfill); 1762 this._agent.enable(fulfill);
1899 } 1763 }
1900 } 1764 }
1901
1902 /**
1903 * @param {!Protocol.DOM.NodeId} nodeId
1904 */
1905 nodeHighlightRequested(nodeId) {
1906 var node = this.nodeForId(nodeId);
1907 if (!node)
1908 return;
1909
1910 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeHighlightedInOverlay, node);
1911 }
1912 }; 1765 };
1913 1766
1914 SDK.SDKModel.register(SDK.DOMModel, SDK.Target.Capability.DOM, true); 1767 SDK.SDKModel.register(SDK.DOMModel, SDK.Target.Capability.DOM, true);
1915 1768
1916 /** @enum {symbol} */ 1769 /** @enum {symbol} */
1917 SDK.DOMModel.Events = { 1770 SDK.DOMModel.Events = {
1918 AttrModified: Symbol('AttrModified'), 1771 AttrModified: Symbol('AttrModified'),
1919 AttrRemoved: Symbol('AttrRemoved'), 1772 AttrRemoved: Symbol('AttrRemoved'),
1920 CharacterDataModified: Symbol('CharacterDataModified'), 1773 CharacterDataModified: Symbol('CharacterDataModified'),
1921 DOMMutated: Symbol('DOMMutated'), 1774 DOMMutated: Symbol('DOMMutated'),
1922 NodeInserted: Symbol('NodeInserted'), 1775 NodeInserted: Symbol('NodeInserted'),
1923 NodeInspected: Symbol('NodeInspected'),
1924 NodeHighlightedInOverlay: Symbol('NodeHighlightedInOverlay'),
1925 NodeRemoved: Symbol('NodeRemoved'), 1776 NodeRemoved: Symbol('NodeRemoved'),
1926 DocumentUpdated: Symbol('DocumentUpdated'), 1777 DocumentUpdated: Symbol('DocumentUpdated'),
1927 ChildNodeCountUpdated: Symbol('ChildNodeCountUpdated'), 1778 ChildNodeCountUpdated: Symbol('ChildNodeCountUpdated'),
1928 DistributedNodesChanged: Symbol('DistributedNodesChanged'), 1779 DistributedNodesChanged: Symbol('DistributedNodesChanged'),
1929 InspectModeWillBeToggled: Symbol('InspectModeWillBeToggled'),
1930 MarkersChanged: Symbol('MarkersChanged') 1780 MarkersChanged: Symbol('MarkersChanged')
1931 }; 1781 };
1932 1782
1933 1783
1934 /** 1784 /**
1935 * @implements {Protocol.DOMDispatcher} 1785 * @implements {Protocol.DOMDispatcher}
1936 * @unrestricted 1786 * @unrestricted
1937 */ 1787 */
1938 SDK.DOMDispatcher = class { 1788 SDK.DOMDispatcher = class {
1939 /** 1789 /**
1940 * @param {!SDK.DOMModel} domModel 1790 * @param {!SDK.DOMModel} domModel
1941 */ 1791 */
1942 constructor(domModel) { 1792 constructor(domModel) {
1943 this._domModel = domModel; 1793 this._domModel = domModel;
1944 } 1794 }
1945 1795
1946 /** 1796 /**
1947 * @override 1797 * @override
1948 */ 1798 */
1949 documentUpdated() { 1799 documentUpdated() {
1950 this._domModel._documentUpdated(); 1800 this._domModel._documentUpdated();
1951 } 1801 }
1952 1802
1953 /** 1803 /**
1954 * @override 1804 * @override
1955 * @param {!Protocol.DOM.NodeId} nodeId 1805 * @param {!Protocol.DOM.NodeId} nodeId
1956 */
1957 inspectNodeRequested(nodeId) {
1958 this._domModel._inspectNodeRequested(nodeId);
1959 }
1960
1961 /**
1962 * @override
1963 * @param {!Protocol.DOM.NodeId} nodeId
1964 * @param {string} name 1806 * @param {string} name
1965 * @param {string} value 1807 * @param {string} value
1966 */ 1808 */
1967 attributeModified(nodeId, name, value) { 1809 attributeModified(nodeId, name, value) {
1968 this._domModel._attributeModified(nodeId, name, value); 1810 this._domModel._attributeModified(nodeId, name, value);
1969 } 1811 }
1970 1812
1971 /** 1813 /**
1972 * @override 1814 * @override
1973 * @param {!Protocol.DOM.NodeId} nodeId 1815 * @param {!Protocol.DOM.NodeId} nodeId
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 } 1910 }
2069 1911
2070 /** 1912 /**
2071 * @override 1913 * @override
2072 * @param {!Protocol.DOM.NodeId} insertionPointId 1914 * @param {!Protocol.DOM.NodeId} insertionPointId
2073 * @param {!Array.<!Protocol.DOM.BackendNode>} distributedNodes 1915 * @param {!Array.<!Protocol.DOM.BackendNode>} distributedNodes
2074 */ 1916 */
2075 distributedNodesUpdated(insertionPointId, distributedNodes) { 1917 distributedNodesUpdated(insertionPointId, distributedNodes) {
2076 this._domModel._distributedNodesUpdated(insertionPointId, distributedNodes); 1918 this._domModel._distributedNodesUpdated(insertionPointId, distributedNodes);
2077 } 1919 }
2078
2079 /**
2080 * @override
2081 * @param {!Protocol.DOM.NodeId} nodeId
2082 */
2083 nodeHighlightRequested(nodeId) {
2084 this._domModel.nodeHighlightRequested(nodeId);
2085 }
2086 }; 1920 };
2087
2088 /**
2089 * @interface
2090 */
2091 SDK.DOMNodeHighlighter = function() {};
2092
2093 SDK.DOMNodeHighlighter.prototype = {
2094 /**
2095 * @param {?SDK.DOMNode} node
2096 * @param {!Protocol.DOM.HighlightConfig} config
2097 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId
2098 * @param {!Protocol.Runtime.RemoteObjectId=} objectId
2099 */
2100 highlightDOMNode(node, config, backendNodeId, objectId) {},
2101
2102 /**
2103 * @param {!Protocol.DOM.InspectMode} mode
2104 * @param {!Protocol.DOM.HighlightConfig} config
2105 * @param {function(?Protocol.Error)=} callback
2106 */
2107 setInspectMode(mode, config, callback) {},
2108
2109 /**
2110 * @param {!Protocol.Page.FrameId} frameId
2111 */
2112 highlightFrame(frameId) {}
2113 };
2114
2115 /**
2116 * @implements {SDK.DOMNodeHighlighter}
2117 * @unrestricted
2118 */
2119 SDK.DefaultDOMNodeHighlighter = class {
2120 /**
2121 * @param {!Protocol.DOMAgent} agent
2122 */
2123 constructor(agent) {
2124 this._agent = agent;
2125 }
2126
2127 /**
2128 * @override
2129 * @param {?SDK.DOMNode} node
2130 * @param {!Protocol.DOM.HighlightConfig} config
2131 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId
2132 * @param {!Protocol.Runtime.RemoteObjectId=} objectId
2133 */
2134 highlightDOMNode(node, config, backendNodeId, objectId) {
2135 if (objectId || node || backendNodeId)
2136 this._agent.highlightNode(config, (objectId || backendNodeId) ? undefined : node.id, backendNodeId, objectId);
2137 else
2138 this._agent.hideHighlight();
2139 }
2140
2141 /**
2142 * @override
2143 * @param {!Protocol.DOM.InspectMode} mode
2144 * @param {!Protocol.DOM.HighlightConfig} config
2145 * @param {function(?Protocol.Error)=} callback
2146 */
2147 setInspectMode(mode, config, callback) {
2148 this._agent.setInspectMode(mode, config, callback);
2149 }
2150
2151 /**
2152 * @override
2153 * @param {!Protocol.Page.FrameId} frameId
2154 */
2155 highlightFrame(frameId) {
2156 this._agent.highlightFrame(
2157 frameId, Common.Color.PageHighlight.Content.toProtocolRGBA(),
2158 Common.Color.PageHighlight.ContentOutline.toProtocolRGBA());
2159 }
2160 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698