CTTE: Use references in and around DragController

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: http://svn.webkit.org/repository/webkit/trunk@157058 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent af176439
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
......@@ -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)
......
......@@ -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
......
......@@ -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
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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;
......
......@@ -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();
......
......@@ -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)
......
......@@ -31,44 +31,36 @@
#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
This diff is collapsed.
......@@ -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;
......
......@@ -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) {
......
......@@ -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&)
{
}
......
......@@ -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);
}
}
......@@ -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
......
......@@ -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));
}
}
......@@ -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;
......
......@@ -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
......
......@@ -80,7 +80,7 @@ String DragData::asURL(Frame*, FilenameConversionPolicy, String*) const
return String();
}
PassRefPtr<DocumentFragment> DragData::asFragment(Frame*, PassRefPtr<Range>, bool, bool&) const