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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

Issue 9215002: Fix window zoom in a sane way, remove nasty casts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: style Created 8 years, 11 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
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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <numeric> 8 #include <numeric>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 // (bounded by available width). 689 // (bounded by available width).
690 const CGFloat kProportion = 0.6; 690 const CGFloat kProportion = 0.6;
691 CGFloat zoomedWidth = 691 CGFloat zoomedWidth =
692 std::max(kProportion * frame.size.width, 692 std::max(kProportion * frame.size.width,
693 std::min(kProportion * frame.size.height, frame.size.width)); 693 std::min(kProportion * frame.size.height, frame.size.width));
694 694
695 WebContents* contents = browser_->GetSelectedWebContents(); 695 WebContents* contents = browser_->GetSelectedWebContents();
696 if (contents) { 696 if (contents) {
697 // If the intrinsic width is bigger, then make it the zoomed width. 697 // If the intrinsic width is bigger, then make it the zoomed width.
698 const int kScrollbarWidth = 16; // TODO(viettrungluu): ugh. 698 const int kScrollbarWidth = 16; // TODO(viettrungluu): ugh.
699 TabContentsViewMac* tab_contents_view =
700 static_cast<TabContentsViewMac*>(contents->GetView());
701 CGFloat intrinsicWidth = static_cast<CGFloat>( 699 CGFloat intrinsicWidth = static_cast<CGFloat>(
702 tab_contents_view->preferred_width() + kScrollbarWidth); 700 contents->GetPreferredSize().width() + kScrollbarWidth);
703 zoomedWidth = std::max(zoomedWidth, 701 zoomedWidth = std::max(zoomedWidth,
704 std::min(intrinsicWidth, frame.size.width)); 702 std::min(intrinsicWidth, frame.size.width));
705 } 703 }
706 704
707 // Never shrink from the current size on zoom (see above). 705 // Never shrink from the current size on zoom (see above).
708 NSRect currentFrame = [[self window] frame]; 706 NSRect currentFrame = [[self window] frame];
709 zoomedWidth = std::max(zoomedWidth, currentFrame.size.width); 707 zoomedWidth = std::max(zoomedWidth, currentFrame.size.width);
710 708
711 // |frame| determines our maximum extents. We need to set the origin of the 709 // |frame| determines our maximum extents. We need to set the origin of the
712 // frame -- and only move it left if necessary. 710 // frame -- and only move it left if necessary.
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 2166
2169 - (BOOL)supportsBookmarkBar { 2167 - (BOOL)supportsBookmarkBar {
2170 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2168 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2171 } 2169 }
2172 2170
2173 - (BOOL)isTabbedWindow { 2171 - (BOOL)isTabbedWindow {
2174 return browser_->is_type_tabbed(); 2172 return browser_->is_type_tabbed();
2175 } 2173 }
2176 2174
2177 @end // @implementation BrowserWindowController(WindowType) 2175 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_cocoa.mm ('k') | content/browser/tab_contents/tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698