Make it possible to request the non-expanded scrollbar width from ScrollbarTheme
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Apr 2017 18:23:29 +0000 (18:23 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Apr 2017 18:23:29 +0000 (18:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171047

Reviewed by Sam Weinig.

No new tests, new behavior is not exposed in any way.

* platform/ScrollTypes.h:
* platform/ScrollbarTheme.h:
(WebCore::ScrollbarTheme::scrollbarThickness):
* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::ScrollbarThemeGtk::scrollbarThickness):
* platform/gtk/ScrollbarThemeGtk.h:
* platform/ios/ScrollbarThemeIOS.h:
* platform/ios/ScrollbarThemeIOS.mm:
(WebCore::ScrollbarThemeIOS::scrollbarThickness):
* platform/mac/ScrollbarThemeMac.h:
* platform/mac/ScrollbarThemeMac.mm:
(WebCore::ScrollbarThemeMac::scrollbarThickness):
* platform/mock/ScrollbarThemeMock.cpp:
(WebCore::ScrollbarThemeMock::scrollbarThickness):
* platform/mock/ScrollbarThemeMock.h:
* platform/win/ScrollbarThemeWin.cpp:
(WebCore::ScrollbarThemeWin::scrollbarThickness):
* platform/win/ScrollbarThemeWin.h:
* rendering/RenderScrollbarTheme.h:
On Mac, when the scrollbar is hovered, it gets bigger.
Currently, scrollbarThickness always returns the big size.
It should be possible to request the smaller, "regular" scrollbar size as well.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215566 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/ScrollTypes.h
Source/WebCore/platform/ScrollbarTheme.h
Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
Source/WebCore/platform/gtk/ScrollbarThemeGtk.h
Source/WebCore/platform/ios/ScrollbarThemeIOS.h
Source/WebCore/platform/ios/ScrollbarThemeIOS.mm
Source/WebCore/platform/mac/ScrollbarThemeMac.h
Source/WebCore/platform/mac/ScrollbarThemeMac.mm
Source/WebCore/platform/mock/ScrollbarThemeMock.cpp
Source/WebCore/platform/mock/ScrollbarThemeMock.h
Source/WebCore/platform/win/ScrollbarThemeWin.cpp
Source/WebCore/platform/win/ScrollbarThemeWin.h
Source/WebCore/rendering/RenderScrollbarTheme.h

index 0b56365..95f8da2 100644 (file)
@@ -1,3 +1,35 @@
+2017-04-20  Tim Horton  <timothy_horton@apple.com>
+
+        Make it possible to request the non-expanded scrollbar width from ScrollbarTheme
+        https://bugs.webkit.org/show_bug.cgi?id=171047
+
+        Reviewed by Sam Weinig.
+
+        No new tests, new behavior is not exposed in any way.
+
+        * platform/ScrollTypes.h:
+        * platform/ScrollbarTheme.h:
+        (WebCore::ScrollbarTheme::scrollbarThickness):
+        * platform/gtk/ScrollbarThemeGtk.cpp:
+        (WebCore::ScrollbarThemeGtk::scrollbarThickness):
+        * platform/gtk/ScrollbarThemeGtk.h:
+        * platform/ios/ScrollbarThemeIOS.h:
+        * platform/ios/ScrollbarThemeIOS.mm:
+        (WebCore::ScrollbarThemeIOS::scrollbarThickness):
+        * platform/mac/ScrollbarThemeMac.h:
+        * platform/mac/ScrollbarThemeMac.mm:
+        (WebCore::ScrollbarThemeMac::scrollbarThickness):
+        * platform/mock/ScrollbarThemeMock.cpp:
+        (WebCore::ScrollbarThemeMock::scrollbarThickness):
+        * platform/mock/ScrollbarThemeMock.h:
+        * platform/win/ScrollbarThemeWin.cpp:
+        (WebCore::ScrollbarThemeWin::scrollbarThickness):
+        * platform/win/ScrollbarThemeWin.h:
+        * rendering/RenderScrollbarTheme.h:
+        On Mac, when the scrollbar is hovered, it gets bigger.
+        Currently, scrollbarThickness always returns the big size.
+        It should be possible to request the smaller, "regular" scrollbar size as well.
+
 2017-04-20  Jon Lee  <jonlee@apple.com>
 
         Update pip placard to "picture in picture"
index df79001..e1a90ec 100644 (file)
@@ -124,6 +124,8 @@ enum ScrollbarMode { ScrollbarAuto, ScrollbarAlwaysOff, ScrollbarAlwaysOn };
 
 enum ScrollbarControlSize { RegularScrollbar, SmallScrollbar };
 
+enum class ScrollbarExpansionState { Regular, Expanded };
+
 enum class ScrollEventAxis { Horizontal, Vertical };
 
 typedef unsigned ScrollbarControlState;
index 31bf661..f4fb5d0 100644 (file)
@@ -51,7 +51,7 @@ public:
     virtual bool paint(Scrollbar&, GraphicsContext&, const IntRect& /*damageRect*/) { return false; }
     virtual ScrollbarPart hitTest(Scrollbar&, const IntPoint&) { return NoPart; }
     
-    virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar) { return 0; }
+    virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar, ScrollbarExpansionState = ScrollbarExpansionState::Expanded) { return 0; }
 
     virtual ScrollbarButtonsPlacement buttonsPlacement() const { return ScrollbarButtonsSingle; }
 
