Commit 73b4f89f authored by oliver's avatar oliver

Reviewed by Steve.

        Fix for <rdar://problem/5126393> REGRESSION (r19672-19697): Safari drag image drags at original size (13261)

        Added logic to ensure that when we create the drag image
        we're looking at the rendered image size.

        * page/DragController.cpp:
        (WebCore::DragController::doImageDrag):
          Pass the rendered image size to fitDragImageToMaxSize

        * platform/DragImage.cpp:
        (WebCore::fitDragImageToMaxSize):
           Need to do scaling relative to rendered image size

        * platform/DragImage.h:
           scaleDragImage needs x and y scales to allow for them to be
           scaled seperately on a page

        * platform/gdk/DragImageGdk.cpp:
        (WebCore::scaleDragImage):
           Prevent build bustage

        * platform/mac/DragImageMac.mm:
        (WebCore::scaleDragImage):
           scale width and height independently

        * platform/qt/DragImageQt.cpp:
        (WebCore::scaleDragImage):
           Prevent build bustage



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a51de911
2007-04-29 Oliver Hunt <oliver@apple.com>
Reviewed by Steve.
Fix for <rdar://problem/5126393> REGRESSION (r19672-19697): Safari drag image drags at original size (13261)
Added logic to ensure that when we create the drag image
we're looking at the rendered image size.
* page/DragController.cpp:
(WebCore::DragController::doImageDrag):
Pass the rendered image size to fitDragImageToMaxSize
* platform/DragImage.cpp:
(WebCore::fitDragImageToMaxSize):
Need to do scaling relative to rendered image size
* platform/DragImage.h:
scaleDragImage needs x and y scales to allow for them to be
scaled seperately on a page
* platform/gdk/DragImageGdk.cpp:
(WebCore::scaleDragImage):
Prevent build bustage
* platform/mac/DragImageMac.mm:
(WebCore::scaleDragImage):
scale width and height independently
* platform/qt/DragImageQt.cpp:
(WebCore::scaleDragImage):
Prevent build bustage
2007-04-29 Darin Adler <darin@apple.com>
Reviewed by Adele.
......@@ -651,7 +651,7 @@ void DragController::doImageDrag(Element* element, const IntPoint& dragOrigin, c
IntSize originalSize = rect.size();
origin = rect.location();
dragImage = fitDragImageToMaxSize(dragImage, maxDragImageSize());
dragImage = fitDragImageToMaxSize(dragImage, rect.size(), maxDragImageSize());
dragImage = dissolveDragImageToFraction(dragImage, DragImageAlpha);
IntSize newSize = dragImageSize(dragImage);
......
......@@ -31,28 +31,36 @@
namespace WebCore {
DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& size)
DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& srcSize, const IntSize& size)
{
float heightResizeRatio = 0.0f;
float widthResizeRatio = 0.0f;
float resizeRatio = 0.0f;
float resizeRatio = -1.0f;
IntSize originalSize = dragImageSize(image);
if (originalSize.width() > size.width()) {
widthResizeRatio = size.width() / (float)originalSize.width();
if (srcSize.width() > size.width()) {
widthResizeRatio = size.width() / (float)srcSize.width();
resizeRatio = widthResizeRatio;
}
if (originalSize.height() > size.height()) {
heightResizeRatio = size.height() / (float)originalSize.height();
if ((resizeRatio == 0.0) || (resizeRatio > heightResizeRatio))
if (srcSize.height() > size.height()) {
heightResizeRatio = size.height() / (float)srcSize.height();
if ((resizeRatio < 0.0f) || (resizeRatio > heightResizeRatio))
resizeRatio = heightResizeRatio;
}
if (resizeRatio > 0.0)
return scaleDragImage(image, resizeRatio);
return image;
if (srcSize == originalSize)
return resizeRatio > 0.0f ? scaleDragImage(image, FloatSize(resizeRatio, resizeRatio)) : image;
// The image was scaled in the webpage so at minimum we must account for that scaling
float scalex = srcSize.width() / (float)originalSize.width();
float scaley = srcSize.height() / (float)originalSize.height();
if (resizeRatio > 0.0f) {
scalex *= resizeRatio;
scaley *= resizeRatio;
}
return scaleDragImage(image, FloatSize(scalex, scaley));
}
DragImageRef createDragImageForSelection(Frame* frame)
......
......@@ -27,6 +27,7 @@
#define DragImage_h
#include "IntSize.h"
#include "FloatSize.h"
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
......@@ -68,8 +69,8 @@ namespace WebCore {
//These functions should be memory neutral, eg. if they return a newly allocated image,
//they should release the input image. As a corollary these methods don't guarantee
//the input image ref will still be valid after they have been called
DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& size);
DragImageRef scaleDragImage(DragImageRef, float);
DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& srcSize, const IntSize& size);
DragImageRef scaleDragImage(DragImageRef, FloatSize scale);
DragImageRef dissolveDragImageToFraction(DragImageRef image, float delta);
DragImageRef createDragImageFromImage(Image*);
......
......@@ -40,7 +40,7 @@ void deleteDragImage(DragImageRef)
{
}
DragImageRef scaleDragImage(DragImageRef image, float)
DragImageRef scaleDragImage(DragImageRef image, FloatSize)
{
return image;
}
......
......@@ -46,10 +46,10 @@ void deleteDragImage(DragImageRef image)
//DragImageRef is a RetainPtr, so we don't need to explicitly delete it
}
DragImageRef scaleDragImage(DragImageRef image, float scale)
DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
{
NSSize originalSize = [image.get() size];
NSSize newSize = NSMakeSize((originalSize.width * scale), (originalSize.height * scale));
NSSize newSize = NSMakeSize((originalSize.width * scale.width()), (originalSize.height * scale.height()));
newSize.width = roundf(newSize.width);
newSize.height = roundf(newSize.height);
[image.get() setScalesWhenResized:YES];
......
......@@ -40,7 +40,7 @@ void deleteDragImage(DragImageRef)
{
}
DragImageRef scaleDragImage(DragImageRef image, float)
DragImageRef scaleDragImage(DragImageRef image, float, float)
{
return image;
}
......
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