Title: [136147] trunk/Source/WebCore
Revision
136147
Author
[email protected]
Date
2012-11-29 12:12:54 -0800 (Thu, 29 Nov 2012)

Log Message

Be consistent in handling of frameAtIndex (and related) returns.
https://bugs.webkit.org/show_bug.cgi?id=103207

Patch by Brent Fulgham <[email protected]> on 2012-11-29
Reviewed by David Hyatt.

Under various conditions, frameAtIndex (and therefore,
nativeImageForCurrentFrame) returns null. A series of bugs over
the years has ensured null returns are handled in some cases,
but there are a handful of remaining cases where this is still a
problem.

No new tests, as these low-level functions are covered by
numerous existing test cases.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (136146 => 136147)


--- trunk/Source/WebCore/ChangeLog	2012-11-29 20:11:06 UTC (rev 136146)
+++ trunk/Source/WebCore/ChangeLog	2012-11-29 20:12:54 UTC (rev 136147)
@@ -1,3 +1,19 @@
+2012-11-29  Brent Fulgham  <[email protected]>
+
+        Be consistent in handling of frameAtIndex (and related) returns.
+        https://bugs.webkit.org/show_bug.cgi?id=103207
+
+        Reviewed by David Hyatt.
+
+        Under various conditions, frameAtIndex (and therefore,
+        nativeImageForCurrentFrame) returns null. A series of bugs over
+        the years has ensured null returns are handled in some cases,
+        but there are a handful of remaining cases where this is still a
+        problem. 
+
+        No new tests, as these low-level functions are covered by
+        numerous existing test cases.
+
 2012-11-29  David Hyatt  <[email protected]>
 
         [New Multicolumn] Add minimum column height tracking and forced break tracking to column sets.

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp (136146 => 136147)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp	2012-11-29 20:11:06 UTC (rev 136146)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp	2012-11-29 20:12:54 UTC (rev 136147)
@@ -179,7 +179,8 @@
         OwnPtr<NativeImageCairo> nativeImage = adoptPtr(decoder.createFrameAtIndex(0));
         imageSurface = nativeImage->surface();
     } else {
-        imageSurface = image->nativeImageForCurrentFrame()->surface();
+        NativeImageCairo* nativeImage = image->nativeImageForCurrentFrame();
+        imageSurface = (nativeImage) ? nativeImage->surface() : 0;
         if (!premultiplyAlpha)
             alphaOp = AlphaDoUnmultiply;
     }

Modified: trunk/Source/WebCore/platform/graphics/filters/skia/FEBlendSkia.cpp (136146 => 136147)


--- trunk/Source/WebCore/platform/graphics/filters/skia/FEBlendSkia.cpp	2012-11-29 20:11:06 UTC (rev 136146)
+++ trunk/Source/WebCore/platform/graphics/filters/skia/FEBlendSkia.cpp	2012-11-29 20:12:54 UTC (rev 136147)
@@ -72,9 +72,15 @@
     RefPtr<Image> foreground = in->asImageBuffer()->copyImage(DontCopyBackingStore);
     RefPtr<Image> background = ""
 
-    SkBitmap foregroundBitmap = foreground->nativeImageForCurrentFrame()->bitmap();
-    SkBitmap backgroundBitmap = background->nativeImageForCurrentFrame()->bitmap();
+    NativeImageSkia* foregroundNativeImage = foreground->nativeImageForCurrentFrame();
+    NativeImageSkia* backgroundNativeImage = background->nativeImageForCurrentFrame();
 
+    if (!foregroundNativeImage || !backgroundNativeImage)
+        return false;
+
+    SkBitmap foregroundBitmap = foregroundNativeImage->bitmap();
+    SkBitmap backgroundBitmap = backgroundNativeImage->bitmap();
+
     SkAutoTUnref<SkImageFilter> backgroundSource(new SkBitmapSource(backgroundBitmap));
     SkBlendImageFilter::Mode mode = toSkiaMode(m_mode);
     SkAutoTUnref<SkImageFilter> blend(new SkBlendImageFilter(mode, backgroundSource));

Modified: trunk/Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp (136146 => 136147)


--- trunk/Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp	2012-11-29 20:11:06 UTC (rev 136146)
+++ trunk/Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp	2012-11-29 20:12:54 UTC (rev 136147)
@@ -43,7 +43,9 @@
         return false;
 
     RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
-    SkBitmap bitmap = image->nativeImageForCurrentFrame()->bitmap();
+    NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
+    if (!nativeImage)
+        return false;
 
     unsigned char rValues[256], gValues[256], bValues[256], aValues[256];
     getValues(rValues, gValues, bValues, aValues);
@@ -51,7 +53,7 @@
     SkPaint paint;
     paint.setColorFilter(SkTableColorFilter::CreateARGB(aValues, rValues, gValues, bValues))->unref();
     paint.setXfermodeMode(SkXfermode::kSrc_Mode);
-    resultImage->context()->platformContext()->drawBitmap(bitmap, 0, 0, &paint);
+    resultImage->context()->platformContext()->drawBitmap(nativeImage->bitmap(), 0, 0, &paint);
 
     return true;
 }

Modified: trunk/Source/WebCore/platform/graphics/filters/skia/FELightingSkia.cpp (136146 => 136147)


--- trunk/Source/WebCore/platform/graphics/filters/skia/FELightingSkia.cpp	2012-11-29 20:11:06 UTC (rev 136146)
+++ trunk/Source/WebCore/platform/graphics/filters/skia/FELightingSkia.cpp	2012-11-29 20:12:54 UTC (rev 136147)
@@ -98,6 +98,8 @@
 
     RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
     NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
+    if (!nativeImage)
+        return false;
 
     GraphicsContext* dstContext = resultImage->context();
 

