diff options
Diffstat (limited to 'chromium/ui/views/style')
-rw-r--r-- | chromium/ui/views/style/platform_style.cc | 9 | ||||
-rw-r--r-- | chromium/ui/views/style/platform_style.h | 9 | ||||
-rw-r--r-- | chromium/ui/views/style/platform_style_mac.mm | 9 | ||||
-rw-r--r-- | chromium/ui/views/style/typography.h | 3 | ||||
-rw-r--r-- | chromium/ui/views/style/typography_provider.cc | 29 | ||||
-rw-r--r-- | chromium/ui/views/style/typography_provider.h | 13 |
6 files changed, 49 insertions, 23 deletions
diff --git a/chromium/ui/views/style/platform_style.cc b/chromium/ui/views/style/platform_style.cc index 0b7ed2f41b5..3f7970d6bf1 100644 --- a/chromium/ui/views/style/platform_style.cc +++ b/chromium/ui/views/style/platform_style.cc @@ -41,15 +41,16 @@ const bool PlatformStyle::kDefaultLabelButtonHasBoldFont = true; const bool PlatformStyle::kDialogDefaultButtonCanBeCancel = true; const bool PlatformStyle::kSelectWordOnRightClick = false; const bool PlatformStyle::kSelectAllOnRightClickWhenUnfocused = false; -const CustomButton::NotifyAction PlatformStyle::kMenuNotifyActivationAction = - CustomButton::NOTIFY_ON_RELEASE; -const CustomButton::KeyClickAction PlatformStyle::kKeyClickActionOnSpace = - CustomButton::CLICK_ON_KEY_RELEASE; +const Button::NotifyAction PlatformStyle::kMenuNotifyActivationAction = + Button::NOTIFY_ON_RELEASE; +const Button::KeyClickAction PlatformStyle::kKeyClickActionOnSpace = + Button::CLICK_ON_KEY_RELEASE; const bool PlatformStyle::kReturnClicksFocusedControl = true; const bool PlatformStyle::kTreeViewSelectionPaintsEntireRow = false; const bool PlatformStyle::kTreeViewUsesOpenIcon = true; const bool PlatformStyle::kUseRipples = true; const bool PlatformStyle::kMirrorBubbleArrowInRTLByDefault = true; +const bool PlatformStyle::kTextfieldScrollsToStartOnFocusChange = false; // static std::unique_ptr<ScrollBar> PlatformStyle::CreateScrollBar(bool is_horizontal) { diff --git a/chromium/ui/views/style/platform_style.h b/chromium/ui/views/style/platform_style.h index ce396891725..025c6743782 100644 --- a/chromium/ui/views/style/platform_style.h +++ b/chromium/ui/views/style/platform_style.h @@ -9,7 +9,6 @@ #include "base/macros.h" #include "ui/views/controls/button/button.h" -#include "ui/views/controls/button/custom_button.h" #include "ui/views/views_export.h" namespace views { @@ -42,10 +41,10 @@ class VIEWS_EXPORT PlatformStyle { static const bool kSelectAllOnRightClickWhenUnfocused; // The menu button's action to show the menu. - static const CustomButton::NotifyAction kMenuNotifyActivationAction; + static const Button::NotifyAction kMenuNotifyActivationAction; // Whether the Space key clicks a button on key press or key release. - static const CustomButton::KeyClickAction kKeyClickActionOnSpace; + static const Button::KeyClickAction kKeyClickActionOnSpace; // Whether the Return key clicks the focused control (on key press). // Otherwise, Return does nothing unless it is handled by an accelerator. @@ -66,6 +65,10 @@ class VIEWS_EXPORT PlatformStyle { // opens in the opposite direction. static const bool kMirrorBubbleArrowInRTLByDefault; + // Whether to scroll text fields to the beginning when they gain or lose + // focus. + static const bool kTextfieldScrollsToStartOnFocusChange; + // Creates the default scrollbar for the given orientation. static std::unique_ptr<ScrollBar> CreateScrollBar(bool is_horizontal); diff --git a/chromium/ui/views/style/platform_style_mac.mm b/chromium/ui/views/style/platform_style_mac.mm index e18282bc17f..ab628d6b2c1 100644 --- a/chromium/ui/views/style/platform_style_mac.mm +++ b/chromium/ui/views/style/platform_style_mac.mm @@ -20,6 +20,7 @@ const bool PlatformStyle::kDefaultLabelButtonHasBoldFont = false; const bool PlatformStyle::kDialogDefaultButtonCanBeCancel = false; const bool PlatformStyle::kSelectWordOnRightClick = true; const bool PlatformStyle::kSelectAllOnRightClickWhenUnfocused = true; +const bool PlatformStyle::kTextfieldScrollsToStartOnFocusChange = true; const bool PlatformStyle::kTreeViewSelectionPaintsEntireRow = true; const bool PlatformStyle::kTreeViewUsesOpenIcon = false; const bool PlatformStyle::kUseRipples = false; @@ -30,11 +31,11 @@ const bool PlatformStyle::kUseRipples = false; const bool PlatformStyle::kMirrorBubbleArrowInRTLByDefault = BUILDFLAG(MAC_VIEWS_BROWSER); -const CustomButton::NotifyAction PlatformStyle::kMenuNotifyActivationAction = - CustomButton::NOTIFY_ON_PRESS; +const Button::NotifyAction PlatformStyle::kMenuNotifyActivationAction = + Button::NOTIFY_ON_PRESS; -const CustomButton::KeyClickAction PlatformStyle::kKeyClickActionOnSpace = - CustomButton::CLICK_ON_KEY_PRESS; +const Button::KeyClickAction PlatformStyle::kKeyClickActionOnSpace = + Button::CLICK_ON_KEY_PRESS; // On Mac, the Return key is used to perform the default action even when a // control is focused. diff --git a/chromium/ui/views/style/typography.h b/chromium/ui/views/style/typography.h index 29295a41583..36ee1230bfa 100644 --- a/chromium/ui/views/style/typography.h +++ b/chromium/ui/views/style/typography.h @@ -41,6 +41,9 @@ enum TextContext { // Text to label a control, usually next to it. "Body 2". Usually 12pt. CONTEXT_LABEL, + // Text in a table row. + CONTEXT_TABLE_ROW, + // An editable text field. Usually matches CONTROL_LABEL. CONTEXT_TEXTFIELD, diff --git a/chromium/ui/views/style/typography_provider.cc b/chromium/ui/views/style/typography_provider.cc index f8f7f3774c4..4fd2cd72b08 100644 --- a/chromium/ui/views/style/typography_provider.cc +++ b/chromium/ui/views/style/typography_provider.cc @@ -5,11 +5,16 @@ #include "ui/views/style/typography_provider.h" #include "base/logging.h" +#include "build/build_config.h" #include "ui/base/default_style.h" #include "ui/base/resource/resource_bundle.h" #include "ui/native_theme/native_theme.h" #include "ui/views/style/typography.h" +#if defined(OS_MACOSX) +#include "base/mac/mac_util.h" +#endif + using gfx::Font; namespace views { @@ -30,13 +35,27 @@ Font::Weight GetValueBolderThan(Font::Weight weight) { } // namespace // static -Font::Weight TypographyProvider::WeightNotLighterThanNormal( - Font::Weight weight) { +Font::Weight TypographyProvider::MediumWeightForUI() { +#if defined(OS_MACOSX) + // System fonts are not user-configurable on Mac, so there's a simpler check. + // However, 10.9 and 10.11 do not ship with a MEDIUM weight system font. In + // that case, trying to use MEDIUM there will give a bold font, which will + // look worse with the surrounding NORMAL text than just using NORMAL. + return (base::mac::IsOS10_9() || base::mac::IsOS10_11()) + ? Font::Weight::NORMAL + : Font::Weight::MEDIUM; +#else + // NORMAL may already have at least MEDIUM weight. Return NORMAL in that case + // since trying to return MEDIUM would actually make the font lighter-weight + // than the surrounding text. For example, Windows can be configured to use a + // BOLD font for dialog text; deriving MEDIUM from that would replace the BOLD + // attribute with something lighter. if (ResourceBundle::GetSharedInstance() .GetFontListWithDelta(0, Font::NORMAL, Font::Weight::NORMAL) - .GetFontWeight() < weight) - return weight; + .GetFontWeight() < Font::Weight::MEDIUM) + return Font::Weight::MEDIUM; return Font::Weight::NORMAL; +#endif } const gfx::FontList& DefaultTypographyProvider::GetFont(int context, @@ -90,7 +109,7 @@ void DefaultTypographyProvider::GetDefaultFont(int context, switch (context) { case style::CONTEXT_BUTTON_MD: *size_delta = ui::kLabelFontSizeDelta; - *font_weight = WeightNotLighterThanNormal(Font::Weight::MEDIUM); + *font_weight = MediumWeightForUI(); break; case style::CONTEXT_DIALOG_TITLE: *size_delta = ui::kTitleFontSizeDelta; diff --git a/chromium/ui/views/style/typography_provider.h b/chromium/ui/views/style/typography_provider.h index 978df456f44..ac67e9890bc 100644 --- a/chromium/ui/views/style/typography_provider.h +++ b/chromium/ui/views/style/typography_provider.h @@ -37,13 +37,12 @@ class VIEWS_EXPORT TypographyProvider { // Gets the line spacing, or 0 if it should be provided by gfx::FontList. virtual int GetLineHeight(int context, int style) const = 0; - // The system may indicate a "bold" UI font is preferred (e.g. by selecting - // the "Bold" checkbox in Windows under "Change only the text size" in - // Control Panel). In this case, a user's gfx::Weight::NORMAL font will - // already be bold, and requesting a MEDIUM font will result in a font that is - // less bold. So this method returns NORMAL, if the NORMAL font is at least as - // bold as |weight|. - static gfx::Font::Weight WeightNotLighterThanNormal(gfx::Font::Weight weight); + // Returns the weight that will result in the ResourceBundle returning an + // appropriate "medium" weight for UI. This caters for systems that are known + // to be unable to provide a system font with weight other than NORMAL or BOLD + // and for user configurations where the NORMAL font is already BOLD. In both + // of these cases, NORMAL is returned instead. + static gfx::Font::Weight MediumWeightForUI(); protected: TypographyProvider() = default; |