CTTE: Use references in and around DragController
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Oct 2013 20:34:35 +0000 (20:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Oct 2013 20:34:35 +0000 (20:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=122427

Patch by Sam Weinig <sam@webkit.org> on 2013-10-07
Reviewed by Andreas Kling.

Source/WebCore:

Use references to indicate non-nullness of DragController related
objects.

Source/WebKit/efl:

* WebCoreSupport/DragClientEfl.cpp:
(WebCore::DragClientEfl::willPerformDragDestinationAction):
(WebCore::DragClientEfl::willPerformDragSourceAction):
(WebCore::DragClientEfl::actionMaskForDrag):
(WebCore::DragClientEfl::startDrag):
* WebCoreSupport/DragClientEfl.h:

Source/WebKit/gtk:

* WebCoreSupport/DragClientGtk.cpp:
(WebKit::DragClient::willPerformDragDestinationAction):
(WebKit::DragClient::willPerformDragSourceAction):
(WebKit::DragClient::actionMaskForDrag):
(WebKit::DragClient::startDrag):
* WebCoreSupport/DragClientGtk.h:
* webkit/webkitwebview.cpp:
(dragExitedCallback):
(webkit_web_view_drag_motion):
(webkit_web_view_drag_data_received):
(webkit_web_view_drag_drop):

Source/WebKit/mac:

* WebCoreSupport/WebDragClient.h:
* WebCoreSupport/WebDragClient.mm:
(WebDragClient::actionMaskForDrag):
(WebDragClient::willPerformDragDestinationAction):
(WebDragClient::willPerformDragSourceAction):
(WebDragClient::startDrag):
(WebDragClient::declareAndWriteDragImage):
* WebView/WebFrame.mm:
(-[WebFrame _replaceSelectionWithText:selectReplacement:smartReplace:]):
* WebView/WebHTMLView.mm:
(-[WebHTMLView _documentFragmentFromPasteboard:forType:inContext:subresources:]):
* WebView/WebView.mm:
(-[WebView draggingEntered:]):
(-[WebView draggingUpdated:]):
(-[WebView draggingExited:]):
(-[WebView performDragOperation:]):

Source/WebKit/win:

* WebCoreSupport/WebDragClient.cpp:
(WebDragClient::actionMaskForDrag):
(WebDragClient::willPerformDragDestinationAction):
(WebDragClient::willPerformDragSourceAction):
(WebDragClient::startDrag):
* WebCoreSupport/WebDragClient.h:

Source/WebKit2:

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseDragDataReceived):
(webkitWebViewBaseDragMotion):
(dragExitedCallback):
(webkitWebViewBaseDragDrop):
* UIProcess/API/mac/WKView.mm:
(-[WKView draggingEntered:]):
(-[WKView draggingUpdated:]):
(-[WKView draggingExited:]):
(-[WKView performDragOperation:]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dragEntered):
(WebKit::WebPageProxy::dragUpdated):
(WebKit::WebPageProxy::dragExited):
(WebKit::WebPageProxy::performDrag):
(WebKit::WebPageProxy::performDragControllerAction):
* UIProcess/WebPageProxy.h:
* WebProcess/WebCoreSupport/WebDragClient.cpp:
(WebKit::WebDragClient::willPerformDragDestinationAction):
(WebKit::WebDragClient::willPerformDragSourceAction):
(WebKit::WebDragClient::actionMaskForDrag):
(WebKit::WebDragClient::dragSourceActionMaskForPoint):
(WebKit::WebDragClient::startDrag):
* WebProcess/WebCoreSupport/WebDragClient.h:
* WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
(WebKit::WebDragClient::startDrag):
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(WebKit::WebDragClient::startDrag):
(WebKit::cachedImage):
(WebKit::WebDragClient::declareAndWriteDragImage):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::performDragControllerAction):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157058 268f45cc-cd09-0410-ab3c-d52691b4dbfc

61 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/bindings/objc/DOMHTML.mm
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/SpellingCorrectionCommand.cpp
Source/WebCore/editing/mac/EditorMac.mm
Source/WebCore/editing/markup.cpp
Source/WebCore/editing/markup.h
Source/WebCore/html/FileInputType.cpp
Source/WebCore/html/FileInputType.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/loader/EmptyClients.h
Source/WebCore/page/DragClient.h
Source/WebCore/page/DragController.cpp
Source/WebCore/page/DragController.h
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/efl/DragControllerEfl.cpp
Source/WebCore/page/gtk/DragControllerGtk.cpp
Source/WebCore/page/mac/DragControllerMac.mm
Source/WebCore/page/win/DragControllerWin.cpp
Source/WebCore/platform/DragData.h
Source/WebCore/platform/Pasteboard.h
Source/WebCore/platform/efl/DragDataEfl.cpp
Source/WebCore/platform/gtk/DragDataGtk.cpp
Source/WebCore/platform/gtk/GtkDragAndDropHelper.cpp
Source/WebCore/platform/gtk/GtkDragAndDropHelper.h
Source/WebCore/platform/gtk/PasteboardGtk.cpp
Source/WebCore/platform/mac/DragDataMac.mm
Source/WebCore/platform/win/DragDataWin.cpp
Source/WebCore/platform/win/PasteboardWin.cpp
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/DragClientEfl.cpp
Source/WebKit/efl/WebCoreSupport/DragClientEfl.h
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
Source/WebKit/gtk/WebCoreSupport/DragClientGtk.h
Source/WebKit/gtk/webkit/webkitwebview.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebDragClient.h
Source/WebKit/mac/WebCoreSupport/WebDragClient.mm
Source/WebKit/mac/WebView/WebFrame.mm
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebDragClient.cpp
Source/WebKit/win/WebCoreSupport/WebDragClient.h
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h
Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 5f9b3cc..06938ed 100644 (file)
@@ -1,3 +1,13 @@
+2013-10-07  Sam Weinig  <sam@webkit.org>
+
+        CTTE: Use references in and around DragController
+        https://bugs.webkit.org/show_bug.cgi?id=122427
+
+        Reviewed by Andreas Kling.
+
+        Use references to indicate non-nullness of DragController related
+        objects.
+
 2013-10-07  Tim Horton  <timothy_horton@apple.com>
 
         Animated images are not restarted when page visibility changes
index 1e5dad9..cbaead9 100644 (file)
@@ -742,7 +742,7 @@ __ZN7WebCore22ScriptExecutionContext26canSuspendActiveDOMObjectsEv
 __ZN7WebCore22StorageEventDispatcher34dispatchLocalStorageEventsToFramesERNS_9PageGroupERKN3WTF6VectorINS3_6RefPtrINS_5FrameEEELm0ENS3_15CrashOnOverflowEEERKNS3_6StringESE_SE_SE_PNS_14SecurityOriginE
 __ZN7WebCore22URLWithUserTypedStringEP8NSStringP5NSURL
 __ZN7WebCore22counterValueForElementEPNS_7ElementE
-__ZN7WebCore22createFragmentFromTextEPNS_5RangeERKN3WTF6StringE
+__ZN7WebCore22createFragmentFromTextERNS_5RangeERKN3WTF6StringE
 __ZN7WebCore22externalRepresentationEPNS_5FrameEj
 __ZN7WebCore22externalRepresentationEPNS_7ElementEj
 __ZN7WebCore22systemMarketingVersionEv
@@ -2456,15 +2456,15 @@ __ZNK7WebCore12SharedBuffer36memoryMappedNotificationCallbackDataEv
 
 #if ENABLE(DRAG_SUPPORT)
 __ZN7WebCore12EventHandler17dragSourceEndedAtERKNS_18PlatformMouseEventENS_13DragOperationE
-__ZNK7WebCore12EventHandler17eventMayStartDragERKNS_18PlatformMouseEventE
-__ZN7WebCore14DragController10dragExitedEPNS_8DragDataE
-__ZN7WebCore14DragController11dragEnteredEPNS_8DragDataE
-__ZN7WebCore14DragController11dragUpdatedEPNS_8DragDataE
-__ZN7WebCore14DragController11performDragEPNS_8DragDataE
+__ZN7WebCore14DragController10dragExitedERNS_8DragDataE
+__ZN7WebCore14DragController11dragEnteredERNS_8DragDataE
+__ZN7WebCore14DragController11dragUpdatedERNS_8DragDataE
+__ZN7WebCore14DragController11performDragERNS_8DragDataE
 __ZN7WebCore14DragController14placeDragCaretERKNS_8IntPointE
 __ZN7WebCore14DragController9dragEndedEv
 __ZN7WebCore8DragDataC1EP11objc_objectRKNS_8IntPointES5_NS_13DragOperationENS_20DragApplicationFlagsE
 __ZN7WebCore8DragDataC1ERKN3WTF6StringERKNS_8IntPointES7_NS_13DragOperationENS_20DragApplicationFlagsE
+__ZNK7WebCore12EventHandler17eventMayStartDragERKNS_18PlatformMouseEventE
 #endif
 
 #if ENABLE(ENCRYPTED_MEDIA_V2)
index d2eea4b..c333514 100644 (file)
@@ -62,7 +62,7 @@
 - (DOMDocumentFragment *)createDocumentFragmentWithText:(NSString *)text
 {
     // FIXME: Since this is not a contextual fragment, it won't handle whitespace properly.
-    return kit(createFragmentFromText(core(self)->createRange().get(), text).get());
+    return kit(createFragmentFromText(*core(self)->createRange().get(), text).get());
 }
 
 @end
index 65e3a49..a20c78c 100644 (file)
@@ -440,8 +440,11 @@ String Editor::plainTextFromPasteboard(const PasteboardPlainText& text)
 void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText)
 {
     RefPtr<Range> range = selectedRange();
+    if (!range)
+        return;
+
     bool chosePlainText;
-    RefPtr<DocumentFragment> fragment = pasteboard->documentFragment(&m_frame, range, allowPlainText, chosePlainText);
+    RefPtr<DocumentFragment> fragment = pasteboard->documentFragment(m_frame, *range, allowPlainText, chosePlainText);
     if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
         pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), chosePlainText);
 }
@@ -493,7 +496,11 @@ void Editor::replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment,
 
 void Editor::replaceSelectionWithText(const String& text, bool selectReplacement, bool smartReplace)
 {
-    replaceSelectionWithFragment(createFragmentFromText(selectedRange().get(), text), selectReplacement, smartReplace, true); 
+    RefPtr<Range> range = selectedRange();
+    if (!range)
+        return;
+
+    replaceSelectionWithFragment(createFragmentFromText(*range, text), selectReplacement, smartReplace, true);
 }
 
 PassRefPtr<Range> Editor::selectedRange()
@@ -1061,7 +1068,7 @@ void Editor::cut()
             writeSelectionToPasteboard(*Pasteboard::createForCopyAndPaste());
 #else
             // FIXME: Convert all other platforms to match Mac and delete this.
-            Pasteboard::createForCopyAndPaste()->writeSelection(selection.get(), canSmartCopyOrDelete(), &m_frame, IncludeImageAltTextForClipboard);
+            Pasteboard::createForCopyAndPaste()->writeSelection(*selection, canSmartCopyOrDelete(), m_frame, IncludeImageAltTextForClipboard);
 #endif
         }
         didWriteSelectionToPasteboard();
@@ -1087,14 +1094,14 @@ void Editor::copy()
 #if (PLATFORM(MAC) && !PLATFORM(IOS)) || PLATFORM(EFL)
             writeImageToPasteboard(*Pasteboard::createForCopyAndPaste(), *imageElement, document().url(), document().title());
 #else
-            Pasteboard::createForCopyAndPaste()->writeImage(imageElement, document().url(), document().title());
+            Pasteboard::createForCopyAndPaste()->writeImage(*imageElement, document().url(), document().title());
 #endif
         } else {
 #if (PLATFORM(MAC) && !PLATFORM(IOS)) || PLATFORM(EFL)
             writeSelectionToPasteboard(*Pasteboard::createForCopyAndPaste());
 #else
             // FIXME: Convert all other platforms to match Mac and delete this.
-            Pasteboard::createForCopyAndPaste()->writeSelection(selectedRange().get(), canSmartCopyOrDelete(), &m_frame, IncludeImageAltTextForClipboard);
+            Pasteboard::createForCopyAndPaste()->writeSelection(*selectedRange(), canSmartCopyOrDelete(), m_frame, IncludeImageAltTextForClipboard);
 #endif
         }
     }
@@ -1196,7 +1203,7 @@ void Editor::copyImage(const HitTestResult& result)
 #if PLATFORM(MAC) || PLATFORM(EFL)
     writeImageToPasteboard(*Pasteboard::createForCopyAndPaste(), *element, url, result.altDisplayString());
 #else
-    Pasteboard::createForCopyAndPaste()->writeImage(element, url, result.altDisplayString());
+    Pasteboard::createForCopyAndPaste()->writeImage(*element, url, result.altDisplayString());
 #endif
 }
 
