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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 2407413004: [Mac] Make new tab button animation RTL-aware (Closed)
Patch Set: Stray Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 if (!NSEqualRects(newTabTargetFrame_, newTabNewFrame)) { 1173 if (!NSEqualRects(newTabTargetFrame_, newTabNewFrame)) {
1174 // Set the new tab button image correctly based on where the cursor is. 1174 // Set the new tab button image correctly based on where the cursor is.
1175 NSWindow* window = [tabStripView_ window]; 1175 NSWindow* window = [tabStripView_ window];
1176 NSPoint currentMouse = [window mouseLocationOutsideOfEventStream]; 1176 NSPoint currentMouse = [window mouseLocationOutsideOfEventStream];
1177 currentMouse = [tabStripView_ convertPoint:currentMouse fromView:nil]; 1177 currentMouse = [tabStripView_ convertPoint:currentMouse fromView:nil];
1178 1178
1179 BOOL shouldShowHover = [newTabButton_ pointIsOverButton:currentMouse]; 1179 BOOL shouldShowHover = [newTabButton_ pointIsOverButton:currentMouse];
1180 [self setNewTabButtonHoverState:shouldShowHover]; 1180 [self setNewTabButtonHoverState:shouldShowHover];
1181 1181
1182 // Move the new tab button into place. We want to animate the new tab 1182 // Move the new tab button into place. We want to animate the new tab
1183 // button if it's moving to the left (closing a tab), but not when it's 1183 // button if it's moving back (closing a tab), but not when it's
1184 // moving to the right (inserting a new tab). If moving right, we need 1184 // moving forward (inserting a new tab). If moving forward, we need
1185 // to use a very small duration to make sure we cancel any in-flight 1185 // to use a very small duration to make sure we cancel any in-flight
1186 // animation to the left. 1186 // animation to the left.
1187 if (visible && animate) { 1187 if (visible && animate) {
1188 ScopedNSAnimationContextGroup localAnimationGroup(true); 1188 ScopedNSAnimationContextGroup localAnimationGroup(true);
1189 BOOL movingLeft = NSMinX(newTabNewFrame) < NSMinX(newTabTargetFrame_); 1189 BOOL movingBack = NSMinX(newTabNewFrame) < NSMinX(newTabTargetFrame_);
1190 if (!movingLeft) { 1190 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout())
1191 movingBack = !movingBack;
1192
1193 if (!movingBack) {
1191 localAnimationGroup.SetCurrentContextShortestDuration(); 1194 localAnimationGroup.SetCurrentContextShortestDuration();
1192 } 1195 }
1193 [[newTabButton_ animator] setFrame:newTabNewFrame]; 1196 [[newTabButton_ animator] setFrame:newTabNewFrame];
1194 newTabTargetFrame_ = newTabNewFrame; 1197 newTabTargetFrame_ = newTabNewFrame;
1195 } else { 1198 } else {
1196 [newTabButton_ setFrame:newTabNewFrame]; 1199 [newTabButton_ setFrame:newTabNewFrame];
1197 newTabTargetFrame_ = newTabNewFrame; 1200 newTabTargetFrame_ = newTabNewFrame;
1198 } 1201 }
1199 } 1202 }
1200 } 1203 }
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 for (int i = 0; i < tabStripModel_->count(); i++) { 2338 for (int i = 0; i < tabStripModel_->count(); i++) {
2336 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i]; 2339 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i];
2337 } 2340 }
2338 } 2341 }
2339 2342
2340 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { 2343 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen {
2341 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; 2344 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen];
2342 } 2345 }
2343 2346
2344 @end 2347 @end
OLDNEW
« 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