Use an enum for scrollbar style
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Feb 2015 04:07:06 +0000 (04:07 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Feb 2015 04:07:06 +0000 (04:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141985

Reviewed by Beth Dakin.
Source/WebCore:

Switch to an enum class for the scrollbar style (normal or overlay).

* page/ChromeClient.h:
* page/FrameView.cpp:
(WebCore::FrameView::scrollbarStyleChanged):
* page/FrameView.h:
* platform/ScrollTypes.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::scrollbarStyleChanged):
* platform/ScrollView.h:
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::scrollbarStyleChanged):
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::updateScrollerStyle):

Source/WebKit2:

Switch to an enum class for the scrollbar style (normal or overlay).

Sadly it still has to be passed as an int across the process boundary.

* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::recommendedScrollbarStyleDidChange):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::recommendedScrollbarStyleDidChange):
* WebProcess/Plugins/PDF/PDFPlugin.h:
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::scrollbarStyleChanged):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::recommendedScrollbarStyleDidChange):
* WebProcess/WebCoreSupport/WebChromeClient.h:

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

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/ScrollTypes.h
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebCore/platform/ScrollableArea.h
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/mac/PageClientImpl.h
Source/WebKit2/UIProcess/mac/PageClientImpl.mm
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

index bac057f..6ed8f7e 100644 (file)
@@ -1,3 +1,25 @@
+2015-02-24  Simon Fraser  <simon.fraser@apple.com>
+
+        Use an enum for scrollbar style
+        https://bugs.webkit.org/show_bug.cgi?id=141985
+
+        Reviewed by Beth Dakin.
+
+        Switch to an enum class for the scrollbar style (normal or overlay).
+
+        * page/ChromeClient.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollbarStyleChanged):
+        * page/FrameView.h:
+        * platform/ScrollTypes.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::scrollbarStyleChanged):
+        * platform/ScrollView.h:
+        * platform/ScrollableArea.h:
+        (WebCore::ScrollableArea::scrollbarStyleChanged):
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::updateScrollerStyle):
+
 2015-02-24  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r180599.
index ddc3b5c..578803f 100644 (file)
@@ -386,7 +386,7 @@ public:
     virtual void postAccessibilityNotification(AccessibilityObject*, AXObjectCache::AXNotification) { }
 
     virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
-    virtual void recommendedScrollbarStyleDidChange(int /*newStyle*/) { }
+    virtual void recommendedScrollbarStyleDidChange(ScrollbarStyle) { }
 
     enum DialogType {
         AlertDialog = 0,
index 81aaa94..06f946c 100644 (file)
@@ -3486,7 +3486,7 @@ bool FrameView::shouldSuspendScrollAnimations() const
     return frame().loader().state() != FrameStateComplete;
 }
 
-void FrameView::scrollbarStyleChanged(int newStyle, bool forceUpdate)
+void FrameView::scrollbarStyleChanged(ScrollbarStyle newStyle, bool forceUpdate)
 {
     if (!frame().isMainFrame())
         return;
index 65c7bbd..4ac1216 100644 (file)
@@ -424,7 +424,7 @@ public:
     void flushAnyPendingPostLayoutTasks();
 
     virtual bool shouldSuspendScrollAnimations() const override;
-    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate) override;
+    virtual void scrollbarStyleChanged(ScrollbarStyle, bool forceUpdate) override;
 
     RenderBox* embeddedContentBox() const;
     
index 46df9fe..4309c6c 100644 (file)
@@ -154,6 +154,11 @@ namespace WebCore {
         ScrollbarButtonsDoubleEnd,
         ScrollbarButtonsDoubleBoth
     };
+
+    enum class ScrollbarStyle {
+        AlwaysVisible,
+        Overlay
+    };
     
     enum ScrollbarOverlayStyle {
         ScrollbarOverlayStyleDefault,
index e37ed22..5df0920 100644 (file)
@@ -1162,7 +1162,7 @@ bool ScrollView::isScrollCornerVisible() const
     return !scrollCornerRect().isEmpty();
 }
 
