Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / ui / ZoomManager.js
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.
4
5 /**
6  * @constructor
7  * @extends {WebInspector.Object}
8  * @param {!Window} window
9  * @param {!InspectorFrontendHostAPI} frontendHost
10  */
11 WebInspector.ZoomManager = function(window, frontendHost)
12 {
13     this._frontendHost = frontendHost;
14     this._zoomFactor = this._frontendHost.zoomFactor();
15     window.addEventListener("resize", this._onWindowResize.bind(this), true);
16 };
17
18 WebInspector.ZoomManager.Events = {
19     ZoomChanged: "ZoomChanged"
20 };
21
22 WebInspector.ZoomManager.prototype = {
23     /**
24      * @return {number}
25      */
26     zoomFactor: function()
27     {
28         return this._zoomFactor;
29     },
30
31     _onWindowResize: function()
32     {
33         var oldZoomFactor = this._zoomFactor;
34         this._zoomFactor = this._frontendHost.zoomFactor();
35         if (oldZoomFactor !== this._zoomFactor)
36             this.dispatchEventToListeners(WebInspector.ZoomManager.Events.ZoomChanged, {from: oldZoomFactor, to: this._zoomFactor});
37     },
38
39     __proto__: WebInspector.Object.prototype
40 };
41
42 /**
43  * @type {!WebInspector.ZoomManager}
44  */
45 WebInspector.zoomManager;