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/base_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 - (void)recordAnchorOffset { | 142 - (void)recordAnchorOffset { |
143 // The offset of the anchor from the parent's upper-left-hand corner is kept | 143 // The offset of the anchor from the parent's upper-left-hand corner is kept |
144 // to ensure the bubble stays anchored correctly if the parent is resized. | 144 // to ensure the bubble stays anchored correctly if the parent is resized. |
145 anchorOffset_ = NSMakePoint(NSMinX([parentWindow_ frame]), | 145 anchorOffset_ = NSMakePoint(NSMinX([parentWindow_ frame]), |
146 NSMaxY([parentWindow_ frame])); | 146 NSMaxY([parentWindow_ frame])); |
147 anchorOffset_.x -= anchor_.x; | 147 anchorOffset_.x -= anchor_.x; |
148 anchorOffset_.y -= anchor_.y; | 148 anchorOffset_.y -= anchor_.y; |
149 } | 149 } |
150 | 150 |
151 - (NSBox*)separatorWithFrame:(NSRect)frame { | 151 - (NSBox*)horizontalSeparatorWithFrame:(NSRect)frame { |
152 frame.size.height = 1.0; | 152 frame.size.height = 1.0; |
153 base::scoped_nsobject<NSBox> spacer([[NSBox alloc] initWithFrame:frame]); | 153 base::scoped_nsobject<NSBox> spacer([[NSBox alloc] initWithFrame:frame]); |
154 [spacer setBoxType:NSBoxSeparator]; | 154 [spacer setBoxType:NSBoxSeparator]; |
155 [spacer setBorderType:NSLineBorder]; | 155 [spacer setBorderType:NSLineBorder]; |
156 [spacer setAlphaValue:0.2]; | 156 [spacer setAlphaValue:0.2]; |
157 return [spacer.release() autorelease]; | 157 return [spacer.release() autorelease]; |
158 } | 158 } |
159 | 159 |
| 160 - (NSBox*)verticalSeparatorWithFrame:(NSRect)frame { |
| 161 frame.size.width = 1.0; |
| 162 base::scoped_nsobject<NSBox> spacer([[NSBox alloc] initWithFrame:frame]); |
| 163 [spacer setBoxType:NSBoxSeparator]; |
| 164 [spacer setBorderType:NSLineBorder]; |
| 165 [spacer setAlphaValue:0.2]; |
| 166 return [spacer.release() autorelease]; |
| 167 } |
| 168 |
160 - (void)parentWindowDidResize:(NSNotification*)notification { | 169 - (void)parentWindowDidResize:(NSNotification*)notification { |
161 if (!parentWindow_) | 170 if (!parentWindow_) |
162 return; | 171 return; |
163 | 172 |
164 DCHECK_EQ(parentWindow_, [notification object]); | 173 DCHECK_EQ(parentWindow_, [notification object]); |
165 NSPoint newOrigin = NSMakePoint(NSMinX([parentWindow_ frame]), | 174 NSPoint newOrigin = NSMakePoint(NSMinX([parentWindow_ frame]), |
166 NSMaxY([parentWindow_ frame])); | 175 NSMaxY([parentWindow_ frame])); |
167 newOrigin.x -= anchorOffset_.x; | 176 newOrigin.x -= anchorOffset_.x; |
168 newOrigin.y -= anchorOffset_.y; | 177 newOrigin.y -= anchorOffset_.y; |
169 [self setAnchorPoint:newOrigin]; | 178 [self setAnchorPoint:newOrigin]; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 353 |
345 - (void)activateTabWithContents:(content::WebContents*)newContents | 354 - (void)activateTabWithContents:(content::WebContents*)newContents |
346 previousContents:(content::WebContents*)oldContents | 355 previousContents:(content::WebContents*)oldContents |
347 atIndex:(NSInteger)index | 356 atIndex:(NSInteger)index |
348 reason:(int)reason { | 357 reason:(int)reason { |
349 // The user switched tabs; close. | 358 // The user switched tabs; close. |
350 [self close]; | 359 [self close]; |
351 } | 360 } |
352 | 361 |
353 @end // BaseBubbleController | 362 @end // BaseBubbleController |
OLD | NEW |