index 9d68b45..b63eb28 100644 (file)
@@ -844,7 +844,7 @@ ScrollbarButtonPressAction ScrollbarThemeGtk::handleMousePressEvent(Scrollbar&,
 }
 
 #if GTK_CHECK_VERSION(3, 20, 0)
-int ScrollbarThemeGtk::scrollbarThickness(ScrollbarControlSize)
+int ScrollbarThemeGtk::scrollbarThickness(ScrollbarControlSize, ScrollbarExpansionState)
 {
     RenderThemeGadget::Info info = { RenderThemeGadget::Type::Scrollbar, "scrollbar", GTK_STATE_FLAG_PRELIGHT, { "vertical", "right", "hovering" } };
     if (m_usesOverlayScrollbars)
@@ -876,7 +876,7 @@ int ScrollbarThemeGtk::scrollbarThickness(ScrollbarControlSize)
     return preferredSize.width();
 }
 #else
-int ScrollbarThemeGtk::scrollbarThickness(ScrollbarControlSize)
+int ScrollbarThemeGtk::scrollbarThickness(ScrollbarControlSize, ScrollbarExpansionState)
 {
     int thumbFat, troughBorderWidth;
     gtk_style_context_get_style(createStyleContext().get(), "slider-width", &thumbFat, "trough-border", &troughBorderWidth, nullptr);
index 9cb47cd..7b134b5 100644 (file)
@@ -48,7 +48,7 @@ public:
 
     bool paint(Scrollbar&, GraphicsContext&, const IntRect& damageRect) override;
     ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart) override;
-    int scrollbarThickness(ScrollbarControlSize) override;
+    int scrollbarThickness(ScrollbarControlSize, ScrollbarExpansionState = ScrollbarExpansionState::Expanded) override;
     int minimumThumbLength(Scrollbar&) override;
 
     // TODO: These are the default GTK+ values. At some point we should pull these from the theme itself.
index accd29c..76499bd 100644 (file)
@@ -37,7 +37,7 @@ public:
 
     bool paint(Scrollbar&, GraphicsContext&, const IntRect& damageRect) override;
 
-    int scrollbarThickness(ScrollbarControlSize = RegularScrollbar) override;
+    int scrollbarThickness(ScrollbarControlSize = RegularScrollbar, ScrollbarExpansionState = ScrollbarExpansionState::Expanded) override;
     
     bool supportsControlTints() const override { return true; }
 
index fe29077..e821ae4 100644 (file)
@@ -61,7 +61,7 @@ void ScrollbarThemeIOS::preferencesChanged()
 {
 }
 
-int ScrollbarThemeIOS::scrollbarThickness(ScrollbarControlSize)
+int ScrollbarThemeIOS::scrollbarThickness(ScrollbarControlSize, ScrollbarExpansionState)
 {
     return 0;
 }
index 7eaa911..26a89ff 100644 (file)
@@ -41,7 +41,7 @@ public:
 
     bool paint(Scrollbar&, GraphicsContext&, const IntRect& damageRect) override;
 
