Chromium Code Reviews| Index: remoting/webapp/client_session.js |
| diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js |
| index 51b72a751ffca4542a6f4d722a327f867a55f373..26b20c4c28ce2da4babe31ddf2a471a092618cf2 100644 |
| --- a/remoting/webapp/client_session.js |
| +++ b/remoting/webapp/client_session.js |
| @@ -161,11 +161,31 @@ remoting.ClientSession.prototype.setOnStateChange = function(onStateChange) { |
| * fixed. |
| */ |
| remoting.ClientSession.prototype.setScrollbarVisibility = function() { |
| + // Determine whether or not horizontal or vertical scrollbars are required, |
| + // taking into account their width. |
| + var kScrollBarWidth = 16; |
|
Wez
2013/08/03 00:19:51
Is this defined in our CSS?
Jamie
2013/08/03 00:36:16
Yes.
|
| + var needsVerticalScroll = |
| + !this.shrinkToFit_ && window.innerHeight < this.plugin.desktopHeight; |
|
Wez
2013/08/03 00:19:51
nit: Might be clearer to just skip this logic enti
Jamie
2013/08/03 00:36:16
I think it's clearer this way. The variables are c
Wez
2013/08/03 00:47:18
Yes, exactly. So why not:
needsHScroll = false;
n
Jamie
2013/08/03 01:35:54
Done.
|
| + var needsHorizontalScroll = |
| + !this.shrinkToFit_ && window.innerWidth < this.plugin.desktopWidth; |
| + if (needsHorizontalScroll && !needsVerticalScroll) { |
| + needsVerticalScroll = |
| + window.innerHeight - kScrollBarWidth < this.plugin.desktopHeight; |
| + } else if (!needsHorizontalScroll && needsVerticalScroll) { |
| + needsHorizontalScroll = |
| + window.innerWidth - kScrollBarWidth < this.plugin.desktopWidth; |
| + } |
| + |
| var htmlNode = /** @type {HTMLElement} */ (document.body.parentNode); |
| - if (this.shrinkToFit_) { |
| - htmlNode.classList.add('no-scroll'); |
| + if (needsHorizontalScroll) { |
| + htmlNode.classList.remove('no-horizontal-scroll'); |
| } else { |
| - htmlNode.classList.remove('no-scroll'); |
| + htmlNode.classList.add('no-horizontal-scroll'); |
| + } |
| + if (needsVerticalScroll) { |
| + htmlNode.classList.remove('no-vertical-scroll'); |
| + } else { |
| + htmlNode.classList.add('no-vertical-scroll'); |
| } |
| }; |
| @@ -930,6 +950,8 @@ remoting.ClientSession.prototype.onResize = function() { |
| // If bump-scrolling is enabled, adjust the plugin margins to fully utilize |
| // the new window area. |
| this.scroll_(0, 0); |
| + |
| + this.setScrollbarVisibility(); |
| }; |
| /** |