[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

enrica at apple.com enrica at apple.com
Sun Feb 20 22:47:59 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 964ea218ab0ea6727f63a08e823958eb4740f104
Author: enrica at apple.com <enrica at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jan 11 19:47:02 2011 +0000

    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

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 7b47267..003e73b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2011-01-07  Enrica Casucci  <enrica at 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 at chromium.org>
 
         Unreviewed; chromium test expectations update.
diff --git a/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.checksum b/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.checksum
index 709808f..24034dd 100644
--- a/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.checksum
+++ b/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.checksum
@@ -1 +1 @@
-507f0044be28d7fe3ca8a3ae46f4e8d6
\ No newline at end of file
+2733ef0d0dee7e02d8dd636d4b317935
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.png b/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.png
index b239040..59ea87c 100644
Binary files a/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.png and b/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.txt b/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.txt
index 56b5a75..0013222 100644
--- a/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.txt
+++ b/LayoutTests/platform/mac/editing/pasteboard/drag-image-to-contenteditable-in-iframe-expected.txt
@@ -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
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 7d62252..2cbd4ad 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,99 @@
+2011-01-10  Enrica Casucci  <enrica at 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 at chromium.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/Source/WebCore/WebCore.exp.in b/Source/WebCore/WebCore.exp.in
index 88ab671..6324064 100644
--- a/Source/WebCore/WebCore.exp.in
+++ b/Source/WebCore/WebCore.exp.in
@@ -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)
diff --git a/Source/WebCore/loader/EmptyClients.h b/Source/WebCore/loader/EmptyClients.h
index 5c4810e..e4cefc5 100644
--- a/Source/WebCore/loader/EmptyClients.h
+++ b/Source/WebCore/loader/EmptyClients.h
@@ -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
diff --git a/Source/WebCore/page/DragController.cpp b/Source/WebCore/page/DragController.cpp
index d0e9a8c..77a8531 100644
--- a/Source/WebCore/page/DragController.cpp
+++ b/Source/WebCore/page/DragController.cpp
@@ -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;
diff --git a/Source/WebCore/page/EditorClient.h b/Source/WebCore/page/EditorClient.h
index 1ec0c7e..71ba3dd 100644
--- a/Source/WebCore/page/EditorClient.h
+++ b/Source/WebCore/page/EditorClient.h
@@ -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
diff --git a/Source/WebCore/page/chromium/DragControllerChromium.cpp b/Source/WebCore/page/chromium/DragControllerChromium.cpp
index de53d19..75e0bd2 100644
--- a/Source/WebCore/page/chromium/DragControllerChromium.cpp
+++ b/Source/WebCore/page/chromium/DragControllerChromium.cpp
@@ -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()
diff --git a/Source/WebCore/page/efl/DragControllerEfl.cpp b/Source/WebCore/page/efl/DragControllerEfl.cpp
index 0c5f002..3a23537 100644
--- a/Source/WebCore/page/efl/DragControllerEfl.cpp
+++ b/Source/WebCore/page/efl/DragControllerEfl.cpp
@@ -50,7 +50,7 @@ bool DragController::isCopyKeyDown()
 
 DragOperation DragController::dragOperation(DragData* dragData)
 {
-    if (dragData->containsURL())
+    if (dragData->containsURL(0))
         return DragOperationCopy;
 
     return DragOperationNone;
diff --git a/Source/WebCore/page/gtk/DragControllerGtk.cpp b/Source/WebCore/page/gtk/DragControllerGtk.cpp
index 5f9044f..4c56162 100644
--- a/Source/WebCore/page/gtk/DragControllerGtk.cpp
+++ b/Source/WebCore/page/gtk/DragControllerGtk.cpp
@@ -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;
diff --git a/Source/WebCore/page/mac/DragControllerMac.mm b/Source/WebCore/page/mac/DragControllerMac.mm
index 05c8e09..608a4fc 100644
--- a/Source/WebCore/page/mac/DragControllerMac.mm
+++ b/Source/WebCore/page/mac/DragControllerMac.mm
@@ -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] 
diff --git a/Source/WebCore/page/qt/DragControllerQt.cpp b/Source/WebCore/page/qt/DragControllerQt.cpp
index 33815b5..24f0d3d 100644
--- a/Source/WebCore/page/qt/DragControllerQt.cpp
+++ b/Source/WebCore/page/qt/DragControllerQt.cpp
@@ -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;
diff --git a/Source/WebCore/page/win/DragControllerWin.cpp b/Source/WebCore/page/win/DragControllerWin.cpp
index f0404ff..a16fe7f 100644
--- a/Source/WebCore/page/win/DragControllerWin.cpp
+++ b/Source/WebCore/page/win/DragControllerWin.cpp
@@ -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()
diff --git a/Source/WebCore/platform/DragData.h b/Source/WebCore/platform/DragData.h
index 548bc67..30f049c 100644
--- a/Source/WebCore/platform/DragData.h
+++ b/Source/WebCore/platform/DragData.h
@@ -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
 
