Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(657)

Unified Diff: remoting/webapp/me2mom/client_session.js

Issue 7821017: Center the desktop if it's smaller than the frame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/me2mom/choice.css ('k') | remoting/webapp/me2mom/toolbar.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/me2mom/client_session.js
diff --git a/remoting/webapp/me2mom/client_session.js b/remoting/webapp/me2mom/client_session.js
index bd0fc6a0f2dbe93bf34853deb97d5c60fb5ae114..75463910d199b958e983a719f3b5f44b5c76adde 100644
--- a/remoting/webapp/me2mom/client_session.js
+++ b/remoting/webapp/me2mom/client_session.js
@@ -352,11 +352,10 @@ remoting.ClientSession.prototype.setState_ = function(state) {
* @return {void} Nothing.
*/
remoting.ClientSession.prototype.onDesktopSizeChanged_ = function() {
- var width = this.plugin.desktopWidth;
- var height = this.plugin.desktopHeight;
- remoting.debug.log('desktop size changed: ' + width + 'x' + height);
- this.plugin.width = width;
- this.plugin.height = height;
+ remoting.debug.log('desktop size changed: ' +
+ this.plugin.desktopWidth + 'x' +
+ this.plugin.desktopHeight);
+ this.setScaleToFit(remoting.scaleToFit);
};
/**
@@ -395,6 +394,19 @@ remoting.ClientSession.prototype.setScaleToFit = function(shouldScale) {
this.plugin.width = this.plugin.desktopWidth;
this.plugin.height = this.plugin.desktopHeight;
}
+
+ // Resize the plugin's container. The container's style places its origin at
+ // the center of the page, so we use -ve margins to move that origin to the
+ // center of the container, rather than its top-left corner, so that it will
+ // appear centered on the page.
+ if (this.plugin.parentNode) {
+ var parentNode = this.plugin.parentNode;
+ parentNode.style["width"] = this.plugin.width + "px";
+ parentNode.style["height"] = this.plugin.height + "px";
+ parentNode.style["margin-left"] = -(this.plugin.width/2) + "px";
+ parentNode.style["margin-top"] = -(this.plugin.height/2) + "px";
+ }
+
remoting.debug.log('plugin size is now: ' +
this.plugin.width + ' x ' + this.plugin.height + '.');
this.plugin.setScaleToFit(shouldScale);
« no previous file with comments | « remoting/webapp/me2mom/choice.css ('k') | remoting/webapp/me2mom/toolbar.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698