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 /** |
| 5 * @unrestricted |
| 6 */ |
| 7 WebInspector.RootView = class extends WebInspector.VBox { |
| 8 constructor() { |
| 9 super(); |
| 10 this.markAsRoot(); |
| 11 this.element.classList.add('root-view'); |
| 12 this.registerRequiredCSS('ui/rootView.css'); |
| 13 this.element.setAttribute('spellcheck', false); |
| 14 } |
4 | 15 |
5 /** | 16 /** |
6 * @constructor | 17 * @param {!Document} document |
7 * @extends {WebInspector.VBox} | 18 */ |
8 */ | 19 attachToDocument(document) { |
9 WebInspector.RootView = function() | 20 document.defaultView.addEventListener('resize', this.doResize.bind(this), fa
lse); |
10 { | 21 this._window = document.defaultView; |
11 WebInspector.VBox.call(this); | 22 this.doResize(); |
12 this.markAsRoot(); | 23 this.show(/** @type {!Element} */ (document.body)); |
13 this.element.classList.add("root-view"); | 24 } |
14 this.registerRequiredCSS("ui/rootView.css"); | 25 |
15 this.element.setAttribute("spellcheck", false); | 26 /** |
| 27 * @override |
| 28 */ |
| 29 doResize() { |
| 30 if (this._window) { |
| 31 var size = this.constraints().minimum; |
| 32 var zoom = WebInspector.zoomManager.zoomFactor(); |
| 33 var right = Math.min(0, this._window.innerWidth - size.width / zoom); |
| 34 this.element.style.marginRight = right + 'px'; |
| 35 var bottom = Math.min(0, this._window.innerHeight - size.height / zoom); |
| 36 this.element.style.marginBottom = bottom + 'px'; |
| 37 } |
| 38 super.doResize(); |
| 39 } |
16 }; | 40 }; |
17 | |
18 WebInspector.RootView.prototype = { | |
19 /** | |
20 * @param {!Document} document | |
21 */ | |
22 attachToDocument: function(document) | |
23 { | |
24 document.defaultView.addEventListener("resize", this.doResize.bind(this)
, false); | |
25 this._window = document.defaultView; | |
26 this.doResize(); | |
27 this.show(/** @type {!Element} */ (document.body)); | |
28 }, | |
29 | |
30 doResize: function() | |
31 { | |
32 if (this._window) { | |
33 var size = this.constraints().minimum; | |
34 var zoom = WebInspector.zoomManager.zoomFactor(); | |
35 var right = Math.min(0, this._window.innerWidth - size.width / zoom)
; | |
36 this.element.style.marginRight = right + "px"; | |
37 var bottom = Math.min(0, this._window.innerHeight - size.height / zo
om); | |
38 this.element.style.marginBottom = bottom + "px"; | |
39 } | |
40 WebInspector.VBox.prototype.doResize.call(this); | |
41 }, | |
42 | |
43 __proto__: WebInspector.VBox.prototype | |
44 }; | |
OLD | NEW |