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

Unified Diff: chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm

Issue 555243002: mac: Refactor browser_window_controller layout logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fullscreen_layout
Patch Set: Comments from andresantoso, round 2. Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm
diff --git a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm
index 8dcbca428a3340d1728cc54b4ca246945b1fd4c1..1f9efa80f7c4e5bd84eff120dc4df9740f5bce34 100644
--- a/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm
+++ b/chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm
@@ -32,8 +32,11 @@
- (id)initWithResizeDelegate:(id<ViewResizer>)resizeDelegate {
DCHECK(resizeDelegate);
if ((self = [super initWithNibName:nil bundle:nil])) {
+ // This view and its subviews use autoresizing masks, The starting frame
+ // needs to be reasonably large, although its exactly values don't matter.
+ // It cannot be NSZeroRect.
base::scoped_nsobject<NSView> view(
- [[NSView alloc] initWithFrame:NSZeroRect]);
+ [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 800, 100)]);
[view setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin];
view_id_util::SetID(view, VIEW_ID_INFO_BAR_CONTAINER);
[self setView:view];
@@ -128,17 +131,7 @@
[controller layoutArrow];
}
- int totalHeight = 0;
- int overlap = containerCocoa_->GetVerticalOverlap(&totalHeight);
-
- if (NSHeight([[self view] frame]) != totalHeight) {
- [resizeDelegate_ resizeView:[self view] newHeight:totalHeight];
- } else if (oldOverlappingTipHeight_ != overlap) {
- // If the infobar overlap changed but the height didn't change then
- // explicitly ask for a layout.
- [[self browserWindowController] layoutInfoBars];
- }
- oldOverlappingTipHeight_ = overlap;
+ [resizeDelegate_ resizeView:[self view] newHeight:[self heightOfInfoBars]];
}
- (void)setShouldSuppressTopInfoBarTip:(BOOL)flag {
@@ -164,4 +157,12 @@
containerCocoa_->SetMaxTopArrowHeight(height);
}
+- (CGFloat)heightOfInfoBars {
+ CGFloat totalHeight = 0;
+ for (InfoBarController* controller in infobarControllers_.get())
Robert Sesek 2014/09/11 03:11:14 nit: needs braces
erikchen 2014/09/12 00:21:30 One day clang-format will automatically add braces
Robert Sesek 2014/09/12 15:40:00 You could file a go/clang-format-bug and maybe it'
erikchen 2014/09/12 17:26:14 Filed clang bugs & feature requests in the past. N
+ totalHeight += [controller infobar]->total_height() -
+ [controller infobar]->arrow_height();
+ return totalHeight;
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698