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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/SASSSourceMapping.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.SASSSourceMapping = class { 34 Bindings.SASSSourceMapping = class {
35 /** 35 /**
36 * @param {!WebInspector.CSSModel} cssModel 36 * @param {!SDK.CSSModel} cssModel
37 * @param {!WebInspector.NetworkMapping} networkMapping 37 * @param {!Bindings.NetworkMapping} networkMapping
38 * @param {!WebInspector.NetworkProject} networkProject 38 * @param {!Bindings.NetworkProject} networkProject
39 */ 39 */
40 constructor(cssModel, networkMapping, networkProject) { 40 constructor(cssModel, networkMapping, networkProject) {
41 this._cssModel = cssModel; 41 this._cssModel = cssModel;
42 this._networkProject = networkProject; 42 this._networkProject = networkProject;
43 this._networkMapping = networkMapping; 43 this._networkMapping = networkMapping;
44 this._eventListeners = [ 44 this._eventListeners = [
45 this._cssModel.addEventListener(WebInspector.CSSModel.Events.SourceMapAtta ched, this._sourceMapAttached, this), 45 this._cssModel.addEventListener(SDK.CSSModel.Events.SourceMapAttached, thi s._sourceMapAttached, this),
46 this._cssModel.addEventListener(WebInspector.CSSModel.Events.SourceMapDeta ched, this._sourceMapDetached, this), 46 this._cssModel.addEventListener(SDK.CSSModel.Events.SourceMapDetached, thi s._sourceMapDetached, this),
47 this._cssModel.addEventListener(WebInspector.CSSModel.Events.SourceMapChan ged, this._sourceMapChanged, this) 47 this._cssModel.addEventListener(SDK.CSSModel.Events.SourceMapChanged, this ._sourceMapChanged, this)
48 ]; 48 ];
49 } 49 }
50 50
51 /** 51 /**
52 * @param {!WebInspector.Event} event 52 * @param {!Common.Event} event
53 */ 53 */
54 _sourceMapAttached(event) { 54 _sourceMapAttached(event) {
55 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.data); 55 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data);
56 var sourceMap = this._cssModel.sourceMapForHeader(header); 56 var sourceMap = this._cssModel.sourceMapForHeader(header);
57 for (var sassURL of sourceMap.sourceURLs()) { 57 for (var sassURL of sourceMap.sourceURLs()) {
58 var contentProvider = sourceMap.sourceContentProvider(sassURL, WebInspecto r.resourceTypes.SourceMapStyleSheet); 58 var contentProvider = sourceMap.sourceContentProvider(sassURL, Common.reso urceTypes.SourceMapStyleSheet);
59 var embeddedContent = sourceMap.embeddedContentByURL(sassURL); 59 var embeddedContent = sourceMap.embeddedContentByURL(sassURL);
60 var embeddedContentLength = typeof embeddedContent === 'string' ? embedded Content.length : null; 60 var embeddedContentLength = typeof embeddedContent === 'string' ? embedded Content.length : null;
61 this._networkProject.addFile( 61 this._networkProject.addFile(
62 contentProvider, WebInspector.ResourceTreeFrame.fromStyleSheet(header) , false, embeddedContentLength); 62 contentProvider, SDK.ResourceTreeFrame.fromStyleSheet(header), false, embeddedContentLength);
63 } 63 }
64 WebInspector.cssWorkspaceBinding.updateLocations(header); 64 Bindings.cssWorkspaceBinding.updateLocations(header);
65 } 65 }
66 66
67 /** 67 /**
68 * @param {!WebInspector.Event} event 68 * @param {!Common.Event} event
69 */ 69 */
70 _sourceMapDetached(event) { 70 _sourceMapDetached(event) {
71 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.data); 71 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data);
72 WebInspector.cssWorkspaceBinding.updateLocations(header); 72 Bindings.cssWorkspaceBinding.updateLocations(header);
73 } 73 }
74 74
75 /** 75 /**
76 * @param {!WebInspector.Event} event 76 * @param {!Common.Event} event
77 */ 77 */
78 _sourceMapChanged(event) { 78 _sourceMapChanged(event) {
79 var sourceMap = /** @type {!WebInspector.SourceMap} */ (event.data.sourceMap ); 79 var sourceMap = /** @type {!SDK.SourceMap} */ (event.data.sourceMap);
80 var newSources = /** @type {!Map<string, string>} */ (event.data.newSources) ; 80 var newSources = /** @type {!Map<string, string>} */ (event.data.newSources) ;
81 var headers = this._cssModel.headersForSourceMap(sourceMap); 81 var headers = this._cssModel.headersForSourceMap(sourceMap);
82 var handledUISourceCodes = new Set(); 82 var handledUISourceCodes = new Set();
83 for (var header of headers) { 83 for (var header of headers) {
84 WebInspector.cssWorkspaceBinding.updateLocations(header); 84 Bindings.cssWorkspaceBinding.updateLocations(header);
85 for (var sourceURL of newSources.keys()) { 85 for (var sourceURL of newSources.keys()) {
86 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(sourceUR L, header); 86 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(sourceUR L, header);
87 if (!uiSourceCode) { 87 if (!uiSourceCode) {
88 console.error('Failed to update source for ' + sourceURL); 88 console.error('Failed to update source for ' + sourceURL);
89 continue; 89 continue;
90 } 90 }
91 if (handledUISourceCodes.has(uiSourceCode)) 91 if (handledUISourceCodes.has(uiSourceCode))
92 continue; 92 continue;
93 handledUISourceCodes.add(uiSourceCode); 93 handledUISourceCodes.add(uiSourceCode);
94 var sassText = /** @type {string} */ (newSources.get(sourceURL)); 94 var sassText = /** @type {string} */ (newSources.get(sourceURL));
95 uiSourceCode.setWorkingCopy(sassText); 95 uiSourceCode.setWorkingCopy(sassText);
96 } 96 }
97 } 97 }
98 } 98 }
99 99
100 /** 100 /**
101 * @param {!WebInspector.CSSLocation} rawLocation 101 * @param {!SDK.CSSLocation} rawLocation
102 * @return {?WebInspector.UILocation} 102 * @return {?Workspace.UILocation}
103 */ 103 */
104 rawLocationToUILocation(rawLocation) { 104 rawLocationToUILocation(rawLocation) {
105 var sourceMap = this._cssModel.sourceMapForHeader(rawLocation.header()); 105 var sourceMap = this._cssModel.sourceMapForHeader(rawLocation.header());
106 if (!sourceMap) 106 if (!sourceMap)
107 return null; 107 return null;
108 var entry = sourceMap.findEntry(rawLocation.lineNumber, rawLocation.columnNu mber); 108 var entry = sourceMap.findEntry(rawLocation.lineNumber, rawLocation.columnNu mber);
109 if (!entry || !entry.sourceURL) 109 if (!entry || !entry.sourceURL)
110 return null; 110 return null;
111 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(entry.source URL, rawLocation.header()); 111 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(entry.source URL, rawLocation.header());
112 if (!uiSourceCode) 112 if (!uiSourceCode)
113 return null; 113 return null;
114 return uiSourceCode.uiLocation(entry.sourceLineNumber || 0, entry.sourceColu mnNumber); 114 return uiSourceCode.uiLocation(entry.sourceLineNumber || 0, entry.sourceColu mnNumber);
115 } 115 }
116 116
117 dispose() { 117 dispose() {
118 WebInspector.EventTarget.removeEventListeners(this._eventListeners); 118 Common.EventTarget.removeEventListeners(this._eventListeners);
119 } 119 }
120 }; 120 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698