void DragClientImpl::startDrag(DragImage* dragImage,
                               const IntPoint& dragImageOrigin,
                               const IntPoint& eventPos,
                               Clipboard* clipboard,
                               Frame* frame,
                               bool isLinkDrag)
{
    // Add a ref to the frame just in case a load occurs mid-drag.
    RefPtr<Frame> frameProtector = frame;

    WebDragData dragData = static_cast<ClipboardChromium*>(clipboard)->dataObject();
    WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask>(clipboard->sourceOperation());
    WebImage image;
    IntSize offsetSize(eventPos - dragImageOrigin);
    WebPoint offsetPoint(offsetSize.width(), offsetSize.height());

    if (dragImage) {
        float resolutionScale = dragImage->resolutionScale();
        if (m_webView->deviceScaleFactor() != resolutionScale) {
            ASSERT(resolutionScale > 0);
            float scale = m_webView->deviceScaleFactor() / resolutionScale;
            dragImage->scale(scale, scale);
        }
        image = dragImage->bitmap();
    }

    m_webView->startDragging(frame, dragData, dragOperationMask, image, offsetPoint);
}
Example #2
0
void DragClientImpl::startDrag(DragImageRef dragImage,
                               const IntPoint& dragImageOrigin,
                               const IntPoint& eventPos,
                               Clipboard* clipboard,
                               Frame* frame,
                               bool isLinkDrag)
{
    // Add a ref to the frame just in case a load occurs mid-drag.
    RefPtr<Frame> frameProtector = frame;

    WebDragData dragData = static_cast<ClipboardChromium*>(clipboard)->dataObject();

    DragOperation dragOperationMask = clipboard->sourceOperation();

    IntSize offsetSize(eventPos - dragImageOrigin);
    WebPoint offsetPoint(offsetSize.width(), offsetSize.height());
    m_webView->startDragging(
        dragData, static_cast<WebDragOperationsMask>(dragOperationMask),
#if WEBKIT_USING_SKIA
        dragImage ? WebImage(*dragImage) : WebImage(),
#else
        dragImage ? WebImage(dragImage) : WebImage(),
#endif
        offsetPoint);
}