Bug 12278 - REGRESSION(r13070): Dragged image size includes padding
Summary: REGRESSION(r13070): Dragged image size includes padding
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 420+
Hardware: Macintosh OS X 10.4
: P1 Normal
Assignee: Darin Adler
URL: data:text/html,<img src="http://webki...
Keywords: HasReduction, InRadar, Regression
Depends on:
Blocks:
 
Reported: 2007-01-15 01:22 PST by Matt Lilek
Modified: 2007-01-17 15:09 PST (History)
1 user (show)

See Also:


Attachments
patch with change log (10.73 KB, patch)
2007-01-16 00:00 PST, Darin Adler
mjs: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Lilek 2007-01-15 01:22:29 PST
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.
Comment 1 Matt Lilek 2007-01-15 19:08:12 PST
The rect the drag image size is calculated from includes borders as well.
Comment 2 Darin Adler 2007-01-15 23:28:20 PST
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.
Comment 3 Dave Hyatt 2007-01-15 23:42:00 PST
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.
Comment 4 Darin Adler 2007-01-16 00:00:06 PST
Created attachment 12477 [details]
patch with change log
Comment 5 Dave Hyatt 2007-01-16 13:00:39 PST
Comment on attachment 12477 [details]
patch with change log

Is this only used for built-in images and not for custom drag images?
Comment 6 Darin Adler 2007-01-16 13:41:37 PST
(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.
Comment 7 Mark Rowe (bdash) 2007-01-16 19:55:45 PST
<rdar://problem/4928705>
Comment 8 Maciej Stachowiak 2007-01-17 01:34:59 PST
Comment on attachment 12477 [details]
patch with change log

r=me
Comment 9 Darin Adler 2007-01-17 15:09:30 PST
Committed revision 18918.