summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderScrollbarTheme.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderScrollbarTheme.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/RenderScrollbarTheme.cpp')
-rw-r--r--Source/WebCore/rendering/RenderScrollbarTheme.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/Source/WebCore/rendering/RenderScrollbarTheme.cpp b/Source/WebCore/rendering/RenderScrollbarTheme.cpp
index 9b9f67155..1692ddcae 100644
--- a/Source/WebCore/rendering/RenderScrollbarTheme.cpp
+++ b/Source/WebCore/rendering/RenderScrollbarTheme.cpp
@@ -26,24 +26,24 @@
#include "config.h"
#include "RenderScrollbarTheme.h"
#include "RenderScrollbar.h"
-#include "ScrollbarThemeClient.h"
+#include <wtf/NeverDestroyed.h>
#include <wtf/StdLibExtras.h>
namespace WebCore {
RenderScrollbarTheme* RenderScrollbarTheme::renderScrollbarTheme()
{
- DEFINE_STATIC_LOCAL(RenderScrollbarTheme, theme, ());
- return &theme;
+ static NeverDestroyed<RenderScrollbarTheme> theme;
+ return &theme.get();
}
-void RenderScrollbarTheme::buttonSizesAlongTrackAxis(ScrollbarThemeClient* scrollbar, int& beforeSize, int& afterSize)
+void RenderScrollbarTheme::buttonSizesAlongTrackAxis(Scrollbar& scrollbar, int& beforeSize, int& afterSize)
{
IntRect firstButton = backButtonRect(scrollbar, BackButtonStartPart);
IntRect secondButton = forwardButtonRect(scrollbar, ForwardButtonStartPart);
IntRect thirdButton = backButtonRect(scrollbar, BackButtonEndPart);
IntRect fourthButton = forwardButtonRect(scrollbar, ForwardButtonEndPart);
- if (scrollbar->orientation() == HorizontalScrollbar) {
+ if (scrollbar.orientation() == HorizontalScrollbar) {
beforeSize = firstButton.width() + secondButton.width();
afterSize = thirdButton.width() + fourthButton.width();
} else {
@@ -52,52 +52,52 @@ void RenderScrollbarTheme::buttonSizesAlongTrackAxis(ScrollbarThemeClient* scrol
}
}
-bool RenderScrollbarTheme::hasButtons(ScrollbarThemeClient* scrollbar)
+bool RenderScrollbarTheme::hasButtons(Scrollbar& scrollbar)
{
int startSize;
int endSize;
buttonSizesAlongTrackAxis(scrollbar, startSize, endSize);
- return (startSize + endSize) <= (scrollbar->orientation() == HorizontalScrollbar ? scrollbar->width() : scrollbar->height());
+ return (startSize + endSize) <= (scrollbar.orientation() == HorizontalScrollbar ? scrollbar.width() : scrollbar.height());
}
-bool RenderScrollbarTheme::hasThumb(ScrollbarThemeClient* scrollbar)
+bool RenderScrollbarTheme::hasThumb(Scrollbar& scrollbar)
{
return trackLength(scrollbar) - thumbLength(scrollbar) >= 0;
}
-int RenderScrollbarTheme::minimumThumbLength(ScrollbarThemeClient* scrollbar)
+int RenderScrollbarTheme::minimumThumbLength(Scrollbar& scrollbar)
{
- return toRenderScrollbar(scrollbar)->minimumThumbLength();
+ return downcast<RenderScrollbar>(scrollbar).minimumThumbLength();
}
-IntRect RenderScrollbarTheme::backButtonRect(ScrollbarThemeClient* scrollbar, ScrollbarPart partType, bool)
+IntRect RenderScrollbarTheme::backButtonRect(Scrollbar& scrollbar, ScrollbarPart partType, bool)
{
- return toRenderScrollbar(scrollbar)->buttonRect(partType);
+ return downcast<RenderScrollbar>(scrollbar).buttonRect(partType);
}
-IntRect RenderScrollbarTheme::forwardButtonRect(ScrollbarThemeClient* scrollbar, ScrollbarPart partType, bool)
+IntRect RenderScrollbarTheme::forwardButtonRect(Scrollbar& scrollbar, ScrollbarPart partType, bool)
{
- return toRenderScrollbar(scrollbar)->buttonRect(partType);
+ return downcast<RenderScrollbar>(scrollbar).buttonRect(partType);
}
-IntRect RenderScrollbarTheme::trackRect(ScrollbarThemeClient* scrollbar, bool)
+IntRect RenderScrollbarTheme::trackRect(Scrollbar& scrollbar, bool)
{
if (!hasButtons(scrollbar))
- return scrollbar->frameRect();
+ return scrollbar.frameRect();
int startLength;
int endLength;
buttonSizesAlongTrackAxis(scrollbar, startLength, endLength);
- return toRenderScrollbar(scrollbar)->trackRect(startLength, endLength);
+ return downcast<RenderScrollbar>(scrollbar).trackRect(startLength, endLength);
}
-IntRect RenderScrollbarTheme::constrainTrackRectToTrackPieces(ScrollbarThemeClient* scrollbar, const IntRect& rect)
+IntRect RenderScrollbarTheme::constrainTrackRectToTrackPieces(Scrollbar& scrollbar, const IntRect& rect)
{
- IntRect backRect = toRenderScrollbar(scrollbar)->trackPieceRectWithMargins(BackTrackPart, rect);
- IntRect forwardRect = toRenderScrollbar(scrollbar)->trackPieceRectWithMargins(ForwardTrackPart, rect);
+ IntRect backRect = downcast<RenderScrollbar>(scrollbar).trackPieceRectWithMargins(BackTrackPart, rect);
+ IntRect forwardRect = downcast<RenderScrollbar>(scrollbar).trackPieceRectWithMargins(ForwardTrackPart, rect);
IntRect result = rect;
- if (scrollbar->orientation() == HorizontalScrollbar) {
+ if (scrollbar.orientation() == HorizontalScrollbar) {
result.setX(backRect.x());
result.setWidth(forwardRect.maxX() - backRect.x());
} else {
@@ -107,59 +107,59 @@ IntRect RenderScrollbarTheme::constrainTrackRectToTrackPieces(ScrollbarThemeClie
return result;
}
-void RenderScrollbarTheme::willPaintScrollbar(GraphicsContext* context, ScrollbarThemeClient* scrollbar)
+void RenderScrollbarTheme::willPaintScrollbar(GraphicsContext& context, Scrollbar& scrollbar)
{
- float opacity = toRenderScrollbar(scrollbar)->opacity();
+ float opacity = downcast<RenderScrollbar>(scrollbar).opacity();
if (opacity != 1) {
- context->save();
- context->clip(scrollbar->frameRect());
- context->beginTransparencyLayer(opacity);
+ context.save();
+ context.clip(scrollbar.frameRect());
+ context.beginTransparencyLayer(opacity);
}
}
-void RenderScrollbarTheme::didPaintScrollbar(GraphicsContext* context, ScrollbarThemeClient* scrollbar)
+void RenderScrollbarTheme::didPaintScrollbar(GraphicsContext& context, Scrollbar& scrollbar)
{
- float opacity = toRenderScrollbar(scrollbar)->opacity();
+ float opacity = downcast<RenderScrollbar>(scrollbar).opacity();
if (opacity != 1) {
- context->endTransparencyLayer();
- context->restore();
+ context.endTransparencyLayer();
+ context.restore();
}
}
-void RenderScrollbarTheme::paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& cornerRect)
+void RenderScrollbarTheme::paintScrollCorner(ScrollView*, GraphicsContext& context, const IntRect& cornerRect)
{
// FIXME: Implement.
- context->fillRect(cornerRect, Color::white, ColorSpaceDeviceRGB);
+ context.fillRect(cornerRect, Color::white);
}
-void RenderScrollbarTheme::paintScrollbarBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar)
+void RenderScrollbarTheme::paintScrollbarBackground(GraphicsContext& context, Scrollbar& scrollbar)
{
- toRenderScrollbar(scrollbar)->paintPart(context, ScrollbarBGPart, scrollbar->frameRect());
+ downcast<RenderScrollbar>(scrollbar).paintPart(context, ScrollbarBGPart, scrollbar.frameRect());
}
-void RenderScrollbarTheme::paintTrackBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
+void RenderScrollbarTheme::paintTrackBackground(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect)
{
- toRenderScrollbar(scrollbar)->paintPart(context, TrackBGPart, rect);
+ downcast<RenderScrollbar>(scrollbar).paintPart(context, TrackBGPart, rect);
}
-void RenderScrollbarTheme::paintTrackPiece(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect, ScrollbarPart part)
+void RenderScrollbarTheme::paintTrackPiece(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect, ScrollbarPart part)
{
- toRenderScrollbar(scrollbar)->paintPart(context, part, rect);
+ downcast<RenderScrollbar>(scrollbar).paintPart(context, part, rect);
}
-void RenderScrollbarTheme::paintButton(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect, ScrollbarPart part)
+void RenderScrollbarTheme::paintButton(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect, ScrollbarPart part)
{
- toRenderScrollbar(scrollbar)->paintPart(context, part, rect);
+ downcast<RenderScrollbar>(scrollbar).paintPart(context, part, rect);
}
-void RenderScrollbarTheme::paintThumb(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
+void RenderScrollbarTheme::paintThumb(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect)
{
- toRenderScrollbar(scrollbar)->paintPart(context, ThumbPart, rect);
+ downcast<RenderScrollbar>(scrollbar).paintPart(context, ThumbPart, rect);
}
-void RenderScrollbarTheme::paintTickmarks(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
+void RenderScrollbarTheme::paintTickmarks(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect)
{
- ScrollbarTheme::theme()->paintTickmarks(context, scrollbar, rect);
+ ScrollbarTheme::theme().paintTickmarks(context, scrollbar, rect);
}
}