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

Side by Side Diff: Source/devtools/front_end/sdk/Linkifier.js

Issue 404953004: DevTools: Refactor linkifyRawLocation to use fallback url (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master Created 6 years, 4 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 anchor.title = anchor.__fallbackAnchor.title; 135 anchor.title = anchor.__fallbackAnchor.title;
136 anchor.className = anchor.__fallbackAnchor.className; 136 anchor.className = anchor.__fallbackAnchor.className;
137 anchor.textContent = anchor.__fallbackAnchor.textContent; 137 anchor.textContent = anchor.__fallbackAnchor.textContent;
138 } 138 }
139 liveLocations[i].location.dispose(); 139 liveLocations[i].location.dispose();
140 } 140 }
141 }, 141 },
142 142
143 /** 143 /**
144 * @param {?WebInspector.Target} target 144 * @param {?WebInspector.Target} target
145 * @param {string} scriptId 145 * @param {?string} scriptId
146 * @param {string} sourceURL 146 * @param {string} sourceURL
147 * @param {number} lineNumber 147 * @param {number} lineNumber
148 * @param {number=} columnNumber 148 * @param {number=} columnNumber
149 * @param {string=} classes 149 * @param {string=} classes
150 * @return {?Element} 150 * @return {!Element}
151 */ 151 */
152 linkifyLocationByScriptId: function(target, scriptId, sourceURL, lineNumber, columnNumber, classes) 152 linkifyScriptLocation: function(target, scriptId, sourceURL, lineNumber, col umnNumber, classes)
153 { 153 {
154 var rawLocation = target ? target.debuggerModel.createRawLocationByScrip tId(scriptId, sourceURL, lineNumber, columnNumber || 0) : null; 154 var rawLocation = target && !target.isDetached() ? target.debuggerModel. createRawLocationByScriptId(scriptId, sourceURL, lineNumber, columnNumber || 0) : null;
155 var fallbackAnchor = WebInspector.linkifyResourceAsNode(sourceURL, lineN umber, classes); 155 var fallbackAnchor = WebInspector.linkifyResourceAsNode(sourceURL, lineN umber, classes);
156 if (!rawLocation) 156 if (!rawLocation)
157 return fallbackAnchor; 157 return fallbackAnchor;
158 158
159 var anchor = this.linkifyRawLocation(rawLocation, classes); 159 var anchor = this._createAnchor(classes);
160 var liveLocation = rawLocation.createLiveLocation(this._updateAnchor.bin d(this, anchor));
161 this._liveLocationsByTarget.get(rawLocation.target()).push({anchor: anch or, location: liveLocation});
160 anchor.__fallbackAnchor = fallbackAnchor; 162 anchor.__fallbackAnchor = fallbackAnchor;
161 return anchor; 163 return anchor;
162
163 },
164
165 /**
166 * @param {!WebInspector.Target} target
167 * @param {string} sourceURL
168 * @param {number} lineNumber
169 * @param {number=} columnNumber
170 * @param {string=} classes
171 * @return {?Element}
172 */
173 linkifyLocation: function(target, sourceURL, lineNumber, columnNumber, class es)
174 {
175 var rawLocation = target.debuggerModel.createRawLocationByURL(sourceURL, lineNumber, columnNumber || 0);
176 if (!rawLocation)
177 return WebInspector.linkifyResourceAsNode(sourceURL, lineNumber, cla sses);
178 return this.linkifyRawLocation(rawLocation, classes);
179 }, 164 },
180 165
181 /** 166 /**
182 * @param {!WebInspector.DebuggerModel.Location} rawLocation 167 * @param {!WebInspector.DebuggerModel.Location} rawLocation
168 * @param {string} fallbackUrl
183 * @param {string=} classes 169 * @param {string=} classes
184 * @return {?Element} 170 * @return {!Element}
185 */ 171 */
186 linkifyRawLocation: function(rawLocation, classes) 172 linkifyRawLocation: function(rawLocation, fallbackUrl, classes)
187 { 173 {
188 // FIXME: this check should not be here. 174 return this.linkifyScriptLocation(rawLocation.target(), rawLocation.scri ptId, fallbackUrl, rawLocation.lineNumber, rawLocation.columnNumber, classes);
189 var script = rawLocation.target().debuggerModel.scriptForId(rawLocation. scriptId);
190 if (!script)
191 return null;
192 var anchor = this._createAnchor(classes);
193 var liveLocation = WebInspector.debuggerWorkspaceBinding.createLiveLocat ion(rawLocation, this._updateAnchor.bind(this, anchor));
194 this._liveLocationsByTarget.get(rawLocation.target()).push({anchor: anch or, location: liveLocation});
195 return anchor;
196 }, 175 },
197 176
198 /** 177 /**
199 * @param {!WebInspector.CSSLocation} rawLocation 178 * @param {!WebInspector.CSSLocation} rawLocation
200 * @param {string=} classes 179 * @param {string=} classes
201 * @return {?Element} 180 * @return {?Element}
202 */ 181 */
203 linkifyCSSLocation: function(rawLocation, classes) 182 linkifyCSSLocation: function(rawLocation, classes)
204 { 183 {
205 var anchor = this._createAnchor(classes); 184 var anchor = this._createAnchor(classes);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 */ 337 */
359 WebInspector.Linkifier.liveLocationText = function(target, scriptId, lineNumber, columnNumber) 338 WebInspector.Linkifier.liveLocationText = function(target, scriptId, lineNumber, columnNumber)
360 { 339 {
361 var script = target.debuggerModel.scriptForId(scriptId); 340 var script = target.debuggerModel.scriptForId(scriptId);
362 if (!script) 341 if (!script)
363 return ""; 342 return "";
364 var location = /** @type {!WebInspector.DebuggerModel.Location} */ (target.d ebuggerModel.createRawLocation(script, lineNumber, columnNumber || 0)); 343 var location = /** @type {!WebInspector.DebuggerModel.Location} */ (target.d ebuggerModel.createRawLocation(script, lineNumber, columnNumber || 0));
365 var uiLocation = /** @type {!WebInspector.UILocation} */ (WebInspector.debug gerWorkspaceBinding.rawLocationToUILocation(location)); 344 var uiLocation = /** @type {!WebInspector.UILocation} */ (WebInspector.debug gerWorkspaceBinding.rawLocationToUILocation(location));
366 return uiLocation.linkText(); 345 return uiLocation.linkText();
367 } 346 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698