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

Side by Side Diff: remoting/webapp/client_session.js

Issue 22006002: Fix scroll-bar behaviour. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment. Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | remoting/webapp/main.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * Class handling creation and teardown of a remoting client session. 7 * Class handling creation and teardown of a remoting client session.
8 * 8 *
9 * The ClientSession class controls lifetime of the client plugin 9 * The ClientSession class controls lifetime of the client plugin
10 * object and provides the plugin with the functionality it needs to 10 * object and provides the plugin with the functionality it needs to
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 /** 147 /**
148 * @param {?function(remoting.ClientSession.State, 148 * @param {?function(remoting.ClientSession.State,
149 remoting.ClientSession.State):void} onStateChange 149 remoting.ClientSession.State):void} onStateChange
150 * The callback to invoke when the session changes state. 150 * The callback to invoke when the session changes state.
151 */ 151 */
152 remoting.ClientSession.prototype.setOnStateChange = function(onStateChange) { 152 remoting.ClientSession.prototype.setOnStateChange = function(onStateChange) {
153 this.onStateChange_ = onStateChange; 153 this.onStateChange_ = onStateChange;
154 }; 154 };
155 155
156 /** 156 /**
157 * Called when the connection has been established to set the initial scroll- 157 * Called when the connection has been established, and subsequently when the
158 * bar visibility correctly. 158 * window size or scaling settings change, to set the scroll-bar visibility.
159 * 159 *
160 * TODO(jamiewalch): crbug.com/252796: Remove this once crbug.com/240772 is 160 * TODO(jamiewalch): crbug.com/252796: Remove this once crbug.com/240772 is
161 * fixed. 161 * fixed.
162 */ 162 */
163 remoting.ClientSession.prototype.setScrollbarVisibility = function() { 163 remoting.ClientSession.prototype.setScrollbarVisibility = function() {
164 // Determine whether or not horizontal or vertical scrollbars are required,
165 // taking into account their width.
166 var kScrollBarWidth = 16;
167 var needsVerticalScroll =
168 !this.shrinkToFit_ && window.innerHeight < this.plugin.desktopHeight;
169 var needsHorizontalScroll =
170 !this.shrinkToFit_ && window.innerWidth < this.plugin.desktopWidth;
171 if (needsHorizontalScroll && !needsVerticalScroll) {
172 needsVerticalScroll =
173 window.innerHeight - kScrollBarWidth < this.plugin.desktopHeight;
174 } else if (!needsHorizontalScroll && needsVerticalScroll) {
175 needsHorizontalScroll =
176 window.innerWidth - kScrollBarWidth < this.plugin.desktopWidth;
177 }
178
164 var htmlNode = /** @type {HTMLElement} */ (document.body.parentNode); 179 var htmlNode = /** @type {HTMLElement} */ (document.body.parentNode);
165 if (this.shrinkToFit_) { 180 if (needsHorizontalScroll) {
166 htmlNode.classList.add('no-scroll'); 181 htmlNode.classList.remove('no-horizontal-scroll');
167 } else { 182 } else {
168 htmlNode.classList.remove('no-scroll'); 183 htmlNode.classList.add('no-horizontal-scroll');
184 }
185 if (needsVerticalScroll) {
186 htmlNode.classList.remove('no-vertical-scroll');
187 } else {
188 htmlNode.classList.add('no-vertical-scroll');
169 } 189 }
170 }; 190 };
171 191
172 // Note that the positive values in both of these enums are copied directly 192 // Note that the positive values in both of these enums are copied directly
173 // from chromoting_scriptable_object.h and must be kept in sync. The negative 193 // from chromoting_scriptable_object.h and must be kept in sync. The negative
174 // values represent state transitions that occur within the web-app that have 194 // values represent state transitions that occur within the web-app that have
175 // no corresponding plugin state transition. 195 // no corresponding plugin state transition.
176 /** @enum {number} */ 196 /** @enum {number} */
177 remoting.ClientSession.State = { 197 remoting.ClientSession.State = {
178 CONNECTION_CANCELED: -5, // Connection closed (gracefully) before connecting. 198 CONNECTION_CANCELED: -5, // Connection closed (gracefully) before connecting.
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 this.plugin.notifyClientResolution.bind(this.plugin, 943 this.plugin.notifyClientResolution.bind(this.plugin,
924 window.innerWidth, 944 window.innerWidth,
925 window.innerHeight, 945 window.innerHeight,
926 window.devicePixelRatio), 946 window.devicePixelRatio),
927 kResizeRateLimitMs); 947 kResizeRateLimitMs);
928 } 948 }
929 949
930 // If bump-scrolling is enabled, adjust the plugin margins to fully utilize 950 // If bump-scrolling is enabled, adjust the plugin margins to fully utilize
931 // the new window area. 951 // the new window area.
932 this.scroll_(0, 0); 952 this.scroll_(0, 0);
953
954 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
933 }; 955 };
934 956
935 /** 957 /**
936 * Requests that the host pause or resume video updates. 958 * Requests that the host pause or resume video updates.
937 * 959 *
938 * @param {boolean} pause True to pause video, false to resume. 960 * @param {boolean} pause True to pause video, false to resume.
939 * @return {void} Nothing. 961 * @return {void} Nothing.
940 */ 962 */
941 remoting.ClientSession.prototype.pauseVideo = function(pause) { 963 remoting.ClientSession.prototype.pauseVideo = function(pause) {
942 if (this.plugin) { 964 if (this.plugin) {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 var lateAdjustment = 1 + (now - expected) / timeout; 1278 var lateAdjustment = 1 + (now - expected) / timeout;
1257 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) { 1279 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) {
1258 that.bumpScrollTimer_ = window.setTimeout( 1280 that.bumpScrollTimer_ = window.setTimeout(
1259 function() { repeatScroll(now + timeout); }, 1281 function() { repeatScroll(now + timeout); },
1260 timeout); 1282 timeout);
1261 } 1283 }
1262 }; 1284 };
1263 repeatScroll(new Date().getTime()); 1285 repeatScroll(new Date().getTime());
1264 } 1286 }
1265 }; 1287 };
OLDNEW
« no previous file with comments | « no previous file | remoting/webapp/main.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698