From 3d914bde3081131a655b467c1a7a232c7c065007 Mon Sep 17 00:00:00 2001 From: bokan Date: Wed, 19 Oct 2016 08:07:58 -0700 Subject: [PATCH] Change Aura overlay scrollbars from solid color to painted scrollbars. With this change, the Aura overlay scrollbars are now painted by the native theme. If the scroller is composited, these scrollbars will now be uploaded to the compositor as PaintedScrollbarLayers rather than SolidColorScrollbarLayers. Additionally, many of the MD scrollbar constants and properties are scattered around the code. This patch moves them into a single location in ui/native_theme. I've also updated the values to match the latest spec. Follow-up patches will make use of these values from the compositor. BUG=592098, 652520 CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel Review-Url: https://chromiumcodereview.appspot.com/2421913002 Cr-Commit-Position: refs/heads/master@{#426191} --- .../compositor/blimp_layer_tree_settings.cc | 13 +-- cc/layers/scrollbar_layer_unittest.cc | 6 +- cc/trees/layer_tree_host_impl_unittest.cc | 16 ++-- cc/trees/layer_tree_impl.cc | 13 +-- cc/trees/layer_tree_settings.cc | 7 +- cc/trees/layer_tree_settings.h | 8 +- .../renderer_host/render_view_host_impl.cc | 4 +- .../renderer/gpu/render_widget_compositor.cc | 25 +++-- .../platform/scroll/ScrollbarThemeAura.cpp | 12 ++- ui/native_theme/BUILD.gn | 1 + ui/native_theme/native_theme_aura.cc | 92 +++++++++++++------ ui/native_theme/native_theme_aura.h | 3 + ui/native_theme/native_theme_base.cc | 4 +- ui/native_theme/native_theme_base.h | 8 +- .../overlay_scrollbar_constants_aura.h | 27 ++++++ 15 files changed, 164 insertions(+), 75 deletions(-) create mode 100644 ui/native_theme/overlay_scrollbar_constants_aura.h diff --git a/blimp/client/support/compositor/blimp_layer_tree_settings.cc b/blimp/client/support/compositor/blimp_layer_tree_settings.cc index 8c44b6e852d090..9f31e72d7c6271 100644 --- a/blimp/client/support/compositor/blimp_layer_tree_settings.cc +++ b/blimp/client/support/compositor/blimp_layer_tree_settings.cc @@ -61,9 +61,9 @@ void PopulateCommonLayerTreeSettings(cc::LayerTreeSettings* settings) { settings->gpu_rasterization_enabled = false; settings->using_synchronous_renderer_compositor = false; settings->scrollbar_animator = cc::LayerTreeSettings::LINEAR_FADE; - settings->scrollbar_fade_delay_ms = 300; - settings->scrollbar_fade_resize_delay_ms = 2000; - settings->scrollbar_fade_duration_ms = 300; + settings->scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(300); + settings->scrollbar_fade_resize_delay = base::TimeDelta::FromSeconds(2); + settings->scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); settings->solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); settings->renderer_settings.highp_threshold_min = 2048; settings->ignore_root_layer_flings = false; @@ -89,9 +89,10 @@ void PopulateCommonLayerTreeSettings(cc::LayerTreeSettings* settings) { #elif !defined(OS_MACOSX) settings->scrollbar_animator = cc::LayerTreeSettings::LINEAR_FADE; settings->solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); - settings->scrollbar_fade_delay_ms = 500; - settings->scrollbar_fade_resize_delay_ms = 500; - settings->scrollbar_fade_duration_ms = 300; + settings->scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); + settings->scrollbar_fade_resize_delay = + base::TimeDelta::FromMilliseconds(500); + settings->scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); // When pinching in, only show the pinch-viewport overlay scrollbars if the // page scale is at least some threshold away from the minimum. i.e. don't diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc index 021efb54c20518..b05fed80074596 100644 --- a/cc/layers/scrollbar_layer_unittest.cc +++ b/cc/layers/scrollbar_layer_unittest.cc @@ -103,8 +103,10 @@ class ScrollbarLayerTest : public testing::Test { layer_tree_settings_.single_thread_proxy_scheduler = false; layer_tree_settings_.use_zero_copy = true; layer_tree_settings_.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; - layer_tree_settings_.scrollbar_fade_delay_ms = 20; - layer_tree_settings_.scrollbar_fade_duration_ms = 20; + layer_tree_settings_.scrollbar_fade_delay = + base::TimeDelta::FromMilliseconds(20); + layer_tree_settings_.scrollbar_fade_duration = + base::TimeDelta::FromMilliseconds(20); layer_tree_settings_.verify_transform_tree_calculations = true; layer_tree_settings_.verify_clip_tree_calculations = true; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index de7eb4f281d773..b763e6ccf281a8 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -2730,8 +2730,8 @@ class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { LayerTreeSettings settings = DefaultSettings(); settings.scrollbar_animator = animator; - settings.scrollbar_fade_delay_ms = 20; - settings.scrollbar_fade_duration_ms = 20; + settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(20); + settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(20); // If no animator is set, scrollbar won't show and no animation is expected. bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; @@ -2923,8 +2923,8 @@ class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest { void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { LayerTreeSettings settings = DefaultSettings(); settings.scrollbar_animator = animator; - settings.scrollbar_fade_delay_ms = 20; - settings.scrollbar_fade_duration_ms = 20; + settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(20); + settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(20); gfx::Size content_size(100, 100); // If no animator is set, scrollbar won't show and no animation is expected. @@ -3054,8 +3054,8 @@ TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) { TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { LayerTreeSettings settings = DefaultSettings(); settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; - settings.scrollbar_fade_delay_ms = 20; - settings.scrollbar_fade_duration_ms = 20; + settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(20); + settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(20); CreateHostImpl(settings, CreateCompositorFrameSink()); gfx::Size viewport_size(300, 200); @@ -3174,8 +3174,8 @@ TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( float device_scale_factor) { LayerTreeSettings settings = DefaultSettings(); - settings.scrollbar_fade_delay_ms = 500; - settings.scrollbar_fade_duration_ms = 300; + settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); + settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); settings.scrollbar_animator = LayerTreeSettings::THINNING; gfx::Size viewport_size(300, 200); diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 9ae1138aa87c3e..1f102231c09c45 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -1359,14 +1359,11 @@ const gfx::Rect LayerTreeImpl::ViewportRectForTilePriority() const { std::unique_ptr LayerTreeImpl::CreateScrollbarAnimationController(int scroll_layer_id) { - DCHECK(settings().scrollbar_fade_delay_ms); - DCHECK(settings().scrollbar_fade_duration_ms); - base::TimeDelta delay = - base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_delay_ms); - base::TimeDelta resize_delay = base::TimeDelta::FromMilliseconds( - settings().scrollbar_fade_resize_delay_ms); - base::TimeDelta duration = - base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_duration_ms); + DCHECK(!settings().scrollbar_fade_delay.is_zero()); + DCHECK(!settings().scrollbar_fade_duration.is_zero()); + base::TimeDelta delay = settings().scrollbar_fade_delay; + base::TimeDelta resize_delay = settings().scrollbar_fade_resize_delay; + base::TimeDelta duration = settings().scrollbar_fade_duration; switch (settings().scrollbar_animator) { case LayerTreeSettings::LINEAR_FADE: { return ScrollbarAnimationControllerLinearFade::Create( diff --git a/cc/trees/layer_tree_settings.cc b/cc/trees/layer_tree_settings.cc index 7a2d0a93f38ba1..232a52274468b5 100644 --- a/cc/trees/layer_tree_settings.cc +++ b/cc/trees/layer_tree_settings.cc @@ -40,10 +40,9 @@ bool LayerTreeSettings::operator==(const LayerTreeSettings& other) const { other.gpu_rasterization_msaa_sample_count && create_low_res_tiling == other.create_low_res_tiling && scrollbar_animator == other.scrollbar_animator && - scrollbar_fade_delay_ms == other.scrollbar_fade_delay_ms && - scrollbar_fade_resize_delay_ms == - other.scrollbar_fade_resize_delay_ms && - scrollbar_fade_duration_ms == other.scrollbar_fade_duration_ms && + scrollbar_fade_delay == other.scrollbar_fade_delay && + scrollbar_fade_resize_delay == other.scrollbar_fade_resize_delay && + scrollbar_fade_duration == other.scrollbar_fade_duration && solid_color_scrollbar_color == other.solid_color_scrollbar_color && timeout_and_draw_when_animation_checkerboards == other.timeout_and_draw_when_animation_checkerboards && diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h index 22275d88e4ed32..7148e92e0dc674 100644 --- a/cc/trees/layer_tree_settings.h +++ b/cc/trees/layer_tree_settings.h @@ -9,6 +9,7 @@ #include +#include "base/time/time.h" #include "cc/base/cc_export.h" #include "cc/debug/layer_tree_debug_state.h" #include "cc/output/managed_memory_policy.h" @@ -56,9 +57,10 @@ class CC_EXPORT LayerTreeSettings { THINNING, }; ScrollbarAnimator scrollbar_animator = NO_ANIMATOR; - int scrollbar_fade_delay_ms = 0; - int scrollbar_fade_resize_delay_ms = 0; - int scrollbar_fade_duration_ms = 0; + base::TimeDelta scrollbar_fade_delay; + base::TimeDelta scrollbar_fade_resize_delay; + base::TimeDelta scrollbar_fade_duration; + base::TimeDelta scrollbar_thinning_duration; SkColor solid_color_scrollbar_color = SK_ColorWHITE; bool timeout_and_draw_when_animation_checkerboards = true; bool layer_transforms_should_scale_layer_contents = false; diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 39eb7da5740754..0afaa9b99014b5 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -464,7 +464,7 @@ WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() { prefs.inert_visual_viewport = command_line.HasSwitch(switches::kInertVisualViewport); - prefs.use_solid_color_scrollbars = ui::IsOverlayScrollbarEnabled(); + prefs.use_solid_color_scrollbars = false; prefs.history_entry_requires_user_gesture = command_line.HasSwitch(switches::kHistoryEntryRequiresUserGesture); @@ -482,6 +482,8 @@ WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() { base::FeatureList::IsEnabled(features::kAutoplayMutedVideos); prefs.progress_bar_completion = GetProgressBarCompletionPolicy(); + + prefs.use_solid_color_scrollbars = true; #endif // Handle autoplay gesture override experiment. diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index 8e47d6f2f7ba52..0d883c52c7a42d 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc @@ -60,6 +60,7 @@ #include "third_party/WebKit/public/web/WebSelection.h" #include "ui/gl/gl_switches.h" #include "ui/native_theme/native_theme_switches.h" +#include "ui/native_theme/overlay_scrollbar_constants_aura.h" #if defined(OS_ANDROID) #include "base/android/build_info.h" @@ -383,9 +384,10 @@ cc::LayerTreeSettings RenderWidgetCompositor::GenerateLayerTreeSettings( settings.gpu_rasterization_enabled = false; settings.using_synchronous_renderer_compositor = using_synchronous_compositor; settings.scrollbar_animator = cc::LayerTreeSettings::LINEAR_FADE; - settings.scrollbar_fade_delay_ms = 300; - settings.scrollbar_fade_resize_delay_ms = 2000; - settings.scrollbar_fade_duration_ms = 300; + settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(300); + settings.scrollbar_fade_resize_delay = + base::TimeDelta::FromMilliseconds(2000); + settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); settings.renderer_settings.highp_threshold_min = 2048; // Android WebView handles root layer flings itself. @@ -420,14 +422,23 @@ cc::LayerTreeSettings RenderWidgetCompositor::GenerateLayerTreeSettings( #if !defined(OS_MACOSX) if (ui::IsOverlayScrollbarEnabled()) { settings.scrollbar_animator = cc::LayerTreeSettings::THINNING; - settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); + settings.scrollbar_fade_delay = ui::kOverlayScrollbarFadeOutDelay; + settings.scrollbar_fade_resize_delay = + ui::kOverlayScrollbarFadeOutDelay; + settings.scrollbar_fade_duration = + ui::kOverlayScrollbarFadeOutDuration; + settings.scrollbar_thinning_duration = + ui::kOverlayScrollbarThinningDuration; } else { + // TODO(bokan): This section is probably unneeded? We don't use scrollbar + // animations for non overlay scrollbars. settings.scrollbar_animator = cc::LayerTreeSettings::LINEAR_FADE; settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); + settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); + settings.scrollbar_fade_resize_delay = + base::TimeDelta::FromMilliseconds(500); + settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); } - settings.scrollbar_fade_delay_ms = 500; - settings.scrollbar_fade_resize_delay_ms = 500; - settings.scrollbar_fade_duration_ms = 300; #endif // !defined(OS_MACOSX) // On desktop, if there's over 4GB of memory on the machine, increase the diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp index 655c9203cf97f5..6d213bed316a25 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp @@ -126,12 +126,20 @@ PartPaintingParams buttonPartPaintingParams( return PartPaintingParams(paintPart, state); } +static int getScrollbarThickness() { + return Platform::current() + ->themeEngine() + ->getSize(WebThemeEngine::PartScrollbarVerticalThumb) + .width; +} + } // namespace ScrollbarTheme& ScrollbarTheme::nativeTheme() { if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) { - DEFINE_STATIC_LOCAL(ScrollbarThemeOverlay, theme, - (10, 0, ScrollbarThemeOverlay::AllowHitTest)); + DEFINE_STATIC_LOCAL( + ScrollbarThemeOverlay, theme, + (getScrollbarThickness(), 0, ScrollbarThemeOverlay::AllowHitTest)); return theme; } diff --git a/ui/native_theme/BUILD.gn b/ui/native_theme/BUILD.gn index a64cb968c028e8..fb2296879bfef0 100644 --- a/ui/native_theme/BUILD.gn +++ b/ui/native_theme/BUILD.gn @@ -29,6 +29,7 @@ component("native_theme") { "native_theme_aura.h", "native_theme_dark_aura.cc", "native_theme_dark_aura.h", + "overlay_scrollbar_constants_aura.h", ] } diff --git a/ui/native_theme/native_theme_aura.cc b/ui/native_theme/native_theme_aura.cc index 6587ec1060157f..d03a0d3211edc0 100644 --- a/ui/native_theme/native_theme_aura.cc +++ b/ui/native_theme/native_theme_aura.cc @@ -8,6 +8,7 @@ #include #include "base/logging.h" +#include "base/trace_event/trace_event.h" #include "build/build_config.h" #include "ui/base/layout.h" #include "ui/base/material_design/material_design_controller.h" @@ -21,40 +22,33 @@ #include "ui/gfx/skia_util.h" #include "ui/native_theme/common_theme.h" #include "ui/native_theme/native_theme_switches.h" +#include "ui/native_theme/overlay_scrollbar_constants_aura.h" namespace ui { namespace { +// Constants for painting overlay scrollbars. Other properties needed outside +// this painting code are defined in overlay_scrollbar_constants_aura.h. +constexpr int kOverlayScrollbarStrokeWidth = 1; +constexpr int kOverlayScrollbarMinimumLength = 12; +constexpr SkAlpha kOverlayScrollbarAlphaNormal = 0x4D; +constexpr SkAlpha kOverlayScrollbarAlphaHovered = 0x80; +constexpr SkAlpha kOverlayScrollbarAlphaPressed = 0x80; +constexpr SkColor kOverlayScrollbarThumbColor = SK_ColorBLACK; +constexpr SkColor kOverlayScrollbarStrokeColor = SK_ColorWHITE; + SkAlpha ThumbAlphaForState(NativeTheme::State state) { bool overlay = IsOverlayScrollbarEnabled(); switch (state) { case NativeTheme::kDisabled: return 0x00; case NativeTheme::kHovered: - return overlay ? 0xB2 : 0x4D; + return overlay ? kOverlayScrollbarAlphaHovered : 0x4D; case NativeTheme::kNormal: - return overlay ? 0x8C : 0x33; + return overlay ? kOverlayScrollbarAlphaNormal : 0x33; case NativeTheme::kPressed: - return overlay ? 0xB2 : 0x80; - case NativeTheme::kNumStates: - break; - } - - NOTREACHED(); - return 0xFF; -} - -SkAlpha ThumbStrokeAlphaForState(NativeTheme::State state) { - DCHECK(IsOverlayScrollbarEnabled()); - switch (state) { - case NativeTheme::kDisabled: - return 0x00; - case NativeTheme::kHovered: - case NativeTheme::kPressed: - return 0x33; - case NativeTheme::kNormal: - return 0x26; + return overlay ? kOverlayScrollbarAlphaPressed : 0x80; case NativeTheme::kNumStates: break; } @@ -84,6 +78,11 @@ NativeThemeAura::NativeThemeAura() { set_scrollbar_button_length(0); #endif + if (IsOverlayScrollbarEnabled()) { + scrollbar_width_ = + kOverlayScrollbarThumbWidthPressed + kOverlayScrollbarStrokeWidth * 2; + } + // Images and alphas declarations assume the following order. static_assert(kDisabled == 0, "states unexpectedly changed"); static_assert(kHovered == 1, "states unexpectedly changed"); @@ -196,20 +195,28 @@ void NativeThemeAura::PaintScrollbarThumbStateTransition( State end_state, double progress, const gfx::Rect& rect) const { + TRACE_EVENT0("blink", "NativeThemeAura::PaintScrollbarThumbStateTransition"); gfx::Rect thumb_rect(rect); + SkColor thumb_color; if (IsOverlayScrollbarEnabled()) { // In overlay mode, draw a stroke (border). - const int kStrokeWidth = 1; + constexpr int kStrokeWidth = kOverlayScrollbarStrokeWidth; SkAlpha stroke_alpha = gfx::Tween::IntValueBetween( - progress, ThumbStrokeAlphaForState(start_state), - ThumbStrokeAlphaForState(end_state)); + progress, ThumbAlphaForState(start_state), + ThumbAlphaForState(end_state)); SkPaint paint; - paint.setColor(SkColorSetA(SK_ColorWHITE, stroke_alpha)); + paint.setColor(SkColorSetA(kOverlayScrollbarStrokeColor, stroke_alpha)); paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(kStrokeWidth); - canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), paint); - thumb_rect.Inset(kStrokeWidth, kStrokeWidth, kStrokeWidth, kStrokeWidth); + gfx::RectF stroke_rect(thumb_rect); + constexpr float kHalfStrokeWidth = kStrokeWidth / 2.f; + stroke_rect.Inset(kHalfStrokeWidth, kHalfStrokeWidth); + canvas->drawRect(gfx::RectFToSkRect(stroke_rect), paint); + + // Inset the all the edges edges so we fill-in the stroke below. + thumb_rect.Inset(kStrokeWidth, kStrokeWidth); + thumb_color = kOverlayScrollbarThumbColor; } else { // If there are no scrollbuttons then provide some padding so that the thumb // doesn't touch the top of the track. @@ -220,12 +227,14 @@ void NativeThemeAura::PaintScrollbarThumbStateTransition( thumb_rect.Inset(kThumbPadding, extra_padding); else thumb_rect.Inset(extra_padding, kThumbPadding); + + thumb_color = SK_ColorBLACK; } SkPaint paint; SkAlpha alpha = gfx::Tween::IntValueBetween( progress, ThumbAlphaForState(start_state), ThumbAlphaForState(end_state)); - paint.setColor(SkColorSetA(SK_ColorBLACK, alpha)); + paint.setColor(SkColorSetA(thumb_color, alpha)); canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), paint); } @@ -239,4 +248,31 @@ void NativeThemeAura::PaintScrollbarCorner(SkCanvas* canvas, canvas->drawIRect(RectToSkIRect(rect), paint); } +gfx::Size NativeThemeAura::GetPartSize(Part part, + State state, + const ExtraParams& extra) const { + if (IsOverlayScrollbarEnabled()) { + constexpr int minimum_length = + kOverlayScrollbarMinimumLength + 2 * kOverlayScrollbarStrokeWidth; + + // Aura overlay scrollbars need a slight tweak from the base sizes. + switch (part) { + case kScrollbarHorizontalThumb: + return gfx::Size(minimum_length, scrollbar_width_); + case kScrollbarVerticalThumb: + return gfx::Size(scrollbar_width_, minimum_length); + default: + // TODO(bokan): We should probably make sure code using overlay + // scrollbars isn't asking for part sizes that don't exist. This + // currently breaks in Views layout code which indicates they aren't + // overlay aware yet. The Views code should be fixed and either this + // branch return 0 for parts that don't exist or assert NOTREACHED. + // crbug.com/657159. + break; + } + } + + return NativeThemeBase::GetPartSize(part, state, extra); +} + } // namespace ui diff --git a/ui/native_theme/native_theme_aura.h b/ui/native_theme/native_theme_aura.h index 85ce5bc708dbdf..596552fb16e4a8 100644 --- a/ui/native_theme/native_theme_aura.h +++ b/ui/native_theme/native_theme_aura.h @@ -53,6 +53,9 @@ class NATIVE_THEME_EXPORT NativeThemeAura : public NativeThemeBase { State endState, double progress, const gfx::Rect& rect) const override; + gfx::Size GetPartSize(Part part, + State state, + const ExtraParams& extra) const override; private: DISALLOW_COPY_AND_ASSIGN(NativeThemeAura); diff --git a/ui/native_theme/native_theme_base.cc b/ui/native_theme/native_theme_base.cc index 54881fe6775430..331ceb46be0a5b 100644 --- a/ui/native_theme/native_theme_base.cc +++ b/ui/native_theme/native_theme_base.cc @@ -51,8 +51,8 @@ const SkColor kProgressValueColor = gfx::kGoogleBlue300; const SkColor kMenuPopupBackgroundColor = SkColorSetRGB(210, 225, 246); -const unsigned int kDefaultScrollbarWidth = 15; -const unsigned int kDefaultScrollbarButtonLength = 14; +const int kDefaultScrollbarWidth = 15; +const int kDefaultScrollbarButtonLength = 14; const SkColor kCheckboxTinyColor = SK_ColorGRAY; const SkColor kCheckboxShadowColor = SkColorSetARGB(0x15, 0, 0, 0); diff --git a/ui/native_theme/native_theme_base.h b/ui/native_theme/native_theme_base.h index 3a8ddde23d1244..716f72e94261bb 100644 --- a/ui/native_theme/native_theme_base.h +++ b/ui/native_theme/native_theme_base.h @@ -151,7 +151,7 @@ class NATIVE_THEME_EXPORT NativeThemeBase : public NativeTheme { // crbug.com/530746 is resolved. virtual void AdjustCheckboxRadioRectForPadding(SkRect* rect) const; - void set_scrollbar_button_length(unsigned int length) { + void set_scrollbar_button_length(int length) { scrollbar_button_length_ = length; } int scrollbar_button_length() const { return scrollbar_button_length_; } @@ -169,6 +169,8 @@ class NATIVE_THEME_EXPORT NativeThemeBase : public NativeTheme { // Returns the color used to draw the arrow. SkColor GetArrowColor(State state) const; + int scrollbar_width_; + private: friend class NativeThemeAuraTest; @@ -201,10 +203,8 @@ class NATIVE_THEME_EXPORT NativeThemeBase : public NativeTheme { const gfx::Rect& rect, const SkScalar borderRadius) const; - unsigned int scrollbar_width_; - // The length of the arrow buttons, 0 means no buttons are drawn. - unsigned int scrollbar_button_length_; + int scrollbar_button_length_; DISALLOW_COPY_AND_ASSIGN(NativeThemeBase); }; diff --git a/ui/native_theme/overlay_scrollbar_constants_aura.h b/ui/native_theme/overlay_scrollbar_constants_aura.h new file mode 100644 index 00000000000000..4022705dcb5971 --- /dev/null +++ b/ui/native_theme/overlay_scrollbar_constants_aura.h @@ -0,0 +1,27 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_NATIVE_THEME_OVERLAY_SCROLLBAR_CONSTANTS_AURA_H_ +#define UI_NATIVE_THEME_OVERLAY_SCROLLBAR_CONSTANTS_AURA_H_ + +#include "base/time/time.h" +#include "ui/gfx/skia_util.h" + +namespace ui { + +constexpr int kOverlayScrollbarThumbWidthNormal = 6; +constexpr int kOverlayScrollbarThumbWidthHovered = 10; +constexpr int kOverlayScrollbarThumbWidthPressed = 10; + +constexpr base::TimeDelta kOverlayScrollbarFadeOutDelay = + base::TimeDelta::FromMilliseconds(1000); +constexpr base::TimeDelta kOverlayScrollbarFadeOutDuration = + base::TimeDelta::FromMilliseconds(200); +// TODO(bokan): This is still undetermined. crbug.com/652520. +constexpr base::TimeDelta kOverlayScrollbarThinningDuration = + base::TimeDelta::FromMilliseconds(200); + +} // namespace ui + +#endif // UI_NATIVE_THEME_OVERLAY_SCROLLBAR_CONSTANTS_AURA_H_