ScrollbarThemes should be returned by reference.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Sep 2015 02:58:14 +0000 (02:58 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Sep 2015 02:58:14 +0000 (02:58 +0000)
<https://webkit.org/b/147551>

Reviewed by Zalan Bujtas.

Source/WebCore:

There's always a ScrollbarTheme of some type, so have ScrollbarTheme getters
return references all around.

* css/SelectorCheckerTestFunctions.h:
(WebCore::scrollbarMatchesDoubleButtonPseudoClass):
(WebCore::scrollbarMatchesSingleButtonPseudoClass):
(WebCore::scrollbarMatchesNoButtonPseudoClass):
* html/shadow/SpinButtonElement.cpp:
(WebCore::SpinButtonElement::startRepeatingTimer):
* page/PageOverlay.cpp:
(WebCore::PageOverlay::bounds):
* page/scrolling/mac/ScrollingStateFrameScrollingNodeMac.mm:
(WebCore::ScrollingStateFrameScrollingNode::setScrollbarPaintersFromScrollbars):
* platform/ScrollView.cpp:
(WebCore::ScrollView::paintScrollCorner):
(WebCore::ScrollView::paintOverhangAreas):
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::setScrollbarOverlayStyle):
* platform/Scrollbar.cpp:
(WebCore::Scrollbar::maxOverlapBetweenPages):
(WebCore::Scrollbar::Scrollbar):
(WebCore::Scrollbar::~Scrollbar):
(WebCore::Scrollbar::offsetDidChange):
(WebCore::Scrollbar::updateThumb):
(WebCore::Scrollbar::paint):
(WebCore::Scrollbar::autoscrollTimerFired):
(WebCore::thumbUnderMouse):
(WebCore::Scrollbar::autoscrollPressedPart):
(WebCore::Scrollbar::startTimerIfNeeded):
(WebCore::Scrollbar::moveThumb):
(WebCore::Scrollbar::setHoveredPart):
(WebCore::Scrollbar::setPressedPart):
(WebCore::Scrollbar::mouseMoved):
(WebCore::Scrollbar::mouseUp):
(WebCore::Scrollbar::mouseDown):
(WebCore::Scrollbar::setEnabled):
(WebCore::Scrollbar::isOverlayScrollbar):
* platform/Scrollbar.h:
(WebCore::Scrollbar::theme):
* platform/ScrollbarTheme.cpp:
(WebCore::ScrollbarTheme::theme):
* platform/ScrollbarTheme.h:
* platform/efl/ScrollbarThemeEfl.cpp:
(WebCore::ScrollbarTheme::nativeTheme):
* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::ScrollbarTheme::nativeTheme):
* platform/ios/ScrollbarThemeIOS.mm:
(WebCore::ScrollbarTheme::nativeTheme):
* platform/mac/ScrollAnimatorMac.mm:
(macScrollbarTheme):
* platform/mac/ScrollbarThemeMac.mm:
(+[WebScrollbarPrefsObserver appearancePrefsChanged:]):
(+[WebScrollbarPrefsObserver behaviorPrefsChanged:]):
(WebCore::ScrollbarTheme::nativeTheme):
* platform/win/PopupMenuWin.cpp:
(WebCore::PopupMenuWin::calculatePositionAndSize):
(WebCore::AccessiblePopupMenu::accLocation):
(WebCore::AccessiblePopupMenu::accHitTest):
* platform/win/ScrollbarThemeSafari.cpp:
(WebCore::ScrollbarTheme::nativeTheme):
* platform/win/ScrollbarThemeWin.cpp:
(WebCore::ScrollbarTheme::nativeTheme):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::hasVerticalScrollbarWithAutoBehavior):
(WebCore::RenderBox::hasHorizontalScrollbarWithAutoBehavior):
* rendering/RenderLayer.cpp:
(WebCore::cornerRect):
(WebCore::styleRequiresScrollbar):
(WebCore::styleDefinesAutomaticScrollbar):
* rendering/RenderScrollbar.cpp:
(WebCore::RenderScrollbar::updateScrollbarPart):
* rendering/RenderScrollbarPart.cpp:
(WebCore::calcScrollbarThicknessUsing):
(WebCore::RenderScrollbarPart::styleDidChange):
(WebCore::RenderScrollbarPart::imageChanged):
* rendering/RenderScrollbarTheme.cpp:
(WebCore::RenderScrollbarTheme::paintTickmarks):
* rendering/RenderScrollbarTheme.h:
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::scrollbarThickness):

Source/WebKit/win:

* WebView.cpp:
(WebView::gestureNotify):
(WebView::WebViewWndProc):

Source/WebKit2:

* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::paintControlForLayerInContext):

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

32 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/SelectorCheckerTestFunctions.h
Source/WebCore/html/shadow/SpinButtonElement.cpp
Source/WebCore/page/PageOverlay.cpp
Source/WebCore/page/scrolling/mac/ScrollingStateFrameScrollingNodeMac.mm
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollableArea.cpp
Source/WebCore/platform/Scrollbar.cpp
Source/WebCore/platform/Scrollbar.h
Source/WebCore/platform/ScrollbarTheme.cpp
Source/WebCore/platform/ScrollbarTheme.h
Source/WebCore/platform/efl/ScrollbarThemeEfl.cpp
Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
Source/WebCore/platform/ios/ScrollbarThemeIOS.mm
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebCore/platform/mac/ScrollbarThemeMac.mm
Source/WebCore/platform/win/PopupMenuWin.cpp
Source/WebCore/platform/win/ScrollbarThemeSafari.cpp
Source/WebCore/platform/win/ScrollbarThemeWin.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderScrollbar.cpp
Source/WebCore/rendering/RenderScrollbarPart.cpp
Source/WebCore/rendering/RenderScrollbarTheme.cpp
Source/WebCore/rendering/RenderScrollbarTheme.h
Source/WebCore/rendering/RenderTextControl.cpp
Source/WebCore/rendering/RenderThemeEfl.cpp
Source/WebCore/rendering/RenderThemeGtk.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm

