| OLD | NEW |
| 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 Loading... |
| 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.StylesSourceMapping = class { | 34 Bindings.StylesSourceMapping = class { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.CSSModel} cssModel | 36 * @param {!SDK.CSSModel} cssModel |
| 37 * @param {!WebInspector.Workspace} workspace | 37 * @param {!Workspace.Workspace} workspace |
| 38 * @param {!WebInspector.NetworkMapping} networkMapping | 38 * @param {!Bindings.NetworkMapping} networkMapping |
| 39 */ | 39 */ |
| 40 constructor(cssModel, workspace, networkMapping) { | 40 constructor(cssModel, workspace, networkMapping) { |
| 41 this._cssModel = cssModel; | 41 this._cssModel = cssModel; |
| 42 this._workspace = workspace; | 42 this._workspace = workspace; |
| 43 this._networkMapping = networkMapping; | 43 this._networkMapping = networkMapping; |
| 44 | 44 |
| 45 /** @type {!Map<string, !Map<string, !Map<string, !WebInspector.CSSStyleShee
tHeader>>>} */ | 45 /** @type {!Map<string, !Map<string, !Map<string, !SDK.CSSStyleSheetHeader>>
>} */ |
| 46 this._urlToHeadersByFrameId = new Map(); | 46 this._urlToHeadersByFrameId = new Map(); |
| 47 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.StyleFile>} */ | 47 /** @type {!Map.<!Workspace.UISourceCode, !Bindings.StyleFile>} */ |
| 48 this._styleFiles = new Map(); | 48 this._styleFiles = new Map(); |
| 49 | 49 |
| 50 this._eventListeners = [ | 50 this._eventListeners = [ |
| 51 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemo
ved, this._projectRemoved, this), | 51 this._workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved
, this._projectRemoved, this), |
| 52 this._workspace.addEventListener( | 52 this._workspace.addEventListener( |
| 53 WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAdd
edToWorkspace, this), | 53 Workspace.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAddedT
oWorkspace, this), |
| 54 this._workspace.addEventListener( | 54 this._workspace.addEventListener( |
| 55 WebInspector.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeR
emoved, this), | 55 Workspace.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeRemo
ved, this), |
| 56 this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetAdd
ed, this._styleSheetAdded, this), | 56 this._cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetAdded, this.
_styleSheetAdded, this), |
| 57 this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetRem
oved, this._styleSheetRemoved, this), | 57 this._cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetRemoved, thi
s._styleSheetRemoved, this), |
| 58 this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetCha
nged, this._styleSheetChanged, this), | 58 this._cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetChanged, thi
s._styleSheetChanged, this), |
| 59 WebInspector.ResourceTreeModel.fromTarget(cssModel.target()) | 59 SDK.ResourceTreeModel.fromTarget(cssModel.target()) |
| 60 .addEventListener( | 60 .addEventListener( |
| 61 WebInspector.ResourceTreeModel.Events.MainFrameNavigated, this._un
bindAllUISourceCodes, this) | 61 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._unbindAllUI
SourceCodes, this) |
| 62 ]; | 62 ]; |
| 63 } | 63 } |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * @param {!WebInspector.CSSLocation} rawLocation | 66 * @param {!SDK.CSSLocation} rawLocation |
| 67 * @return {?WebInspector.UILocation} | 67 * @return {?Workspace.UILocation} |
| 68 */ | 68 */ |
| 69 rawLocationToUILocation(rawLocation) { | 69 rawLocationToUILocation(rawLocation) { |
| 70 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(rawLocation.
url, rawLocation.header()); | 70 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(rawLocation.
url, rawLocation.header()); |
| 71 if (!uiSourceCode) | 71 if (!uiSourceCode) |
| 72 return null; | 72 return null; |
| 73 var lineNumber = rawLocation.lineNumber; | 73 var lineNumber = rawLocation.lineNumber; |
| 74 var columnNumber = rawLocation.columnNumber; | 74 var columnNumber = rawLocation.columnNumber; |
| 75 var header = this._cssModel.styleSheetHeaderForId(rawLocation.styleSheetId); | 75 var header = this._cssModel.styleSheetHeaderForId(rawLocation.styleSheetId); |
| 76 if (header && header.isInline && header.hasSourceURL) { | 76 if (header && header.isInline && header.hasSourceURL) { |
| 77 lineNumber -= header.lineNumberInSource(0); | 77 lineNumber -= header.lineNumberInSource(0); |
| 78 columnNumber -= header.columnNumberInSource(lineNumber, 0); | 78 columnNumber -= header.columnNumberInSource(lineNumber, 0); |
| 79 } | 79 } |
| 80 return uiSourceCode.uiLocation(lineNumber, columnNumber); | 80 return uiSourceCode.uiLocation(lineNumber, columnNumber); |
| 81 } | 81 } |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * @param {!WebInspector.Event} event | 84 * @param {!Common.Event} event |
| 85 */ | 85 */ |
| 86 _styleSheetAdded(event) { | 86 _styleSheetAdded(event) { |
| 87 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.data); | 87 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data); |
| 88 var url = header.resourceURL(); | 88 var url = header.resourceURL(); |
| 89 if (!url) | 89 if (!url) |
| 90 return; | 90 return; |
| 91 | 91 |
| 92 var map = this._urlToHeadersByFrameId.get(url); | 92 var map = this._urlToHeadersByFrameId.get(url); |
| 93 if (!map) { | 93 if (!map) { |
| 94 map = /** @type {!Map.<string, !Map.<string, !WebInspector.CSSStyleSheetHe
ader>>} */ (new Map()); | 94 map = /** @type {!Map.<string, !Map.<string, !SDK.CSSStyleSheetHeader>>} *
/ (new Map()); |
| 95 this._urlToHeadersByFrameId.set(url, map); | 95 this._urlToHeadersByFrameId.set(url, map); |
| 96 } | 96 } |
| 97 var headersById = map.get(header.frameId); | 97 var headersById = map.get(header.frameId); |
| 98 if (!headersById) { | 98 if (!headersById) { |
| 99 headersById = /** @type {!Map.<string, !WebInspector.CSSStyleSheetHeader>}
*/ (new Map()); | 99 headersById = /** @type {!Map.<string, !SDK.CSSStyleSheetHeader>} */ (new
Map()); |
| 100 map.set(header.frameId, headersById); | 100 map.set(header.frameId, headersById); |
| 101 } | 101 } |
| 102 headersById.set(header.id, header); | 102 headersById.set(header.id, header); |
| 103 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(url, header)
; | 103 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(url, header)
; |
| 104 if (uiSourceCode) | 104 if (uiSourceCode) |
| 105 this._bindUISourceCode(uiSourceCode, header); | 105 this._bindUISourceCode(uiSourceCode, header); |
| 106 } | 106 } |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * @param {!WebInspector.Event} event | 109 * @param {!Common.Event} event |
| 110 */ | 110 */ |
| 111 _styleSheetRemoved(event) { | 111 _styleSheetRemoved(event) { |
| 112 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.data); | 112 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data); |
| 113 var url = header.resourceURL(); | 113 var url = header.resourceURL(); |
| 114 if (!url) | 114 if (!url) |
| 115 return; | 115 return; |
| 116 | 116 |
| 117 var map = this._urlToHeadersByFrameId.get(url); | 117 var map = this._urlToHeadersByFrameId.get(url); |
| 118 console.assert(map); | 118 console.assert(map); |
| 119 var headersById = map.get(header.frameId); | 119 var headersById = map.get(header.frameId); |
| 120 console.assert(headersById); | 120 console.assert(headersById); |
| 121 headersById.delete(header.id); | 121 headersById.delete(header.id); |
| 122 | 122 |
| 123 if (!headersById.size) { | 123 if (!headersById.size) { |
| 124 map.delete(header.frameId); | 124 map.delete(header.frameId); |
| 125 if (!map.size) { | 125 if (!map.size) { |
| 126 this._urlToHeadersByFrameId.delete(url); | 126 this._urlToHeadersByFrameId.delete(url); |
| 127 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(url, hea
der); | 127 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(url, hea
der); |
| 128 if (uiSourceCode) | 128 if (uiSourceCode) |
| 129 this._unbindUISourceCode(uiSourceCode); | 129 this._unbindUISourceCode(uiSourceCode); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * @param {!WebInspector.UISourceCode} uiSourceCode | 135 * @param {!Workspace.UISourceCode} uiSourceCode |
| 136 */ | 136 */ |
| 137 _unbindUISourceCode(uiSourceCode) { | 137 _unbindUISourceCode(uiSourceCode) { |
| 138 var styleFile = this._styleFiles.get(uiSourceCode); | 138 var styleFile = this._styleFiles.get(uiSourceCode); |
| 139 if (!styleFile) | 139 if (!styleFile) |
| 140 return; | 140 return; |
| 141 styleFile.dispose(); | 141 styleFile.dispose(); |
| 142 this._styleFiles.delete(uiSourceCode); | 142 this._styleFiles.delete(uiSourceCode); |
| 143 } | 143 } |
| 144 | 144 |
| 145 /** | 145 /** |
| 146 * @param {!WebInspector.Event} event | 146 * @param {!Common.Event} event |
| 147 */ | 147 */ |
| 148 _unbindAllUISourceCodes(event) { | 148 _unbindAllUISourceCodes(event) { |
| 149 if (event.data.target() !== this._cssModel.target()) | 149 if (event.data.target() !== this._cssModel.target()) |
| 150 return; | 150 return; |
| 151 for (var styleFile of this._styleFiles.values()) | 151 for (var styleFile of this._styleFiles.values()) |
| 152 styleFile.dispose(); | 152 styleFile.dispose(); |
| 153 this._styleFiles.clear(); | 153 this._styleFiles.clear(); |
| 154 this._urlToHeadersByFrameId = new Map(); | 154 this._urlToHeadersByFrameId = new Map(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 /** | 157 /** |
| 158 * @param {!WebInspector.Event} event | 158 * @param {!Common.Event} event |
| 159 */ | 159 */ |
| 160 _uiSourceCodeAddedToWorkspace(event) { | 160 _uiSourceCodeAddedToWorkspace(event) { |
| 161 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data); | 161 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); |
| 162 if (!this._urlToHeadersByFrameId.has(uiSourceCode.url())) | 162 if (!this._urlToHeadersByFrameId.has(uiSourceCode.url())) |
| 163 return; | 163 return; |
| 164 this._bindUISourceCode( | 164 this._bindUISourceCode( |
| 165 uiSourceCode, this._urlToHeadersByFrameId.get(uiSourceCode.url()).values
Array()[0].valuesArray()[0]); | 165 uiSourceCode, this._urlToHeadersByFrameId.get(uiSourceCode.url()).values
Array()[0].valuesArray()[0]); |
| 166 } | 166 } |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * @param {!WebInspector.UISourceCode} uiSourceCode | 169 * @param {!Workspace.UISourceCode} uiSourceCode |
| 170 * @param {!WebInspector.CSSStyleSheetHeader} header | 170 * @param {!SDK.CSSStyleSheetHeader} header |
| 171 */ | 171 */ |
| 172 _bindUISourceCode(uiSourceCode, header) { | 172 _bindUISourceCode(uiSourceCode, header) { |
| 173 if (this._styleFiles.get(uiSourceCode) || (header.isInline && !header.hasSou
rceURL)) | 173 if (this._styleFiles.get(uiSourceCode) || (header.isInline && !header.hasSou
rceURL)) |
| 174 return; | 174 return; |
| 175 this._styleFiles.set(uiSourceCode, new WebInspector.StyleFile(uiSourceCode,
this)); | 175 this._styleFiles.set(uiSourceCode, new Bindings.StyleFile(uiSourceCode, this
)); |
| 176 WebInspector.cssWorkspaceBinding.updateLocations(header); | 176 Bindings.cssWorkspaceBinding.updateLocations(header); |
| 177 } | 177 } |
| 178 | 178 |
| 179 /** | 179 /** |
| 180 * @param {!WebInspector.Event} event | 180 * @param {!Common.Event} event |
| 181 */ | 181 */ |
| 182 _projectRemoved(event) { | 182 _projectRemoved(event) { |
| 183 var project = /** @type {!WebInspector.Project} */ (event.data); | 183 var project = /** @type {!Workspace.Project} */ (event.data); |
| 184 var uiSourceCodes = project.uiSourceCodes(); | 184 var uiSourceCodes = project.uiSourceCodes(); |
| 185 for (var i = 0; i < uiSourceCodes.length; ++i) | 185 for (var i = 0; i < uiSourceCodes.length; ++i) |
| 186 this._unbindUISourceCode(uiSourceCodes[i]); | 186 this._unbindUISourceCode(uiSourceCodes[i]); |
| 187 } | 187 } |
| 188 | 188 |
| 189 /** | 189 /** |
| 190 * @param {!WebInspector.Event} event | 190 * @param {!Common.Event} event |
| 191 */ | 191 */ |
| 192 _uiSourceCodeRemoved(event) { | 192 _uiSourceCodeRemoved(event) { |
| 193 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data); | 193 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); |
| 194 this._unbindUISourceCode(uiSourceCode); | 194 this._unbindUISourceCode(uiSourceCode); |
| 195 } | 195 } |
| 196 | 196 |
| 197 /** | 197 /** |
| 198 * @param {!WebInspector.UISourceCode} uiSourceCode | 198 * @param {!Workspace.UISourceCode} uiSourceCode |
| 199 * @param {string} content | 199 * @param {string} content |
| 200 * @param {boolean} majorChange | 200 * @param {boolean} majorChange |
| 201 * @return {!Promise<?string>} | 201 * @return {!Promise<?string>} |
| 202 */ | 202 */ |
| 203 _setStyleContent(uiSourceCode, content, majorChange) { | 203 _setStyleContent(uiSourceCode, content, majorChange) { |
| 204 var styleSheetIds = this._cssModel.styleSheetIdsForURL(uiSourceCode.url()); | 204 var styleSheetIds = this._cssModel.styleSheetIdsForURL(uiSourceCode.url()); |
| 205 if (!styleSheetIds.length) | 205 if (!styleSheetIds.length) |
| 206 return Promise.resolve(/** @type {?string} */ ('No stylesheet found: ' + u
iSourceCode.url())); | 206 return Promise.resolve(/** @type {?string} */ ('No stylesheet found: ' + u
iSourceCode.url())); |
| 207 | 207 |
| 208 this._isSettingContent = true; | 208 this._isSettingContent = true; |
| 209 | 209 |
| 210 /** | 210 /** |
| 211 * @param {?string} error | 211 * @param {?string} error |
| 212 * @this {WebInspector.StylesSourceMapping} | 212 * @this {Bindings.StylesSourceMapping} |
| 213 * @return {?string} | 213 * @return {?string} |
| 214 */ | 214 */ |
| 215 function callback(error) { | 215 function callback(error) { |
| 216 delete this._isSettingContent; | 216 delete this._isSettingContent; |
| 217 return error || null; | 217 return error || null; |
| 218 } | 218 } |
| 219 | 219 |
| 220 var promises = []; | 220 var promises = []; |
| 221 for (var i = 0; i < styleSheetIds.length; ++i) | 221 for (var i = 0; i < styleSheetIds.length; ++i) |
| 222 promises.push(this._cssModel.setStyleSheetText(styleSheetIds[i], content,
majorChange)); | 222 promises.push(this._cssModel.setStyleSheetText(styleSheetIds[i], content,
majorChange)); |
| 223 | 223 |
| 224 return Promise.all(promises).spread(callback.bind(this)); | 224 return Promise.all(promises).spread(callback.bind(this)); |
| 225 } | 225 } |
| 226 | 226 |
| 227 /** | 227 /** |
| 228 * @param {!WebInspector.Event} event | 228 * @param {!Common.Event} event |
| 229 */ | 229 */ |
| 230 _styleSheetChanged(event) { | 230 _styleSheetChanged(event) { |
| 231 if (this._isSettingContent) | 231 if (this._isSettingContent) |
| 232 return; | 232 return; |
| 233 | 233 |
| 234 this._updateStyleSheetTextSoon(event.data.styleSheetId); | 234 this._updateStyleSheetTextSoon(event.data.styleSheetId); |
| 235 } | 235 } |
| 236 | 236 |
| 237 /** | 237 /** |
| 238 * @param {!Protocol.CSS.StyleSheetId} styleSheetId | 238 * @param {!Protocol.CSS.StyleSheetId} styleSheetId |
| 239 */ | 239 */ |
| 240 _updateStyleSheetTextSoon(styleSheetId) { | 240 _updateStyleSheetTextSoon(styleSheetId) { |
| 241 if (this._updateStyleSheetTextTimer) | 241 if (this._updateStyleSheetTextTimer) |
| 242 clearTimeout(this._updateStyleSheetTextTimer); | 242 clearTimeout(this._updateStyleSheetTextTimer); |
| 243 | 243 |
| 244 this._updateStyleSheetTextTimer = setTimeout( | 244 this._updateStyleSheetTextTimer = setTimeout( |
| 245 this._updateStyleSheetText.bind(this, styleSheetId), WebInspector.Styles
SourceMapping.ChangeUpdateTimeoutMs); | 245 this._updateStyleSheetText.bind(this, styleSheetId), Bindings.StylesSour
ceMapping.ChangeUpdateTimeoutMs); |
| 246 } | 246 } |
| 247 | 247 |
| 248 /** | 248 /** |
| 249 * @param {!Protocol.CSS.StyleSheetId} styleSheetId | 249 * @param {!Protocol.CSS.StyleSheetId} styleSheetId |
| 250 */ | 250 */ |
| 251 _updateStyleSheetText(styleSheetId) { | 251 _updateStyleSheetText(styleSheetId) { |
| 252 if (this._updateStyleSheetTextTimer) { | 252 if (this._updateStyleSheetTextTimer) { |
| 253 clearTimeout(this._updateStyleSheetTextTimer); | 253 clearTimeout(this._updateStyleSheetTextTimer); |
| 254 delete this._updateStyleSheetTextTimer; | 254 delete this._updateStyleSheetTextTimer; |
| 255 } | 255 } |
| 256 | 256 |
| 257 var header = this._cssModel.styleSheetHeaderForId(styleSheetId); | 257 var header = this._cssModel.styleSheetHeaderForId(styleSheetId); |
| 258 if (!header) | 258 if (!header) |
| 259 return; | 259 return; |
| 260 var styleSheetURL = header.resourceURL(); | 260 var styleSheetURL = header.resourceURL(); |
| 261 if (!styleSheetURL) | 261 if (!styleSheetURL) |
| 262 return; | 262 return; |
| 263 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(styleSheetUR
L, header); | 263 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(styleSheetUR
L, header); |
| 264 if (!uiSourceCode) | 264 if (!uiSourceCode) |
| 265 return; | 265 return; |
| 266 header.requestContent().then(callback.bind(this, uiSourceCode)); | 266 header.requestContent().then(callback.bind(this, uiSourceCode)); |
| 267 | 267 |
| 268 /** | 268 /** |
| 269 * @param {!WebInspector.UISourceCode} uiSourceCode | 269 * @param {!Workspace.UISourceCode} uiSourceCode |
| 270 * @param {?string} content | 270 * @param {?string} content |
| 271 * @this {WebInspector.StylesSourceMapping} | 271 * @this {Bindings.StylesSourceMapping} |
| 272 */ | 272 */ |
| 273 function callback(uiSourceCode, content) { | 273 function callback(uiSourceCode, content) { |
| 274 var styleFile = this._styleFiles.get(uiSourceCode); | 274 var styleFile = this._styleFiles.get(uiSourceCode); |
| 275 if (styleFile) | 275 if (styleFile) |
| 276 styleFile.addRevision(content || ''); | 276 styleFile.addRevision(content || ''); |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 | 279 |
| 280 dispose() { | 280 dispose() { |
| 281 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | 281 Common.EventTarget.removeEventListeners(this._eventListeners); |
| 282 } | 282 } |
| 283 }; | 283 }; |
| 284 | 284 |
| 285 WebInspector.StylesSourceMapping.ChangeUpdateTimeoutMs = 200; | 285 Bindings.StylesSourceMapping.ChangeUpdateTimeoutMs = 200; |
| 286 | 286 |
| 287 /** | 287 /** |
| 288 * @unrestricted | 288 * @unrestricted |
| 289 */ | 289 */ |
| 290 WebInspector.StyleFile = class { | 290 Bindings.StyleFile = class { |
| 291 /** | 291 /** |
| 292 * @param {!WebInspector.UISourceCode} uiSourceCode | 292 * @param {!Workspace.UISourceCode} uiSourceCode |
| 293 * @param {!WebInspector.StylesSourceMapping} mapping | 293 * @param {!Bindings.StylesSourceMapping} mapping |
| 294 */ | 294 */ |
| 295 constructor(uiSourceCode, mapping) { | 295 constructor(uiSourceCode, mapping) { |
| 296 this._uiSourceCode = uiSourceCode; | 296 this._uiSourceCode = uiSourceCode; |
| 297 this._mapping = mapping; | 297 this._mapping = mapping; |
| 298 this._eventListeners = [ | 298 this._eventListeners = [ |
| 299 this._uiSourceCode.addEventListener( | 299 this._uiSourceCode.addEventListener( |
| 300 WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopy
Changed, this), | 300 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyCha
nged, this), |
| 301 this._uiSourceCode.addEventListener( | 301 this._uiSourceCode.addEventListener( |
| 302 WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCo
pyCommitted, this) | 302 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyC
ommitted, this) |
| 303 ]; | 303 ]; |
| 304 this._commitThrottler = new WebInspector.Throttler(WebInspector.StyleFile.up
dateTimeout); | 304 this._commitThrottler = new Common.Throttler(Bindings.StyleFile.updateTimeou
t); |
| 305 this._terminated = false; | 305 this._terminated = false; |
| 306 } | 306 } |
| 307 | 307 |
| 308 /** | 308 /** |
| 309 * @param {!WebInspector.Event} event | 309 * @param {!Common.Event} event |
| 310 */ | 310 */ |
| 311 _workingCopyCommitted(event) { | 311 _workingCopyCommitted(event) { |
| 312 if (this._isAddingRevision) | 312 if (this._isAddingRevision) |
| 313 return; | 313 return; |
| 314 | 314 |
| 315 this._isMajorChangePending = true; | 315 this._isMajorChangePending = true; |
| 316 this._commitThrottler.schedule(this._commitIncrementalEdit.bind(this), true)
; | 316 this._commitThrottler.schedule(this._commitIncrementalEdit.bind(this), true)
; |
| 317 } | 317 } |
| 318 | 318 |
| 319 /** | 319 /** |
| 320 * @param {!WebInspector.Event} event | 320 * @param {!Common.Event} event |
| 321 */ | 321 */ |
| 322 _workingCopyChanged(event) { | 322 _workingCopyChanged(event) { |
| 323 if (this._isAddingRevision) | 323 if (this._isAddingRevision) |
| 324 return; | 324 return; |
| 325 | 325 |
| 326 this._commitThrottler.schedule(this._commitIncrementalEdit.bind(this), false
); | 326 this._commitThrottler.schedule(this._commitIncrementalEdit.bind(this), false
); |
| 327 } | 327 } |
| 328 | 328 |
| 329 _commitIncrementalEdit() { | 329 _commitIncrementalEdit() { |
| 330 if (this._terminated) | 330 if (this._terminated) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 350 addRevision(content) { | 350 addRevision(content) { |
| 351 this._isAddingRevision = true; | 351 this._isAddingRevision = true; |
| 352 this._uiSourceCode.addRevision(content); | 352 this._uiSourceCode.addRevision(content); |
| 353 delete this._isAddingRevision; | 353 delete this._isAddingRevision; |
| 354 } | 354 } |
| 355 | 355 |
| 356 dispose() { | 356 dispose() { |
| 357 if (this._terminated) | 357 if (this._terminated) |
| 358 return; | 358 return; |
| 359 this._terminated = true; | 359 this._terminated = true; |
| 360 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | 360 Common.EventTarget.removeEventListeners(this._eventListeners); |
| 361 } | 361 } |
| 362 }; | 362 }; |
| 363 | 363 |
| 364 WebInspector.StyleFile.updateTimeout = 200; | 364 Bindings.StyleFile.updateTimeout = 200; |
| OLD | NEW |