| 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 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/browser/themes/theme_service.h" | 26 #include "chrome/browser/themes/theme_service.h" |
| 27 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/browser/ui/browser_navigator.h" | 28 #include "chrome/browser/ui/browser_navigator.h" |
| 29 #include "chrome/browser/ui/browser_navigator_params.h" | 29 #include "chrome/browser/ui/browser_navigator_params.h" |
| 30 #include "chrome/browser/ui/browser_tabstrip.h" | 30 #include "chrome/browser/ui/browser_tabstrip.h" |
| 31 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 31 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 32 #include "chrome/browser/ui/cocoa/drag_util.h" | 32 #include "chrome/browser/ui/cocoa/drag_util.h" |
| 33 #import "chrome/browser/ui/cocoa/image_button_cell.h" | 33 #import "chrome/browser/ui/cocoa/image_button_cell.h" |
| 34 #include "chrome/browser/ui/cocoa/l10n_util.h" | 34 #import "ui/base/cocoa/rtl_util.h" |
| 35 #import "chrome/browser/ui/cocoa/new_tab_button.h" | 35 #import "chrome/browser/ui/cocoa/new_tab_button.h" |
| 36 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h" | 36 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h" |
| 37 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 37 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
| 38 #import "chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h" | 38 #import "chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h" |
| 39 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" | 39 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" |
| 40 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" | 40 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" |
| 41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" | 41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" |
| 42 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 42 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
| 43 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 43 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 44 #import "chrome/browser/ui/cocoa/themed_window.h" | 44 #import "chrome/browser/ui/cocoa/themed_window.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 [[NSAnimationContext currentContext] setDuration:kMinimumTimeInterval]; | 130 [[NSAnimationContext currentContext] setDuration:kMinimumTimeInterval]; |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 private: | 134 private: |
| 135 bool animate_; | 135 bool animate_; |
| 136 DISALLOW_COPY_AND_ASSIGN(ScopedNSAnimationContextGroup); | 136 DISALLOW_COPY_AND_ASSIGN(ScopedNSAnimationContextGroup); |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { | 139 CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { |
| 140 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) | 140 if (cocoa_rtl_util::ShouldDoExperimentalRTLLayout()) |
| 141 return [view frame].size.width - x - width; | 141 return [view frame].size.width - x - width; |
| 142 return x; | 142 return x; |
| 143 } | 143 } |
| 144 | 144 |
| 145 NSRect FlipRectInView(NSView* view, NSRect rect) { | 145 NSRect FlipRectInView(NSView* view, NSRect rect) { |
| 146 rect.origin.x = FlipXInView(view, NSWidth(rect), NSMinX(rect)); | 146 rect.origin.x = FlipXInView(view, NSWidth(rect), NSMinX(rect)); |
| 147 return rect; | 147 return rect; |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace | 150 } // namespace |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 // However, if the tab being closed is a pinned tab, break out of | 824 // However, if the tab being closed is a pinned tab, break out of |
| 825 // rapid-closure mode since the mouse is almost guaranteed not to be over | 825 // rapid-closure mode since the mouse is almost guaranteed not to be over |
| 826 // the closebox of the adjacent tab (due to the difference in widths). | 826 // the closebox of the adjacent tab (due to the difference in widths). |
| 827 // TODO(pinkerton): re-visit when handling tab overflow. | 827 // TODO(pinkerton): re-visit when handling tab overflow. |
| 828 // http://crbug.com/188 | 828 // http://crbug.com/188 |
| 829 if (tabStripModel_->IsTabPinned(index)) { | 829 if (tabStripModel_->IsTabPinned(index)) { |
| 830 availableResizeWidth_ = kUseFullAvailableWidth; | 830 availableResizeWidth_ = kUseFullAvailableWidth; |
| 831 } else { | 831 } else { |
| 832 NSView* penultimateTab = [self viewAtIndex:numberOfOpenTabs - 2]; | 832 NSView* penultimateTab = [self viewAtIndex:numberOfOpenTabs - 2]; |
| 833 availableResizeWidth_ = | 833 availableResizeWidth_ = |
| 834 cocoa_l10n_util::ShouldDoExperimentalRTLLayout() | 834 cocoa_rtl_util::ShouldDoExperimentalRTLLayout() |
| 835 ? FlipXInView(tabStripView_, 0, NSMinX([penultimateTab frame])) | 835 ? FlipXInView(tabStripView_, 0, NSMinX([penultimateTab frame])) |
| 836 : NSMaxX([penultimateTab frame]); | 836 : NSMaxX([penultimateTab frame]); |
| 837 } | 837 } |
| 838 } else { | 838 } else { |
| 839 // If the trailing tab is closed, change the available width so that | 839 // If the trailing tab is closed, change the available width so that |
| 840 // another tab's close button lands below the cursor (assuming the tabs | 840 // another tab's close button lands below the cursor (assuming the tabs |
| 841 // are currently below their maximum width and can grow). | 841 // are currently below their maximum width and can grow). |
| 842 NSView* lastTab = [self viewAtIndex:numberOfOpenTabs - 1]; | 842 NSView* lastTab = [self viewAtIndex:numberOfOpenTabs - 1]; |
| 843 availableResizeWidth_ = | 843 availableResizeWidth_ = |
| 844 cocoa_l10n_util::ShouldDoExperimentalRTLLayout() | 844 cocoa_rtl_util::ShouldDoExperimentalRTLLayout() |
| 845 ? FlipXInView(tabStripView_, 0, NSMinX([lastTab frame])) | 845 ? FlipXInView(tabStripView_, 0, NSMinX([lastTab frame])) |
| 846 : NSMaxX([lastTab frame]); | 846 : NSMaxX([lastTab frame]); |
| 847 } | 847 } |
| 848 tabStripModel_->CloseWebContentsAt( | 848 tabStripModel_->CloseWebContentsAt( |
| 849 index, | 849 index, |
| 850 TabStripModel::CLOSE_USER_GESTURE | | 850 TabStripModel::CLOSE_USER_GESTURE | |
| 851 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | 851 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); |
| 852 } else { | 852 } else { |
| 853 // Use the standard window close if this is the last tab | 853 // Use the standard window close if this is the last tab |
| 854 // this prevents the tab from being removed from the model until after | 854 // this prevents the tab from being removed from the model until after |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 placeholderFrame_ = frame; | 892 placeholderFrame_ = frame; |
| 893 [self layoutTabsWithAnimation:initialLayoutComplete_ regenerateSubviews:NO]; | 893 [self layoutTabsWithAnimation:initialLayoutComplete_ regenerateSubviews:NO]; |
| 894 } | 894 } |
| 895 | 895 |
| 896 - (BOOL)isDragSessionActive { | 896 - (BOOL)isDragSessionActive { |
| 897 return placeholderTab_ != nil; | 897 return placeholderTab_ != nil; |
| 898 } | 898 } |
| 899 | 899 |
| 900 - (BOOL)isTabFullyVisible:(TabView*)tab { | 900 - (BOOL)isTabFullyVisible:(TabView*)tab { |
| 901 NSRect frame = [tab frame]; | 901 NSRect frame = [tab frame]; |
| 902 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) { | 902 if (cocoa_rtl_util::ShouldDoExperimentalRTLLayout()) { |
| 903 return NSMinX(frame) >= [self trailingIndentForControls] && | 903 return NSMinX(frame) >= [self trailingIndentForControls] && |
| 904 NSMaxX(frame) <= [self tabAreaRightEdge]; | 904 NSMaxX(frame) <= [self tabAreaRightEdge]; |
| 905 } else { | 905 } else { |
| 906 return NSMinX(frame) >= [self leadingIndentForControls] && | 906 return NSMinX(frame) >= [self leadingIndentForControls] && |
| 907 NSMaxX(frame) <= [self tabAreaRightEdge]; | 907 NSMaxX(frame) <= [self tabAreaRightEdge]; |
| 908 } | 908 } |
| 909 } | 909 } |
| 910 | 910 |
| 911 - (CGFloat)tabAreaRightEdge { | 911 - (CGFloat)tabAreaRightEdge { |
| 912 CGFloat rightEdge = cocoa_l10n_util::ShouldDoExperimentalRTLLayout() | 912 CGFloat rightEdge = cocoa_rtl_util::ShouldDoExperimentalRTLLayout() |
| 913 ? [self leadingIndentForControls] | 913 ? [self leadingIndentForControls] |
| 914 : [self trailingIndentForControls]; | 914 : [self trailingIndentForControls]; |
| 915 return NSMaxX([tabStripView_ frame]) - rightEdge; | 915 return NSMaxX([tabStripView_ frame]) - rightEdge; |
| 916 } | 916 } |
| 917 | 917 |
| 918 - (void)showNewTabButton:(BOOL)show { | 918 - (void)showNewTabButton:(BOOL)show { |
| 919 forceNewTabButtonHidden_ = show ? NO : YES; | 919 forceNewTabButtonHidden_ = show ? NO : YES; |
| 920 if (forceNewTabButtonHidden_) | 920 if (forceNewTabButtonHidden_) |
| 921 [newTabButton_ setHidden:YES]; | 921 [newTabButton_ setHidden:YES]; |
| 922 } | 922 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 NSValue* identifier = [NSValue valueWithPointer:[tab view]]; | 1066 NSValue* identifier = [NSValue valueWithPointer:[tab view]]; |
| 1067 [targetFrames_ setObject:[NSValue valueWithRect:tabFrame] | 1067 [targetFrames_ setObject:[NSValue valueWithRect:tabFrame] |
| 1068 forKey:identifier]; | 1068 forKey:identifier]; |
| 1069 continue; | 1069 continue; |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 if (placeholderTab_ && !hasPlaceholderGap) { | 1072 if (placeholderTab_ && !hasPlaceholderGap) { |
| 1073 // If the back edge is behind the placeholder's back edge, but the | 1073 // If the back edge is behind the placeholder's back edge, but the |
| 1074 // mid is in front of it of it, slide over to make space for it. | 1074 // mid is in front of it of it, slide over to make space for it. |
| 1075 bool shouldLeaveGap; | 1075 bool shouldLeaveGap; |
| 1076 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) { | 1076 if (cocoa_rtl_util::ShouldDoExperimentalRTLLayout()) { |
| 1077 const CGFloat tabMidpoint = | 1077 const CGFloat tabMidpoint = |
| 1078 NSMidX(FlipRectInView(tabStripView_, tabFrame)); | 1078 NSMidX(FlipRectInView(tabStripView_, tabFrame)); |
| 1079 shouldLeaveGap = tabMidpoint < NSMaxX(placeholderFrame_); | 1079 shouldLeaveGap = tabMidpoint < NSMaxX(placeholderFrame_); |
| 1080 } else { | 1080 } else { |
| 1081 shouldLeaveGap = NSMidX(tabFrame) > NSMinX(placeholderFrame_); | 1081 shouldLeaveGap = NSMidX(tabFrame) > NSMinX(placeholderFrame_); |
| 1082 } | 1082 } |
| 1083 if (shouldLeaveGap) { | 1083 if (shouldLeaveGap) { |
| 1084 hasPlaceholderGap = true; | 1084 hasPlaceholderGap = true; |
| 1085 offset += NSWidth(placeholderFrame_); | 1085 offset += NSWidth(placeholderFrame_); |
| 1086 offset -= kTabOverlap; | 1086 offset -= kTabOverlap; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 // be hidden, doing it again doesn't hurt. Otherwise position it | 1181 // be hidden, doing it again doesn't hurt. Otherwise position it |
| 1182 // appropriately, showing it if necessary. | 1182 // appropriately, showing it if necessary. |
| 1183 if (forceNewTabButtonHidden_) { | 1183 if (forceNewTabButtonHidden_) { |
| 1184 [newTabButton_ setHidden:YES]; | 1184 [newTabButton_ setHidden:YES]; |
| 1185 } else { | 1185 } else { |
| 1186 NSRect newTabNewFrame = [newTabButton_ frame]; | 1186 NSRect newTabNewFrame = [newTabButton_ frame]; |
| 1187 // We've already ensured there's enough space for the new tab button | 1187 // We've already ensured there's enough space for the new tab button |
| 1188 // so we don't have to check it against the available space. We do need | 1188 // so we don't have to check it against the available space. We do need |
| 1189 // to make sure we put it after any placeholder. | 1189 // to make sure we put it after any placeholder. |
| 1190 CGFloat maxTabX = MAX(offset, NSMaxX(placeholderFrame_) - kTabOverlap); | 1190 CGFloat maxTabX = MAX(offset, NSMaxX(placeholderFrame_) - kTabOverlap); |
| 1191 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) { | 1191 if (cocoa_rtl_util::ShouldDoExperimentalRTLLayout()) { |
| 1192 maxTabX = FlipXInView(tabStripView_, [newTabButton_ frame].size.width, | 1192 maxTabX = FlipXInView(tabStripView_, [newTabButton_ frame].size.width, |
| 1193 maxTabX) - | 1193 maxTabX) - |
| 1194 (2 * kNewTabButtonOffset); | 1194 (2 * kNewTabButtonOffset); |
| 1195 } | 1195 } |
| 1196 newTabNewFrame.origin = NSMakePoint(maxTabX + kNewTabButtonOffset, 0); | 1196 newTabNewFrame.origin = NSMakePoint(maxTabX + kNewTabButtonOffset, 0); |
| 1197 if ([tabContentsArray_ count]) | 1197 if ([tabContentsArray_ count]) |
| 1198 [newTabButton_ setHidden:NO]; | 1198 [newTabButton_ setHidden:NO]; |
| 1199 | 1199 |
| 1200 if (!NSEqualRects(newTabTargetFrame_, newTabNewFrame)) { | 1200 if (!NSEqualRects(newTabTargetFrame_, newTabNewFrame)) { |
| 1201 // Set the new tab button image correctly based on where the cursor is. | 1201 // Set the new tab button image correctly based on where the cursor is. |
| 1202 NSWindow* window = [tabStripView_ window]; | 1202 NSWindow* window = [tabStripView_ window]; |
| 1203 NSPoint currentMouse = [window mouseLocationOutsideOfEventStream]; | 1203 NSPoint currentMouse = [window mouseLocationOutsideOfEventStream]; |
| 1204 currentMouse = [tabStripView_ convertPoint:currentMouse fromView:nil]; | 1204 currentMouse = [tabStripView_ convertPoint:currentMouse fromView:nil]; |
| 1205 | 1205 |
| 1206 BOOL shouldShowHover = [newTabButton_ pointIsOverButton:currentMouse]; | 1206 BOOL shouldShowHover = [newTabButton_ pointIsOverButton:currentMouse]; |
| 1207 [self setNewTabButtonHoverState:shouldShowHover]; | 1207 [self setNewTabButtonHoverState:shouldShowHover]; |
| 1208 | 1208 |
| 1209 // Move the new tab button into place. We want to animate the new tab | 1209 // Move the new tab button into place. We want to animate the new tab |
| 1210 // button if it's moving back (closing a tab), but not when it's | 1210 // button if it's moving back (closing a tab), but not when it's |
| 1211 // moving forward (inserting a new tab). If moving forward, we need | 1211 // moving forward (inserting a new tab). If moving forward, we need |
| 1212 // to use a very small duration to make sure we cancel any in-flight | 1212 // to use a very small duration to make sure we cancel any in-flight |
| 1213 // animation to the left. | 1213 // animation to the left. |
| 1214 if (visible && animate) { | 1214 if (visible && animate) { |
| 1215 ScopedNSAnimationContextGroup localAnimationGroup(true); | 1215 ScopedNSAnimationContextGroup localAnimationGroup(true); |
| 1216 BOOL movingBack = NSMinX(newTabNewFrame) < NSMinX(newTabTargetFrame_); | 1216 BOOL movingBack = NSMinX(newTabNewFrame) < NSMinX(newTabTargetFrame_); |
| 1217 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) | 1217 if (cocoa_rtl_util::ShouldDoExperimentalRTLLayout()) |
| 1218 movingBack = !movingBack; | 1218 movingBack = !movingBack; |
| 1219 | 1219 |
| 1220 if (!movingBack) { | 1220 if (!movingBack) { |
| 1221 localAnimationGroup.SetCurrentContextShortestDuration(); | 1221 localAnimationGroup.SetCurrentContextShortestDuration(); |
| 1222 } | 1222 } |
| 1223 [[newTabButton_ animator] setFrame:newTabNewFrame]; | 1223 [[newTabButton_ animator] setFrame:newTabNewFrame]; |
| 1224 newTabTargetFrame_ = newTabNewFrame; | 1224 newTabTargetFrame_ = newTabNewFrame; |
| 1225 } else { | 1225 } else { |
| 1226 [newTabButton_ setFrame:newTabNewFrame]; | 1226 [newTabButton_ setFrame:newTabNewFrame]; |
| 1227 newTabTargetFrame_ = newTabNewFrame; | 1227 newTabTargetFrame_ = newTabNewFrame; |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1750 } | 1750 } |
| 1751 | 1751 |
| 1752 - (int)indexOfPlaceholder { | 1752 - (int)indexOfPlaceholder { |
| 1753 // Use |tabArray_| here instead of the tab strip count in order to get the | 1753 // Use |tabArray_| here instead of the tab strip count in order to get the |
| 1754 // correct index when there are closing tabs to the left of the placeholder. | 1754 // correct index when there are closing tabs to the left of the placeholder. |
| 1755 const int count = [tabArray_ count]; | 1755 const int count = [tabArray_ count]; |
| 1756 | 1756 |
| 1757 // No placeholder, return the end of the strip. | 1757 // No placeholder, return the end of the strip. |
| 1758 if (placeholderTab_ == nil) | 1758 if (placeholderTab_ == nil) |
| 1759 return count; | 1759 return count; |
| 1760 BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout(); | 1760 BOOL isRTL = cocoa_rtl_util::ShouldDoExperimentalRTLLayout(); |
| 1761 double placeholderX = | 1761 double placeholderX = |
| 1762 isRTL ? NSMaxX(placeholderFrame_) : placeholderFrame_.origin.x; | 1762 isRTL ? NSMaxX(placeholderFrame_) : placeholderFrame_.origin.x; |
| 1763 int index = 0; | 1763 int index = 0; |
| 1764 int location = 0; | 1764 int location = 0; |
| 1765 while (index < count) { | 1765 while (index < count) { |
| 1766 // Ignore closing tabs for simplicity. The only drawback of this is that | 1766 // Ignore closing tabs for simplicity. The only drawback of this is that |
| 1767 // if the placeholder is placed right before one or several contiguous | 1767 // if the placeholder is placed right before one or several contiguous |
| 1768 // currently closing tabs, the associated TabController will start at the | 1768 // currently closing tabs, the associated TabController will start at the |
| 1769 // end of the closing tabs. | 1769 // end of the closing tabs. |
| 1770 if ([closingControllers_ containsObject:[tabArray_ objectAtIndex:index]]) { | 1770 if ([closingControllers_ containsObject:[tabArray_ objectAtIndex:index]]) { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2042 disposition:(WindowOpenDisposition*)disposition | 2042 disposition:(WindowOpenDisposition*)disposition |
| 2043 activateTab:(BOOL)activateTab { | 2043 activateTab:(BOOL)activateTab { |
| 2044 // Proportion of the tab which is considered the "middle" (and causes things | 2044 // Proportion of the tab which is considered the "middle" (and causes things |
| 2045 // to drop on that tab). | 2045 // to drop on that tab). |
| 2046 const double kMiddleProportion = 0.5; | 2046 const double kMiddleProportion = 0.5; |
| 2047 const double kLRProportion = (1.0 - kMiddleProportion) / 2.0; | 2047 const double kLRProportion = (1.0 - kMiddleProportion) / 2.0; |
| 2048 const CGFloat kTabOverlap = [TabStripController tabOverlap]; | 2048 const CGFloat kTabOverlap = [TabStripController tabOverlap]; |
| 2049 | 2049 |
| 2050 DCHECK(index && disposition); | 2050 DCHECK(index && disposition); |
| 2051 NSInteger i = 0; | 2051 NSInteger i = 0; |
| 2052 BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout(); | 2052 BOOL isRTL = cocoa_rtl_util::ShouldDoExperimentalRTLLayout(); |
| 2053 for (TabController* tab in tabArray_.get()) { | 2053 for (TabController* tab in tabArray_.get()) { |
| 2054 NSView* view = [tab view]; | 2054 NSView* view = [tab view]; |
| 2055 DCHECK([view isKindOfClass:[TabView class]]); | 2055 DCHECK([view isKindOfClass:[TabView class]]); |
| 2056 | 2056 |
| 2057 // Recall that |-[NSView frame]| is in its superview's coordinates, so a | 2057 // Recall that |-[NSView frame]| is in its superview's coordinates, so a |
| 2058 // |TabView|'s frame is in the coordinates of the |TabStripView| (which | 2058 // |TabView|'s frame is in the coordinates of the |TabStripView| (which |
| 2059 // matches the coordinate system of |point|). | 2059 // matches the coordinate system of |point|). |
| 2060 NSRect frame = [view frame]; | 2060 NSRect frame = [view frame]; |
| 2061 | 2061 |
| 2062 // Modify the frame to make it "unoverlapped". | 2062 // Modify the frame to make it "unoverlapped". |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2264 return nil; | 2264 return nil; |
| 2265 NSInteger index = [self indexFromModelIndex:modelIndex]; | 2265 NSInteger index = [self indexFromModelIndex:modelIndex]; |
| 2266 if (index < 0 || | 2266 if (index < 0 || |
| 2267 index >= (NSInteger)[tabContentsArray_ count]) | 2267 index >= (NSInteger)[tabContentsArray_ count]) |
| 2268 return nil; | 2268 return nil; |
| 2269 return [tabContentsArray_ objectAtIndex:index]; | 2269 return [tabContentsArray_ objectAtIndex:index]; |
| 2270 } | 2270 } |
| 2271 | 2271 |
| 2272 - (void)addCustomWindowControls { | 2272 - (void)addCustomWindowControls { |
| 2273 BOOL shouldFlipWindowControls = | 2273 BOOL shouldFlipWindowControls = |
| 2274 cocoa_l10n_util::ShouldFlipWindowControlsInRTL(); | 2274 cocoa_rtl_util::ShouldFlipWindowControlsInRTL(); |
| 2275 if (!customWindowControls_) { | 2275 if (!customWindowControls_) { |
| 2276 // Make the container view. | 2276 // Make the container view. |
| 2277 CGFloat height = NSHeight([tabStripView_ frame]); | 2277 CGFloat height = NSHeight([tabStripView_ frame]); |
| 2278 CGFloat width = [self leadingIndentForControls]; | 2278 CGFloat width = [self leadingIndentForControls]; |
| 2279 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout() && | 2279 if (cocoa_rtl_util::ShouldDoExperimentalRTLLayout() && |
| 2280 !shouldFlipWindowControls) | 2280 !shouldFlipWindowControls) |
| 2281 // The trailing indent is correct in this case, since the controls should | 2281 // The trailing indent is correct in this case, since the controls should |
| 2282 // stay on the left. | 2282 // stay on the left. |
| 2283 width = [self trailingIndentForControls]; | 2283 width = [self trailingIndentForControls]; |
| 2284 CGFloat xOrigin = | 2284 CGFloat xOrigin = |
| 2285 shouldFlipWindowControls ? NSWidth([tabStripView_ frame]) - width : 0; | 2285 shouldFlipWindowControls ? NSWidth([tabStripView_ frame]) - width : 0; |
| 2286 NSRect frame = NSMakeRect(xOrigin, 0, width, height); | 2286 NSRect frame = NSMakeRect(xOrigin, 0, width, height); |
| 2287 customWindowControls_.reset( | 2287 customWindowControls_.reset( |
| 2288 [[CustomWindowControlsView alloc] initWithFrame:frame]); | 2288 [[CustomWindowControlsView alloc] initWithFrame:frame]); |
| 2289 [customWindowControls_ | 2289 [customWindowControls_ |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2408 for (int i = 0; i < tabStripModel_->count(); i++) { | 2408 for (int i = 0; i < tabStripModel_->count(); i++) { |
| 2409 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i]; | 2409 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i]; |
| 2410 } | 2410 } |
| 2411 } | 2411 } |
| 2412 | 2412 |
| 2413 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { | 2413 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { |
| 2414 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; | 2414 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; |
| 2415 } | 2415 } |
| 2416 | 2416 |
| 2417 @end | 2417 @end |
| OLD | NEW |