index 1705c87..79f3bf2 100644 (file)
@@ -187,7 +187,11 @@ ReplacementFragment::ReplacementFragment(Document& document, DocumentFragment* f
     if (text != evt->text() || !editableRoot->rendererIsRichlyEditable()) {
         restoreAndRemoveTestRenderingNodesToFragment(holder.get());
 
-        m_fragment = createFragmentFromText(selection.toNormalizedRange().get(), evt->text());
+        RefPtr<Range> range = selection.toNormalizedRange();
+        if (!range)
+            return;
+
+        m_fragment = createFragmentFromText(*range, evt->text());
         if (!m_fragment->firstChild())
             return;
 
index 2d966d1..bd22d1b 100644 (file)
@@ -98,7 +98,10 @@ void SpellingCorrectionCommand::doApply()
     if (!frame().selection().shouldChangeSelection(m_selectionToBeCorrected))
         return;
 
-    RefPtr<DocumentFragment> fragment = createFragmentFromText(m_rangeToBeCorrected.get(), m_correction);
+    if (!m_rangeToBeCorrected)
+        return;
+
+    RefPtr<DocumentFragment> fragment = createFragmentFromText(*m_rangeToBeCorrected, m_correction);
     if (!fragment)
         return;
 
index cd9039f..ddc425e 100644 (file)
@@ -564,7 +564,7 @@ bool Editor::WebContentReader::readPlainText(const String& text)
     if (!allowPlainText)
         return false;
 
-    fragment = createFragmentFromText(&context, [text precomposedStringWithCanonicalMapping]);
+    fragment = createFragmentFromText(context, [text precomposedStringWithCanonicalMapping]);
     if (!fragment)
         return false;
 
index ee7162e..e1d2294 100644 (file)
@@ -752,12 +752,9 @@ static bool contextPreservesNewline(const Range& context)
     return container->renderer()->style()->preserveNewline();
 }
 
-PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String& text)
+PassRefPtr<DocumentFragment> createFragmentFromText(Range& context, const String& text)
 {
-    if (!context)
-        return 0;
-
-    Document& document = context->ownerDocument();
+    Document& document = context.ownerDocument();
     RefPtr<DocumentFragment> fragment = document.createDocumentFragment();
     
     if (text.isEmpty())
@@ -767,7 +764,7 @@ PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String
     string.replace("\r\n", "\n");
     string.replace('\r', '\n');
 
-    if (contextPreservesNewline(*context)) {
+    if (contextPreservesNewline(context)) {
         fragment->appendChild(document.createTextNode(string), ASSERT_NO_EXCEPTION);
         if (string.endsWith('\n')) {
             RefPtr<Element> element = createBreakElement(document);
@@ -784,14 +781,14 @@ PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String
     }
 
     // Break string into paragraphs. Extra line breaks turn into empty paragraphs.
-    Node* blockNode = enclosingBlock(context->firstNode());
+    Node* blockNode = enclosingBlock(context.firstNode());
     Element* block = toElement(blockNode);
     bool useClonesOfEnclosingBlock = blockNode
         && blockNode->isElementNode()
         && !block->hasTagName(bodyTag)
         && !block->hasTagName(htmlTag)
-        && block != editableRootForPosition(context->startPosition());
-    bool useLineBreak = enclosingTextFormControl(context->startPosition());
+        && block != editableRootForPosition(context.startPosition());
+    bool useLineBreak = enclosingTextFormControl(context.startPosition());
 
     Vector<String> list;
     string.split('\n', true, list); // true gets us empty strings in the list
index 8a68be1..65b72ad 100644 (file)
@@ -49,7 +49,7 @@ enum EChildrenOnly { IncludeNode, ChildrenOnly };
 enum EAbsoluteURLs { DoNotResolveURLs, ResolveAllURLs, ResolveNonLocalURLs };
 enum EFragmentSerialization { HTMLFragmentSerialization, XMLFragmentSerialization };
 
-PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String& text);
+PassRefPtr<DocumentFragment> createFragmentFromText(Range& context, const String& text);
 PassRefPtr<DocumentFragment> createFragmentFromMarkup(Document&, const String& markup, const String& baseURL, ParserContentPolicy = AllowScriptingContent);
 PassRefPtr<DocumentFragment> createFragmentForInnerOuterHTML(const String&, Element*, ParserContentPolicy, ExceptionCode&);
 PassRefPtr<DocumentFragment> createFragmentForTransformToFragment(const String&, const String& sourceMIMEType, Document* outputDoc);
index 01edc4b..1bccda5 100644 (file)
@@ -433,10 +433,10 @@ void FileInputType::updateRendering(PassRefPtr<Icon> icon)
         element().renderer()->repaint();
 }
 
-bool FileInputType::receiveDroppedFiles(const DragData* dragData)
+bool FileInputType::receiveDroppedFiles(const DragData& dragData)
 {
     Vector<String> paths;
-    dragData->asFilenames(paths);
+    dragData.asFilenames(paths);
     if (paths.isEmpty())
         return false;
 
index 28a0fdd..c980fb5 100644 (file)
@@ -67,7 +67,7 @@ private:
     virtual bool canSetValue(const String&) OVERRIDE;
     virtual bool getTypeSpecificValue(String&) OVERRIDE; // Checked first, before internal storage or the value attribute.
     virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE;
-    virtual bool receiveDroppedFiles(const DragData*) OVERRIDE;
+    virtual bool receiveDroppedFiles(const DragData&) OVERRIDE;
     virtual Icon* icon() const OVERRIDE;
     virtual bool isFileUpload() const OVERRIDE;
     virtual void createShadowSubtree() OVERRIDE;
index 820cecc..b6581ed 100644 (file)
@@ -1357,7 +1357,7 @@ void HTMLInputElement::setFiles(PassRefPtr<FileList> files)
     m_inputType->setFiles(files);
 }
 
-bool HTMLInputElement::receiveDroppedFiles(const DragData* dragData)
+bool HTMLInputElement::receiveDroppedFiles(const DragData& dragData)
 {
     return m_inputType->receiveDroppedFiles(dragData);
 }
index dcf366e..768aa8d 100644 (file)
@@ -243,7 +243,7 @@ public:
     void setFiles(PassRefPtr<FileList>);
 
     // Returns true if the given DragData has more than one dropped files.
-    bool receiveDroppedFiles(const DragData*);
+    bool receiveDroppedFiles(const DragData&);
 
     Icon* icon() const;
     // These functions are used for rendering the input active during a
index 47f1e1f..fbb731a 100644 (file)
@@ -705,7 +705,7 @@ String InputType::sanitizeValue(const String& proposedValue) const
     return proposedValue;
 }
 
-bool InputType::receiveDroppedFiles(const DragData*)
+bool InputType::receiveDroppedFiles(const DragData&)
 {
     ASSERT_NOT_REACHED();
     return false;
index ea31a0a..c2efdd6 100644 (file)
@@ -239,7 +239,7 @@ public:
     virtual FileList* files();
     virtual void setFiles(PassRefPtr<FileList>);
     // Should return true if the given DragData has more than one dropped files.
-    virtual bool receiveDroppedFiles(const DragData*);
+    virtual bool receiveDroppedFiles(const DragData&);
     virtual Icon* icon() const;
     // Should return true if the corresponding renderer for a type can display a suggested value.
     virtual bool canSetSuggestedValue();
index ff79c58..cd45a16 100644 (file)
@@ -533,11 +533,11 @@ class EmptyDragClient : public DragClient {
 public:
     EmptyDragClient() { }
     virtual ~EmptyDragClient() {}
-    virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*) OVERRIDE { }
-    virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) OVERRIDE { }
-    virtual DragDestinationAction actionMaskForDrag(DragData*) OVERRIDE { return DragDestinationActionNone; }
+    virtual void willPerformDragDestinationAction(DragDestinationAction, DragData&) OVERRIDE { }
+    virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard&) OVERRIDE { }
+    virtual DragDestinationAction actionMaskForDrag(DragData&) OVERRIDE { return DragDestinationActionNone; }
     virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint&) OVERRIDE { return DragSourceActionNone; }
-    virtual void startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) OVERRIDE { }
+    virtual void startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard&, Frame&, bool) OVERRIDE { }
     virtual void dragControllerDestroyed() OVERRIDE { }
 };
 #endif // ENABLE(DRAG_SUPPORT)
index b72d73d..343490c 100644 (file)
 #include "DragImage.h"
 #include "IntPoint.h"
 
-#if PLATFORM(MAC)
-OBJC_CLASS DOMElement;
-OBJC_CLASS NSURL;
-OBJC_CLASS NSString;
-#endif
-
 namespace WebCore {
     
-    class Clipboard;
-    class DragData;
-    class Frame;
-    class Image;
-    class HTMLImageElement;
-    
-    class DragClient {
-    public:
-        virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*) = 0;
-        virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) = 0;
-        virtual DragDestinationAction actionMaskForDrag(DragData*) = 0;
+class Clipboard;
+class DragData;
+class Element;
+class Frame;
+class Image;
+
+class DragClient {
+public:
+    virtual void dragControllerDestroyed() = 0;
 
-        virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint& rootViewPoint) = 0;
-        
-        virtual void startDrag(DragImageRef dragImage, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard*, Frame*, bool linkDrag = false) = 0;
-        
-        virtual void dragControllerDestroyed() = 0;
+    virtual void willPerformDragDestinationAction(DragDestinationAction, DragData&) = 0;
+    virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard&) = 0;
+    virtual DragDestinationAction actionMaskForDrag(DragData&) = 0;
+    virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint& rootViewPoint) = 0;
+    
+    virtual void startDrag(DragImageRef, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard&, Frame&, bool linkDrag = false) = 0;
+    virtual void dragEnded() { }
 
 #if PLATFORM(MAC)
-        // Mac-specific helper function to allow access to web archives and NSPasteboard extras in WebKit.
-        // This is not abstract as that would require another #if PLATFORM(MAC) for the SVGImage client empty implentation.
-        virtual void declareAndWriteDragImage(const String&, DOMElement*, NSURL *, NSString *, Frame*) { }
+    // Mac-specific helper function to allow access to web archives and NSPasteboard extras in WebKit.
+    // This is not abstract as that would require another #if PLATFORM(MAC) for the SVGImage client empty implentation.
+    virtual void declareAndWriteDragImage(const String&, Element&, const URL&, const String&, Frame*) { }
 #endif
-        
-        virtual void dragEnded() { }
 
-        virtual ~DragClient() { }
-    };
+    virtual ~DragClient() { }
+};
     
-}
+} // namespace WebCore
 
-#endif // !DragClient_h
+#endif // DragClient_h
 
index 3966582..f120d2c 100644 (file)
 
 namespace WebCore {
 
-static PlatformMouseEvent createMouseEvent(DragData* dragData)
+static PlatformMouseEvent createMouseEvent(DragData& dragData)
 {
     bool shiftKey, ctrlKey, altKey, metaKey;
     shiftKey = ctrlKey = altKey = metaKey = false;
-    int keyState = dragData->modifierKeyState();
+    int keyState = dragData.modifierKeyState();
     shiftKey = static_cast<bool>(keyState & PlatformEvent::ShiftKey);
     ctrlKey = static_cast<bool>(keyState & PlatformEvent::CtrlKey);
     altKey = static_cast<bool>(keyState & PlatformEvent::AltKey);
     metaKey = static_cast<bool>(keyState & PlatformEvent::MetaKey);
 
-    return PlatformMouseEvent(dragData->clientPosition(), dragData->globalPosition(),
+    return PlatformMouseEvent(dragData.clientPosition(), dragData.globalPosition(),
                               LeftButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey,
                               metaKey, currentTime());
 }
@@ -117,26 +117,25 @@ DragController::~DragController()
     m_client.dragControllerDestroyed();
 }
 
-static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragData, Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText)
+static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData& dragData, Frame* frame, Range& context, bool allowPlainText, bool& chosePlainText)
 {
-    ASSERT(dragData);
     chosePlainText = false;
 
-    Document& document = context->ownerDocument();
-    if (dragData->containsCompatibleContent()) {
-        if (PassRefPtr<DocumentFragment> fragment = dragData->asFragment(frame, context.get(), allowPlainText, chosePlainText))
+    Document& document = context.ownerDocument();
+    if (dragData.containsCompatibleContent()) {
+        if (PassRefPtr<DocumentFragment> fragment = dragData.asFragment(frame, context, allowPlainText, chosePlainText))
             return fragment;
 
-        if (dragData->containsURL(frame, DragData::DoNotConvertFilenames)) {
+        if (dragData.containsURL(frame, DragData::DoNotConvertFilenames)) {
             String title;
-            String url = dragData->asURL(frame, 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(frame);
+                    if (dragData.containsPlainText())
+                        title = dragData.asPlainText(frame);
                     if (title.isEmpty())
                         title = url;
                 }
@@ -148,15 +147,15 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD
             }
         }
     }
-    if (allowPlainText && dragData->containsPlainText()) {
+    if (allowPlainText && dragData.containsPlainText()) {
         chosePlainText = true;
-        return createFragmentFromText(context.get(), dragData->asPlainText(frame)).get();
+        return createFragmentFromText(context, dragData.asPlainText(frame)).get();
     }
 
     return 0;
 }
 
-bool DragController::dragIsMove(FrameSelection& selection, DragData* dragData)
+bool DragController::dragIsMove(FrameSelection& selection, DragData& dragData)
 {
     return m_documentUnderMouse == m_dragInitiator && selection.isContentEditable() && selection.isRange() && !isCopyKeyDown(dragData);
 }
@@ -176,19 +175,17 @@ void DragController::dragEnded()
     m_client.dragEnded();
 }
 
-DragSession DragController::dragEntered(DragData* dragData)
+DragSession DragController::dragEntered(DragData& dragData)
 {
     return dragEnteredOrUpdated(dragData);
 }
 
-void DragController::dragExited(DragData* dragData)
+void DragController::dragExited(DragData& dragData)
 {
-    ASSERT(dragData);
-
     if (RefPtr<FrameView> v = m_page.mainFrame().view()) {
         ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnderMouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable;
-        RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(policy, *dragData);
-        clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
+        RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(policy, dragData);
+        clipboard->setSourceOperation(dragData.draggingSourceOperationMask());
         m_page.mainFrame().eventHandler().cancelDragAndDrop(createMouseEvent(dragData), clipboard.get());
         clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
     }
@@ -198,23 +195,22 @@ void DragController::dragExited(DragData* dragData)
     m_fileInputElementUnderMouse = 0;
 }
 
-DragSession DragController::dragUpdated(DragData* dragData)
+DragSession DragController::dragUpdated(DragData& dragData)
 {
     return dragEnteredOrUpdated(dragData);
 }
 
-bool DragController::performDrag(DragData* dragData)
+bool DragController::performDrag(DragData& dragData)
 {
-    ASSERT(dragData);
-    m_documentUnderMouse = m_page.mainFrame().documentAtPoint(dragData->clientPosition());
+    m_documentUnderMouse = m_page.mainFrame().documentAtPoint(dragData.clientPosition());
     if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHandlingDrag) {
         m_client.willPerformDragDestinationAction(DragDestinationActionDHTML, dragData);
         Ref<MainFrame> mainFrame(m_page.mainFrame());
         bool preventedDefault = false;
         if (mainFrame->view()) {
             // Sending an event can result in the destruction of the view and part.
-            RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(ClipboardReadable, *dragData);
-            clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
+            RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(ClipboardReadable, dragData);
+            clipboard->setSourceOperation(dragData.draggingSourceOperationMask());
             preventedDefault = mainFrame->eventHandler().performDragAndDrop(createMouseEvent(dragData), clipboard.get());
             clipboard->setAccessPolicy(ClipboardNumb); // Invalidate clipboard here for security
         }
@@ -235,7 +231,7 @@ bool DragController::performDrag(DragData* dragData)
         return false;
 
     m_client.willPerformDragDestinationAction(DragDestinationActionLoad, dragData);
-    m_page.mainFrame().loader().load(FrameLoadRequest(&m_page.mainFrame(), ResourceRequest(dragData->asURL(&m_page.mainFrame()))));
+    m_page.mainFrame().loader().load(FrameLoadRequest(&m_page.mainFrame(), ResourceRequest(dragData.asURL(&m_page.mainFrame()))));
     return true;
 }
 
@@ -250,10 +246,9 @@ void DragController::mouseMovedIntoDocument(Document* newDocument)
     m_documentUnderMouse = newDocument;
 }
 
