| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> | |
| 10 #include <limits> | 9 #include <limits> |
| 11 #include <string> | 10 #include <string> |
| 12 | 11 |
| 13 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 14 #include "base/mac/mac_util.h" | 13 #include "base/mac/mac_util.h" |
| 15 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
| 16 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete.h" | 16 #include "chrome/browser/autocomplete/autocomplete.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_match.h" | 18 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 // Initialize |nonMiniTabWidth| in case there aren't any non-mini-tabs; this | 851 // Initialize |nonMiniTabWidth| in case there aren't any non-mini-tabs; this |
| 853 // value shouldn't actually be used. | 852 // value shouldn't actually be used. |
| 854 CGFloat nonMiniTabWidth = kMaxTabWidth; | 853 CGFloat nonMiniTabWidth = kMaxTabWidth; |
| 855 const NSInteger numberOfOpenNonMiniTabs = [self numberOfOpenNonMiniTabs]; | 854 const NSInteger numberOfOpenNonMiniTabs = [self numberOfOpenNonMiniTabs]; |
| 856 if (numberOfOpenNonMiniTabs) { | 855 if (numberOfOpenNonMiniTabs) { |
| 857 // Find the width of a non-mini-tab. This only applies to horizontal | 856 // Find the width of a non-mini-tab. This only applies to horizontal |
| 858 // mode. Add in the amount we "get back" from the tabs overlapping. | 857 // mode. Add in the amount we "get back" from the tabs overlapping. |
| 859 availableSpaceForNonMini += (numberOfOpenNonMiniTabs - 1) * kTabOverlap; | 858 availableSpaceForNonMini += (numberOfOpenNonMiniTabs - 1) * kTabOverlap; |
| 860 | 859 |
| 861 // Divide up the space between the non-mini-tabs. | 860 // Divide up the space between the non-mini-tabs. |
| 862 nonMiniTabWidth = | 861 nonMiniTabWidth = availableSpaceForNonMini / numberOfOpenNonMiniTabs; |
| 863 std::floor(availableSpaceForNonMini / numberOfOpenNonMiniTabs); | |
| 864 | 862 |
| 865 // Clamp the width between the max and min. | 863 // Clamp the width between the max and min. |
| 866 nonMiniTabWidth = MAX(MIN(nonMiniTabWidth, kMaxTabWidth), kMinTabWidth); | 864 nonMiniTabWidth = MAX(MIN(nonMiniTabWidth, kMaxTabWidth), kMinTabWidth); |
| 867 } | 865 } |
| 868 | 866 |
| 869 BOOL visible = [[tabStripView_ window] isVisible]; | 867 BOOL visible = [[tabStripView_ window] isVisible]; |
| 870 | 868 |
| 871 CGFloat offset = [self leftIndentForControls]; | 869 CGFloat offset = [self leftIndentForControls]; |
| 872 bool hasPlaceholderGap = false; | 870 bool hasPlaceholderGap = false; |
| 873 // Whether or not the last tab processed by the loop was a mini tab. | 871 // Whether or not the last tab processed by the loop was a mini tab. |
| (...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 NSInteger index = [self indexFromModelIndex:modelIndex]; | 2017 NSInteger index = [self indexFromModelIndex:modelIndex]; |
| 2020 BrowserWindowController* controller = | 2018 BrowserWindowController* controller = |
| 2021 (BrowserWindowController*)[[switchView_ window] windowController]; | 2019 (BrowserWindowController*)[[switchView_ window] windowController]; |
| 2022 DCHECK(index >= 0); | 2020 DCHECK(index >= 0); |
| 2023 if (index >= 0) { | 2021 if (index >= 0) { |
| 2024 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; | 2022 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; |
| 2025 } | 2023 } |
| 2026 } | 2024 } |
| 2027 | 2025 |
| 2028 @end | 2026 @end |
| OLD | NEW |