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.Widget} |
8 */ | 8 */ |
9 WebInspector.InspectedPagePlaceholder = function() | 9 WebInspector.InspectedPagePlaceholder = function() |
10 { | 10 { |
11 WebInspector.View.call(this); | 11 WebInspector.Widget.call(this); |
12 this.element.classList.add("inspected-page-placeholder"); | 12 this.element.classList.add("inspected-page-placeholder"); |
13 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._scheduleUpdate, 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 }; | 16 }; |
17 | 17 |
18 WebInspector.InspectedPagePlaceholder.Events = { | 18 WebInspector.InspectedPagePlaceholder.Events = { |
19 Update: "Update" | 19 Update: "Update" |
20 }; | 20 }; |
21 | 21 |
22 WebInspector.InspectedPagePlaceholder.MarginValue = 3; | 22 WebInspector.InspectedPagePlaceholder.MarginValue = 3; |
23 | 23 |
24 WebInspector.InspectedPagePlaceholder.prototype = { | 24 WebInspector.InspectedPagePlaceholder.prototype = { |
25 _findMargins: function() | 25 _findMargins: function() |
26 { | 26 { |
27 var margins = { top: 0, right: 0, bottom: 0, left: 0 }; | 27 var margins = { top: 0, right: 0, bottom: 0, left: 0 }; |
28 | 28 |
29 if (this._useMargins) { | 29 if (this._useMargins) { |
30 var adjacent = { top: true, right: true, bottom: true, left: true }; | 30 var adjacent = { top: true, right: true, bottom: true, left: true }; |
31 var view = this; | 31 var widget = this; |
32 while (view.parentView()) { | 32 while (widget.parentWidget()) { |
33 var parent = view.parentView(); | 33 var parent = widget.parentWidget(); |
34 // This view assumes it's always inside the main split view elem
ent, not a sidebar. | 34 // This view assumes it's always inside the main split widget el
ement, not a sidebar. |
35 // Every parent which is not a split view, must be of the same s
ize as this view. | 35 // Every parent which is not a split widget, must be of the same
size as this widget. |
36 if (parent instanceof WebInspector.SplitView) { | 36 if (parent instanceof WebInspector.SplitWidget) { |
37 var side = parent.sidebarSide(); | 37 var side = parent.sidebarSide(); |
38 if (adjacent[side] && !parent.hasCustomResizer() && parent.i
sResizable()) | 38 if (adjacent[side] && !parent.hasCustomResizer() && parent.i
sResizable()) |
39 margins[side] = WebInspector.InspectedPagePlaceholder.Ma
rginValue; | 39 margins[side] = WebInspector.InspectedPagePlaceholder.Ma
rginValue; |
40 adjacent[side] = false; | 40 adjacent[side] = false; |
41 } | 41 } |
42 view = parent; | 42 widget = parent; |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 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) { |
47 this._margins = margins; | 47 this._margins = margins; |
48 this._scheduleUpdate(); | 48 this._scheduleUpdate(); |
49 } | 49 } |
50 }, | 50 }, |
51 | 51 |
52 onResize: function() | 52 onResize: function() |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 }, | 91 }, |
92 | 92 |
93 update: function() | 93 update: function() |
94 { | 94 { |
95 delete this._updateId; | 95 delete this._updateId; |
96 var rect = this._dipPageRect(); | 96 var rect = this._dipPageRect(); |
97 var bounds = { x: Math.round(rect.x), y: Math.round(rect.y), height: Mat
h.max(1, Math.round(rect.height)), width: Math.max(1, Math.round(rect.width)) }; | 97 var bounds = { x: Math.round(rect.x), y: Math.round(rect.y), height: Mat
h.max(1, Math.round(rect.height)), width: Math.max(1, Math.round(rect.width)) }; |
98 this.dispatchEventToListeners(WebInspector.InspectedPagePlaceholder.Even
ts.Update, bounds); | 98 this.dispatchEventToListeners(WebInspector.InspectedPagePlaceholder.Even
ts.Update, bounds); |
99 }, | 99 }, |
100 | 100 |
101 __proto__: WebInspector.View.prototype | 101 __proto__: WebInspector.Widget.prototype |
102 }; | 102 }; |
OLD | NEW |