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

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

Issue 10545050: mac: Use NSWidth() and friends in a few more places. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" 5 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { 139 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) {
140 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; 140 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds];
141 141
142 ExitFullscreen(); 142 ExitFullscreen();
143 NSRect cocoa_bounds = NSMakeRect(real_bounds.x(), 0, 143 NSRect cocoa_bounds = NSMakeRect(real_bounds.x(), 0,
144 real_bounds.width(), 144 real_bounds.width(),
145 real_bounds.height()); 145 real_bounds.height());
146 // Flip coordinates based on the primary screen. 146 // Flip coordinates based on the primary screen.
147 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; 147 NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
148 cocoa_bounds.origin.y = 148 cocoa_bounds.origin.y =
149 [screen frame].size.height - real_bounds.height() - real_bounds.y(); 149 NSHeight([screen frame]) - real_bounds.height() - real_bounds.y();
150 150
151 [window() setFrame:cocoa_bounds display:YES]; 151 [window() setFrame:cocoa_bounds display:YES];
152 } 152 }
153 153
154 // Callers assume that this doesn't immediately delete the Browser object. 154 // Callers assume that this doesn't immediately delete the Browser object.
155 // The controller implementing the window delegate methods called from 155 // The controller implementing the window delegate methods called from
156 // |-performClose:| must take precautions to ensure that. 156 // |-performClose:| must take precautions to ensure that.
157 void BrowserWindowCocoa::Close() { 157 void BrowserWindowCocoa::Close() {
158 // If there is an overlay window, we contain a tab being dragged between 158 // If there is an overlay window, we contain a tab being dragged between
159 // windows. Don't hide the window as it makes the UI extra confused. We can 159 // windows. Don't hide the window as it makes the UI extra confused. We can
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 261 }
262 262
263 void BrowserWindowCocoa::ShowZoomBubble(int zoom_percent) { 263 void BrowserWindowCocoa::ShowZoomBubble(int zoom_percent) {
264 // TODO(khorimoto): Find someone to implement this. 264 // TODO(khorimoto): Find someone to implement this.
265 } 265 }
266 266
267 gfx::Rect BrowserWindowCocoa::GetRestoredBounds() const { 267 gfx::Rect BrowserWindowCocoa::GetRestoredBounds() const {
268 // Flip coordinates based on the primary screen. 268 // Flip coordinates based on the primary screen.
269 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; 269 NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
270 NSRect frame = [controller_ regularWindowFrame]; 270 NSRect frame = [controller_ regularWindowFrame];
271 gfx::Rect bounds(frame.origin.x, 0, frame.size.width, frame.size.height); 271 gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
272 bounds.set_y([screen frame].size.height - frame.origin.y - frame.size.height); 272 bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame));
Robert Sesek 2012/06/07 16:52:38 Is NSMaxY correct here? (that's origin.y + size.he
Nico 2012/06/07 17:40:23 - frame.origin.y - frame.size.height == - (frame.o
Robert Sesek 2012/06/07 18:37:20 You're right. Lost track of the negative when goin
273 return bounds; 273 return bounds;
274 } 274 }
275 275
276 gfx::Rect BrowserWindowCocoa::GetBounds() const { 276 gfx::Rect BrowserWindowCocoa::GetBounds() const {
277 return GetRestoredBounds(); 277 return GetRestoredBounds();
278 } 278 }
279 279
280 bool BrowserWindowCocoa::IsMaximized() const { 280 bool BrowserWindowCocoa::IsMaximized() const {
281 return [window() isZoomed]; 281 return [window() isZoomed];
282 } 282 }
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 AvatarMenuBubbleController* menu = 652 AvatarMenuBubbleController* menu =
653 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ 653 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_
654 anchoredAt:point]; 654 anchoredAt:point];
655 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge]; 655 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge];
656 [menu showWindow:nil]; 656 [menu showWindow:nil];
657 } 657 }
658 658
659 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() { 659 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() {
660 [[controller_ avatarButtonController] showAvatarBubble]; 660 [[controller_ avatarButtonController] showAvatarBubble];
661 } 661 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698