[chromium] Fix crash in DragImageTest caused by r122996
[WebKit-https.git] / Source / WebCore / platform / chromium / DragImageChromiumSkia.cpp
index 40f8925a540f5a4a6d4289fd921f59f22e5cad87..dd8ace385c248308fb6b301a42efa89e7364f325 100644 (file)
@@ -47,11 +47,13 @@ IntSize dragImageSize(DragImageRef image)
     if (!image)
         return IntSize();
 
     if (!image)
         return IntSize();
 
-    return IntSize(image->width(), image->height());
+    return IntSize(image->bitmap->width(), image->bitmap->height());
 }
 
 void deleteDragImage(DragImageRef image)
 {
 }
 
 void deleteDragImage(DragImageRef image)
 {
+    if (image)
+        delete image->bitmap;
     delete image;
 }
 
     delete image;
 }
 
@@ -60,13 +62,14 @@ DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
     if (!image)
         return 0;
 
     if (!image)
         return 0;
 
-    int imageWidth = scale.width() * image->width();
-    int imageHeight = scale.height() * image->height();
-    DragImageRef scaledImage = new SkBitmap(
-        skia::ImageOperations::Resize(*image, skia::ImageOperations::RESIZE_LANCZOS3,
+    int imageWidth = scale.width() * image->bitmap->width();
+    int imageHeight = scale.height() * image->bitmap->height();
+    SkBitmap* scaledImage = new SkBitmap(
+        skia::ImageOperations::Resize(*image->bitmap, skia::ImageOperations::RESIZE_LANCZOS3,
                                       imageWidth, imageHeight));
                                       imageWidth, imageHeight));
-    delete image;
-    return scaledImage;
+    delete image->bitmap;
+    image->bitmap = scaledImage;
+    return image;
 }
 
 DragImageRef dissolveDragImageToFraction(DragImageRef image, float fraction)
 }
 
 DragImageRef dissolveDragImageToFraction(DragImageRef image, float fraction)
@@ -74,12 +77,12 @@ DragImageRef dissolveDragImageToFraction(DragImageRef image, float fraction)
     if (!image)
         return 0;
 
     if (!image)
         return 0;
 
-    image->setIsOpaque(false);
-    image->lockPixels();
+    image->bitmap->setIsOpaque(false);
+    image->bitmap->lockPixels();
 
 
-    for (int row = 0; row < image->height(); ++row) {
-        for (int column = 0; column < image->width(); ++column) {
-            uint32_t* pixel = image->getAddr32(column, row);
+    for (int row = 0; row < image->bitmap->height(); ++row) {
+        for (int column = 0; column < image->bitmap->width(); ++column) {
+            uint32_t* pixel = image->bitmap->getAddr32(column, row);
             *pixel = SkPreMultiplyARGB(SkColorGetA(*pixel) * fraction,
                                        SkColorGetR(*pixel),
                                        SkColorGetG(*pixel),
             *pixel = SkPreMultiplyARGB(SkColorGetA(*pixel) * fraction,
                                        SkColorGetR(*pixel),
                                        SkColorGetG(*pixel),
@@ -87,7 +90,7 @@ DragImageRef dissolveDragImageToFraction(DragImageRef image, float fraction)
         }
     }
 
         }
     }
 
-    image->unlockPixels();
+    image->bitmap->unlockPixels();
 
     return image;
 }
 
     return image;
 }
@@ -103,7 +106,10 @@ DragImageRef createDragImageFromImage(Image* image, RespectImageOrientationEnum)
 
     SkBitmap* dragImage = new SkBitmap();
     bitmap->bitmap().copyTo(dragImage, SkBitmap::kARGB_8888_Config);
 
     SkBitmap* dragImage = new SkBitmap();
     bitmap->bitmap().copyTo(dragImage, SkBitmap::kARGB_8888_Config);
-    return dragImage;
+    DragImageChromium* dragImageChromium = new DragImageChromium;
+    dragImageChromium->bitmap = dragImage;
+    dragImageChromium->resolutionScale = bitmap->resolutionScale();
+    return dragImageChromium;
 }
 
 DragImageRef createDragImageIconForCachedImage(CachedImage*)
 }
 
 DragImageRef createDragImageIconForCachedImage(CachedImage*)