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

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

Issue 1130013003: Replace moveTo and resizeTo with outerBounds= (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplified. Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 * A module that contains basic utility components and methods for the 7 * A module that contains basic utility components and methods for the
8 * chromoting project 8 * chromoting project
9 * 9 *
10 */ 10 */
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 return '[' + new Date().toISOString() + ']'; 782 return '[' + new Date().toISOString() + ']';
783 }; 783 };
784 784
785 /** 785 /**
786 * Size the current window to fit its content. 786 * Size the current window to fit its content.
787 * @param {boolean=} opt_centerWindow If true, position the window in the 787 * @param {boolean=} opt_centerWindow If true, position the window in the
788 * center of the screen after resizing it. 788 * center of the screen after resizing it.
789 */ 789 */
790 base.resizeWindowToContent = function(opt_centerWindow) { 790 base.resizeWindowToContent = function(opt_centerWindow) {
791 var appWindow = chrome.app.window.current(); 791 var appWindow = chrome.app.window.current();
792 var outerBounds = appWindow.outerBounds; 792 var borderX = appWindow.outerBounds.width - appWindow.innerBounds.width;
793 var borderX = outerBounds.width - appWindow.innerBounds.width; 793 var borderY = appWindow.outerBounds.height - appWindow.innerBounds.height;
794 var borderY = outerBounds.height - appWindow.innerBounds.height; 794 var width = Math.ceil(document.documentElement.scrollWidth + borderX);
795 var newWidth = document.documentElement.scrollWidth + borderX; 795 var height = Math.ceil(document.documentElement.scrollHeight + borderY);
796 var newHeight = document.documentElement.scrollHeight + borderY; 796 appWindow.outerBounds.width = width;
797 appWindow.resizeTo(newWidth, newHeight); 797 appWindow.outerBounds.height = height;
798 var left = outerBounds.left;
799 var top = outerBounds.top;
800 if (opt_centerWindow) { 798 if (opt_centerWindow) {
801 var screenWidth = screen.availWidth; 799 var screenWidth = screen.availWidth;
802 var screenHeight = screen.availHeight; 800 var screenHeight = screen.availHeight;
803 left = (screenWidth - newWidth) / 2; 801 appWindow.outerBounds.left = Math.round((screenWidth - width) / 2);
804 top = (screenHeight - newHeight) / 2; 802 appWindow.outerBounds.top = Math.round((screenHeight - height) / 2);
805 } 803 }
806 // Sometimes, resizing the window causes its position to be reset to (0, 0),
807 // so restore it explicitly, even if it doesn't need to be centered.
808 appWindow.moveTo(left, top);
809 }; 804 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698