-void ScrollView::scrollbarStyleChanged(int, bool forceUpdate)
+void ScrollView::scrollbarStyleChanged(ScrollbarStyle, bool forceUpdate)
 {
     if (!forceUpdate)
         return;
index b6a6eb8..4d8620a 100644 (file)
@@ -73,7 +73,7 @@ public:
     virtual int scrollPosition(Scrollbar*) const override;
     WEBCORE_EXPORT virtual void setScrollOffset(const IntPoint&) override;
     virtual bool isScrollCornerVisible() const override;
-    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate) override;
+    virtual void scrollbarStyleChanged(ScrollbarStyle, bool forceUpdate) override;
 
     virtual void notifyPageThatContentAreaWillPaint() const;
 
index ca6e42d..62d79af 100644 (file)
@@ -201,7 +201,7 @@ public:
     WEBCORE_EXPORT IntSize totalContentsSize() const;
 
     virtual bool shouldSuspendScrollAnimations() const { return true; }
-    virtual void scrollbarStyleChanged(int /*newStyle*/, bool /*forceUpdate*/) { }
+    virtual void scrollbarStyleChanged(ScrollbarStyle, bool /*forceUpdate*/) { }
     virtual void setVisibleScrollerThumbRect(const IntRect&) { }
     
     // Note that this only returns scrollable areas that can actually be scrolled.
index 08b2abd..2ba6b4f 100644 (file)
@@ -1342,7 +1342,7 @@ void ScrollAnimatorMac::updateScrollerStyle()
 
     // If m_needsScrollerStyleUpdate is true, then the page is restoring from the page cache, and 
     // a relayout will happen on its own. Otherwise, we must initiate a re-layout ourselves.
-    scrollableArea().scrollbarStyleChanged(newStyle, !m_needsScrollerStyleUpdate);
+    scrollableArea().scrollbarStyleChanged(newStyle == NSScrollerStyleOverlay ? ScrollbarStyle::Overlay : ScrollbarStyle::AlwaysVisible, !m_needsScrollerStyleUpdate);
 
     m_needsScrollerStyleUpdate = false;
 }
index 682dac3..86416fc 100644 (file)
@@ -1,3 +1,27 @@
+2015-02-24  Simon Fraser  <simon.fraser@apple.com>
+
+        Use an enum for scrollbar style
+        https://bugs.webkit.org/show_bug.cgi?id=141985
+
+        Reviewed by Beth Dakin.
+        
+        Switch to an enum class for the scrollbar style (normal or overlay).
+        
+        Sadly it still has to be passed as an int across the process boundary.
+
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::recommendedScrollbarStyleDidChange):
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::recommendedScrollbarStyleDidChange):
+        * WebProcess/Plugins/PDF/PDFPlugin.h:
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::scrollbarStyleChanged):
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::recommendedScrollbarStyleDidChange):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+
 2015-02-24  Chris Dumez  <cdumez@apple.com>
 
         [Mac][WK2] ASSERTION FAILED: m_sendPort in IPC::Connection::open()
index 8c6086f..210f62a 100644 (file)
@@ -233,7 +233,7 @@ public:
     virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeText) = 0;
     virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText) = 0;
     virtual void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString) = 0;
-    virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) = 0;
+    virtual void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle) = 0;
     virtual void removeNavigationGestureSnapshot() = 0;
 
     virtual CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const = 0;
index d85ef48..59645f2 100644 (file)
@@ -5024,7 +5024,7 @@ void WebPageProxy::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThu
 void WebPageProxy::recommendedScrollbarStyleDidChange(int32_t newStyle)
 {
 #if USE(APPKIT)
-    m_pageClient.recommendedScrollbarStyleDidChange(newStyle);
+    m_pageClient.recommendedScrollbarStyleDidChange(static_cast<WebCore::ScrollbarStyle>(newStyle));
 #else
     UNUSED_PARAM(newStyle);
 #endif
index 4d81a27..2602988 100644 (file)
@@ -148,7 +148,7 @@ private:
     virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText) override;
     virtual void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString) override;
 