-DragSession DragController::dragEnteredOrUpdated(DragData* dragData)
+DragSession DragController::dragEnteredOrUpdated(DragData& dragData)
 {
-    ASSERT(dragData);
-    mouseMovedIntoDocument(m_page.mainFrame().documentAtPoint(dragData->clientPosition()));
+    mouseMovedIntoDocument(m_page.mainFrame().documentAtPoint(dragData.clientPosition()));
 
     m_dragDestinationAction = m_client.actionMaskForDrag(dragData);
     if (m_dragDestinationAction == DragDestinationActionNone) {
@@ -301,10 +296,8 @@ static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint&
     return toElement(n);
 }
 
-bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction actionMask, DragSession& dragSession)
+bool DragController::tryDocumentDrag(DragData& dragData, DragDestinationAction actionMask, DragSession& dragSession)
 {
-    ASSERT(dragData);
-
     if (!m_documentUnderMouse)
         return false;
 
@@ -335,12 +328,12 @@ bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction a
     }
 
     if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) {
-        if (dragData->containsColor()) {
+        if (dragData.containsColor()) {
             dragSession.operation = DragOperationGeneric;
             return true;
         }
 
-        IntPoint point = frameView->windowToContents(dragData->clientPosition());
+        IntPoint point = frameView->windowToContents(dragData.clientPosition());
         Element* element = elementUnderMouse(m_documentUnderMouse.get(), point);
         if (!element)
             return false;
@@ -360,7 +353,7 @@ bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction a
         dragSession.mouseIsOverFileInput = m_fileInputElementUnderMouse;
         dragSession.numberOfItemsToBeAccepted = 0;
 
-        unsigned numberOfFiles = dragData->numberOfFiles();
+        unsigned numberOfFiles = dragData.numberOfFiles();
         if (m_fileInputElementUnderMouse) {
             if (m_fileInputElementUnderMouse->isDisabledFormControl())
                 dragSession.numberOfItemsToBeAccepted = 0;
@@ -397,10 +390,9 @@ DragSourceAction DragController::delegateDragSourceAction(const IntPoint& rootVi
     return m_dragSourceAction;
 }
 
-DragOperation DragController::operationForLoad(DragData* dragData)
+DragOperation DragController::operationForLoad(DragData& dragData)
 {
-    ASSERT(dragData);
-    Document* doc = m_page.mainFrame().documentAtPoint(dragData->clientPosition());
+    Document* doc = m_page.mainFrame().documentAtPoint(dragData.clientPosition());
 
     bool pluginDocumentAcceptsDrags = false;
 
@@ -428,18 +420,16 @@ static bool setSelectionToDragCaret(Frame* frame, VisibleSelection& dragCaret, R
     return !frame->selection().isNone() && frame->selection().isContentEditable();
 }
 
-bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData* dragData)
+bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData& dragData)
 {
     ASSERT(m_page.dragCaretController().hasCaret());
-    String text = m_page.dragCaretController().isContentRichlyEditable() ? "" : dragData->asPlainText(innerFrame);
+    String text = m_page.dragCaretController().isContentRichlyEditable() ? emptyString() : dragData.asPlainText(innerFrame);
     Node* target = innerFrame->editor().findEventTargetFrom(m_page.dragCaretController().caretPosition());
     return target->dispatchEvent(TextEvent::createForDrop(innerFrame->document()->domWindow(), text), IGNORE_EXCEPTION);
 }
 
-bool DragController::concludeEditDrag(DragData* dragData)
+bool DragController::concludeEditDrag(DragData& dragData)
 {
-    ASSERT(dragData);
-
     RefPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMouse;
     if (m_fileInputElementUnderMouse) {
         m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
@@ -449,7 +439,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
     if (!m_documentUnderMouse)
         return false;
 
-    IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->clientPosition());
+    IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData.clientPosition());
     Element* element = elementUnderMouse(m_documentUnderMouse.get(), point);
     if (!element)
         return false;
@@ -459,8 +449,8 @@ bool DragController::concludeEditDrag(DragData* dragData)
     if (m_page.dragCaretController().hasCaret() && !dispatchTextInputEventFor(innerFrame.get(), dragData))
         return true;
 
-    if (dragData->containsColor()) {
-        Color color = dragData->asColor();
+    if (dragData.containsColor()) {
+        Color color = dragData.asColor();
         if (!color.isValid())
             return false;
         RefPtr<Range> innerRange = innerFrame->selection().toNormalizedRange();
@@ -473,7 +463,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
         return true;
     }
 
-    if (dragData->containsFiles() && fileInput) {
+    if (dragData.containsFiles() && fileInput) {
         // fileInput should be the element we hit tested for, unless it was made
         // display:none in a drop event handler.
         ASSERT(fileInput == element || !fileInput->renderer());
@@ -497,11 +487,12 @@ bool DragController::concludeEditDrag(DragData* dragData)
     // manually controlling drag behaviour
     if (!range)
         return false;
+
     CachedResourceLoader* cachedResourceLoader = range->ownerDocument().cachedResourceLoader();
     ResourceCacheValidationSuppressor validationSuppressor(cachedResourceLoader);
     if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRichlyEditable()) {
         bool chosePlainText = false;
-        RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame.get(), range, true, chosePlainText);
+        RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame.get(), *range, true, chosePlainText);
         if (!fragment || !innerFrame->editor().shouldInsertFragment(fragment, range, EditorInsertActionDropped)) {
             return false;
         }
@@ -511,12 +502,12 @@ bool DragController::concludeEditDrag(DragData* dragData)
             // NSTextView behavior is to always smart delete on moving a selection,
             // but only to smart insert if the selection granularity is word granularity.
             bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled();
-            bool smartInsert = smartDelete && innerFrame->selection().granularity() == WordGranularity && dragData->canSmartReplace();
+            bool smartInsert = smartDelete && innerFrame->selection().granularity() == WordGranularity && dragData.canSmartReplace();
             applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base(), smartInsert, smartDelete));
         } else {
             if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point)) {
                 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting;
-                if (dragData->canSmartReplace())
+                if (dragData.canSmartReplace())
                     options |= ReplaceSelectionCommand::SmartReplace;
                 if (chosePlainText)
                     options |= ReplaceSelectionCommand::MatchStyle;
@@ -524,14 +515,14 @@ bool DragController::concludeEditDrag(DragData* dragData)
             }
         }
     } else {
-        String text = dragData->asPlainText(innerFrame.get());
+        String text = dragData.asPlainText(innerFrame.get());
         if (text.isEmpty() || !innerFrame->editor().shouldInsertText(text, range.get(), EditorInsertActionDropped)) {
             return false;
         }
 
         m_client.willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
         if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point))
-            applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMouse, createFragmentFromText(range.get(), text),  ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting));
+            applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMouse, createFragmentFromText(*range, text),  ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting));
     }
 
     if (rootEditableElement) {
@@ -542,14 +533,12 @@ bool DragController::concludeEditDrag(DragData* dragData)
     return true;
 }
 
-bool DragController::canProcessDrag(DragData* dragData)
+bool DragController::canProcessDrag(DragData& dragData)
 {
-    ASSERT(dragData);
-
-    if (!dragData->containsCompatibleContent())
+    if (!dragData.containsCompatibleContent())
         return false;
 
-    IntPoint point = m_page.mainFrame().view()->windowToContents(dragData->clientPosition());
+    IntPoint point = m_page.mainFrame().view()->windowToContents(dragData.clientPosition());
     HitTestResult result = HitTestResult(point);
     if (!m_page.mainFrame().contentRenderer())
         return false;
@@ -559,7 +548,7 @@ bool DragController::canProcessDrag(DragData* dragData)
     if (!result.innerNonSharedNode())
         return false;
 
-    if (dragData->containsFiles() && asFileInput(result.innerNonSharedNode()))
+    if (dragData.containsFiles() && asFileInput(result.innerNonSharedNode()))
         return true;
 
     if (result.innerNonSharedNode()->isPluginElement()) {
@@ -594,9 +583,8 @@ static DragOperation defaultOperationForDrag(DragOperation srcOpMask)
     return DragOperationGeneric;
 }
 
-bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
+bool DragController::tryDHTMLDrag(DragData& dragData, DragOperation& operation)
 {
-    ASSERT(dragData);
     ASSERT(m_documentUnderMouse);
     Ref<MainFrame> mainFrame(m_page.mainFrame());
     RefPtr<FrameView> viewProtector = mainFrame->view();
@@ -604,8 +592,8 @@ bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
         return false;
 
     ClipboardAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLocal() ? ClipboardReadable : ClipboardTypesReadable;
-    RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(policy, *dragData);
-    DragOperation srcOpMask = dragData->draggingSourceOperationMask();
+    RefPtr<Clipboard> clipboard = Clipboard::createForDragAndDrop(policy, dragData);
+    DragOperation srcOpMask = dragData.draggingSourceOperationMask();
     clipboard->setSourceOperation(srcOpMask);
 
     PlatformMouseEvent event = createMouseEvent(dragData);
@@ -664,19 +652,17 @@ Element* DragController::draggableElement(const Frame* sourceFrame, Element* sta
     return (state.type & DragSourceActionSelection) ? startElement : 0;
 }
 
-static CachedImage* getCachedImage(Element* element)
+static CachedImage* getCachedImage(Element& element)
 {
-    ASSERT(element);
-    RenderObject* renderer = element->renderer();
+    RenderObject* renderer = element.renderer();
     if (!renderer || !renderer->isImage())
         return 0;
     RenderImage* image = toRenderImage(renderer);
     return image->cachedImage();
 }
 
-static Image* getImage(Element* element)
+static Image* getImage(Element& element)
 {
-    ASSERT(element);
     CachedImage* cachedImage = getCachedImage(element);
     // Don't use cachedImage->imageForRenderer() here as that may return BitmapImages for cached SVG Images.
     // Users of getImage() want access to the SVGImage, in order to figure out the filename extensions,
@@ -685,11 +671,11 @@ static Image* getImage(Element* element)
         cachedImage->image() : 0;
 }
 
-static void selectElement(Element* element)
+static void selectElement(Element& element)
 {
-    RefPtr<Range> range = element->document().createRange();
-    range->selectNode(element);
-    element->document().frame()->selection().setSelection(VisibleSelection(range.get(), DOWNSTREAM));
+    RefPtr<Range> range = element.document().createRange();
+    range->selectNode(&element);
+    element.document().frame()->selection().setSelection(VisibleSelection(range.get(), DOWNSTREAM));
 }
 
 static IntPoint dragLocForDHTMLDrag(const IntPoint& mouseDraggedPoint, const IntPoint& dragOrigin, const IntPoint& dragImageOffset, bool isLinkImage)
@@ -708,9 +694,9 @@ static IntPoint dragLocForDHTMLDrag(const IntPoint& mouseDraggedPoint, const Int
     return IntPoint(dragOrigin.x() - dragImageOffset.x(), dragOrigin.y() + yOffset);
 }
 
-static IntPoint dragLocForSelectionDrag(Frame* src)
+static IntPoint dragLocForSelectionDrag(Frame& src)
 {
-    IntRect draggingRect = enclosingIntRect(src->selection().bounds());
+    IntRect draggingRect = enclosingIntRect(src.selection().bounds());
     int xpos = draggingRect.maxX();
     xpos = draggingRect.x() < xpos ? draggingRect.x() : xpos;
     int ypos = draggingRect.maxY();
@@ -723,14 +709,12 @@ static IntPoint dragLocForSelectionDrag(Frame* src)
     return IntPoint(xpos, ypos);
 }
 
-bool DragController::startDrag(Frame* src, const DragState& state, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin)
+bool DragController::startDrag(Frame& src, const DragState& state, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin)
 {
-    ASSERT(src);
-
-    if (!src->view() || !src->contentRenderer())
+    if (!src.view() || !src.contentRenderer())
         return false;
 
-    HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragOrigin, HitTestRequest::ReadOnly | HitTestRequest::Active);
+    HitTestResult hitTestResult = src.eventHandler().hitTestResultAtPoint(dragOrigin, HitTestRequest::ReadOnly | HitTestRequest::Active);
     if (!state.source->contains(hitTestResult.innerNode()))
         // The original node being dragged isn't under the drag origin anymore... maybe it was
         // hidden or moved out from under the cursor. Regardless, we don't want to start a drag on
@@ -739,7 +723,7 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
     URL linkURL = hitTestResult.absoluteLinkURL();
     URL imageURL = hitTestResult.absoluteImageURL();
 
-    IntPoint mouseDraggedPoint = src->view()->windowToContents(dragEvent.position());
+    IntPoint mouseDraggedPoint = src.view()->windowToContents(dragEvent.position());
 
     m_draggingImageURL = URL();
     m_sourceDragOperation = srcOp;
@@ -748,9 +732,11 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
     IntPoint dragLoc(0, 0);
     IntPoint dragImageOffset(0, 0);
 
-    Clipboard* clipboard = state.clipboard.get();
+    ASSERT(state.clipboard);
+
+    Clipboard& clipboard = *state.clipboard;
     if (state.type == DragSourceActionDHTML)
-        dragImage = clipboard->createDragImage(dragImageOffset);
+        dragImage = clipboard.createDragImage(dragImageOffset);
     if (state.type == DragSourceActionSelection || !imageURL.isEmpty() || !linkURL.isEmpty())
         // Selection, image, and link drags receive a default set of allowed drag operations that
         // follows from:
@@ -766,45 +752,46 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
 
     bool startedDrag = true; // optimism - we almost always manage to start the drag
 
-    Element* element = state.source.get();
+    ASSERT(state.source);
+    Element& element = *state.source;
 
     Image* image = getImage(element);
     if (state.type == DragSourceActionSelection) {
-        if (!clipboard->pasteboard().hasData()) {
+        if (!clipboard.pasteboard().hasData()) {
             // FIXME: This entire block is almost identical to the code in Editor::copy, and the code should be shared.
 
-            RefPtr<Range> selectionRange = src->selection().toNormalizedRange();
+            RefPtr<Range> selectionRange = src.selection().toNormalizedRange();
             ASSERT(selectionRange);
 
-            src->editor().willWriteSelectionToPasteboard(selectionRange.get());
+            src.editor().willWriteSelectionToPasteboard(selectionRange.get());
 
-            if (enclosingTextFormControl(src->selection().start()))
-                clipboard->pasteboard().writePlainText(src->editor().selectedTextForClipboard(), Pasteboard::CannotSmartReplace);
+            if (enclosingTextFormControl(src.selection().start()))
+                clipboard.pasteboard().writePlainText(src.editor().selectedTextForClipboard(), Pasteboard::CannotSmartReplace);
             else {
 #if PLATFORM(MAC) || PLATFORM(EFL)
-                src->editor().writeSelectionToPasteboard(clipboard->pasteboard());
+                src.editor().writeSelectionToPasteboard(clipboard.pasteboard());
 #else
                 // FIXME: Convert all other platforms to match Mac and delete this.
-                clipboard->pasteboard().writeSelection(selectionRange.get(), src->editor().canSmartCopyOrDelete(), src, IncludeImageAltTextForClipboard);
+                clipboard.pasteboard().writeSelection(*selectionRange, src.editor().canSmartCopyOrDelete(), src, IncludeImageAltTextForClipboard);
 #endif
             }
 
-            src->editor().didWriteSelectionToPasteboard();
+            src.editor().didWriteSelectionToPasteboard();
         }
         m_client.willPerformDragSourceAction(DragSourceActionSelection, dragOrigin, clipboard);
         if (!dragImage) {
-            dragImage = dissolveDragImageToFraction(src->dragImageForSelection(), DragImageAlpha);
+            dragImage = dissolveDragImageToFraction(src.dragImageForSelection(), DragImageAlpha);
             dragLoc = dragLocForSelectionDrag(src);
             m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y());
         }
         doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false);
-    } else if (!imageURL.isEmpty() && element && image && !image->isNull() && (m_dragSourceAction & DragSourceActionImage)) {
+    } else if (!imageURL.isEmpty() && image && !image->isNull() && (m_dragSourceAction & DragSourceActionImage)) {
         // We shouldn't be starting a drag for an image that can't provide an extension.
         // This is an early detection for problems encountered later upon drop.
         ASSERT(!image->filenameExtension().isEmpty());
-        if (!clipboard->pasteboard().hasData()) {
+        if (!clipboard.pasteboard().hasData()) {
             m_draggingImageURL = imageURL;
-            if (element->isContentRichlyEditable())
+            if (element.isContentRichlyEditable())
                 selectElement(element);
             declareAndWriteDragImage(clipboard, element, !linkURL.isEmpty() ? linkURL : imageURL, hitTestResult.altDisplayString());
         }
@@ -813,31 +800,31 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
 
         if (!dragImage) {
             IntRect imageRect = hitTestResult.imageRect();
-            imageRect.setLocation(m_page.mainFrame().view()->rootViewToContents(src->view()->contentsToRootView(imageRect.location())));
+            imageRect.setLocation(m_page.mainFrame().view()->rootViewToContents(src.view()->contentsToRootView(imageRect.location())));
             doImageDrag(element, dragOrigin, hitTestResult.imageRect(), clipboard, src, m_dragOffset);
-        } else
+        } else {
             // DHTML defined drag image
             doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false);
-
+        }
     } else if (!linkURL.isEmpty() && (m_dragSourceAction & DragSourceActionLink)) {
-        if (!clipboard->pasteboard().hasData())
+        if (!clipboard.pasteboard().hasData())
             // Simplify whitespace so the title put on the clipboard resembles what the user sees
             // on the web page. This includes replacing newlines with spaces.
-            src->editor().copyURL(linkURL, hitTestResult.textContent().simplifyWhiteSpace(), clipboard->pasteboard());
+            src.editor().copyURL(linkURL, hitTestResult.textContent().simplifyWhiteSpace(), clipboard.pasteboard());
 
-        if (src->selection().isCaret() && src->selection().isContentEditable()) {
+        if (src.selection().isCaret() && src.selection().isContentEditable()) {
             // a user can initiate a drag on a link without having any text
             // selected.  In this case, we should expand the selection to
             // the enclosing anchor element
-            Position pos = src->selection().base();
+            Position pos = src.selection().base();
             Node* node = enclosingAnchorElement(pos);
             if (node)
-                src->selection().setSelection(VisibleSelection::selectionFromContentsOfNode(node));
+                src.selection().setSelection(VisibleSelection::selectionFromContentsOfNode(node));
         }
 
         m_client.willPerformDragSourceAction(DragSourceActionLink, dragOrigin, clipboard);
         if (!dragImage) {
-            dragImage = createDragImageForLink(linkURL, hitTestResult.textContent(), src->settings().fontRenderingMode());
+            dragImage = createDragImageForLink(linkURL, hitTestResult.textContent(), src.settings().fontRenderingMode());
             IntSize size = dragImageSize(dragImage);
             m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset);
             dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDraggedPoint.y() + m_dragOffset.y());
@@ -861,7 +848,7 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
     return startedDrag;
 }
 
