| 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/tabs/tab_view.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/sdk_forward_declarations.h" | 8 #include "base/mac/sdk_forward_declarations.h" |
| 9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
| 10 #import "chrome/browser/ui/cocoa/nsview_additions.h" | 10 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if ([self hitTest:hitLocation] == closeButton_) { | 204 if ([self hitTest:hitLocation] == closeButton_) { |
| 205 [closeButton_ mouseDown:theEvent]; | 205 [closeButton_ mouseDown:theEvent]; |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| 210 // If the tab gets torn off, the tab controller will be removed from the tab | 210 // If the tab gets torn off, the tab controller will be removed from the tab |
| 211 // strip and then deallocated. This will also result in *us* being | 211 // strip and then deallocated. This will also result in *us* being |
| 212 // deallocated. Both these are bad, so we prevent this by retaining the | 212 // deallocated. Both these are bad, so we prevent this by retaining the |
| 213 // controller. | 213 // controller. |
| 214 scoped_nsobject<TabController> controller([controller_ retain]); | 214 base::scoped_nsobject<TabController> controller([controller_ retain]); |
| 215 | 215 |
| 216 // Try to initiate a drag. This will spin a custom event loop and may | 216 // Try to initiate a drag. This will spin a custom event loop and may |
| 217 // dispatch other mouse events. | 217 // dispatch other mouse events. |
| 218 [controller_ maybeStartDrag:theEvent forTab:controller]; | 218 [controller_ maybeStartDrag:theEvent forTab:controller]; |
| 219 | 219 |
| 220 // The custom loop has ended, so clear the point. | 220 // The custom loop has ended, so clear the point. |
| 221 mouseDownPoint_ = NSZeroPoint; | 221 mouseDownPoint_ = NSZeroPoint; |
| 222 } | 222 } |
| 223 | 223 |
| 224 - (void)mouseUp:(NSEvent*)theEvent { | 224 - (void)mouseUp:(NSEvent*)theEvent { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // ui::ThemeProvider::HasCustomImage is true only if the theme provides the | 372 // ui::ThemeProvider::HasCustomImage is true only if the theme provides the |
| 373 // image. However, even if the theme doesn't provide a tab background, the | 373 // image. However, even if the theme doesn't provide a tab background, the |
| 374 // theme machinery will make one if given a frame image. See | 374 // theme machinery will make one if given a frame image. See |
| 375 // BrowserThemePack::GenerateTabBackgroundImages for details. | 375 // BrowserThemePack::GenerateTabBackgroundImages for details. |
| 376 BOOL hasCustomTheme = themeProvider && | 376 BOOL hasCustomTheme = themeProvider && |
| 377 (themeProvider->HasCustomImage(IDR_THEME_TAB_BACKGROUND) || | 377 (themeProvider->HasCustomImage(IDR_THEME_TAB_BACKGROUND) || |
| 378 themeProvider->HasCustomImage(IDR_THEME_FRAME)); | 378 themeProvider->HasCustomImage(IDR_THEME_FRAME)); |
| 379 // Draw a mouse hover gradient for the default themes. | 379 // Draw a mouse hover gradient for the default themes. |
| 380 if (!selected && hoverAlpha > 0) { | 380 if (!selected && hoverAlpha > 0) { |
| 381 if (themeProvider && !hasCustomTheme) { | 381 if (themeProvider && !hasCustomTheme) { |
| 382 scoped_nsobject<NSGradient> glow([NSGradient alloc]); | 382 base::scoped_nsobject<NSGradient> glow([NSGradient alloc]); |
| 383 [glow initWithStartingColor:[NSColor colorWithCalibratedWhite:1.0 | 383 [glow initWithStartingColor:[NSColor colorWithCalibratedWhite:1.0 |
| 384 alpha:1.0 * hoverAlpha] | 384 alpha:1.0 * hoverAlpha] |
| 385 endingColor:[NSColor colorWithCalibratedWhite:1.0 | 385 endingColor:[NSColor colorWithCalibratedWhite:1.0 |
| 386 alpha:0.0]]; | 386 alpha:0.0]]; |
| 387 NSRect rect = [self bounds]; | 387 NSRect rect = [self bounds]; |
| 388 NSPoint point = hoverPoint_; | 388 NSPoint point = hoverPoint_; |
| 389 point.y = NSHeight(rect); | 389 point.y = NSHeight(rect); |
| 390 [glow drawFromCenter:point | 390 [glow drawFromCenter:point |
| 391 radius:0.0 | 391 radius:0.0 |
| 392 toCenter:point | 392 toCenter:point |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 CGFloat middleWidth = tabWidth - leftWidth - rightWidth; | 691 CGFloat middleWidth = tabWidth - leftWidth - rightWidth; |
| 692 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight); | 692 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight); |
| 693 [[NSColor whiteColor] setFill]; | 693 [[NSColor whiteColor] setFill]; |
| 694 NSRectFill(middleRect); | 694 NSRectFill(middleRect); |
| 695 | 695 |
| 696 maskCache_.reset(CGBitmapContextCreateImage(maskContext)); | 696 maskCache_.reset(CGBitmapContextCreateImage(maskContext)); |
| 697 return maskCache_; | 697 return maskCache_; |
| 698 } | 698 } |
| 699 | 699 |
| 700 @end // @implementation TabView(Private) | 700 @end // @implementation TabView(Private) |
| OLD | NEW |