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_strip_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <limits> | 10 #include <limits> |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 NSValue* oldTargetValue = [targetFrames_ objectForKey:identifier]; | 1124 NSValue* oldTargetValue = [targetFrames_ objectForKey:identifier]; |
1125 if (!oldTargetValue || | 1125 if (!oldTargetValue || |
1126 !NSEqualRects([oldTargetValue rectValue], tabFrame)) { | 1126 !NSEqualRects([oldTargetValue rectValue], tabFrame)) { |
1127 // Redraw the tab once it moves to its final location. Because we're | 1127 // Redraw the tab once it moves to its final location. Because we're |
1128 // using Core Animation, each tab caches its contents until told to | 1128 // using Core Animation, each tab caches its contents until told to |
1129 // redraw. Without forcing a redraw at the end of the move, tabs will | 1129 // redraw. Without forcing a redraw at the end of the move, tabs will |
1130 // display the wrong content when using a theme that creates transparent | 1130 // display the wrong content when using a theme that creates transparent |
1131 // tabs. | 1131 // tabs. |
1132 ScopedNSAnimationContextGroup subAnimationGroup(animate); | 1132 ScopedNSAnimationContextGroup subAnimationGroup(animate); |
1133 subAnimationGroup.SetCurrentContextDuration(kAnimationDuration); | 1133 subAnimationGroup.SetCurrentContextDuration(kAnimationDuration); |
1134 // -[NSAnimationContext setCompletionHandler:] is only available on | 1134 NSView* tabView = [tab view]; |
1135 // 10.7 and higher. | 1135 [[NSAnimationContext currentContext] setCompletionHandler:^{ |
1136 if (base::mac::IsOSLionOrLater()) { | 1136 [tabView setNeedsDisplay:YES]; |
1137 NSView* tabView = [tab view]; | 1137 }]; |
1138 [[NSAnimationContext currentContext] setCompletionHandler:^{ | |
1139 [tabView setNeedsDisplay:YES]; | |
1140 }]; | |
1141 } | |
1142 | 1138 |
1143 [frameTarget setFrame:tabFrame]; | 1139 [frameTarget setFrame:tabFrame]; |
1144 [targetFrames_ setObject:[NSValue valueWithRect:tabFrame] | 1140 [targetFrames_ setObject:[NSValue valueWithRect:tabFrame] |
1145 forKey:identifier]; | 1141 forKey:identifier]; |
1146 } | 1142 } |
1147 | 1143 |
1148 enclosingRect = NSUnionRect(tabFrame, enclosingRect); | 1144 enclosingRect = NSUnionRect(tabFrame, enclosingRect); |
1149 | 1145 |
1150 offset += NSWidth(tabFrame); | 1146 offset += NSWidth(tabFrame); |
1151 offset -= kTabOverlap; | 1147 offset -= kTabOverlap; |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2293 | 2289 |
2294 - (TabAlertState)alertStateForContents:(content::WebContents*)contents { | 2290 - (TabAlertState)alertStateForContents:(content::WebContents*)contents { |
2295 return chrome::GetTabAlertStateForContents(contents); | 2291 return chrome::GetTabAlertStateForContents(contents); |
2296 } | 2292 } |
2297 | 2293 |
2298 - (void)themeDidChangeNotification:(NSNotification*)notification { | 2294 - (void)themeDidChangeNotification:(NSNotification*)notification { |
2299 [newTabButton_ setImages]; | 2295 [newTabButton_ setImages]; |
2300 } | 2296 } |
2301 | 2297 |
2302 @end | 2298 @end |
OLD | NEW |