| OLD | NEW |
| 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 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" | 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" |
| 11 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_in
fo.h" | 11 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_in
fo.h" |
| 12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 // Maps parent windows to sheet controllers. | 16 // Maps parent windows to sheet controllers. |
| 16 NSMutableDictionary* g_sheetControllers; | 17 NSMutableDictionary* g_sheetControllers; |
| 17 | 18 |
| 18 // Get a value for the given window that can be used as a key in a dictionary. | 19 // Get a value for the given window that can be used as a key in a dictionary. |
| 19 NSValue* GetKeyForParentWindow(NSWindow* parent_window) { | 20 NSValue* GetKeyForParentWindow(NSWindow* parent_window) { |
| 20 return [NSValue valueWithNonretainedObject:parent_window]; | 21 return [NSValue valueWithNonretainedObject:parent_window]; |
| 21 } | 22 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 [self findSheetInfoForParentView:parentView]; | 237 [self findSheetInfoForParentView:parentView]; |
| 237 if (!info) | 238 if (!info) |
| 238 return; | 239 return; |
| 239 | 240 |
| 240 NSRect rect = [self overlayWindowFrameForParentView:parentView]; | 241 NSRect rect = [self overlayWindowFrameForParentView:parentView]; |
| 241 [[info overlayWindow] setFrame:rect display:YES]; | 242 [[info overlayWindow] setFrame:rect display:YES]; |
| 242 [[info sheet] updateSheetPosition]; | 243 [[info sheet] updateSheetPosition]; |
| 243 } | 244 } |
| 244 | 245 |
| 245 - (NSRect)overlayWindowFrameForParentView:(NSView*)parentView { | 246 - (NSRect)overlayWindowFrameForParentView:(NSView*)parentView { |
| 246 NSRect viewFrame = [parentView convertRect:[parentView bounds] toView:nil]; | 247 NSRect viewFrame = GetSheetParentBoundsForParentView(parentView); |
| 247 | 248 |
| 248 id<NSWindowDelegate> delegate = [[parentView window] delegate]; | 249 id<NSWindowDelegate> delegate = [[parentView window] delegate]; |
| 249 if ([delegate respondsToSelector:@selector(window: | 250 if ([delegate respondsToSelector:@selector(window: |
| 250 willPositionSheet: | 251 willPositionSheet: |
| 251 usingRect:)]) { | 252 usingRect:)]) { |
| 252 NSRect sheetFrame = NSZeroRect; | 253 NSRect sheetFrame = NSZeroRect; |
| 253 // This API needs Y to be the distance from the bottom of the overlay to | 254 // This API needs Y to be the distance from the bottom of the overlay to |
| 254 // the top of the sheet. X, width, and height are ignored. | 255 // the top of the sheet. X, width, and height are ignored. |
| 255 sheetFrame.origin.y = NSMaxY(viewFrame); | 256 sheetFrame.origin.y = NSMaxY(viewFrame); |
| 256 NSRect customSheetFrame = [delegate window:[parentView window] | 257 NSRect customSheetFrame = [delegate window:[parentView window] |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 name:NSWindowDidResizeNotification | 293 name:NSWindowDidResizeNotification |
| 293 object:parentWindow_]; | 294 object:parentWindow_]; |
| 294 | 295 |
| 295 [parentWindow_ removeChildWindow:[info overlayWindow]]; | 296 [parentWindow_ removeChildWindow:[info overlayWindow]]; |
| 296 [[info sheet] closeSheetWithAnimation:withAnimation]; | 297 [[info sheet] closeSheetWithAnimation:withAnimation]; |
| 297 [[info overlayWindow] close]; | 298 [[info overlayWindow] close]; |
| 298 [sheets_ removeObject:info]; | 299 [sheets_ removeObject:info]; |
| 299 } | 300 } |
| 300 | 301 |
| 301 @end | 302 @end |
| OLD | NEW |