-void DragController::doImageDrag(Element* element, const IntPoint& dragOrigin, const IntRect& rect, Clipboard* clipboard, Frame* frame, IntPoint& dragImageOffset)
+void DragController::doImageDrag(Element& element, const IntPoint& dragOrigin, const IntRect& rect, Clipboard& clipboard, Frame& frame, IntPoint& dragImageOffset)
 {
     IntPoint mouseDownPoint = dragOrigin;
     DragImageRef dragImage = 0;
@@ -869,7 +856,7 @@ void DragController::doImageDrag(Element* element, const IntPoint& dragOrigin, c
 
     Image* image = getImage(element);
     if (image && image->size().height() * image->size().width() <= MaxOriginalImageArea
-        && (dragImage = createDragImageFromImage(image, element->renderer() ? ImageOrientationDescription(element->renderer()->shouldRespectImageOrientation()) : ImageOrientationDescription()))) {
+        && (dragImage = createDragImageFromImage(image, element.renderer() ? ImageOrientationDescription(element.renderer()->shouldRespectImageOrientation()) : ImageOrientationDescription()))) {
         IntSize originalSize = rect.size();
         origin = rect.location();
 
@@ -903,15 +890,15 @@ void DragController::doImageDrag(Element* element, const IntPoint& dragOrigin, c
     deleteDragImage(dragImage);
 }
 
-void DragController::doSystemDrag(DragImageRef image, const IntPoint& dragLoc, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool forLink)
+void DragController::doSystemDrag(DragImageRef image, const IntPoint& dragLoc, const IntPoint& eventPos, Clipboard& clipboard, Frame& frame, bool forLink)
 {
     m_didInitiateDrag = true;
-    m_dragInitiator = frame->document();
+    m_dragInitiator = frame.document();
     // Protect this frame and view, as a load may occur mid drag and attempt to unload this frame
     Ref<MainFrame> frameProtector(m_page.mainFrame());
     RefPtr<FrameView> viewProtector = frameProtector->view();
-    m_client.startDrag(image, viewProtector->rootViewToContents(frame->view()->contentsToRootView(dragLoc)),
-        viewProtector->rootViewToContents(frame->view()->contentsToRootView(eventPos)), clipboard, &frameProtector.get(), forLink);
+    m_client.startDrag(image, viewProtector->rootViewToContents(frame.view()->contentsToRootView(dragLoc)),
+        viewProtector->rootViewToContents(frame.view()->contentsToRootView(eventPos)), clipboard, frameProtector.get(), forLink);
     // DragClient::startDrag can cause our Page to dispear, deallocating |this|.
     if (!frameProtector->page())
         return;
index 3c69128..0508990 100644 (file)
@@ -58,10 +58,10 @@ namespace WebCore {
 
         DragClient& client() const { return m_client; }
 
-        DragSession dragEntered(DragData*);
-        void dragExited(DragData*);
-        DragSession dragUpdated(DragData*);
-        bool performDrag(DragData*);
+        DragSession dragEntered(DragData&);
+        void dragExited(DragData&);
+        DragSession dragUpdated(DragData&);
+        bool performDrag(DragData&);
         
         // FIXME: It should be possible to remove a number of these accessors once all
         // drag logic is in WebCore.
@@ -82,7 +82,7 @@ namespace WebCore {
         
         void placeDragCaret(const IntPoint&);
         
-        bool startDrag(Frame* src, const DragState&, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin);
+        bool startDrag(Frame& src, const DragState&, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin);
         static const IntSize& maxDragImageSize();
         
         static const int LinkDragBorderInset;
@@ -92,24 +92,24 @@ namespace WebCore {
         static const float DragImageAlpha;
 
     private:
-        bool dispatchTextInputEventFor(Frame*, DragData*);
-        bool canProcessDrag(DragData*);
-        bool concludeEditDrag(DragData*);
-        DragSession dragEnteredOrUpdated(DragData*);
-        DragOperation operationForLoad(DragData*);
-        bool tryDocumentDrag(DragData*, DragDestinationAction, DragSession&);
-        bool tryDHTMLDrag(DragData*, DragOperation&);
-        DragOperation dragOperation(DragData*);
+        bool dispatchTextInputEventFor(Frame*, DragData&);
+        bool canProcessDrag(DragData&);
+        bool concludeEditDrag(DragData&);
+        DragSession dragEnteredOrUpdated(DragData&);
+        DragOperation operationForLoad(DragData&);
+        bool tryDocumentDrag(DragData&, DragDestinationAction, DragSession&);
+        bool tryDHTMLDrag(DragData&, DragOperation&);
+        DragOperation dragOperation(DragData&);
         void cancelDrag();
-        bool dragIsMove(FrameSelection&, DragData*);
-        bool isCopyKeyDown(DragData*);
+        bool dragIsMove(FrameSelection&, DragData&);
+        bool isCopyKeyDown(DragData&);
 
         void mouseMovedIntoDocument(Document*);
 
-        void doImageDrag(Element*, const IntPoint&, const IntRect&, Clipboard*, Frame*, IntPoint&);
-        void doSystemDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool forLink);
+        void doImageDrag(Element&, const IntPoint&, const IntRect&, Clipboard&, Frame&, IntPoint&);
+        void doSystemDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard&, Frame&, bool forLink);
         void cleanupAfterSystemDrag();
-        void declareAndWriteDragImage(Clipboard*, Element*, const URL&, const String& label);
+        void declareAndWriteDragImage(Clipboard&, Element&, const URL&, const String& label);
 
         Page& m_page;
         DragClient& m_client;
index 685b21a..8677ca4 100644 (file)
@@ -3668,7 +3668,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDr
     
     if (m_mouseDownMayStartDrag) {
         Page* page = m_frame.page();
-        m_didStartDrag = page && page->dragController().startDrag(&m_frame, dragState(), srcOp, event.event(), m_mouseDownPos);
+        m_didStartDrag = page && page->dragController().startDrag(m_frame, dragState(), srcOp, event.event(), m_mouseDownPos);
         // In WebKit2 we could re-enter this code and start another drag.
         // On OS X this causes problems with the ownership of the pasteboard and the promised types.
         if (m_didStartDrag) {
index a7a3602..481d984 100644 (file)
@@ -43,14 +43,14 @@ const int DragController::DragIconBottomInset = 3;
 
 const float DragController::DragImageAlpha = 0.75f;
 
-bool DragController::isCopyKeyDown(DragData*)
+bool DragController::isCopyKeyDown(DragData&)
 {
     return false;
 }
 
-DragOperation DragController::dragOperation(DragData* dragData)
+DragOperation DragController::dragOperation(DragData& dragData)
 {
-    if (dragData->containsURL(0))
+    if (dragData.containsURL(0))
         return DragOperationCopy;
 
     return DragOperationNone;
@@ -67,7 +67,7 @@ void DragController::cleanupAfterSystemDrag()
 {
 }
 
-void DragController::declareAndWriteDragImage(Clipboard*, Element*, const URL&, const String&)
+void DragController::declareAndWriteDragImage(Clipboard&, Element&, const URL&, const String&)
 {
 }
 
index 170e841..69606a4 100644 (file)
@@ -45,15 +45,15 @@ const int DragController::DragIconBottomInset = 3;
 
 const float DragController::DragImageAlpha = 0.75f;
 
-bool DragController::isCopyKeyDown(DragData*)
+bool DragController::isCopyKeyDown(DragData&)
 {
     return false;
 }
 
-DragOperation DragController::dragOperation(DragData* dragData)
+DragOperation DragController::dragOperation(DragData& dragData)
 {
-    //FIXME: This logic is incomplete
-     if (dragData->containsURL(0))
+    // FIXME: This logic is incomplete
+    if (dragData.containsURL(0))
         return DragOperationCopy;
 
     return DragOperationNone;
@@ -69,9 +69,9 @@ void DragController::cleanupAfterSystemDrag()
 {
 }
 
-void DragController::declareAndWriteDragImage(Clipboard* clipboard, Element* element, const URL& url, const String& label)
+void DragController::declareAndWriteDragImage(Clipboard& clipboard, Element& element, const URL& url, const String& label)
 {
-    clipboard->pasteboard().writeImage(element, url, label);
+    clipboard.pasteboard().writeImage(element, url, label);
 }
 
 }
index 8ed7e2d..e6e87b3 100644 (file)
@@ -29,7 +29,6 @@
 #if ENABLE(DRAG_SUPPORT)
 
 #import "Clipboard.h"
-#import "DOMElementInternal.h"
 #import "DragClient.h"
 #import "DragData.h"
 #import "Element.h"
@@ -48,19 +47,17 @@ const int DragController::DragIconBottomInset = 3;
 
 const float DragController::DragImageAlpha = 0.75f;
 
-bool DragController::isCopyKeyDown(DragData* dragData)
+bool DragController::isCopyKeyDown(DragData& dragData)
 {
-    return dragData->flags() & DragApplicationIsCopyKeyDown;
+    return dragData.flags() & DragApplicationIsCopyKeyDown;
 }
     
-DragOperation DragController::dragOperation(DragData* dragData)
+DragOperation DragController::dragOperation(DragData& dragData)
 {
-    ASSERT(dragData);
-
-    if ((dragData->flags() & DragApplicationIsModal) || !dragData->containsURL(&m_page.mainFrame()))
+    if ((dragData.flags() & DragApplicationIsModal) || !dragData.containsURL(&m_page.mainFrame()))
         return DragOperationNone;
 
-    if (!m_documentUnderMouse || (!(dragData->flags() & (DragApplicationHasAttachedSheet | DragApplicationIsSource))))
+    if (!m_documentUnderMouse || (!(dragData.flags() & (DragApplicationHasAttachedSheet | DragApplicationIsSource))))
         return DragOperationCopy;
 
     return DragOperationNone;
@@ -85,9 +82,9 @@ void DragController::cleanupAfterSystemDrag()
         dragEnded();
 }
 
-void DragController::declareAndWriteDragImage(Clipboard* clipboard, Element* element, const URL& url, const String& label)
+void DragController::declareAndWriteDragImage(Clipboard& clipboard, Element& element, const URL& url, const String& label)
 {
-    m_client.declareAndWriteDragImage(clipboard->pasteboard().name(), kit(element), url, label, element->document().frame());
+    m_client.declareAndWriteDragImage(clipboard.pasteboard().name(), element, url, label, element.document().frame());
 }
 
 } // namespace WebCore
index 6e48fa7..76ac406 100644 (file)
@@ -44,17 +44,16 @@ const int DragController::DragIconBottomInset = 3;
 
 const float DragController::DragImageAlpha = 0.75f;
 
-DragOperation DragController::dragOperation(DragData* dragData)
+DragOperation DragController::dragOperation(DragData& dragData)
 {
     //FIXME: to match the macos behaviour we should return DragOperationNone
     //if we are a modal window, we are the drag source, or the window is an attached sheet
     //If this can be determined from within WebCore operationForDrag can be pulled into 
     //WebCore itself
-    ASSERT(dragData);
-    return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
+    return dragData.containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
 }
 
-bool DragController::isCopyKeyDown(DragData*)
+bool DragController::isCopyKeyDown(DragData&)
 {
     return ::GetAsyncKeyState(VK_CONTROL);
 }
@@ -70,9 +69,9 @@ void DragController::cleanupAfterSystemDrag()
 {
 }
 
-void DragController::declareAndWriteDragImage(Clipboard* clipboard, Element* element, const URL& url, const String& label)
+void DragController::declareAndWriteDragImage(Clipboard& clipboard, Element& element, const URL& url, const String& label)
 {
-    Pasteboard& pasteboard = clipboard->pasteboard();
+    Pasteboard& pasteboard = clipboard.pasteboard();
 
     // FIXME: Do we really need this check?
     if (!pasteboard.writableDataObject())
@@ -81,7 +80,7 @@ void DragController::declareAndWriteDragImage(Clipboard* clipboard, Element* ele
     // Order is important here for Explorer's sake
     pasteboard.writeURLToWritableDataObject(url, label);
     pasteboard.writeImageToDataObject(element, url);
-    pasteboard.writeMarkup(createMarkup(*element, IncludeNode, 0, ResolveAllURLs));
+    pasteboard.writeMarkup(createMarkup(element, IncludeNode, 0, ResolveAllURLs));
 }
 
 }
index 9303769..1784ef4 100644 (file)
@@ -104,8 +104,7 @@ public:
     String asPlainText(Frame*) const;
     void asFilenames(Vector<String>&) const;
     Color asColor() const;
-    PassRefPtr<DocumentFragment> asFragment(Frame*, PassRefPtr<Range> context,
-                                            bool allowPlainText, bool& chosePlainText) const;
+    PassRefPtr<DocumentFragment> asFragment(Frame*, Range& context, bool allowPlainText, bool& chosePlainText) const;
     bool canSmartReplace() const;
     bool containsColor() const;
     bool containsFiles() const;
index 7627af7..e841746 100644 (file)
@@ -164,21 +164,15 @@ public:
 #endif
 
 #if PLATFORM(GTK) || PLATFORM(WIN)
-    PassRefPtr<DocumentFragment> documentFragment(Frame*, PassRefPtr<Range>, bool allowPlainText, bool& chosePlainText); // FIXME: Layering violation.
-#endif
-
-#if PLATFORM(GTK) || PLATFORM(WIN)
-    void writeImage(Node*, const URL&, const String& title); // FIXME: Layering violation.
-    void writeSelection(Range*, bool canSmartCopyOrDelete, Frame*, ShouldSerializeSelectedTextForClipboard = DefaultSelectedTextType); // FIXME: Layering violation.
+    PassRefPtr<DocumentFragment> documentFragment(Frame&, Range&, bool allowPlainText, bool& chosePlainText); // FIXME: Layering violation.
+    void writeImage(Element&, const URL&, const String& title); // FIXME: Layering violation.
+    void writeSelection(Range&, bool canSmartCopyOrDelete, Frame&, ShouldSerializeSelectedTextForClipboard = DefaultSelectedTextType); // FIXME: Layering violation.
 #endif
 
 #if PLATFORM(GTK)
     static PassOwnPtr<Pasteboard> create(PassRefPtr<DataObjectGtk>);
     static PassOwnPtr<Pasteboard> create(GtkClipboard*);
     PassRefPtr<DataObjectGtk> dataObject() const;
-#endif
-
-#if PLATFORM(GTK)
     static PassOwnPtr<Pasteboard> createForGlobalSelection();
 #endif
 
@@ -199,7 +193,7 @@ public:
     void setExternalDataObject(IDataObject*);
     void writeURLToWritableDataObject(const URL&, const String&);
     COMPtr<WCDataObject> writableDataObject() const { return m_writableDataObject; }
-    void writeImageToDataObject(Element*, const URL&); // FIXME: Layering violation.
+    void writeImageToDataObject(Element&, const URL&); // FIXME: Layering violation.
 #endif
 
 private:
@@ -216,7 +210,7 @@ private:
     explicit Pasteboard(const DragDataMap&);
 
     void finishCreatingPasteboard();
-    void writeRangeToDataObject(Range*, Frame*); // FIXME: Layering violation.
+    void writeRangeToDataObject(Range&, Frame&); // FIXME: Layering violation.
     void writeURLToDataObject(const URL&, const String&);
     void writePlainTextToDataObject(const String&, SmartReplaceOption);
 #endif
index dcaf408..dcc8efb 100644 (file)
@@ -80,7 +80,7 @@ String DragData::asURL(Frame*, FilenameConversionPolicy, String*) const
     return String();
 }
 
-PassRefPtr<DocumentFragment> DragData::asFragment(Frame*, PassRefPtr<Range>, bool, bool&) const
+PassRefPtr<DocumentFragment> DragData::asFragment(Frame*, Range&, bool, bool&) const
 {
     return 0;
 }
index 45abd2d..2bf34df 100644 (file)
@@ -92,7 +92,7 @@ String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String*
 }
 
 
-PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const
+PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, Range&, bool, bool&) const
 {
     if (!m_platformDragData->hasMarkup())
         return nullptr;
index 8b9de6a..9de6f4c 100644 (file)
@@ -95,7 +95,7 @@ void GtkDragAndDropHelper::handleDragLeaveLater(DroppingContext* context)
     DragData dragData(context->dataObject.get(), position,
                       convertWidgetPointToScreenPoint(m_widget, position),
                       DragOperationNone);
-    context->exitedCallback(m_widget, &dragData, context->dropHappened);
+    context->exitedCallback(m_widget, dragData, context->dropHappened);
 
     m_droppingContexts.remove(iterator);
 }
index e89ac49..529e998 100644 (file)
@@ -28,7 +28,7 @@ namespace WebCore {
 struct DroppingContext;
 class DragData;
 
-typedef void (*DragExitedCallback)(GtkWidget*, DragData*, bool dropHappened);
+typedef void (*DragExitedCallback)(GtkWidget*, DragData&, bool dropHappened);
 
 class GtkDragAndDropHelper {
     WTF_MAKE_NONCOPYABLE(GtkDragAndDropHelper);
index 0a6a8c7..c88b047 100644 (file)
@@ -157,11 +157,11 @@ bool Pasteboard::writeString(const String& type, const String& data)
     return false;
 }
 
-void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
+void Pasteboard::writeSelection(Range& selectedRange, bool canSmartCopyOrDelete, Frame& frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
 {
     m_dataObject->clearAll();
-    m_dataObject->setText(shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor().selectedTextForClipboard() : frame->editor().selectedText());
-    m_dataObject->setMarkup(createMarkup(*selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs));
+    m_dataObject->setText(shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame.editor().selectedTextForClipboard() : frame.editor().selectedText());
+    m_dataObject->setMarkup(createMarkup(selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs));
 
     if (m_gtkClipboard)
         PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard, canSmartCopyOrDelete ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste);
@@ -187,31 +187,28 @@ void Pasteboard::write(const PasteboardURL& pasteboardURL)
         PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard);
 }
 
-static URL getURLForImageNode(Node* node)
+static URL getURLForImageElement(Element& element)
 {
     // FIXME: Later this code should be shared with Chromium somehow. Chances are all platforms want it.
     AtomicString urlString;
-    if (isHTMLImageElement(node) || isHTMLInputElement(node))
-        urlString = toElement(node)->getAttribute(HTMLNames::srcAttr);
+    if (isHTMLImageElement(element) || isHTMLInputElement(element))
+        urlString = element.getAttribute(HTMLNames::srcAttr);
 #if ENABLE(SVG)
-    else if (node->hasTagName(SVGNames::imageTag))
-        urlString = toElement(node)->getAttribute(XLinkNames::hrefAttr);
+    else if (element.hasTagName(SVGNames::imageTag))
+        urlString = element.getAttribute(XLinkNames::hrefAttr);
 #endif
-    else if (node->hasTagName(HTMLNames::embedTag) || isHTMLObjectElement(node)) {
-        Element* element = toElement(node);
-        urlString = element->imageSourceURL();
-    }
-    return urlString.isEmpty() ? URL() : node->document().completeURL(stripLeadingAndTrailingHTMLSpaces(urlString));
+    else if (element.hasTagName(HTMLNames::embedTag) || isHTMLObjectElement(element))
+        urlString = element.imageSourceURL();
+
+    return urlString.isEmpty() ? URL() : element.document().completeURL(stripLeadingAndTrailingHTMLSpaces(urlString));
 }
 
-void Pasteboard::writeImage(Node* node, const URL&, const String& title)
+void Pasteboard::writeImage(Element& element, const URL&, const String& title)
 {
-    ASSERT(node);
-
-    if (!(node->renderer() && node->renderer()->isImage()))
+    if (!(element.renderer() && element.renderer()->isImage()))
         return;
 
-    RenderImage* renderer = toRenderImage(node->renderer());
+    RenderImage* renderer = toRenderImage(element.renderer());
     CachedImage* cachedImage = renderer->cachedImage();
     if (!cachedImage || cachedImage->errorOccurred())
         return;
@@ -220,11 +217,11 @@ void Pasteboard::writeImage(Node* node, const URL&, const String& title)
 
     m_dataObject->clearAll();
 
-    URL url = getURLForImageNode(node);
+    URL url = getURLForImageElement(element);
     if (!url.isEmpty()) {
         m_dataObject->setURL(url, title);
 
-        m_dataObject->setMarkup(createMarkup(*toElement(node), IncludeNode, 0, ResolveAllURLs));
+        m_dataObject->setMarkup(createMarkup(element, IncludeNode, 0, ResolveAllURLs));
     }
 
     GRefPtr<GdkPixbuf> pixbuf = adoptGRef(image->getGdkPixbuf());
@@ -302,8 +299,7 @@ void Pasteboard::setDragImage(DragImageRef, const IntPoint& hotSpot)
 }
 #endif
 
-PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context,
-                                                          bool allowPlainText, bool& chosePlainText)
+PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
 {
     if (m_gtkClipboard)
         PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_gtkClipboard);
@@ -311,8 +307,8 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
     chosePlainText = false;
 
     if (m_dataObject->hasMarkup()) {
-        if (frame->document()) {
-            RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(*frame->document(), m_dataObject->markup(), emptyString(), DisallowScriptingAndPluginContent);
+        if (frame.document()) {
+            RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(*frame.document(), m_dataObject->markup(), emptyString(), DisallowScriptingAndPluginContent);
             if (fragment)
                 return fragment.release();
         }
@@ -323,7 +319,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
 
     if (m_dataObject->hasText()) {
         chosePlainText = true;
-        RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), m_dataObject->text());
+        RefPtr<DocumentFragment> fragment = createFragmentFromText(context, m_dataObject->text());
         if (fragment)
             return fragment.release();
     }
index d7e6eee..6dcd341 100644 (file)
@@ -189,10 +189,10 @@ String DragData::asURL(Frame* frame, FilenameConversionPolicy, String* title) co
     return String();        
 }
 
-PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range> range, bool allowPlainText, bool& chosePlainText) const
+PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, Range& range, bool allowPlainText, bool& chosePlainText) const
 {
     Pasteboard pasteboard(m_pasteboardName);
-    return frame->editor().webContentFromPasteboard(pasteboard, *range, allowPlainText, chosePlainText);
+    return frame->editor().webContentFromPasteboard(pasteboard, range, allowPlainText, chosePlainText);
 }
     
 } // namespace WebCore
