Index: Source/devtools/front_end/toolbox/MediaQueryInspector.js |
diff --git a/Source/devtools/front_end/toolbox/MediaQueryInspector.js b/Source/devtools/front_end/toolbox/MediaQueryInspector.js |
index c3ffb99b63ff4a21975ffb0ca0ca8a9256c5e3aa..a51c429aaf34f91284c677fc67f4f0e91a6bb49d 100644 |
--- a/Source/devtools/front_end/toolbox/MediaQueryInspector.js |
+++ b/Source/devtools/front_end/toolbox/MediaQueryInspector.js |
@@ -18,6 +18,7 @@ WebInspector.MediaQueryInspector = function() |
this._offset = 0; |
this._scale = 1; |
this._lastReportedCount = 0; |
+ this._canRevealSourceLocation = false; |
lushnikov
2015/02/25 15:23:55
сan we have method _canRevealSourceLocation that w
dgozman
2015/02/25 15:51:55
Done.
|
WebInspector.targetManager.observeTargets(this); |
@@ -49,10 +50,13 @@ WebInspector.MediaQueryInspector.prototype = { |
if (this._target) |
return; |
this._target = target; |
+ this._canRevealSourceLocation = target.cssModel.isEnabled(); |
target.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetAdded, this._scheduleMediaQueriesUpdate, this); |
target.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetRemoved, this._scheduleMediaQueriesUpdate, this); |
target.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetChanged, this._scheduleMediaQueriesUpdate, this); |
target.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.MediaQueryResultChanged, this._scheduleMediaQueriesUpdate, this); |
+ target.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.ModelWasDisabled, this._cssModelEnabledChanged, this); |
+ target.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.ModelWasEnabled, this._cssModelEnabledChanged, this); |
}, |
/** |
@@ -67,6 +71,10 @@ WebInspector.MediaQueryInspector.prototype = { |
target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.StyleSheetRemoved, this._scheduleMediaQueriesUpdate, this); |
target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.StyleSheetChanged, this._scheduleMediaQueriesUpdate, this); |
target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.MediaQueryResultChanged, this._scheduleMediaQueriesUpdate, this); |
+ target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.ModelWasDisabled, this._cssModelEnabledChanged, this); |
+ target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.ModelWasEnabled, this._cssModelEnabledChanged, this); |
+ this._canRevealSourceLocation = false; |
+ delete this._target; |
}, |
/** |
@@ -130,6 +138,9 @@ WebInspector.MediaQueryInspector.prototype = { |
*/ |
_onContextMenu: function(event) |
{ |
+ if (!this._canRevealSourceLocation) |
+ return; |
+ |
var mediaQueryMarker = event.target.enclosingNodeOrSelfWithClass("media-inspector-marker"); |
if (!mediaQueryMarker) |
return; |
@@ -154,6 +165,12 @@ WebInspector.MediaQueryInspector.prototype = { |
contextMenu.show(); |
}, |
+ _cssModelEnabledChanged: function() |
+ { |
+ if (this._target) |
+ this._canRevealSourceLocation = this._target.cssModel.isEnabled(); |
caseq
2015/02/25 14:58:34
Why not just check the model state upon onContextM
dgozman
2015/02/25 15:51:55
Done.
|
+ }, |
+ |
/** |
* @param {!WebInspector.UILocation} location |
*/ |
@@ -174,7 +191,7 @@ WebInspector.MediaQueryInspector.prototype = { |
*/ |
_refetchMediaQueries: function(finishCallback) |
{ |
- if (!this._enabled) { |
+ if (!this._enabled || !this._target) { |
finishCallback(); |
return; |
} |