| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This file provides the PinchAction object, which zooms into or out of a | 5 // This file provides the PinchAction object, which zooms into or out of a |
| 6 // page by a given scale factor: | 6 // page by a given scale factor: |
| 7 // 1. var action = new __PinchAction(callback) | 7 // 1. var action = new __PinchAction(callback) |
| 8 // 2. action.start(pinch_options) | 8 // 2. action.start(pinch_options) |
| 9 'use strict'; | 9 'use strict'; |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 this.left_anchor_ratio_ = 0.5; | 22 this.left_anchor_ratio_ = 0.5; |
| 23 this.top_anchor_ratio_ = 0.5; | 23 this.top_anchor_ratio_ = 0.5; |
| 24 this.scale_factor_ = 2.0; | 24 this.scale_factor_ = 2.0; |
| 25 this.speed_ = 800; | 25 this.speed_ = 800; |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 | 28 |
| 29 function supportedByBrowser() { | 29 function supportedByBrowser() { |
| 30 return !!(window.chrome && | 30 return !!(window.chrome && |
| 31 chrome.gpuBenchmarking && | 31 chrome.gpuBenchmarking && |
| 32 chrome.gpuBenchmarking.pinchBy); | 32 chrome.gpuBenchmarking.pinchBy && |
| 33 chrome.gpuBenchmarking.visualViewportHeight && |
| 34 chrome.gpuBenchmarking.visualViewportWidth); |
| 33 } | 35 } |
| 34 | 36 |
| 35 // This class zooms into or out of a page, given a number of pixels for | 37 // This class zooms into or out of a page, given a number of pixels for |
| 36 // the synthetic pinch gesture to cover. | 38 // the synthetic pinch gesture to cover. |
| 37 function PinchAction(opt_callback) { | 39 function PinchAction(opt_callback) { |
| 38 var self = this; | 40 var self = this; |
| 39 | 41 |
| 40 this.beginMeasuringHook = function() {} | 42 this.beginMeasuringHook = function() {}; |
| 41 this.endMeasuringHook = function() {} | 43 this.endMeasuringHook = function() {}; |
| 42 | 44 |
| 43 this.callback_ = opt_callback; | 45 this.callback_ = opt_callback; |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 PinchAction.prototype.start = function(opt_options) { | 48 PinchAction.prototype.start = function(opt_options) { |
| 47 this.options_ = new PinchGestureOptions(opt_options); | 49 this.options_ = new PinchGestureOptions(opt_options); |
| 48 | 50 |
| 49 requestAnimationFrame(this.startPass_.bind(this)); | 51 requestAnimationFrame(this.startPass_.bind(this)); |
| 50 }; | 52 }; |
| 51 | 53 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 66 PinchAction.prototype.onGestureComplete_ = function() { | 68 PinchAction.prototype.onGestureComplete_ = function() { |
| 67 this.endMeasuringHook(); | 69 this.endMeasuringHook(); |
| 68 | 70 |
| 69 if (this.callback_) | 71 if (this.callback_) |
| 70 this.callback_(); | 72 this.callback_(); |
| 71 }; | 73 }; |
| 72 | 74 |
| 73 window.__PinchAction = PinchAction; | 75 window.__PinchAction = PinchAction; |
| 74 window.__PinchAction_SupportedByBrowser = supportedByBrowser; | 76 window.__PinchAction_SupportedByBrowser = supportedByBrowser; |
| 75 })(); | 77 })(); |
| OLD | NEW |