Title: [174874] trunk/Source/WebCore
Revision
174874
Author
[email protected]
Date
2014-10-19 20:24:57 -0700 (Sun, 19 Oct 2014)

Log Message

Use SPECIALIZE_TYPE_TRAITS_*() macro for RenderScrollbar
https://bugs.webkit.org/show_bug.cgi?id=137854

Reviewed by Darin Adler.

Use SPECIALIZE_TYPE_TRAITS_*() macro for RenderScrollbar instead of a
custom toRenderScrollbar() function, for consistency.

No new tests, no behavior change.

* rendering/RenderScrollbar.h:
(isType):
(WebCore::toRenderScrollbar): Deleted.
* rendering/RenderScrollbarTheme.cpp:
(WebCore::RenderScrollbarTheme::minimumThumbLength):
(WebCore::RenderScrollbarTheme::backButtonRect):
(WebCore::RenderScrollbarTheme::forwardButtonRect):
(WebCore::RenderScrollbarTheme::trackRect):
(WebCore::RenderScrollbarTheme::constrainTrackRectToTrackPieces):
(WebCore::RenderScrollbarTheme::willPaintScrollbar):
(WebCore::RenderScrollbarTheme::didPaintScrollbar):
(WebCore::RenderScrollbarTheme::paintScrollbarBackground):
(WebCore::RenderScrollbarTheme::paintTrackBackground):
(WebCore::RenderScrollbarTheme::paintTrackPiece):
(WebCore::RenderScrollbarTheme::paintButton):
(WebCore::RenderScrollbarTheme::paintThumb):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (174873 => 174874)


--- trunk/Source/WebCore/ChangeLog	2014-10-19 18:14:43 UTC (rev 174873)
+++ trunk/Source/WebCore/ChangeLog	2014-10-20 03:24:57 UTC (rev 174874)
@@ -1,3 +1,32 @@
+2014-10-19  Chris Dumez  <[email protected]>
+
+        Use SPECIALIZE_TYPE_TRAITS_*() macro for RenderScrollbar
+        https://bugs.webkit.org/show_bug.cgi?id=137854
+
+        Reviewed by Darin Adler.
+
+        Use SPECIALIZE_TYPE_TRAITS_*() macro for RenderScrollbar instead of a
+        custom toRenderScrollbar() function, for consistency.
+
+        No new tests, no behavior change.
+
+        * rendering/RenderScrollbar.h:
+        (isType):
+        (WebCore::toRenderScrollbar): Deleted.
+        * rendering/RenderScrollbarTheme.cpp:
+        (WebCore::RenderScrollbarTheme::minimumThumbLength):
+        (WebCore::RenderScrollbarTheme::backButtonRect):
+        (WebCore::RenderScrollbarTheme::forwardButtonRect):
+        (WebCore::RenderScrollbarTheme::trackRect):
+        (WebCore::RenderScrollbarTheme::constrainTrackRectToTrackPieces):
+        (WebCore::RenderScrollbarTheme::willPaintScrollbar):
+        (WebCore::RenderScrollbarTheme::didPaintScrollbar):
+        (WebCore::RenderScrollbarTheme::paintScrollbarBackground):
+        (WebCore::RenderScrollbarTheme::paintTrackBackground):
+        (WebCore::RenderScrollbarTheme::paintTrackPiece):
+        (WebCore::RenderScrollbarTheme::paintButton):
+        (WebCore::RenderScrollbarTheme::paintThumb):
+
 2014-10-19  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Move GtkDragAndDropHelper from Platform to WebKit2

Modified: trunk/Source/WebCore/rendering/RenderScrollbar.h (174873 => 174874)


--- trunk/Source/WebCore/rendering/RenderScrollbar.h	2014-10-19 18:14:43 UTC (rev 174873)
+++ trunk/Source/WebCore/rendering/RenderScrollbar.h	2014-10-20 03:24:57 UTC (rev 174874)
@@ -88,15 +88,10 @@
     HashMap<unsigned, RenderPtr<RenderScrollbarPart>> m_parts;
 };
 
-inline RenderScrollbar* toRenderScrollbar(ScrollbarThemeClient* scrollbar)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!scrollbar || scrollbar->isCustomScrollbar());
-    return static_cast<RenderScrollbar*>(scrollbar);
-}
-
-// This will catch anyone doing an unnecessary cast.
-void toRenderScrollbar(const RenderScrollbar*);
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::RenderScrollbar)
+    static bool isType(const WebCore::ScrollbarThemeClient& scrollbar) { return scrollbar.isCustomScrollbar(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif // RenderScrollbar_h

Modified: trunk/Source/WebCore/rendering/RenderScrollbarTheme.cpp (174873 => 174874)


--- trunk/Source/WebCore/rendering/RenderScrollbarTheme.cpp	2014-10-19 18:14:43 UTC (rev 174873)
+++ trunk/Source/WebCore/rendering/RenderScrollbarTheme.cpp	2014-10-20 03:24:57 UTC (rev 174874)
@@ -67,17 +67,17 @@
 
 int RenderScrollbarTheme::minimumThumbLength(ScrollbarThemeClient* scrollbar)
 {
-    return toRenderScrollbar(scrollbar)->minimumThumbLength();
+    return downcast<RenderScrollbar>(*scrollbar).minimumThumbLength();
 }
 
 IntRect RenderScrollbarTheme::backButtonRect(ScrollbarThemeClient* scrollbar, ScrollbarPart partType, bool)
 {
-    return toRenderScrollbar(scrollbar)->buttonRect(partType);
+    return downcast<RenderScrollbar>(*scrollbar).buttonRect(partType);
 }
 
 IntRect RenderScrollbarTheme::forwardButtonRect(ScrollbarThemeClient* scrollbar, ScrollbarPart partType, bool)
 {
-    return toRenderScrollbar(scrollbar)->buttonRect(partType);
+    return downcast<RenderScrollbar>(*scrollbar).buttonRect(partType);
 }
 
 IntRect RenderScrollbarTheme::trackRect(ScrollbarThemeClient* scrollbar, bool)
@@ -89,13 +89,13 @@
     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 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) {
         result.setX(backRect.x());
@@ -109,7 +109,7 @@
 
 void RenderScrollbarTheme::willPaintScrollbar(GraphicsContext* context, ScrollbarThemeClient* scrollbar)
 {
-    float opacity = toRenderScrollbar(scrollbar)->opacity();
+    float opacity = downcast<RenderScrollbar>(*scrollbar).opacity();
     if (opacity != 1) {
         context->save();
         context->clip(scrollbar->frameRect());
@@ -119,7 +119,7 @@
 
 void RenderScrollbarTheme::didPaintScrollbar(GraphicsContext* context, ScrollbarThemeClient* scrollbar)
 {
-    float opacity = toRenderScrollbar(scrollbar)->opacity();
+    float opacity = downcast<RenderScrollbar>(*scrollbar).opacity();
     if (opacity != 1) {
         context->endTransparencyLayer();
         context->restore();
@@ -134,27 +134,27 @@
 
 void RenderScrollbarTheme::paintScrollbarBackground(GraphicsContext* context, ScrollbarThemeClient* 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)
 {
-    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)
 {
-    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)
 {
-    toRenderScrollbar(scrollbar)->paintPart(context, part, rect);
+    downcast<RenderScrollbar>(*scrollbar).paintPart(context, part, rect);
 }
 
 void RenderScrollbarTheme::paintThumb(GraphicsContext* context, ScrollbarThemeClient* 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)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to