| 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 */ | 8 */ |
| 9 WebInspector.InspectedPagePlaceholder = function() | 9 WebInspector.InspectedPagePlaceholder = function() |
| 10 { | 10 { |
| 11 WebInspector.View.call(this); | 11 WebInspector.View.call(this); |
| 12 this.element.classList.add("white-background"); | 12 this.element.classList.add("white-background"); |
| 13 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._onZoomChanged, this); | 13 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._scheduleUpdate, this); |
| 14 this._margins = { top: 0, right: 0, bottom: 0, left: 0 }; | 14 this._margins = { top: 0, right: 0, bottom: 0, left: 0 }; |
| 15 this.restoreMinimumSizeAndMargins(); | 15 this.restoreMinimumSizeAndMargins(); |
| 16 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve
nts.BeforeDockSideChanged, this._beforeDockSideChange, this); | 16 }; |
| 17 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve
nts.AfterDockSideChanged, this._afterDockSideChange, this); | 17 |
| 18 WebInspector.InspectedPagePlaceholder.Events = { |
| 19 Update: "Update" |
| 18 }; | 20 }; |
| 19 | 21 |
| 20 WebInspector.InspectedPagePlaceholder.MarginValue = 3; | 22 WebInspector.InspectedPagePlaceholder.MarginValue = 3; |
| 21 | 23 |
| 22 WebInspector.InspectedPagePlaceholder.prototype = { | 24 WebInspector.InspectedPagePlaceholder.prototype = { |
| 23 _findMargins: function() | 25 _findMargins: function() |
| 24 { | 26 { |
| 25 var margins = { top: 0, right: 0, bottom: 0, left: 0 }; | 27 var margins = { top: 0, right: 0, bottom: 0, left: 0 }; |
| 26 | 28 |
| 27 if (this._useMargins) { | 29 if (this._useMargins) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 40 view = parent; | 42 view = parent; |
| 41 } | 43 } |
| 42 } | 44 } |
| 43 | 45 |
| 44 if (this._margins.top !== margins.top || this._margins.left !== margins.
left || this._margins.right !== margins.right || this._margins.bottom !== margin
s.bottom) { | 46 if (this._margins.top !== margins.top || this._margins.left !== margins.
left || this._margins.right !== margins.right || this._margins.bottom !== margin
s.bottom) { |
| 45 this._margins = margins; | 47 this._margins = margins; |
| 46 this._scheduleUpdate(); | 48 this._scheduleUpdate(); |
| 47 } | 49 } |
| 48 }, | 50 }, |
| 49 | 51 |
| 50 _onZoomChanged: function() | |
| 51 { | |
| 52 this._scheduleUpdate(); | |
| 53 }, | |
| 54 | |
| 55 onResize: function() | 52 onResize: function() |
| 56 { | 53 { |
| 57 this._findMargins(); | 54 this._findMargins(); |
| 58 this._scheduleUpdate(); | 55 this._scheduleUpdate(); |
| 59 }, | 56 }, |
| 60 | 57 |
| 61 _scheduleUpdate: function() | 58 _scheduleUpdate: function() |
| 62 { | 59 { |
| 63 if (this._noUpdates) | 60 if (this._updateId) |
| 64 return; | 61 window.cancelAnimationFrame(this._updateId); |
| 65 | 62 this._updateId = window.requestAnimationFrame(this.update.bind(this)); |
| 66 var dockSide = WebInspector.dockController.dockSide(); | |
| 67 if (dockSide !== WebInspector.DockController.State.Undocked) { | |
| 68 if (this._updateId) | |
| 69 window.cancelAnimationFrame(this._updateId); | |
| 70 this._updateId = window.requestAnimationFrame(this._update.bind(this
)); | |
| 71 } | |
| 72 }, | 63 }, |
| 73 | 64 |
| 74 /** | 65 /** |
| 75 * @return {!Size} | 66 * @return {!Size} |
| 76 */ | 67 */ |
| 77 dipPageSize: function() | 68 dipPageSize: function() |
| 78 { | 69 { |
| 79 var rect = this._dipPageRect(); | 70 var rect = this._dipPageRect(); |
| 80 return new Size(Math.round(rect.width), Math.round(rect.height)); | 71 return new Size(Math.round(rect.width), Math.round(rect.height)); |
| 81 }, | 72 }, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 var bodyRect = document.body.getBoundingClientRect(); | 104 var bodyRect = document.body.getBoundingClientRect(); |
| 114 | 105 |
| 115 var left = Math.max(rect.left * zoomFactor + this._margins.left, bodyRec
t.left * zoomFactor); | 106 var left = Math.max(rect.left * zoomFactor + this._margins.left, bodyRec
t.left * zoomFactor); |
| 116 var top = Math.max(rect.top * zoomFactor + this._margins.top, bodyRect.t
op * zoomFactor); | 107 var top = Math.max(rect.top * zoomFactor + this._margins.top, bodyRect.t
op * zoomFactor); |
| 117 var bottom = Math.min(rect.bottom * zoomFactor - this._margins.bottom, b
odyRect.bottom * zoomFactor); | 108 var bottom = Math.min(rect.bottom * zoomFactor - this._margins.bottom, b
odyRect.bottom * zoomFactor); |
| 118 var right = Math.min(rect.right * zoomFactor - this._margins.right, body
Rect.right * zoomFactor); | 109 var right = Math.min(rect.right * zoomFactor - this._margins.right, body
Rect.right * zoomFactor); |
| 119 | 110 |
| 120 return { x: left, y: top, width: right - left, height: bottom - top }; | 111 return { x: left, y: top, width: right - left, height: bottom - top }; |
| 121 }, | 112 }, |
| 122 | 113 |
| 123 _update: function() | 114 update: function() |
| 124 { | 115 { |
| 125 delete this._updateId; | 116 delete this._updateId; |
| 126 if (this._noUpdates) | |
| 127 return; | |
| 128 | |
| 129 var rect = this._dipPageRect(); | 117 var rect = this._dipPageRect(); |
| 130 var bounds = { x: Math.round(rect.x), y: Math.round(rect.y), height: Mat
h.round(rect.height), width: Math.round(rect.width) }; | 118 var bounds = { x: Math.round(rect.x), y: Math.round(rect.y), height: Mat
h.round(rect.height), width: Math.round(rect.width) }; |
| 131 InspectorFrontendHost.setInspectedPageBounds(bounds); | 119 this.dispatchEventToListeners(WebInspector.InspectedPagePlaceholder.Even
ts.Update, bounds); |
| 132 }, | |
| 133 | |
| 134 _beforeDockSideChange: function() | |
| 135 { | |
| 136 this._noUpdates = true; | |
| 137 }, | |
| 138 | |
| 139 _afterDockSideChange: function() | |
| 140 { | |
| 141 this._noUpdates = false; | |
| 142 this._scheduleUpdate(); | |
| 143 }, | 120 }, |
| 144 | 121 |
| 145 __proto__: WebInspector.View.prototype | 122 __proto__: WebInspector.View.prototype |
| 146 }; | 123 }; |
| OLD | NEW |