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

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

Issue 2493273002: [Mac] Fix tab dragging in RTL (Closed)
Patch Set: Stray log Created 4 years, 1 month 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 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 } 1749 }
1750 1750
1751 - (int)indexOfPlaceholder { 1751 - (int)indexOfPlaceholder {
1752 // Use |tabArray_| here instead of the tab strip count in order to get the 1752 // Use |tabArray_| here instead of the tab strip count in order to get the
1753 // correct index when there are closing tabs to the left of the placeholder. 1753 // correct index when there are closing tabs to the left of the placeholder.
1754 const int count = [tabArray_ count]; 1754 const int count = [tabArray_ count];
1755 1755
1756 // No placeholder, return the end of the strip. 1756 // No placeholder, return the end of the strip.
1757 if (placeholderTab_ == nil) 1757 if (placeholderTab_ == nil)
1758 return count; 1758 return count;
1759 1759 BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout();
1760 double placeholderX = placeholderFrame_.origin.x; 1760 double placeholderX =
1761 isRTL ? NSMaxX(placeholderFrame_) : placeholderFrame_.origin.x;
1761 int index = 0; 1762 int index = 0;
1762 int location = 0; 1763 int location = 0;
1763 while (index < count) { 1764 while (index < count) {
1764 // Ignore closing tabs for simplicity. The only drawback of this is that 1765 // Ignore closing tabs for simplicity. The only drawback of this is that
1765 // if the placeholder is placed right before one or several contiguous 1766 // if the placeholder is placed right before one or several contiguous
1766 // currently closing tabs, the associated TabController will start at the 1767 // currently closing tabs, the associated TabController will start at the
1767 // end of the closing tabs. 1768 // end of the closing tabs.
1768 if ([closingControllers_ containsObject:[tabArray_ objectAtIndex:index]]) { 1769 if ([closingControllers_ containsObject:[tabArray_ objectAtIndex:index]]) {
1769 index++; 1770 index++;
1770 continue; 1771 continue;
1771 } 1772 }
1772 NSView* curr = [self viewAtIndex:index]; 1773 NSView* curr = [self viewAtIndex:index];
1773 // The placeholder tab works by changing the frame of the tab being dragged 1774 // The placeholder tab works by changing the frame of the tab being dragged
1774 // to be the bounds of the placeholder, so we need to skip it while we're 1775 // to be the bounds of the placeholder, so we need to skip it while we're
1775 // iterating, otherwise we'll end up off by one. Note This only effects 1776 // iterating, otherwise we'll end up off by one. Note This only effects
1776 // dragging to the right, not to the left. 1777 // dragging to the right, not to the left.
1777 if (curr == placeholderTab_) { 1778 if (curr == placeholderTab_) {
1778 index++; 1779 index++;
1779 continue; 1780 continue;
1780 } 1781 }
1781 if (placeholderX <= NSMinX([curr frame])) 1782 if (isRTL ? placeholderX >= NSMaxX([curr frame])
1783 : placeholderX <= NSMinX([curr frame]))
1782 break; 1784 break;
1783 index++; 1785 index++;
1784 location++; 1786 location++;
1785 } 1787 }
1786 return location; 1788 return location;
1787 } 1789 }
1788 1790
1789 // Move the given tab at index |from| in this window to the location of the 1791 // Move the given tab at index |from| in this window to the location of the
1790 // current placeholder. 1792 // current placeholder.
1791 - (void)moveTabFromIndex:(NSInteger)from { 1793 - (void)moveTabFromIndex:(NSInteger)from {
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
2379 for (int i = 0; i < tabStripModel_->count(); i++) { 2381 for (int i = 0; i < tabStripModel_->count(); i++) {
2380 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i]; 2382 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i];
2381 } 2383 }
2382 } 2384 }
2383 2385
2384 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { 2386 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen {
2385 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; 2387 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen];
2386 } 2388 }
2387 2389
2388 @end 2390 @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