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 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.View} | 7 * @extends {WebInspector.View} |
8 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
9 */ | 9 */ |
10 WebInspector.MediaQueryInspector = function() | 10 WebInspector.MediaQueryInspector = function() |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 * @param {!WebInspector.Target} target | 60 * @param {!WebInspector.Target} target |
61 */ | 61 */ |
62 targetRemoved: function(target) | 62 targetRemoved: function(target) |
63 { | 63 { |
64 if (target !== this._target) | 64 if (target !== this._target) |
65 return; | 65 return; |
66 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.St
yleSheetAdded, this._scheduleMediaQueriesUpdate, this); | 66 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.St
yleSheetAdded, this._scheduleMediaQueriesUpdate, this); |
67 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.St
yleSheetRemoved, this._scheduleMediaQueriesUpdate, this); | 67 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.St
yleSheetRemoved, this._scheduleMediaQueriesUpdate, this); |
68 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.St
yleSheetChanged, this._scheduleMediaQueriesUpdate, this); | 68 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.St
yleSheetChanged, this._scheduleMediaQueriesUpdate, this); |
69 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Me
diaQueryResultChanged, this._scheduleMediaQueriesUpdate, this); | 69 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Me
diaQueryResultChanged, this._scheduleMediaQueriesUpdate, this); |
| 70 delete this._target; |
70 }, | 71 }, |
71 | 72 |
72 /** | 73 /** |
73 * @param {number} offset | 74 * @param {number} offset |
74 * @param {number} scale | 75 * @param {number} scale |
75 */ | 76 */ |
76 setAxisTransform: function(offset, scale) | 77 setAxisTransform: function(offset, scale) |
77 { | 78 { |
78 if (this._offset === offset && Math.abs(this._scale - scale) < 1e-8) | 79 if (this._offset === offset && Math.abs(this._scale - scale) < 1e-8) |
79 return; | 80 return; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 setWidth(model.minWidthExpression().computedLength()); | 124 setWidth(model.minWidthExpression().computedLength()); |
124 else | 125 else |
125 setWidth(model.maxWidthExpression().computedLength()); | 126 setWidth(model.maxWidthExpression().computedLength()); |
126 }, | 127 }, |
127 | 128 |
128 /** | 129 /** |
129 * @param {!Event} event | 130 * @param {!Event} event |
130 */ | 131 */ |
131 _onContextMenu: function(event) | 132 _onContextMenu: function(event) |
132 { | 133 { |
| 134 if (!this._target || !this._target.cssModel.isEnabled()) |
| 135 return; |
| 136 |
133 var mediaQueryMarker = event.target.enclosingNodeOrSelfWithClass("media-
inspector-marker"); | 137 var mediaQueryMarker = event.target.enclosingNodeOrSelfWithClass("media-
inspector-marker"); |
134 if (!mediaQueryMarker) | 138 if (!mediaQueryMarker) |
135 return; | 139 return; |
136 | 140 |
137 var locations = mediaQueryMarker._locations; | 141 var locations = mediaQueryMarker._locations; |
138 var uiLocations = new Map(); | 142 var uiLocations = new Map(); |
139 for (var i = 0; i < locations.length; ++i) { | 143 for (var i = 0; i < locations.length; ++i) { |
140 var uiLocation = WebInspector.cssWorkspaceBinding.rawLocationToUILoc
ation(locations[i]); | 144 var uiLocation = WebInspector.cssWorkspaceBinding.rawLocationToUILoc
ation(locations[i]); |
141 if (!uiLocation) | 145 if (!uiLocation) |
142 continue; | 146 continue; |
(...skipping 24 matching lines...) Expand all Loading... |
167 if (!this._enabled) | 171 if (!this._enabled) |
168 return; | 172 return; |
169 this._mediaThrottler.schedule(this._refetchMediaQueries.bind(this)); | 173 this._mediaThrottler.schedule(this._refetchMediaQueries.bind(this)); |
170 }, | 174 }, |
171 | 175 |
172 /** | 176 /** |
173 * @param {!WebInspector.Throttler.FinishCallback} finishCallback | 177 * @param {!WebInspector.Throttler.FinishCallback} finishCallback |
174 */ | 178 */ |
175 _refetchMediaQueries: function(finishCallback) | 179 _refetchMediaQueries: function(finishCallback) |
176 { | 180 { |
177 if (!this._enabled) { | 181 if (!this._enabled || !this._target) { |
178 finishCallback(); | 182 finishCallback(); |
179 return; | 183 return; |
180 } | 184 } |
181 | 185 |
182 /** | 186 /** |
183 * @param {!Array.<!WebInspector.CSSMedia>} cssMedias | 187 * @param {!Array.<!WebInspector.CSSMedia>} cssMedias |
184 * @this {!WebInspector.MediaQueryInspector} | 188 * @this {!WebInspector.MediaQueryInspector} |
185 */ | 189 */ |
186 function callback(cssMedias) | 190 function callback(cssMedias) |
187 { | 191 { |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 }, | 505 }, |
502 | 506 |
503 /** | 507 /** |
504 * @return {boolean} | 508 * @return {boolean} |
505 */ | 509 */ |
506 active: function() | 510 active: function() |
507 { | 511 { |
508 return this._active; | 512 return this._active; |
509 } | 513 } |
510 } | 514 } |
OLD | NEW |