Commit 964ea218 authored by enrica@apple.com's avatar enrica@apple.com

Source/WebCore: Paste and drag and drop use different code paths to interact with the pasteboard.

https://bugs.webkit.org/show_bug.cgi?id=52093
The change consists in a refactoring of the code to have only one class that
deals with the pasteboard on Mac.

Reviewed by Alexey Proskuryakov.

No new tests. A test is already available for this
(editing/pasteboard/drag-image-to-contenteditable-in-iframe.html) but had incorrect results.

* WebCore.exp.in:
* loader/EmptyClients.h: Added two Mac only methods to call into WebKit to use functionality
that is in NSURLExtras.
(WebCore::EmptyEditorClient::canonicalizeURL):
(WebCore::EmptyEditorClient::canonicalizeURLString):
* page/DragController.cpp:
The following methods have been changed to pass a pointer to the Frame object
to the DragData class.
(WebCore::documentFragmentFromDragData):
(WebCore::DragController::performDrag):
(WebCore::DragController::dispatchTextInputEventFor):
(WebCore::DragController::concludeEditDrag):
* page/EditorClient.h: Added two Mac only methods to call into WebKit to use functionality
that is in NSURLExtras.
The following files have been modified to pass the Frame object to the DragData method calls.
* page/chromium/DragControllerChromium.cpp:
(WebCore::DragController::dragOperation):
* page/gtk/DragControllerGtk.cpp:
(WebCore::DragController::dragOperation):
* page/mac/DragControllerMac.mm:
(WebCore::DragController::dragOperation):
* page/qt/DragControllerQt.cpp:
(WebCore::DragController::dragOperation):
* page/win/DragControllerWin.cpp:
(WebCore::DragController::dragOperation):
* platform/DragData.h: Removed Mac specific constructor and reference to PasteboardHelper class.
* platform/Pasteboard.h: Added public constructor to create a Pasteboard object from an NSPasteboard.
The following files were all modified to match the new parameters of the methods listed.
* platform/android/DragDataAndroid.cpp:
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/chromium/DragDataChromium.cpp:
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::asFragment):
* platform/gtk/DragDataGtk.cpp:
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/haiku/DragDataHaiku.cpp:
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/mac/DragDataMac.mm:
(WebCore::DragData::DragData):
(WebCore::DragData::asPlainText):
(WebCore::insertablePasteboardTypes):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::getBestURL):
(WebCore::Pasteboard::asURL):
* platform/qt/DragDataQt.cpp:
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/win/DragDataWin.cpp:
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::asFragment):
* platform/wince/DragDataWinCE.cpp:
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asPlainText):
(WebCore::DragData::asFragment):
* platform/wx/DragDataWx.cpp:
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):

WebKit: Paste and drag and drop use different code paths to interact with the pasteboard.
https://bugs.webkit.org/show_bug.cgi?id=52093
The change consists in a refactoring of the code to have only one class that
deals with the pasteboard on Mac.

Reviewed by Alexey Proskuryakov.

* WebKit.xcodeproj/project.pbxproj: Removed WebPasteboardHelper.mm and WebPasteboardHelper.h.

WebKit/mac: Paste and drag and drop use different code paths to interact with the pasteboard.
https://bugs.webkit.org/show_bug.cgi?id=52093
The change consists in a refactoring of the code to have only one class that
deals with the pasteboard on Mac.

Reviewed by Alexey Proskuryakov.

* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm: Added two methods to provide to WebCore functionality
exposed by NSURLExtras.
(WebEditorClient::canonicalizeURL):
(WebEditorClient::canonicalizeURLString):
* WebCoreSupport/WebPasteboardHelper.h: Removed.
* WebCoreSupport/WebPasteboardHelper.mm: Removed.
* WebView/WebHTMLView.mm: Removed comment.
* WebView/WebView.mm: The following methods have been changed to use the new DragData
constructor that doesn't use the WebPasteboardHelper reference.
(-[WebView draggingEntered:]):
(-[WebView draggingUpdated:]):
(-[WebView draggingExited:]):
(-[WebView performDragOperation:]):

WebKit2: Paste and drag and drop use different code paths to interact with the pasteboard.
https://bugs.webkit.org/show_bug.cgi?id=52093
The change consists in a refactoring of the code to have only one class that
deals with the pasteboard on Mac.

Reviewed by Alexey Proskuryakov.

* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm: Added two methods to provide to WebCore functionality
exposed by NSURLExtras.
(WebKit::WebEditorClient::canonicalizeURL):
(WebKit::WebEditorClient::canonicalizeURLString):

LayoutTests: Paste and drag and drop use different code paths to interact with the pasteboard.
https://bugs.webkit.org/show_bug.cgi?id=52093

Reviewed by Alexey Proskuryakov.

New test results added to match the correct behavior.
        
* platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.checksum:
* platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.png:
* platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.txt:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75523 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 609fc0d4
2011-01-07 Enrica Casucci <enrica@apple.com>
Reviewed by Alexey Proskuryakov.
Paste and drag and drop use different code paths to interact with the pasteboard.
https://bugs.webkit.org/show_bug.cgi?id=52093
New test results added to match the correct behavior.
* platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.checksum:
* platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.png:
* platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.txt:
2011-01-11 Mihai Parparita <mihaip@chromium.org>
Unreviewed; chromium test expectations update.
......
507f0044be28d7fe3ca8a3ae46f4e8d6
\ No newline at end of file
2733ef0d0dee7e02d8dd636d4b317935
\ No newline at end of file
......@@ -18,8 +18,8 @@ layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 300x150
RenderBody {BODY} at (8,8) size 284x134
RenderBlock {DIV} at (0,0) size 271x129 [border: (1px solid #000000)]
RenderImage {IMG} at (1,1) size 20x20
RenderImage {IMG} at (21,1) size 20x20
RenderImage {IMG} at (1,84) size 20x20
RenderImage {IMG} at (21,1) size 76x103
RenderText {#text} at (0,0) size 0x0
RenderBlock {UL} at (0,226) size 784x0
selection start: position 0 of child 3 {IMG} of body
......
2011-01-10 Enrica Casucci <enrica@apple.com>
Reviewed by Alexey Proskuryakov.
Paste and drag and drop use different code paths to interact with the pasteboard.
https://bugs.webkit.org/show_bug.cgi?id=52093
The change consists in a refactoring of the code to have only one class that
deals with the pasteboard on Mac.
No new tests. A test is already available for this
(editing/pasteboard/drag-image-to-contenteditable-in-iframe.html) but had incorrect results.
* WebCore.exp.in:
* loader/EmptyClients.h: Added two Mac only methods to call into WebKit to use functionality
that is in NSURLExtras.
(WebCore::EmptyEditorClient::canonicalizeURL):
(WebCore::EmptyEditorClient::canonicalizeURLString):
* page/DragController.cpp:
The following methods have been changed to pass a pointer to the Frame object
to the DragData class.
(WebCore::documentFragmentFromDragData):
(WebCore::DragController::performDrag):
(WebCore::DragController::dispatchTextInputEventFor):
(WebCore::DragController::concludeEditDrag):
* page/EditorClient.h: Added two Mac only methods to call into WebKit to use functionality
that is in NSURLExtras.
The following files have been modified to pass the Frame object to the DragData method calls.
* page/chromium/DragControllerChromium.cpp:
(WebCore::DragController::dragOperation):
* page/gtk/DragControllerGtk.cpp:
(WebCore::DragController::dragOperation):
* page/mac/DragControllerMac.mm:
(WebCore::DragController::dragOperation):
* page/qt/DragControllerQt.cpp:
(WebCore::DragController::dragOperation):
* page/win/DragControllerWin.cpp:
(WebCore::DragController::dragOperation):
* platform/DragData.h: Removed Mac specific constructor and reference to PasteboardHelper class.
* platform/Pasteboard.h: Added public constructor to create a Pasteboard object from an NSPasteboard.
The following files were all modified to match the new parameters of the methods listed.
* platform/android/DragDataAndroid.cpp:
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/chromium/DragDataChromium.cpp:
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::asFragment):
* platform/gtk/DragDataGtk.cpp:
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/haiku/DragDataHaiku.cpp:
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/mac/DragDataMac.mm:
(WebCore::DragData::DragData):
(WebCore::DragData::asPlainText):
(WebCore::insertablePasteboardTypes):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::getBestURL):
(WebCore::Pasteboard::asURL):
* platform/qt/DragDataQt.cpp:
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/win/DragDataWin.cpp:
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::asFragment):
* platform/wince/DragDataWinCE.cpp:
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asPlainText):
(WebCore::DragData::asFragment):
* platform/wx/DragDataWx.cpp:
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsURL):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
2011-01-11 Abhishek Arya <inferno@chromium.org>
Reviewed by Dimitri Glazkov.
......
......@@ -1324,7 +1324,7 @@ __ZN7WebCore14DragController11dragUpdatedEPNS_8DragDataE
__ZN7WebCore14DragController11performDragEPNS_8DragDataE
__ZN7WebCore14DragController14placeDragCaretERKNS_8IntPointE
__ZN7WebCore14DragController9dragEndedEv
__ZN7WebCore8DragDataC1EP11objc_objectRKNS_8IntPointES5_NS_13DragOperationEPNS_16PasteboardHelperE
__ZN7WebCore8DragDataC1EP11objc_objectRKNS_8IntPointES5_NS_13DragOperationE
#endif
#if ENABLE(GEOLOCATION)
......
......@@ -453,6 +453,8 @@ public:
virtual NSString* userVisibleString(NSURL*) { return 0; }
virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector<RefPtr<ArchiveResource> >&) { return 0; };
virtual void setInsertionPasteboard(NSPasteboard*) { };
virtual NSURL* canonicalizeURL(NSURL*) { return 0; }
virtual NSURL* canonicalizeURLString(NSString*) { return 0; }
#ifdef BUILDING_ON_TIGER
virtual NSArray* pasteboardTypesForSelection(Frame*) { return 0; }
#endif
......
......@@ -99,7 +99,7 @@ DragController::~DragController()
m_client->dragControllerDestroyed();
}
static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragData, RefPtr<Range> context,
static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragData, Frame* frame, RefPtr<Range> context,
bool allowPlainText, bool& chosePlainText)
{
ASSERT(dragData);
......@@ -108,19 +108,19 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD
Document* document = context->ownerDocument();
ASSERT(document);
if (document && dragData->containsCompatibleContent()) {
if (PassRefPtr<DocumentFragment> fragment = dragData->asFragment(document))
if (PassRefPtr<DocumentFragment> fragment = dragData->asFragment(frame, context, allowPlainText, chosePlainText))
return fragment;
if (dragData->containsURL(DragData::DoNotConvertFilenames)) {
if (dragData->containsURL(frame, DragData::DoNotConvertFilenames)) {
String title;
String url = dragData->asURL(DragData::DoNotConvertFilenames, &title);
String url = dragData->asURL(frame, DragData::DoNotConvertFilenames, &title);
if (!url.isEmpty()) {
RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(document);
anchor->setHref(url);
if (title.isEmpty()) {
// Try the plain text first because the url might be normalized or escaped.
if (dragData->containsPlainText())
title = dragData->asPlainText();
title = dragData->asPlainText(frame);
if (title.isEmpty())
title = url;
}
......@@ -135,7 +135,7 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD
}
if (allowPlainText && dragData->containsPlainText()) {
chosePlainText = true;
return createFragmentFromText(context.get(), dragData->asPlainText()).get();
return createFragmentFromText(context.get(), dragData->asPlainText(frame)).get();
}
return 0;
......@@ -214,7 +214,7 @@ bool DragController::performDrag(DragData* dragData)
return false;
m_client->willPerformDragDestinationAction(DragDestinationActionLoad, dragData);
m_page->mainFrame()->loader()->load(ResourceRequest(dragData->asURL()), false);
m_page->mainFrame()->loader()->load(ResourceRequest(dragData->asURL(m_page->mainFrame())), false);
return true;
}
......@@ -372,7 +372,7 @@ static bool setSelectionToDragCaret(Frame* frame, VisibleSelection& dragCaret, R
bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData* dragData)
{
VisibleSelection dragCaret(m_page->dragCaretController()->selection());
String text = dragCaret.isContentRichlyEditable() ? "" : dragData->asPlainText();
String text = dragCaret.isContentRichlyEditable() ? "" : dragData->asPlainText(innerFrame);
Node* target = innerFrame->editor()->findEventTargetFrom(dragCaret);
ExceptionCode ec = 0;
return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow(), text), ec);
......@@ -451,7 +451,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
cachedResourceLoader->setAllowStaleResources(true);
if (dragIsMove(innerFrame->selection()) || dragCaret.isContentRichlyEditable()) {
bool chosePlainText = false;
RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, range, true, chosePlainText);
RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame, range, true, chosePlainText);
if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, range, EditorInsertActionDropped)) {
cachedResourceLoader->setAllowStaleResources(false);
return false;
......@@ -469,7 +469,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.get(), fragment, true, dragData->canSmartReplace(), chosePlainText));
}
} else {
String text = dragData->asPlainText();
String text = dragData->asPlainText(innerFrame);
if (text.isEmpty() || !innerFrame->editor()->shouldInsertText(text, range.get(), EditorInsertActionDropped)) {
cachedResourceLoader->setAllowStaleResources(false);
return false;
......
......@@ -157,6 +157,8 @@ public:
virtual NSString* userVisibleString(NSURL*) = 0;
virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector< RefPtr<ArchiveResource> >&) = 0;
virtual void setInsertionPasteboard(NSPasteboard*) = 0;
virtual NSURL* canonicalizeURL(NSURL*) = 0;
virtual NSURL* canonicalizeURLString(NSString*) = 0;
#ifdef BUILDING_ON_TIGER
virtual NSArray* pasteboardTypesForSelection(Frame*) = 0;
#endif
......
......@@ -51,7 +51,7 @@ DragOperation DragController::dragOperation(DragData* dragData)
// attached sheet If this can be determined from within WebCore
// operationForDrag can be pulled into WebCore itself
ASSERT(dragData);
return dragData->containsURL() && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
}
bool DragController::isCopyKeyDown()
......
......@@ -50,7 +50,7 @@ bool DragController::isCopyKeyDown()
DragOperation DragController::dragOperation(DragData* dragData)
{
if (dragData->containsURL())
if (dragData->containsURL(0))
return DragOperationCopy;
return DragOperationNone;
......
......@@ -50,7 +50,7 @@ bool DragController::isCopyKeyDown()
DragOperation DragController::dragOperation(DragData* dragData)
{
//FIXME: This logic is incomplete
if (dragData->containsURL())
if (dragData->containsURL(0))
return DragOperationCopy;
return DragOperationNone;
......
......@@ -50,7 +50,7 @@ bool DragController::isCopyKeyDown()
DragOperation DragController::dragOperation(DragData* dragData)
{
ASSERT(dragData);
if ([NSApp modalWindow] || !dragData->containsURL())
if ([NSApp modalWindow] || !dragData->containsURL(m_page->mainFrame()))
return DragOperationNone;
if (!m_documentUnderMouse || (![[m_page->mainFrame()->view()->getOuterView() window] attachedSheet]
......
......@@ -51,7 +51,7 @@ bool DragController::isCopyKeyDown()
DragOperation DragController::dragOperation(DragData* dragData)
{
//FIXME: This logic is incomplete
if (dragData->containsURL())
if (dragData->containsURL(0))
return DragOperationCopy;
return DragOperationNone;
......
......@@ -47,7 +47,7 @@ DragOperation DragController::dragOperation(DragData* dragData)
//If this can be determined from within WebCore operationForDrag can be pulled into
//WebCore itself
ASSERT(dragData);
return dragData->containsURL() && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
}
bool DragController::isCopyKeyDown()
......
......@@ -66,55 +66,42 @@ typedef void* DragDataRef;
namespace WebCore {
class Document;
class DocumentFragment;
class KURL;
#if PLATFORM(MAC)
class PasteboardHelper;
#endif
class DragData {
public:
enum FilenameConversionPolicy { DoNotConvertFilenames, ConvertFilenames };
class Frame;
class DocumentFragment;
class KURL;
class Range;
#if PLATFORM(MAC)
//FIXME: In the future the WebKit functions provided by the helper class should be moved into WebCore,
//after which this constructor should be removed
DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition,
DragOperation operation, PasteboardHelper*);
#else
//clientPosition is taken to be the position of the drag event within the target window, with (0,0) at the top left
DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation operation);
#endif
const IntPoint& clientPosition() const { return m_clientPosition; }
const IntPoint& globalPosition() const { return m_globalPosition; }
DragDataRef platformData() const { return m_platformDragData; }
DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; }
bool containsURL(FilenameConversionPolicy filenamePolicy = ConvertFilenames) const;
bool containsPlainText() const;
bool containsCompatibleContent() const;
String asURL(FilenameConversionPolicy filenamePolicy = ConvertFilenames, String* title = 0) const;
String asPlainText() const;
void asFilenames(Vector<String>&) const;
Color asColor() const;
PassRefPtr<DocumentFragment> asFragment(Document*) const;
bool canSmartReplace() const;
bool containsColor() const;
bool containsFiles() const;
private:
IntPoint m_clientPosition;
IntPoint m_globalPosition;
DragDataRef m_platformDragData;
DragOperation m_draggingSourceOperationMask;
#if PLATFORM(MAC)
PasteboardHelper* m_pasteboardHelper;
#endif
class DragData {
public:
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
DragData(DragDataRef, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation operation);
const IntPoint& clientPosition() const { return m_clientPosition; }
const IntPoint& globalPosition() const { return m_globalPosition; }
DragDataRef platformData() const { return m_platformDragData; }
DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; }
bool containsURL(Frame*, FilenameConversionPolicy filenamePolicy = ConvertFilenames) const;
bool containsPlainText() const;
bool containsCompatibleContent() const;
String asURL(Frame*, FilenameConversionPolicy filenamePolicy = ConvertFilenames, String* title = 0) const;
String asPlainText(Frame*) const;
void asFilenames(Vector<String>&) const;
Color asColor() const;
PassRefPtr<DocumentFragment> asFragment(Frame*, PassRefPtr<Range> context,
bool allowPlainText, bool& chosePlainText) const;
bool canSmartReplace() const;
bool containsColor() const;
bool containsFiles() const;
private:
IntPoint m_clientPosition;
IntPoint m_globalPosition;
DragDataRef m_platformDragData;
DragOperation m_draggingSourceOperationMask;
};
} //namespace WebCore
}
#endif //!DragData_h
#endif // !DragData_h
......@@ -88,6 +88,8 @@ public:
static void writeSelection(NSPasteboard* pasteboard, Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame);
static void writeURL(NSPasteboard* pasteboard, NSArray* types, const KURL& url, const String& titleStr, Frame* frame);
static void writePlainText(NSPasteboard* pasteboard, const String& text);
Pasteboard(NSPasteboard *);
#endif
static Pasteboard* generalPasteboard();
......@@ -97,11 +99,13 @@ public:
void writeImage(Node*, const KURL&, const String& title);
#if PLATFORM(MAC)
void writeFileWrapperAsRTFDAttachment(NSFileWrapper*);
String asURL(Frame*);
#endif
void clear();
bool canSmartReplace();
PassRefPtr<DocumentFragment> documentFragment(Frame*, PassRefPtr<Range>, bool allowPlainText, bool& chosePlainText);
String plainText(Frame* = 0);
#if PLATFORM(QT) || PLATFORM(CHROMIUM)
bool isSelectionMode() const;
void setSelectionMode(bool selectionMode);
......@@ -110,17 +114,17 @@ public:
#if PLATFORM(GTK)
void setHelper(PasteboardHelper*);
PasteboardHelper* helper();
~Pasteboard();
#endif
private:
Pasteboard();
~Pasteboard();
#if PLATFORM(MAC)
Pasteboard(NSPasteboard *);
RetainPtr<NSPasteboard> m_pasteboard;
PassRefPtr<DocumentFragment> documentFragmentWithImageResource(Frame* frame, PassRefPtr<ArchiveResource> resource);
PassRefPtr<DocumentFragment> documentFragmentWithRtf(Frame* frame, NSString* pboardType);
NSURL *getBestURL(Frame *);
#endif
#if PLATFORM(WIN)
......
......@@ -47,7 +47,7 @@ bool DragData::containsPlainText() const
return false;
}
String DragData::asPlainText() const
String DragData::asPlainText(Frame*) const
{
return String();
}
......@@ -62,18 +62,18 @@ bool DragData::containsCompatibleContent() const
return false;
}
bool DragData::containsURL(FilenameConversionPolicy) const
bool DragData::containsURL(Frame*, FilenameConversionPolicy) const
{
return false;
}
String DragData::asURL(FilenameConversionPolicy, String*) const
String DragData::asURL(Frame*, FilenameConversionPolicy, String*) const
{
return String();
}
PassRefPtr<DocumentFragment> DragData::asFragment(Document*) const
PassRefPtr<DocumentFragment> DragData::asFragment(Frame*, PassRefPtr<Range>, bool, bool&) const
{
return 0;
}
......
......@@ -35,6 +35,7 @@
#include "ClipboardMimeTypes.h"
#include "DocumentFragment.h"
#include "FileSystem.h"
#include "Frame.h"
#include "KURL.h"
#include "markup.h"
#include "NotImplemented.h"
......@@ -47,13 +48,13 @@ static bool containsHTML(const ChromiumDataObject* dropData)
return dropData->types().contains(mimeTypeTextHTML);
}
bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const
{
return m_platformDragData->types().contains(mimeTypeURL)
|| (filenamePolicy == ConvertFilenames && m_platformDragData->containsFilenames());
}
String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const
String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String* title) const
{
String url;
if (m_platformDragData->types().contains(mimeTypeURL)) {
......@@ -84,7 +85,7 @@ bool DragData::containsPlainText() const
return m_platformDragData->types().contains(mimeTypeTextPlain);
}
String DragData::asPlainText() const
String DragData::asPlainText(Frame*) const
{
bool ignoredSuccess;
return m_platformDragData->getData(mimeTypeTextPlain, ignoredSuccess);
......@@ -109,13 +110,13 @@ bool DragData::canSmartReplace() const
bool DragData::containsCompatibleContent() const
{
return containsPlainText()
|| containsURL()
|| containsURL(0)
|| containsHTML(m_platformDragData)
|| containsColor()
|| containsFiles();
}
PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const
{
/*
* Order is richest format first. On OSX this is:
......@@ -137,7 +138,7 @@ PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
if (m_platformDragData->types().contains(mimeTypeTextHTML)) {
bool ignoredSuccess;
RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(doc,
RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(),
m_platformDragData->getData(mimeTypeTextHTML, ignoredSuccess), m_platformDragData->htmlBaseUrl(), FragmentScriptingNotAllowed);
return fragment.release();
}
......
......@@ -50,7 +50,7 @@ bool DragData::containsPlainText() const
return false;
}
String DragData::asPlainText() const
String DragData::asPlainText(Frame*) const
{
return String();
}
......@@ -65,17 +65,17 @@ bool DragData::containsCompatibleContent() const
return false;
}
bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const
{
return false;
}
String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const
String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String* title) const
{
return String();
}
PassRefPtr<DocumentFragment> DragData::asFragment(Document*) const
PassRefPtr<DocumentFragment> DragData::asFragment(Frame*, PassRefPtr<Range>, bool, bool&) const
{
return 0;
}
......
......@@ -46,11 +46,6 @@ Pasteboard::Pasteboard()
notImplemented();
}
Pasteboard::~Pasteboard()
{
notImplemented();
}
void Pasteboard::writePlainText(const String&)
{
notImplemented();
......
......@@ -21,6 +21,7 @@
#include "ClipboardGtk.h"
#include "Document.h"
#include "DocumentFragment.h"
#include "Frame.h"
#include "markup.h"
namespace WebCore {
......@@ -50,7 +51,7 @@ bool DragData::containsPlainText() const
return m_platformDragData->hasText();
}
String DragData::asPlainText() const
String DragData::asPlainText(Frame*) const
{
return m_platformDragData->text();
}
......@@ -62,15 +63,15 @@ Color DragData::asColor() const
bool DragData::containsCompatibleContent() const
{
return containsPlainText() || containsURL() || m_platformDragData->hasMarkup() || containsColor() || containsFiles();
return containsPlainText() || containsURL(0) || m_platformDragData->hasMarkup() || containsColor() || containsFiles();
}
bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const
{
return m_platformDragData->hasURL();
}
String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const
String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String* title) const
{
String url(m_platformDragData->url());
if (title)
......@@ -79,12 +80,12 @@ String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) c
}
PassRefPtr<DocumentFragment> DragData::asFragment(Document* document) const
PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const
{
if (!m_platformDragData->hasMarkup())
return 0;
return createFragmentFromMarkup(document, m_platformDragData->markup(), "");
return createFragmentFromMarkup(frame->document(), m_platformDragData->markup(), "");
}
}
......@@ -63,7 +63,7 @@ bool DragData::containsPlainText() const
return false;
}
String DragData::asPlainText() const
String DragData::asPlainText(Frame*) const
{
notImplemented();
return String();
......@@ -80,19 +80,19 @@ bool DragData::containsCompatibleContent() const
return containsColor() || containsURL() || containsPlainText();
}
bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const
{
notImplemented();
return false;
}
String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const
String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String* title) const
{
notImplemented();
return String();
}
PassRefPtr<DocumentFragment> DragData::asFragment(Document*) const
PassRefPtr<DocumentFragment> DragData::asFragment(Frame*, PassRefPtr<Range>, bool, bool&) const
{
notImplemented();
return 0;
......
......@@ -33,19 +33,17 @@
#import "DOMDocumentFragmentInternal.h"
#import "MIMETypeRegistry.h"