| 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 * @suppressGlobalPropertiesCheck | |
| 9 */ | 8 */ |
| 10 WebInspector.RootView = function() | 9 WebInspector.RootView = function() |
| 11 { | 10 { |
| 12 WebInspector.VBox.call(this); | 11 WebInspector.VBox.call(this); |
| 13 this.markAsRoot(); | 12 this.markAsRoot(); |
| 14 this.element.classList.add("root-view"); | 13 this.element.classList.add("root-view"); |
| 15 this.element.setAttribute("spellcheck", false); | 14 this.element.setAttribute("spellcheck", false); |
| 16 // This view is not designed to change owner document. | |
| 17 window.addEventListener("resize", this.doResize.bind(this), false); | |
| 18 } | 15 } |
| 19 | 16 |
| 20 WebInspector.RootView.prototype = { | 17 WebInspector.RootView.prototype = { |
| 21 /** | 18 /** |
| 22 * @public // FIXME: this is a workaround for validator bug (http://crbug.co
m/425506). | 19 * @param {!Document} document |
| 23 * @suppressGlobalPropertiesCheck | |
| 24 */ | 20 */ |
| 25 attachToBody: function() | 21 attachToDocument: function(document) |
| 26 { | 22 { |
| 23 document.defaultView.addEventListener("resize", this.doResize.bind(this)
, false); |
| 24 this._window = document.defaultView; |
| 27 this.doResize(); | 25 this.doResize(); |
| 28 this.show(document.body); | 26 this.show(document.body); |
| 29 }, | 27 }, |
| 30 | 28 |
| 31 doResize: function() | 29 doResize: function() |
| 32 { | 30 { |
| 33 var size = this.constraints().minimum; | 31 if (this._window) { |
| 34 var zoom = WebInspector.zoomManager.zoomFactor(); | 32 var size = this.constraints().minimum; |
| 35 var right = Math.min(0, window.innerWidth - size.width / zoom); | 33 var zoom = WebInspector.zoomManager.zoomFactor(); |
| 36 this.element.style.marginRight = right + "px"; | 34 var right = Math.min(0, this._window.innerWidth - size.width / zoom)
; |
| 37 var bottom = Math.min(0, window.innerHeight - size.height / zoom); | 35 this.element.style.marginRight = right + "px"; |
| 38 this.element.style.marginBottom = bottom + "px"; | 36 var bottom = Math.min(0, this._window.innerHeight - size.height / zo
om); |
| 37 this.element.style.marginBottom = bottom + "px"; |
| 38 } |
| 39 WebInspector.VBox.prototype.doResize.call(this); | 39 WebInspector.VBox.prototype.doResize.call(this); |
| 40 }, | 40 }, |
| 41 | 41 |
| 42 __proto__: WebInspector.VBox.prototype | 42 __proto__: WebInspector.VBox.prototype |
| 43 } | 43 } |
| OLD | NEW |