diff --git a/Source/WebCore/platform/Pasteboard.h b/Source/WebCore/platform/Pasteboard.h
index 7c50737..78a40b3 100644
--- a/Source/WebCore/platform/Pasteboard.h
+++ b/Source/WebCore/platform/Pasteboard.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)
diff --git a/Source/WebCore/platform/android/DragDataAndroid.cpp b/Source/WebCore/platform/android/DragDataAndroid.cpp
index 4e99b2c..2c341b0 100644
--- a/Source/WebCore/platform/android/DragDataAndroid.cpp
+++ b/Source/WebCore/platform/android/DragDataAndroid.cpp
@@ -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;
 }
diff --git a/Source/WebCore/platform/chromium/DragDataChromium.cpp b/Source/WebCore/platform/chromium/DragDataChromium.cpp
index 2b04523..8c20a00 100644
--- a/Source/WebCore/platform/chromium/DragDataChromium.cpp
+++ b/Source/WebCore/platform/chromium/DragDataChromium.cpp
@@ -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();
     }
diff --git a/Source/WebCore/platform/efl/DragDataEfl.cpp b/Source/WebCore/platform/efl/DragDataEfl.cpp
index a8458d6..b35b963 100644
--- a/Source/WebCore/platform/efl/DragDataEfl.cpp
+++ b/Source/WebCore/platform/efl/DragDataEfl.cpp
@@ -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;
 }
diff --git a/Source/WebCore/platform/efl/PasteboardEfl.cpp b/Source/WebCore/platform/efl/PasteboardEfl.cpp
index 1af5a92..77c1d90 100644
--- a/Source/WebCore/platform/efl/PasteboardEfl.cpp
+++ b/Source/WebCore/platform/efl/PasteboardEfl.cpp
@@ -46,11 +46,6 @@ Pasteboard::Pasteboard()
     notImplemented();
 }
 
-Pasteboard::~Pasteboard()
-{
-    notImplemented();
-}
-
 void Pasteboard::writePlainText(const String&)
 {
     notImplemented();
diff --git a/Source/WebCore/platform/gtk/DragDataGtk.cpp b/Source/WebCore/platform/gtk/DragDataGtk.cpp
index 42ddb16..3a1daf1 100644
--- a/Source/WebCore/platform/gtk/DragDataGtk.cpp
+++ b/Source/WebCore/platform/gtk/DragDataGtk.cpp
@@ -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(), "");
 }
 
 }
diff --git a/Source/WebCore/platform/haiku/DragDataHaiku.cpp b/Source/WebCore/platform/haiku/DragDataHaiku.cpp
index 7c2dc9c..5069c6f 100644
--- a/Source/WebCore/platform/haiku/DragDataHaiku.cpp
+++ b/Source/WebCore/platform/haiku/DragDataHaiku.cpp
@@ -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;
diff --git a/Source/WebCore/platform/mac/DragDataMac.mm b/Source/WebCore/platform/mac/DragDataMac.mm
index 9cb4836..a079f4a 100644
--- a/Source/WebCore/platform/mac/DragDataMac.mm
+++ b/Source/WebCore/platform/mac/DragDataMac.mm
@@ -33,19 +33,17 @@
 #import "DOMDocumentFragmentInternal.h"
 #import "MIMETypeRegistry.h"
 #import "Pasteboard.h"
-#import "PasteboardHelper.h"
+#import "Range.h"
 
 namespace WebCore {
 
 DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, 
-    DragOperation sourceOperationMask, PasteboardHelper* pasteboardHelper)
+    DragOperation sourceOperationMask)
     : m_clientPosition(clientPosition)
     , m_globalPosition(globalPosition)
     , m_platformDragData(data)
     , m_draggingSourceOperationMask(sourceOperationMask)
-    , m_pasteboardHelper(pasteboardHelper)
 {
-    ASSERT(pasteboardHelper);  
 }
     
 bool DragData::canSmartReplace() const
@@ -86,9 +84,10 @@ bool DragData::containsPlainText() const
         || [NSURL URLFromPasteboard:pasteboard];
 }
 
-String DragData::asPlainText() const
+String DragData::asPlainText(Frame *frame) const
 {
-    return m_pasteboardHelper->plainTextFromPasteboard([m_platformDragData draggingPasteboard]);
+    Pasteboard pasteboard([m_platformDragData draggingPasteboard]);
+    return pasteboard.plainText(frame);
 }
 
 Color DragData::asColor() const
