| OLD | NEW |
| 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 | |
| 5 /** | 4 /** |
| 6 * @constructor | |
| 7 * @implements {WebInspector.TargetManager.Observer} | 5 * @implements {WebInspector.TargetManager.Observer} |
| 8 * @param {!WebInspector.TargetManager} targetManager | 6 * @unrestricted |
| 9 * @param {!WebInspector.Workspace} workspace | |
| 10 * @param {!WebInspector.NetworkMapping} networkMapping | |
| 11 */ | 7 */ |
| 12 WebInspector.CSSWorkspaceBinding = function(targetManager, workspace, networkMap
ping) | 8 WebInspector.CSSWorkspaceBinding = class { |
| 13 { | 9 /** |
| 10 * @param {!WebInspector.TargetManager} targetManager |
| 11 * @param {!WebInspector.Workspace} workspace |
| 12 * @param {!WebInspector.NetworkMapping} networkMapping |
| 13 */ |
| 14 constructor(targetManager, workspace, networkMapping) { |
| 14 this._workspace = workspace; | 15 this._workspace = workspace; |
| 15 this._networkMapping = networkMapping; | 16 this._networkMapping = networkMapping; |
| 16 | 17 |
| 17 /** @type {!Map.<!WebInspector.CSSModel, !WebInspector.CSSWorkspaceBinding.T
argetInfo>} */ | 18 /** @type {!Map.<!WebInspector.CSSModel, !WebInspector.CSSWorkspaceBinding.T
argetInfo>} */ |
| 18 this._modelToTargetInfo = new Map(); | 19 this._modelToTargetInfo = new Map(); |
| 19 targetManager.observeTargets(this); | 20 targetManager.observeTargets(this); |
| 21 } |
| 22 |
| 23 /** |
| 24 * @override |
| 25 * @param {!WebInspector.Target} target |
| 26 */ |
| 27 targetAdded(target) { |
| 28 var cssModel = WebInspector.CSSModel.fromTarget(target); |
| 29 if (cssModel) |
| 30 this._modelToTargetInfo.set( |
| 31 cssModel, new WebInspector.CSSWorkspaceBinding.TargetInfo(cssModel, th
is._workspace, this._networkMapping)); |
| 32 } |
| 33 |
| 34 /** |
| 35 * @override |
| 36 * @param {!WebInspector.Target} target |
| 37 */ |
| 38 targetRemoved(target) { |
| 39 var cssModel = WebInspector.CSSModel.fromTarget(target); |
| 40 if (cssModel) |
| 41 this._modelToTargetInfo.remove(cssModel)._dispose(); |
| 42 } |
| 43 |
| 44 /** |
| 45 * @param {!WebInspector.CSSStyleSheetHeader} header |
| 46 * @return {?WebInspector.CSSWorkspaceBinding.TargetInfo} |
| 47 */ |
| 48 _targetInfo(header) { |
| 49 return this._modelToTargetInfo.get(header.cssModel()) || null; |
| 50 } |
| 51 |
| 52 /** |
| 53 * @param {!WebInspector.CSSStyleSheetHeader} header |
| 54 * @return {!WebInspector.CSSWorkspaceBinding.TargetInfo} |
| 55 */ |
| 56 _ensureTargetInfo(header) { |
| 57 var targetInfo = this._modelToTargetInfo.get(header.cssModel()); |
| 58 if (!targetInfo) { |
| 59 targetInfo = |
| 60 new WebInspector.CSSWorkspaceBinding.TargetInfo(header.cssModel(), thi
s._workspace, this._networkMapping); |
| 61 this._modelToTargetInfo.set(header.cssModel(), targetInfo); |
| 62 } |
| 63 return targetInfo; |
| 64 } |
| 65 |
| 66 /** |
| 67 * @param {!WebInspector.CSSStyleSheetHeader} header |
| 68 */ |
| 69 updateLocations(header) { |
| 70 var targetInfo = this._targetInfo(header); |
| 71 if (targetInfo) |
| 72 targetInfo._updateLocations(header); |
| 73 } |
| 74 |
| 75 /** |
| 76 * @param {!WebInspector.CSSLocation} rawLocation |
| 77 * @param {function(!WebInspector.LiveLocation)} updateDelegate |
| 78 * @param {!WebInspector.LiveLocationPool} locationPool |
| 79 * @return {!WebInspector.CSSWorkspaceBinding.LiveLocation} |
| 80 */ |
| 81 createLiveLocation(rawLocation, updateDelegate, locationPool) { |
| 82 var header = |
| 83 rawLocation.styleSheetId ? rawLocation.cssModel().styleSheetHeaderForId(
rawLocation.styleSheetId) : null; |
| 84 return new WebInspector.CSSWorkspaceBinding.LiveLocation( |
| 85 rawLocation.cssModel(), header, rawLocation, this, updateDelegate, locat
ionPool); |
| 86 } |
| 87 |
| 88 /** |
| 89 * @param {!WebInspector.CSSWorkspaceBinding.LiveLocation} location |
| 90 */ |
| 91 _addLiveLocation(location) { |
| 92 this._ensureTargetInfo(location._header)._addLocation(location); |
| 93 } |
| 94 |
| 95 /** |
| 96 * @param {!WebInspector.CSSWorkspaceBinding.LiveLocation} location |
| 97 */ |
| 98 _removeLiveLocation(location) { |
| 99 var targetInfo = this._targetInfo(location._header); |
| 100 if (targetInfo) |
| 101 targetInfo._removeLocation(location); |
| 102 } |
| 103 |
| 104 /** |
| 105 * @param {!WebInspector.CSSProperty} cssProperty |
| 106 * @param {boolean} forName |
| 107 * @return {?WebInspector.UILocation} |
| 108 */ |
| 109 propertyUILocation(cssProperty, forName) { |
| 110 var style = cssProperty.ownerStyle; |
| 111 if (!style || style.type !== WebInspector.CSSStyleDeclaration.Type.Regular |
| !style.styleSheetId) |
| 112 return null; |
| 113 var header = style.cssModel().styleSheetHeaderForId(style.styleSheetId); |
| 114 if (!header) |
| 115 return null; |
| 116 |
| 117 var range = forName ? cssProperty.nameRange() : cssProperty.valueRange(); |
| 118 if (!range) |
| 119 return null; |
| 120 |
| 121 var lineNumber = range.startLine; |
| 122 var columnNumber = range.startColumn; |
| 123 var rawLocation = new WebInspector.CSSLocation( |
| 124 header, header.lineNumberInSource(lineNumber), header.columnNumberInSour
ce(lineNumber, columnNumber)); |
| 125 return this.rawLocationToUILocation(rawLocation); |
| 126 } |
| 127 |
| 128 /** |
| 129 * @param {?WebInspector.CSSLocation} rawLocation |
| 130 * @return {?WebInspector.UILocation} |
| 131 */ |
| 132 rawLocationToUILocation(rawLocation) { |
| 133 if (!rawLocation) |
| 134 return null; |
| 135 var header = rawLocation.cssModel().styleSheetHeaderForId(rawLocation.styleS
heetId); |
| 136 if (!header) |
| 137 return null; |
| 138 var targetInfo = this._targetInfo(header); |
| 139 return targetInfo ? targetInfo._rawLocationToUILocation(header, rawLocation.
lineNumber, rawLocation.columnNumber) : |
| 140 null; |
| 141 } |
| 20 }; | 142 }; |
| 21 | 143 |
| 22 WebInspector.CSSWorkspaceBinding.prototype = { | |
| 23 /** | |
| 24 * @override | |
| 25 * @param {!WebInspector.Target} target | |
| 26 */ | |
| 27 targetAdded: function(target) | |
| 28 { | |
| 29 var cssModel = WebInspector.CSSModel.fromTarget(target); | |
| 30 if (cssModel) | |
| 31 this._modelToTargetInfo.set(cssModel, new WebInspector.CSSWorkspaceB
inding.TargetInfo(cssModel, this._workspace, this._networkMapping)); | |
| 32 }, | |
| 33 | |
| 34 /** | |
| 35 * @override | |
| 36 * @param {!WebInspector.Target} target | |
| 37 */ | |
| 38 targetRemoved: function(target) | |
| 39 { | |
| 40 var cssModel = WebInspector.CSSModel.fromTarget(target); | |
| 41 if (cssModel) | |
| 42 this._modelToTargetInfo.remove(cssModel)._dispose(); | |
| 43 }, | |
| 44 | |
| 45 /** | |
| 46 * @param {!WebInspector.CSSStyleSheetHeader} header | |
| 47 * @return {?WebInspector.CSSWorkspaceBinding.TargetInfo} | |
| 48 */ | |
| 49 _targetInfo: function(header) | |
| 50 { | |
| 51 return this._modelToTargetInfo.get(header.cssModel()) || null; | |
| 52 }, | |
| 53 | |
| 54 /** | |
| 55 * @param {!WebInspector.CSSStyleSheetHeader} header | |
| 56 * @return {!WebInspector.CSSWorkspaceBinding.TargetInfo} | |
| 57 */ | |
| 58 _ensureTargetInfo: function(header) | |
| 59 { | |
| 60 var targetInfo = this._modelToTargetInfo.get(header.cssModel()); | |
| 61 if (!targetInfo) { | |
| 62 targetInfo = new WebInspector.CSSWorkspaceBinding.TargetInfo(header.
cssModel(), this._workspace, this._networkMapping); | |
| 63 this._modelToTargetInfo.set(header.cssModel(), targetInfo); | |
| 64 } | |
| 65 return targetInfo; | |
| 66 }, | |
| 67 | |
| 68 /** | |
| 69 * @param {!WebInspector.CSSStyleSheetHeader} header | |
| 70 */ | |
| 71 updateLocations: function(header) | |
| 72 { | |
| 73 var targetInfo = this._targetInfo(header); | |
| 74 if (targetInfo) | |
| 75 targetInfo._updateLocations(header); | |
| 76 }, | |
| 77 | |
| 78 /** | |
| 79 * @param {!WebInspector.CSSLocation} rawLocation | |
| 80 * @param {function(!WebInspector.LiveLocation)} updateDelegate | |
| 81 * @param {!WebInspector.LiveLocationPool} locationPool | |
| 82 * @return {!WebInspector.CSSWorkspaceBinding.LiveLocation} | |
| 83 */ | |
| 84 createLiveLocation: function(rawLocation, updateDelegate, locationPool) | |
| 85 { | |
| 86 var header = rawLocation.styleSheetId ? rawLocation.cssModel().styleShee
tHeaderForId(rawLocation.styleSheetId) : null; | |
| 87 return new WebInspector.CSSWorkspaceBinding.LiveLocation(rawLocation.css
Model(), header, rawLocation, this, updateDelegate, locationPool); | |
| 88 }, | |
| 89 | |
| 90 /** | |
| 91 * @param {!WebInspector.CSSWorkspaceBinding.LiveLocation} location | |
| 92 */ | |
| 93 _addLiveLocation: function(location) | |
| 94 { | |
| 95 this._ensureTargetInfo(location._header)._addLocation(location); | |
| 96 }, | |
| 97 | |
| 98 /** | |
| 99 * @param {!WebInspector.CSSWorkspaceBinding.LiveLocation} location | |
| 100 */ | |
| 101 _removeLiveLocation: function(location) | |
| 102 { | |
| 103 var targetInfo = this._targetInfo(location._header); | |
| 104 if (targetInfo) | |
| 105 targetInfo._removeLocation(location); | |
| 106 }, | |
| 107 | |
| 108 /** | |
| 109 * @param {!WebInspector.CSSProperty} cssProperty | |
| 110 * @param {boolean} forName | |
| 111 * @return {?WebInspector.UILocation} | |
| 112 */ | |
| 113 propertyUILocation: function(cssProperty, forName) | |
| 114 { | |
| 115 var style = cssProperty.ownerStyle; | |
| 116 if (!style || style.type !== WebInspector.CSSStyleDeclaration.Type.Regul
ar || !style.styleSheetId) | |
| 117 return null; | |
| 118 var header = style.cssModel().styleSheetHeaderForId(style.styleSheetId); | |
| 119 if (!header) | |
| 120 return null; | |
| 121 | |
| 122 var range = forName ? cssProperty.nameRange() : cssProperty.valueRange()
; | |
| 123 if (!range) | |
| 124 return null; | |
| 125 | |
| 126 var lineNumber = range.startLine; | |
| 127 var columnNumber = range.startColumn; | |
| 128 var rawLocation = new WebInspector.CSSLocation(header, header.lineNumber
InSource(lineNumber), header.columnNumberInSource(lineNumber, columnNumber)); | |
| 129 return this.rawLocationToUILocation(rawLocation); | |
| 130 }, | |
| 131 | |
| 132 /** | |
| 133 * @param {?WebInspector.CSSLocation} rawLocation | |
| 134 * @return {?WebInspector.UILocation} | |
| 135 */ | |
| 136 rawLocationToUILocation: function(rawLocation) | |
| 137 { | |
| 138 if (!rawLocation) | |
| 139 return null; | |
| 140 var header = rawLocation.cssModel().styleSheetHeaderForId(rawLocation.st
yleSheetId); | |
| 141 if (!header) | |
| 142 return null; | |
| 143 var targetInfo = this._targetInfo(header); | |
| 144 return targetInfo ? targetInfo._rawLocationToUILocation(header, rawLocat
ion.lineNumber, rawLocation.columnNumber) : null; | |
| 145 } | |
| 146 }; | |
| 147 | |
| 148 /** | 144 /** |
| 149 * @constructor | 145 * @unrestricted |
| 150 * @param {!WebInspector.CSSModel} cssModel | |
| 151 * @param {!WebInspector.Workspace} workspace | |
| 152 * @param {!WebInspector.NetworkMapping} networkMapping | |
| 153 */ | 146 */ |
| 154 WebInspector.CSSWorkspaceBinding.TargetInfo = function(cssModel, workspace, netw
orkMapping) | 147 WebInspector.CSSWorkspaceBinding.TargetInfo = class { |
| 155 { | 148 /** |
| 149 * @param {!WebInspector.CSSModel} cssModel |
| 150 * @param {!WebInspector.Workspace} workspace |
| 151 * @param {!WebInspector.NetworkMapping} networkMapping |
| 152 */ |
| 153 constructor(cssModel, workspace, networkMapping) { |
| 156 this._cssModel = cssModel; | 154 this._cssModel = cssModel; |
| 157 this._stylesSourceMapping = new WebInspector.StylesSourceMapping(cssModel, w
orkspace, networkMapping); | 155 this._stylesSourceMapping = new WebInspector.StylesSourceMapping(cssModel, w
orkspace, networkMapping); |
| 158 this._sassSourceMapping = new WebInspector.SASSSourceMapping(cssModel, netwo
rkMapping, WebInspector.NetworkProject.forTarget(cssModel.target())); | 156 this._sassSourceMapping = new WebInspector.SASSSourceMapping( |
| 157 cssModel, networkMapping, WebInspector.NetworkProject.forTarget(cssModel
.target())); |
| 159 | 158 |
| 160 /** @type {!Multimap<!WebInspector.CSSStyleSheetHeader, !WebInspector.LiveLo
cation>} */ | 159 /** @type {!Multimap<!WebInspector.CSSStyleSheetHeader, !WebInspector.LiveLo
cation>} */ |
| 161 this._locations = new Multimap(); | 160 this._locations = new Multimap(); |
| 161 } |
| 162 |
| 163 /** |
| 164 * @param {!WebInspector.CSSWorkspaceBinding.LiveLocation} location |
| 165 */ |
| 166 _addLocation(location) { |
| 167 var header = location._header; |
| 168 this._locations.set(header, location); |
| 169 location.update(); |
| 170 } |
| 171 |
| 172 /** |
| 173 * @param {!WebInspector.CSSWorkspaceBinding.LiveLocation} location |
| 174 */ |
| 175 _removeLocation(location) { |
| 176 this._locations.remove(location._header, location); |
| 177 } |
| 178 |
| 179 /** |
| 180 * @param {!WebInspector.CSSStyleSheetHeader} header |
| 181 */ |
| 182 _updateLocations(header) { |
| 183 for (var location of this._locations.get(header)) |
| 184 location.update(); |
| 185 } |
| 186 |
| 187 /** |
| 188 * @param {!WebInspector.CSSStyleSheetHeader} header |
| 189 * @param {number} lineNumber |
| 190 * @param {number=} columnNumber |
| 191 * @return {?WebInspector.UILocation} |
| 192 */ |
| 193 _rawLocationToUILocation(header, lineNumber, columnNumber) { |
| 194 var rawLocation = new WebInspector.CSSLocation(header, lineNumber, columnNum
ber); |
| 195 var uiLocation = null; |
| 196 uiLocation = uiLocation || this._sassSourceMapping.rawLocationToUILocation(r
awLocation); |
| 197 uiLocation = uiLocation || this._stylesSourceMapping.rawLocationToUILocation
(rawLocation); |
| 198 return uiLocation; |
| 199 } |
| 200 |
| 201 _dispose() { |
| 202 this._stylesSourceMapping.dispose(); |
| 203 this._sassSourceMapping.dispose(); |
| 204 } |
| 162 }; | 205 }; |
| 163 | 206 |
| 164 WebInspector.CSSWorkspaceBinding.TargetInfo.prototype = { | |
| 165 /** | |
| 166 * @param {!WebInspector.CSSWorkspaceBinding.LiveLocation} location | |
| 167 */ | |
| 168 _addLocation: function(location) | |
| 169 { | |
| 170 var header = location._header; | |
| 171 this._locations.set(header, location); | |
| 172 location.update(); | |
| 173 }, | |
| 174 | |
| 175 /** | |
| 176 * @param {!WebInspector.CSSWorkspaceBinding.LiveLocation} location | |
| 177 */ | |
| 178 _removeLocation: function(location) | |
| 179 { | |
| 180 this._locations.remove(location._header, location); | |
| 181 }, | |
| 182 | |
| 183 /** | |
| 184 * @param {!WebInspector.CSSStyleSheetHeader} header | |
| 185 */ | |
| 186 _updateLocations: function(header) | |
| 187 { | |
| 188 for (var location of this._locations.get(header)) | |
| 189 location.update(); | |
| 190 }, | |
| 191 | |
| 192 /** | |
| 193 * @param {!WebInspector.CSSStyleSheetHeader} header | |
| 194 * @param {number} lineNumber | |
| 195 * @param {number=} columnNumber | |
| 196 * @return {?WebInspector.UILocation} | |
| 197 */ | |
| 198 _rawLocationToUILocation: function(header, lineNumber, columnNumber) | |
| 199 { | |
| 200 var rawLocation = new WebInspector.CSSLocation(header, lineNumber, colum
nNumber); | |
| 201 var uiLocation = null; | |
| 202 uiLocation = uiLocation || this._sassSourceMapping.rawLocationToUILocati
on(rawLocation); | |
| 203 uiLocation = uiLocation || this._stylesSourceMapping.rawLocationToUILoca
tion(rawLocation); | |
| 204 return uiLocation; | |
| 205 }, | |
| 206 | |
| 207 _dispose: function() | |
| 208 { | |
| 209 this._stylesSourceMapping.dispose(); | |
| 210 this._sassSourceMapping.dispose(); | |
| 211 } | |
| 212 }; | |
| 213 | |
| 214 /** | 207 /** |
| 215 * @constructor | 208 * @unrestricted |
| 216 * @extends {WebInspector.LiveLocationWithPool} | |
| 217 * @param {!WebInspector.CSSModel} cssModel | |
| 218 * @param {?WebInspector.CSSStyleSheetHeader} header | |
| 219 * @param {!WebInspector.CSSLocation} rawLocation | |
| 220 * @param {!WebInspector.CSSWorkspaceBinding} binding | |
| 221 * @param {function(!WebInspector.LiveLocation)} updateDelegate | |
| 222 * @param {!WebInspector.LiveLocationPool} locationPool | |
| 223 */ | 209 */ |
| 224 WebInspector.CSSWorkspaceBinding.LiveLocation = function(cssModel, header, rawLo
cation, binding, updateDelegate, locationPool) | 210 WebInspector.CSSWorkspaceBinding.LiveLocation = class extends WebInspector.LiveL
ocationWithPool { |
| 225 { | 211 /** |
| 226 WebInspector.LiveLocationWithPool.call(this, updateDelegate, locationPool); | 212 * @param {!WebInspector.CSSModel} cssModel |
| 213 * @param {?WebInspector.CSSStyleSheetHeader} header |
| 214 * @param {!WebInspector.CSSLocation} rawLocation |
| 215 * @param {!WebInspector.CSSWorkspaceBinding} binding |
| 216 * @param {function(!WebInspector.LiveLocation)} updateDelegate |
| 217 * @param {!WebInspector.LiveLocationPool} locationPool |
| 218 */ |
| 219 constructor(cssModel, header, rawLocation, binding, updateDelegate, locationPo
ol) { |
| 220 super(updateDelegate, locationPool); |
| 227 this._cssModel = cssModel; | 221 this._cssModel = cssModel; |
| 228 this._rawLocation = rawLocation; | 222 this._rawLocation = rawLocation; |
| 229 this._binding = binding; | 223 this._binding = binding; |
| 230 if (!header) | 224 if (!header) |
| 231 this._clearStyleSheet(); | 225 this._clearStyleSheet(); |
| 232 else | 226 else |
| 233 this._setStyleSheet(header); | 227 this._setStyleSheet(header); |
| 228 } |
| 229 |
| 230 /** |
| 231 * @param {!WebInspector.Event} event |
| 232 */ |
| 233 _styleSheetAdded(event) { |
| 234 console.assert(!this._header); |
| 235 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.data); |
| 236 if (header.sourceURL && header.sourceURL === this._rawLocation.url) |
| 237 this._setStyleSheet(header); |
| 238 } |
| 239 |
| 240 /** |
| 241 * @param {!WebInspector.Event} event |
| 242 */ |
| 243 _styleSheetRemoved(event) { |
| 244 console.assert(this._header); |
| 245 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.data); |
| 246 if (this._header !== header) |
| 247 return; |
| 248 this._binding._removeLiveLocation(this); |
| 249 this._clearStyleSheet(); |
| 250 } |
| 251 |
| 252 /** |
| 253 * @param {!WebInspector.CSSStyleSheetHeader} header |
| 254 */ |
| 255 _setStyleSheet(header) { |
| 256 this._header = header; |
| 257 this._binding._addLiveLocation(this); |
| 258 this._cssModel.removeEventListener(WebInspector.CSSModel.Events.StyleSheetAd
ded, this._styleSheetAdded, this); |
| 259 this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetRemov
ed, this._styleSheetRemoved, this); |
| 260 } |
| 261 |
| 262 _clearStyleSheet() { |
| 263 delete this._header; |
| 264 this._cssModel.removeEventListener(WebInspector.CSSModel.Events.StyleSheetRe
moved, this._styleSheetRemoved, this); |
| 265 this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetAdded
, this._styleSheetAdded, this); |
| 266 } |
| 267 |
| 268 /** |
| 269 * @override |
| 270 * @return {?WebInspector.UILocation} |
| 271 */ |
| 272 uiLocation() { |
| 273 var cssLocation = this._rawLocation; |
| 274 if (this._header) { |
| 275 var targetInfo = this._binding._targetInfo(this._header); |
| 276 return targetInfo._rawLocationToUILocation(this._header, cssLocation.lineN
umber, cssLocation.columnNumber); |
| 277 } |
| 278 var uiSourceCode = this._binding._networkMapping.uiSourceCodeForStyleURL(css
Location.url, cssLocation.header()); |
| 279 if (!uiSourceCode) |
| 280 return null; |
| 281 return uiSourceCode.uiLocation(cssLocation.lineNumber, cssLocation.columnNum
ber); |
| 282 } |
| 283 |
| 284 /** |
| 285 * @override |
| 286 */ |
| 287 dispose() { |
| 288 super.dispose(); |
| 289 if (this._header) |
| 290 this._binding._removeLiveLocation(this); |
| 291 this._cssModel.removeEventListener(WebInspector.CSSModel.Events.StyleSheetAd
ded, this._styleSheetAdded, this); |
| 292 this._cssModel.removeEventListener(WebInspector.CSSModel.Events.StyleSheetRe
moved, this._styleSheetRemoved, this); |
| 293 } |
| 294 |
| 295 /** |
| 296 * @override |
| 297 * @return {boolean} |
| 298 */ |
| 299 isBlackboxed() { |
| 300 return false; |
| 301 } |
| 234 }; | 302 }; |
| 235 | 303 |
| 236 WebInspector.CSSWorkspaceBinding.LiveLocation.prototype = { | |
| 237 /** | |
| 238 * @param {!WebInspector.Event} event | |
| 239 */ | |
| 240 _styleSheetAdded: function(event) | |
| 241 { | |
| 242 console.assert(!this._header); | |
| 243 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat
a); | |
| 244 if (header.sourceURL && header.sourceURL === this._rawLocation.url) | |
| 245 this._setStyleSheet(header); | |
| 246 }, | |
| 247 | |
| 248 /** | |
| 249 * @param {!WebInspector.Event} event | |
| 250 */ | |
| 251 _styleSheetRemoved: function(event) | |
| 252 { | |
| 253 console.assert(this._header); | |
| 254 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat
a); | |
| 255 if (this._header !== header) | |
| 256 return; | |
| 257 this._binding._removeLiveLocation(this); | |
| 258 this._clearStyleSheet(); | |
| 259 }, | |
| 260 | |
| 261 /** | |
| 262 * @param {!WebInspector.CSSStyleSheetHeader} header | |
| 263 */ | |
| 264 _setStyleSheet: function(header) | |
| 265 { | |
| 266 this._header = header; | |
| 267 this._binding._addLiveLocation(this); | |
| 268 this._cssModel.removeEventListener(WebInspector.CSSModel.Events.StyleShe
etAdded, this._styleSheetAdded, this); | |
| 269 this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetR
emoved, this._styleSheetRemoved, this); | |
| 270 }, | |
| 271 | |
| 272 _clearStyleSheet: function() | |
| 273 { | |
| 274 delete this._header; | |
| 275 this._cssModel.removeEventListener(WebInspector.CSSModel.Events.StyleShe
etRemoved, this._styleSheetRemoved, this); | |
| 276 this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetA
dded, this._styleSheetAdded, this); | |
| 277 }, | |
| 278 | |
| 279 /** | |
| 280 * @override | |
| 281 * @return {?WebInspector.UILocation} | |
| 282 */ | |
| 283 uiLocation: function() | |
| 284 { | |
| 285 var cssLocation = this._rawLocation; | |
| 286 if (this._header) { | |
| 287 var targetInfo = this._binding._targetInfo(this._header); | |
| 288 return targetInfo._rawLocationToUILocation(this._header, cssLocation
.lineNumber, cssLocation.columnNumber); | |
| 289 } | |
| 290 var uiSourceCode = this._binding._networkMapping.uiSourceCodeForStyleURL
(cssLocation.url, cssLocation.header()); | |
| 291 if (!uiSourceCode) | |
| 292 return null; | |
| 293 return uiSourceCode.uiLocation(cssLocation.lineNumber, cssLocation.colum
nNumber); | |
| 294 }, | |
| 295 | |
| 296 /** | |
| 297 * @override | |
| 298 */ | |
| 299 dispose: function() | |
| 300 { | |
| 301 WebInspector.LiveLocationWithPool.prototype.dispose.call(this); | |
| 302 if (this._header) | |
| 303 this._binding._removeLiveLocation(this); | |
| 304 this._cssModel.removeEventListener(WebInspector.CSSModel.Events.StyleShe
etAdded, this._styleSheetAdded, this); | |
| 305 this._cssModel.removeEventListener(WebInspector.CSSModel.Events.StyleShe
etRemoved, this._styleSheetRemoved, this); | |
| 306 }, | |
| 307 | |
| 308 /** | |
| 309 * @override | |
| 310 * @return {boolean} | |
| 311 */ | |
| 312 isBlackboxed: function() | |
| 313 { | |
| 314 return false; | |
| 315 }, | |
| 316 | |
| 317 __proto__: WebInspector.LiveLocationWithPool.prototype | |
| 318 }; | |
| 319 | |
| 320 /** | 304 /** |
| 321 * @type {!WebInspector.CSSWorkspaceBinding} | 305 * @type {!WebInspector.CSSWorkspaceBinding} |
| 322 */ | 306 */ |
| 323 WebInspector.cssWorkspaceBinding; | 307 WebInspector.cssWorkspaceBinding; |
| OLD | NEW |