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

Side by Side Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.mm

Issue 11416309: Fix constrained window position for inactive tab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm » ('j') | 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 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h" 5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_animatio n.h" 10 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_animatio n.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 [[ConstrainedWindowAnimationHide alloc] initWithWindow:sheet]); 175 [[ConstrainedWindowAnimationHide alloc] initWithWindow:sheet]);
176 [animation startAnimation]; 176 [animation startAnimation];
177 } 177 }
178 178
179 [self closeSheetWithoutAnimation:info]; 179 [self closeSheetWithoutAnimation:info];
180 } 180 }
181 181
182 - (void)parentViewDidBecomeActive:(NSView*)parentView { 182 - (void)parentViewDidBecomeActive:(NSView*)parentView {
183 [[self findSheetInfoForParentView:activeView_] hideSheet]; 183 [[self findSheetInfoForParentView:activeView_] hideSheet];
184 activeView_.reset([parentView retain]); 184 activeView_.reset([parentView retain]);
185 [self updateSheetPosition:parentView];
185 [[self findSheetInfoForParentView:activeView_] showSheet]; 186 [[self findSheetInfoForParentView:activeView_] showSheet];
186 } 187 }
187 188
188 - (void)pulseSheet:(NSWindow*)sheet { 189 - (void)pulseSheet:(NSWindow*)sheet {
189 ConstrainedWindowSheetInfo* info = [self findSheetInfoForSheet:sheet]; 190 ConstrainedWindowSheetInfo* info = [self findSheetInfoForSheet:sheet];
190 DCHECK(info); 191 DCHECK(info);
191 if (![activeView_ isEqual:[info parentView]]) 192 if (![activeView_ isEqual:[info parentView]])
192 return; 193 return;
193 194
194 scoped_nsobject<NSAnimation> animation( 195 scoped_nsobject<NSAnimation> animation(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 230
230 // Delete this instance. 231 // Delete this instance.
231 [g_sheetControllers removeObjectForKey:GetKeyForParentWindow(parentWindow_)]; 232 [g_sheetControllers removeObjectForKey:GetKeyForParentWindow(parentWindow_)];
232 if (![g_sheetControllers count]) { 233 if (![g_sheetControllers count]) {
233 [g_sheetControllers release]; 234 [g_sheetControllers release];
234 g_sheetControllers = nil; 235 g_sheetControllers = nil;
235 } 236 }
236 } 237 }
237 238
238 - (void)onParentViewFrameDidChange:(NSNotification*)note { 239 - (void)onParentViewFrameDidChange:(NSNotification*)note {
239 [self updateSheetPosition:[note object]]; 240 NSView* parentView = [note object];
241 if (![activeView_ isEqual:parentView])
242 return;
243 [self updateSheetPosition:parentView];
240 } 244 }
241 245
242 - (void)updateSheetPosition:(NSView*)parentView { 246 - (void)updateSheetPosition:(NSView*)parentView {
243 if (![activeView_ isEqual:parentView])
244 return;
245 ConstrainedWindowSheetInfo* info = 247 ConstrainedWindowSheetInfo* info =
246 [self findSheetInfoForParentView:parentView]; 248 [self findSheetInfoForParentView:parentView];
247 DCHECK(info); 249 if (!info)
250 return;
251
248 NSRect rect = [self overlayWindowFrameForParentView:parentView]; 252 NSRect rect = [self overlayWindowFrameForParentView:parentView];
249 [[info overlayWindow] setFrame:rect display:YES]; 253 [[info overlayWindow] setFrame:rect display:YES];
250 NSPoint origin = [self originForSheetSize:[[info sheet] frame].size 254 NSPoint origin = [self originForSheetSize:[[info sheet] frame].size
251 inContainerRect:rect]; 255 inContainerRect:rect];
252 [[info sheet] setFrameOrigin:origin]; 256 [[info sheet] setFrameOrigin:origin];
253 } 257 }
254 258
255 - (NSRect)overlayWindowFrameForParentView:(NSView*)parentView { 259 - (NSRect)overlayWindowFrameForParentView:(NSView*)parentView {
256 NSRect viewFrame = [parentView convertRect:[parentView bounds] toView:nil]; 260 NSRect viewFrame = [parentView convertRect:[parentView bounds] toView:nil];
257 viewFrame.origin = [[parentView window] convertBaseToScreen:viewFrame.origin]; 261 viewFrame.origin = [[parentView window] convertBaseToScreen:viewFrame.origin];
(...skipping 29 matching lines...) Expand all
287 object:[info parentView]]; 291 object:[info parentView]];
288 292
289 [parentWindow_ removeChildWindow:[info overlayWindow]]; 293 [parentWindow_ removeChildWindow:[info overlayWindow]];
290 [[info overlayWindow] removeChildWindow:[info sheet]]; 294 [[info overlayWindow] removeChildWindow:[info sheet]];
291 [[info sheet] close]; 295 [[info sheet] close];
292 [[info overlayWindow] close]; 296 [[info overlayWindow] close];
293 [sheets_ removeObject:info]; 297 [sheets_ removeObject:info];
294 } 298 }
295 299
296 @end 300 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698