Modified: trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp (136146 => 136147)


--- trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp	2012-11-29 20:11:06 UTC (rev 136146)
+++ trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp	2012-11-29 20:12:54 UTC (rev 136147)
@@ -503,6 +503,9 @@
         qtImage = QImage::fromData(reinterpret_cast<const uchar*>(image->data()->data()), image->data()->size());
     else {
         QPixmap* nativePixmap = image->nativeImageForCurrentFrame();
+        if (!nativePixmap)
+            return false;
+
         // With QPA, we can avoid a deep copy.
         qtImage = *nativePixmap->handle()->buffer();
     }

Modified: trunk/Source/WebCore/platform/graphics/win/ImageCGWin.cpp (136146 => 136147)


--- trunk/Source/WebCore/platform/graphics/win/ImageCGWin.cpp	2012-11-29 20:11:06 UTC (rev 136146)
+++ trunk/Source/WebCore/platform/graphics/win/ImageCGWin.cpp	2012-11-29 20:12:54 UTC (rev 136147)
@@ -91,7 +91,7 @@
     size_t frames = frameCount();
     for (size_t i = 0; i < frames; ++i) {
         CGImageRef image = frameAtIndex(i);
-        if (CGImageGetHeight(image) == static_cast<size_t>(srcSize.height()) && CGImageGetWidth(image) == static_cast<size_t>(srcSize.width())) {
+        if (image && CGImageGetHeight(image) == static_cast<size_t>(srcSize.height()) && CGImageGetWidth(image) == static_cast<size_t>(srcSize.width())) {
             size_t currentFrame = m_currentFrame;
             m_currentFrame = i;
             draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), styleColorSpace, compositeOp);

Modified: trunk/Source/WebCore/platform/graphics/wince/ImageWinCE.cpp (136146 => 136147)


--- trunk/Source/WebCore/platform/graphics/wince/ImageWinCE.cpp	2012-11-29 20:11:06 UTC (rev 136146)
+++ trunk/Source/WebCore/platform/graphics/wince/ImageWinCE.cpp	2012-11-29 20:12:54 UTC (rev 136147)
@@ -118,16 +118,17 @@
     else {
         IntRect intSrcRect(srcRectIn);
         RefPtr<SharedBitmap> bmp = frameAtIndex(m_currentFrame);
+        if (bmp) {
+            if (bmp->width() != m_source.size().width()) {
+                double scaleFactor = static_cast<double>(bmp->width()) / m_source.size().width();
 
-        if (bmp->width() != m_source.size().width()) {
-            double scaleFactor = static_cast<double>(bmp->width()) / m_source.size().width();
-
-            intSrcRect.setX(stableRound(srcRectIn.x() * scaleFactor));
-            intSrcRect.setWidth(stableRound(srcRectIn.width() * scaleFactor));
-            intSrcRect.setY(stableRound(srcRectIn.y() * scaleFactor));
-            intSrcRect.setHeight(stableRound(srcRectIn.height() * scaleFactor));
+                intSrcRect.setX(stableRound(srcRectIn.x() * scaleFactor));
+                intSrcRect.setWidth(stableRound(srcRectIn.width() * scaleFactor));
+                intSrcRect.setY(stableRound(srcRectIn.y() * scaleFactor));
+                intSrcRect.setHeight(stableRound(srcRectIn.height() * scaleFactor));
+            }
+            bmp->draw(ctxt, enclosingIntRect(dstRect), intSrcRect, styleColorSpace, compositeOp);
         }
-        bmp->draw(ctxt, enclosingIntRect(dstRect), intSrcRect, styleColorSpace, compositeOp);
     }
 
     startAnimation();

Modified: trunk/Source/WebCore/platform/win/DragImageCGWin.cpp (136146 => 136147)


--- trunk/Source/WebCore/platform/win/DragImageCGWin.cpp	2012-11-29 20:11:06 UTC (rev 136146)
+++ trunk/Source/WebCore/platform/win/DragImageCGWin.cpp	2012-11-29 20:12:54 UTC (rev 136147)
@@ -148,8 +148,10 @@
     CGContextScaleCTM(drawContext, 1, -1);
     CGContextSetFillColor(drawContext, white);
     CGContextFillRect(drawContext, rect);
-    CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
-    CGContextDrawImage(drawContext, rect, srcImage);
+    if (srcImage) {
+        CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
+        CGContextDrawImage(drawContext, rect, srcImage);
+    }
     CGContextRelease(drawContext);
 
 exit:

Modified: trunk/Source/WebCore/platform/win/DragImageCairoWin.cpp (136146 => 136147)


--- trunk/Source/WebCore/platform/win/DragImageCairoWin.cpp	2012-11-29 20:11:06 UTC (rev 136146)
+++ trunk/Source/WebCore/platform/win/DragImageCairoWin.cpp	2012-11-29 20:12:54 UTC (rev 136147)
@@ -173,11 +173,14 @@
     cairo_set_source_rgb(cr, 1.0, 0.0, 1.0);
     cairo_fill_preserve(cr);
 
-    cairo_surface_t* srcImage = img->nativeImageForCurrentFrame()->surface();
+    NativeImageCairo* srcNativeImage = img->nativeImageForCurrentFrame();
+    cairo_surface_t* srcImage = (srcNativeImage) ? srcNativeImage->surface() : 0;
 
-    // Draw the image.
-    cairo_set_source_surface(cr, srcImage, 0.0, 0.0);
-    cairo_paint(cr);
+    if (srcImage) {
+        // Draw the image.
+        cairo_set_source_surface(cr, srcImage, 0.0, 0.0);
+        cairo_paint(cr);
+    }
 
     deallocContext(drawContext);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to