-    virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) override;
+    virtual void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle) override;
 
     virtual WKView* wkView() const override { return m_wkView; }
     virtual void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize) override;
index 14792b4..d846ea6 100644 (file)
@@ -608,11 +608,11 @@ void PageClientImpl::recordAutocorrectionResponse(AutocorrectionResponseType res
     CorrectionPanel::recordAutocorrectionResponse(m_wkView, response, replacedString, replacementString);
 }
 
-void PageClientImpl::recommendedScrollbarStyleDidChange(int32_t newStyle)
+void PageClientImpl::recommendedScrollbarStyleDidChange(ScrollbarStyle newStyle)
 {
     // Now re-create a tracking area with the appropriate options given the new scrollbar style
     NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect;
-    if (newStyle == NSScrollerStyleLegacy)
+    if (newStyle == ScrollbarStyle::AlwaysVisible)
         options |= NSTrackingActiveAlways;
     else
         options |= NSTrackingActiveInKeyWindow;
index 67093e2..78d49db 100644 (file)
@@ -194,7 +194,7 @@ private:
     virtual WebCore::Scrollbar* horizontalScrollbar() const override { return m_horizontalScrollbar.get(); }
     virtual WebCore::Scrollbar* verticalScrollbar() const override { return m_verticalScrollbar.get(); }
     virtual bool shouldSuspendScrollAnimations() const override { return false; } // If we return true, ScrollAnimatorMac will keep cycling a timer forever, waiting for a good time to animate.
-    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate) override;
+    virtual void scrollbarStyleChanged(WebCore::ScrollbarStyle, bool forceUpdate) override;
     virtual WebCore::IntRect convertFromScrollbarToContainingView(const WebCore::Scrollbar*, const WebCore::IntRect& scrollbarRect) const override;
     virtual WebCore::IntRect convertFromContainingViewToScrollbar(const WebCore::Scrollbar*, const WebCore::IntRect& parentRect) const override;
     virtual WebCore::IntPoint convertFromScrollbarToContainingView(const WebCore::Scrollbar*, const WebCore::IntPoint& scrollbarPoint) const override;
index 0bcd19e..b2f67eb 100644 (file)
@@ -788,7 +788,7 @@ IntPoint PDFPlugin::maximumScrollPosition() const
     return maximumOffset;
 }
 
-void PDFPlugin::scrollbarStyleChanged(int, bool forceUpdate)
+void PDFPlugin::scrollbarStyleChanged(ScrollbarStyle style, bool forceUpdate)
 {
     if (!forceUpdate)
         return;
index 7e19e3b..a50a9ac 100644 (file)
@@ -971,9 +971,9 @@ void WebChromeClient::notifyScrollerThumbIsVisibleInRect(const IntRect& scroller
     m_page->send(Messages::WebPageProxy::NotifyScrollerThumbIsVisibleInRect(scrollerThumb));
 }
 
-void WebChromeClient::recommendedScrollbarStyleDidChange(int32_t newStyle)
+void WebChromeClient::recommendedScrollbarStyleDidChange(ScrollbarStyle newStyle)
 {
-    m_page->send(Messages::WebPageProxy::RecommendedScrollbarStyleDidChange(newStyle));
+    m_page->send(Messages::WebPageProxy::RecommendedScrollbarStyleDidChange(static_cast<int32_t>(newStyle)));
 }
 
 Color WebChromeClient::underlayColor() const
index e9bc08c..1760065 100644 (file)
@@ -274,7 +274,7 @@ private:
     virtual void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const override;
 
     virtual void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&) override;
-    virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) override;
+    virtual void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle newStyle) override;
 
     virtual WebCore::Color underlayColor() const override;