@@ -98,29 +97,51 @@ Color DragData::asColor() const
                     (int)([color blueComponent] * 255.0 + 0.5), (int)([color alphaComponent] * 255.0 + 0.5));
 }
 
+static NSArray *insertablePasteboardTypes()
+{
+    static NSArray *types = nil;
+    if (!types) {
+        types = [[NSArray alloc] initWithObjects:WebArchivePboardType, NSHTMLPboardType, NSFilenamesPboardType, NSTIFFPboardType, NSPDFPboardType,
+#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
+                 NSPICTPboardType,
+#endif
+                 NSURLPboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, NSColorPboardType, kUTTypePNG, nil];
+        CFRetain(types);
+    }
+    return types;
+}
+    
 bool DragData::containsCompatibleContent() const
 {
     NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard];
     NSMutableSet *types = [NSMutableSet setWithArray:[pasteboard types]];
-    [types intersectSet:[NSSet setWithArray:m_pasteboardHelper->insertablePasteboardTypes()]];
+    [types intersectSet:[NSSet setWithArray:insertablePasteboardTypes()]];
     return [types count] != 0;
 }
     
-bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
+bool DragData::containsURL(Frame* frame, FilenameConversionPolicy filenamePolicy) const
 {
-    return !asURL(filenamePolicy).isEmpty();
+    return !asURL(frame, filenamePolicy).isEmpty();
 }
     
-String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const
+String DragData::asURL(Frame* frame, FilenameConversionPolicy filenamePolicy, String* title) const
 {
     // FIXME: Use filenamePolicy.
     (void)filenamePolicy;
-    return m_pasteboardHelper->urlFromPasteboard([m_platformDragData draggingPasteboard], title);
+
+    if (title) {
+        if (NSString *URLTitleString = [[m_platformDragData draggingPasteboard] stringForType:WebURLNamePboardType])
+            *title = URLTitleString;
+    }
+    Pasteboard pasteboard([m_platformDragData draggingPasteboard]);
+    return pasteboard.asURL(frame);
 }
 
-PassRefPtr<DocumentFragment> DragData::asFragment(Document*) const
+PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range> range, bool allowPlainText, bool& chosePlainText) const
 {
-    return core(m_pasteboardHelper->fragmentFromPasteboard([m_platformDragData draggingPasteboard]));
+    Pasteboard pasteboard([m_platformDragData draggingPasteboard]);
+    
+    return pasteboard.documentFragment(frame, range, allowPlainText, chosePlainText);
 }
     
 } // namespace WebCore
diff --git a/Source/WebCore/platform/mac/PasteboardMac.mm b/Source/WebCore/platform/mac/PasteboardMac.mm
index 0625287..b1f2327 100644
--- a/Source/WebCore/platform/mac/PasteboardMac.mm
+++ b/Source/WebCore/platform/mac/PasteboardMac.mm
@@ -436,7 +436,50 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
 
     return URL;
 }
+
+NSURL *Pasteboard::getBestURL(Frame* frame)
+{
+    NSArray *types = [m_pasteboard.get() types];
+
+    // FIXME: using the editorClient to call into webkit, for now, since 
+    // calling webkit_canonicalize from WebCore involves migrating a sizable amount of 
+    // helper code that should either be done in a separate patch or figured out in another way.
+    
+    if ([types containsObject:NSURLPboardType]) {
+        NSURL *URLFromPasteboard = [NSURL URLFromPasteboard:m_pasteboard.get()];
+        NSString *scheme = [URLFromPasteboard scheme];
+        if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"]) {
+            return frame->editor()->client()->canonicalizeURL(URLFromPasteboard);
+        }
+    }
+    
+    if ([types containsObject:NSStringPboardType]) {
+        NSString *URLString = [m_pasteboard.get() stringForType:NSStringPboardType];
+        NSURL *URL = frame->editor()->client()->canonicalizeURLString(URLString);
+        if (URL)
+            return URL;
+    }
+    
+    if ([types containsObject:NSFilenamesPboardType]) {
+        NSArray *files = [m_pasteboard.get() propertyListForType:NSFilenamesPboardType];
+        // FIXME: Maybe it makes more sense to allow multiple files and only use the first one?
+        if ([files count] == 1) {
+            NSString *file = [files objectAtIndex:0];
+            BOOL isDirectory;
+            if ([[NSFileManager defaultManager] fileExistsAtPath:file isDirectory:&isDirectory] && isDirectory)
+                return nil;
+            return frame->editor()->client()->canonicalizeURL([NSURL fileURLWithPath:file]);
+        }
+    }
     
