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..49f20221bf8f4be8506dd3fc5424fe4402a3cf95 100644 |
| --- a/remoting/webapp/client_session.js |
| +++ b/remoting/webapp/client_session.js |
| @@ -154,18 +154,38 @@ remoting.ClientSession.prototype.setOnStateChange = function(onStateChange) { |
| }; |
| /** |
| - * Called when the connection has been established to set the initial scroll- |
| - * bar visibility correctly. |
| + * Called when the connection has been established, and subsequently when the |
| + * window size or scaling settings change, to set the scroll-bar visibility. |
| * |
| * TODO(jamiewalch): crbug.com/252796: Remove this once crbug.com/240772 is |
| * fixed. |
| */ |
| remoting.ClientSession.prototype.setScrollbarVisibility = function() { |
| + // Determine whether or not horizontal or vertical scrollbars are required, |
| + // taking into account their width. |
| + var kScrollBarWidth = 16; |
| + var needsVerticalScroll = |
| + !this.shrinkToFit_ && window.innerHeight < this.plugin.desktopHeight; |
| + 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(); |
|
Wez
2013/08/03 00:47:18
nit: Add a comment e.g. "Show or hide the scrollba
Jamie
2013/08/03 01:35:55
This feels like a classic "Add 1 to x" style comme
|
| }; |
| /** |