| 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Viewport class controls the way the image is displayed (scale, offset etc). | 8 * Viewport class controls the way the image is displayed (scale, offset etc). |
| 9 * @constructor | 9 * @constructor |
| 10 */ | 10 */ |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 this.imageBoundsOnScreenClipped_ = new Rect( | 430 this.imageBoundsOnScreenClipped_ = new Rect( |
| 431 left, top, right - left, bottom - top); | 431 left, top, right - left, bottom - top); |
| 432 }; | 432 }; |
| 433 | 433 |
| 434 /** | 434 /** |
| 435 * Obtains CSS transformation for the screen image. | 435 * Obtains CSS transformation for the screen image. |
| 436 * @return {string} Transformation description. | 436 * @return {string} Transformation description. |
| 437 */ | 437 */ |
| 438 Viewport.prototype.getTransformation = function() { | 438 Viewport.prototype.getTransformation = function() { |
| 439 return 'translate(' + this.offsetX_ + 'px, ' + this.offsetY_ + 'px) ' + | 439 return 'translate(' + this.offsetX_ + 'px, ' + this.offsetY_ + 'px) ' + |
| 440 'scale(' + (1 / window.devicePixelRatio * this.zoom_) + ')'; | 440 'scale(' + this.zoom_ + ')'; |
| 441 }; | 441 }; |
| 442 | 442 |
| 443 /** | 443 /** |
| 444 * Obtains shift CSS transformation for the screen image. | 444 * Obtains shift CSS transformation for the screen image. |
| 445 * @param {number} dx Amount of shift. | 445 * @param {number} dx Amount of shift. |
| 446 * @return {string} Transformation description. | 446 * @return {string} Transformation description. |
| 447 */ | 447 */ |
| 448 Viewport.prototype.getShiftTransformation = function(dx) { | 448 Viewport.prototype.getShiftTransformation = function(dx) { |
| 449 return 'translateX(' + dx + 'px) ' + this.getTransformation(); | 449 return 'translateX(' + dx + 'px) ' + this.getTransformation(); |
| 450 }; | 450 }; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 var screenWidth = this.screenBounds_.width; | 515 var screenWidth = this.screenBounds_.width; |
| 516 var screenHeight = this.screenBounds_.height; | 516 var screenHeight = this.screenBounds_.height; |
| 517 var dx = screenRect.left + screenRect.width / 2 - screenWidth / 2; | 517 var dx = screenRect.left + screenRect.width / 2 - screenWidth / 2; |
| 518 var dy = screenRect.top + screenRect.height / 2 - screenHeight / 2; | 518 var dy = screenRect.top + screenRect.height / 2 - screenHeight / 2; |
| 519 return [ | 519 return [ |
| 520 'translate(' + dx + 'px,' + dy + 'px)', | 520 'translate(' + dx + 'px,' + dy + 'px)', |
| 521 'scale(' + scaleX + ',' + scaleY + ')', | 521 'scale(' + scaleX + ',' + scaleY + ')', |
| 522 this.getTransformation() | 522 this.getTransformation() |
| 523 ].join(' '); | 523 ].join(' '); |
| 524 }; | 524 }; |
| OLD | NEW |