Skip to content

Commit

Permalink
Fix click-to-play positioning.
Browse files Browse the repository at this point in the history
BUG=370687

Review URL: https://codereview.chromium.org/335853004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277127 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jamiewalch@chromium.org committed Jun 13, 2014
1 parent 332ba22 commit c2ef3eb
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions remoting/webapp/client_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ remoting.ClientPlugin.prototype.handleMessageMethod_ = function(message) {
};

if (message.method == 'hello') {
// Reset the size in case we had to enlarge it to support click-to-play.
this.plugin.style.width = '0px';
this.plugin.style.height = '0px';
// Resize in case we had to enlarge it to support click-to-play.
this.hidePluginForClickToPlay_();
this.pluginApiVersion_ = getNumberAttr(message.data, 'apiVersion');
this.pluginApiMinVersion_ = getNumberAttr(message.data, 'apiMinVersion');

Expand Down Expand Up @@ -703,10 +702,22 @@ remoting.ClientPlugin.prototype.showPluginForClickToPlay_ = function() {
this.plugin.style.width = width + 'px';
this.plugin.style.height = height + 'px';
// Center the plugin just underneath the "Connnecting..." dialog.
var parentNode = this.plugin.parentNode;
var dialog = document.getElementById('client-dialog');
var dialogRect = dialog.getBoundingClientRect();
parentNode.style.top = (dialogRect.bottom + 16) + 'px';
parentNode.style.left = (window.innerWidth - width) / 2 + 'px';
this.plugin.style.top = (dialogRect.bottom + 16) + 'px';
this.plugin.style.left = (window.innerWidth - width) / 2 + 'px';
this.plugin.style.position = 'fixed';
}
};

/**
* Undo the CSS rules needed to make the plugin clickable for click-to-play.
* @private
*/
remoting.ClientPlugin.prototype.hidePluginForClickToPlay_ = function() {
this.plugin.style.width = '';
this.plugin.style.height = '';
this.plugin.style.top = '';
this.plugin.style.left = '';
this.plugin.style.position = '';
};

0 comments on commit c2ef3eb

Please sign in to comment.