| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** | 
| 6  * @fileoverview | 6  * @fileoverview | 
| 7  * Provides view port management utilities below for a desktop remoting session. | 7  * Provides view port management utilities below for a desktop remoting session. | 
| 8  * - Enabling bump scrolling | 8  * - Enabling bump scrolling | 
| 9  * - Resizing the viewport to fit the host desktop | 9  * - Resizing the viewport to fit the host desktop | 
| 10  * - Resizing the host desktop to fit the client viewport. | 10  * - Resizing the host desktop to fit the client viewport. | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 46   // and height of the client plugin so that bump-scrolling can be tested | 46   // and height of the client plugin so that bump-scrolling can be tested | 
| 47   // without relying on the actual size of the host desktop. | 47   // without relying on the actual size of the host desktop. | 
| 48   /** @private {number} */ | 48   /** @private {number} */ | 
| 49   this.pluginWidthForBumpScrollTesting_ = 0; | 49   this.pluginWidthForBumpScrollTesting_ = 0; | 
| 50   /** @private {number} */ | 50   /** @private {number} */ | 
| 51   this.pluginHeightForBumpScrollTesting_ = 0; | 51   this.pluginHeightForBumpScrollTesting_ = 0; | 
| 52 | 52 | 
| 53   this.eventHooks_ = new base.Disposables( | 53   this.eventHooks_ = new base.Disposables( | 
| 54       new base.EventHook( | 54       new base.EventHook( | 
| 55         this.hostDesktop_, remoting.HostDesktop.Events.sizeChanged, | 55         this.hostDesktop_, remoting.HostDesktop.Events.sizeChanged, | 
| 56         this.onDesktopSizeChanged_.bind(this)), | 56         this.onDesktopSizeChanged_.bind(this))); | 
| 57       // TODO(kelvinp): Move window shape related logic into |  | 
| 58       // remoting.AppConnectedView. |  | 
| 59       new base.EventHook( |  | 
| 60         this.hostDesktop_, remoting.HostDesktop.Events.shapeChanged, |  | 
| 61         remoting.windowShape.setDesktopRects.bind(remoting.windowShape))); |  | 
| 62 | 57 | 
| 63   if (this.hostOptions_.resizeToClient) { | 58   if (this.hostOptions_.resizeToClient) { | 
| 64     // TODO(kelvinp): This call is required in app remoting to set the host |  | 
| 65     // desktop size.  Move this to remoting.AppConnectedView later. |  | 
| 66     this.resizeHostDesktop_(); | 59     this.resizeHostDesktop_(); | 
| 67   } else { | 60   } else { | 
| 68     this.onDesktopSizeChanged_(); | 61     this.onDesktopSizeChanged_(); | 
| 69   } | 62   } | 
| 70 }; | 63 }; | 
| 71 | 64 | 
| 72 remoting.DesktopViewport.prototype.dispose = function() { | 65 remoting.DesktopViewport.prototype.dispose = function() { | 
| 73   base.dispose(this.eventHooks_); | 66   base.dispose(this.eventHooks_); | 
| 74   this.eventHooks_ = null; | 67   this.eventHooks_ = null; | 
| 75   base.dispose(this.bumpScroller_); | 68   base.dispose(this.bumpScroller_); | 
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 339                      y: dimensions.yDpi }; | 332                      y: dimensions.yDpi }; | 
| 340   var newSize = remoting.DesktopViewport.choosePluginSize( | 333   var newSize = remoting.DesktopViewport.choosePluginSize( | 
| 341       this.getClientArea(), window.devicePixelRatio, | 334       this.getClientArea(), window.devicePixelRatio, | 
| 342       desktopSize, desktopDpi, this.hostOptions_.desktopScale, | 335       desktopSize, desktopDpi, this.hostOptions_.desktopScale, | 
| 343       remoting.fullscreen.isActive(), this.hostOptions_.shrinkToFit); | 336       remoting.fullscreen.isActive(), this.hostOptions_.shrinkToFit); | 
| 344 | 337 | 
| 345   // Resize the plugin if necessary. | 338   // Resize the plugin if necessary. | 
| 346   console.log('plugin dimensions:' + newSize.width + 'x' + newSize.height); | 339   console.log('plugin dimensions:' + newSize.width + 'x' + newSize.height); | 
| 347   this.pluginElement_.style.width = newSize.width + 'px'; | 340   this.pluginElement_.style.width = newSize.width + 'px'; | 
| 348   this.pluginElement_.style.height = newSize.height + 'px'; | 341   this.pluginElement_.style.height = newSize.height + 'px'; | 
| 349 |  | 
| 350   // When we receive the first plugin dimensions from the host, we know that |  | 
| 351   // remote host has started. |  | 
| 352   remoting.app.onVideoStreamingStarted(); |  | 
| 353 }; | 342 }; | 
| 354 | 343 | 
| 355 /** | 344 /** | 
| 356  * Helper function accepting client and host dimensions, and returning a chosen | 345  * Helper function accepting client and host dimensions, and returning a chosen | 
| 357  * size for the plugin element, in DIPs. | 346  * size for the plugin element, in DIPs. | 
| 358  * | 347  * | 
| 359  * @param {{width: number, height: number}} clientSizeDips Available client | 348  * @param {{width: number, height: number}} clientSizeDips Available client | 
| 360  *     dimensions, in DIPs. | 349  *     dimensions, in DIPs. | 
| 361  * @param {number} clientPixelRatio Number of physical pixels per client DIP. | 350  * @param {number} clientPixelRatio Number of physical pixels per client DIP. | 
| 362  * @param {{width: number, height: number}} desktopSize Size of the host desktop | 351  * @param {{width: number, height: number}} desktopSize Size of the host desktop | 
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 485   return { width: pluginWidth, height: pluginHeight }; | 474   return { width: pluginWidth, height: pluginHeight }; | 
| 486 }; | 475 }; | 
| 487 | 476 | 
| 488 /** @private */ | 477 /** @private */ | 
| 489 remoting.DesktopViewport.prototype.resetScroll_ = function() { | 478 remoting.DesktopViewport.prototype.resetScroll_ = function() { | 
| 490   this.pluginContainer_.style.marginTop = '0px'; | 479   this.pluginContainer_.style.marginTop = '0px'; | 
| 491   this.pluginContainer_.style.marginLeft = '0px'; | 480   this.pluginContainer_.style.marginLeft = '0px'; | 
| 492 }; | 481 }; | 
| 493 | 482 | 
| 494 }()); | 483 }()); | 
| OLD | NEW | 
|---|