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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm

Issue 2435593008: Cocoa: Fix a constraint violation when navigating away from a detached bookmark bar. (Closed)
Patch Set: redundant Created 4 years, 2 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
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/bookmarks/bookmark_bar_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #import "base/mac/bundle_locations.h" 9 #import "base/mac/bundle_locations.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return; 158 return;
159 159
160 extensions::RecordAppLaunchType(extension_misc::APP_LAUNCH_BOOKMARK_BAR, 160 extensions::RecordAppLaunchType(extension_misc::APP_LAUNCH_BOOKMARK_BAR,
161 extension->GetType()); 161 extension->GetType());
162 } 162 }
163 163
164 } // namespace 164 } // namespace
165 165
166 @interface BookmarkBarController () 166 @interface BookmarkBarController ()
167 167
168 // Updates the sizes and positions of the subviews.
169 - (void)layoutSubviews;
170
168 // Moves to the given next state (from the current state), possibly animating. 171 // Moves to the given next state (from the current state), possibly animating.
169 // If |animate| is NO, it will stop any running animation and jump to the given 172 // If |animate| is NO, it will stop any running animation and jump to the given
170 // state. If YES, it may either (depending on implementation) jump to the end of 173 // state. If YES, it may either (depending on implementation) jump to the end of
171 // the current animation and begin the next one, or stop the current animation 174 // the current animation and begin the next one, or stop the current animation
172 // mid-flight and animate to the next state. 175 // mid-flight and animate to the next state.
173 - (void)moveToState:(BookmarkBar::State)nextState 176 - (void)moveToState:(BookmarkBar::State)nextState
174 withAnimation:(BOOL)animate; 177 withAnimation:(BOOL)animate;
175 178
176 // Create buttons for all items in the given bookmark node tree. 179 // Create buttons for all items in the given bookmark node tree.
177 // Modifies self->buttons_. Do not add more buttons than will fit on the view. 180 // Modifies self->buttons_. Do not add more buttons than will fit on the view.
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 // NSNotificationCenter callback. 554 // NSNotificationCenter callback.
552 - (void)parentWindowWillClose:(NSNotification*)notification { 555 - (void)parentWindowWillClose:(NSNotification*)notification {
553 [self closeFolderAndStopTrackingMenus]; 556 [self closeFolderAndStopTrackingMenus];
554 } 557 }
555 558
556 // NSNotificationCenter callback. 559 // NSNotificationCenter callback.
557 - (void)parentWindowDidResignMain:(NSNotification*)notification { 560 - (void)parentWindowDidResignMain:(NSNotification*)notification {
558 [self closeFolderAndStopTrackingMenus]; 561 [self closeFolderAndStopTrackingMenus];
559 } 562 }
560 563
564 - (void)layoutToFrame:(NSRect)frame {
565 // The view should be pinned to the top of the window with a flexible width.
566 DCHECK_EQ(NSViewWidthSizable | NSViewMinYMargin,
567 [[self view] autoresizingMask]);
568 [[self view] setFrame:frame];
569 [self layoutSubviews];
570 }
571
561 // Change the layout of the bookmark bar's subviews in response to a visibility 572 // Change the layout of the bookmark bar's subviews in response to a visibility
562 // change (e.g., show or hide the bar) or style change (attached or floating). 573 // change (e.g., show or hide the bar) or style change (attached or floating).
563 - (void)layoutSubviews { 574 - (void)layoutSubviews {
564 NSRect frame = [[self view] frame]; 575 NSRect frame = [[self view] frame];
565 NSRect buttonViewFrame = NSMakeRect(0, 0, NSWidth(frame), NSHeight(frame)); 576 NSRect buttonViewFrame = NSMakeRect(0, 0, NSWidth(frame), NSHeight(frame));
566 577
567 // Add padding to the detached bookmark bar. 578 // Add padding to the detached bookmark bar.
568 // The state of our morph (if any); 1 is total bubble, 0 is the regular bar. 579 // The state of our morph (if any); 1 is total bubble, 0 is the regular bar.
569 CGFloat morph = [self detachedMorphProgress]; 580 CGFloat morph = [self detachedMorphProgress];
570 CGFloat padding = 0; 581 CGFloat padding = 0;
(...skipping 2423 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 - (id<BookmarkButtonControllerProtocol>)controllerForNode: 3005 - (id<BookmarkButtonControllerProtocol>)controllerForNode:
2995 (const BookmarkNode*)node { 3006 (const BookmarkNode*)node {
2996 // See if it's in the bar, then if it is in the hierarchy of visible 3007 // See if it's in the bar, then if it is in the hierarchy of visible
2997 // folder menus. 3008 // folder menus.
2998 if (bookmarkModel_->bookmark_bar_node() == node) 3009 if (bookmarkModel_->bookmark_bar_node() == node)
2999 return self; 3010 return self;
3000 return [folderController_ controllerForNode:node]; 3011 return [folderController_ controllerForNode:node];
3001 } 3012 }
3002 3013
3003 @end 3014 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698