| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/i18n/rtl.h" | |
| 15 #include "base/mac/mac_util.h" | 14 #include "base/mac/mac_util.h" |
| 16 #include "base/mac/scoped_nsautorelease_pool.h" | 15 #include "base/mac/scoped_nsautorelease_pool.h" |
| 17 #include "base/mac/sdk_forward_declarations.h" | 16 #include "base/mac/sdk_forward_declarations.h" |
| 18 #include "base/macros.h" | 17 #include "base/macros.h" |
| 19 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
| 20 #include "base/strings/sys_string_conversions.h" | 19 #include "base/strings/sys_string_conversions.h" |
| 21 #include "chrome/app/chrome_command_ids.h" | 20 #include "chrome/app/chrome_command_ids.h" |
| 22 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 21 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 23 #include "chrome/browser/extensions/tab_helper.h" | 22 #include "chrome/browser/extensions/tab_helper.h" |
| 24 #include "chrome/browser/favicon/favicon_utils.h" | 23 #include "chrome/browser/favicon/favicon_utils.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 [[NSAnimationContext currentContext] setDuration:kMinimumTimeInterval]; | 131 [[NSAnimationContext currentContext] setDuration:kMinimumTimeInterval]; |
| 133 } | 132 } |
| 134 } | 133 } |
| 135 | 134 |
| 136 private: | 135 private: |
| 137 bool animate_; | 136 bool animate_; |
| 138 DISALLOW_COPY_AND_ASSIGN(ScopedNSAnimationContextGroup); | 137 DISALLOW_COPY_AND_ASSIGN(ScopedNSAnimationContextGroup); |
| 139 }; | 138 }; |
| 140 | 139 |
| 141 CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { | 140 CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { |
| 142 if (cocoa_l10n_util::ExperimentalMacRTLIsEnabled() && base::i18n::IsRTL()) | 141 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) |
| 143 return [view frame].size.width - x - width; | 142 return [view frame].size.width - x - width; |
| 144 return x; | 143 return x; |
| 145 } | 144 } |
| 146 | 145 |
| 147 } // namespace | 146 } // namespace |
| 148 | 147 |
| 149 @interface TabStripController (Private) | 148 @interface TabStripController (Private) |
| 150 - (void)addSubviewToPermanentList:(NSView*)aView; | 149 - (void)addSubviewToPermanentList:(NSView*)aView; |
| 151 - (void)regenerateSubviewList; | 150 - (void)regenerateSubviewList; |
| 152 - (NSInteger)indexForContentsView:(NSView*)view; | 151 - (NSInteger)indexForContentsView:(NSView*)view; |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 | 1000 |
| 1002 // Separate integral and fractional parts. | 1001 // Separate integral and fractional parts. |
| 1003 CGFloat integralPart = std::floor(nonPinnedTabWidth); | 1002 CGFloat integralPart = std::floor(nonPinnedTabWidth); |
| 1004 nonPinnedTabWidthFraction = nonPinnedTabWidth - integralPart; | 1003 nonPinnedTabWidthFraction = nonPinnedTabWidth - integralPart; |
| 1005 nonPinnedTabWidth = integralPart; | 1004 nonPinnedTabWidth = integralPart; |
| 1006 } | 1005 } |
| 1007 | 1006 |
| 1008 BOOL visible = [[tabStripView_ window] isVisible]; | 1007 BOOL visible = [[tabStripView_ window] isVisible]; |
| 1009 | 1008 |
| 1010 CGFloat offset = | 1009 CGFloat offset = |
| 1011 cocoa_l10n_util::ExperimentalMacRTLIsEnabled() && base::i18n::IsRTL() | 1010 cocoa_l10n_util::ShouldDoExperimentalRTLLayout() |
| 1012 ? [self rightIndentForControls] | 1011 ? [self rightIndentForControls] |
| 1013 : [self leftIndentForControls]; | 1012 : [self leftIndentForControls]; |
| 1014 bool hasPlaceholderGap = false; | 1013 bool hasPlaceholderGap = false; |
| 1015 // Whether or not the last tab processed by the loop was a pinned tab. | 1014 // Whether or not the last tab processed by the loop was a pinned tab. |
| 1016 BOOL isLastTabPinned = NO; | 1015 BOOL isLastTabPinned = NO; |
| 1017 CGFloat tabWidthAccumulatedFraction = 0; | 1016 CGFloat tabWidthAccumulatedFraction = 0; |
| 1018 NSInteger laidOutNonPinnedTabs = 0; | 1017 NSInteger laidOutNonPinnedTabs = 0; |
| 1019 | 1018 |
| 1020 for (TabController* tab in tabArray_.get()) { | 1019 for (TabController* tab in tabArray_.get()) { |
| 1021 // Ignore a tab that is going through a close animation. | 1020 // Ignore a tab that is going through a close animation. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 // be hidden, doing it again doesn't hurt. Otherwise position it | 1154 // be hidden, doing it again doesn't hurt. Otherwise position it |
| 1156 // appropriately, showing it if necessary. | 1155 // appropriately, showing it if necessary. |
| 1157 if (forceNewTabButtonHidden_) { | 1156 if (forceNewTabButtonHidden_) { |
| 1158 [newTabButton_ setHidden:YES]; | 1157 [newTabButton_ setHidden:YES]; |
| 1159 } else { | 1158 } else { |
| 1160 NSRect newTabNewFrame = [newTabButton_ frame]; | 1159 NSRect newTabNewFrame = [newTabButton_ frame]; |
| 1161 // We've already ensured there's enough space for the new tab button | 1160 // We've already ensured there's enough space for the new tab button |
| 1162 // so we don't have to check it against the available space. We do need | 1161 // so we don't have to check it against the available space. We do need |
| 1163 // to make sure we put it after any placeholder. | 1162 // to make sure we put it after any placeholder. |
| 1164 CGFloat maxTabX = MAX(offset, NSMaxX(placeholderFrame_) - kTabOverlap); | 1163 CGFloat maxTabX = MAX(offset, NSMaxX(placeholderFrame_) - kTabOverlap); |
| 1165 if (cocoa_l10n_util::ExperimentalMacRTLIsEnabled() && base::i18n::IsRTL()) { | 1164 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) { |
| 1166 maxTabX = FlipXInView(tabStripView_, [newTabButton_ frame].size.width, | 1165 maxTabX = FlipXInView(tabStripView_, [newTabButton_ frame].size.width, |
| 1167 maxTabX) - | 1166 maxTabX) - |
| 1168 (2 * kNewTabButtonOffset); | 1167 (2 * kNewTabButtonOffset); |
| 1169 } | 1168 } |
| 1170 newTabNewFrame.origin = NSMakePoint(maxTabX + kNewTabButtonOffset, 0); | 1169 newTabNewFrame.origin = NSMakePoint(maxTabX + kNewTabButtonOffset, 0); |
| 1171 if ([tabContentsArray_ count]) | 1170 if ([tabContentsArray_ count]) |
| 1172 [newTabButton_ setHidden:NO]; | 1171 [newTabButton_ setHidden:NO]; |
| 1173 | 1172 |
| 1174 if (!NSEqualRects(newTabTargetFrame_, newTabNewFrame)) { | 1173 if (!NSEqualRects(newTabTargetFrame_, newTabNewFrame)) { |
| 1175 // 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. |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2334 for (int i = 0; i < tabStripModel_->count(); i++) { | 2333 for (int i = 0; i < tabStripModel_->count(); i++) { |
| 2335 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i]; | 2334 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i]; |
| 2336 } | 2335 } |
| 2337 } | 2336 } |
| 2338 | 2337 |
| 2339 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { | 2338 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { |
| 2340 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; | 2339 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; |
| 2341 } | 2340 } |
| 2342 | 2341 |
| 2343 @end | 2342 @end |
| OLD | NEW |