+    return nil;    
+}
+
+String Pasteboard::asURL(Frame* frame)
+{
+    return [getBestURL(frame) absoluteString];
+}
+
 PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText)
 {
     NSArray *types = [m_pasteboard.get() types];
diff --git a/Source/WebCore/platform/qt/DragDataQt.cpp b/Source/WebCore/platform/qt/DragDataQt.cpp
index 4033123..f68ad1d 100644
--- a/Source/WebCore/platform/qt/DragDataQt.cpp
+++ b/Source/WebCore/platform/qt/DragDataQt.cpp
@@ -28,6 +28,7 @@
 
 #include "Document.h"
 #include "DocumentFragment.h"
+#include "Frame.h"
 #include "markup.h"
 
 #include <QColor>
@@ -80,7 +81,7 @@ bool DragData::containsPlainText() const
     return m_platformDragData->hasText() || m_platformDragData->hasUrls();
 }
 
-String DragData::asPlainText() const
+String DragData::asPlainText(Frame* frame) const
 {
     if (!m_platformDragData)
         return String();
@@ -89,7 +90,7 @@ String DragData::asPlainText() const
         return text;
 
     // FIXME: Should handle rich text here
-    return asURL(DoNotConvertFilenames, 0);
+    return asURL(frame, DoNotConvertFilenames, 0);
 }
 
 Color DragData::asColor() const
@@ -103,10 +104,10 @@ bool DragData::containsCompatibleContent() const
 {
     if (!m_platformDragData)
         return false;
-    return containsColor() || containsURL() || m_platformDragData->hasHtml() || m_platformDragData->hasText();
+    return containsColor() || containsURL(0) || m_platformDragData->hasHtml() || m_platformDragData->hasText();
 }
 
-bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
+bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const
 {
     // FIXME: Use filenamePolicy.
     if (!m_platformDragData)
@@ -114,7 +115,7 @@ bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
     return m_platformDragData->hasUrls();
 }
 
-String DragData::asURL(FilenameConversionPolicy filenamePolicy, String*) const
+String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String*) const
 {
     // FIXME: Use filenamePolicy.
     if (!m_platformDragData)
@@ -127,10 +128,10 @@ String DragData::asURL(FilenameConversionPolicy filenamePolicy, String*) const
     return encodeWithURLEscapeSequences(urls.first().toString());
 }
 
-PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
+PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const
 {
     if (m_platformDragData && m_platformDragData->hasHtml())
-        return createFragmentFromMarkup(doc, m_platformDragData->html(), "", FragmentScriptingNotAllowed);
+        return createFragmentFromMarkup(frame->document(), m_platformDragData->html(), "", FragmentScriptingNotAllowed);
 
     return 0;
 }
diff --git a/Source/WebCore/platform/win/DragDataWin.cpp b/Source/WebCore/platform/win/DragDataWin.cpp
index 56345e2..906119d 100644
--- a/Source/WebCore/platform/win/DragDataWin.cpp
+++ b/Source/WebCore/platform/win/DragDataWin.cpp
@@ -27,6 +27,7 @@
 #include "DragData.h"
 
 #include "ClipboardUtilitiesWin.h"
+#include "Frame.h"
 #include "DocumentFragment.h"
 #include "PlatformString.h"
 #include "Markup.h"
@@ -37,7 +38,7 @@
 
 namespace WebCore {
 
-bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
+bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const
 {
     return SUCCEEDED(m_platformDragData->QueryGetData(urlWFormat())) 
         || SUCCEEDED(m_platformDragData->QueryGetData(urlFormat()))
@@ -46,7 +47,7 @@ bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
                 || SUCCEEDED(m_platformDragData->QueryGetData(filenameFormat()))));
 }
 
-String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const
+String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String* title) const
 {
     bool success;
     return getURL(m_platformDragData, filenamePolicy, success, title);
@@ -89,7 +90,7 @@ bool DragData::containsPlainText() const
         || SUCCEEDED(m_platformDragData->QueryGetData(plainTextFormat()));
 }
 
-String DragData::asPlainText() const
+String DragData::asPlainText(Frame*) const
 {
     bool success;
     return getPlainText(m_platformDragData, success);
@@ -107,13 +108,13 @@ bool DragData::canSmartReplace() const
 
 bool DragData::containsCompatibleContent() const
 {
-    return containsPlainText() || containsURL() 
+    return containsPlainText() || containsURL(0) 
         || containsHTML(m_platformDragData) 
         || containsFilenames(m_platformDragData) 
         || containsColor();
 }
 
-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:
@@ -126,11 +127,11 @@ PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
      */
         
      if (containsFilenames(m_platformDragData))
-         if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(doc, m_platformDragData))
+         if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame->document(), m_platformDragData))
              return fragment;
 
      if (containsHTML(m_platformDragData))