index 2aa9e78..8f20aa3 100644 (file)
@@ -206,7 +206,7 @@ bool DragData::containsCompatibleContent() const
         || containsColor();
 }
 
-PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const
+PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, Range&, bool, bool&) const
 {     
     /*
      * Order is richest format first. On OSX this is:
index 32cb869..e8021c8 100644 (file)
@@ -422,9 +422,8 @@ void Pasteboard::setDragImage(DragImageRef, const IntPoint&)
 }
 #endif
 
-void Pasteboard::writeRangeToDataObject(Range* selectedRange, Frame* frame)
+void Pasteboard::writeRangeToDataObject(Range& selectedRange, Frame& frame)
 {
-    ASSERT(selectedRange);
     if (!m_writableDataObject)
         return;
 
@@ -432,13 +431,13 @@ void Pasteboard::writeRangeToDataObject(Range* selectedRange, Frame* frame)
     medium.tymed = TYMED_HGLOBAL;
 
     Vector<char> data;
-    markupToCFHTML(createMarkup(*selectedRange, 0, AnnotateForInterchange),
-        selectedRange->startContainer()->document().url().string(), data);
+    markupToCFHTML(createMarkup(selectedRange, 0, AnnotateForInterchange),
+        selectedRange.startContainer()->document().url().string(), data);
     medium.hGlobal = createGlobalData(data);
     if (medium.hGlobal && FAILED(m_writableDataObject->SetData(htmlFormat(), &medium, TRUE)))
         ::GlobalFree(medium.hGlobal);
 
-    String str = frame->editor().selectedTextForClipboard();
+    String str = frame.editor().selectedTextForClipboard();
     replaceNewlinesWithWindowsStyleNewlines(str);
     replaceNBSPWithSpace(str);
     medium.hGlobal = createGlobalData(str);
@@ -446,19 +445,19 @@ void Pasteboard::writeRangeToDataObject(Range* selectedRange, Frame* frame)
         ::GlobalFree(medium.hGlobal);
 
     medium.hGlobal = 0;
-    if (frame->editor().canSmartCopyOrDelete())
+    if (frame.editor().canSmartCopyOrDelete())
         m_writableDataObject->SetData(smartPasteFormat(), &medium, TRUE);
 }
 
-void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
+void Pasteboard::writeSelection(Range& selectedRange, bool canSmartCopyOrDelete, Frame& frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
 {
     clear();
 
     // Put CF_HTML format on the pasteboard 
     if (::OpenClipboard(m_owner)) {
         Vector<char> data;
-        markupToCFHTML(createMarkup(*selectedRange, 0, AnnotateForInterchange),
-            selectedRange->startContainer()->document().url().string(), data);
+        markupToCFHTML(createMarkup(selectedRange, 0, AnnotateForInterchange),
+            selectedRange.startContainer()->document().url().string(), data);
         HGLOBAL cbData = createGlobalData(data);
         if (!::SetClipboardData(HTMLClipboardFormat, cbData))
             ::GlobalFree(cbData);
@@ -466,7 +465,7 @@ void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete,
     }
     
     // Put plain string on the pasteboard. CF_UNICODETEXT covers CF_TEXT as well
-    String str = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor().selectedTextForClipboard() : frame->editor().selectedText();
+    String str = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame.editor().selectedTextForClipboard() : frame.editor().selectedText();
     replaceNewlinesWithWindowsStyleNewlines(str);
     replaceNBSPWithSpace(str);
     if (::OpenClipboard(m_owner)) {
@@ -725,14 +724,12 @@ void Pasteboard::write(const PasteboardURL& pasteboardURL)
     writeURLToDataObject(pasteboardURL.url, pasteboardURL.title);
 }
 
-void Pasteboard::writeImage(Node* node, const URL&, const String&)
+void Pasteboard::writeImage(Element& element, const URL&, const String&)
 {
-    ASSERT(node);
-
-    if (!(node->renderer() && node->renderer()->isImage()))
+    if (!(element.renderer() && element.renderer()->isImage()))
         return;
 
-    RenderImage* renderer = toRenderImage(node->renderer());
+    RenderImage* renderer = toRenderImage(element.renderer());
     CachedImage* cachedImage = renderer->cachedImage();
     if (!cachedImage || cachedImage->errorOccurred())
         return;
@@ -798,7 +795,7 @@ void Pasteboard::read(PasteboardPlainText& text)
     }
 }
 
-PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText)
+PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
 {
     chosePlainText = false;
     
@@ -811,9 +808,9 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
             GlobalUnlock(cbData);
             ::CloseClipboard();
 
-            PassRefPtr<DocumentFragment> fragment = fragmentFromCFHTML(frame->document(), cfhtml);
+            RefPtr<DocumentFragment> fragment = fragmentFromCFHTML(frame.document(), cfhtml);
             if (fragment)
-                return fragment;
+                return fragment.release();
         } else 
             ::CloseClipboard();
     }
@@ -827,7 +824,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
                 String str(buffer);
                 GlobalUnlock(cbData);
                 ::CloseClipboard();
-                RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), str);
+                RefPtr<DocumentFragment> fragment = createFragmentFromText(context, str);
                 if (fragment)
                     return fragment.release();
             } else 
@@ -844,7 +841,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
                 String str(buffer);
                 GlobalUnlock(cbData);
                 ::CloseClipboard();
-                RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), str);
+                RefPtr<DocumentFragment> fragment = createFragmentFromText(context, str);
                 if (fragment)
                     return fragment.release();
             } else
@@ -861,11 +858,10 @@ void Pasteboard::setExternalDataObject(IDataObject *dataObject)
     m_dataObject = dataObject;
 }
 
-static CachedImage* getCachedImage(Element* element)
+static CachedImage* getCachedImage(Element& element)
 {
     // Attempt to pull CachedImage from element
-    ASSERT(element);
-    RenderObject* renderer = element->renderer();
+    RenderObject* renderer = element.renderer();
     if (!renderer || !renderer->isImage()) 
         return 0;
 
@@ -1001,18 +997,18 @@ static HGLOBAL createGlobalHDropContent(const URL& url, String& fileName, Shared
     return memObj;
 }
 
-void Pasteboard::writeImageToDataObject(Element* element, const URL& url)
+void Pasteboard::writeImageToDataObject(Element& element, const URL& url)
 {
     // Shove image data into a DataObject for use as a file
     CachedImage* cachedImage = getCachedImage(element);
-    if (!cachedImage || !cachedImage->imageForRenderer(element->renderer()) || !cachedImage->isLoaded())
+    if (!cachedImage || !cachedImage->imageForRenderer(element.renderer()) || !cachedImage->isLoaded())
         return;
 
-    SharedBuffer* imageBuffer = cachedImage->imageForRenderer(element->renderer())->data();
+    SharedBuffer* imageBuffer = cachedImage->imageForRenderer(element.renderer())->data();
     if (!imageBuffer || !imageBuffer->size())
         return;
 
-    HGLOBAL imageFileDescriptor = createGlobalImageFileDescriptor(url.string(), element->getAttribute(HTMLNames::altAttr), cachedImage);
+    HGLOBAL imageFileDescriptor = createGlobalImageFileDescriptor(url.string(), element.getAttribute(HTMLNames::altAttr), cachedImage);
     if (!imageFileDescriptor)
         return;
 
index ae71a77..95efd06 100644 (file)
@@ -1,3 +1,17 @@
+2013-10-07  Sam Weinig  <sam@webkit.org>
+
+        CTTE: Use references in and around DragController
+        https://bugs.webkit.org/show_bug.cgi?id=122427
+
+        Reviewed by Andreas Kling.
+
+        * WebCoreSupport/DragClientEfl.cpp:
+        (WebCore::DragClientEfl::willPerformDragDestinationAction):
+        (WebCore::DragClientEfl::willPerformDragSourceAction):
+        (WebCore::DragClientEfl::actionMaskForDrag):
+        (WebCore::DragClientEfl::startDrag):
+        * WebCoreSupport/DragClientEfl.h:
+
 2013-10-04  Anders Carlsson  <andersca@apple.com>
 
         FramePolicyFunction should be an std::function
index b1f68e0..38dce76 100644 (file)
@@ -35,17 +35,17 @@ using namespace WebCore;
 
 namespace WebCore {
 
-void DragClientEfl::willPerformDragDestinationAction(DragDestinationAction, DragData*)
+void DragClientEfl::willPerformDragDestinationAction(DragDestinationAction, DragData&)
 {
     notImplemented();
 }
 
-void DragClientEfl::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*)
+void DragClientEfl::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard&)
 {
     notImplemented();
 }
 
-DragDestinationAction DragClientEfl::actionMaskForDrag(DragData*)
+DragDestinationAction DragClientEfl::actionMaskForDrag(DragData&)
 {
     return DragDestinationActionAny;
 }
@@ -55,7 +55,7 @@ DragSourceAction DragClientEfl::dragSourceActionMaskForPoint(const IntPoint&)
     return DragSourceActionAny;
 }
 
-void DragClientEfl::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool)
+void DragClientEfl::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard&, Frame&, bool)
 {
     notImplemented();
 }
index 3f7e5d1..f409138 100644 (file)
 #include "DragClient.h"
 
 namespace WebCore {
+
 class DragClientEfl : public WebCore::DragClient {
 public:
-    virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*);
-    virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*);
-    virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*);
+    virtual void dragControllerDestroyed();
 
+    virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData&);
+    virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard&);
+    virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData&);
     virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint);
-
-    virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag = false);
-
-    virtual void dragControllerDestroyed();
+    virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard&, WebCore::Frame&, bool linkDrag = false);
 };
+
 }
 
 #endif // DragClientEfl_h
index 65b129a..784c2ea 100644 (file)
@@ -1,3 +1,22 @@
+2013-10-07  Sam Weinig  <sam@webkit.org>
+
+        CTTE: Use references in and around DragController
+        https://bugs.webkit.org/show_bug.cgi?id=122427
+
+        Reviewed by Andreas Kling.
+
+        * WebCoreSupport/DragClientGtk.cpp:
+        (WebKit::DragClient::willPerformDragDestinationAction):
+        (WebKit::DragClient::willPerformDragSourceAction):
+        (WebKit::DragClient::actionMaskForDrag):
+        (WebKit::DragClient::startDrag):
+        * WebCoreSupport/DragClientGtk.h:
+        * webkit/webkitwebview.cpp:
+        (dragExitedCallback):
+        (webkit_web_view_drag_motion):
+        (webkit_web_view_drag_data_received):
+        (webkit_web_view_drag_drop):
+
 2013-10-04  Philippe Normand  <pnormand@igalia.com>
 
         [GTK] UserMediaClientGtk needs API update
index fa03c65..09055eb 100644 (file)
@@ -55,16 +55,16 @@ DragClient::~DragClient()
 {
 }
 
-void DragClient::willPerformDragDestinationAction(DragDestinationAction, DragData*)
+void DragClient::willPerformDragDestinationAction(DragDestinationAction, DragData&)
 {
 }
 
-void DragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint& startPos, Clipboard*)
+void DragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint& startPos, Clipboard&)
 {
     m_startPos = startPos;
 }
 
-DragDestinationAction DragClient::actionMaskForDrag(DragData*)
+DragDestinationAction DragClient::actionMaskForDrag(DragData&)
 {
     notImplemented();
     return DragDestinationActionAny;
@@ -76,14 +76,14 @@ DragSourceAction DragClient::dragSourceActionMaskForPoint(const IntPoint&)
     return DragSourceActionAny;
 }
 
-void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool linkDrag)
+void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard& clipboard, Frame& frame, bool linkDrag)
 {
-    WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame));
-    RefPtr<DataObjectGtk> dataObject = clipboard->pasteboard().dataObject();
+    WebKitWebView* webView = webkit_web_frame_get_web_view(kit(&frame));
+    RefPtr<DataObjectGtk> dataObject = clipboard.pasteboard().dataObject();
     GRefPtr<GtkTargetList> targetList = adoptGRef(PasteboardHelper::defaultPasteboardHelper()->targetListForDataObject(dataObject.get()));
     GOwnPtr<GdkEvent> currentEvent(gtk_get_current_event());
 
-    GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(m_webView), targetList.get(), dragOperationToGdkDragActions(clipboard->sourceOperation()), 1, currentEvent.get());
+    GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(m_webView), targetList.get(), dragOperationToGdkDragActions(clipboard.sourceOperation()), 1, currentEvent.get());
     webView->priv->dragAndDropHelper.startedDrag(context, dataObject.get());
 
     // A drag starting should prevent a double-click from happening. This might
index 08b794b..1f7049b 100644 (file)
@@ -40,26 +40,24 @@ typedef struct _WebKitWebView WebKitWebView;
 
 namespace WebKit {
 
-    class DragClient : public WebCore::DragClient {
-    public:
-        DragClient(WebKitWebView*);
-        ~DragClient();
+class DragClient : public WebCore::DragClient {
+public:
+    DragClient(WebKitWebView*);
+    ~DragClient();
 
-        virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*);
-        virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*);
-        virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*);
+    virtual void dragControllerDestroyed();
 
-        virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint);
+    virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData&);
+    virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard&);
+    virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData&);
+    virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint);
+    virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard&, WebCore::Frame&, bool linkDrag = false);
 
-        virtual void startDrag(WebCore::DragImageRef dragImage, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag = false);
-
-        virtual void dragControllerDestroyed();
-
-    private:
-        WebKitWebView* m_webView;
-        WebCore::IntPoint m_startPos;
-        WebCore::DragIcon m_dragIcon;
-    };
+private:
+    WebKitWebView* m_webView;
+    WebCore::IntPoint m_startPos;
+    WebCore::DragIcon m_dragIcon;
+};
 }
 
 #endif
index 580a9f2..18ac697 100644 (file)
@@ -1529,7 +1529,7 @@ static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* con
     WEBKIT_WEB_VIEW(widget)->priv->dragAndDropHelper.handleGetDragData(context, selectionData, info);
 }
 
-static void dragExitedCallback(GtkWidget* widget, DragData* dragData, bool dropHappened)
+static void dragExitedCallback(GtkWidget* widget, DragData& dragData, bool dropHappened)
 {
     // Don't call dragExited if we have just received a drag-drop signal. This
     // happens in the case of a successful drop onto the view.
@@ -1552,7 +1552,7 @@ static gboolean webkit_web_view_drag_motion(GtkWidget* widget, GdkDragContext* c
         return TRUE;
 
     DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
-    DragOperation operation = core(webView)->dragController().dragUpdated(&dragData).operation;
+    DragOperation operation = core(webView)->dragController().dragUpdated(dragData).operation;
     gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
     return TRUE;
 }
@@ -1566,7 +1566,7 @@ static void webkit_web_view_drag_data_received(GtkWidget* widget, GdkDragContext
         return;
 
     DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
-    DragOperation operation = core(webView)->dragController().dragEntered(&dragData).operation;
+    DragOperation operation = core(webView)->dragController().dragEntered(dragData).operation;
     gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
 }
 
@@ -1579,7 +1579,7 @@ static gboolean webkit_web_view_drag_drop(GtkWidget* widget, GdkDragContext* con
 
     IntPoint position(x, y);
     DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
-    core(webView)->dragController().performDrag(&dragData);
+    core(webView)->dragController().performDrag(dragData);
     gtk_drag_finish(context, TRUE, FALSE, time);
     return TRUE;
 }
index 4bd57d1..400b55e 100644 (file)
@@ -1,3 +1,27 @@
+2013-10-07  Sam Weinig  <sam@webkit.org>
+
+        CTTE: Use references in and around DragController
+        https://bugs.webkit.org/show_bug.cgi?id=122427
+
+        Reviewed by Andreas Kling.
+
+        * WebCoreSupport/WebDragClient.h:
+        * WebCoreSupport/WebDragClient.mm:
+        (WebDragClient::actionMaskForDrag):
+        (WebDragClient::willPerformDragDestinationAction):
+        (WebDragClient::willPerformDragSourceAction):
+        (WebDragClient::startDrag):
+        (WebDragClient::declareAndWriteDragImage):
+        * WebView/WebFrame.mm:
+        (-[WebFrame _replaceSelectionWithText:selectReplacement:smartReplace:]):
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _documentFragmentFromPasteboard:forType:inContext:subresources:]):
+        * WebView/WebView.mm:
+        (-[WebView draggingEntered:]):
+        (-[WebView draggingUpdated:]):
+        (-[WebView draggingExited:]):
+        (-[WebView performDragOperation:]):
+
 2013-10-05  Sam Weinig  <sam@webkit.org>
 
         CTTE: Thread references through markup.h
index a7d0e69..ffd6551 100644 (file)
 class WebDragClient : public WebCore::DragClient {
 public:
     WebDragClient(WebView*);
-    virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*) OVERRIDE;
-    virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*) OVERRIDE;
-    virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*) OVERRIDE;
+    virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData&) OVERRIDE;
+    virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard&) OVERRIDE;
+    virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData&) OVERRIDE;
     virtual void dragControllerDestroyed() OVERRIDE;
     virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) OVERRIDE;
-    virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragPos, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag) OVERRIDE;
-    virtual void declareAndWriteDragImage(const String& pasteboardName, DOMElement*, NSURL*, NSString*, WebCore::Frame*) OVERRIDE;
+    virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragPos, const WebCore::IntPoint& eventPos, WebCore::Clipboard&, WebCore::Frame&, bool linkDrag) OVERRIDE;
+    virtual void declareAndWriteDragImage(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String&, WebCore::Frame*) OVERRIDE;
 private:
     WebView* m_webView;
 };
index 6eecfec..26d5213 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(DRAG_SUPPORT)
 
+#import "DOMElementInternal.h"
 #import "WebArchive.h"
 #import "WebDOMOperations.h"
 #import "WebFrame.h"
@@ -66,14 +67,14 @@ static WebHTMLView *getTopHTMLView(Frame* frame)
     return (WebHTMLView*)[[kit(&frame->page()->mainFrame()) frameView] documentView];
 }
 
-WebCore::DragDestinationAction WebDragClient::actionMaskForDrag(WebCore::DragData* dragData)
+WebCore::DragDestinationAction WebDragClient::actionMaskForDrag(WebCore::DragData& dragData)
 {
-    return (WebCore::DragDestinationAction)[[m_webView _UIDelegateForwarder] webView:m_webView dragDestinationActionMaskForDraggingInfo:dragData->platformData()];
+    return (WebCore::DragDestinationAction)[[m_webView _UIDelegateForwarder] webView:m_webView dragDestinationActionMaskForDraggingInfo:dragData.platformData()];
 }
 
-void WebDragClient::willPerformDragDestinationAction(WebCore::DragDestinationAction action, WebCore::DragData* dragData)
+void WebDragClient::willPerformDragDestinationAction(WebCore::DragDestinationAction action, WebCore::DragData& dragData)
 {
-    [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragDestinationAction:(WebDragDestinationAction)action forDraggingInfo:dragData->platformData()];
+    [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragDestinationAction:(WebDragDestinationAction)action forDraggingInfo:dragData.platformData()];
 }
 
 
@@ -83,27 +84,23 @@ WebCore::DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntP
     return (DragSourceAction)[[m_webView _UIDelegateForwarder] webView:m_webView dragSourceActionMaskForPoint:viewPoint];
 }
 
-void WebDragClient::willPerformDragSourceAction(WebCore::DragSourceAction action, const WebCore::IntPoint& mouseDownPoint, WebCore::Clipboard* clipboard)
+void WebDragClient::willPerformDragSourceAction(WebCore::DragSourceAction action, const WebCore::IntPoint& mouseDownPoint, WebCore::Clipboard& clipboard)
 {
-    ASSERT(clipboard);
-    [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:mouseDownPoint withPasteboard:[NSPasteboard pasteboardWithName:clipboard->pasteboard().name()]];
+    [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:mouseDownPoint withPasteboard:[NSPasteboard pasteboardWithName:clipboard.pasteboard().name()]];
 }
 
-void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool linkDrag)
+void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const IntPoint& eventPos, Clipboard& clipboard, Frame& frame, bool linkDrag)
 {
-    if (!frame)
-        return;
-    ASSERT(clipboard);
-    RetainPtr<WebHTMLView> htmlView = (WebHTMLView*)[[kit(frame) frameView] documentView];
+    RetainPtr<WebHTMLView> htmlView = (WebHTMLView*)[[kit(&frame) frameView] documentView];
     if (![htmlView.get() isKindOfClass:[WebHTMLView class]])
         return;
     
-    NSEvent *event = linkDrag ? frame->eventHandler().currentNSEvent() : [htmlView.get() _mouseDownEvent];
-    WebHTMLView* topHTMLView = getTopHTMLView(frame);
+    NSEvent *event = linkDrag ? frame.eventHandler().currentNSEvent() : [htmlView.get() _mouseDownEvent];
+    WebHTMLView* topHTMLView = getTopHTMLView(&frame);
     RetainPtr<WebHTMLView> topViewProtector = topHTMLView;
     
     [topHTMLView _stopAutoscrollTimer];
-    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:clipboard->pasteboard().name()];
+    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:clipboard.pasteboard().name()];
 
     NSImage *dragNSImage = dragImage.get();
     WebHTMLView *sourceHTMLView = htmlView.get();
@@ -123,14 +120,13 @@ void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const
 #pragma clang diagnostic pop
 }
 
-void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, DOMElement* element, NSURL* URL, NSString* title, WebCore::Frame* frame) 
+void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& title, WebCore::Frame* frame)
 {
     ASSERT(pasteboardName);
-    ASSERT(element);
-    WebHTMLView *source = getTopHTMLView(frame);      
-    WebArchive *archive = [element webArchive];
+    WebHTMLView *source = getTopHTMLView(frame);
+    WebArchive *archive = [kit(&element) webArchive];
     
-    [[NSPasteboard pasteboardWithName:pasteboardName] _web_declareAndWriteDragImageForElement:element URL:URL title:title archive:archive source:source];
+    [[NSPasteboard pasteboardWithName:pasteboardName] _web_declareAndWriteDragImageForElement:kit(&element) URL:url title:title archive:archive source:source];
 }
 
 void WebDragClient::dragControllerDestroyed() 
index 9a39c29..9f30b9d 100644 (file)
@@ -998,8 +998,10 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
 }
 
 - (void)_replaceSelectionWithText:(NSString *)text selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace
-{   
-    DOMDocumentFragment* fragment = kit(createFragmentFromText(_private->coreFrame->selection().toNormalizedRange().get(), text).get());
+{
+    RefPtr<Range> range = _private->coreFrame->selection().toNormalizedRange();
+    
+    DOMDocumentFragment* fragment = range ? kit(createFragmentFromText(*range, text).get()) : nil;
     [self _replaceSelectionWithFragment:fragment selectReplacement:selectReplacement smartReplace:smartReplace matchStyle:YES];
 }
 
index ee96716..625b1ca 100644 (file)
@@ -2065,8 +2065,11 @@ static bool mouseEventIsPartOfClickOrDrag(NSEvent *event)
         [fragment appendChild:anchor];
         return fragment;
     }
-    if (pboardType == NSStringPboardType)
-        return kit(createFragmentFromText(core(context), [[pasteboard stringForType:NSStringPboardType] precomposedStringWithCanonicalMapping]).get());
+    if (pboardType == NSStringPboardType) {
+        if (!context)
+            return nil;
+        return kit(createFragmentFromText(*core(context), [[pasteboard stringForType:NSStringPboardType] precomposedStringWithCanonicalMapping]).get());
+    }
     return nil;
 }
 
index 0082903..3bb1de1 100644 (file)
@@ -4332,7 +4332,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
-    return core(self)->dragController().dragEntered(&dragData).operation;
+    return core(self)->dragController().dragEntered(dragData).operation;
 }
 
 - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)draggingInfo
@@ -4344,7 +4344,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
-    return page->dragController().dragUpdated(&dragData).operation;
+    return page->dragController().dragUpdated(dragData).operation;
 }
 
 - (void)draggingExited:(id <NSDraggingInfo>)draggingInfo
@@ -4356,7 +4356,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
-    page->dragController().dragExited(&dragData);
+    page->dragController().dragExited(dragData);
 }
 
 - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)draggingInfo
@@ -4369,7 +4369,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
-    return core(self)->dragController().performDrag(&dragData);
+    return core(self)->dragController().performDrag(dragData);
 }
 
 - (NSView *)_hitTest:(NSPoint *)point dragTypes:(NSSet *)types
index f3e633e..17056e6 100644 (file)
@@ -1,3 +1,17 @@
+2013-10-07  Sam Weinig  <sam@webkit.org>
+
+        CTTE: Use references in and around DragController
+        https://bugs.webkit.org/show_bug.cgi?id=122427
+
+        Reviewed by Andreas Kling.
+
+        * WebCoreSupport/WebDragClient.cpp:
+        (WebDragClient::actionMaskForDrag):
+        (WebDragClient::willPerformDragDestinationAction):
+        (WebDragClient::willPerformDragSourceAction):
+        (WebDragClient::startDrag):
+        * WebCoreSupport/WebDragClient.h:
+
 2013-10-04  Anders Carlsson  <andersca@apple.com>
 
         FramePolicyFunction should be an std::function
index 7255b73..071db57 100644 (file)
@@ -65,25 +65,25 @@ WebDragClient::WebDragClient(WebView* webView)
     ASSERT(webView);
 }
 
-DragDestinationAction WebDragClient::actionMaskForDrag(DragData* dragData)
+DragDestinationAction WebDragClient::actionMaskForDrag(DragData& dragData)
 {
     COMPtr<IWebUIDelegate> delegateRef = 0;
     //Default behaviour (eg. no delegate, or callback not implemented) is to allow
     //any action
     WebDragDestinationAction mask = WebDragDestinationActionAny;
     if (SUCCEEDED(m_webView->uiDelegate(&delegateRef)))
-        delegateRef->dragDestinationActionMaskForDraggingInfo(m_webView, dragData->platformData(), &mask);
+        delegateRef->dragDestinationActionMaskForDraggingInfo(m_webView, dragData.platformData(), &mask);
 
     return (DragDestinationAction)mask;
 }
 
-void WebDragClient::willPerformDragDestinationAction(DragDestinationAction action, DragData* dragData)
+void WebDragClient::willPerformDragDestinationAction(DragDestinationAction action, DragData& dragData)
 {
     //Default delegate for willPerformDragDestinationAction has no side effects
     //so we just call the delegate, and don't worry about whether it's implemented
     COMPtr<IWebUIDelegate> delegateRef = 0;
     if (SUCCEEDED(m_webView->uiDelegate(&delegateRef)))
-        delegateRef->willPerformDragDestinationAction(m_webView, (WebDragDestinationAction)action, dragData->platformData());
+        delegateRef->willPerformDragDestinationAction(m_webView, (WebDragDestinationAction)action, dragData.platformData());
 }
 
 DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& windowPoint)
@@ -96,27 +96,27 @@ DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& win
     return (DragSourceAction)action;
 }
 
-void WebDragClient::willPerformDragSourceAction(DragSourceAction action, const IntPoint& intPoint, Clipboard* clipboard)
+void WebDragClient::willPerformDragSourceAction(DragSourceAction action, const IntPoint& intPoint, Clipboard& clipboard)
 {
     COMPtr<IWebUIDelegate> uiDelegate;
     if (!SUCCEEDED(m_webView->uiDelegate(&uiDelegate)))
         return;
 
     POINT point = intPoint;
-    COMPtr<IDataObject> dataObject = clipboard->pasteboard().dataObject();
+    COMPtr<IDataObject> dataObject = clipboard.pasteboard().dataObject();
 
     COMPtr<IDataObject> newDataObject;
     HRESULT result = uiDelegate->willPerformDragSourceAction(m_webView, static_cast<WebDragSourceAction>(action), &point, dataObject.get(), &newDataObject);
     if (result == S_OK && newDataObject != dataObject)
-        const_cast<Pasteboard&>(clipboard->pasteboard()).setExternalDataObject(newDataObject.get());
+        const_cast<Pasteboard&>(clipboard.pasteboard()).setExternalDataObject(newDataObject.get());
 }
 
-void WebDragClient::startDrag(DragImageRef image, const IntPoint& imageOrigin, const IntPoint& dragPoint, Clipboard* clipboard, Frame* frame, bool isLink)
+void WebDragClient::startDrag(DragImageRef image, const IntPoint& imageOrigin, const IntPoint& dragPoint, Clipboard& clipboard, Frame& frame, bool isLink)
 {
     //FIXME: Allow UIDelegate to override behaviour <rdar://problem/5015953>
 
     //We liberally protect everything, to protect against a load occurring mid-drag
-    RefPtr<Frame> frameProtector = frame;
+    RefPtr<Frame> frameProtector = &frame;
     COMPtr<IDragSourceHelper> helper;
     COMPtr<IDataObject> dataObject;
     COMPtr<WebView> viewProtector = m_webView;
@@ -124,7 +124,7 @@ void WebDragClient::startDrag(DragImageRef image, const IntPoint& imageOrigin, c
     if (FAILED(WebDropSource::createInstance(m_webView, &source)))
         return;
 
-    dataObject = clipboard->pasteboard().dataObject();
+    dataObject = clipboard.pasteboard().dataObject();
     if (source && (image || dataObject)) {
         if (image) {
             if(SUCCEEDED(CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER,
@@ -166,7 +166,7 @@ void WebDragClient::startDrag(DragImageRef image, const IntPoint& imageOrigin, c
             else if (effect & DROPEFFECT_MOVE)
                 operation = DragOperationMove;
         }
-        frame->eventHandler().dragSourceEndedAt(generateMouseEvent(m_webView, false), operation);
+        frame.eventHandler().dragSourceEndedAt(generateMouseEvent(m_webView, false), operation);
     }
 }
 
index 303edd6..24495b0 100644 (file)
@@ -33,12 +33,14 @@ class WebView;
 class WebDragClient : public WebCore::DragClient {
 public:
     WebDragClient(WebView*);
-    virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*);
-    virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*);
     virtual void dragControllerDestroyed();
+
+    virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData&);
     virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint&);
-    virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*);
-    virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint&, const WebCore::IntPoint&, WebCore::Clipboard*, WebCore::Frame*, bool);
+    virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData&);
+    virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard&);
+    virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint&, const WebCore::IntPoint&, WebCore::Clipboard&, WebCore::Frame&, bool);
+
 private:
     WebView* m_webView;
 };
index 2344d92..6a37549 100644 (file)
@@ -5255,7 +5255,7 @@ HRESULT STDMETHODCALLTYPE WebView::DragEnter(
     ::ScreenToClient(m_viewWindow, (LPPOINT)&localpt);
     DragData data(pDataObject, IntPoint(localpt.x, localpt.y), 
         IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState));
-    *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragEntered(&data).operation);
+    *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragEntered(data).operation);
 
     m_lastDropEffect = *pdwEffect;
     m_dragData = pDataObject;
@@ -5274,7 +5274,7 @@ HRESULT STDMETHODCALLTYPE WebView::DragOver(
         ::ScreenToClient(m_viewWindow, (LPPOINT)&localpt);
         DragData data(m_dragData.get(), IntPoint(localpt.x, localpt.y), 
             IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState));
-        *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragUpdated(&data).operation);
+        *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragUpdated(data).operation);
     } else
         *pdwEffect = DROPEFFECT_NONE;
 
@@ -5290,7 +5290,7 @@ HRESULT STDMETHODCALLTYPE WebView::DragLeave()
     if (m_dragData) {
         DragData data(m_dragData.get(), IntPoint(), IntPoint(), 
             DragOperationNone);
-        m_page->dragController().dragExited(&data);
+        m_page->dragController().dragExited(data);
         m_dragData = 0;
     }
     return S_OK;
@@ -5308,7 +5308,7 @@ HRESULT STDMETHODCALLTYPE WebView::Drop(
     ::ScreenToClient(m_viewWindow, (LPPOINT)&localpt);
     DragData data(pDataObject, IntPoint(localpt.x, localpt.y), 
         IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState));
-    m_page->dragController().performDrag(&data);
+    m_page->dragController().performDrag(data);
     return S_OK;
 }
 
index 56916ff..5f56a27 100644 (file)
@@ -1,3 +1,43 @@
+2013-10-07  Sam Weinig  <sam@webkit.org>
+
+        CTTE: Use references in and around DragController
+        https://bugs.webkit.org/show_bug.cgi?id=122427
+
+        Reviewed by Andreas Kling.
+
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseDragDataReceived):
+        (webkitWebViewBaseDragMotion):
+        (dragExitedCallback):
+        (webkitWebViewBaseDragDrop):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView draggingEntered:]):
+        (-[WKView draggingUpdated:]):
+        (-[WKView draggingExited:]):
+        (-[WKView performDragOperation:]):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::dragEntered):
+        (WebKit::WebPageProxy::dragUpdated):
+        (WebKit::WebPageProxy::dragExited):
+        (WebKit::WebPageProxy::performDrag):
+        (WebKit::WebPageProxy::performDragControllerAction):
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebCoreSupport/WebDragClient.cpp:
+        (WebKit::WebDragClient::willPerformDragDestinationAction):
+        (WebKit::WebDragClient::willPerformDragSourceAction):
+        (WebKit::WebDragClient::actionMaskForDrag):
+        (WebKit::WebDragClient::dragSourceActionMaskForPoint):
+        (WebKit::WebDragClient::startDrag):
+        * WebProcess/WebCoreSupport/WebDragClient.h:
+        * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
+        (WebKit::WebDragClient::startDrag):
+        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+        (WebKit::WebDragClient::startDrag):
+        (WebKit::cachedImage):
+        (WebKit::WebDragClient::declareAndWriteDragImage):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::performDragControllerAction):
+
 2013-10-07  Tim Horton  <timothy_horton@apple.com>
 
         Animated images are not restarted when page visibility changes
index 0078d73..36d1223 100644 (file)
@@ -723,7 +723,7 @@ static void webkitWebViewBaseDragDataReceived(GtkWidget* widget, GdkDragContext*
 
     DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
     webViewBase->priv->pageProxy->resetDragOperation();
-    webViewBase->priv->pageProxy->dragEntered(&dragData);
+    webViewBase->priv->pageProxy->dragEntered(dragData);
     DragOperation operation = webViewBase->priv->pageProxy->dragSession().operation;
     gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
 }
@@ -767,13 +767,13 @@ static gboolean webkitWebViewBaseDragMotion(GtkWidget* widget, GdkDragContext* c
         return TRUE;
 
     DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
-    webViewBase->priv->pageProxy->dragUpdated(&dragData);
+    webViewBase->priv->pageProxy->dragUpdated(dragData);
     DragOperation operation = webViewBase->priv->pageProxy->dragSession().operation;
     gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
     return TRUE;
 }
 
-static void dragExitedCallback(GtkWidget* widget, DragData* dragData, bool dropHappened)
+static void dragExitedCallback(GtkWidget* widget, DragData& dragData, bool dropHappened)
 {
     // Don't call dragExited if we have just received a drag-drop signal. This
     // happens in the case of a successful drop onto the view.
@@ -801,7 +801,7 @@ static gboolean webkitWebViewBaseDragDrop(GtkWidget* widget, GdkDragContext* con
     DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
     SandboxExtension::Handle handle;
     SandboxExtension::HandleArray sandboxExtensionForUpload;
-    webViewBase->priv->pageProxy->performDrag(&dragData, String(), handle, sandboxExtensionForUpload);
+    webViewBase->priv->pageProxy->performDrag(dragData, String(), handle, sandboxExtensionForUpload);
     gtk_drag_finish(context, TRUE, FALSE, time);
     return TRUE;
 }
index 8948cae..bce4ca9 100644 (file)
@@ -1773,7 +1773,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
 
     _data->_page->resetDragOperation();
-    _data->_page->dragEntered(&dragData, [[draggingInfo draggingPasteboard] name]);
+    _data->_page->dragEntered(dragData, [[draggingInfo draggingPasteboard] name]);
     return NSDragOperationCopy;
 }
 
@@ -1782,7 +1782,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
-    _data->_page->dragUpdated(&dragData, [[draggingInfo draggingPasteboard] name]);
+    _data->_page->dragUpdated(dragData, [[draggingInfo draggingPasteboard] name]);
     
     WebCore::DragSession dragSession = _data->_page->dragSession();
     NSInteger numberOfValidItemsForDrop = dragSession.numberOfItemsToBeAccepted;
@@ -1803,7 +1803,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
     DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
-    _data->_page->dragExited(&dragData, [[draggingInfo draggingPasteboard] name]);
+    _data->_page->dragExited(dragData, [[draggingInfo draggingPasteboard] name]);
     _data->_page->resetDragOperation();
 }
 
@@ -1867,7 +1867,7 @@ static void createSandboxExtensionsForFileUpload(NSPasteboard *pasteboard, Sandb
     SandboxExtension::HandleArray sandboxExtensionForUpload;
     createSandboxExtensionsForFileUpload([draggingInfo draggingPasteboard], sandboxExtensionForUpload);
 
-    _data->_page->performDrag(&dragData, [[draggingInfo draggingPasteboard] name], sandboxExtensionHandle, sandboxExtensionForUpload);
+    _data->_page->performDrag(dragData, [[draggingInfo draggingPasteboard] name], sandboxExtensionHandle, sandboxExtensionForUpload);
 
     return YES;
 }
index e47b196..75f1037 100644 (file)
@@ -1194,40 +1194,40 @@ void WebPageProxy::commitPageTransitionViewport()
 #endif
 
 #if ENABLE(DRAG_SUPPORT)
-void WebPageProxy::dragEntered(DragData* dragData, const String& dragStorageName)
+void WebPageProxy::dragEntered(DragData& dragData, const String& dragStorageName)
 {
     SandboxExtension::Handle sandboxExtensionHandle;
     SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
     performDragControllerAction(DragControllerActionEntered, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
 }
 
-void WebPageProxy::dragUpdated(DragData* dragData, const String& dragStorageName)
+void WebPageProxy::dragUpdated(DragData& dragData, const String& dragStorageName)
 {
     SandboxExtension::Handle sandboxExtensionHandle;
     SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
     performDragControllerAction(DragControllerActionUpdated, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
 }
 
-void WebPageProxy::dragExited(DragData* dragData, const String& dragStorageName)
+void WebPageProxy::dragExited(DragData& dragData, const String& dragStorageName)
 {
     SandboxExtension::Handle sandboxExtensionHandle;
     SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
     performDragControllerAction(DragControllerActionExited, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
 }
 
-void WebPageProxy::performDrag(DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
+void WebPageProxy::performDrag(DragData& dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
 {
     performDragControllerAction(DragControllerActionPerformDrag, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionsForUpload);
 }
 
-void WebPageProxy::performDragControllerAction(DragControllerAction action, DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
+void WebPageProxy::performDragControllerAction(DragControllerAction action, DragData& dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
 {
     if (!isValid())
         return;
 #if PLATFORM(GTK)
-    m_process->send(Messages::WebPage::PerformDragControllerAction(action, *dragData), m_pageID);
+    m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData), m_pageID);
 #else
-    m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragStorageName, dragData->flags(), sandboxExtensionHandle, sandboxExtensionsForUpload), m_pageID);
+    m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData.clientPosition(), dragData.globalPosition(), dragData.draggingSourceOperationMask(), dragStorageName, dragData.flags(), sandboxExtensionHandle, sandboxExtensionsForUpload), m_pageID);
 #endif
 }
 
index 908ee39..70c98e3 100644 (file)
@@ -574,10 +574,10 @@ public:
 
 #if ENABLE(DRAG_SUPPORT)    
     // Drag and drop support.
-    void dragEntered(WebCore::DragData*, const String& dragStorageName = String());
-    void dragUpdated(WebCore::DragData*, const String& dragStorageName = String());
-    void dragExited(WebCore::DragData*, const String& dragStorageName = String());
-    void performDrag(WebCore::DragData*, const String& dragStorageName, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&);
+    void dragEntered(WebCore::DragData&, const String& dragStorageName = String());
+    void dragUpdated(WebCore::DragData&, const String& dragStorageName = String());
+    void dragExited(WebCore::DragData&, const String& dragStorageName = String());
+    void performDrag(WebCore::DragData&, const String& dragStorageName, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&);
 
     void didPerformDragControllerAction(WebCore::DragSession);
     void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation);
@@ -1015,7 +1015,7 @@ private:
 
     void clearLoadDependentCallbacks();
 
-    void performDragControllerAction(DragControllerAction, WebCore::DragData*, const String& dragStorageName, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&);
+    void performDragControllerAction(DragControllerAction, WebCore::DragData&, const String& dragStorageName, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&);
 
     void updateBackingStoreDiscardableState();
 
index 718cbb1..9330516 100644 (file)
@@ -34,7 +34,7 @@ using namespace WebCore;
 
 namespace WebKit {
 
-void WebDragClient::willPerformDragDestinationAction(DragDestinationAction action, DragData*)
+void WebDragClient::willPerformDragDestinationAction(DragDestinationAction action, DragData&)
 {
     if (action == DragDestinationActionLoad)
         m_page->willPerformLoadDragDestinationAction();
@@ -42,22 +42,22 @@ void WebDragClient::willPerformDragDestinationAction(DragDestinationAction actio
         m_page->mayPerformUploadDragDestinationAction(); // Upload can happen from a drop event handler, so we should prepare early.
 }
 
-void WebDragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*)
+void WebDragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard&)
 {
 }
 
-DragDestinationAction WebDragClient::actionMaskForDrag(DragData*)
+DragDestinationAction WebDragClient::actionMaskForDrag(DragData&)
 {
     return DragDestinationActionAny;
 }
 
-DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& /*windowPoint*/)
+DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint&)
 {
     return DragSourceActionAny;
 }
 
 #if !PLATFORM(MAC) && !PLATFORM(GTK)
