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
3 // found in the LICENSE file.
7 * @extends {WebInspector.Object}
8 * @param {!Window} window
9 * @param {!InspectorFrontendHostAPI} frontendHost
11 WebInspector
.ZoomManager = function(window
, frontendHost
)
13 this._frontendHost
= frontendHost
;
14 this._zoomFactor
= this._frontendHost
.zoomFactor();
15 window
.addEventListener("resize", this._onWindowResize
.bind(this), true);
18 WebInspector
.ZoomManager
.Events
= {
19 ZoomChanged
: "ZoomChanged"
22 WebInspector
.ZoomManager
.prototype = {
26 zoomFactor: function()
28 return this._zoomFactor
;
32 * @param {number} value
35 cssToDIP: function(value
)
37 return value
* this._zoomFactor
;
41 * @param {number} valueDIP
44 dipToCSS: function(valueDIP
)
46 return valueDIP
/ this._zoomFactor
;
49 _onWindowResize: function()
51 var oldZoomFactor
= this._zoomFactor
;
52 this._zoomFactor
= this._frontendHost
.zoomFactor();
53 if (oldZoomFactor
!== this._zoomFactor
)
54 this.dispatchEventToListeners(WebInspector
.ZoomManager
.Events
.ZoomChanged
, {from: oldZoomFactor
, to
: this._zoomFactor
});
57 __proto__
: WebInspector
.Object
.prototype
61 * @type {!WebInspector.ZoomManager}
63 WebInspector
.zoomManager
;