-         if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(doc, m_platformDragData))
+         if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame->document(), m_platformDragData))
              return fragment;
 
      return 0;
diff --git a/Source/WebCore/platform/wince/DragDataWinCE.cpp b/Source/WebCore/platform/wince/DragDataWinCE.cpp
index 5535ea9..fd9014e 100644
--- a/Source/WebCore/platform/wince/DragDataWinCE.cpp
+++ b/Source/WebCore/platform/wince/DragDataWinCE.cpp
@@ -26,12 +26,12 @@
 
 namespace WebCore {
 
-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();
 }
@@ -50,7 +50,7 @@ bool DragData::containsPlainText() const
     return false;
 }
 
-String DragData::asPlainText() const
+String DragData::asPlainText(Frame*) const
 {
     return String();
 }
@@ -70,7 +70,7 @@ bool DragData::containsCompatibleContent() const
     return false;
 }
 
-PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
+PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const
 {
      return 0;
 }
diff --git a/Source/WebCore/platform/wx/DragDataWx.cpp b/Source/WebCore/platform/wx/DragDataWx.cpp
index 35e3753..53b4219 100644
--- a/Source/WebCore/platform/wx/DragDataWx.cpp
+++ b/Source/WebCore/platform/wx/DragDataWx.cpp
@@ -55,7 +55,7 @@ bool DragData::containsPlainText() const
     return false;
 }
 
-String DragData::asPlainText() const
+String DragData::asPlainText(Frame*) const
 {
     return String();
 }
@@ -70,18 +70,18 @@ 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;
 }
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index a4bdeef..aa18035 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-07  Enrica Casucci  <enrica at 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.
+
+        * WebKit.xcodeproj/project.pbxproj: Removed WebPasteboardHelper.mm and WebPasteboardHelper.h.
+
 2010-12-31  Adam Barth  <abarth at webkit.org>
 
         Update SVN ignore property to hide two more external dependencies.
diff --git a/WebKit/WebKit.xcodeproj/project.pbxproj b/WebKit/WebKit.xcodeproj/project.pbxproj
index 5856175..d47bce4 100644
--- a/WebKit/WebKit.xcodeproj/project.pbxproj
+++ b/WebKit/WebKit.xcodeproj/project.pbxproj
@@ -333,8 +333,6 @@
 		A5DEFC1411D5344B00885273 /* WebApplicationCacheQuotaManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5DEFC1211D5344B00885273 /* WebApplicationCacheQuotaManager.mm */; };
 		A70936AF0B5608DC00CDB48E /* WebDragClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A70936AD0B5608DC00CDB48E /* WebDragClient.h */; };
 		A70936B00B5608DC00CDB48E /* WebDragClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = A70936AE0B5608DC00CDB48E /* WebDragClient.mm */; };
-		A7D3C5BC0B5773C5002CA450 /* WebPasteboardHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D3C5BA0B5773C5002CA450 /* WebPasteboardHelper.h */; };
-		A7D3C5BD0B5773C5002CA450 /* WebPasteboardHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = A7D3C5BB0B5773C5002CA450 /* WebPasteboardHelper.mm */; };
 		A864B3F6123ED9FA00C2A612 /* MailQuirksUserScript.js in Resources */ = {isa = PBXBuildFile; fileRef = A864B3E5123ED83D00C2A612 /* MailQuirksUserScript.js */; };
 		AB9FBBBB0F8582B0006ADC43 /* WebDOMOperationsInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = AB9FBBBA0F8582B0006ADC43 /* WebDOMOperationsInternal.h */; };
 		ABDDF20D08EB0DDC001E1241 /* WebDownloadInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDF20C08EB0DDC001E1241 /* WebDownloadInternal.h */; };
@@ -645,8 +643,6 @@
 		A5DEFC1211D5344B00885273 /* WebApplicationCacheQuotaManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebApplicationCacheQuotaManager.mm; sourceTree = "<group>"; };
 		A70936AD0B5608DC00CDB48E /* WebDragClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebDragClient.h; sourceTree = "<group>"; };
 		A70936AE0B5608DC00CDB48E /* WebDragClient.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDragClient.mm; sourceTree = "<group>"; };
-		A7D3C5BA0B5773C5002CA450 /* WebPasteboardHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPasteboardHelper.h; sourceTree = "<group>"; };
-		A7D3C5BB0B5773C5002CA450 /* WebPasteboardHelper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPasteboardHelper.mm; sourceTree = "<group>"; };
 		A864B3E5123ED83D00C2A612 /* MailQuirksUserScript.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = MailQuirksUserScript.js; sourceTree = "<group>"; };
 		AB9FBBBA0F8582B0006ADC43 /* WebDOMOperationsInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDOMOperationsInternal.h; sourceTree = "<group>"; };
 		ABDDF20C08EB0DDC001E1241 /* WebDownloadInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDownloadInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
@@ -1314,8 +1310,6 @@
 				9345D4EB0365C5B2008635CE /* WebJavaScriptTextInputPanel.m */,
 				84723BE3056D719E0044BFEA /* WebKeyGenerator.h */,
 				84723BE4056D719E0044BFEA /* WebKeyGenerator.m */,
