Commit 9d9813d0 authored by enrica@apple.com's avatar enrica@apple.com

Source/WebCore: WebKit2: Add support for drag and drop

https://bugs.webkit.org/show_bug.cgi?id=52343
<rdar://problem/7660558>
               
Reviewed by Darin Adler.

This patch contains the changes required to support dropping content
in WebKit on the Mac. The DragData class has been extended to provide
additional context from the application (keyboard state, modal windows, etc.)
as well as information of the drag pasteboard being used.
The support for WebKit as drag source will be added with a separate patch.

* WebCore.exp.in:
* page/DragController.cpp:
(WebCore::DragController::dragIsMove): Added DragData parameter.
(WebCore::DragController::tryDocumentDrag): Modified call to dragIsMove.
(WebCore::DragController::concludeEditDrag): Same as above.
* page/DragController.h: Added parameter to isCopyKeyDown.
* page/mac/DragControllerMac.mm:
The following methods have been modified to use the information stored
in the DragData class.
(WebCore::DragController::isCopyKeyDown):
(WebCore::DragController::dragOperation):
* platform/DragData.h:
(WebCore::DragData::flags):
* platform/DragData.cpp: Added default flags parameter to the constructor.
* platform/mac/DragDataMac.mm:
(WebCore::DragData::DragData): Added constructor that receives the name of the pasteboard to use.
(WebCore::DragData::canSmartReplace):
(WebCore::DragData::containsColor):
(WebCore::DragData::containsFiles):
(WebCore::DragData::asFilenames):
(WebCore::DragData::containsPlainText):
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
All the following files have been modified to add the DragData
parameter to isCopyKeyDown. I plan to improve this in the future
and make isCopyKeyDown not platform specific.
* page/android/DragControllerAndroid.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/brew/DragControllerBrew.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/chromium/DragControllerChromium.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/efl/DragControllerEfl.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/gtk/DragControllerGtk.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/haiku/DragControllerHaiku.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/mac/DragControllerMac.mm:
(WebCore::DragController::isCopyKeyDown):
(WebCore::DragController::dragOperation):
* page/qt/DragControllerQt.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/win/DragControllerWin.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/wx/DragControllerWx.cpp:
(WebCore::DragController::isCopyKeyDown):

WebKit/mac: WebKit2: Add support for drag and drop
https://bugs.webkit.org/show_bug.cgi?id=52343
<rdar://problem/7660558>
        
Reviewed by Darin Adler.

The DragData class has been extended to provide
additional context from the application (keyboard state, modal windows, etc.)
as well as information of the drag pasteboard being used.
These are the changes to align the behavior for WebKit.

* WebView/WebView.mm:
(-[WebView applicationFlags:]): Added.
(-[WebView draggingEntered:]): Added parameter to the DragData constructor.
(-[WebView draggingUpdated:]): Added parameter to the DragData constructor.
(-[WebView draggingExited:]): Added parameter to the DragData constructor.
(-[WebView performDragOperation:]): Added parameter to the DragData constructor.

WebKit2: WebKit2: Add support for drag and drop
https://bugs.webkit.org/show_bug.cgi?id=52343
<rdar://problem/7660558>
               
Reviewed by Darin Adler.

This patch contains the changes required to support dropping content
in WebKit on the Mac. The DragData class has been extended to provide
additional context from the application (keyboard state, modal windows, etc.)
as well as information of the drag pasteboard being used.
The support for WebKit as drag source will be added with a separate patch.

* Shared/DragControllerAction.h: Added.
* UIProcess/API/mac/WKView.mm:
Added implemention of the methods required to add suport for a drop target.
To maintain asynchronous communication with the WebProcess, we always return
the previous calculated value for the drag operation.
(-[WKView _registerDraggedTypes]):
(-[WKView initWithFrame:contextRef:pageGroupRef:]):
(-[WKView applicationFlags:]):
(-[WKView draggingEntered:]):
(-[WKView draggingUpdated:]):
(-[WKView draggingExited:]):
(-[WKView prepareForDragOperation:]):
(-[WKView performDragOperation:]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::performDragControllerAction):
(WebKit::WebPageProxy::didPerformDragControllerAction):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::dragOperation):
(WebKit::WebPageProxy::resetDragOperation):
* UIProcess/WebPageProxy.messages.in:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebDragClient.cpp:
(WebKit::WebDragClient::willPerformDragDestinationAction):
(WebKit::WebDragClient::willPerformDragSourceAction):
(WebKit::WebDragClient::actionMaskForDrag):
(WebKit::WebDragClient::dragSourceActionMaskForPoint):
(WebKit::WebDragClient::startDrag):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::performDragControllerAction):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75743 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent de794561
2011-01-12 Enrica Casucci <enrica@apple.com>
Reviewed by Darin Adler.
WebKit2: Add support for drag and drop
https://bugs.webkit.org/show_bug.cgi?id=52343
<rdar://problem/7660558>
This patch contains the changes required to support dropping content
in WebKit on the Mac. The DragData class has been extended to provide
additional context from the application (keyboard state, modal windows, etc.)
as well as information of the drag pasteboard being used.
The support for WebKit as drag source will be added with a separate patch.
* WebCore.exp.in:
* page/DragController.cpp:
(WebCore::DragController::dragIsMove): Added DragData parameter.
(WebCore::DragController::tryDocumentDrag): Modified call to dragIsMove.
(WebCore::DragController::concludeEditDrag): Same as above.
* page/DragController.h: Added parameter to isCopyKeyDown.
* page/mac/DragControllerMac.mm:
The following methods have been modified to use the information stored
in the DragData class.
(WebCore::DragController::isCopyKeyDown):
(WebCore::DragController::dragOperation):
* platform/DragData.h:
(WebCore::DragData::flags):
* platform/DragData.cpp: Added default flags parameter to the constructor.
* platform/mac/DragDataMac.mm:
(WebCore::DragData::DragData): Added constructor that receives the name of the pasteboard to use.
(WebCore::DragData::canSmartReplace):
(WebCore::DragData::containsColor):
(WebCore::DragData::containsFiles):
(WebCore::DragData::asFilenames):
(WebCore::DragData::containsPlainText):
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
All the following files have been modified to add the DragData
parameter to isCopyKeyDown. I plan to improve this in the future
and make isCopyKeyDown not platform specific.
* page/android/DragControllerAndroid.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/brew/DragControllerBrew.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/chromium/DragControllerChromium.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/efl/DragControllerEfl.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/gtk/DragControllerGtk.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/haiku/DragControllerHaiku.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/mac/DragControllerMac.mm:
(WebCore::DragController::isCopyKeyDown):
(WebCore::DragController::dragOperation):
* page/qt/DragControllerQt.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/win/DragControllerWin.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/wx/DragControllerWx.cpp:
(WebCore::DragController::isCopyKeyDown):
2011-01-13 David Kilzer <ddkilzer@apple.com> 2011-01-13 David Kilzer <ddkilzer@apple.com>
Add missing MathMLElementFactory.h and MathMLNames.h to Xcode project Add missing MathMLElementFactory.h and MathMLNames.h to Xcode project
...@@ -299,6 +363,7 @@ ...@@ -299,6 +363,7 @@
* html/canvas/WebGLRenderingContext.cpp: * html/canvas/WebGLRenderingContext.cpp:
>>>>>>> .r75740
2011-01-13 Adrienne Walker <enne@google.com> 2011-01-13 Adrienne Walker <enne@google.com>
Reviewed by Kenneth Russell. Reviewed by Kenneth Russell.
...@@ -758,6 +823,7 @@ ...@@ -758,6 +823,7 @@
(WebCore::firstPositionInOrBeforeNode): Added. (WebCore::firstPositionInOrBeforeNode): Added.
(WebCore::lastPositionInOrAfterNode): Added. (WebCore::lastPositionInOrAfterNode): Added.
>>>>>>> .r75734
2011-01-12 Sam Weinig <sam@webkit.org> 2011-01-12 Sam Weinig <sam@webkit.org>
Another build fix. Another build fix.
......
...@@ -1328,7 +1328,8 @@ __ZN7WebCore14DragController11dragUpdatedEPNS_8DragDataE ...@@ -1328,7 +1328,8 @@ __ZN7WebCore14DragController11dragUpdatedEPNS_8DragDataE
__ZN7WebCore14DragController11performDragEPNS_8DragDataE __ZN7WebCore14DragController11performDragEPNS_8DragDataE
__ZN7WebCore14DragController14placeDragCaretERKNS_8IntPointE __ZN7WebCore14DragController14placeDragCaretERKNS_8IntPointE
__ZN7WebCore14DragController9dragEndedEv __ZN7WebCore14DragController9dragEndedEv
__ZN7WebCore8DragDataC1EP11objc_objectRKNS_8IntPointES5_NS_13DragOperationE __ZN7WebCore8DragDataC1EP11objc_objectRKNS_8IntPointES5_NS_13DragOperationENS_20DragApplicationFlagsE
__ZN7WebCore8DragDataC1ERKN3WTF6StringERKNS_8IntPointES7_NS_13DragOperationENS_20DragApplicationFlagsE
#endif #endif
#if ENABLE(GEOLOCATION) #if ENABLE(GEOLOCATION)
......
...@@ -22381,6 +22381,7 @@ ...@@ -22381,6 +22381,7 @@
isa = PBXProject; isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */; buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
compatibilityVersion = "Xcode 2.4"; compatibilityVersion = "Xcode 2.4";
developmentRegion = English;
hasScannedForEncodings = 1; hasScannedForEncodings = 1;
knownRegions = ( knownRegions = (
English, English,
...@@ -141,9 +141,9 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD ...@@ -141,9 +141,9 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD
return 0; return 0;
} }
bool DragController::dragIsMove(SelectionController* selection) bool DragController::dragIsMove(SelectionController* selection, DragData* dragData)
{ {
return m_documentUnderMouse == m_dragInitiator && selection->isContentEditable() && !isCopyKeyDown(); return m_documentUnderMouse == m_dragInitiator && selection->isContentEditable() && !isCopyKeyDown(dragData);
} }
// FIXME: This method is poorly named. We're just clearing the selection from the document this drag is exiting. // FIXME: This method is poorly named. We're just clearing the selection from the document this drag is exiting.
...@@ -335,7 +335,7 @@ bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction a ...@@ -335,7 +335,7 @@ bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction a
} }
Frame* innerFrame = element->document()->frame(); Frame* innerFrame = element->document()->frame();
operation = dragIsMove(innerFrame->selection()) ? DragOperationMove : DragOperationCopy; operation = dragIsMove(innerFrame->selection(), dragData) ? DragOperationMove : DragOperationCopy;
return true; return true;
} }
// If we're not over an editable region, make sure we're clearing any prior drag cursor. // If we're not over an editable region, make sure we're clearing any prior drag cursor.
...@@ -449,7 +449,7 @@ bool DragController::concludeEditDrag(DragData* dragData) ...@@ -449,7 +449,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
return false; return false;
CachedResourceLoader* cachedResourceLoader = range->ownerDocument()->cachedResourceLoader(); CachedResourceLoader* cachedResourceLoader = range->ownerDocument()->cachedResourceLoader();
cachedResourceLoader->setAllowStaleResources(true); cachedResourceLoader->setAllowStaleResources(true);
if (dragIsMove(innerFrame->selection()) || dragCaret.isContentRichlyEditable()) { if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRichlyEditable()) {
bool chosePlainText = false; bool chosePlainText = false;
RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame, range, true, chosePlainText); RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame, range, true, chosePlainText);
if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, range, EditorInsertActionDropped)) { if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, range, EditorInsertActionDropped)) {
...@@ -458,7 +458,7 @@ bool DragController::concludeEditDrag(DragData* dragData) ...@@ -458,7 +458,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
} }
m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData); m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
if (dragIsMove(innerFrame->selection())) { if (dragIsMove(innerFrame->selection(), dragData)) {
// NSTextView behavior is to always smart delete on moving a selection, // NSTextView behavior is to always smart delete on moving a selection,
// but only to smart insert if the selection granularity is word granularity. // but only to smart insert if the selection granularity is word granularity.
bool smartDelete = innerFrame->editor()->smartInsertDeleteEnabled(); bool smartDelete = innerFrame->editor()->smartInsertDeleteEnabled();
......
...@@ -99,8 +99,8 @@ namespace WebCore { ...@@ -99,8 +99,8 @@ namespace WebCore {
bool tryDHTMLDrag(DragData*, DragOperation&); bool tryDHTMLDrag(DragData*, DragOperation&);
DragOperation dragOperation(DragData*); DragOperation dragOperation(DragData*);
void cancelDrag(); void cancelDrag();
bool dragIsMove(SelectionController*); bool dragIsMove(SelectionController*, DragData*);
bool isCopyKeyDown(); bool isCopyKeyDown(DragData*);
void mouseMovedIntoDocument(Document*); void mouseMovedIntoDocument(Document*);
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
namespace WebCore { namespace WebCore {
bool DragController::isCopyKeyDown() bool DragController::isCopyKeyDown(DragData*)
{ {
return false; return false;
} }
......
...@@ -41,7 +41,7 @@ const int DragController::DragIconBottomInset = 3; ...@@ -41,7 +41,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f; const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown() bool DragController::isCopyKeyDown(DragData*)
{ {
return false; return false;
} }
......
...@@ -54,7 +54,7 @@ DragOperation DragController::dragOperation(DragData* dragData) ...@@ -54,7 +54,7 @@ DragOperation DragController::dragOperation(DragData* dragData)
return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone; return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
} }
bool DragController::isCopyKeyDown() bool DragController::isCopyKeyDown(DragData*)
{ {
// FIXME: This should not be OS specific. Delegate to the embedder instead. // FIXME: This should not be OS specific. Delegate to the embedder instead.
#if OS(WINDOWS) #if OS(WINDOWS)
......
...@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3; ...@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f; const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown() bool DragController::isCopyKeyDown(DragData*)
{ {
return false; return false;
} }
......
...@@ -42,7 +42,7 @@ const int DragController::DragIconBottomInset = 3; ...@@ -42,7 +42,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f; const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown() bool DragController::isCopyKeyDown(DragData*)
{ {
return false; return false;
} }
......
...@@ -44,7 +44,7 @@ const int DragController::DragIconBottomInset = 3; ...@@ -44,7 +44,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f; const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown() bool DragController::isCopyKeyDown(DragData*)
{ {
if (modifiers() & B_COMMAND_KEY) if (modifiers() & B_COMMAND_KEY)
return true; return true;
......
...@@ -42,19 +42,19 @@ const int DragController::DragIconBottomInset = 3; ...@@ -42,19 +42,19 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f; const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown() bool DragController::isCopyKeyDown(DragData* dragData)
{ {
return [[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask; return dragData->flags() & DragApplicationIsCopyKeyDown;
} }
DragOperation DragController::dragOperation(DragData* dragData) DragOperation DragController::dragOperation(DragData* dragData)
{ {
ASSERT(dragData); ASSERT(dragData);
if ([NSApp modalWindow] || !dragData->containsURL(m_page->mainFrame()))
if ((dragData->flags() & DragApplicationIsModal) || !dragData->containsURL(m_page->mainFrame()))
return DragOperationNone; return DragOperationNone;
if (!m_documentUnderMouse || (![[m_page->mainFrame()->view()->getOuterView() window] attachedSheet] if (!m_documentUnderMouse || (!(dragData->flags() & (DragApplicationHasAttachedSheet | DragApplicationIsSource))))
&& [dragData->platformData() draggingSource] != m_page->mainFrame()->view()->getOuterView()))
return DragOperationCopy; return DragOperationCopy;
return DragOperationNone; return DragOperationNone;
......
...@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3; ...@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f; const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown() bool DragController::isCopyKeyDown(DragData*)
{ {
return false; return false;
} }
......
...@@ -50,7 +50,7 @@ DragOperation DragController::dragOperation(DragData* dragData) ...@@ -50,7 +50,7 @@ DragOperation DragController::dragOperation(DragData* dragData)
return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone; return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
} }
bool DragController::isCopyKeyDown() bool DragController::isCopyKeyDown(DragData*)
{ {
return ::GetAsyncKeyState(VK_CONTROL); return ::GetAsyncKeyState(VK_CONTROL);
} }
......
...@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3; ...@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f; const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown() bool DragController::isCopyKeyDown(DragData*)
{ {
notImplemented(); notImplemented();
return false; return false;
......
...@@ -31,13 +31,24 @@ namespace WebCore { ...@@ -31,13 +31,24 @@ namespace WebCore {
#if !PLATFORM(MAC) #if !PLATFORM(MAC)
DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition,
DragOperation sourceOperationMask) DragOperation sourceOperationMask, DragApplicationFlags flags)
: m_clientPosition(clientPosition) : m_clientPosition(clientPosition)
, m_globalPosition(globalPosition) , m_globalPosition(globalPosition)
, m_platformDragData(data) , m_platformDragData(data)
, m_draggingSourceOperationMask(sourceOperationMask) , m_draggingSourceOperationMask(sourceOperationMask)
, m_applicationFlags(flags)
{ {
} }
DragData::DragData(const String&, const IntPoint& clientPosition, const IntPoint& globalPosition,
DragOperation sourceOperationMask, DragApplicationFlags flags)
: m_clientPosition(clientPosition)
, m_globalPosition(globalPosition)
, m_platformDragData(0)
, m_draggingSourceOperationMask(sourceOperationMask)
, m_applicationFlags(flags)
{
}
#endif #endif
} // namespace WebCore } // namespace WebCore
......
...@@ -34,12 +34,15 @@ ...@@ -34,12 +34,15 @@
#include <wtf/Vector.h> #include <wtf/Vector.h>
#if PLATFORM(MAC) #if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#ifdef __OBJC__ #ifdef __OBJC__
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <AppKit/NSDragging.h> #import <AppKit/NSDragging.h>
typedef id <NSDraggingInfo> DragDataRef; typedef id <NSDraggingInfo> DragDataRef;
@class NSPasteboard;
#else #else
typedef void* DragDataRef; typedef void* DragDataRef;
class NSPasteboard;
#endif #endif
#elif PLATFORM(QT) #elif PLATFORM(QT)
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
...@@ -72,14 +75,25 @@ class DocumentFragment; ...@@ -72,14 +75,25 @@ class DocumentFragment;
class KURL; class KURL;
class Range; class Range;
enum DragApplicationFlags {
DragApplicationNone = 0,
DragApplicationIsModal = 1,
DragApplicationIsSource = 2,
DragApplicationHasAttachedSheet = 4,
DragApplicationIsCopyKeyDown = 8
};
class DragData { class DragData {
public: public:
enum FilenameConversionPolicy { DoNotConvertFilenames, ConvertFilenames }; enum FilenameConversionPolicy { DoNotConvertFilenames, ConvertFilenames };
// clientPosition is taken to be the position of the drag event within the target window, with (0,0) at the top left // clientPosition is taken to be the position of the drag event within the target window, with (0,0) at the top left
DragData(DragDataRef, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation operation); DragData(DragDataRef, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation, DragApplicationFlags = DragApplicationNone);
DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation, DragApplicationFlags = DragApplicationNone);
const IntPoint& clientPosition() const { return m_clientPosition; } const IntPoint& clientPosition() const { return m_clientPosition; }
const IntPoint& globalPosition() const { return m_globalPosition; } const IntPoint& globalPosition() const { return m_globalPosition; }
DragApplicationFlags flags() { return m_applicationFlags; }
DragDataRef platformData() const { return m_platformDragData; } DragDataRef platformData() const { return m_platformDragData; }
DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; } DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; }
bool containsURL(Frame*, FilenameConversionPolicy filenamePolicy = ConvertFilenames) const; bool containsURL(Frame*, FilenameConversionPolicy filenamePolicy = ConvertFilenames) const;
...@@ -99,6 +113,10 @@ private: ...@@ -99,6 +113,10 @@ private:
IntPoint m_globalPosition; IntPoint m_globalPosition;
DragDataRef m_platformDragData; DragDataRef m_platformDragData;
DragOperation m_draggingSourceOperationMask; DragOperation m_draggingSourceOperationMask;
DragApplicationFlags m_applicationFlags;
#if PLATFORM(MAC)
RetainPtr<NSPasteboard> m_pasteboard;
#endif
}; };
} }
......
...@@ -38,11 +38,24 @@ ...@@ -38,11 +38,24 @@
namespace WebCore { namespace WebCore {
DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition,
DragOperation sourceOperationMask) DragOperation sourceOperationMask, DragApplicationFlags flags)
: m_clientPosition(clientPosition) : m_clientPosition(clientPosition)
, m_globalPosition(globalPosition) , m_globalPosition(globalPosition)
, m_platformDragData(data) , m_platformDragData(data)
, m_draggingSourceOperationMask(sourceOperationMask) , m_draggingSourceOperationMask(sourceOperationMask)
, m_applicationFlags(flags)
, m_pasteboard([m_platformDragData draggingPasteboard])
{
}
DragData::DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition,
DragOperation sourceOperationMask, DragApplicationFlags flags)
: m_clientPosition(clientPosition)
, m_globalPosition(globalPosition)
, m_platformDragData(0)
, m_draggingSourceOperationMask(sourceOperationMask)
, m_applicationFlags(flags)
, m_pasteboard([NSPasteboard pasteboardWithName:dragStorageName])
{ {
} }
...@@ -50,22 +63,22 @@ bool DragData::canSmartReplace() const ...@@ -50,22 +63,22 @@ bool DragData::canSmartReplace() const
{ {
//Need to call this so that the various Pasteboard type strings are intialised //Need to call this so that the various Pasteboard type strings are intialised
Pasteboard::generalPasteboard(); Pasteboard::generalPasteboard();
return [[[m_platformDragData draggingPasteboard] types] containsObject:WebSmartPastePboardType]; return [[m_pasteboard.get() types] containsObject:WebSmartPastePboardType];
} }
bool DragData::containsColor() const bool DragData::containsColor() const
{ {
return [[[m_platformDragData draggingPasteboard] types] containsObject:NSColorPboardType]; return [[m_pasteboard.get() types] containsObject:NSColorPboardType];
} }
bool DragData::containsFiles() const bool DragData::containsFiles() const
{ {
return [[[m_platformDragData draggingPasteboard] types] containsObject:NSFilenamesPboardType]; return [[m_pasteboard.get() types] containsObject:NSFilenamesPboardType];
} }
void DragData::asFilenames(Vector<String>& result) const void DragData::asFilenames(Vector<String>& result) const
{ {
NSArray *filenames = [[m_platformDragData draggingPasteboard] propertyListForType:NSFilenamesPboardType]; NSArray *filenames = [m_pasteboard.get() propertyListForType:NSFilenamesPboardType];
NSEnumerator *fileEnumerator = [filenames objectEnumerator]; NSEnumerator *fileEnumerator = [filenames objectEnumerator];
while (NSString *filename = [fileEnumerator nextObject]) while (NSString *filename = [fileEnumerator nextObject])
...@@ -74,19 +87,18 @@ void DragData::asFilenames(Vector<String>& result) const ...@@ -74,19 +87,18 @@ void DragData::asFilenames(Vector<String>& result) const
bool DragData::containsPlainText() const bool DragData::containsPlainText() const
{ {
NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard]; NSArray *types = [m_pasteboard.get() types];
NSArray *types = [pasteboard types];
return [types containsObject:NSStringPboardType] return [types containsObject:NSStringPboardType]
|| [types containsObject:NSRTFDPboardType] || [types containsObject:NSRTFDPboardType]
|| [types containsObject:NSRTFPboardType] || [types containsObject:NSRTFPboardType]
|| [types containsObject:NSFilenamesPboardType] || [types containsObject:NSFilenamesPboardType]
|| [NSURL URLFromPasteboard:pasteboard]; || [NSURL URLFromPasteboard:m_pasteboard.get()];
} }
String DragData::asPlainText(Frame *frame) const String DragData::asPlainText(Frame *frame) const
{ {
Pasteboard pasteboard([m_platformDragData draggingPasteboard]); Pasteboard pasteboard(m_pasteboard.get());
return pasteboard.plainText(frame); return pasteboard.plainText(frame);
} }
...@@ -113,8 +125,7 @@ static NSArray *insertablePasteboardTypes() ...@@ -113,8 +125,7 @@ static NSArray *insertablePasteboardTypes()
bool DragData::containsCompatibleContent() const bool DragData::containsCompatibleContent() const
{ {
NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard]; NSMutableSet *types = [NSMutableSet setWithArray:[m_pasteboard.get() types]];
NSMutableSet *types = [NSMutableSet setWithArray:[pasteboard types]];
[types intersectSet:[NSSet setWithArray:insertablePasteboardTypes()]]; [types intersectSet:[NSSet setWithArray:insertablePasteboardTypes()]];
return [types count] != 0; return [types count] != 0;
} }
...@@ -133,13 +144,13 @@ String DragData::asURL(Frame* frame, FilenameConversionPolicy filenamePolicy, St ...@@ -133,13 +144,13 @@ String DragData::asURL(Frame* frame, FilenameConversionPolicy filenamePolicy, St
if (NSString *URLTitleString = [[m_platformDragData draggingPasteboard] stringForType:WebURLNamePboardType]) if (NSString *URLTitleString = [[m_platformDragData draggingPasteboard] stringForType:WebURLNamePboardType])
*title = URLTitleString; *title = URLTitleString;
} }
Pasteboard pasteboard([m_platformDragData draggingPasteboard]); Pasteboard pasteboard(m_pasteboard.get());
return pasteboard.asURL(frame); return pasteboard.asURL(frame);
} }
PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range> range, bool allowPlainText, bool& chosePlainText) const PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range> range, bool allowPlainText, bool& chosePlainText) const
{ {
<