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

Side by Side Diff: Source/devtools/front_end/bindings/CSSWorkspaceBinding.js

Issue 471433004: DevTools: Split out the "workspace" and "bindings" modules from "sdk" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove marker interfaces and WI.SourceMapping 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {WebInspector.TargetManager.Observer} 7 * @implements {WebInspector.TargetManager.Observer}
8 */ 8 */
9 WebInspector.CSSWorkspaceBinding = function() 9 WebInspector.CSSWorkspaceBinding = function()
10 { 10 {
(...skipping 16 matching lines...) Expand all
27 /** 27 /**
28 * @param {!WebInspector.Target} target 28 * @param {!WebInspector.Target} target
29 */ 29 */
30 targetRemoved: function(target) 30 targetRemoved: function(target)
31 { 31 {
32 this._targetToTargetInfo.remove(target)._dispose(); 32 this._targetToTargetInfo.remove(target)._dispose();
33 }, 33 },
34 34
35 /** 35 /**
36 * @param {!WebInspector.CSSStyleSheetHeader} header 36 * @param {!WebInspector.CSSStyleSheetHeader} header
37 * @param {!WebInspector.SourceMapping} mapping 37 * @param {!WebInspector.CSSSourceMapping} mapping
38 */ 38 */
39 pushSourceMapping: function(header, mapping) 39 pushSourceMapping: function(header, mapping)
40 { 40 {
41 this._ensureInfoForHeader(header)._pushSourceMapping(mapping); 41 this._ensureInfoForHeader(header)._pushSourceMapping(mapping);
42 }, 42 },
43 43
44 /** 44 /**
45 * @param {!WebInspector.CSSStyleSheetHeader} header 45 * @param {!WebInspector.CSSStyleSheetHeader} header
46 * @return {?WebInspector.CSSWorkspaceBinding.HeaderInfo} 46 * @return {?WebInspector.CSSWorkspaceBinding.HeaderInfo}
47 */ 47 */
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 243 }
244 244
245 /** 245 /**
246 * @constructor 246 * @constructor
247 * @param {!WebInspector.CSSStyleSheetHeader} header 247 * @param {!WebInspector.CSSStyleSheetHeader} header
248 */ 248 */
249 WebInspector.CSSWorkspaceBinding.HeaderInfo = function(header) 249 WebInspector.CSSWorkspaceBinding.HeaderInfo = function(header)
250 { 250 {
251 this._header = header; 251 this._header = header;
252 252
253 /** @type {!Array.<!WebInspector.SourceMapping>} */ 253 /** @type {!Array.<!WebInspector.CSSSourceMapping>} */
254 this._sourceMappings = []; 254 this._sourceMappings = [];
255 255
256 /** @type {!Set.<!WebInspector.LiveLocation>} */ 256 /** @type {!Set.<!WebInspector.LiveLocation>} */
257 this._locations = new Set(); 257 this._locations = new Set();
258 } 258 }
259 259
260 WebInspector.CSSWorkspaceBinding.HeaderInfo.prototype = { 260 WebInspector.CSSWorkspaceBinding.HeaderInfo.prototype = {
261 /** 261 /**
262 * @param {!WebInspector.LiveLocation} location 262 * @param {!WebInspector.LiveLocation} location
263 */ 263 */
(...skipping 26 matching lines...) Expand all
290 _rawLocationToUILocation: function(lineNumber, columnNumber) 290 _rawLocationToUILocation: function(lineNumber, columnNumber)
291 { 291 {
292 var uiLocation = null; 292 var uiLocation = null;
293 var rawLocation = new WebInspector.CSSLocation(this._header.target(), th is._header.id, this._header.resourceURL(), lineNumber, columnNumber); 293 var rawLocation = new WebInspector.CSSLocation(this._header.target(), th is._header.id, this._header.resourceURL(), lineNumber, columnNumber);
294 for (var i = this._sourceMappings.length - 1; !uiLocation && i >= 0; --i ) 294 for (var i = this._sourceMappings.length - 1; !uiLocation && i >= 0; --i )
295 uiLocation = this._sourceMappings[i].rawLocationToUILocation(rawLoca tion); 295 uiLocation = this._sourceMappings[i].rawLocationToUILocation(rawLoca tion);
296 return uiLocation; 296 return uiLocation;
297 }, 297 },
298 298
299 /** 299 /**
300 * @param {!WebInspector.SourceMapping} sourceMapping 300 * @param {!WebInspector.CSSSourceMapping} sourceMapping
301 */ 301 */
302 _pushSourceMapping: function(sourceMapping) 302 _pushSourceMapping: function(sourceMapping)
303 { 303 {
304 this._sourceMappings.push(sourceMapping); 304 this._sourceMappings.push(sourceMapping);
305 this._updateLocations(); 305 this._updateLocations();
306 } 306 }
307 } 307 }
308 308
309 /** 309 /**
310 * @constructor 310 * @constructor
311 * @extends {WebInspector.LiveLocation} 311 * @extends {WebInspector.LiveLocation}
312 * @param {!WebInspector.CSSStyleModel} cssModel 312 * @param {!WebInspector.CSSStyleModel} cssModel
313 * @param {?WebInspector.CSSStyleSheetHeader} header 313 * @param {?WebInspector.CSSStyleSheetHeader} header
314 * @param {!WebInspector.CSSLocation} rawLocation 314 * @param {!WebInspector.CSSLocation} rawLocation
315 * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegat e 315 * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegat e
316 */ 316 */
317 WebInspector.CSSWorkspaceBinding.LiveLocation = function(cssModel, header, rawLo cation, updateDelegate) 317 WebInspector.CSSWorkspaceBinding.LiveLocation = function(cssModel, header, rawLo cation, updateDelegate)
318 { 318 {
319 WebInspector.LiveLocation.call(this, rawLocation, updateDelegate); 319 WebInspector.LiveLocation.call(this, updateDelegate);
320 this._cssModel = cssModel; 320 this._cssModel = cssModel;
321 this._rawLocation = rawLocation;
321 if (!header) 322 if (!header)
322 this._clearStyleSheet(); 323 this._clearStyleSheet();
323 else 324 else
324 this._setStyleSheet(header); 325 this._setStyleSheet(header);
325 } 326 }
326 327
327 WebInspector.CSSWorkspaceBinding.LiveLocation.prototype = { 328 WebInspector.CSSWorkspaceBinding.LiveLocation.prototype = {
328 /** 329 /**
329 * @param {!WebInspector.Event} event 330 * @param {!WebInspector.Event} event
330 */ 331 */
331 _styleSheetAdded: function(event) 332 _styleSheetAdded: function(event)
332 { 333 {
333 console.assert(!this._header); 334 console.assert(!this._header);
334 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a); 335 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a);
335 if (header.sourceURL && header.sourceURL === this.rawLocation().url) 336 if (header.sourceURL && header.sourceURL === this._rawLocation.url)
336 this._setStyleSheet(header); 337 this._setStyleSheet(header);
337 }, 338 },
338 339
339 /** 340 /**
340 * @param {!WebInspector.Event} event 341 * @param {!WebInspector.Event} event
341 */ 342 */
342 _styleSheetRemoved: function(event) 343 _styleSheetRemoved: function(event)
343 { 344 {
344 console.assert(this._header); 345 console.assert(this._header);
345 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a); 346 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a);
(...skipping 19 matching lines...) Expand all
365 delete this._header; 366 delete this._header;
366 this._cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Sty leSheetRemoved, this._styleSheetRemoved, this); 367 this._cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Sty leSheetRemoved, this._styleSheetRemoved, this);
367 this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleS heetAdded, this._styleSheetAdded, this); 368 this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleS heetAdded, this._styleSheetAdded, this);
368 }, 369 },
369 370
370 /** 371 /**
371 * @return {?WebInspector.UILocation} 372 * @return {?WebInspector.UILocation}
372 */ 373 */
373 uiLocation: function() 374 uiLocation: function()
374 { 375 {
375 var cssLocation = /** @type WebInspector.CSSLocation */ (this.rawLocatio n()); 376 var cssLocation = this._rawLocation;
376 if (this._header) { 377 if (this._header) {
377 var headerInfo = WebInspector.cssWorkspaceBinding._headerInfo(this._ header); 378 var headerInfo = WebInspector.cssWorkspaceBinding._headerInfo(this._ header);
378 return headerInfo._rawLocationToUILocation(cssLocation.lineNumber, c ssLocation.columnNumber); 379 return headerInfo._rawLocationToUILocation(cssLocation.lineNumber, c ssLocation.columnNumber);
379 } 380 }
380 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(cssLocation .url); 381 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(cssLocation .url);
381 if (!uiSourceCode) 382 if (!uiSourceCode)
382 return null; 383 return null;
383 return uiSourceCode.uiLocation(cssLocation.lineNumber, cssLocation.colum nNumber); 384 return uiSourceCode.uiLocation(cssLocation.lineNumber, cssLocation.colum nNumber);
384 }, 385 },
385 386
386 dispose: function() 387 dispose: function()
387 { 388 {
388 WebInspector.LiveLocation.prototype.dispose.call(this); 389 WebInspector.LiveLocation.prototype.dispose.call(this);
389 if (this._header) 390 if (this._header)
390 WebInspector.cssWorkspaceBinding._removeLiveLocation(this); 391 WebInspector.cssWorkspaceBinding._removeLiveLocation(this);
391 this._cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Sty leSheetAdded, this._styleSheetAdded, this); 392 this._cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Sty leSheetAdded, this._styleSheetAdded, this);
392 this._cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Sty leSheetRemoved, this._styleSheetRemoved, this); 393 this._cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Sty leSheetRemoved, this._styleSheetRemoved, this);
393 }, 394 },
394 395
395 __proto__: WebInspector.LiveLocation.prototype 396 __proto__: WebInspector.LiveLocation.prototype
396 } 397 }
397 398
398 /** 399 /**
400 * @interface
401 */
402 WebInspector.CSSSourceMapping = function()
403 {
404 }
405
406 WebInspector.CSSSourceMapping.prototype = {
407 /**
408 * @param {!WebInspector.CSSLocation} rawLocation
409 * @return {?WebInspector.UILocation}
410 */
411 rawLocationToUILocation: function(rawLocation) { },
412
413 /**
414 * @param {!WebInspector.UISourceCode} uiSourceCode
415 * @param {number} lineNumber
416 * @param {number} columnNumber
417 * @return {?WebInspector.CSSLocation}
418 */
419 uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) { },
420
421 /**
422 * @return {boolean}
423 */
424 isIdentity: function() { },
425
426 /**
427 * @param {!WebInspector.UISourceCode} uiSourceCode
428 * @param {number} lineNumber
429 * @return {boolean}
430 */
431 uiLineHasMapping: function(uiSourceCode, lineNumber) { }
432 }
433
434 /**
399 * @type {!WebInspector.CSSWorkspaceBinding} 435 * @type {!WebInspector.CSSWorkspaceBinding}
400 */ 436 */
401 WebInspector.cssWorkspaceBinding; 437 WebInspector.cssWorkspaceBinding;
OLDNEW
« no previous file with comments | « Source/devtools/front_end/bindings/BreakpointManager.js ('k') | Source/devtools/front_end/bindings/CompilerScriptMapping.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698