-				A7D3C5BA0B5773C5002CA450 /* WebPasteboardHelper.h */,
-				A7D3C5BB0B5773C5002CA450 /* WebPasteboardHelper.mm */,
 				1AA879B411CBE9BF003C664F /* WebPlatformStrategies.h */,
 				1AA879B511CBE9BF003C664F /* WebPlatformStrategies.mm */,
 				0A2D87FB107AF52B00CDDEE3 /* WebPluginHalterClient.h */,
@@ -1562,7 +1556,6 @@
 				939810240824BF01008DF038 /* WebNSViewExtras.h in Headers */,
 				939810250824BF01008DF038 /* WebNSWindowExtras.h in Headers */,
 				9398102A0824BF01008DF038 /* WebPanelAuthenticationHandler.h in Headers */,
-				A7D3C5BC0B5773C5002CA450 /* WebPasteboardHelper.h in Headers */,
 				37B6FB4E1063530C000FDB3B /* WebPDFDocumentExtras.h in Headers */,
 				939810A50824BF01008DF038 /* WebPDFRepresentation.h in Headers */,
 				939810A40824BF01008DF038 /* WebPDFView.h in Headers */,
@@ -1955,7 +1948,6 @@
 				939810C90824BF01008DF038 /* WebNSViewExtras.m in Sources */,
 				939810CA0824BF01008DF038 /* WebNSWindowExtras.m in Sources */,
 				939810D00824BF01008DF038 /* WebPanelAuthenticationHandler.m in Sources */,
-				A7D3C5BD0B5773C5002CA450 /* WebPasteboardHelper.mm in Sources */,
 				37B6FB4F1063530C000FDB3B /* WebPDFDocumentExtras.mm in Sources */,
 				9398111F0824BF01008DF038 /* WebPDFRepresentation.mm in Sources */,
 				9398111E0824BF01008DF038 /* WebPDFView.mm in Sources */,
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index c5a14a2..a7af1f4 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,27 @@
+2011-01-07  Enrica Casucci  <enrica at 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.
+
+        * 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:]):
+
 2011-01-09  Tony Gentilcore  <tonyg at chromium.org>
 
         Reviewed by Alexey Proskuryakov.
diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.h b/WebKit/mac/WebCoreSupport/WebEditorClient.h
index 8a54ca9..d5ac891 100644
--- a/WebKit/mac/WebCoreSupport/WebEditorClient.h
+++ b/WebKit/mac/WebCoreSupport/WebEditorClient.h
@@ -73,6 +73,8 @@ public:
     virtual NSString* userVisibleString(NSURL *);
     virtual WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString *, Vector< RefPtr<WebCore::ArchiveResource> >&);
     virtual void setInsertionPasteboard(NSPasteboard *);
+    virtual NSURL* canonicalizeURL(NSURL*);
+    virtual NSURL* canonicalizeURLString(NSString*);
 #ifdef BUILDING_ON_TIGER
     virtual NSArray *pasteboardTypesForSelection(WebCore::Frame*);
 #endif
diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.mm b/WebKit/mac/WebCoreSupport/WebEditorClient.mm
index d3b38de..5cbb0fe 100644
--- a/WebKit/mac/WebCoreSupport/WebEditorClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebEditorClient.mm
@@ -354,6 +354,19 @@ NSString *WebEditorClient::userVisibleString(NSURL *URL)
     return [URL _web_userVisibleString];
 }
 
