Changeset 147912 in webkit


Ignore:
Timestamp:
Apr 8, 2013 6:35:18 AM (11 years ago)
Author:
Carlos Garcia Campos
Message:

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.

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147911 r147912  
     12013-04-08  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        DragImage should not depend on Frame and CachedImage
     4        https://bugs.webkit.org/show_bug.cgi?id=21357
     5
     6        Reviewed by Sam Weinig.
     7
     8        Remove Frame and CachedImage dependencies from DragImage.
     9
     10        * dom/Clipboard.h:
     11        (WebCore): Add forward delcaration for CacheImage since it's not
     12        included anymore in DragImage.h.
     13        * page/DragController.cpp:
     14        (WebCore::DragController::startDrag): Use
     15        Frame::dragImageForSelection() and call
     16        dissolveDragImageToFraction() for the returned DragImage. Pass the
     17        font rendering mode to createDragImageForLink, instead of a Frame
     18        that is only used to get the font rendering mode.
     19        (WebCore::DragController::doImageDrag): Get the suggested filename
     20        for the cached image and pass it to
     21        createDragImageIconForCachedImageFilename().
     22        * platform/DragImage.cpp:
     23        (WebCore::createDragImageForLink): Receive a FontRenderingMode
     24        instead of a Frame.
     25        * platform/DragImage.h:
     26        (WebCore): Remove createDragImageForSelection, change
     27        createDragImageForLink to receive a FontRenderingMode instead of a
     28        frame, and rename createDragImageIconForCachedImage as
     29        createDragImageIconForCachedImageFilename since it nows received
     30        the suggested filename of the cached image.
     31        * platform/blackberry/DragImageBlackBerry.cpp:
     32        (WebCore::createDragImageIconForCachedImageFilename): Adapt to API
     33        changes.
     34        * platform/efl/DragImageEfl.cpp:
     35        (WebCore::createDragImageIconForCachedImageFilename): Ditto.
     36        * platform/gtk/DragImageGtk.cpp:
     37        (WebCore::createDragImageIconForCachedImageFilename): Ditto.
     38        * platform/mac/DragImageMac.mm:
     39        (WebCore::dissolveDragImageToFraction): Return early if the passed
     40        image is NULL.
     41        (WebCore::createDragImageIconForCachedImageFilename): Adapt to API
     42        changes.
     43        (WebCore::createDragImageForLink): Ditto.
     44        * platform/qt/DragImageQt.cpp:
     45        (WebCore::createDragImageIconForCachedImageFilename): Ditto.
     46        * platform/win/DragImageWin.cpp:
     47        (WebCore::createDragImageIconForCachedImageFilename): Ditto.
     48        (WebCore::createDragImageForLink): Ditto.
     49        * platform/wx/DragImageWx.cpp:
     50        (WebCore::createDragImageIconForCachedImageFilename): Ditto.
     51
    1522013-04-08  Raphael Kubo da Costa  <raphael.kubo.da.costa@intel.com>
    253
  • trunk/Source/WebCore/dom/Clipboard.h

    r146644 r147912  
    3434namespace WebCore {
    3535
     36    class CachedImage;
    3637    class DataTransferItemList;
    3738    class DragData;
  • trunk/Source/WebCore/page/DragController.cpp

    r147135 r147912  
    800800        m_client->willPerformDragSourceAction(DragSourceActionSelection, dragOrigin, clipboard);
    801801        if (!dragImage) {
    802             dragImage = createDragImageForSelection(src);
     802            dragImage = dissolveDragImageToFraction(src->dragImageForSelection(), DragImageAlpha);
    803803            dragLoc = dragLocForSelectionDrag(src);
    804804            m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y());
     
    844844        m_client->willPerformDragSourceAction(DragSourceActionLink, dragOrigin, clipboard);
    845845        if (!dragImage) {
    846             dragImage = createDragImageForLink(linkURL, hitTestResult.textContent(), src);
     846            dragImage = createDragImageForLink(linkURL, hitTestResult.textContent(), src->settings() ? src->settings()->fontRenderingMode() : NormalRenderingMode);
    847847            IntSize size = dragImageSize(dragImage);
    848848            m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset);
     
    894894        origin.setY((int)(dy + 0.5));
    895895    } else {
    896         dragImage = createDragImageIconForCachedImage(getCachedImage(element));
    897         if (dragImage)
    898             origin = IntPoint(DragIconRightInset - dragImageSize(dragImage).width(), DragIconBottomInset);
     896        if (CachedImage* cachedImage = getCachedImage(element)) {
     897            dragImage = createDragImageIconForCachedImageFilename(cachedImage->response().suggestedFilename());
     898            if (dragImage)
     899                origin = IntPoint(DragIconRightInset - dragImageSize(dragImage).width(), DragIconBottomInset);
     900        }
    899901    }
    900902
  • trunk/Source/WebCore/platform/DragImage.cpp

    r77935 r147912  
    3030#include "DragController.h"
    3131
    32 #include "Frame.h"
     32#include "FontRenderingMode.h"
    3333
    3434namespace WebCore {
     
    6565    return scaleDragImage(image, FloatSize(scalex, scaley));
    6666}
    67    
    68 DragImageRef createDragImageForSelection(Frame* frame)
    69 {
    70     DragImageRef image = frame->dragImageForSelection();
    71     if (image)
    72         image = dissolveDragImageToFraction(image, DragController::DragImageAlpha);
    73     return image;
    74 }
    7567
    7668#if !PLATFORM(MAC) && (!PLATFORM(WIN) || OS(WINCE))
    77 DragImageRef createDragImageForLink(KURL&, const String&, Frame*)
     69DragImageRef createDragImageForLink(KURL&, const String&, FontRenderingMode)
    7870{
    7971    return 0;
  • trunk/Source/WebCore/platform/DragImage.h

    r147888 r147912  
    2727#define DragImage_h
    2828
     29#include "FontRenderingMode.h"
    2930#include "ImageOrientation.h"
    3031#include "IntSize.h"
     
    5152
    5253namespace WebCore {
    53    
    54     class CachedImage;
    55     class Frame;
     54
    5655    class Image;
    5756    class KURL;
     
    8281   
    8382    DragImageRef createDragImageFromImage(Image*, RespectImageOrientationEnum = DoNotRespectImageOrientation);
    84     DragImageRef createDragImageForSelection(Frame*);   
    85     DragImageRef createDragImageIconForCachedImage(CachedImage*);
    86     DragImageRef createDragImageForLink(KURL&, const String& label, Frame*);
     83    DragImageRef createDragImageIconForCachedImageFilename(const String&);
     84    DragImageRef createDragImageForLink(KURL&, const String& label, FontRenderingMode);
    8785    void deleteDragImage(DragImageRef);
    8886}
  • trunk/Source/WebCore/platform/blackberry/DragImageBlackBerry.cpp

    r113486 r147912  
    2020#include "DragImage.h"
    2121
    22 #include "CachedImage.h"
    2322#include "FloatSize.h"
    2423#include "Image.h"
     
    3332}
    3433
    35 void* createDragImageIconForCachedImage(CachedImage*)
     34void* createDragImageIconForCachedImageFilename(const String&)
    3635{
    3736    notImplemented();
  • trunk/Source/WebCore/platform/efl/DragImageEfl.cpp

    r113486 r147912  
    2222#include "DragImage.h"
    2323
    24 #include "CachedImage.h"
    2524#include "Image.h"
    2625#include "NotImplemented.h"
     
    5756}
    5857
    59 DragImageRef createDragImageIconForCachedImage(CachedImage*)
     58DragImageRef createDragImageIconForCachedImageFilename(const String&)
    6059{
    6160    notImplemented();
  • trunk/Source/WebCore/platform/gtk/DragImageGtk.cpp

    r147643 r147912  
    2020#include "DragImage.h"
    2121
    22 #include "CachedImage.h"
    2322#include "Image.h"
    2423#include "RefPtrCairo.h"
     
    8382}
    8483
    85 DragImageRef createDragImageIconForCachedImage(CachedImage*)
     84DragImageRef createDragImageIconForCachedImageFilename(const String&)
    8685{
    8786    return 0;
  • trunk/Source/WebCore/platform/mac/DragImageMac.mm

    r141678 r147912  
    2929#if ENABLE(DRAG_SUPPORT)
    3030#import "BitmapImage.h"
    31 #import "CachedImage.h"
    3231#import "Font.h"
    3332#import "FontCache.h"
     
    3837#import "KURL.h"
    3938#import "ResourceResponse.h"
    40 #import "Settings.h"
    4139#import "StringTruncator.h"
    4240#import "TextRun.h"
     
    6866RetainPtr<NSImage> dissolveDragImageToFraction(RetainPtr<NSImage> image, float delta)
    6967{
     68    if (!image)
     69        return nil;
     70
    7071    RetainPtr<NSImage> dissolvedImage(AdoptNS, [[NSImage alloc] initWithSize:[image.get() size]]);
    7172   
     
    124125}
    125126   
    126 RetainPtr<NSImage> createDragImageIconForCachedImage(CachedImage* image)
    127 {
    128     const String& filename = image->response().suggestedFilename();
     127RetainPtr<NSImage> createDragImageIconForCachedImageFilename(const String& filename)
     128{
    129129    NSString *extension = nil;
    130130    size_t dotIndex = filename.reverseFind('.');
     
    268268}
    269269
    270 DragImageRef createDragImageForLink(KURL& url, const String& title, Frame* frame)
    271 {
    272     if (!frame)
    273         return nil;
     270DragImageRef createDragImageForLink(KURL& url, const String& title, FontRenderingMode)
     271{
    274272    NSString *label = nsStringNilIfEmpty(title);
    275273    NSURL *cocoaURL = url;
  • trunk/Source/WebCore/platform/qt/DragImageQt.cpp

    r130636 r147912  
    2727#include "DragImage.h"
    2828
    29 #include "CachedImage.h"
    3029#include "Image.h"
    3130
     
    7069}
    7170
    72 DragImageRef createDragImageIconForCachedImage(CachedImage*)
     71DragImageRef createDragImageIconForCachedImageFilename(const String&)
    7372{
    7473    return 0;
  • trunk/Source/WebCore/platform/win/DragImageWin.cpp

    r141378 r147912  
    2727#include "DragImage.h"
    2828
    29 #include "CachedImage.h"
    3029#include "Font.h"
    3130#include "FontCache.h"
    3231#include "FontDescription.h"
    3332#include "FontSelector.h"
    34 #include "Frame.h"
    3533#include "GraphicsContext.h"
    3634#include "HWndDC.h"
    3735#include "Image.h"
    38 #include "Settings.h"
    3936#include "StringTruncator.h"
    4037#include "TextRun.h"
     
    7067}
    7168       
    72 DragImageRef createDragImageIconForCachedImage(CachedImage* image)
    73 {
    74     if (!image)
    75         return 0;
    76 
    77     String filename = image->response().suggestedFilename();
    78    
     69DragImageRef createDragImageIconForCachedImageFilename(const String& filename)
     70{
    7971    SHFILEINFO shfi = {0};
    8072    if (FAILED(SHGetFileInfo(static_cast<LPCWSTR>(filename.charactersWithNullTermination()), FILE_ATTRIBUTE_NORMAL,
     
    130122}
    131123
    132 DragImageRef createDragImageForLink(KURL& url, const String& inLabel, Frame* frame)
     124DragImageRef createDragImageForLink(KURL& url, const String& inLabel, FontRenderingMode fontRenderingMode)
    133125{
    134126    // This is more or less an exact match for the Mac OS X code.
     
    138130    FontCachePurgePreventer fontCachePurgePreventer;
    139131
    140     if (frame->settings() && frame->settings()->fontRenderingMode() == AlternateRenderingMode) {
     132    if (fontRenderingMode == AlternateRenderingMode) {
    141133        static const Font alternateRenderingModeLabelFont = dragLabelFont(DragLinkLabelFontsize, true, AlternateRenderingMode);
    142134        static const Font alternateRenderingModeURLFont = dragLabelFont(DragLinkUrlFontSize, false, AlternateRenderingMode);
  • trunk/Source/WebCore/platform/wx/DragImageWx.cpp

    r113486 r147912  
    2626#include "config.h"
    2727#include "DragImage.h"
    28 #include "CachedImage.h"
     28
    2929#include "FloatSize.h"
    3030#include "Image.h"
     
    5656}
    5757   
    58 DragImageRef createDragImageIconForCachedImage(CachedImage*)
     58DragImageRef createDragImageIconForCachedImageFilename(const String&)
    5959{
    6060    return 0;     
Note: See TracChangeset for help on using the changeset viewer.