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

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

Issue 2782773002: [DevTools] Remove SDKModels' fromTarget methods (Closed)
Patch Set: addressed review comments Created 3 years, 8 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 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 941
942 /** 942 /**
943 * @unrestricted 943 * @unrestricted
944 */ 944 */
945 SDK.DeferredDOMNode = class { 945 SDK.DeferredDOMNode = class {
946 /** 946 /**
947 * @param {!SDK.Target} target 947 * @param {!SDK.Target} target
948 * @param {number} backendNodeId 948 * @param {number} backendNodeId
949 */ 949 */
950 constructor(target, backendNodeId) { 950 constructor(target, backendNodeId) {
951 this._domModel = SDK.DOMModel.fromTarget(target); 951 this._domModel = target.model(SDK.DOMModel);
952 this._backendNodeId = backendNodeId; 952 this._backendNodeId = backendNodeId;
953 } 953 }
954 954
955 /** 955 /**
956 * @param {function(?SDK.DOMNode)} callback 956 * @param {function(?SDK.DOMNode)} callback
957 */ 957 */
958 resolve(callback) { 958 resolve(callback) {
959 if (!this._domModel) { 959 if (!this._domModel) {
960 callback(null); 960 callback(null);
961 return; 961 return;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 * @return {!SDK.CSSModel} 1079 * @return {!SDK.CSSModel}
1080 */ 1080 */
1081 cssModel() { 1081 cssModel() {
1082 return /** @type {!SDK.CSSModel} */ (this.target().model(SDK.CSSModel)); 1082 return /** @type {!SDK.CSSModel} */ (this.target().model(SDK.CSSModel));
1083 } 1083 }
1084 1084
1085 /** 1085 /**
1086 * @param {!SDK.RemoteObject} object 1086 * @param {!SDK.RemoteObject} object
1087 */ 1087 */
1088 static highlightObjectAsDOMNode(object) { 1088 static highlightObjectAsDOMNode(object) {
1089 var domModel = SDK.DOMModel.fromTarget(object.runtimeModel().target()); 1089 var domModel = object.runtimeModel().target().model(SDK.DOMModel);
1090 if (domModel) 1090 if (domModel)
1091 domModel.highlightDOMNode(undefined, undefined, undefined, object.objectId ); 1091 domModel.highlightDOMNode(undefined, undefined, undefined, object.objectId );
1092 } 1092 }
1093 1093
1094 static hideDOMNodeHighlight() { 1094 static hideDOMNodeHighlight() {
1095 for (var domModel of SDK.targetManager.models(SDK.DOMModel)) 1095 for (var domModel of SDK.targetManager.models(SDK.DOMModel))
1096 domModel.highlightDOMNode(0); 1096 domModel.highlightDOMNode(0);
1097 } 1097 }
1098 1098
1099 static muteHighlight() { 1099 static muteHighlight() {
1100 SDK.DOMModel.hideDOMNodeHighlight(); 1100 SDK.DOMModel.hideDOMNodeHighlight();
1101 SDK.DOMModel._highlightDisabled = true; 1101 SDK.DOMModel._highlightDisabled = true;
1102 } 1102 }
1103 1103
1104 static unmuteHighlight() { 1104 static unmuteHighlight() {
1105 SDK.DOMModel._highlightDisabled = false; 1105 SDK.DOMModel._highlightDisabled = false;
1106 } 1106 }
1107 1107
1108 static cancelSearch() { 1108 static cancelSearch() {
1109 for (var domModel of SDK.targetManager.models(SDK.DOMModel)) 1109 for (var domModel of SDK.targetManager.models(SDK.DOMModel))
1110 domModel._cancelSearch(); 1110 domModel._cancelSearch();
1111 } 1111 }
1112 1112
1113 /** 1113 /**
1114 * @param {!SDK.Target} target
1115 * @return {?SDK.DOMModel}
1116 */
1117 static fromTarget(target) {
1118 return target.model(SDK.DOMModel);
1119 }
1120
1121 /**
1122 * @param {!SDK.DOMNode} node 1114 * @param {!SDK.DOMNode} node
1123 */ 1115 */
1124 _scheduleMutationEvent(node) { 1116 _scheduleMutationEvent(node) {
1125 if (!this.hasEventListeners(SDK.DOMModel.Events.DOMMutated)) 1117 if (!this.hasEventListeners(SDK.DOMModel.Events.DOMMutated))
1126 return; 1118 return;
1127 1119
1128 this._lastMutationId = (this._lastMutationId || 0) + 1; 1120 this._lastMutationId = (this._lastMutationId || 0) + 1;
1129 Promise.resolve().then(callObserve.bind(this, node, this._lastMutationId)); 1121 Promise.resolve().then(callObserve.bind(this, node, this._lastMutationId));
1130 1122
1131 /** 1123 /**
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
2152 /** 2144 /**
2153 * @override 2145 * @override
2154 * @param {!Protocol.Page.FrameId} frameId 2146 * @param {!Protocol.Page.FrameId} frameId
2155 */ 2147 */
2156 highlightFrame(frameId) { 2148 highlightFrame(frameId) {
2157 this._agent.highlightFrame( 2149 this._agent.highlightFrame(
2158 frameId, Common.Color.PageHighlight.Content.toProtocolRGBA(), 2150 frameId, Common.Color.PageHighlight.Content.toProtocolRGBA(),
2159 Common.Color.PageHighlight.ContentOutline.toProtocolRGBA()); 2151 Common.Color.PageHighlight.ContentOutline.toProtocolRGBA());
2160 } 2152 }
2161 }; 2153 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698