Commit ff90543c authored by eric@webkit.org's avatar eric@webkit.org

2010-04-06 Nicolas Weber <thakis@chromium.org>

        Reviewed by Dimitri Glazkov.

        Implement DragImage functionality for chromium/mac.
        https://bugs.webkit.org/show_bug.cgi?id=37069

        * page/chromium/DragControllerChromium.cpp:
        (WebCore::DragController::maxDragImageSize):
        Use a max size of 400x400 on OS X.
        * platform/chromium/DragImageChromiumMac.cpp:
        (WebCore::dragImageSize): Implement.
        (WebCore::deleteDragImage): Implement.
        (WebCore::scaleDragImage): Implement.
        (WebCore::dissolveDragImageToFraction): Implement.
        (WebCore::createDragImageFromImage): Implement.
        * platform/chromium/DragImageRef.h:
        Use CGImageRefs as DragImageRef on OS X.
2010-04-06  Nicolas Weber  <thakis@chromium.org>

        Reviewed by Dimitri Glazkov.

        Use drag images on OS X as well.
        https://bugs.webkit.org/show_bug.cgi?id=37069

        * src/DragClientImpl.cpp:
        (WebKit::DragClientImpl::startDrag):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@57180 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3638c10b
2010-04-06 Nicolas Weber <thakis@chromium.org>
Reviewed by Dimitri Glazkov.
Implement DragImage functionality for chromium/mac.
https://bugs.webkit.org/show_bug.cgi?id=37069
* page/chromium/DragControllerChromium.cpp:
(WebCore::DragController::maxDragImageSize):
Use a max size of 400x400 on OS X.
* platform/chromium/DragImageChromiumMac.cpp:
(WebCore::dragImageSize): Implement.
(WebCore::deleteDragImage): Implement.
(WebCore::scaleDragImage): Implement.
(WebCore::dissolveDragImageToFraction): Implement.
(WebCore::createDragImageFromImage): Implement.
* platform/chromium/DragImageRef.h:
Use CGImageRefs as DragImageRef on OS X.
2010-04-06 Chris Evans <cevans@chromium.org>
Reviewed by Adam Barth.
......@@ -66,7 +66,12 @@ bool DragController::isCopyKeyDown()
const IntSize& DragController::maxDragImageSize()
{
#if OS(DARWIN)
// Match Safari's drag image size.
static const IntSize maxDragImageSize(400, 400);
#else
static const IntSize maxDragImageSize(200, 200);
#endif
return maxDragImageSize;
}
......
......@@ -31,37 +31,71 @@
#include "config.h"
#include "DragImage.h"
#include "Image.h"
#include "NotImplemented.h"
#include <CoreGraphics/CGBitmapContext.h>
#include <CoreGraphics/CGImage.h>
namespace WebCore {
IntSize dragImageSize(DragImageRef image)
{
notImplemented();
return IntSize();
if (!image)
return IntSize();
return IntSize(CGImageGetWidth(image), CGImageGetHeight(image));
}
void deleteDragImage(DragImageRef image)
{
notImplemented();
CGImageRelease(image);
}
DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
{
notImplemented();
return 0;
if (!image)
return 0;
size_t width = roundf(CGImageGetWidth(image) * scale.width());
size_t height = roundf(CGImageGetHeight(image) * scale.height());
CGContextRef context = CGBitmapContextCreate(0, width, height, 8, width * 4, CGImageGetColorSpace(image), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
if (!context)
return 0;
CGContextDrawImage(context, CGRectMake(0, 0, width, height), image);
CGImageRelease(image);
CGImageRef scaledImage = CGBitmapContextCreateImage(context);
CGContextRelease(context);
return scaledImage;
}
DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
DragImageRef dissolveDragImageToFraction(DragImageRef image, float delta)
{
notImplemented();
return image;
if (!image)
return 0;
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
CGContextRef context = CGBitmapContextCreate(0, width, height, 8, width * 4, CGImageGetColorSpace(image), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
if (!context)
return 0;
// From CGContext.h:
// The Porter-Duff "source over" mode is called `kCGBlendModeNormal':
// R = S + D*(1 - Sa)
// This is the same as NSCompositeSourceOver, which is what -[NSImage dissolveToPoint:fraction:] uses.
CGContextSetAlpha(context, delta);
CGContextSetBlendMode(context, kCGBlendModeNormal);
CGContextDrawImage(context, CGRectMake(0, 0, width, height), image);
CGImageRelease(image);
CGImageRef dissolvedImage = CGBitmapContextCreateImage(context);
CGContextRelease(context);
return dissolvedImage;
}
DragImageRef createDragImageFromImage(Image* img)
DragImageRef createDragImageFromImage(Image* image)
{
notImplemented();
return 0;
if (!image)
return 0;
return CGImageCreateCopy(image->nativeImageForCurrentFrame());
}
DragImageRef createDragImageIconForCachedImage(CachedImage*)
......
......@@ -29,13 +29,16 @@
#ifndef DragImageRef_h
#define DragImageRef_h
#if OS(DARWIN)
typedef struct CGImage* CGImageRef;
#else
class SkBitmap;
#endif
namespace WebCore {
#if OS(DARWIN)
// FIXME: not implemented.
typedef void* DragImageRef;
typedef CGImageRef DragImageRef;
#else
typedef SkBitmap* DragImageRef;
#endif
......
2010-04-06 Nicolas Weber <thakis@chromium.org>
Reviewed by Dimitri Glazkov.
Use drag images on OS X as well.
https://bugs.webkit.org/show_bug.cgi?id=37069
* src/DragClientImpl.cpp:
(WebKit::DragClientImpl::startDrag):
2010-04-06 Vangelis Kokkevis <vangelis@chromium.org>
Reviewed by Dimitri Glazkov.
......
......@@ -86,17 +86,14 @@ void DragClientImpl::startDrag(DragImageRef dragImage,
IntSize offsetSize(eventPos - dragImageOrigin);
WebPoint offsetPoint(offsetSize.width(), offsetSize.height());
#if WEBKIT_USING_SKIA
m_webView->startDragging(
dragData, static_cast<WebDragOperationsMask>(dragOperationMask),
dragImage ? WebImage(*dragImage) : WebImage(), offsetPoint);
#if WEBKIT_USING_SKIA
dragImage ? WebImage(*dragImage) : WebImage(),
#else
// FIXME: When DragImageRef is implemented for CG, we can probably just remove
// this #if fork. For now, pass an empty image.
m_webView->startDragging(
dragData, static_cast<WebDragOperationsMask>(dragOperationMask),
WebImage(), WebPoint());
dragImage ? WebImage(dragImage) : WebImage(),
#endif
offsetPoint);
}
DragImageRef DragClientImpl::createDragImageForLink(KURL&, const String& label, Frame*)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment