Commit caf9248c authored by darin@apple.com's avatar darin@apple.com

2011-03-11 Darin Adler <darin@apple.com>

        Reviewed by Sam Weinig.

        Dragging image to desktop gives webloc instead of image file in WebKit2
        https://bugs.webkit.org/show_bug.cgi?id=56193

        * WebCore.exp.in: Added some additional exports. Re-sorted.
2011-03-11  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        Dragging image to desktop gives webloc instead of image file in WebKit2
        https://bugs.webkit.org/show_bug.cgi?id=56193

        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
        (WebKit::convertImageToBitmap): Added. Factored out from startDrag to
        make the startDrag code clearer.
        (WebKit::WebDragClient::startDrag): Streamlined code a bit.
        (WebKit::cachedImage): Added. Helper for function below.
        (WebKit::arrayForURLsWithTitles): Added. Helper for function below.
        (WebKit::WebDragClient::declareAndWriteDragImage): Added code to handle file
        promises and removed a log of uneeded code.
        (-[WKPasteboardFilePromiseOwner copyDropDirectory]): Added.
        (promisedDataClient): Added.
        (-[WKPasteboardOwner clearImage]): Added.
        (-[WKPasteboardOwner initWithImage:]): Added.
        (-[WKPasteboardOwner dealloc]): Added.
        (-[WKPasteboardOwner finalize]): Added.
        (-[WKPasteboardOwner pasteboard:provideDataForType:]): Added.
        (-[WKPasteboardOwner pasteboardChangedOwner:]): Added.
        (matchesExtensionOrEquivalent): Added.
        (-[WKPasteboardOwner namesOfPromisedFilesDroppedAtDestination:]): Added.
        Much of the new code above came from the WebKit1 drag code.

        * WebProcess/WebPage/WebPage.cpp:
        (WebKit::WebPage::dragEnded): Added call to Mac-only platformDragEnded.
        * WebProcess/WebPage/WebPage.h: Added Mac-only platformDragEnded and m_dragSource.
        * WebProcess/WebPage/mac/WebPageMac.mm:
        (WebKit::WebPage::setDragSource): Added.
        (WebKit::WebPage::platformDragEnded): Added.


git-svn-id: svn://svn.chromium.org/blink/trunk@80948 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 37fa9f1e
2011-03-11 Darin Adler <darin@apple.com>
Reviewed by Sam Weinig.
Dragging image to desktop gives webloc instead of image file in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=56193
* WebCore.exp.in: Added some additional exports. Re-sorted.
2011-03-12 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r80919.
......
......@@ -325,6 +325,7 @@ __ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow
__ZN7WebCore13toHTMLElementEPNS_21FormAssociatedElementE
__ZN7WebCore13toJSDOMWindowEN3JSC7JSValueE
__ZN7WebCore14CachedResource12removeClientEPNS_20CachedResourceClientE
__ZN7WebCore14CachedResource16unregisterHandleEPNS_24CachedResourceHandleBaseE
__ZN7WebCore14CachedResource9addClientEPNS_20CachedResourceClientE
__ZN7WebCore14DocumentLoader10commitDataEPKci
__ZN7WebCore14DocumentLoader13attachToFrameEv
......@@ -553,6 +554,7 @@ __ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0
__ZN7WebCore23getHostnamesWithCookiesERN3WTF7HashSetINS0_6StringENS0_10StringHashENS0_10HashTraitsIS2_EEEE
__ZN7WebCore23overrideDefaultLanguageERKN3WTF6StringE
__ZN7WebCore24BinaryPropertyListWriter17writePropertyListEv
__ZN7WebCore24CachedResourceHandleBase11setResourceEPNS_14CachedResourceE
__ZN7WebCore24DocumentMarkerController13removeMarkersEj
__ZN7WebCore24DocumentMarkerController14markersForNodeEPNS_4NodeE
__ZN7WebCore24DocumentMarkerController14markersForNodeEPNS_4NodeE
......@@ -1291,12 +1293,16 @@ _wkAdvanceDefaultButtonPulseAnimation
_wkCGContextGetShouldSmoothFonts
_wkCopyCFLocalizationPreferredName
_wkCopyCONNECTProxyResponse
_wkCopyHTTPCookieStorage
_wkCopyNSURLResponseStatusLine
_wkCopyRequestWithStorageSession
_wkCreateCTLineWithUniCharProvider
_wkCreateCustomCFReadStream
_wkCreateNSURLConnectionDelegateProxy
_wkCreatePrivateStorageSession
_wkCreateURLNPasteboardFlavorTypeName
_wkCreateURLPasteboardFlavorTypeName
_wkDeleteHTTPCookie
_wkDrawBezeledTextArea
_wkDrawBezeledTextFieldCell
_wkDrawCapsLockIndicator
......@@ -1309,6 +1315,7 @@ _wkGetFontInLanguageForCharacter
_wkGetFontInLanguageForRange
_wkGetGlyphTransformedAdvances
_wkGetGlyphsForCharacters
_wkGetHTTPCookieAcceptPolicy
_wkGetHTTPPipeliningPriority
_wkGetHyphenationLocationBeforeIndex
_wkGetMIMETypeForExtension
......@@ -1318,6 +1325,7 @@ _wkGetNSURLResponseMustRevalidate
_wkGetPreferredExtensionForMIMEType
_wkGetUserToBaseCTM
_wkGetWheelEventDeltas
_wkHTTPCookiesForURL
_wkHitTestMediaUIPart
_wkInitializeMaximumHTTPConnectionCountPerHost
_wkIsLatchingWheelEvent
......@@ -1340,6 +1348,7 @@ _wkSetCONNECTProxyAuthorizationForStream
_wkSetCONNECTProxyForStream
_wkSetCookieStoragePrivateBrowsingEnabled
_wkSetDragImage
_wkSetHTTPCookiesForURL
_wkSetHTTPPipeliningPriority
_wkSetNSURLConnectionDefersCallbacks
_wkSetNSURLRequestShouldContentSniff
......@@ -1349,13 +1358,6 @@ _wkSetUpFontCache
_wkSignalCFReadStreamEnd
_wkSignalCFReadStreamError
_wkSignalCFReadStreamHasBytes
_wkCreatePrivateStorageSession
_wkCopyRequestWithStorageSession
_wkCopyHTTPCookieStorage
_wkGetHTTPCookieAcceptPolicy
_wkHTTPCookiesForURL
_wkSetHTTPCookiesForURL
_wkDeleteHTTPCookie
#if !defined(NDEBUG)
__ZN7WebCore20LogNotYetImplementedE
......
2011-03-11 Darin Adler <darin@apple.com>
Reviewed by Sam Weinig.
Dragging image to desktop gives webloc instead of image file in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=56193
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(WebKit::convertImageToBitmap): Added. Factored out from startDrag to
make the startDrag code clearer.
(WebKit::WebDragClient::startDrag): Streamlined code a bit.
(WebKit::cachedImage): Added. Helper for function below.
(WebKit::arrayForURLsWithTitles): Added. Helper for function below.
(WebKit::WebDragClient::declareAndWriteDragImage): Added code to handle file
promises and removed a log of uneeded code.
(-[WKPasteboardFilePromiseOwner copyDropDirectory]): Added.
(promisedDataClient): Added.
(-[WKPasteboardOwner clearImage]): Added.
(-[WKPasteboardOwner initWithImage:]): Added.
(-[WKPasteboardOwner dealloc]): Added.
(-[WKPasteboardOwner finalize]): Added.
(-[WKPasteboardOwner pasteboard:provideDataForType:]): Added.
(-[WKPasteboardOwner pasteboardChangedOwner:]): Added.
(matchesExtensionOrEquivalent): Added.
(-[WKPasteboardOwner namesOfPromisedFilesDroppedAtDestination:]): Added.
Much of the new code above came from the WebKit1 drag code.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::dragEnded): Added call to Mac-only platformDragEnded.
* WebProcess/WebPage/WebPage.h: Added Mac-only platformDragEnded and m_dragSource.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::setDragSource): Added.
(WebKit::WebPage::platformDragEnded): Added.
2011-03-12 Mark Rowe <mrowe@apple.com>
Fix the 32-bit build.
......
......@@ -32,50 +32,108 @@
#import "WebPage.h"
#import "WebPageProxyMessages.h"
#import <WebCore/CachedImage.h>
#import <WebCore/DOMPrivate.h>
#import <WebCore/DOMElementInternal.h>
#import <WebCore/DOMPrivate.h>
#import <WebCore/DragController.h>
#import <WebCore/FrameView.h>
#import <WebCore/GraphicsContext.h>
#import <WebCore/LegacyWebArchive.h>
#import <WebCore/RenderImage.h>
#import <WebCore/ResourceHandle.h>
#import <WebCore/StringTruncator.h>
#import <wtf/StdLibExtras.h>
#import <WebKit/WebArchive.h>
#import <WebKit/WebKitNSStringExtras.h>
#import <WebKit/WebNSFileManagerExtras.h>
#import <WebKit/WebNSPasteboardExtras.h>
#import <WebKit/WebNSURLExtras.h>
#import <WebKitSystemInterface.h>
#import <wtf/StdLibExtras.h>
using namespace WebCore;
using namespace WebKit;
namespace WebKit {
// Internal AppKit class. If the pasteboard handling was in the same process
// that called the dragImage method, this would be created automatically.
// Create it explicitly because dragImage is called in the UI process.
@interface NSFilePromiseDragSource : NSObject
{
char _unknownFields[256];
}
- (id)initWithSource:(id)dragSource;
- (void)setTypes:(NSArray *)types onPasteboard:(NSPasteboard *)pasteboard;
@end
using namespace WebCore;
@interface WKPasteboardFilePromiseOwner : NSFilePromiseDragSource
@end
void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool linkDrag)
@interface WKPasteboardOwner : NSObject
{
if (!frame)
return;
ASSERT(clipboard);
CachedResourceHandle<CachedImage> _image;
}
- (id)initWithImage:(CachedImage*)image;
@end
NSImage *dragNSImage = dragImage.get();
RefPtr<ShareableBitmap> dragShareableImage = ShareableBitmap::createShareable(IntSize([dragNSImage size]));
OwnPtr<GraphicsContext> graphicsContext = dragShareableImage->createGraphicsContext();
namespace WebKit {
[NSGraphicsContext saveGraphicsState];
NSGraphicsContext* bitmapContext = [NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES];
[NSGraphicsContext setCurrentContext: bitmapContext];
static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image)
{
RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize([image size]));
OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext();
NSGraphicsContext *savedContext = [NSGraphicsContext currentContext];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES]];
[image drawInRect:NSMakeRect(0, 0, bitmap->size().width(), bitmap->size().height()) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1 respectFlipped:YES hints:nil];
[dragNSImage drawInRect:NSMakeRect(0, 0, [dragNSImage size].width , [dragNSImage size].height) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1 respectFlipped:YES hints:nil];
[NSGraphicsContext restoreGraphicsState];
[NSGraphicsContext setCurrentContext:savedContext];
return bitmap.release();
}
void WebDragClient::startDrag(RetainPtr<NSImage> image, const IntPoint& point, const IntPoint&, Clipboard*, Frame*, bool linkDrag)
{
RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get());
SharedMemory::Handle handle;
if (!dragShareableImage->createHandle(handle))
if (!bitmap->createHandle(handle))
return;
IntPoint clientPoint(at);
m_page->send(Messages::WebPageProxy::SetDragImage(clientPoint, IntSize([dragNSImage size]), handle, linkDrag));
// FIXME: Seems this mesage should be named StartDrag, not SetDragImage.
m_page->send(Messages::WebPageProxy::SetDragImage(point, bitmap->size(), handle, linkDrag));
}
static CachedImage* cachedImage(Element* element)
{
RenderObject* renderer = element->renderer();
if (!renderer)
return 0;
if (!renderer->isRenderImage())
return 0;
CachedImage* image = toRenderImage(renderer)->cachedImage();
if (!image || image->errorOccurred())
return 0;
return image;
}
static NSArray *arrayForURLsWithTitles(NSURL *URL, NSString *title)
{
return [NSArray arrayWithObjects:[NSArray arrayWithObject:[URL _web_originalDataAsString]],
[NSArray arrayWithObject:[title _webkit_stringByTrimmingWhitespace]], nil];
}
static void writeURL(NSPasteboard* pasteboard, NSURL* URL, NSString* title, NSArray* types)
void WebDragClient::declareAndWriteDragImage(NSPasteboard *pasteboard, DOMElement *element, NSURL *URL, NSString *title, WebCore::Frame*)
{
ASSERT(URL);
ASSERT(element);
ASSERT(pasteboard && pasteboard == [NSPasteboard pasteboardWithName:NSDragPboard]);
Element* coreElement = core(element);
CachedImage* image = cachedImage(coreElement);
NSString *extension = @"";
if (image) {
extension = image->image()->filenameExtension();
if (![extension length])
return;
}
if (![title length]) {
title = [[URL path] lastPathComponent];
......@@ -83,83 +141,163 @@ static void writeURL(NSPasteboard* pasteboard, NSURL* URL, NSString* title, NSAr
title = [URL _web_userVisibleString];
}
if ([types containsObject:NSURLPboardType])
RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(coreElement);
RetainPtr<NSMutableArray> types(AdoptNS, [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]);
[types.get() addObjectsFromArray:archive ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()];
RetainPtr<WKPasteboardOwner> pasteboardOwner(AdoptNS, [[WKPasteboardOwner alloc] initWithImage:image]);
RetainPtr<WKPasteboardFilePromiseOwner> filePromiseOwner(AdoptNS, [(WKPasteboardFilePromiseOwner *)[WKPasteboardFilePromiseOwner alloc] initWithSource:pasteboardOwner.get()]);
m_page->setDragSource(filePromiseOwner.get());
[pasteboard declareTypes:types.get() owner:pasteboardOwner.get()];
[pasteboard setPropertyList:[NSArray arrayWithObject:extension] forType:NSFilesPromisePboardType];
[filePromiseOwner.get() setTypes:[pasteboard propertyListForType:NSFilesPromisePboardType] onPasteboard:pasteboard];
[URL writeToPasteboard:pasteboard];
if ([types containsObject:PasteboardTypes::WebURLPboardType])
[pasteboard setString:[URL _web_originalDataAsString] forType:PasteboardTypes::WebURLPboardType];
if ([types containsObject:PasteboardTypes::WebURLNamePboardType])
[pasteboard setString:title forType:PasteboardTypes::WebURLNamePboardType];
if ([types containsObject:NSStringPboardType])
[pasteboard setString:[URL _web_userVisibleString] forType:NSStringPboardType];
if ([types containsObject:PasteboardTypes::WebURLsWithTitlesPboardType]) {
NSArray* URLs = [NSArray arrayWithObject:URL];
unsigned count = [URLs count];
if (!count || [pasteboard availableTypeFromArray:[NSArray arrayWithObject:PasteboardTypes::WebURLsWithTitlesPboardType]] == nil)
return;
[pasteboard setPropertyList:arrayForURLsWithTitles(URL, title) forType:PasteboardTypes::WebURLsWithTitlesPboardType];
NSArray* titles = [NSArray arrayWithObject:title];
if (archive)
[pasteboard setData:(NSData *)archive->rawDataRepresentation().get() forType:PasteboardTypes::WebArchivePboardType];
}
if (count != [titles count])
titles = nil;
} // namespace WebKit
NSMutableArray* URLStrings = [NSMutableArray arrayWithCapacity:count];
NSMutableArray* titlesOrEmptyStrings = [NSMutableArray arrayWithCapacity:count];
for (unsigned index = 0; index < count; ++index) {
[URLStrings addObject:[[URLs objectAtIndex:index] _web_originalDataAsString]];
[titlesOrEmptyStrings addObject:(titles == nil) ? @"" : [[titles objectAtIndex:index] _webkit_stringByTrimmingWhitespace]];
}
@implementation WKPasteboardFilePromiseOwner
[pasteboard setPropertyList:[NSArray arrayWithObjects:URLStrings, titlesOrEmptyStrings, nil]
forType:PasteboardTypes::WebURLsWithTitlesPboardType];
}
// The AppKit implementation of copyDropDirectory gets the current pasteboard in
// a way that only works in the process where the drag is initiated. We supply
// an implementation that gets the pasteboard by name instead.
- (CFURLRef)copyDropDirectory
{
PasteboardRef pasteboard;
OSStatus status = PasteboardCreate((CFStringRef)NSDragPboard, &pasteboard);
if (status != noErr || !pasteboard)
return 0;
CFURLRef location = 0;
status = PasteboardCopyPasteLocation(pasteboard, &location);
CFRelease(pasteboard);
if (status != noErr || !location)
return 0;
CFMakeCollectable(location);
return location;
}
static void writeImage(NSPasteboard* pasteboard, NSImage *image, DOMElement* element, NSURL* URL, NSString* title, LegacyWebArchive* archive, NSArray* types)
@end
@implementation WKPasteboardOwner
static CachedResourceClient* promisedDataClient()
{
ASSERT(image || element);
ASSERT(URL);
static CachedResourceClient* client = new CachedResourceClient;
return client;
}
writeURL(pasteboard, URL, title, types);
- (void)clearImage
{
if (!_image)
return;
_image->removeClient(promisedDataClient());
_image = 0;
}
if ([types containsObject:NSTIFFPboardType]) {
// FIXME: we should add handling of promised types.
- (id)initWithImage:(CachedImage*)image
{
self = [super init];
if (!self)
return nil;
_image = image;
if (image)
[pasteboard setData:[image TIFFRepresentation] forType:NSTIFFPboardType];
else if (element)
[pasteboard setData:[element _imageTIFFRepresentation] forType:NSTIFFPboardType];
}
image->addClient(promisedDataClient());
return self;
}
if (archive && [types containsObject:PasteboardTypes::WebArchivePboardType])
[pasteboard setData:[[(NSData *)archive->rawDataRepresentation().get() retain] autorelease] forType:PasteboardTypes::WebArchivePboardType];
- (void)dealloc
{
[self clearImage];
[super dealloc];
}
void WebDragClient::declareAndWriteDragImage(NSPasteboard* pasteboard, DOMElement* element, NSURL* URL, NSString* title, WebCore::Frame*)
- (void)finalize
{
ASSERT(element);
ASSERT(pasteboard && pasteboard == [NSPasteboard pasteboardWithName:NSDragPboard]);
[self clearImage];
[super finalize];
}
NSString *extension = @"";
if (RenderObject* renderer = core(element)->renderer()) {
if (renderer->isImage()) {
if (CachedImage* image = toRenderImage(renderer)->cachedImage()) {
extension = image->image()->filenameExtension();
if (![extension length])
- (void)pasteboard:(NSPasteboard *)pasteboard provideDataForType:(NSString *)type
{
if ([type isEqual:NSTIFFPboardType]) {
if (_image) {
if (Image* image = _image->image())
[pasteboard setData:(NSData *)image->getTIFFRepresentation() forType:NSTIFFPboardType];
[self clearImage];
}
return;
}
// FIXME: Handle RTFD here.
}
- (void)pasteboardChangedOwner:(NSPasteboard *)pasteboard
{
[self clearImage];
}
static bool matchesExtensionOrEquivalent(NSString *filename, NSString *extension)
{
NSString *extensionAsSuffix = [@"." stringByAppendingString:extension];
return [filename _webkit_hasCaseInsensitiveSuffix:extensionAsSuffix]
|| ([extension _webkit_isCaseInsensitiveEqualToString:@"jpeg"]
&& [filename _webkit_hasCaseInsensitiveSuffix:@".jpg"]);
}
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
{
NSFileWrapper *wrapper = nil;
NSURL *draggingImageURL = nil;
if (_image) {
if (SharedBuffer* buffer = _image->CachedResource::data()) {
NSData *data = buffer->createNSData();
NSURLResponse *response = _image->response().nsURLResponse();
draggingImageURL = [response URL];
wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease];
NSString* filename = [response suggestedFilename];
NSString* trueExtension(_image->image()->filenameExtension());
if (!matchesExtensionOrEquivalent(filename, trueExtension))
filename = [[filename stringByAppendingString:@"."] stringByAppendingString:trueExtension];
[wrapper setPreferredFilename:filename];
}
}
// FIXME: Do we need to handle the case where we do not have a CachedImage?
// WebKit1 had code for this case.
if (!wrapper) {
LOG_ERROR("Failed to create image file.");
return nil;
}
RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(core(element));
NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil];
[types addObjectsFromArray:(archive) ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()];
[pasteboard declareTypes:types owner:nil];
writeImage(pasteboard, nil, element, URL, title, archive.get(), types);
[types release];
// FIXME: Report an error if we fail to create a file.
NSString *path = [[dropDestination path] stringByAppendingPathComponent:[wrapper preferredFilename]];
path = [[NSFileManager defaultManager] _webkit_pathWithUniqueFilenameForPath:path];
if (![wrapper writeToFile:path atomically:NO updateFilenames:YES])
LOG_ERROR("Failed to create image file via -[NSFileWrapper writeToFile:atomically:updateFilenames:] at path %@", path);
NSArray *extensions = [[NSArray alloc] initWithObjects:extension, nil];
[pasteboard setPropertyList:extensions forType:NSFilesPromisePboardType];
[extensions release];
if (draggingImageURL)
[[NSFileManager defaultManager] _webkit_setMetadataURL:[draggingImageURL absoluteString] referrer:nil atPath:path];
return [NSArray arrayWithObject:[path lastPathComponent]];
}
} // namespace WebKit
@end
......@@ -1514,6 +1514,7 @@ void WebPage::dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint glob
IntPoint adjustedClientPosition(clientPosition.x() + m_page->dragController()->dragOffset().x(), clientPosition.y() + m_page->dragController()->dragOffset().y());
IntPoint adjustedGlobalPosition(globalPosition.x() + m_page->dragController()->dragOffset().x(), globalPosition.y() + m_page->dragController()->dragOffset().y());
platformDragEnded();
m_page->dragController()->dragEnded();
FrameView* view = m_page->mainFrame()->view();
if (!view)
......@@ -2109,4 +2110,10 @@ void WebPage::setMemoryCacheMessagesEnabled(bool memoryCacheMessagesEnabled)
m_page->setMemoryCacheClientCallsEnabled(memoryCacheMessagesEnabled);
}
#if !PLATFORM(MAC)
void WebPage::platformDragEnded()
{
}
#endif
} // namespace WebKit
......@@ -61,6 +61,7 @@
#include "DictionaryPopupInfo.h"
#include <wtf/RetainPtr.h>
OBJC_CLASS AccessibilityWebPageObject;
OBJC_CLASS NSObject;
#endif
namespace CoreIPC {
......@@ -356,6 +357,10 @@ public:
void forceRepaintWithoutCallback();
#if PLATFORM(MAC)
void setDragSource(NSObject *);
#endif
private:
WebPage(uint64_t pageID, const WebPageCreationParameters&);
......@@ -479,6 +484,8 @@ private:
void didSelectItemFromActiveContextMenu(const WebContextMenuItemData&);
#endif
void platformDragEnded();
OwnPtr<WebCore::Page> m_page;
RefPtr<WebFrame> m_mainFrame;
RefPtr<InjectedBundleBackForwardList> m_backForwardList;
......@@ -518,6 +525,8 @@ private:
HashSet<PluginView*> m_pluginViews;
RetainPtr<AccessibilityWebPageObject> m_mockAccessibilityElement;
RetainPtr<NSObject> m_dragSource;
#elif PLATFORM(WIN)
// Our view's window (in the UI process).
HWND m_nativeWindow;
......
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
* Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -481,4 +481,17 @@ bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request)
return request.url().protocolIs("applewebdata");
}
void WebPage::setDragSource(NSObject *dragSource)
{
m_dragSource = dragSource;
}
void WebPage::platformDragEnded()
{
// The drag source we care about here is NSFilePromiseDragSource, which doesn't look at
// the arguments. It's OK to just pass arbitrary constant values, so we just pass all zeroes.
[m_dragSource.get() draggedImage:nil endedAt:NSZeroPoint operation:NSDragOperationNone];
m_dragSource = nullptr;
}
} // namespace WebKit
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