-void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool)
+void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard&, Frame&, bool)
 {
 }
 #endif
index e703fd2..bacaae5 100644 (file)
@@ -42,15 +42,15 @@ public:
     }
 
 private:
-    virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*) OVERRIDE;
-    virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*) OVERRIDE;
-    virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*) OVERRIDE;
+    virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData&) OVERRIDE;
+    virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard&) OVERRIDE;
+    virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData&) OVERRIDE;
     virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) OVERRIDE;
 
-    virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag = false) OVERRIDE;
+    virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard&, WebCore::Frame&, bool linkDrag = false) OVERRIDE;
 
 #if PLATFORM(MAC)
-    virtual void declareAndWriteDragImage(const String& pasteboardName, DOMElement*, NSURL*, NSString*, WebCore::Frame*) OVERRIDE;
+    virtual void declareAndWriteDragImage(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String&, WebCore::Frame*) OVERRIDE;
 #endif
 
     virtual void dragControllerDestroyed() OVERRIDE;
index c2e108b..697dd8f 100644 (file)
@@ -56,7 +56,7 @@ static PassRefPtr<ShareableBitmap> convertCairoSurfaceToShareableBitmap(cairo_su
     return bitmap.release();
 }
 
-void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& clientPosition, const IntPoint& globalPosition, Clipboard* clipboard, Frame*, bool)
+void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& clientPosition, const IntPoint& globalPosition, Clipboard& clipboard, Frame&, bool)
 {
     RefPtr<ShareableBitmap> bitmap = convertCairoSurfaceToShareableBitmap(dragImage);
     ShareableBitmap::Handle handle;
@@ -65,8 +65,8 @@ void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& clientPosi
     if (bitmap && !bitmap->createHandle(handle))
         return;
 
-    RefPtr<DataObjectGtk> dataObject = clipboard->pasteboard().dataObject();
-    DragData dragData(dataObject.get(), clientPosition, globalPosition, clipboard->sourceOperation());
+    RefPtr<DataObjectGtk> dataObject = clipboard.pasteboard().dataObject();
+    DragData dragData(dataObject.get(), clientPosition, globalPosition, clipboard.sourceOperation());
     m_page->send(Messages::WebPageProxy::StartDrag(dragData, handle));
 }
 
