Introduce IMAGE_TYPE_CASTS, and use it
authorgyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Dec 2013 05:20:32 +0000 (05:20 +0000)
committergyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Dec 2013 05:20:32 +0000 (05:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125330

Reviewed by Ryosuke Niwa.

Source/WebCore:

As a step to use TYPE_CASTS_BASE, this cl introduce IMAGE_TYPE_CASTS.
BitmapImage and SVGImage can use it to generate toFoo() type case helper functions.

No new tests, no behavior changes.

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::imageSizeForRenderer):
(WebCore::CachedImage::resumeAnimatingImagesForLoader):
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/mac/DragImageMac.mm:
(WebCore::createDragImageFromImage):
* svg/graphics/SVGImage.h:

Source/WebKit2:

As a step to use TYPE_CASTS_BASE, this cl introduce IMAGE_TYPE_CASTS.
BitmapImage, SVGImage can use it to generate toFoo() type case helper functions.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::pluginSnapshotTimerFired):

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

Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/platform/graphics/BitmapImage.h
Source/WebCore/platform/graphics/Image.h
Source/WebCore/platform/mac/DragImageMac.mm
Source/WebCore/svg/graphics/SVGImage.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PluginView.cpp

index 7dfc27e..1307821 100644 (file)
@@ -1,3 +1,24 @@
+2013-12-05  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Introduce IMAGE_TYPE_CASTS, and use it
+        https://bugs.webkit.org/show_bug.cgi?id=125330
+
+        Reviewed by Ryosuke Niwa.
+
+        As a step to use TYPE_CASTS_BASE, this cl introduce IMAGE_TYPE_CASTS.
+        BitmapImage and SVGImage can use it to generate toFoo() type case helper functions.
+
+        No new tests, no behavior changes.
+
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::imageSizeForRenderer):
+        (WebCore::CachedImage::resumeAnimatingImagesForLoader):
+        * platform/graphics/BitmapImage.h:
+        * platform/graphics/Image.h:
+        * platform/mac/DragImageMac.mm:
+        (WebCore::createDragImageFromImage):
+        * svg/graphics/SVGImage.h:
+
 2013-12-05  Zoltan Horvath  <zoltan@webkit.org>
 
         Clean up the forwarding headers of RenderBlock.h
index 94d9a07..7eb1ce7 100644 (file)
@@ -263,11 +263,11 @@ LayoutSize CachedImage::imageSizeForRenderer(const RenderObject* renderer, float
     if (renderer && m_image->isBitmapImage()) {
         ImageOrientationDescription orientationDescription(renderer->shouldRespectImageOrientation(), renderer->style().imageOrientation());
         if (orientationDescription.respectImageOrientation() == RespectImageOrientation)
-            imageSize = static_cast<BitmapImage*>(m_image.get())->sizeRespectingOrientation(orientationDescription);
+            imageSize = toBitmapImage(m_image.get())->sizeRespectingOrientation(orientationDescription);
     }
 #else
     if (m_image->isBitmapImage() && (renderer && renderer->shouldRespectImageOrientation() == RespectImageOrientation))
-        imageSize = static_cast<BitmapImage*>(m_image.get())->sizeRespectingOrientation();
+        imageSize = toBitmapImage(m_image.get())->sizeRespectingOrientation();
 #endif
 
 #if ENABLE(SVG)
@@ -529,7 +529,7 @@ void CachedImage::resumeAnimatingImagesForLoader(CachedResourceLoader* loader)
         Image* image = cachedImage->image();
         if (!image->isBitmapImage())
             continue;
-        BitmapImage* bitmapImage = static_cast<BitmapImage*>(image);
+        BitmapImage* bitmapImage = toBitmapImage(image);
         if (!bitmapImage->canAnimate())
             continue;
         cachedImage->animationAdvanced(bitmapImage);
index 66650d3..4ba9c24 100644 (file)
@@ -300,6 +300,8 @@ private:
     RefPtr<Image> m_cachedImage;
 };
 
+IMAGE_TYPE_CASTS(BitmapImage)
+
 }
 
 #endif
index 4104625..f8d61c9 100644 (file)
@@ -209,6 +209,9 @@ private:
     FloatSize m_space;
 };
 
+#define IMAGE_TYPE_CASTS(ToClassName) \
+    TYPE_CASTS_BASE(ToClassName, Image, image, image->is##ToClassName(), image.is##ToClassName())
+
 }
 
 #endif
index 63a5356..b8dae8a 100644 (file)
@@ -86,7 +86,7 @@ RetainPtr<NSImage> createDragImageFromImage(Image* image, ImageOrientationDescri
 
     if (image->isBitmapImage()) {
         ImageOrientation orientation;
-        BitmapImage* bitmapImage = static_cast<BitmapImage *>(image);
+        BitmapImage* bitmapImage = toBitmapImage(image);
         IntSize sizeRespectingOrientation = bitmapImage->sizeRespectingOrientation(description);
 
         if (description.respectImageOrientation() == RespectImageOrientation)
index 3c95a5c..b18ccba 100644 (file)
@@ -102,7 +102,10 @@ private:
 
 bool isInSVGImage(const Element*);
 
+IMAGE_TYPE_CASTS(SVGImage)
+
 }
 
+
 #endif // ENABLE(SVG)
 #endif // SVGImage_h
index 54ee641..b82ca2f 100644 (file)
@@ -1,3 +1,16 @@
+2013-12-05  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Introduce IMAGE_TYPE_CASTS, and use it
+        https://bugs.webkit.org/show_bug.cgi?id=125330
+
+        Reviewed by Ryosuke Niwa.
+
+        As a step to use TYPE_CASTS_BASE, this cl introduce IMAGE_TYPE_CASTS.
+        BitmapImage, SVGImage can use it to generate toFoo() type case helper functions.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::pluginSnapshotTimerFired):
+
 2013-12-05  Mark Lam  <mark.lam@apple.com>
 
         C Loop LLINT layout test regressions.
index 9738460..e00d3a2 100644 (file)
@@ -1683,7 +1683,7 @@ void PluginView::pluginSnapshotTimerFired(DeferrableOneShotTimer<PluginView>*)
 
 #if PLATFORM(MAC)
         unsigned maximumSnapshotRetries = frame() ? frame()->settings().maximumPlugInSnapshotAttempts() : 0;
-        if (snapshotImage && isAlmostSolidColor(static_cast<BitmapImage*>(snapshotImage.get())) && m_countSnapshotRetries < maximumSnapshotRetries) {
+        if (snapshotImage && isAlmostSolidColor(toBitmapImage(snapshotImage.get())) && m_countSnapshotRetries < maximumSnapshotRetries) {
             ++m_countSnapshotRetries;
             m_pluginSnapshotTimer.restart();
             return;