Dragged images seem to have any padding on them included when calculating the size of the semi-transparent drag image. Load the testcase at the URL on this bug report then drag the image. The WebKit logo is at fullsize and should therefore stay the same when dragged, but instead has the 100px padding applied to it.
The rect the drag image size is calculated from includes borders as well.
The bug here is in -[WebElementDictionary _imageRect], which calls HitTestResult::boundingBox. There's been an attempt to generalize things too much. An image's rect is not the same thing as the absoluteBoundingBoxRect, which is what HitTestResult::boundingBox computes. To find the image's rect, we need to take the margin and border into account as RenderImage::paint does. I suggest we add a function to HitTestResult called imageRect and use that.
Custom HTML drag images should use the border box though. I think _imageRect may be set for those too? http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/DragAndDrop.html Note that setDragImage can be called with either an image object or an element, although haven't we now unified the two? In this API, the borders/padding should be included. It's really just our "built-in" image dragging that should exclude them. In the future we may want to enhance the API to specify which box to use.
Created attachment 12477 [details] patch with change log
Comment on attachment 12477 [details] patch with change log Is this only used for built-in images and not for custom drag images?
(In reply to comment #5) > Is this only used for built-in images and not for custom drag images? Yes, that's right. Ultimately we could rewrite this to work in a simpler way. For this patch, I just fixed the regression in WebKit API that caused the bug rather than trying to remove this code path and unify with other dragging down at the WebCore level.
<rdar://problem/4928705>
Comment on attachment 12477 [details] patch with change log r=me
Committed revision 18918.