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

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

Issue 10185005: [Mac] Fix "Chrome windows use more 'hidden' space on Exposé/Mission Control". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | no next file » | 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 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" 5 #include "chrome/browser/ui/cocoa/status_bubble_mac.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 Create(); 111 Create();
112 Attach(); 112 Attach();
113 } 113 }
114 114
115 StatusBubbleMac::~StatusBubbleMac() { 115 StatusBubbleMac::~StatusBubbleMac() {
116 DCHECK(window_); 116 DCHECK(window_);
117 117
118 Hide(); 118 Hide();
119 119
120 [[[window_ animationForKey:kFadeAnimationKey] delegate] invalidate]; 120 [[[window_ animationForKey:kFadeAnimationKey] delegate] invalidate];
121 Detach(); 121 if (is_attached())
Mark Mentovai 2012/04/23 17:59:36 Why not move this logic into Detach()? Detach() i
asvitkine_google 2012/04/23 18:06:24 Done.
122 Detach();
122 [window_ release]; 123 [window_ release];
123 window_ = nil; 124 window_ = nil;
124 } 125 }
125 126
126 void StatusBubbleMac::SetStatus(const string16& status) { 127 void StatusBubbleMac::SetStatus(const string16& status) {
127 SetText(status, false); 128 SetText(status, false);
128 } 129 }
129 130
130 void StatusBubbleMac::SetURL(const GURL& url, const std::string& languages) { 131 void StatusBubbleMac::SetURL(const GURL& url, const std::string& languages) {
131 url_ = url; 132 url_ = url;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 void StatusBubbleMac::Attach() { 407 void StatusBubbleMac::Attach() {
407 DCHECK(!is_attached()); 408 DCHECK(!is_attached());
408 409
409 [window_ orderFront:nil]; 410 [window_ orderFront:nil];
410 [parent_ addChildWindow:window_ ordered:NSWindowAbove]; 411 [parent_ addChildWindow:window_ ordered:NSWindowAbove];
411 412
412 [[window_ contentView] setThemeProvider:parent_]; 413 [[window_ contentView] setThemeProvider:parent_];
413 } 414 }
414 415
415 void StatusBubbleMac::Detach() { 416 void StatusBubbleMac::Detach() {
416 DCHECK(is_attached()); 417 DCHECK(is_attached());
Mark Mentovai 2012/04/23 17:59:36 Is this DCHECK no longer correct (given the change
asvitkine_google 2012/04/23 18:06:24 Done.
417 418
418 // Magic setFrame: See crbug.com/58506, and codereview.chromium.org/3564021 419 // Magic setFrame: See crbug.com/58506, and codereview.chromium.org/3564021
419 [window_ setFrame:CalculateWindowFrame(/*expand=*/false) display:NO]; 420 [window_ setFrame:CalculateWindowFrame(/*expand=*/false) display:NO];
420 [parent_ removeChildWindow:window_]; // See crbug.com/28107 ... 421 [parent_ removeChildWindow:window_]; // See crbug.com/28107 ...
421 [window_ orderOut:nil]; // ... and crbug.com/29054. 422 [window_ orderOut:nil]; // ... and crbug.com/29054.
422 423
423 [[window_ contentView] setThemeProvider:nil]; 424 [[window_ contentView] setThemeProvider:nil];
424 } 425 }
425 426
426 void StatusBubbleMac::AnimationDidStop(CAAnimation* animation, bool finished) { 427 void StatusBubbleMac::AnimationDidStop(CAAnimation* animation, bool finished) {
(...skipping 13 matching lines...) Expand all
440 DCHECK_EQ([[window_ animator] alphaValue], 0.0); 441 DCHECK_EQ([[window_ animator] alphaValue], 0.0);
441 SetState(kBubbleHidden); 442 SetState(kBubbleHidden);
442 } 443 }
443 } 444 }
444 } 445 }
445 446
446 void StatusBubbleMac::SetState(StatusBubbleState state) { 447 void StatusBubbleMac::SetState(StatusBubbleState state) {
447 if (state == state_) 448 if (state == state_)
448 return; 449 return;
449 450
450 if (state == kBubbleHidden) 451 if (state == kBubbleHidden) {
sail 2012/04/23 18:08:53 Hi Alexei. I think this change might reintroduce b
sail 2012/04/23 18:10:22 Also, you may decide that regressing the above bug
451 [window_ setFrame:NSMakeRect(0, 0, 1, 1) display:YES]; 452 if (is_attached())
453 Detach();
454 } else if (!is_attached()) {
455 Attach();
456 }
452 457
453 if ([delegate_ respondsToSelector:@selector(statusBubbleWillEnterState:)]) 458 if ([delegate_ respondsToSelector:@selector(statusBubbleWillEnterState:)])
454 [delegate_ statusBubbleWillEnterState:state]; 459 [delegate_ statusBubbleWillEnterState:state];
455 460
456 state_ = state; 461 state_ = state;
457 } 462 }
458 463
459 void StatusBubbleMac::Fade(bool show) { 464 void StatusBubbleMac::Fade(bool show) {
460 DCHECK([NSThread isMainThread]); 465 DCHECK([NSThread isMainThread]);
461 466
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 return; 678 return;
674 679
675 SetFrameAvoidingMouse(CalculateWindowFrame(/*expand=*/false), 680 SetFrameAvoidingMouse(CalculateWindowFrame(/*expand=*/false),
676 GetMouseLocation()); 681 GetMouseLocation());
677 } 682 }
678 683
679 void StatusBubbleMac::SwitchParentWindow(NSWindow* parent) { 684 void StatusBubbleMac::SwitchParentWindow(NSWindow* parent) {
680 DCHECK(parent); 685 DCHECK(parent);
681 DCHECK(is_attached()); 686 DCHECK(is_attached());
682 687
683 Detach(); 688 if (is_attached())
689 Detach();
684 parent_ = parent; 690 parent_ = parent;
685 Attach(); 691 Attach();
686 UpdateSizeAndPosition(); 692 UpdateSizeAndPosition();
687 } 693 }
688 694
689 NSRect StatusBubbleMac::CalculateWindowFrame(bool expanded_width) { 695 NSRect StatusBubbleMac::CalculateWindowFrame(bool expanded_width) {
690 DCHECK(parent_); 696 DCHECK(parent_);
691 697
692 NSRect screenRect; 698 NSRect screenRect;
693 if ([delegate_ respondsToSelector:@selector(statusBubbleBaseFrame)]) { 699 if ([delegate_ respondsToSelector:@selector(statusBubbleBaseFrame)]) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 } 736 }
731 737
732 // Round the top corners when the bubble is below the parent window. 738 // Round the top corners when the bubble is below the parent window.
733 if (NSMinY(window_frame) < NSMinY(parent_frame)) { 739 if (NSMinY(window_frame) < NSMinY(parent_frame)) {
734 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner; 740 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner;
735 } 741 }
736 } 742 }
737 743
738 return corner_flags; 744 return corner_flags;
739 } 745 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698