index 744fbda..0d4f6d8 100644 (file)
@@ -1,3 +1,91 @@
+2015-09-02  Andreas Kling  <akling@apple.com>
+
+        ScrollbarThemes should be returned by reference.
+        <https://webkit.org/b/147551>
+
+        Reviewed by Zalan Bujtas.
+
+        There's always a ScrollbarTheme of some type, so have ScrollbarTheme getters
+        return references all around.
+
+        * css/SelectorCheckerTestFunctions.h:
+        (WebCore::scrollbarMatchesDoubleButtonPseudoClass):
+        (WebCore::scrollbarMatchesSingleButtonPseudoClass):
+        (WebCore::scrollbarMatchesNoButtonPseudoClass):
+        * html/shadow/SpinButtonElement.cpp:
+        (WebCore::SpinButtonElement::startRepeatingTimer):
+        * page/PageOverlay.cpp:
+        (WebCore::PageOverlay::bounds):
+        * page/scrolling/mac/ScrollingStateFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingStateFrameScrollingNode::setScrollbarPaintersFromScrollbars):
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::paintScrollCorner):
+        (WebCore::ScrollView::paintOverhangAreas):
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::setScrollbarOverlayStyle):
+        * platform/Scrollbar.cpp:
+        (WebCore::Scrollbar::maxOverlapBetweenPages):
+        (WebCore::Scrollbar::Scrollbar):
+        (WebCore::Scrollbar::~Scrollbar):
+        (WebCore::Scrollbar::offsetDidChange):
+        (WebCore::Scrollbar::updateThumb):
+        (WebCore::Scrollbar::paint):
+        (WebCore::Scrollbar::autoscrollTimerFired):
+        (WebCore::thumbUnderMouse):
+        (WebCore::Scrollbar::autoscrollPressedPart):
+        (WebCore::Scrollbar::startTimerIfNeeded):
+        (WebCore::Scrollbar::moveThumb):
+        (WebCore::Scrollbar::setHoveredPart):
+        (WebCore::Scrollbar::setPressedPart):
+        (WebCore::Scrollbar::mouseMoved):
+        (WebCore::Scrollbar::mouseUp):
+        (WebCore::Scrollbar::mouseDown):
+        (WebCore::Scrollbar::setEnabled):
+        (WebCore::Scrollbar::isOverlayScrollbar):
+        * platform/Scrollbar.h:
+        (WebCore::Scrollbar::theme):
+        * platform/ScrollbarTheme.cpp:
+        (WebCore::ScrollbarTheme::theme):
+        * platform/ScrollbarTheme.h:
+        * platform/efl/ScrollbarThemeEfl.cpp:
+        (WebCore::ScrollbarTheme::nativeTheme):
+        * platform/gtk/ScrollbarThemeGtk.cpp:
+        (WebCore::ScrollbarTheme::nativeTheme):
+        * platform/ios/ScrollbarThemeIOS.mm:
+        (WebCore::ScrollbarTheme::nativeTheme):
+        * platform/mac/ScrollAnimatorMac.mm:
+        (macScrollbarTheme):
+        * platform/mac/ScrollbarThemeMac.mm:
+        (+[WebScrollbarPrefsObserver appearancePrefsChanged:]):
+        (+[WebScrollbarPrefsObserver behaviorPrefsChanged:]):
+        (WebCore::ScrollbarTheme::nativeTheme):
+        * platform/win/PopupMenuWin.cpp:
+        (WebCore::PopupMenuWin::calculatePositionAndSize):
+        (WebCore::AccessiblePopupMenu::accLocation):
+        (WebCore::AccessiblePopupMenu::accHitTest):
+        * platform/win/ScrollbarThemeSafari.cpp:
+        (WebCore::ScrollbarTheme::nativeTheme):
+        * platform/win/ScrollbarThemeWin.cpp:
+        (WebCore::ScrollbarTheme::nativeTheme):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::hasVerticalScrollbarWithAutoBehavior):
+        (WebCore::RenderBox::hasHorizontalScrollbarWithAutoBehavior):
+        * rendering/RenderLayer.cpp:
+        (WebCore::cornerRect):
+        (WebCore::styleRequiresScrollbar):
+        (WebCore::styleDefinesAutomaticScrollbar):
+        * rendering/RenderScrollbar.cpp:
+        (WebCore::RenderScrollbar::updateScrollbarPart):
+        * rendering/RenderScrollbarPart.cpp:
+        (WebCore::calcScrollbarThicknessUsing):
+        (WebCore::RenderScrollbarPart::styleDidChange):
+        (WebCore::RenderScrollbarPart::imageChanged):
+        * rendering/RenderScrollbarTheme.cpp:
+        (WebCore::RenderScrollbarTheme::paintTickmarks):
+        * rendering/RenderScrollbarTheme.h:
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::scrollbarThickness):
+
 2015-09-02  Ryosuke Niwa  <rniwa@webkit.org>
 
         Node.textContent = undefined should be equivalent to textContent = ""
