Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / devtools / front_end / ui / ZoomManager.js
blobf67ad0642982cbfb5632de6bd62596892aa245d4
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.
5 /**
6 * @constructor
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 = {
23 /**
24 * @return {number}
26 zoomFactor: function()
28 return this._zoomFactor;
31 /**
32 * @param {number} value
33 * @return {number}
35 cssToDIP: function(value)
37 return value * this._zoomFactor;
40 /**
41 * @param {number} valueDIP
42 * @return {number}
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
60 /**
61 * @type {!WebInspector.ZoomManager}
63 WebInspector.zoomManager;