+NSURL *WebEditorClient::canonicalizeURL(NSURL *URL)
+{
+    return [URL _webkit_canonicalize];
+}
+
+NSURL *WebEditorClient::canonicalizeURLString(NSString *URLString)
+{
+    NSURL *URL = nil;
+    if ([URLString _webkit_looksLikeAbsoluteURL])
+        URL = [[NSURL _web_URLWithUserTypedString:URLString] _webkit_canonicalize];
+    return URL;
+}
+
 static NSArray *createExcludedElementsForAttributedStringConversion()
 {
     NSArray *elements = [[NSArray alloc] initWithObjects: 
diff --git a/WebKit/mac/WebCoreSupport/WebPasteboardHelper.h b/WebKit/mac/WebCoreSupport/WebPasteboardHelper.h
deleted file mode 100644
index 2aa37a6..0000000
--- a/WebKit/mac/WebCoreSupport/WebPasteboardHelper.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#ifndef WebPasteboardHelper_h
-#define WebPasteboardHelper_h
-
-#import <WebCore/PasteboardHelper.h>
-
- at class WebHTMLView;
-
-class WebPasteboardHelper : public WebCore::PasteboardHelper
-{
-public:
-    WebPasteboardHelper(WebHTMLView* view) : m_view(view) {}
-    virtual WTF::String urlFromPasteboard(NSPasteboard*, WTF::String* title) const;
-    virtual WTF::String plainTextFromPasteboard(NSPasteboard*) const;
-    virtual DOMDocumentFragment* fragmentFromPasteboard(NSPasteboard*) const;
-    virtual NSArray* insertablePasteboardTypes() const;
-    private:
-    WebHTMLView* m_view;
-};
-
-#endif
diff --git a/WebKit/mac/WebCoreSupport/WebPasteboardHelper.mm b/WebKit/mac/WebCoreSupport/WebPasteboardHelper.mm
deleted file mode 100644
index fb93f8e..0000000
--- a/WebKit/mac/WebCoreSupport/WebPasteboardHelper.mm
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#import "WebPasteboardHelper.h"
-
-#import "WebArchive.h"
-#import "WebHTMLViewInternal.h"
-#import "WebNSPasteboardExtras.h"
-#import "WebNSURLExtras.h"
-#import <WebCore/PlatformString.h>
-#import <WebKit/DOMDocument.h>
-#import <WebKit/DOMDocumentFragment.h>
-#import <wtf/RetainPtr.h>
-#import <wtf/StdLibExtras.h>
-
-using namespace WebCore;
-
-String WebPasteboardHelper::urlFromPasteboard(NSPasteboard* pasteboard, String* title) const
-{
-    NSURL *URL = [pasteboard _web_bestURL];
-    if (title) {
-        if (NSString *URLTitleString = [pasteboard stringForType:WebURLNamePboardType])
-            *title = URLTitleString;
-    }
-
-    return [URL _web_originalDataAsString];
-}
-
-String WebPasteboardHelper::plainTextFromPasteboard(NSPasteboard *pasteboard) const
-{    
-    NSArray *types = [pasteboard types];
-    
-    if ([types containsObject:NSStringPboardType])
-        return [[pasteboard stringForType:NSStringPboardType] precomposedStringWithCanonicalMapping];
-    
-    NSAttributedString *attributedString = nil;
-    NSString *string;
-    
-    if ([types containsObject:NSRTFDPboardType])
-        attributedString = [[NSAttributedString alloc] initWithRTFD:[pasteboard dataForType:NSRTFDPboardType] documentAttributes:nil];
-    if (!attributedString && [types containsObject:NSRTFPboardType])
-        attributedString = [[NSAttributedString alloc] initWithRTF:[pasteboard dataForType:NSRTFPboardType] documentAttributes:nil];
-    if (attributedString) {
-        string = [[attributedString string] precomposedStringWithCanonicalMapping];
-        [attributedString release];
-        return string;
-    }
-    
-    if ([types containsObject:NSFilenamesPboardType]) {
-        string = [[pasteboard propertyListForType:NSFilenamesPboardType] componentsJoinedByString:@"\n"];
-        if (string)
-            return [string precomposedStringWithCanonicalMapping];
-    }
-    
-    NSURL *URL;
-    
-    if ((URL = [NSURL URLFromPasteboard:pasteboard])) {
-        string = [URL _web_userVisibleString];
-        if ([string length] > 0)
-            return string;
-    }
-    
-    return String();
-}
-
-DOMDocumentFragment *WebPasteboardHelper::fragmentFromPasteboard(NSPasteboard *pasteboard) const
-{   
-    return [m_view _documentFragmentFromPasteboard:pasteboard];
-}
-
-NSArray *WebPasteboardHelper::insertablePasteboardTypes() const
-{
-    DEFINE_STATIC_LOCAL(RetainPtr<NSArray>, types, ([[NSArray alloc] initWithObjects:WebArchivePboardType, NSHTMLPboardType, NSFilenamesPboardType, NSTIFFPboardType, NSPDFPboardType,
-#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
-           NSPICTPboardType,
-#endif
-           NSURLPboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, NSColorPboardType, nil]));
-
-    return types.get();
-}
diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm
index 093f3db..30472d2 100644
--- a/WebKit/mac/WebView/WebHTMLView.mm
+++ b/WebKit/mac/WebView/WebHTMLView.mm
@@ -1717,7 +1717,6 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
     }
 }
 
