DragImageRef createDragImageForSelection(Frame* frame) { DragImageRef image = frame->dragImageForSelection(); if (image) dissolveDragImageToFraction(image, DragController::DragImageAlpha); return image; }
void DragController::doImageDrag(Element* element, const IntPoint& dragOrigin, const IntRect& rect, Clipboard* clipboard, Frame* frame, IntPoint& dragImageOffset) { IntPoint mouseDownPoint = dragOrigin; DragImageRef dragImage; IntPoint origin; Image* image = getImage(element); if (image && image->size().height() * image->size().width() <= MaxOriginalImageArea && (dragImage = createDragImageFromImage(image))) { IntSize originalSize = rect.size(); origin = rect.location(); dragImage = fitDragImageToMaxSize(dragImage, rect.size(), maxDragImageSize()); dragImage = dissolveDragImageToFraction(dragImage, DragImageAlpha); IntSize newSize = dragImageSize(dragImage); // Properly orient the drag image and orient it differently if it's smaller than the original float scale = newSize.width() / (float)originalSize.width(); float dx = origin.x() - mouseDownPoint.x(); dx *= scale; origin.setX((int)(dx + 0.5)); #if PLATFORM(MAC) //Compensate for accursed flipped coordinates in cocoa origin.setY(origin.y() + originalSize.height()); #endif float dy = origin.y() - mouseDownPoint.y(); dy *= scale; origin.setY((int)(dy + 0.5)); } else { dragImage = createDragImageIconForCachedImage(getCachedImage(element)); if (dragImage) origin = IntPoint(DragIconRightInset - dragImageSize(dragImage).width(), DragIconBottomInset); } dragImageOffset.setX(mouseDownPoint.x() + origin.x()); dragImageOffset.setY(mouseDownPoint.y() + origin.y()); doSystemDrag(dragImage, dragImageOffset, dragOrigin, clipboard, frame, false); deleteDragImage(dragImage); }