Commit baf91e99 authored by carlosgc@webkit.org's avatar carlosgc@webkit.org

DragImage should not depend on Frame and CachedImage

https://bugs.webkit.org/show_bug.cgi?id=21357

Reviewed by Sam Weinig.

Remove Frame and CachedImage dependencies from DragImage.

* dom/Clipboard.h:
(WebCore): Add forward delcaration for CacheImage since it's not
included anymore in DragImage.h.
* page/DragController.cpp:
(WebCore::DragController::startDrag): Use
Frame::dragImageForSelection() and call
dissolveDragImageToFraction() for the returned DragImage. Pass the
font rendering mode to createDragImageForLink, instead of a Frame
that is only used to get the font rendering mode.
(WebCore::DragController::doImageDrag): Get the suggested filename
for the cached image and pass it to
createDragImageIconForCachedImageFilename().
* platform/DragImage.cpp:
(WebCore::createDragImageForLink): Receive a FontRenderingMode
instead of a Frame.
* platform/DragImage.h:
(WebCore): Remove createDragImageForSelection, change
createDragImageForLink to receive a FontRenderingMode instead of a
frame, and rename createDragImageIconForCachedImage as
createDragImageIconForCachedImageFilename since it nows received
the suggested filename of the cached image.
* platform/blackberry/DragImageBlackBerry.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Adapt to API
changes.
* platform/efl/DragImageEfl.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Ditto.
* platform/gtk/DragImageGtk.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Ditto.
* platform/mac/DragImageMac.mm:
(WebCore::dissolveDragImageToFraction): Return early if the passed
image is NULL.
(WebCore::createDragImageIconForCachedImageFilename): Adapt to API
changes.
(WebCore::createDragImageForLink): Ditto.
* platform/qt/DragImageQt.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Ditto.
* platform/win/DragImageWin.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Ditto.
(WebCore::createDragImageForLink): Ditto.
* platform/wx/DragImageWx.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147912 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c1671085
2013-04-08 Carlos Garcia Campos <cgarcia@igalia.com>
DragImage should not depend on Frame and CachedImage
https://bugs.webkit.org/show_bug.cgi?id=21357
Reviewed by Sam Weinig.
Remove Frame and CachedImage dependencies from DragImage.
* dom/Clipboard.h:
(WebCore): Add forward delcaration for CacheImage since it's not
included anymore in DragImage.h.
* page/DragController.cpp:
(WebCore::DragController::startDrag): Use
Frame::dragImageForSelection() and call
dissolveDragImageToFraction() for the returned DragImage. Pass the
font rendering mode to createDragImageForLink, instead of a Frame
that is only used to get the font rendering mode.
(WebCore::DragController::doImageDrag): Get the suggested filename
for the cached image and pass it to
createDragImageIconForCachedImageFilename().
* platform/DragImage.cpp:
(WebCore::createDragImageForLink): Receive a FontRenderingMode
instead of a Frame.
* platform/DragImage.h:
(WebCore): Remove createDragImageForSelection, change
createDragImageForLink to receive a FontRenderingMode instead of a
frame, and rename createDragImageIconForCachedImage as
createDragImageIconForCachedImageFilename since it nows received
the suggested filename of the cached image.
* platform/blackberry/DragImageBlackBerry.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Adapt to API
changes.
* platform/efl/DragImageEfl.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Ditto.
* platform/gtk/DragImageGtk.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Ditto.
* platform/mac/DragImageMac.mm:
(WebCore::dissolveDragImageToFraction): Return early if the passed
image is NULL.
(WebCore::createDragImageIconForCachedImageFilename): Adapt to API
changes.
(WebCore::createDragImageForLink): Ditto.
* platform/qt/DragImageQt.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Ditto.
* platform/win/DragImageWin.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Ditto.
(WebCore::createDragImageForLink): Ditto.
* platform/wx/DragImageWx.cpp:
(WebCore::createDragImageIconForCachedImageFilename): Ditto.
2013-04-08 Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
[EFL] REGRESSION(r147743): Use the correct `operator new' override in RenderThemeEfl.
......@@ -33,6 +33,7 @@
namespace WebCore {
class CachedImage;
class DataTransferItemList;
class DragData;
class FileList;
......
......@@ -799,7 +799,7 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
}
m_client->willPerformDragSourceAction(DragSourceActionSelection, dragOrigin, clipboard);
if (!dragImage) {
dragImage = createDragImageForSelection(src);
dragImage = dissolveDragImageToFraction(src->dragImageForSelection(), DragImageAlpha);
dragLoc = dragLocForSelectionDrag(src);
m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y());
}
......@@ -843,7 +843,7 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
m_client->willPerformDragSourceAction(DragSourceActionLink, dragOrigin, clipboard);
if (!dragImage) {
dragImage = createDragImageForLink(linkURL, hitTestResult.textContent(), src);
dragImage = createDragImageForLink(linkURL, hitTestResult.textContent(), src->settings() ? src->settings()->fontRenderingMode() : NormalRenderingMode);
IntSize size = dragImageSize(dragImage);
m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset);
dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDraggedPoint.y() + m_dragOffset.y());
......@@ -893,9 +893,11 @@ void DragController::doImageDrag(Element* element, const IntPoint& dragOrigin, c
dy *= scale;
origin.setY((int)(dy + 0.5));
} else {
dragImage = createDragImageIconForCachedImage(getCachedImage(element));
if (dragImage)
origin = IntPoint(DragIconRightInset - dragImageSize(dragImage).width(), DragIconBottomInset);
if (CachedImage* cachedImage = getCachedImage(element)) {
dragImage = createDragImageIconForCachedImageFilename(cachedImage->response().suggestedFilename());
if (dragImage)
origin = IntPoint(DragIconRightInset - dragImageSize(dragImage).width(), DragIconBottomInset);
}
}
dragImageOffset = mouseDownPoint + origin;
......
......@@ -29,7 +29,7 @@
#if ENABLE(DRAG_SUPPORT)
#include "DragController.h"
#include "Frame.h"
#include "FontRenderingMode.h"
namespace WebCore {
......@@ -64,17 +64,9 @@ DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& srcSize, c
return scaleDragImage(image, FloatSize(scalex, scaley));
}
DragImageRef createDragImageForSelection(Frame* frame)
{
DragImageRef image = frame->dragImageForSelection();
if (image)
image = dissolveDragImageToFraction(image, DragController::DragImageAlpha);
return image;
}
#if !PLATFORM(MAC) && (!PLATFORM(WIN) || OS(WINCE))
DragImageRef createDragImageForLink(KURL&, const String&, Frame*)
DragImageRef createDragImageForLink(KURL&, const String&, FontRenderingMode)
{
return 0;
}
......
......@@ -26,6 +26,7 @@
#ifndef DragImage_h
#define DragImage_h
#include "FontRenderingMode.h"
#include "ImageOrientation.h"
#include "IntSize.h"
#include "FloatSize.h"
......@@ -50,9 +51,7 @@ typedef struct _cairo_surface cairo_surface_t;
#define DragLabelBorderYOffset 2
namespace WebCore {
class CachedImage;
class Frame;
class Image;
class KURL;
class Range;
......@@ -81,9 +80,8 @@ namespace WebCore {
DragImageRef dissolveDragImageToFraction(DragImageRef image, float delta);
DragImageRef createDragImageFromImage(Image*, RespectImageOrientationEnum = DoNotRespectImageOrientation);
DragImageRef createDragImageForSelection(Frame*);
DragImageRef createDragImageIconForCachedImage(CachedImage*);
DragImageRef createDragImageForLink(KURL&, const String& label, Frame*);
DragImageRef createDragImageIconForCachedImageFilename(const String&);
DragImageRef createDragImageForLink(KURL&, const String& label, FontRenderingMode);
void deleteDragImage(DragImageRef);
}
......
......@@ -19,7 +19,6 @@
#include "config.h"
#include "DragImage.h"
#include "CachedImage.h"
#include "FloatSize.h"
#include "Image.h"
#include "NotImplemented.h"
......@@ -32,7 +31,7 @@ void* createDragImageFromImage(Image*, RespectImageOrientationEnum)
return 0;
}
void* createDragImageIconForCachedImage(CachedImage*)
void* createDragImageIconForCachedImageFilename(const String&)
{
notImplemented();
return 0;
......
......@@ -21,7 +21,6 @@
#include "config.h"
#include "DragImage.h"
#include "CachedImage.h"
#include "Image.h"
#include "NotImplemented.h"
......@@ -56,7 +55,7 @@ DragImageRef createDragImageFromImage(Image*, RespectImageOrientationEnum)
return 0;
}
DragImageRef createDragImageIconForCachedImage(CachedImage*)
DragImageRef createDragImageIconForCachedImageFilename(const String&)
{
notImplemented();
return 0;
......
......@@ -19,7 +19,6 @@
#include "config.h"
#include "DragImage.h"
#include "CachedImage.h"
#include "Image.h"
#include "RefPtrCairo.h"
#include <cairo.h>
......@@ -82,7 +81,7 @@ DragImageRef createDragImageFromImage(Image* image, RespectImageOrientationEnum)
return image->nativeImageForCurrentFrame().leakRef();
}
DragImageRef createDragImageIconForCachedImage(CachedImage*)
DragImageRef createDragImageIconForCachedImageFilename(const String&)
{
return 0;
}
......
......@@ -28,7 +28,6 @@
#if ENABLE(DRAG_SUPPORT)
#import "BitmapImage.h"
#import "CachedImage.h"
#import "Font.h"
#import "FontCache.h"
#import "FontDescription.h"
......@@ -37,7 +36,6 @@
#import "Image.h"
#import "KURL.h"
#import "ResourceResponse.h"
#import "Settings.h"
#import "StringTruncator.h"
#import "TextRun.h"
......@@ -67,6 +65,9 @@ RetainPtr<NSImage> scaleDragImage(RetainPtr<NSImage> image, FloatSize scale)
RetainPtr<NSImage> dissolveDragImageToFraction(RetainPtr<NSImage> image, float delta)
{
if (!image)
return nil;
RetainPtr<NSImage> dissolvedImage(AdoptNS, [[NSImage alloc] initWithSize:[image.get() size]]);
[dissolvedImage.get() lockFocus];
......@@ -123,9 +124,8 @@ RetainPtr<NSImage> createDragImageFromImage(Image* image, RespectImageOrientatio
return dragImage;
}
RetainPtr<NSImage> createDragImageIconForCachedImage(CachedImage* image)
RetainPtr<NSImage> createDragImageIconForCachedImageFilename(const String& filename)
{
const String& filename = image->response().suggestedFilename();
NSString *extension = nil;
size_t dotIndex = filename.reverseFind('.');
......@@ -267,10 +267,8 @@ static void drawDoubledAtPoint(NSString *string, NSPoint textPoint, NSColor *top
drawAtPoint(string, textPoint, font, topColor);
}
DragImageRef createDragImageForLink(KURL& url, const String& title, Frame* frame)
DragImageRef createDragImageForLink(KURL& url, const String& title, FontRenderingMode)
{
if (!frame)
return nil;
NSString *label = nsStringNilIfEmpty(title);
NSURL *cocoaURL = url;
NSString *urlString = [cocoaURL absoluteString];
......
......@@ -26,7 +26,6 @@
#include "config.h"
#include "DragImage.h"
#include "CachedImage.h"
#include "Image.h"
namespace WebCore {
......@@ -69,7 +68,7 @@ DragImageRef createDragImageFromImage(Image* image, RespectImageOrientationEnum)
return new QPixmap(*image->nativeImageForCurrentFrame());
}
DragImageRef createDragImageIconForCachedImage(CachedImage*)
DragImageRef createDragImageIconForCachedImageFilename(const String&)
{
return 0;
}
......
......@@ -26,16 +26,13 @@
#include "config.h"
#include "DragImage.h"
#include "CachedImage.h"
#include "Font.h"
#include "FontCache.h"
#include "FontDescription.h"
#include "FontSelector.h"
#include "Frame.h"
#include "GraphicsContext.h"
#include "HWndDC.h"
#include "Image.h"
#include "Settings.h"
#include "StringTruncator.h"
#include "TextRun.h"
#include "WebCoreTextRenderer.h"
......@@ -69,13 +66,8 @@ DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
return image;
}
DragImageRef createDragImageIconForCachedImage(CachedImage* image)
DragImageRef createDragImageIconForCachedImageFilename(const String& filename)
{
if (!image)
return 0;
String filename = image->response().suggestedFilename();
SHFILEINFO shfi = {0};
if (FAILED(SHGetFileInfo(static_cast<LPCWSTR>(filename.charactersWithNullTermination()), FILE_ATTRIBUTE_NORMAL,
&shfi, sizeof(shfi), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES)))
......@@ -129,7 +121,7 @@ static Font dragLabelFont(int size, bool bold, FontRenderingMode renderingMode)
return result;
}
DragImageRef createDragImageForLink(KURL& url, const String& inLabel, Frame* frame)
DragImageRef createDragImageForLink(KURL& url, const String& inLabel, FontRenderingMode fontRenderingMode)
{
// This is more or less an exact match for the Mac OS X code.
......@@ -137,7 +129,7 @@ DragImageRef createDragImageForLink(KURL& url, const String& inLabel, Frame* fra
const Font* urlFont;
FontCachePurgePreventer fontCachePurgePreventer;
if (frame->settings() && frame->settings()->fontRenderingMode() == AlternateRenderingMode) {
if (fontRenderingMode == AlternateRenderingMode) {
static const Font alternateRenderingModeLabelFont = dragLabelFont(DragLinkLabelFontsize, true, AlternateRenderingMode);
static const Font alternateRenderingModeURLFont = dragLabelFont(DragLinkUrlFontSize, false, AlternateRenderingMode);
labelFont = &alternateRenderingModeLabelFont;
......
......@@ -25,7 +25,7 @@
#include "config.h"
#include "DragImage.h"
#include "CachedImage.h"
#include "FloatSize.h"
#include "Image.h"
......@@ -55,7 +55,7 @@ DragImageRef createDragImageFromImage(Image*, RespectImageOrientationEnum)
return 0;
}
DragImageRef createDragImageIconForCachedImage(CachedImage*)
DragImageRef createDragImageIconForCachedImageFilename(const String&)
{
return 0;
}
......
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