index 94ccd62..a639192 100644 (file)
@@ -76,22 +76,22 @@ static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image, const In
     return bitmap.release();
 }
 
-void WebDragClient::startDrag(RetainPtr<NSImage> image, const IntPoint& point, const IntPoint&, Clipboard*, Frame* frame, bool linkDrag)
+void WebDragClient::startDrag(RetainPtr<NSImage> image, const IntPoint& point, const IntPoint&, Clipboard&, Frame& frame, bool linkDrag)
 {
     IntSize bitmapSize([image.get() size]);
-    bitmapSize.scale(frame->page()->deviceScaleFactor());
+    bitmapSize.scale(frame.page()->deviceScaleFactor());
     RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get(), bitmapSize);
     ShareableBitmap::Handle handle;
     if (!bitmap || !bitmap->createHandle(handle))
         return;
 
     // FIXME: Seems this message should be named StartDrag, not SetDragImage.
-    m_page->send(Messages::WebPageProxy::SetDragImage(frame->view()->contentsToWindow(point), handle, linkDrag));
+    m_page->send(Messages::WebPageProxy::SetDragImage(frame.view()->contentsToWindow(point), handle, linkDrag));
 }
 
-static WebCore::CachedImage* cachedImage(Element* element)
+static WebCore::CachedImage* cachedImage(Element& element)
 {
-    RenderObject* renderer = element->renderer();
+    RenderObject* renderer = element.renderer();
     if (!renderer)
         return 0;
     if (!renderer->isRenderImage())
@@ -102,29 +102,27 @@ static WebCore::CachedImage* cachedImage(Element* element)
     return image;
 }
 