-    int scrollbarThickness(ScrollbarControlSize = RegularScrollbar) override;
+    int scrollbarThickness(ScrollbarControlSize = RegularScrollbar, ScrollbarExpansionState = ScrollbarExpansionState::Expanded) override;
     
     bool supportsControlTints() const override { return true; }
     bool usesOverlayScrollbars() const  override;
index 28aa154..1182562 100644 (file)
@@ -240,11 +240,11 @@ void ScrollbarThemeMac::preferencesChanged()
     usesOverlayScrollbarsChanged();
 }
 
-int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize)
+int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize, ScrollbarExpansionState expansionState)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     NSScrollerImp *scrollerImp = [NSScrollerImp scrollerImpWithStyle:recommendedScrollerStyle() controlSize:scrollbarControlSizeToNSControlSize(controlSize) horizontal:NO replacingScrollerImp:nil];
-    [scrollerImp setExpanded:YES];
+    [scrollerImp setExpanded:(expansionState == ScrollbarExpansionState::Expanded)];
     return [scrollerImp trackBoxWidth];
     END_BLOCK_OBJC_EXCEPTIONS;
 }
index 171dfd5..5bd3ee0 100644 (file)
@@ -39,7 +39,7 @@ IntRect ScrollbarThemeMock::trackRect(Scrollbar& scrollbar, bool)
     return scrollbar.frameRect();
 }
 
-int ScrollbarThemeMock::scrollbarThickness(ScrollbarControlSize controlSize)
+int ScrollbarThemeMock::scrollbarThickness(ScrollbarControlSize controlSize, ScrollbarExpansionState)
 {
     return cScrollbarThickness[controlSize];
 }
index 7fd0392..f064e2e 100644 (file)
@@ -33,7 +33,7 @@ namespace WebCore {
 // Scrollbar theme used in image snapshots, to eliminate appearance differences between platforms.
 class ScrollbarThemeMock : public ScrollbarThemeComposite {
 public:
-    int scrollbarThickness(ScrollbarControlSize = RegularScrollbar) override;
+    int scrollbarThickness(ScrollbarControlSize = RegularScrollbar, ScrollbarExpansionState = ScrollbarExpansionState::Expanded) override;
 
 protected:
     bool hasButtons(Scrollbar&) override { return false; }
index 550372f..6558415 100644 (file)
@@ -115,7 +115,7 @@ static int scrollbarThicknessInPixels()
     return thickness;
 }
 
-int ScrollbarThemeWin::scrollbarThickness(ScrollbarControlSize)
+int ScrollbarThemeWin::scrollbarThickness(ScrollbarControlSize, ScrollbarExpansionState)
 {
     float inverseScaleFactor = 1.0f / deviceScaleFactorForWindow(0);
     return clampTo<int>(inverseScaleFactor * scrollbarThicknessInPixels());
index c4b4cf6..055e8ef 100644 (file)
@@ -35,7 +35,7 @@ public:
     ScrollbarThemeWin();
     virtual ~ScrollbarThemeWin();
 
-    int scrollbarThickness(ScrollbarControlSize = RegularScrollbar) override;
+    int scrollbarThickness(ScrollbarControlSize = RegularScrollbar, ScrollbarExpansionState = ScrollbarExpansionState::Expanded) override;
 
     void themeChanged() override;
     
index 41bd823..f3b2efd 100644 (file)
@@ -37,7 +37,7 @@ class RenderScrollbarTheme final : public ScrollbarThemeComposite {
 public:
     virtual ~RenderScrollbarTheme() { }
     
-    int scrollbarThickness(ScrollbarControlSize controlSize) override { return ScrollbarTheme::theme().scrollbarThickness(controlSize); }
+    int scrollbarThickness(ScrollbarControlSize controlSize, ScrollbarExpansionState expansionState = ScrollbarExpansionState::Expanded) override { return ScrollbarTheme::theme().scrollbarThickness(controlSize, expansionState); }
 
     ScrollbarButtonsPlacement buttonsPlacement() const override { return ScrollbarTheme::theme().buttonsPlacement(); }