index ad7a1c9..a8ab5fa 100644 (file)
@@ -288,7 +288,7 @@ ALWAYS_INLINE bool scrollbarMatchesDoubleButtonPseudoClass(const SelectorChecker
 {
     if (!context.scrollbar)
         return false;
-    ScrollbarButtonsPlacement buttonsPlacement = context.scrollbar->theme()->buttonsPlacement();
+    ScrollbarButtonsPlacement buttonsPlacement = context.scrollbar->theme().buttonsPlacement();
     if (context.scrollbarPart == BackButtonStartPart || context.scrollbarPart == ForwardButtonStartPart || context.scrollbarPart == BackTrackPart)
         return buttonsPlacement == ScrollbarButtonsDoubleStart || buttonsPlacement == ScrollbarButtonsDoubleBoth;
     if (context.scrollbarPart == BackButtonEndPart || context.scrollbarPart == ForwardButtonEndPart || context.scrollbarPart == ForwardTrackPart)
@@ -300,7 +300,7 @@ ALWAYS_INLINE bool scrollbarMatchesSingleButtonPseudoClass(const SelectorChecker
 {
     if (!context.scrollbar)
         return false;
-    ScrollbarButtonsPlacement buttonsPlacement = context.scrollbar->theme()->buttonsPlacement();
+    ScrollbarButtonsPlacement buttonsPlacement = context.scrollbar->theme().buttonsPlacement();
     if (context.scrollbarPart == BackButtonStartPart || context.scrollbarPart == ForwardButtonEndPart || context.scrollbarPart == BackTrackPart || context.scrollbarPart == ForwardTrackPart)
         return buttonsPlacement == ScrollbarButtonsSingle;
     return false;
@@ -310,7 +310,7 @@ ALWAYS_INLINE bool scrollbarMatchesNoButtonPseudoClass(const SelectorChecker::Ch
 {
     if (!context.scrollbar)
         return false;
-    ScrollbarButtonsPlacement buttonsPlacement = context.scrollbar->theme()->buttonsPlacement();
+    ScrollbarButtonsPlacement buttonsPlacement = context.scrollbar->theme().buttonsPlacement();
     if (context.scrollbarPart == BackTrackPart)
         return buttonsPlacement == ScrollbarButtonsNone || buttonsPlacement == ScrollbarButtonsDoubleEnd;
     if (context.scrollbarPart == ForwardTrackPart)
index 3cd8954..b74626f 100644 (file)
@@ -207,8 +207,8 @@ bool SpinButtonElement::matchesReadWritePseudoClass() const
 void SpinButtonElement::startRepeatingTimer()
 {
     m_pressStartingState = m_upDownState;
-    ScrollbarTheme* theme = ScrollbarTheme::theme();
-    m_repeatingTimer.start(theme->initialAutoscrollTimerDelay(), theme->autoscrollTimerDelay());
+    ScrollbarTheme& theme = ScrollbarTheme::theme();
+    m_repeatingTimer.start(theme.initialAutoscrollTimerDelay(), theme.autoscrollTimerDelay());
 }
 
 void SpinButtonElement::stopRepeatingTimer()
index a9b91cd..e56600b 100644 (file)
@@ -91,7 +91,7 @@ IntRect PageOverlay::bounds() const
         int width = frameView->width();
         int height = frameView->height();
 
-        if (!ScrollbarTheme::theme()->usesOverlayScrollbars()) {
+        if (!ScrollbarTheme::theme().usesOverlayScrollbars()) {
             if (frameView->verticalScrollbar())
                 width -= frameView->verticalScrollbar()->width();
             if (frameView->horizontalScrollbar())
index bd8557f..a5eb91a 100644 (file)
@@ -37,15 +37,15 @@ namespace WebCore {
     
 void ScrollingStateFrameScrollingNode::setScrollbarPaintersFromScrollbars(Scrollbar* verticalScrollbar, Scrollbar* horizontalScrollbar)
 {
-    ScrollbarTheme* scrollbarTheme = ScrollbarTheme::theme();
-    if (scrollbarTheme->isMockTheme())
+    ScrollbarTheme& scrollbarTheme = ScrollbarTheme::theme();
+    if (scrollbarTheme.isMockTheme())
         return;
-    ScrollbarThemeMac* macTheme = static_cast<ScrollbarThemeMac*>(scrollbarTheme);
+    ScrollbarThemeMac& macTheme = static_cast<ScrollbarThemeMac&>(scrollbarTheme);
 
     ScrollbarPainter verticalPainter = verticalScrollbar && verticalScrollbar->supportsUpdateOnSecondaryThread()
-        ? macTheme->painterForScrollbar(*verticalScrollbar) : nullptr;
+        ? macTheme.painterForScrollbar(*verticalScrollbar) : nullptr;
     ScrollbarPainter horizontalPainter = horizontalScrollbar && horizontalScrollbar->supportsUpdateOnSecondaryThread()
-        ? macTheme->painterForScrollbar(*horizontalScrollbar) : nullptr;
+        ? macTheme.painterForScrollbar(*horizontalScrollbar) : nullptr;
 
     if (m_verticalScrollbarPainter == verticalPainter && m_horizontalScrollbarPainter == horizontalPainter)
         return;
index 60f3708..09788b0 100644 (file)
@@ -1149,7 +1149,7 @@ void ScrollView::updateScrollCorner()
 
 void ScrollView::paintScrollCorner(GraphicsContext& context, const IntRect& cornerRect)
 {
-    ScrollbarTheme::theme()->paintScrollCorner(this, context, cornerRect);
+    ScrollbarTheme::theme().paintScrollCorner(this, context, cornerRect);
 }
 
 void ScrollView::paintScrollbar(GraphicsContext& context, Scrollbar& bar, const IntRect& rect)
@@ -1301,7 +1301,7 @@ void ScrollView::updateOverhangAreas()
 
 void ScrollView::paintOverhangAreas(GraphicsContext& context, const IntRect& horizontalOverhangRect, const IntRect& verticalOverhangRect, const IntRect& dirtyRect)
 {
-    ScrollbarTheme::theme()->paintOverhangAreas(*this, context, horizontalOverhangRect, verticalOverhangRect, dirtyRect);
+    ScrollbarTheme::theme().paintOverhangAreas(*this, context, horizontalOverhangRect, verticalOverhangRect, dirtyRect);
 }
 
 void ScrollView::calculateAndPaintOverhangAreas(GraphicsContext& context, const IntRect& dirtyRect)
index 5dfc695..aefc021 100644 (file)
@@ -339,14 +339,14 @@ void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle
     m_scrollbarOverlayStyle = overlayStyle;
 
     if (horizontalScrollbar()) {
-        ScrollbarTheme::theme()->updateScrollbarOverlayStyle(*horizontalScrollbar());
+        ScrollbarTheme::theme().updateScrollbarOverlayStyle(*horizontalScrollbar());
         horizontalScrollbar()->invalidate();
         if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
             scrollAnimator->invalidateScrollbarPartLayers(horizontalScrollbar());
     }
     
     if (verticalScrollbar()) {
-        ScrollbarTheme::theme()->updateScrollbarOverlayStyle(*verticalScrollbar());
+        ScrollbarTheme::theme().updateScrollbarOverlayStyle(*verticalScrollbar());
         verticalScrollbar()->invalidate();
         if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
             scrollAnimator->invalidateScrollbarPartLayers(verticalScrollbar());
index 3151149..8d3daa1 100644 (file)
@@ -50,16 +50,15 @@ PassRefPtr<Scrollbar> Scrollbar::createNativeScrollbar(ScrollableArea& scrollabl
 
 int Scrollbar::maxOverlapBetweenPages()
 {
-    static int maxOverlapBetweenPages = ScrollbarTheme::theme()->maxOverlapBetweenPages();
+    static int maxOverlapBetweenPages = ScrollbarTheme::theme().maxOverlapBetweenPages();
     return maxOverlapBetweenPages;
 }
 
-Scrollbar::Scrollbar(ScrollableArea& scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize,
-    ScrollbarTheme* theme, bool isCustomScrollbar)
+Scrollbar::Scrollbar(ScrollableArea& scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize, ScrollbarTheme* customTheme, bool isCustomScrollbar)
     : m_scrollableArea(scrollableArea)
     , m_orientation(orientation)
     , m_controlSize(controlSize)
-    , m_theme(theme)
+    , m_theme(customTheme ? *customTheme : ScrollbarTheme::theme())
     , m_visibleSize(0)
     , m_totalSize(0)
     , m_currentPos(0)
@@ -80,15 +79,12 @@ Scrollbar::Scrollbar(ScrollableArea& scrollableArea, ScrollbarOrientation orient
     , m_isCustomScrollbar(isCustomScrollbar)
     , m_weakPtrFactory(this)
 {
-    if (!m_theme)
-        m_theme = ScrollbarTheme::theme();
-
-    m_theme->registerScrollbar(*this);
+    theme().registerScrollbar(*this);
 
     // FIXME: This is ugly and would not be necessary if we fix cross-platform code to actually query for
     // scrollbar thickness and use it when sizing scrollbars (rather than leaving one dimension of the scrollbar
     // alone when sizing).
-    int thickness = m_theme->scrollbarThickness(controlSize);
+    int thickness = theme().scrollbarThickness(controlSize);
     Widget::setFrameRect(IntRect(0, 0, thickness, thickness));
 
     m_currentPos = static_cast<float>(m_scrollableArea.scrollPosition(this));
@@ -98,7 +94,7 @@ Scrollbar::~Scrollbar()
 {
     stopTimerIfNeeded();
     
-    m_theme->unregisterScrollbar(*this);
+    theme().unregisterScrollbar(*this);
 }
 
 void Scrollbar::offsetDidChange()
@@ -107,11 +103,11 @@ void Scrollbar::offsetDidChange()
     if (position == m_currentPos)
         return;
 
-    int oldThumbPosition = theme()->thumbPosition(*this);
+    int oldThumbPosition = theme().thumbPosition(*this);
     m_currentPos = position;
     updateThumbPosition();
     if (m_pressedPart == ThumbPart)
-        setPressedPos(m_pressedPos + theme()->thumbPosition(*this) - oldThumbPosition);
+        setPressedPos(m_pressedPos + theme().thumbPosition(*this) - oldThumbPosition);
 }
 
 void Scrollbar::setProportion(int visibleSize, int totalSize)
@@ -137,7 +133,7 @@ void Scrollbar::updateThumb()
 #ifdef THUMB_POSITION_AFFECTS_BUTTONS
     invalidate();
 #else
-    theme()->invalidateParts(*this, ForwardTrackPart | BackTrackPart | ThumbPart);
+    theme().invalidateParts(*this, ForwardTrackPart | BackTrackPart | ThumbPart);
 #endif
 }
 
@@ -153,7 +149,7 @@ void Scrollbar::updateThumbProportion()
 
 void Scrollbar::paint(GraphicsContext& context, const IntRect& damageRect)
 {
-    if (context.updatingControlTints() && theme()->supportsControlTints()) {
+    if (context.updatingControlTints() && theme().supportsControlTints()) {
         invalidate();
         return;
     }
@@ -161,19 +157,19 @@ void Scrollbar::paint(GraphicsContext& context, const IntRect& damageRect)
     if (context.paintingDisabled() || !frameRect().intersects(damageRect))
         return;
 
-    if (!theme()->paint(*this, context, damageRect))
+    if (!theme().paint(*this, context, damageRect))
         Widget::paint(context, damageRect);
 }
 
 void Scrollbar::autoscrollTimerFired()
 {
-    autoscrollPressedPart(theme()->autoscrollTimerDelay());
+    autoscrollPressedPart(theme().autoscrollTimerDelay());
 }
 
 static bool thumbUnderMouse(Scrollbar* scrollbar)
 {
-    int thumbPos = scrollbar->theme()->trackPosition(*scrollbar) + scrollbar->theme()->thumbPosition(*scrollbar);
-    int thumbLength = scrollbar->theme()->thumbLength(*scrollbar);
+    int thumbPos = scrollbar->theme().trackPosition(*scrollbar) + scrollbar->theme().thumbPosition(*scrollbar);
+    int thumbLength = scrollbar->theme().thumbLength(*scrollbar);
     return scrollbar->pressedPos() >= thumbPos && scrollbar->pressedPos() < thumbPos + thumbLength;
 }
 
@@ -185,7 +181,7 @@ void Scrollbar::autoscrollPressedPart(double delay)
 
     // Handle the track.
     if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
-        theme()->invalidatePart(*this, m_pressedPart);
+        theme().invalidatePart(*this, m_pressedPart);
         setHoveredPart(ThumbPart);
         return;
     }
@@ -204,7 +200,7 @@ void Scrollbar::startTimerIfNeeded(double delay)
     // Handle the track.  We halt track scrolling once the thumb is level
     // with us.
     if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
-        theme()->invalidatePart(*this, m_pressedPart);
+        theme().invalidatePart(*this, m_pressedPart);
         setHoveredPart(ThumbPart);
         return;
     }
@@ -273,9 +269,9 @@ void Scrollbar::moveThumb(int pos, bool draggingDocument)
     }
 
     // Drag the thumb.
-    int thumbPos = theme()->thumbPosition(*this);
-    int thumbLen = theme()->thumbLength(*this);
-    int trackLen = theme()->trackLength(*this);
+    int thumbPos = theme().thumbPosition(*this);
+    int thumbLen = theme().thumbLength(*this);
+    int trackLen = theme().trackLength(*this);
     int maxPos = trackLen - thumbLen;
     if (delta > 0)
         delta = std::min(maxPos - thumbPos, delta);
@@ -293,11 +289,11 @@ void Scrollbar::setHoveredPart(ScrollbarPart part)
     if (part == m_hoveredPart)
         return;
 
-    if ((m_hoveredPart == NoPart || part == NoPart) && theme()->invalidateOnMouseEnterExit())
+    if ((m_hoveredPart == NoPart || part == NoPart) && theme().invalidateOnMouseEnterExit())
         invalidate();  // Just invalidate the whole scrollbar, since the buttons at either end change anyway.
     else if (m_pressedPart == NoPart) {  // When there's a pressed part, we don't draw a hovered state, so there's no reason to invalidate.
-        theme()->invalidatePart(*this, part);
-        theme()->invalidatePart(*this, m_hoveredPart);
+        theme().invalidatePart(*this, part);
+        theme().invalidatePart(*this, m_hoveredPart);
     }
     m_hoveredPart = part;
 }
@@ -305,24 +301,24 @@ void Scrollbar::setHoveredPart(ScrollbarPart part)
 void Scrollbar::setPressedPart(ScrollbarPart part)
 {
     if (m_pressedPart != NoPart)
-        theme()->invalidatePart(*this, m_pressedPart);
+        theme().invalidatePart(*this, m_pressedPart);
     m_pressedPart = part;
     if (m_pressedPart != NoPart)
-        theme()->invalidatePart(*this, m_pressedPart);
+        theme().invalidatePart(*this, m_pressedPart);
     else if (m_hoveredPart != NoPart)  // When we no longer have a pressed part, we can start drawing a hovered state on the hovered part.
-        theme()->invalidatePart(*this, m_hoveredPart);
+        theme().invalidatePart(*this, m_hoveredPart);
 }
 
 #if !PLATFORM(IOS)
 bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt)
 {
     if (m_pressedPart == ThumbPart) {
-        if (theme()->shouldSnapBackToDragOrigin(*this, evt))
+        if (theme().shouldSnapBackToDragOrigin(*this, evt))
             m_scrollableArea.scrollToOffsetWithoutAnimation(m_orientation, m_dragOrigin);
         else {
             moveThumb(m_orientation == HorizontalScrollbar ? 
                       convertFromContainingWindow(evt.position()).x() :
-                      convertFromContainingWindow(evt.position()).y(), theme()->shouldDragDocumentInsteadOfThumb(*this, evt));
+                      convertFromContainingWindow(evt.position()).y(), theme().shouldDragDocumentInsteadOfThumb(*this, evt));
         }
         return true;
     }
@@ -330,19 +326,19 @@ bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt)
     if (m_pressedPart != NoPart)
         m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y());
 
-    ScrollbarPart part = theme()->hitTest(*this, evt.position());
+    ScrollbarPart part = theme().hitTest(*this, evt.position());
     if (part != m_hoveredPart) {
         if (m_pressedPart != NoPart) {
             if (part == m_pressedPart) {
                 // The mouse is moving back over the pressed part.  We
                 // need to start up the timer action again.
-                startTimerIfNeeded(theme()->autoscrollTimerDelay());
-                theme()->invalidatePart(*this, m_pressedPart);
+                startTimerIfNeeded(theme().autoscrollTimerDelay());
+                theme().invalidatePart(*this, m_pressedPart);
             } else if (m_hoveredPart == m_pressedPart) {
                 // The mouse is leaving the pressed part.  Kill our timer
                 // if needed.
                 stopTimerIfNeeded();
-                theme()->invalidatePart(*this, m_pressedPart);
+                theme().invalidatePart(*this, m_pressedPart);
             }
         } 
         
@@ -374,7 +370,7 @@ bool Scrollbar::mouseUp(const PlatformMouseEvent& mouseEvent)
 
     // m_hoveredPart won't be updated until the next mouseMoved or mouseDown, so we have to hit test
     // to really know if the mouse has exited the scrollbar on a mouseUp.
-    ScrollbarPart part = theme()->hitTest(*this, mouseEvent.position());
+    ScrollbarPart part = theme().hitTest(*this, mouseEvent.position());
     if (part == NoPart)
         m_scrollableArea.mouseExitedScrollbar(this);
 
@@ -387,18 +383,18 @@ bool Scrollbar::mouseDown(const PlatformMouseEvent& evt)
     if (evt.button() == RightButton)
         return true; // FIXME: Handled as context menu by Qt right now.  Should just avoid even calling this method on a right click though.
 
-    setPressedPart(theme()->hitTest(*this, evt.position()));
+    setPressedPart(theme().hitTest(*this, evt.position()));
     int pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y());
     
-    if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && theme()->shouldCenterOnThumb(*this, evt)) {
+    if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && theme().shouldCenterOnThumb(*this, evt)) {
         setHoveredPart(ThumbPart);
         setPressedPart(ThumbPart);
         m_dragOrigin = m_currentPos;
-        int thumbLen = theme()->thumbLength(*this);
+        int thumbLen = theme().thumbLength(*this);
         int desiredPos = pressedPos;
         // Set the pressed position to the middle of the thumb so that when we do the move, the delta
         // will be from the current pixel position of the thumb to the new desired position for the thumb.
-        m_pressedPos = theme()->trackPosition(*this) + theme()->thumbPosition(*this) + thumbLen / 2;
+        m_pressedPos = theme().trackPosition(*this) + theme().thumbPosition(*this) + thumbLen / 2;
         moveThumb(desiredPos);
         return true;
     } else if (m_pressedPart == ThumbPart)
@@ -406,7 +402,7 @@ bool Scrollbar::mouseDown(const PlatformMouseEvent& evt)
     
     m_pressedPos = pressedPos;
 
-    autoscrollPressedPart(theme()->initialAutoscrollTimerDelay());
+    autoscrollPressedPart(theme().initialAutoscrollTimerDelay());
     return true;
 }
 
@@ -415,13 +411,13 @@ void Scrollbar::setEnabled(bool e)
     if (m_enabled == e)
         return;
     m_enabled = e;
-    theme()->updateEnabledState(*this);
+    theme().updateEnabledState(*this);
     invalidate();
 }
 
 bool Scrollbar::isOverlayScrollbar() const
 {
-    return m_theme->usesOverlayScrollbars();
+    return theme().usesOverlayScrollbars();
 }
 
 bool Scrollbar::shouldParticipateInHitTesting()
index 9c00eee..e24a207 100644 (file)
@@ -107,7 +107,7 @@ public:
 
     WEBCORE_EXPORT bool mouseDown(const PlatformMouseEvent&);
 
-    ScrollbarTheme* theme() const { return m_theme; }
+    ScrollbarTheme& theme() const { return m_theme; }
 
     virtual void invalidateRect(const IntRect&) override;
 
@@ -148,7 +148,7 @@ protected:
     ScrollableArea& m_scrollableArea;
     ScrollbarOrientation m_orientation;
     ScrollbarControlSize m_controlSize;
-    ScrollbarTheme* m_theme;
+    ScrollbarTheme& m_theme;
 
     int m_visibleSize;
     int m_totalSize;
index 8ed2d95..d737e2d 100644 (file)
 
 namespace WebCore {
 
-ScrollbarTheme* ScrollbarTheme::theme()
+ScrollbarTheme& ScrollbarTheme::theme()
 {
     if (Settings::mockScrollbarsEnabled()) {
         DEPRECATED_DEFINE_STATIC_LOCAL(ScrollbarThemeMock, mockTheme, ());
-        return &mockTheme;
+        return mockTheme;
     }
     return nativeTheme();
 }
index 16bb252..e54c46a 100644 (file)
@@ -113,10 +113,10 @@ public:
 
     virtual bool isMockTheme() const { return false; }
 
-    WEBCORE_EXPORT static ScrollbarTheme* theme();
+    WEBCORE_EXPORT static ScrollbarTheme& theme();
 
 private:
-    static ScrollbarTheme* nativeTheme(); // Must be implemented to return the correct theme subclass.
+    static ScrollbarTheme& nativeTheme(); // Must be implemented to return the correct theme subclass.
 };
 
 }
index 2e135ba..d2c1773 100644 (file)
 
 namespace WebCore {
 
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
+ScrollbarTheme& ScrollbarTheme::nativeTheme()
 {
     static ScrollbarThemeEfl theme;
-    return &theme;
+    return theme;
 }
 
 static const int defaultThickness = 10;
index 9a153f6..70cf195 100644 (file)
 
 namespace WebCore {
 
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
+ScrollbarTheme& ScrollbarTheme::nativeTheme()
 {
     static ScrollbarThemeGtk theme;
-    return &theme;
+    return theme;
 }
 
 ScrollbarThemeGtk::~ScrollbarThemeGtk()
index edc1a59..517010e 100644 (file)
 
 namespace WebCore {
 
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
+ScrollbarTheme& ScrollbarTheme::nativeTheme()
 {
     static NeverDestroyed<ScrollbarThemeIOS> theme;
-    return &theme.get();
+    return theme;
 }
 
 void ScrollbarThemeIOS::registerScrollbar(Scrollbar&)
index 38c4446..eb8330a 100644 (file)
@@ -63,8 +63,8 @@ static bool supportsContentAreaScrolledInDirection()
 
 static ScrollbarThemeMac* macScrollbarTheme()
 {
-    ScrollbarTheme* scrollbarTheme = ScrollbarTheme::theme();
-    return !scrollbarTheme->isMockTheme() ? static_cast<ScrollbarThemeMac*>(scrollbarTheme) : 0;
+    ScrollbarTheme& scrollbarTheme = ScrollbarTheme::theme();
+    return !scrollbarTheme.isMockTheme() ? static_cast<ScrollbarThemeMac*>(&scrollbarTheme) : nullptr;
 }
 
 static ScrollbarPainter scrollbarPainterForScrollbar(Scrollbar& scrollbar)
index c33765f..e93d872 100644 (file)
@@ -38,6 +38,7 @@
 #include "WebCoreSystemInterface.h"
 #include <Carbon/Carbon.h>
 #include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/TemporaryChange.h>
 
@@ -77,11 +78,11 @@ static ScrollbarPainterMap* scrollbarMap()
 {
     UNUSED_PARAM(unusedNotification);
 
-    ScrollbarTheme* theme = ScrollbarTheme::theme();
-    if (theme->isMockTheme())
+    ScrollbarTheme& theme = ScrollbarTheme::theme();
+    if (theme.isMockTheme())
         return;
 
-    static_cast<ScrollbarThemeMac*>(ScrollbarTheme::theme())->preferencesChanged();
+    static_cast<ScrollbarThemeMac&>(theme).preferencesChanged();
     if (scrollbarMap()->isEmpty())
         return;
     ScrollbarPainterMap::iterator end = scrollbarMap()->end();
@@ -95,11 +96,11 @@ static ScrollbarPainterMap* scrollbarMap()
 {
     UNUSED_PARAM(unusedNotification);
 
-    ScrollbarTheme* theme = ScrollbarTheme::theme();
-    if (theme->isMockTheme())
+    ScrollbarTheme& theme = ScrollbarTheme::theme();
+    if (theme.isMockTheme())
         return;
 
-    static_cast<ScrollbarThemeMac*>(ScrollbarTheme::theme())->preferencesChanged();
+    static_cast<ScrollbarThemeMac&>(theme).preferencesChanged();
 }
 
 + (void)registerAsObserver
@@ -112,10 +113,10 @@ static ScrollbarPainterMap* scrollbarMap()
 
 namespace WebCore {
 
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
+ScrollbarTheme& ScrollbarTheme::nativeTheme()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(ScrollbarThemeMac, theme, ());
-    return &theme;
+    static NeverDestroyed<ScrollbarThemeMac> theme;
+    return theme;
 }
 
 // FIXME: Get these numbers from CoreUI.
index 6444893..45c1ac7 100644 (file)
@@ -352,7 +352,7 @@ void PopupMenuWin::calculatePositionAndSize(const IntRect& r, FrameView* v)
 
     if (naturalHeight > maxPopupHeight)
         // We need room for a scrollbar
-        popupWidth += ScrollbarTheme::theme()->scrollbarThickness(SmallScrollbar);
+        popupWidth += ScrollbarTheme::theme().scrollbarThickness(SmallScrollbar);
 
     // Add padding to align the popup text with the <select> text
     popupWidth += std::max<int>(0, client()->clientPaddingRight() - client()->clientInsetRight()) + std::max<int>(0, client()->clientPaddingLeft() - client()->clientInsetLeft());
@@ -1287,26 +1287,24 @@ HRESULT AccessiblePopupMenu::accLocation(long* left, long* top, long* width, lon
         Scrollbar& scrollbar = *m_popupMenu.scrollbar();
         WebCore::ScrollbarPart part = static_cast<WebCore::ScrollbarPart>(-vChild.lVal);
 
-        ScrollbarThemeWin* theme = static_cast<ScrollbarThemeWin*>(scrollbar.theme());
-        if (!theme)
-            return E_FAIL;
+        ScrollbarThemeWin& theme = static_cast<ScrollbarThemeWin&>(scrollbar.theme());
 
         IntRect partRect;
 
         switch (part) {
         case BackTrackPart:
         case BackButtonStartPart:
-            partRect = theme->backButtonRect(scrollbar, WebCore::BackTrackPart);
+            partRect = theme.backButtonRect(scrollbar, WebCore::BackTrackPart);
             break;
         case ThumbPart:
-            partRect = theme->thumbRect(scrollbar);
+            partRect = theme.thumbRect(scrollbar);
             break;
         case ForwardTrackPart:
         case ForwardButtonEndPart:
-            partRect = theme->forwardButtonRect(scrollbar, WebCore::ForwardTrackPart);
+            partRect = theme.forwardButtonRect(scrollbar, WebCore::ForwardTrackPart);
             break;
         case ScrollbarBGPart:
-            partRect = theme->trackRect(scrollbar);
+            partRect = theme.trackRect(scrollbar);
             break;
         default:
             return E_FAIL;
@@ -1358,12 +1356,10 @@ HRESULT AccessiblePopupMenu::accHitTest(long x, long y, VARIANT* pvChildAtPoint)
 
     if (m_popupMenu.scrollbar() && scrollRect.contains(pt)) {
         Scrollbar& scrollbar = *m_popupMenu.scrollbar();
-        if (!scrollbar.theme())
-            return E_FAIL;
 
         pt.move(-scrollRect.x(), -scrollRect.y());
 
-        WebCore::ScrollbarPart part = scrollbar.theme()->hitTest(scrollbar, pt);
+        WebCore::ScrollbarPart part = scrollbar.theme().hitTest(scrollbar, pt);
 
         V_VT(pvChildAtPoint) = VT_I4;
         V_I4(pvChildAtPoint) = -part; // Scrollbar parts are encoded as negative, to avoid mixup with item indexes.
index 6c90a9c..b774f86 100644 (file)
@@ -55,13 +55,13 @@ namespace WebCore {
 
 using namespace SafariTheme;
 
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
+ScrollbarTheme& ScrollbarTheme::nativeTheme()
 {
     static ScrollbarThemeSafari safariTheme;
     static ScrollbarThemeWin windowsTheme;
     if (Settings::shouldPaintNativeControls())
-        return &windowsTheme;
-    return &safariTheme;
+        return windowsTheme;
+    return safariTheme;
 }
 
 // FIXME: Get these numbers from CoreUI.
index 3a09444..28dfbfc 100644 (file)
@@ -89,10 +89,10 @@ static void checkAndInitScrollbarTheme()
         scrollbarTheme = OpenThemeData(0, L"Scrollbar");
 }
 
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
+ScrollbarTheme& ScrollbarTheme::nativeTheme()
 {
     static ScrollbarThemeWin winTheme;
-    return &winTheme;
+    return winTheme;
 }
 
 ScrollbarThemeWin::ScrollbarThemeWin()
index 8bc0f08..80e61f2 100644 (file)
@@ -954,13 +954,13 @@ void RenderBox::panScroll(const IntPoint& source)
 
 bool RenderBox::hasVerticalScrollbarWithAutoBehavior() const
 {
-    bool overflowScrollActsLikeAuto = style().overflowY() == OSCROLL && !style().hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme()->usesOverlayScrollbars();
+    bool overflowScrollActsLikeAuto = style().overflowY() == OSCROLL && !style().hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme().usesOverlayScrollbars();
     return hasOverflowClip() && (style().overflowY() == OAUTO || style().overflowY() == OOVERLAY || overflowScrollActsLikeAuto);
 }
 
 bool RenderBox::hasHorizontalScrollbarWithAutoBehavior() const
 {
-    bool overflowScrollActsLikeAuto = style().overflowX() == OSCROLL && !style().hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme()->usesOverlayScrollbars();
+    bool overflowScrollActsLikeAuto = style().overflowX() == OSCROLL && !style().hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme().usesOverlayScrollbars();
     return hasOverflowClip() && (style().overflowX() == OAUTO || style().overflowX() == OOVERLAY || overflowScrollActsLikeAuto);
 }
 
index 3797a76..89966d8 100644 (file)
@@ -2802,7 +2802,7 @@ static LayoutRect cornerRect(const RenderLayer* layer, const LayoutRect& bounds)
     if (!layer->verticalScrollbar() && !layer->horizontalScrollbar()) {
         // FIXME: This isn't right.  We need to know the thickness of custom scrollbars
         // even when they don't exist in order to set the resizer square size properly.
-        horizontalThickness = ScrollbarTheme::theme()->scrollbarThickness();
+        horizontalThickness = ScrollbarTheme::theme().scrollbarThickness();
         verticalThickness = horizontalThickness;
     } else if (layer->verticalScrollbar() && !layer->horizontalScrollbar()) {
         horizontalThickness = layer->verticalScrollbar()->width();
@@ -3382,14 +3382,14 @@ bool RenderLayer::hasVerticalOverflow() const
 static bool styleRequiresScrollbar(const RenderStyle& style, ScrollbarOrientation axis)
 {
     EOverflow overflow = axis == ScrollbarOrientation::HorizontalScrollbar ? style.overflowX() : style.overflowY();
-    bool overflowScrollActsLikeAuto = overflow == OSCROLL && !style.hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme()->usesOverlayScrollbars();
+    bool overflowScrollActsLikeAuto = overflow == OSCROLL && !style.hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme().usesOverlayScrollbars();
     return overflow == OSCROLL && !overflowScrollActsLikeAuto;
 }
 
 static bool styleDefinesAutomaticScrollbar(const RenderStyle& style, ScrollbarOrientation axis)
 {
     EOverflow overflow = axis == ScrollbarOrientation::HorizontalScrollbar ? style.overflowX() : style.overflowY();
-    bool overflowScrollActsLikeAuto = overflow == OSCROLL && !style.hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme()->usesOverlayScrollbars();
+    bool overflowScrollActsLikeAuto = overflow == OSCROLL && !style.hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme().usesOverlayScrollbars();
     return overflow == OAUTO || overflow == OOVERLAY || overflowScrollActsLikeAuto;
 }
 
index 277dac8..7d670e1 100644 (file)
@@ -218,7 +218,7 @@ void RenderScrollbar::updateScrollbarPart(ScrollbarPart partType)
 
     if (needRenderer && partStyle->display() != BLOCK) {
         // See if we are a button that should not be visible according to OS settings.
-        ScrollbarButtonsPlacement buttonsPlacement = theme()->buttonsPlacement();
+        ScrollbarButtonsPlacement buttonsPlacement = theme().buttonsPlacement();
         switch (partType) {
             case BackButtonStartPart:
                 needRenderer = (buttonsPlacement == ScrollbarButtonsSingle || buttonsPlacement == ScrollbarButtonsDoubleStart ||
index 0cbec0f..31d4370 100644 (file)
@@ -83,7 +83,7 @@ static int calcScrollbarThicknessUsing(SizeType sizeType, const Length& length,
 {
     if (!length.isIntrinsicOrAuto() || (sizeType == MinSize && length.isAuto()))
         return minimumValueForLength(length, containingLength);
-    return ScrollbarTheme::theme()->scrollbarThickness();
+    return ScrollbarTheme::theme().scrollbarThickness();
 }
 
 void RenderScrollbarPart::computeScrollbarWidth()
@@ -138,13 +138,13 @@ void RenderScrollbarPart::styleDidChange(StyleDifference diff, const RenderStyle
     setFloating(false);
     setHasOverflowClip(false);
     if (oldStyle && m_scrollbar && m_part != NoPart && diff >= StyleDifferenceRepaint)
-        m_scrollbar->theme()->invalidatePart(*m_scrollbar, m_part);
+        m_scrollbar->theme().invalidatePart(*m_scrollbar, m_part);
 }
 
 void RenderScrollbarPart::imageChanged(WrappedImagePtr image, const IntRect* rect)
 {
     if (m_scrollbar && m_part != NoPart)
-        m_scrollbar->theme()->invalidatePart(*m_scrollbar, m_part);
+        m_scrollbar->theme().invalidatePart(*m_scrollbar, m_part);
     else {
         if (view().frameView().isFrameViewScrollCorner(*this)) {
             view().frameView().invalidateScrollCorner(view().frameView().scrollCornerRect());
index db5288f..af96118 100644 (file)
@@ -158,7 +158,7 @@ void RenderScrollbarTheme::paintThumb(GraphicsContext& context, Scrollbar& scrol
 
 void RenderScrollbarTheme::paintTickmarks(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect)
 {
-    ScrollbarTheme::theme()->paintTickmarks(context, scrollbar, rect);
+    ScrollbarTheme::theme().paintTickmarks(context, scrollbar, rect);
 }
 
 }
index f7e419d..c099513 100644 (file)
@@ -38,21 +38,21 @@ class RenderScrollbarTheme final : public ScrollbarThemeComposite {
 public:
     virtual ~RenderScrollbarTheme() { }
     
-    virtual int scrollbarThickness(ScrollbarControlSize controlSize) override { return ScrollbarTheme::theme()->scrollbarThickness(controlSize); }
+    virtual int scrollbarThickness(ScrollbarControlSize controlSize) override { return ScrollbarTheme::theme().scrollbarThickness(controlSize); }
 
-    virtual ScrollbarButtonsPlacement buttonsPlacement() const override { return ScrollbarTheme::theme()->buttonsPlacement(); }
+    virtual ScrollbarButtonsPlacement buttonsPlacement() const override { return ScrollbarTheme::theme().buttonsPlacement(); }
 
     virtual bool supportsControlTints() const override { return true; }
 
     virtual void paintScrollCorner(ScrollView*, GraphicsContext&, const IntRect& cornerRect) override;
 
-    virtual bool shouldCenterOnThumb(Scrollbar& scrollbar, const PlatformMouseEvent& event) override { return ScrollbarTheme::theme()->shouldCenterOnThumb(scrollbar, event); }
+    virtual bool shouldCenterOnThumb(Scrollbar& scrollbar, const PlatformMouseEvent& event) override { return ScrollbarTheme::theme().shouldCenterOnThumb(scrollbar, event); }
     
-    virtual double initialAutoscrollTimerDelay() override { return ScrollbarTheme::theme()->initialAutoscrollTimerDelay(); }
-    virtual double autoscrollTimerDelay() override { return ScrollbarTheme::theme()->autoscrollTimerDelay(); }
+    virtual double initialAutoscrollTimerDelay() override { return ScrollbarTheme::theme().initialAutoscrollTimerDelay(); }
+    virtual double autoscrollTimerDelay() override { return ScrollbarTheme::theme().autoscrollTimerDelay(); }
 
-    virtual void registerScrollbar(Scrollbar& scrollbar) override { return ScrollbarTheme::theme()->registerScrollbar(scrollbar); }
-    virtual void unregisterScrollbar(Scrollbar& scrollbar) override { return ScrollbarTheme::theme()->unregisterScrollbar(scrollbar); }
+    virtual void registerScrollbar(Scrollbar& scrollbar) override { return ScrollbarTheme::theme().registerScrollbar(scrollbar); }
+    virtual void unregisterScrollbar(Scrollbar& scrollbar) override { return ScrollbarTheme::theme().unregisterScrollbar(scrollbar); }
 
     virtual int minimumThumbLength(Scrollbar&) override;
 
index 7df383c..5e2f4e7 100644 (file)
@@ -138,7 +138,7 @@ int RenderTextControl::textBlockLogicalWidth() const
 int RenderTextControl::scrollbarThickness() const
 {
     // FIXME: We should get the size of the scrollbar from the RenderTheme instead.
-    return ScrollbarTheme::theme()->scrollbarThickness();
+    return ScrollbarTheme::theme().scrollbarThickness();
 }
 
 void RenderTextControl::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const
index bac1d6f..0ab6166 100644 (file)
@@ -524,7 +524,7 @@ bool RenderThemeEfl::loadTheme()
 
     const char* thickness = edje_object_data_get(m_edje.get(), "scrollbar.thickness");
     if (thickness && !Settings::mockScrollbarsEnabled())
-        static_cast<ScrollbarThemeEfl*>(ScrollbarTheme::theme())->setScrollbarThickness(atoi(thickness));
+        static_cast<ScrollbarThemeEfl&>(ScrollbarTheme::theme()).setScrollbarThickness(atoi(thickness));
 
     edje_object_signal_callback_add(edje(), "color_class,set", "webkit/selection/foreground", applyColorCallback, this);
     edje_object_signal_callback_add(edje(), "color_class,set", "webkit/selection/background", applyColorCallback, this);
index fefbb24..121f098 100644 (file)
@@ -142,7 +142,7 @@ static void gtkStyleChangedCallback(GObject*, GParamSpec*)
 {
     for (const auto& styleContext : styleContextMap())
         gtk_style_context_invalidate(styleContext.value.get());
-    static_cast<ScrollbarThemeGtk*>(ScrollbarTheme::theme())->themeChanged();
+    static_cast<ScrollbarThemeGtk&>(ScrollbarTheme::theme()).themeChanged();
     Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
 }
 
index 2f21466..49a1248 100644 (file)
@@ -1,3 +1,14 @@
+2015-09-02  Andreas Kling  <akling@apple.com>
+
+        ScrollbarThemes should be returned by reference.
+        <https://webkit.org/b/147551>
+
+        Reviewed by Zalan Bujtas.
+
+        * WebView.cpp:
+        (WebView::gestureNotify):
+        (WebView::WebViewWndProc):
+
 2015-08-31  Chris Dumez  <cdumez@apple.com>
 
         Range API is throwing wrong exception type
index 96d8769..b7af2cb 100644 (file)
@@ -1687,8 +1687,8 @@ bool WebView::gestureNotify(WPARAM wParam, LPARAM lParam)
         // The hit testing above won't detect if we've hit the main frame's vertical scrollbar. Check that manually now.
         RECT webViewRect;
         GetWindowRect(m_viewWindow, &webViewRect);
-        hitScrollbar = (view->verticalScrollbar() && (gestureBeginPoint.x > (webViewRect.right - view->verticalScrollbar()->theme()->scrollbarThickness()))) 
-            || (view->horizontalScrollbar() && (gestureBeginPoint.y > (webViewRect.bottom - view->horizontalScrollbar()->theme()->scrollbarThickness())));  
+        hitScrollbar = (view->verticalScrollbar() && (gestureBeginPoint.x > (webViewRect.right - view->verticalScrollbar()->theme().scrollbarThickness()))) 
+            || (view->horizontalScrollbar() && (gestureBeginPoint.y > (webViewRect.bottom - view->horizontalScrollbar()->theme().scrollbarThickness())));  
     }
 
     bool canBeScrolled = false;
@@ -2467,7 +2467,7 @@ LRESULT CALLBACK WebView::WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam,
             if (Frame* coreFrame = core(mainFrameImpl)) {
                 webView->deleteBackingStore();
                 coreFrame->page()->theme().themeChanged();
-                ScrollbarTheme::theme()->themeChanged();
+                ScrollbarTheme::theme().themeChanged();
                 RECT windowRect;
                 ::GetClientRect(hWnd, &windowRect);
                 ::InvalidateRect(hWnd, &windowRect, false);
index 7c65f28..18fd9d2 100644 (file)
@@ -1,3 +1,13 @@
+2015-09-02  Andreas Kling  <akling@apple.com>
+
+        ScrollbarThemes should be returned by reference.
+        <https://webkit.org/b/147551>
+
+        Reviewed by Zalan Bujtas.
+
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::paintControlForLayerInContext):
+
 2015-09-02  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
 
         REGRESSION(r188206): [EFL] Adjust scrollbar width to ewk_view_contents_size_get API test 
index 111a225..53dbfa5 100644 (file)
@@ -1132,7 +1132,7 @@ void PDFPlugin::paintControlForLayerInContext(CALayer *layer, CGContextRef conte
     if (layer == m_scrollCornerLayer) {
         IntRect scrollCornerRect = this->scrollCornerRect();
         graphicsContext.translate(-scrollCornerRect.x(), -scrollCornerRect.y());
-        ScrollbarTheme::theme()->paintScrollCorner(nullptr, graphicsContext, scrollCornerRect);
+        ScrollbarTheme::theme().paintScrollCorner(nullptr, graphicsContext, scrollCornerRect);
         return;
     }