-void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, DOMElement *element, NSURL *URL, NSString *title, WebCore::Frame*)
+void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& label, Frame*)
 {
-    ASSERT(element);
     ASSERT(pasteboardName == String(NSDragPboard));
 
-    Element* coreElement = core(element);
+    WebCore::CachedImage* image = cachedImage(element);
 
-    WebCore::CachedImage* image = cachedImage(coreElement);
-
-    NSString *extension = @"";
+    String extension;
     if (image) {
         extension = image->image()->filenameExtension();
-        if (![extension length])
+        if (extension.isEmpty())
             return;
     }
 
-    if (![title length]) {
-        title = [[URL path] lastPathComponent];
-        if (![title length])
-            title = [URL _web_userVisibleString];
+    String title = label;
+    if (title.isEmpty()) {
+        title = url.lastPathComponent();
+        if (title.isEmpty())
+            title = [(NSURL *)url _web_userVisibleString];
     }
 
-    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(coreElement);
+    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(&element);
 
     NSURLResponse *response = image->response().nsURLResponse();
     
@@ -146,7 +144,7 @@ void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, DOMEl
         memcpy(sharedMemoryBuffer->data(), buffer->data(), archiveSize);
         sharedMemoryBuffer->createHandle(archiveHandle, SharedMemory::ReadOnly);            
     }
-    m_page->send(Messages::WebPageProxy::SetPromisedData(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), String(extension), String(title), String([[response URL] absoluteString]), String([URL _web_userVisibleString]), archiveHandle, archiveSize));
+    m_page->send(Messages::WebPageProxy::SetPromisedData(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), extension, title, String([[response URL] absoluteString]), String([(NSURL *)url _web_userVisibleString]), archiveHandle, archiveSize));
 }
 
 } // namespace WebKit
index c50de78..30e3f66 100644 (file)
@@ -2540,19 +2540,19 @@ void WebPage::performDragControllerAction(uint64_t action, WebCore::DragData dra
 
     switch (action) {
     case DragControllerActionEntered:
-        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragEntered(&dragData)));
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragEntered(dragData)));
         break;
 
     case DragControllerActionUpdated:
-        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragUpdated(&dragData)));
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragUpdated(dragData)));
         break;
 
     case DragControllerActionExited:
-        m_page->dragController().dragExited(&dragData);
+        m_page->dragController().dragExited(dragData);
         break;
 
     case DragControllerActionPerformDrag: {
-        m_page->dragController().performDrag(&dragData);
+        m_page->dragController().performDrag(dragData);
         break;
     }
 
@@ -2575,15 +2575,15 @@ void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint cli
     DragData dragData(dragStorageName, clientPosition, globalPosition, static_cast<DragOperation>(draggingSourceOperationMask), static_cast<DragApplicationFlags>(flags));
     switch (action) {
     case DragControllerActionEntered:
-        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragEntered(&dragData)));
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragEntered(dragData)));
         break;
 
     case DragControllerActionUpdated:
-        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragUpdated(&dragData)));
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController().dragUpdated(dragData)));
         break;
         
     case DragControllerActionExited:
-        m_page->dragController().dragExited(&dragData);
+        m_page->dragController().dragExited(dragData);
         break;
         
     case DragControllerActionPerformDrag: {
@@ -2595,7 +2595,7 @@ void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint cli
                 m_pendingDropExtensionsForFileUpload.append(extension);
         }
 
-        m_page->dragController().performDrag(&dragData);
+        m_page->dragController().performDrag(dragData);
 
         // If we started loading a local file, the sandbox extension tracker would have adopted this
         // pending drop sandbox extension. If not, we'll play it safe and clear it.