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

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

Issue 2680203004: Do RTL tabstrip transforms before animating tabs. (Closed)
Patch Set: Created 3 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 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 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 tabFrame.size.width = MAX(tabFrame.size.width, kMinActiveTabWidth); 1120 tabFrame.size.width = MAX(tabFrame.size.width, kMinActiveTabWidth);
1121 1121
1122 // If this is the first non-pinned tab, then add a bit of spacing between 1122 // If this is the first non-pinned tab, then add a bit of spacing between
1123 // this and the last pinned tab. 1123 // this and the last pinned tab.
1124 if (!isPinned && isLastTabPinned) { 1124 if (!isPinned && isLastTabPinned) {
1125 offset += kLastPinnedTabSpacing; 1125 offset += kLastPinnedTabSpacing;
1126 tabFrame.origin.x = offset; 1126 tabFrame.origin.x = offset;
1127 } 1127 }
1128 isLastTabPinned = isPinned; 1128 isLastTabPinned = isPinned;
1129 1129
1130 // Flip if in RTL mode.
1131 tabFrame.origin.x =
1132 FlipXInView(tabStripView_, tabFrame.size.width, tabFrame.origin.x);
1133
1130 if (laidOutNonPinnedTabs > numberOfNonPinnedTabs) { 1134 if (laidOutNonPinnedTabs > numberOfNonPinnedTabs) {
1131 // There is not enough space to fit this tab. 1135 // There is not enough space to fit this tab.
1132 tabFrame.size.width = 0; 1136 tabFrame.size.width = 0;
1133 [self setFrame:tabFrame ofTabView:[tab view]]; 1137 [self setFrame:tabFrame ofTabView:[tab view]];
1134 continue; 1138 continue;
1135 } 1139 }
1136 1140
1137 // Animate a new tab in by putting it below the horizon unless told to put 1141 // Animate a new tab in by putting it below the horizon unless told to put
1138 // it in a specific location (i.e., from a drop). 1142 // it in a specific location (i.e., from a drop).
1139 if (newTab && visible && animate) { 1143 if (newTab && visible && animate) {
1140 if (NSEqualRects(droppedTabFrame_, NSZeroRect)) { 1144 if (NSEqualRects(droppedTabFrame_, NSZeroRect)) {
1141 [[tab view] setFrame:NSOffsetRect(tabFrame, 0, -NSHeight(tabFrame))]; 1145 [[tab view] setFrame:NSOffsetRect(tabFrame, 0, -NSHeight(tabFrame))];
1142 } else { 1146 } else {
1143 [[tab view] setFrame:droppedTabFrame_]; 1147 [[tab view] setFrame:droppedTabFrame_];
1144 droppedTabFrame_ = NSZeroRect; 1148 droppedTabFrame_ = NSZeroRect;
1145 } 1149 }
1146 } 1150 }
1147 1151
1148 tabFrame.origin.x =
1149 FlipXInView(tabStripView_, tabFrame.size.width, tabFrame.origin.x);
1150
1151 // Check the frame by identifier to avoid redundant calls to animator. 1152 // Check the frame by identifier to avoid redundant calls to animator.
1152 id frameTarget = visible && animate ? [[tab view] animator] : [tab view]; 1153 id frameTarget = visible && animate ? [[tab view] animator] : [tab view];
1153 NSValue* identifier = [NSValue valueWithPointer:[tab view]]; 1154 NSValue* identifier = [NSValue valueWithPointer:[tab view]];
1154 NSValue* oldTargetValue = [targetFrames_ objectForKey:identifier]; 1155 NSValue* oldTargetValue = [targetFrames_ objectForKey:identifier];
1155 if (!oldTargetValue || 1156 if (!oldTargetValue ||
1156 !NSEqualRects([oldTargetValue rectValue], tabFrame)) { 1157 !NSEqualRects([oldTargetValue rectValue], tabFrame)) {
1157 // Redraw the tab once it moves to its final location. Because we're 1158 // Redraw the tab once it moves to its final location. Because we're
1158 // using Core Animation, each tab caches its contents until told to 1159 // using Core Animation, each tab caches its contents until told to
1159 // redraw. Without forcing a redraw at the end of the move, tabs will 1160 // redraw. Without forcing a redraw at the end of the move, tabs will
1160 // display the wrong content when using a theme that creates transparent 1161 // display the wrong content when using a theme that creates transparent
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 for (int i = 0; i < tabStripModel_->count(); i++) { 2409 for (int i = 0; i < tabStripModel_->count(); i++) {
2409 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i]; 2410 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i];
2410 } 2411 }
2411 } 2412 }
2412 2413
2413 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { 2414 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen {
2414 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; 2415 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen];
2415 } 2416 }
2416 2417
2417 @end 2418 @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