| 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.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 * @implements {WebInspector.OverridesSupport.PageResizer} | 8 * @implements {WebInspector.OverridesSupport.PageResizer} |
| 9 * @implements {WebInspector.TargetManager.Observer} |
| 9 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder | 10 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder |
| 10 */ | 11 */ |
| 11 WebInspector.ResponsiveDesignView = function(inspectedPagePlaceholder) | 12 WebInspector.ResponsiveDesignView = function(inspectedPagePlaceholder) |
| 12 { | 13 { |
| 13 WebInspector.VBox.call(this); | 14 WebInspector.VBox.call(this); |
| 14 this.setMinimumSize(150, 150); | 15 this.setMinimumSize(150, 150); |
| 15 this.element.classList.add("overflow-hidden"); | 16 this.element.classList.add("overflow-hidden"); |
| 16 | 17 |
| 17 this._responsiveDesignContainer = new WebInspector.VBox(); | 18 this._responsiveDesignContainer = new WebInspector.VBox(); |
| 18 this._responsiveDesignContainer.registerRequiredCSS("responsiveDesignView.cs
s"); | 19 this._responsiveDesignContainer.registerRequiredCSS("responsiveDesignView.cs
s"); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 inspectedPagePlaceholder.show(this.element); | 57 inspectedPagePlaceholder.show(this.element); |
| 57 | 58 |
| 58 this._enabled = false; | 59 this._enabled = false; |
| 59 this._viewport = { scrollX: 0, scrollY: 0, contentsWidth: 0, contentsHeight:
0, pageScaleFactor: 1 }; | 60 this._viewport = { scrollX: 0, scrollY: 0, contentsWidth: 0, contentsHeight:
0, pageScaleFactor: 1 }; |
| 60 this._drawContentsSize = true; | 61 this._drawContentsSize = true; |
| 61 this._viewportChangedThrottler = new WebInspector.Throttler(0); | 62 this._viewportChangedThrottler = new WebInspector.Throttler(0); |
| 62 | 63 |
| 63 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._onZoomChanged, this); | 64 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._onZoomChanged, this); |
| 64 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, this._emulationEnabledChanged, this); | 65 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, this._emulationEnabledChanged, this); |
| 65 this._mediaInspector.addEventListener(WebInspector.MediaQueryInspector.Event
s.HeightUpdated, this.onResize, this); | 66 this._mediaInspector.addEventListener(WebInspector.MediaQueryInspector.Event
s.HeightUpdated, this.onResize, this); |
| 66 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod
el.EventTypes.ViewportChanged, this._viewportChanged, this); | 67 WebInspector.targetManager.observeTargets(this); |
| 67 | 68 |
| 68 this._emulationEnabledChanged(); | 69 this._emulationEnabledChanged(); |
| 69 this._overridesWarningUpdated(); | 70 this._overridesWarningUpdated(); |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 // Measured in DIP. | 73 // Measured in DIP. |
| 73 WebInspector.ResponsiveDesignView.SliderWidth = 19; | 74 WebInspector.ResponsiveDesignView.SliderWidth = 19; |
| 74 WebInspector.ResponsiveDesignView.RulerWidth = 22; | 75 WebInspector.ResponsiveDesignView.RulerWidth = 22; |
| 75 | 76 |
| 76 WebInspector.ResponsiveDesignView.prototype = { | 77 WebInspector.ResponsiveDesignView.prototype = { |
| 78 |
| 79 /** |
| 80 * @param {!WebInspector.Target} target |
| 81 */ |
| 82 targetAdded: function(target) |
| 83 { |
| 84 // FIXME: adapt this to multiple targets. |
| 85 if (this._target) |
| 86 return; |
| 87 this._target = target; |
| 88 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel
.EventTypes.ViewportChanged, this._viewportChanged, this); |
| 89 }, |
| 90 |
| 91 /** |
| 92 * @param {!WebInspector.Target} target |
| 93 */ |
| 94 targetRemoved: function(target) |
| 95 { |
| 96 if (target !== this._target) |
| 97 return; |
| 98 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo
del.EventTypes.ViewportChanged, this._viewportChanged, this); |
| 99 }, |
| 100 |
| 77 _invalidateCache: function() | 101 _invalidateCache: function() |
| 78 { | 102 { |
| 79 delete this._cachedScale; | 103 delete this._cachedScale; |
| 80 delete this._cachedCssCanvasWidth; | 104 delete this._cachedCssCanvasWidth; |
| 81 delete this._cachedCssCanvasHeight; | 105 delete this._cachedCssCanvasHeight; |
| 82 delete this._cachedCssHeight; | 106 delete this._cachedCssHeight; |
| 83 delete this._cachedCssWidth; | 107 delete this._cachedCssWidth; |
| 84 delete this._cachedZoomFactor; | 108 delete this._cachedZoomFactor; |
| 85 delete this._cachedViewport; | 109 delete this._cachedViewport; |
| 86 delete this._cachedDrawContentsSize; | 110 delete this._cachedDrawContentsSize; |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 * @param {!WebInspector.Throttler.FinishCallback} finishCallback | 629 * @param {!WebInspector.Throttler.FinishCallback} finishCallback |
| 606 */ | 630 */ |
| 607 _updateUIThrottled: function(finishCallback) | 631 _updateUIThrottled: function(finishCallback) |
| 608 { | 632 { |
| 609 this._updateUI(); | 633 this._updateUI(); |
| 610 finishCallback(); | 634 finishCallback(); |
| 611 }, | 635 }, |
| 612 | 636 |
| 613 __proto__: WebInspector.VBox.prototype | 637 __proto__: WebInspector.VBox.prototype |
| 614 }; | 638 }; |
| OLD | NEW |