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_controller.h" |
| 6 |
| 7 #include <cmath> |
| 8 |
5 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
6 #import "chrome/browser/themes/theme_service.h" | 10 #import "chrome/browser/themes/theme_service.h" |
7 #import "chrome/browser/ui/cocoa/menu_controller.h" | 11 #import "chrome/browser/ui/cocoa/menu_controller.h" |
8 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" | |
9 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" | 12 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" |
10 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 13 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
11 #import "chrome/browser/ui/cocoa/themed_window.h" | 14 #import "chrome/browser/ui/cocoa/themed_window.h" |
12 #import "chrome/common/extensions/extension.h" | 15 #import "chrome/common/extensions/extension.h" |
13 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
14 #import "third_party/GTM/AppKit/GTMFadeTruncatingTextFieldCell.h" | 17 #import "third_party/GTM/AppKit/GTMFadeTruncatingTextFieldCell.h" |
15 #include "ui/base/l10n/l10n_util_mac.h" | 18 #include "ui/base/l10n/l10n_util_mac.h" |
16 | 19 |
17 @implementation TabController | 20 @implementation TabController |
18 | 21 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 [iconView_ removeFromSuperview]; | 189 [iconView_ removeFromSuperview]; |
187 iconView_ = iconView; | 190 iconView_ = iconView; |
188 if ([self app] || [self mini]) { | 191 if ([self app] || [self mini]) { |
189 NSRect appIconFrame = [iconView frame]; | 192 NSRect appIconFrame = [iconView frame]; |
190 appIconFrame.origin = originalIconFrame_.origin; | 193 appIconFrame.origin = originalIconFrame_.origin; |
191 | 194 |
192 const CGFloat tabWidth = [self app] ? [TabController appTabWidth] | 195 const CGFloat tabWidth = [self app] ? [TabController appTabWidth] |
193 : [TabController miniTabWidth]; | 196 : [TabController miniTabWidth]; |
194 | 197 |
195 // Center the icon. | 198 // Center the icon. |
196 appIconFrame.origin.x = (tabWidth - NSWidth(appIconFrame)) / 2.0; | 199 appIconFrame.origin.x = |
| 200 std::floor((tabWidth - NSWidth(appIconFrame)) / 2.0); |
197 [iconView_ setFrame:appIconFrame]; | 201 [iconView_ setFrame:appIconFrame]; |
198 } else { | 202 } else { |
199 [iconView_ setFrame:originalIconFrame_]; | 203 [iconView_ setFrame:originalIconFrame_]; |
200 } | 204 } |
201 // Ensure that the icon is suppressed if no icon is set or if the tab is too | 205 // Ensure that the icon is suppressed if no icon is set or if the tab is too |
202 // narrow to display one. | 206 // narrow to display one. |
203 [self updateVisibility]; | 207 [self updateVisibility]; |
204 | 208 |
205 if (iconView_) | 209 if (iconView_) |
206 [[self view] addSubview:iconView_]; | 210 [[self view] addSubview:iconView_]; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 // TabStripDragController. | 330 // TabStripDragController. |
327 - (BOOL)tabCanBeDragged:(TabController*)controller { | 331 - (BOOL)tabCanBeDragged:(TabController*)controller { |
328 return [[target_ dragController] tabCanBeDragged:controller]; | 332 return [[target_ dragController] tabCanBeDragged:controller]; |
329 } | 333 } |
330 | 334 |
331 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab { | 335 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab { |
332 [[target_ dragController] maybeStartDrag:event forTab:tab]; | 336 [[target_ dragController] maybeStartDrag:event forTab:tab]; |
333 } | 337 } |
334 | 338 |
335 @end | 339 @end |
OLD | NEW |