-// keep in sync with WebPasteboardHelper::insertablePasteboardTypes
 + (NSArray *)_insertablePasteboardTypes
 {
     static NSArray *types = nil;
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index 9c7de2c..22de83f 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -90,7 +90,6 @@
 #import "WebNodeHighlight.h"
 #import "WebPDFView.h"
 #import "WebPanelAuthenticationHandler.h"
-#import "WebPasteboardHelper.h"
 #import "WebPlatformStrategies.h"
 #import "WebPluginDatabase.h"
 #import "WebPluginHalterClient.h"
@@ -3713,11 +3712,9 @@ static bool needsWebViewInitThreadWorkaround()
 
 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)draggingInfo
 {
-    NSView <WebDocumentView>* view = [self documentViewAtWindowPoint:[draggingInfo draggingLocation]];
-    WebPasteboardHelper helper([view isKindOfClass:[WebHTMLView class]] ? (WebHTMLView*)view : nil);
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
-    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask], &helper);
+    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
     return core(self)->dragController()->dragEntered(&dragData);
 }
 
@@ -3727,11 +3724,9 @@ static bool needsWebViewInitThreadWorkaround()
     if (!page)
         return NSDragOperationNone;
 
-    NSView <WebDocumentView>* view = [self documentViewAtWindowPoint:[draggingInfo draggingLocation]];
-    WebPasteboardHelper helper([view isKindOfClass:[WebHTMLView class]] ? (WebHTMLView*)view : nil);
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
-    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask], &helper);
+    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
     return page->dragController()->dragUpdated(&dragData);
 }
 
@@ -3741,11 +3736,9 @@ static bool needsWebViewInitThreadWorkaround()
     if (!page)
         return;
 
-    NSView <WebDocumentView>* view = [self documentViewAtWindowPoint:[draggingInfo draggingLocation]];
-    WebPasteboardHelper helper([view isKindOfClass:[WebHTMLView class]] ? (WebHTMLView*)view : nil);
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
-    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask], &helper);
+    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
     page->dragController()->dragExited(&dragData);
 }
 
@@ -3756,11 +3749,9 @@ static bool needsWebViewInitThreadWorkaround()
 
 - (BOOL)performDragOperation:(id <NSDraggingInfo>)draggingInfo
 {
-    NSView <WebDocumentView>* view = [self documentViewAtWindowPoint:[draggingInfo draggingLocation]];
-    WebPasteboardHelper helper([view isKindOfClass:[WebHTMLView class]]? (WebHTMLView*)view : nil);
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
-    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask], &helper);
+    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
     return core(self)->dragController()->performDrag(&dragData);
 }
 
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index f02777d..ba8152a 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,18 @@
+2011-01-07  Enrica Casucci  <enrica at 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.
+
+        * 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):
+
 2011-01-11  Jessie Berlin  <jberlin at apple.com>
 
         Reviewed by Anders Carlsson and Sam Weinig.
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
index 1e340dd..40bd8c6 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
+++ b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
@@ -94,6 +94,8 @@ private:
     virtual NSString *userVisibleString(NSURL *);
     virtual WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString *, Vector< RefPtr<WebCore::ArchiveResource> >&);
     virtual void setInsertionPasteboard(NSPasteboard *);
+    virtual NSURL* canonicalizeURL(NSURL*);
+    virtual NSURL* canonicalizeURLString(NSString*);
 #ifdef BUILDING_ON_TIGER
     virtual NSArray *pasteboardTypesForSelection(WebCore::Frame*);
 #endif
diff --git a/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm b/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
index d623434..ce33890 100644
--- a/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
+++ b/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
@@ -80,6 +80,19 @@ NSString *WebEditorClient::userVisibleString(NSURL *url)
     return [url _web_userVisibleString];
 }
 
+NSURL *WebEditorClient::canonicalizeURL(NSURL *url)
+{
+    return [url _webkit_canonicalize];
+}
+
+NSURL *WebEditorClient::canonicalizeURLString(NSString *URLString)
+{
+    NSURL *URL = nil;
+    if ([URLString _webkit_looksLikeAbsoluteURL])
+        URL = [[NSURL _web_URLWithUserTypedString:URLString] _webkit_canonicalize];
+    return URL;
+}
+    
 static NSArray *createExcludedElementsForAttributedStringConversion()
 {
     NSArray *elements = [[NSArray alloc] initWithObjects: 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list