Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/InspectedPagePlaceholder.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 WebInspector.InspectedPagePlaceholder = class extends WebInspector.Widget { 7 Emulation.InspectedPagePlaceholder = class extends UI.Widget {
8 constructor() { 8 constructor() {
9 super(true); 9 super(true);
10 this.registerRequiredCSS('emulation/inspectedPagePlaceholder.css'); 10 this.registerRequiredCSS('emulation/inspectedPagePlaceholder.css');
11 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo omChanged, this._scheduleUpdate, this); 11 UI.zoomManager.addEventListener(UI.ZoomManager.Events.ZoomChanged, this._sch eduleUpdate, this);
12 this._margins = {top: 0, right: 0, bottom: 0, left: 0}; 12 this._margins = {top: 0, right: 0, bottom: 0, left: 0};
13 this.restoreMinimumSizeAndMargins(); 13 this.restoreMinimumSizeAndMargins();
14 } 14 }
15 15
16 _findMargins() { 16 _findMargins() {
17 var margins = {top: 0, right: 0, bottom: 0, left: 0}; 17 var margins = {top: 0, right: 0, bottom: 0, left: 0};
18 18
19 if (this._useMargins) { 19 if (this._useMargins) {
20 var adjacent = {top: true, right: true, bottom: true, left: true}; 20 var adjacent = {top: true, right: true, bottom: true, left: true};
21 var widget = this; 21 var widget = this;
22 while (widget.parentWidget()) { 22 while (widget.parentWidget()) {
23 var parent = widget.parentWidget(); 23 var parent = widget.parentWidget();
24 // This view assumes it's always inside the main split widget element, n ot a sidebar. 24 // This view assumes it's always inside the main split widget element, n ot a sidebar.
25 // Every parent which is not a split widget, must be of the same size as this widget. 25 // Every parent which is not a split widget, must be of the same size as this widget.
26 if (parent instanceof WebInspector.SplitWidget) { 26 if (parent instanceof UI.SplitWidget) {
27 var side = parent.sidebarSide(); 27 var side = parent.sidebarSide();
28 if (adjacent[side] && !parent.hasCustomResizer() && parent.isResizable ()) 28 if (adjacent[side] && !parent.hasCustomResizer() && parent.isResizable ())
29 margins[side] = WebInspector.InspectedPagePlaceholder.MarginValue; 29 margins[side] = Emulation.InspectedPagePlaceholder.MarginValue;
30 adjacent[side] = false; 30 adjacent[side] = false;
31 } 31 }
32 widget = parent; 32 widget = parent;
33 } 33 }
34 } 34 }
35 35
36 if (this._margins.top !== margins.top || this._margins.left !== margins.left || 36 if (this._margins.top !== margins.top || this._margins.left !== margins.left ||
37 this._margins.right !== margins.right || this._margins.bottom !== margin s.bottom) { 37 this._margins.right !== margins.right || this._margins.bottom !== margin s.bottom) {
38 this._margins = margins; 38 this._margins = margins;
39 this._scheduleUpdate(); 39 this._scheduleUpdate();
(...skipping 20 matching lines...) Expand all
60 this._findMargins(); 60 this._findMargins();
61 } 61 }
62 62
63 clearMinimumSizeAndMargins() { 63 clearMinimumSizeAndMargins() {
64 this._useMargins = false; 64 this._useMargins = false;
65 this.setMinimumSize(1, 1); 65 this.setMinimumSize(1, 1);
66 this._findMargins(); 66 this._findMargins();
67 } 67 }
68 68
69 _dipPageRect() { 69 _dipPageRect() {
70 var zoomFactor = WebInspector.zoomManager.zoomFactor(); 70 var zoomFactor = UI.zoomManager.zoomFactor();
71 var rect = this.element.getBoundingClientRect(); 71 var rect = this.element.getBoundingClientRect();
72 var bodyRect = this.element.ownerDocument.body.getBoundingClientRect(); 72 var bodyRect = this.element.ownerDocument.body.getBoundingClientRect();
73 73
74 var left = Math.max(rect.left * zoomFactor + this._margins.left, bodyRect.le ft * zoomFactor); 74 var left = Math.max(rect.left * zoomFactor + this._margins.left, bodyRect.le ft * zoomFactor);
75 var top = Math.max(rect.top * zoomFactor + this._margins.top, bodyRect.top * zoomFactor); 75 var top = Math.max(rect.top * zoomFactor + this._margins.top, bodyRect.top * zoomFactor);
76 var bottom = Math.min(rect.bottom * zoomFactor - this._margins.bottom, bodyR ect.bottom * zoomFactor); 76 var bottom = Math.min(rect.bottom * zoomFactor - this._margins.bottom, bodyR ect.bottom * zoomFactor);
77 var right = Math.min(rect.right * zoomFactor - this._margins.right, bodyRect .right * zoomFactor); 77 var right = Math.min(rect.right * zoomFactor - this._margins.right, bodyRect .right * zoomFactor);
78 78
79 return {x: left, y: top, width: right - left, height: bottom - top}; 79 return {x: left, y: top, width: right - left, height: bottom - top};
80 } 80 }
81 81
82 update() { 82 update() {
83 delete this._updateId; 83 delete this._updateId;
84 var rect = this._dipPageRect(); 84 var rect = this._dipPageRect();
85 var bounds = { 85 var bounds = {
86 x: Math.round(rect.x), 86 x: Math.round(rect.x),
87 y: Math.round(rect.y), 87 y: Math.round(rect.y),
88 height: Math.max(1, Math.round(rect.height)), 88 height: Math.max(1, Math.round(rect.height)),
89 width: Math.max(1, Math.round(rect.width)) 89 width: Math.max(1, Math.round(rect.width))
90 }; 90 };
91 this.dispatchEventToListeners(WebInspector.InspectedPagePlaceholder.Events.U pdate, bounds); 91 this.dispatchEventToListeners(Emulation.InspectedPagePlaceholder.Events.Upda te, bounds);
92 } 92 }
93 }; 93 };
94 94
95 /** @enum {symbol} */ 95 /** @enum {symbol} */
96 WebInspector.InspectedPagePlaceholder.Events = { 96 Emulation.InspectedPagePlaceholder.Events = {
97 Update: Symbol('Update') 97 Update: Symbol('Update')
98 }; 98 };
99 99
100 WebInspector.InspectedPagePlaceholder.MarginValue = 3; 100 Emulation.InspectedPagePlaceholder.MarginValue = 3;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698