| 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_view.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 11 #include "chrome/browser/themes/theme_properties.h" | 12 #include "chrome/browser/themes/theme_properties.h" |
| 12 #include "chrome/browser/themes/theme_service.h" | 13 #include "chrome/browser/themes/theme_service.h" |
| 13 #include "chrome/browser/ui/cocoa/l10n_util.h" | 14 #include "chrome/browser/ui/cocoa/l10n_util.h" |
| 14 #import "chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h" | 15 #import "chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h" |
| 15 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" | 16 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" | 17 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" |
| 17 #import "chrome/browser/ui/cocoa/themed_window.h" | 18 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 18 #import "chrome/browser/ui/cocoa/view_id_util.h" | 19 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 20 #include "chrome/common/chrome_features.h" |
| 19 #include "chrome/grit/theme_resources.h" | 21 #include "chrome/grit/theme_resources.h" |
| 20 #include "skia/ext/skia_utils_mac.h" | 22 #include "skia/ext/skia_utils_mac.h" |
| 21 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMFadeTruncatingTextFiel
dCell.h" | 23 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMFadeTruncatingTextFiel
dCell.h" |
| 22 #import "ui/base/cocoa/nsgraphics_context_additions.h" | 24 #import "ui/base/cocoa/nsgraphics_context_additions.h" |
| 23 #import "ui/base/cocoa/nsview_additions.h" | 25 #import "ui/base/cocoa/nsview_additions.h" |
| 24 #include "ui/base/cocoa/three_part_image.h" | 26 #include "ui/base/cocoa/three_part_image.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "ui/base/material_design/material_design_controller.h" | 28 #include "ui/base/material_design/material_design_controller.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 30 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 29 #include "ui/strings/grit/ui_strings.h" | 31 #include "ui/strings/grit/ui_strings.h" |
| 30 | 32 |
| 31 namespace { | 33 namespace { |
| 32 | 34 |
| 33 // The color of the icons in dark mode theme. | 35 // The color of the icons in dark mode theme. |
| 34 const SkColor kDarkModeIconColor = SkColorSetARGB(0xFF, 0xC4, 0xC4, 0xC4); | 36 const SkColor kDarkModeIconColor = SkColorSetARGB(0xFF, 0xC4, 0xC4, 0xC4); |
| 35 | 37 |
| 38 bool IsTabStripKeyboardFocusEnabled() { |
| 39 return base::FeatureList::IsEnabled(features::kTabStripKeyboardFocus); |
| 40 } |
| 41 |
| 36 } // namespace | 42 } // namespace |
| 37 | 43 |
| 38 // The amount of time in seconds during which each type of glow increases, holds | 44 // The amount of time in seconds during which each type of glow increases, holds |
| 39 // steady, and decreases, respectively. | 45 // steady, and decreases, respectively. |
| 40 const NSTimeInterval kHoverShowDuration = 0.2; | 46 const NSTimeInterval kHoverShowDuration = 0.2; |
| 41 const NSTimeInterval kHoverHoldDuration = 0.02; | 47 const NSTimeInterval kHoverHoldDuration = 0.02; |
| 42 const NSTimeInterval kHoverHideDuration = 0.4; | 48 const NSTimeInterval kHoverHideDuration = 0.4; |
| 43 const NSTimeInterval kAlertShowDuration = 0.4; | 49 const NSTimeInterval kAlertShowDuration = 0.4; |
| 44 const NSTimeInterval kAlertHoldDuration = 0.4; | 50 const NSTimeInterval kAlertHoldDuration = 0.4; |
| 45 const NSTimeInterval kAlertHideDuration = 0.4; | 51 const NSTimeInterval kAlertHideDuration = 0.4; |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 // ThemedWindowDrawing implementation. | 788 // ThemedWindowDrawing implementation. |
| 783 | 789 |
| 784 - (void)windowDidChangeTheme { | 790 - (void)windowDidChangeTheme { |
| 785 [self setNeedsDisplay:YES]; | 791 [self setNeedsDisplay:YES]; |
| 786 } | 792 } |
| 787 | 793 |
| 788 - (void)windowDidChangeActive { | 794 - (void)windowDidChangeActive { |
| 789 [self setNeedsDisplay:YES]; | 795 [self setNeedsDisplay:YES]; |
| 790 } | 796 } |
| 791 | 797 |
| 798 - (BOOL)acceptsFirstResponder { |
| 799 return IsTabStripKeyboardFocusEnabled() ? YES : NO; |
| 800 } |
| 801 |
| 802 - (BOOL)becomeFirstResponder { |
| 803 return IsTabStripKeyboardFocusEnabled() ? YES : NO; |
| 804 } |
| 805 |
| 806 - (void)drawFocusRingMask { |
| 807 if (!IsTabStripKeyboardFocusEnabled()) |
| 808 return; |
| 809 if ([titleView_ isHidden]) |
| 810 NSRectFill([self bounds]); |
| 811 else |
| 812 NSRectFill([titleView_ frame]); |
| 813 } |
| 814 |
| 815 - (NSRect)focusRingMaskBounds { |
| 816 return [self bounds]; |
| 817 } |
| 818 |
| 792 @end // @implementation TabView | 819 @end // @implementation TabView |
| 793 | 820 |
| 794 @implementation TabView (TabControllerInterface) | 821 @implementation TabView (TabControllerInterface) |
| 795 | 822 |
| 796 - (void)setController:(TabController*)controller { | 823 - (void)setController:(TabController*)controller { |
| 797 controller_ = controller; | 824 controller_ = controller; |
| 798 } | 825 } |
| 799 | 826 |
| 800 @end // @implementation TabView (TabControllerInterface) | 827 @end // @implementation TabView (TabControllerInterface) |
| 801 | 828 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 | 1052 |
| 1026 // For "Increase Contrast" mode, use flat black instead of semitransparent black | 1053 // For "Increase Contrast" mode, use flat black instead of semitransparent black |
| 1027 // for the tab edge stroke. | 1054 // for the tab edge stroke. |
| 1028 + (void)setTabEdgeStrokeColor { | 1055 + (void)setTabEdgeStrokeColor { |
| 1029 static NSColor* heavyStrokeColor = | 1056 static NSColor* heavyStrokeColor = |
| 1030 [skia::SkColorToSRGBNSColor(SK_ColorBLACK) retain]; | 1057 [skia::SkColorToSRGBNSColor(SK_ColorBLACK) retain]; |
| 1031 [heavyStrokeColor set]; | 1058 [heavyStrokeColor set]; |
| 1032 } | 1059 } |
| 1033 | 1060 |
| 1034 @end | 1061 @end |
| OLD | NEW |