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

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

Issue 1018693003: Relaxes window size DCHECKs in StatusBubbleMac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« 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"
11 #include "base/debug/stack_trace.h"
11 #include "base/mac/mac_util.h" 12 #include "base/mac/mac_util.h"
12 #include "base/mac/scoped_block.h" 13 #include "base/mac/scoped_block.h"
13 #include "base/mac/sdk_forward_declarations.h" 14 #include "base/mac/sdk_forward_declarations.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #import "chrome/browser/ui/cocoa/bubble_view.h" 19 #import "chrome/browser/ui/cocoa/bubble_view.h"
19 #include "chrome/browser/ui/elide_url.h" 20 #include "chrome/browser/ui/elide_url.h"
20 #include "net/base/net_util.h" 21 #include "net/base/net_util.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 void StatusBubbleMac::SetStatus(const base::string16& status) { 199 void StatusBubbleMac::SetStatus(const base::string16& status) {
199 SetText(status, false); 200 SetText(status, false);
200 } 201 }
201 202
202 void StatusBubbleMac::SetURL(const GURL& url, const std::string& languages) { 203 void StatusBubbleMac::SetURL(const GURL& url, const std::string& languages) {
203 url_ = url; 204 url_ = url;
204 languages_ = languages; 205 languages_ = languages;
205 206
206 CGFloat bubble_width = NSWidth([window_ frame]); 207 CGFloat bubble_width = NSWidth([window_ frame]);
207 if (state_ == kBubbleHidden) { 208 if (state_ == kBubbleHidden) {
208 DCHECK_EQ(ui::kWindowSizeDeterminedLater.size.width, 209 // TODO(rohitrao): The window size is expected to be (1,1) whenever the
209 [window_ frame].size.width); 210 // window is hidden, but the GPU bots are hitting cases where this is not
210 DCHECK_EQ(ui::kWindowSizeDeterminedLater.size.height, 211 // true. Instead of enforcing this invariant with a DCHECK, add logging to
211 [window_ frame].size.height); 212 // try and debug it and fix up the window size if needed. crbug.com/464754
213 NSRect frame = [window_ frame];
214 if (!CGSizeEqualToSize(frame.size, ui::kWindowSizeDeterminedLater.size)) {
erikchen 2015/03/17 18:14:31 You may want to wrap this logic so that it doesn't
erikchen 2015/03/17 18:15:37 I'm referring to the logs messages and stack_trace
215 LOG(ERROR) << "Window size should be (1,1), but is instead ("
216 << frame.size.width << "," << frame.size.height << ")";
217 LOG(ERROR) << base::debug::StackTrace().ToString();
218 frame.size = ui::kWindowSizeDeterminedLater.size;
219 [window_ setFrame:frame display:NO];
220 }
212 bubble_width = NSWidth(CalculateWindowFrame(/*expand=*/false)); 221 bubble_width = NSWidth(CalculateWindowFrame(/*expand=*/false));
213 } 222 }
214 223
215 int text_width = static_cast<int>(bubble_width - 224 int text_width = static_cast<int>(bubble_width -
216 kBubbleViewTextPositionX - 225 kBubbleViewTextPositionX -
217 kTextPadding); 226 kTextPadding);
218 227
219 // Scale from view to window coordinates before eliding URL string. 228 // Scale from view to window coordinates before eliding URL string.
220 NSSize scaled_width = NSMakeSize(text_width, 0); 229 NSSize scaled_width = NSMakeSize(text_width, 0);
221 scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil]; 230 scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil];
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 } 761 }
753 762
754 void StatusBubbleMac::UpdateSizeAndPosition() { 763 void StatusBubbleMac::UpdateSizeAndPosition() {
755 if (!window_) 764 if (!window_)
756 return; 765 return;
757 766
758 // There is no need to update the size if the bubble is hidden. 767 // There is no need to update the size if the bubble is hidden.
759 if (state_ == kBubbleHidden) { 768 if (state_ == kBubbleHidden) {
760 // Verify that hidden bubbles always have size equal to 769 // Verify that hidden bubbles always have size equal to
761 // ui::kWindowSizeDeterminedLater. 770 // ui::kWindowSizeDeterminedLater.
762 DCHECK_EQ(ui::kWindowSizeDeterminedLater.size.width, 771 // TODO(rohitrao): The GPU bots are hitting cases where this is not
763 [window_ frame].size.width); 772 // true. Instead of enforcing this invariant with a DCHECK, add logging to
764 DCHECK_EQ(ui::kWindowSizeDeterminedLater.size.height, 773 // try and debug it and fix up the window size if needed. crbug.com/464754
765 [window_ frame].size.height); 774 NSRect frame = [window_ frame];
775 if (!CGSizeEqualToSize(frame.size, ui::kWindowSizeDeterminedLater.size)) {
776 LOG(ERROR) << "Window size should be (1,1), but is instead ("
777 << frame.size.width << "," << frame.size.height << ")";
778 LOG(ERROR) << base::debug::StackTrace().ToString();
779 frame.size = ui::kWindowSizeDeterminedLater.size;
780 [window_ setFrame:frame display:YES];
781 }
766 return; 782 return;
767 } 783 }
768 784
769 SetFrameAvoidingMouse(CalculateWindowFrame(/*expand=*/false), 785 SetFrameAvoidingMouse(CalculateWindowFrame(/*expand=*/false),
770 GetMouseLocation()); 786 GetMouseLocation());
771 } 787 }
772 788
773 void StatusBubbleMac::SwitchParentWindow(NSWindow* parent) { 789 void StatusBubbleMac::SwitchParentWindow(NSWindow* parent) {
774 DCHECK(parent); 790 DCHECK(parent);
775 DCHECK(is_attached()); 791 DCHECK(is_attached());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 } 840 }
825 841
826 // Round the top corners when the bubble is below the parent window. 842 // Round the top corners when the bubble is below the parent window.
827 if (NSMinY(window_frame) < NSMinY(parent_frame)) { 843 if (NSMinY(window_frame) < NSMinY(parent_frame)) {
828 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner; 844 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner;
829 } 845 }
830 } 846 }
831 847
832 return corner_flags; 848 return corner_flags;
833 } 849 }
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