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

Unified Diff: chrome/browser/ui/cocoa/tabs/tab_view.mm

Issue 922223003: Mac: Use macro for static local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ThreePartImage
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/tabs/tab_view.mm
diff --git a/chrome/browser/ui/cocoa/tabs/tab_view.mm b/chrome/browser/ui/cocoa/tabs/tab_view.mm
index bd5b053e29234616eecb871ae3edf81d6198cd21..ce0f87a611dac0bd2808a8a4835b4ff823b6708b 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_view.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_view.mm
@@ -46,17 +46,19 @@ const CGFloat kRapidCloseDist = 2.5;
namespace {
-ui::ThreePartImage* GetMaskImage() {
- static ui::ThreePartImage* mask =
- new ui::ThreePartImage(IDR_TAB_ALPHA_LEFT, 0, IDR_TAB_ALPHA_RIGHT);
+ui::ThreePartImage& GetMaskImage() {
+ CR_DEFINE_STATIC_LOCAL(ui::ThreePartImage, mask,
+ (IDR_TAB_ALPHA_LEFT, 0, IDR_TAB_ALPHA_RIGHT));
return mask;
}
-ui::ThreePartImage* GetStrokeImage(bool active) {
- static ui::ThreePartImage* activeStroke = new ui::ThreePartImage(
- IDR_TAB_ACTIVE_LEFT, IDR_TAB_ACTIVE_CENTER, IDR_TAB_ACTIVE_RIGHT);
- static ui::ThreePartImage* inactiveStroke = new ui::ThreePartImage(
- IDR_TAB_INACTIVE_LEFT, IDR_TAB_INACTIVE_CENTER, IDR_TAB_INACTIVE_RIGHT);
+ui::ThreePartImage& GetStrokeImage(bool active) {
+ CR_DEFINE_STATIC_LOCAL(
+ ui::ThreePartImage, activeStroke,
+ (IDR_TAB_ACTIVE_LEFT, IDR_TAB_ACTIVE_CENTER, IDR_TAB_ACTIVE_RIGHT));
+ CR_DEFINE_STATIC_LOCAL(
+ ui::ThreePartImage, inactiveStroke,
+ (IDR_TAB_INACTIVE_LEFT, IDR_TAB_INACTIVE_CENTER, IDR_TAB_INACTIVE_RIGHT));
return active ? activeStroke : inactiveStroke;
}
@@ -179,7 +181,7 @@ ui::ThreePartImage* GetStrokeImage(bool active) {
NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]];
NSRect maskRect = [self bounds];
maskRect.size.height = kFillHeight;
- return GetMaskImage()->HitTest(viewPoint, maskRect) ? self : nil;
+ return GetMaskImage().HitTest(viewPoint, maskRect) ? self : nil;
}
// Returns |YES| if this tab can be torn away into a new window.
@@ -335,9 +337,9 @@ ui::ThreePartImage* GetStrokeImage(bool active) {
// If we filled outside the middle rect, we need to erase what we filled
// outside the tab's shape.
// This only works if we are drawing to our own backing layer.
- if (!NSContainsRect(GetMaskImage()->GetMiddleRect(bounds), dirtyRect)) {
+ if (!NSContainsRect(GetMaskImage().GetMiddleRect(bounds), dirtyRect)) {
DCHECK([self layer]);
- GetMaskImage()->DrawInRect(bounds, NSCompositeDestinationIn, 1.0);
+ GetMaskImage().DrawInRect(bounds, NSCompositeDestinationIn, 1.0);
}
}
@@ -395,7 +397,7 @@ ui::ThreePartImage* GetStrokeImage(bool active) {
- (void)drawStroke:(NSRect)dirtyRect {
CGFloat alpha = [[self window] isMainWindow] ? 1.0 : tabs::kImageNoFocusAlpha;
GetStrokeImage(state_ == NSOnState)
- ->DrawInRect([self bounds], NSCompositeSourceOver, alpha);
+ .DrawInRect([self bounds], NSCompositeSourceOver, alpha);
}
- (void)drawRect:(NSRect)dirtyRect {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698