2007-01-23  Oliver Hunt  <oliver@apple.com>

        Reviewed by Adam.

        Added DragController to handled drag and drop state and control logic.
        Currently this only handles logic for Dragging and Dropping, and is 
        unable to initialise a drag itself.

        platform/DragData encapsulate the paltform Drag data (NSDraggingInfo on Mac, 
        QMimeType in Qt).  This provides methods to pull data out the drag data as a String, 
        a URL, a DocumentFragment (for rich content), or a Colour.

        * WebCore.exp:
        * WebCore.pro:
        * WebCore.xcodeproj/project.pbxproj:
        * dom/Clipboard.cpp: Added.
        (WebCore::Clipboard::setAccessPolicy):
        (WebCore::dragOpFromIEOp):
        (WebCore::IEOpFromDragOp):
        (WebCore::Clipboard::sourceOperation):
        (WebCore::Clipboard::destinationOperation):
        (WebCore::Clipboard::setSourceOperation):
        (WebCore::Clipboard::setDestinationOperation):
        (WebCore::Clipboard::setDropEffect):
        (WebCore::Clipboard::setEffectAllowed):
          move platform independent functions from ClipboardMac to Clipboard

        * dom/Clipboard.h:
        (WebCore::Clipboard::Clipboard):
        (WebCore::Clipboard::dropEffect):
        (WebCore::Clipboard::effectAllowed):
        (WebCore::Clipboard::policy):
          as above -- also removed virtual modifier from now 
          platform independent methods

        * editing/Editor.cpp:
        (WebCore::Editor::smartInsertDeleteEnabled): 
        (WebCore::Editor::shouldApplyStyle):
        * editing/Editor.h:
          adding calls through to EditorClient
         
        * page/DragActions.h: Added.
        (WebCore::):
          Replicates a number of NS* enums in the WebCore namespace

        * page/DragClient.h: Added.
        (WebCore::DragClient::~DragClient):
          Standard client interface for dragging UIDelegate

        * page/DragController.cpp: Added.
        (WebCore::createMouseEvent):
        (WebCore::DragController::DragController):
        (WebCore::DragController::~DragController):
        (WebCore::documentFragmentFromDragData):
        (WebCore::DragController::isMoveDrag):
        (WebCore::visiblePositionForPoint):
        (WebCore::DragController::cancelDrag):
        (WebCore::documentAtPoint):
        (WebCore::DragController::dragEntered):
        (WebCore::DragController::dragExited):
        (WebCore::DragController::dragUpdated):
        (WebCore::DragController::performDrag):
        (WebCore::DragController::dragEnteredOrUpdated):
        (WebCore::DragController::tryDocumentDrag):
        (WebCore::DragController::operationForLoad):
        (WebCore::DragController::concludeDrag):
        (WebCore::DragController::canProcessDrag):
        (WebCore::DragController::tryDHTMLDrag):
          Class to handle state and logic for dragging and dropping

        * page/DragController.h: Added.
        (WebCore::DragController::client):
        (WebCore::DragController::didInitiateDrag):
        (WebCore::DragController::isHandlingDrag):
        (WebCore::DragController::dragOperation):
        (WebCore::DragController::document):
        (WebCore::DragController::dragInitiator):
        (WebCore::DragController::dragDestinationAction):
        (WebCore::DragController::dragSourceAction):
        (WebCore::DragController::dragEnded):
        (WebCore::DragController::setIsHandlingDrag):
        (WebCore::DragController::setDidInitiateDrag):
        (WebCore::DragController::setDragOperation):
        (WebCore::DragController::setDragSourceAction):
        (WebCore::DragController::setDragInitiator):
          See above

        * page/Page.cpp:
        (WebCore::Page::Page):
          Update Page to have DragController

        * page/Page.h:
        (WebCore::Page::dragController):
          ditto

        * page/mac/DragControllerMac.mm: Added.
        (WebCore::DragController::isCopyKeyDown):
        (WebCore::DragController::dragOperation):
          Platform specific portions of the DragController

        * page/mac/EventHandlerMac.mm:
        (WebCore::EventHandler::handleDrag):
        (WebCore::EventHandler::dragSourceEndedAt):
          Convert from NSDragOperation to WebCore::DragOperation

        * page/mac/WebCoreFrameBridge.h:
        * page/mac/WebCoreFrameBridge.mm:
          Remove obsolete Drag functions

        * page/qt/DragControllerQt.cpp: Added.
        (WebCore::DragController::isCopyKeyDown):
        (WebCore::DragController::dragOperation):
          Basic stubs to maintain Qt  build

        * platform/DragData.cpp: Added.
        (WebCore::DragData::DragData):
        * platform/DragData.h: Added.
        (WebCore::DragData::clientPosition):
        (WebCore::DragData::globalPosition):
        (WebCore::DragData::platformData):
        (WebCore::DragData::draggingSourceOperationMask):
          DragData class to encapsulate platform drag data/event

        * platform/graphics/svg/SVGImage.cpp:
        (WebCore::SVGImage::setData):
          Addition of dummy DragClient

        * platform/graphics/svg/SVGImageEmptyClients.h:
        (WebCore::SVGEmptyDragClient::~SVGEmptyDragClient):
        (WebCore::SVGEmptyDragClient::willPerformDragDestinationAction):
        (WebCore::SVGEmptyDragClient::actionMaskForDrag):
        (WebCore::SVGEmptyDragClient::dragControllerDestroyed):
          ditto

        * platform/mac/ClipboardMac.h:
        * platform/mac/ClipboardMac.mm:
        (WebCore::ClipboardMac::ClipboardMac):
        (WebCore::ClipboardMac::clearData):
        (WebCore::ClipboardMac::clearAllData):
        (WebCore::ClipboardMac::getData):
        (WebCore::ClipboardMac::setData):
        (WebCore::ClipboardMac::types):
        (WebCore::ClipboardMac::setDragImage):
         Moving platform independent logic to Clipboard, and updating
         platform specific methods to use appropriate accessors rather than 
         directly manipulating data they no longer own

        * platform/mac/DragDataMac.mm: Added.
        (WebCore::DragData::DragData):
        (WebCore::DragData::canSmartReplace):
        (WebCore::DragData::containsColor):
        (WebCore::DragData::containsPlainText):
        (WebCore::DragData::asPlainText):
        (WebCore::DragData::asColor):
        (WebCore::DragData::createClipboard):
        (WebCore::imageExistsAtPaths):
        (WebCore::DragData::containsCompatibleContent):
        (WebCore::DragData::containsURL):
        (WebCore::DragData::asURL):
        (WebCore::DragData::asFragment):
          Mac implementations of DragData methods.  A number of these use
          a Helper class that accesses WebKit functionality.  That functionality 
          should be migrated to WebCore in the future.

        * platform/mac/PasteboardHelper.h: Added.
        (WebCore::PasteboardHelper::~PasteboardHelper):
          Temporary, and Mac only, helper class to access WebKit functionality 
          from WebCore

        * platform/qt/DragDataQt.cpp: Added.
        (WebCore::DragData::canSmartReplace):
        (WebCore::DragData::containsColor):
        (WebCore::DragData::containsPlainText):
        (WebCore::DragData::asPlainText):
        (WebCore::DragData::asColor):
        (WebCore::DragData::createClipboard):
        (WebCore::DragData::containsCompatibleContent):
        (WebCore::DragData::containsURL):
        (WebCore::DragData::asURL):
        (WebCore::DragData::asFragment):
         Basic stubs to maintain Qt build

        * rendering/HitTestResult.cpp:
        (WebCore::HitTestResult::HitTestResult):
         Correct HitTestResult copy contructor to copy localPoint


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@19039 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 29cbde4..9ba88b2 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,189 @@
+2007-01-23  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Adam.
+
+        Added DragController to handled drag and drop state and control logic.
+        Currently this only handles logic for Dragging and Dropping, and is 
+        unable to initialise a drag itself.
+
+        platform/DragData encapsulate the paltform Drag data (NSDraggingInfo on Mac, 
+        QMimeType in Qt).  This provides methods to pull data out the drag data as a String, 
+        a URL, a DocumentFragment (for rich content), or a Colour.
+
+        * WebCore.exp:
+        * WebCore.pro:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Clipboard.cpp: Added.
+        (WebCore::Clipboard::setAccessPolicy):
+        (WebCore::dragOpFromIEOp):
+        (WebCore::IEOpFromDragOp):
+        (WebCore::Clipboard::sourceOperation):
+        (WebCore::Clipboard::destinationOperation):
+        (WebCore::Clipboard::setSourceOperation):
+        (WebCore::Clipboard::setDestinationOperation):
+        (WebCore::Clipboard::setDropEffect):
+        (WebCore::Clipboard::setEffectAllowed):
+          move platform independent functions from ClipboardMac to Clipboard
+
+        * dom/Clipboard.h:
+        (WebCore::Clipboard::Clipboard):
+        (WebCore::Clipboard::dropEffect):
+        (WebCore::Clipboard::effectAllowed):
+        (WebCore::Clipboard::policy):
+          as above -- also removed virtual modifier from now 
+          platform independent methods
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::smartInsertDeleteEnabled): 
+        (WebCore::Editor::shouldApplyStyle):
+        * editing/Editor.h:
+          adding calls through to EditorClient
+         
+        * page/DragActions.h: Added.
+        (WebCore::):
+          Replicates a number of NS* enums in the WebCore namespace
+
+        * page/DragClient.h: Added.
+        (WebCore::DragClient::~DragClient):
+          Standard client interface for dragging UIDelegate
+
+        * page/DragController.cpp: Added.
+        (WebCore::createMouseEvent):
+        (WebCore::DragController::DragController):
+        (WebCore::DragController::~DragController):
+        (WebCore::documentFragmentFromDragData):
+        (WebCore::DragController::isMoveDrag):
+        (WebCore::visiblePositionForPoint):
+        (WebCore::DragController::cancelDrag):
+        (WebCore::documentAtPoint):
+        (WebCore::DragController::dragEntered):
+        (WebCore::DragController::dragExited):
+        (WebCore::DragController::dragUpdated):
+        (WebCore::DragController::performDrag):
+        (WebCore::DragController::dragEnteredOrUpdated):
+        (WebCore::DragController::tryDocumentDrag):
+        (WebCore::DragController::operationForLoad):
+        (WebCore::DragController::concludeDrag):
+        (WebCore::DragController::canProcessDrag):
+        (WebCore::DragController::tryDHTMLDrag):
+          Class to handle state and logic for dragging and dropping
+
+        * page/DragController.h: Added.
+        (WebCore::DragController::client):
+        (WebCore::DragController::didInitiateDrag):
+        (WebCore::DragController::isHandlingDrag):
+        (WebCore::DragController::dragOperation):
+        (WebCore::DragController::document):
+        (WebCore::DragController::dragInitiator):
+        (WebCore::DragController::dragDestinationAction):
+        (WebCore::DragController::dragSourceAction):
+        (WebCore::DragController::dragEnded):
+        (WebCore::DragController::setIsHandlingDrag):
+        (WebCore::DragController::setDidInitiateDrag):
+        (WebCore::DragController::setDragOperation):
+        (WebCore::DragController::setDragSourceAction):
+        (WebCore::DragController::setDragInitiator):
+          See above
+
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+          Update Page to have DragController
+
+        * page/Page.h:
+        (WebCore::Page::dragController):
+          ditto
+
+        * page/mac/DragControllerMac.mm: Added.
+        (WebCore::DragController::isCopyKeyDown):
+        (WebCore::DragController::dragOperation):
+          Platform specific portions of the DragController
+
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::EventHandler::handleDrag):
+        (WebCore::EventHandler::dragSourceEndedAt):
+          Convert from NSDragOperation to WebCore::DragOperation
+
+        * page/mac/WebCoreFrameBridge.h:
+        * page/mac/WebCoreFrameBridge.mm:
+          Remove obsolete Drag functions
+
+        * page/qt/DragControllerQt.cpp: Added.
+        (WebCore::DragController::isCopyKeyDown):
+        (WebCore::DragController::dragOperation):
+          Basic stubs to maintain Qt  build
+
+        * platform/DragData.cpp: Added.
+        (WebCore::DragData::DragData):
+        * platform/DragData.h: Added.
+        (WebCore::DragData::clientPosition):
+        (WebCore::DragData::globalPosition):
+        (WebCore::DragData::platformData):
+        (WebCore::DragData::draggingSourceOperationMask):
+          DragData class to encapsulate platform drag data/event
+
+        * platform/graphics/svg/SVGImage.cpp:
+        (WebCore::SVGImage::setData):
+          Addition of dummy DragClient
+
+        * platform/graphics/svg/SVGImageEmptyClients.h:
+        (WebCore::SVGEmptyDragClient::~SVGEmptyDragClient):
+        (WebCore::SVGEmptyDragClient::willPerformDragDestinationAction):
+        (WebCore::SVGEmptyDragClient::actionMaskForDrag):
+        (WebCore::SVGEmptyDragClient::dragControllerDestroyed):
+          ditto
+
+        * platform/mac/ClipboardMac.h:
+        * platform/mac/ClipboardMac.mm:
+        (WebCore::ClipboardMac::ClipboardMac):
+        (WebCore::ClipboardMac::clearData):
+        (WebCore::ClipboardMac::clearAllData):
+        (WebCore::ClipboardMac::getData):
+        (WebCore::ClipboardMac::setData):
+        (WebCore::ClipboardMac::types):
+        (WebCore::ClipboardMac::setDragImage):
+         Moving platform independent logic to Clipboard, and updating
+         platform specific methods to use appropriate accessors rather than 
+         directly manipulating data they no longer own
+
+        * platform/mac/DragDataMac.mm: Added.
+        (WebCore::DragData::DragData):
+        (WebCore::DragData::canSmartReplace):
+        (WebCore::DragData::containsColor):
+        (WebCore::DragData::containsPlainText):
+        (WebCore::DragData::asPlainText):
+        (WebCore::DragData::asColor):
+        (WebCore::DragData::createClipboard):
+        (WebCore::imageExistsAtPaths):
+        (WebCore::DragData::containsCompatibleContent):
+        (WebCore::DragData::containsURL):
+        (WebCore::DragData::asURL):
+        (WebCore::DragData::asFragment):
+          Mac implementations of DragData methods.  A number of these use
+          a Helper class that accesses WebKit functionality.  That functionality 
+          should be migrated to WebCore in the future.
+
+        * platform/mac/PasteboardHelper.h: Added.
+        (WebCore::PasteboardHelper::~PasteboardHelper):
+          Temporary, and Mac only, helper class to access WebKit functionality 
+          from WebCore
+
+        * platform/qt/DragDataQt.cpp: Added.
+        (WebCore::DragData::canSmartReplace):
+        (WebCore::DragData::containsColor):
+        (WebCore::DragData::containsPlainText):
+        (WebCore::DragData::asPlainText):
+        (WebCore::DragData::asColor):
+        (WebCore::DragData::createClipboard):
+        (WebCore::DragData::containsCompatibleContent):
+        (WebCore::DragData::containsURL):
+        (WebCore::DragData::asURL):
+        (WebCore::DragData::asFragment):
+         Basic stubs to maintain Qt build
+
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::HitTestResult):
+         Correct HitTestResult copy contructor to copy localPoint
+
 2007-01-22  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Maciej.
diff --git a/WebCore/WebCore.exp b/WebCore/WebCore.exp
index df9516f..8149544 100644
--- a/WebCore/WebCore.exp
+++ b/WebCore/WebCore.exp
@@ -159,6 +159,7 @@
 __ZN7WebCore11FrameLoader5clearEb
 __ZN7WebCore11FrameLoader6reloadEv
 __ZN7WebCore11FrameLoader7canLoadERKNS_4KURLERKNS_6StringERb
+__ZN7WebCore11globalPointERK8_NSPointP8NSWindow
 __ZN7WebCore11HistoryItem12addChildItemEN3WTF10PassRefPtrIS0_EE
 __ZN7WebCore11HistoryItem12setURLStringERKNS_6StringE
 __ZN7WebCore11HistoryItem12setViewStateEP11objc_object
@@ -230,6 +231,10 @@
 __ZN7WebCore14DocumentLoader7requestEv
 __ZN7WebCore14DocumentLoaderC2ERKNS_15ResourceRequestE
 __ZN7WebCore14DocumentLoaderD2Ev
+__ZN7WebCore14DragController10dragExitedEPNS_8DragDataE
+__ZN7WebCore14DragController11dragEnteredEPNS_8DragDataE
+__ZN7WebCore14DragController11dragUpdatedEPNS_8DragDataE
+__ZN7WebCore14DragController11performDragEPNS_8DragDataE
 __ZN7WebCore14ResourceHandle12releaseProxyEv
 __ZN7WebCore14ResourceLoader14cancelledErrorEv
 __ZN7WebCore15BackForwardList10removeItemEPNS_11HistoryItemE
@@ -301,7 +306,7 @@
 __ZN7WebCore4Page6goBackEv
 __ZN7WebCore4Page8goToItemEPNS_11HistoryItemENS_13FrameLoadTypeE
 __ZN7WebCore4Page9goForwardEv
-__ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientE
+__ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientEPNS_10DragClientE
 __ZN7WebCore4PageD1Ev
 __ZN7WebCore5Cache11setDisabledEb
 __ZN7WebCore5Cache13getStatisticsEv
@@ -351,6 +356,7 @@
 __ZN7WebCore8Document13removeMarkersENS_14DocumentMarker10MarkerTypeE
 __ZN7WebCore8Document14setFocusedNodeEN3WTF10PassRefPtrINS_4NodeEEE
 __ZN7WebCore8Document4bodyEv
+__ZN7WebCore8DragDataC1EP11objc_objectRKNS_8IntPointES5_NS_13DragOperationEPNS_16PasteboardHelperE
 __ZN7WebCore8FrameMac18windowScriptObjectEv
 __ZN7WebCore8FrameMac20windowScriptNPObjectEv
 __ZN7WebCore8FrameMac26dashboardRegionsDictionaryEv
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 9339213..6884e19 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -468,9 +468,11 @@
     page/PageState.cpp \
     page/ContextMenuController.cpp \
     page/EventHandler.cpp \
+    page/DragController.cpp \
     page/qt/EventHandlerQt.cpp \
     page/qt/FrameQt.cpp \
     page/qt/FrameQtClient.cpp \
+    page/qt/DragControllerQt.cpp \
     xml/XPathUtil.cpp \
     xml/XPathPredicate.cpp \
     xml/XPathVariableReference.cpp \
@@ -517,6 +519,7 @@
     loader/qt/FrameLoaderQt.cpp \
     loader/qt/DocumentLoaderQt.cpp \
     platform/CString.cpp \
+    platform/DragData.cpp \
     platform/AtomicString.cpp \
     platform/Base64.cpp \
     platform/graphics/AffineTransform.cpp \
@@ -580,6 +583,7 @@
     platform/qt/ContextMenuQt.cpp \
     platform/qt/ContextMenuItemQt.cpp \
     platform/qt/PasteboardQt.cpp \
+    platform/qt/DragDataQt.cpp \
     platform/ContextMenu.cpp \
 #    platform/SearchPopupMenu.cpp \ 
     platform/qt/SearchPopupMenuQt.cpp \ 
@@ -680,6 +684,7 @@
     ../WebKitQt/WebCoreSupport/EditorClientQt.cpp \
     ../WebKitQt/WebCoreSupport/ChromeClientQt.cpp \
     ../WebKitQt/WebCoreSupport/ContextMenuClientQt.cpp \
+    ../WebKitQt/WebCoreSupport/DragClientQt.cpp \
     ../WebKitQt/Api/qwebpage.cpp \
     ../WebKitQt/Api/qwebframe.cpp
 
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 670f805..73a6cd8 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1641,10 +1641,20 @@
 		A70023FD0B02BEAB00170215 /* MimeTypeRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70023FB0B02BEAB00170215 /* MimeTypeRegistry.cpp */; };
 		A70023FE0B02BEAB00170215 /* MimeTypeRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = A70023FC0B02BEAB00170215 /* MimeTypeRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A70024000B02BECC00170215 /* MimeTypeRegistryMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A70023FF0B02BECC00170215 /* MimeTypeRegistryMac.mm */; };
+		A718760E0B2A120100A16ECE /* DragActions.h in Headers */ = {isa = PBXBuildFile; fileRef = A718760D0B2A120100A16ECE /* DragActions.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		A71878900B2D04AC00A16ECE /* DragControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */; };
 		A7352C190B1BB89D00A986D0 /* RenderSVGBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7352C170B1BB89D00A986D0 /* RenderSVGBlock.cpp */; };
 		A7352C1A0B1BB89D00A986D0 /* RenderSVGBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = A7352C180B1BB89D00A986D0 /* RenderSVGBlock.h */; };
 		A7638A970995965D0007E14F /* SVGFEDisplacementMapElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A7638A950995965D0007E14F /* SVGFEDisplacementMapElement.h */; };
 		A7638A980995965D0007E14F /* SVGFEDisplacementMapElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7638A960995965D0007E14F /* SVGFEDisplacementMapElement.cpp */; };
+		A784941B0B5FE507001E237A /* Clipboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A784941A0B5FE507001E237A /* Clipboard.cpp */; };
+		A795463E0B5C4C80007B438F /* DragDataMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A795463D0B5C4C80007B438F /* DragDataMac.mm */; };
+		A79546430B5C4CB4007B438F /* DragData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A79546420B5C4CB4007B438F /* DragData.cpp */; };
+		A7B6E69F0B291A9600D0529F /* DragData.h in Headers */ = {isa = PBXBuildFile; fileRef = A7B6E69D0B291A9600D0529F /* DragData.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		A7CA595D0B27BD9E00FA021D /* DragController.h in Headers */ = {isa = PBXBuildFile; fileRef = A7CA595B0B27BD9E00FA021D /* DragController.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		A7CA595E0B27BD9E00FA021D /* DragController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7CA595C0B27BD9E00FA021D /* DragController.cpp */; };
+		A7CA59630B27C1F200FA021D /* DragClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A7CA59620B27C1F200FA021D /* DragClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		A7D3C5240B576B4B002CA450 /* PasteboardHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A80CEBAC0B60FC49007637C1 /* SVGMPathElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A80CEBAA0B60FC49007637C1 /* SVGMPathElement.h */; };
 		A80CEBAD0B60FC49007637C1 /* SVGMPathElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A80CEBAB0B60FC49007637C1 /* SVGMPathElement.cpp */; };
 		A80E6CE40A1989CA007FB8C5 /* CSSValueList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A80E6CBA0A1989CA007FB8C5 /* CSSValueList.cpp */; };
@@ -4627,10 +4637,20 @@
 		A70023FB0B02BEAB00170215 /* MimeTypeRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MimeTypeRegistry.cpp; sourceTree = "<group>"; };
 		A70023FC0B02BEAB00170215 /* MimeTypeRegistry.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MimeTypeRegistry.h; sourceTree = "<group>"; };
 		A70023FF0B02BECC00170215 /* MimeTypeRegistryMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = MimeTypeRegistryMac.mm; sourceTree = "<group>"; };
+		A718760D0B2A120100A16ECE /* DragActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragActions.h; sourceTree = "<group>"; };
+		A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragControllerMac.mm; sourceTree = "<group>"; };
 		A7352C170B1BB89D00A986D0 /* RenderSVGBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGBlock.cpp; sourceTree = "<group>"; };
 		A7352C180B1BB89D00A986D0 /* RenderSVGBlock.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderSVGBlock.h; sourceTree = "<group>"; };
 		A7638A950995965D0007E14F /* SVGFEDisplacementMapElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGFEDisplacementMapElement.h; sourceTree = "<group>"; };
 		A7638A960995965D0007E14F /* SVGFEDisplacementMapElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGFEDisplacementMapElement.cpp; sourceTree = "<group>"; };
+		A784941A0B5FE507001E237A /* Clipboard.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Clipboard.cpp; sourceTree = "<group>"; };
+		A795463D0B5C4C80007B438F /* DragDataMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DragDataMac.mm; sourceTree = "<group>"; };
+		A79546420B5C4CB4007B438F /* DragData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DragData.cpp; sourceTree = "<group>"; };
+		A7B6E69D0B291A9600D0529F /* DragData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragData.h; sourceTree = "<group>"; };
+		A7CA595B0B27BD9E00FA021D /* DragController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragController.h; sourceTree = "<group>"; };
+		A7CA595C0B27BD9E00FA021D /* DragController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DragController.cpp; sourceTree = "<group>"; };
+		A7CA59620B27C1F200FA021D /* DragClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragClient.h; sourceTree = "<group>"; };
+		A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PasteboardHelper.h; sourceTree = "<group>"; };
 		A80CEBAA0B60FC49007637C1 /* SVGMPathElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGMPathElement.h; sourceTree = "<group>"; };
 		A80CEBAB0B60FC49007637C1 /* SVGMPathElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGMPathElement.cpp; sourceTree = "<group>"; };
 		A80E6CBA0A1989CA007FB8C5 /* CSSValueList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSSValueList.cpp; sourceTree = "<group>"; };
@@ -6745,6 +6765,7 @@
 		6582A14809999D6C00BEEB6D /* mac */ = {
 			isa = PBXGroup;
 			children = (
+				A795463D0B5C4C80007B438F /* DragDataMac.mm */,
 				06027CB20B1CC03D00884B2D /* ContextMenuItemMac.mm */,
 				65A640F00533BB1F0085E777 /* BlockExceptions.h */,
 				65F80697054D9F86008BF776 /* BlockExceptions.mm */,
@@ -6805,6 +6826,7 @@
 				BC6DADF90A19602B00E5CD14 /* WebFontCache.mm */,
 				935C477209AC4D7700A6AAB4 /* WheelEventMac.mm */,
 				9380F47709A11ACC001FDB34 /* WidgetMac.mm */,
+				A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -6844,6 +6866,10 @@
 				93E22A720AF5E94C00D48324 /* PageState.h */,
 				65D1C1C909932B22000CB324 /* Plugin.h */,
 				F587863A02DE3A1401EA4122 /* Settings.h */,
+				A7CA595B0B27BD9E00FA021D /* DragController.h */,
+				A7CA595C0B27BD9E00FA021D /* DragController.cpp */,
+				A7CA59620B27C1F200FA021D /* DragClient.h */,
+				A718760D0B2A120100A16ECE /* DragActions.h */,
 				14C9A5E90B3D105F005A0232 /* Settings.cpp */,
 			);
 			path = page;
@@ -7854,6 +7880,7 @@
 			isa = PBXGroup;
 			children = (
 				93C09A7E0B064EEF005ABD4D /* EventHandlerMac.mm */,
+				A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */,
 				65BF023B0974819000C43196 /* FrameMac.h */,
 				65BF023C0974819000C43196 /* FrameMac.mm */,
 				654EC60F097778F500DAB52C /* WebCoreFrameBridge.h */,
@@ -8982,6 +9009,7 @@
 				F58786C202DE3B8601EA4122 /* DeprecatedValueList.h */,
 				F587853C02DE375901EA4122 /* DeprecatedValueListImpl.cpp */,
 				F587853B02DE375901EA4122 /* DeprecatedValueListImpl.h */,
+				A7B6E69D0B291A9600D0529F /* DragData.h */,
 				934FE9E40B5CA539003E4A73 /* FileChooser.cpp */,
 				066C772A0AB603B700238CC4 /* FileChooser.h */,
 				BC6D6DD009AF906600F59759 /* Font.cpp */,
@@ -9066,6 +9094,7 @@
 				9380F47109A11AB4001FDB34 /* Widget.cpp */,
 				9380F47209A11AB4001FDB34 /* Widget.h */,
 				93B780C909B3B7FE00690162 /* WidgetClient.h */,
+				A79546420B5C4CB4007B438F /* DragData.cpp */,
 			);
 			path = platform;
 			sourceTree = "<group>";
@@ -9403,6 +9432,7 @@
 		F523D32402DE4478018635CA /* dom */ = {
 			isa = PBXGroup;
 			children = (
+				A784941A0B5FE507001E237A /* Clipboard.cpp */,
 				BC3B364705C9D5E200E42902 /* AtomicStringList.h */,
 				A8C4A7FC09D563270003AC8D /* Attr.cpp */,
 				A8C4A7FB09D563270003AC8D /* Attr.h */,
@@ -9560,6 +9590,11 @@
 			isa = PBXHeadersBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				A7D3C5240B576B4B002CA450 /* PasteboardHelper.h in Headers */,
+				A718760E0B2A120100A16ECE /* DragActions.h in Headers */,
+				A7B6E69F0B291A9600D0529F /* DragData.h in Headers */,
+				A7CA595D0B27BD9E00FA021D /* DragController.h in Headers */,
+				A7CA59630B27C1F200FA021D /* DragClient.h in Headers */,
 				1A3178930B20A81600316987 /* SubresourceLoaderClient.h in Headers */,
 				93F198E608245E59001E9ABC /* HTMLElement.h in Headers */,
 				93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */,
@@ -11056,6 +11091,7 @@
 		0867D690FE84028FC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				English,
@@ -11070,6 +11106,7 @@
 			productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
 			projectDirPath = "";
 			projectRoot = "";
+			shouldCheckCompatibility = 1;
 			targets = (
 				93F198A508245E59001E9ABC /* WebCore */,
 				DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
@@ -12320,10 +12357,12 @@
 				B2310B760B1F46A200D55D87 /* CgSupport.cpp in Sources */,
 				B2310B780B1F46A300D55D87 /* RenderPathCg.cpp in Sources */,
 				B2ED97710B1F55CE00257D0F /* GraphicsContextCG.cpp in Sources */,
+				A7CA595E0B27BD9E00FA021D /* DragController.cpp in Sources */,
 				B277B4040B22F37C0004BEC6 /* GraphicsContextMac.mm in Sources */,
 				ED501DC60B249F2900AE18D9 /* EditorMac.mm in Sources */,
 				93354A3C0B24F8C9003F6DEA /* UIEventWithKeyState.cpp in Sources */,
 				E1D8E31A0B29E3B600F4BAF6 /* HTTPParsers.cpp in Sources */,
+				A71878900B2D04AC00A16ECE /* DragControllerMac.mm in Sources */,
 				BC18C5D10B2A886F0018461D /* TextBreakIteratorICU.cpp in Sources */,
 				AA4C3A760B2B1679002334A2 /* StyleElement.cpp in Sources */,
 				93E2425F0B2B509500C732A1 /* HTMLFrameOwnerElement.cpp in Sources */,
@@ -12351,6 +12390,8 @@
 				510F735F0B56C08800A3002A /* AuthenticationChallenge.cpp in Sources */,
 				510F73610B56C08800A3002A /* Credential.cpp in Sources */,
 				510F73630B56C08800A3002A /* ProtectionSpace.cpp in Sources */,
+				A795463E0B5C4C80007B438F /* DragDataMac.mm in Sources */,
+				A79546430B5C4CB4007B438F /* DragData.cpp in Sources */,
 				B2CB92420B5BD966009BAA78 /* JSSVGElementInstance.cpp in Sources */,
 				B2CB92460B5BD97B009BAA78 /* JSSVGElementInstanceList.cpp in Sources */,
 				B2CB92620B5BDA02009BAA78 /* DOMSVGElementInstance.mm in Sources */,
@@ -12358,6 +12399,7 @@
 				B2F273F20B5BFAC50068C956 /* SVGElementInstance.cpp in Sources */,
 				B2F273F30B5BFAC80068C956 /* SVGElementInstanceList.cpp in Sources */,
 				1A2A68230B5BEDE70002A480 /* ProgressTracker.cpp in Sources */,
+				A784941B0B5FE507001E237A /* Clipboard.cpp in Sources */,
 				934FE9E50B5CA539003E4A73 /* FileChooser.cpp in Sources */,
 				A80CEBAD0B60FC49007637C1 /* SVGMPathElement.cpp in Sources */,
 				E1E6EEA40B628DA8005F2F70 /* JSHTMLSelectElement.cpp in Sources */,
@@ -12406,6 +12448,7 @@
 				HEADER_SEARCH_PATHS_QUOTED_1 = "\"${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore\"";
 				INFOPLIST_FILE = Info.plist;
 				INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
+				LINKER_DISPLAYS_MANGLED_NAMES = YES;
 				OTHER_LDFLAGS = (
 					"-sub_library",
 					libobjc,
diff --git a/WebCore/dom/Clipboard.cpp b/WebCore/dom/Clipboard.cpp
new file mode 100755
index 0000000..ccc5b1c
--- /dev/null
+++ b/WebCore/dom/Clipboard.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "Clipboard.h"
+
+namespace WebCore {
+
+
+void Clipboard::setAccessPolicy(ClipboardAccessPolicy policy)
+{
+    // once you go numb, can never go back
+    ASSERT(m_policy != ClipboardNumb || policy == ClipboardNumb);
+    m_policy = policy;
+}
+
+// These "conversion" methods are called by both WebCore and WebKit, and never make sense to JS, so we don't
+// worry about security for these. They don't allow access to the pasteboard anyway.
+
+static DragOperation dragOpFromIEOp(const String& op)
+{
+    // yep, it's really just this fixed set
+    if (op == "none")
+        return DragOperationNone;
+    if (op == "copy")
+        return DragOperationCopy;
+    if (op == "link")
+        return DragOperationLink;
+    if (op == "move")
+        return DragOperationGeneric;
+    if (op == "copyLink")
+        return (DragOperation)(DragOperationCopy | DragOperationLink);
+    if (op == "copyMove")
+        return (DragOperation)(DragOperationCopy | DragOperationGeneric | DragOperationMove);
+    if (op == "linkMove")
+        return (DragOperation)(DragOperationLink | DragOperationGeneric | DragOperationMove);
+    if (op == "all")
+        return DragOperationEvery;
+    return DragOperationPrivate;  // really a marker for "no conversion"
+}
+
+static String IEOpFromDragOp(DragOperation op)
+{
+    bool moveSet = !!((DragOperationGeneric | DragOperationMove) & op);
+    
+    if ((moveSet && (op & DragOperationCopy) && (op & DragOperationLink))
+        || (op == DragOperationEvery))
+        return "all";
+    if (moveSet && (op & DragOperationCopy))
+        return "copyMove";
+    if (moveSet && (op & DragOperationLink))
+        return "linkMove";
+    if ((op & DragOperationCopy) && (op & DragOperationLink))
+        return "copyLink";
+    if (moveSet)
+        return "move";
+    if (op & DragOperationCopy)
+        return "copy";
+    if (op & DragOperationLink)
+        return "link";
+    return "none";
+}
+
+bool Clipboard::sourceOperation(DragOperation& op) const
+{
+    if (m_effectAllowed.isNull())
+        return false;
+    op = dragOpFromIEOp(m_effectAllowed);
+    return true;
+}
+
+bool Clipboard::destinationOperation(DragOperation& op) const
+{
+    if (m_dropEffect.isNull())
+        return false;
+    op = dragOpFromIEOp(m_dropEffect);
+    return true;
+}
+
+void Clipboard::setSourceOperation(DragOperation op)
+{
+    m_effectAllowed = IEOpFromDragOp(op);
+}
+
+void Clipboard::setDestinationOperation(DragOperation op)
+{
+    m_dropEffect = IEOpFromDragOp(op);
+}
+
+void Clipboard::setDropEffect(const String &effect)
+{
+    if (m_policy == ClipboardReadable || m_policy == ClipboardTypesReadable) {
+        m_dropEffect = effect;
+    }
+}
+
+void Clipboard::setEffectAllowed(const String &effect)
+{
+    if (m_policy == ClipboardWritable)
+        m_effectAllowed = effect;
+}
+
+}
diff --git a/WebCore/dom/Clipboard.h b/WebCore/dom/Clipboard.h
index 1ca3181..81125df 100644
--- a/WebCore/dom/Clipboard.h
+++ b/WebCore/dom/Clipboard.h
@@ -29,6 +29,7 @@
 #include <wtf/HashSet.h>
 #include "AtomicString.h"
 #include "ClipboardAccessPolicy.h"
+#include "DragActions.h"
 #include "Node.h"
 #include "Shared.h"
 
@@ -40,15 +41,16 @@
     // State available during IE's events for drag and drop and copy/paste
     class Clipboard : public Shared<Clipboard> {
     public:
+        Clipboard(ClipboardAccessPolicy policy) : m_policy(policy) { }
         virtual ~Clipboard() { }
 
         // Is this operation a drag-drop or a copy-paste?
         virtual bool isForDragging() const = 0;
 
-        virtual String dropEffect() const = 0;
-        virtual void setDropEffect(const String&) = 0;
-        virtual String effectAllowed() const = 0;
-        virtual void setEffectAllowed(const String&) = 0;
+        String dropEffect() const { return m_dropEffect; }
+        void setDropEffect(const String&);
+        String effectAllowed() const { return m_effectAllowed; }
+        void setEffectAllowed(const String&);
     
         virtual void clearData(const String& type) = 0;
         virtual void clearAllData() = 0;
@@ -64,7 +66,20 @@
         virtual Node* dragImageElement() = 0;
         virtual void setDragImageElement(Node*, const IntPoint&) = 0;
 
-        virtual void setAccessPolicy(ClipboardAccessPolicy) = 0;
+        void setAccessPolicy(ClipboardAccessPolicy);
+
+        bool sourceOperation(DragOperation&) const;
+        bool destinationOperation(DragOperation&) const;
+        void setSourceOperation(DragOperation);
+        void setDestinationOperation(DragOperation);
+        
+    protected:
+        ClipboardAccessPolicy policy() const { return m_policy; }
+        
+    private:
+        ClipboardAccessPolicy m_policy;
+        String m_dropEffect;
+        String m_effectAllowed;
     };
 
 } // namespace WebCore
diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp
index e5fe04c..2d65084 100644
--- a/WebCore/editing/Editor.cpp
+++ b/WebCore/editing/Editor.cpp
@@ -148,6 +148,13 @@
     return true;
 }
 
+bool Editor::smartInsertDeleteEnabled()
+{   
+    if (client())
+        return client()->smartInsertDeleteEnabled();
+    return false;
+}
+    
 bool Editor::canSmartCopyOrDelete()
 {
     if (client())
@@ -523,7 +530,12 @@
             break;
     }
 }
-
+    
+bool Editor::shouldApplyStyle(CSSStyleDeclaration* style, Range* range)
+{   
+    return client()->shouldApplyStyle(style, range);
+}
+    
 void Editor::applyParagraphStyle(CSSStyleDeclaration* style, EditAction editingAction)
 {
     switch (m_frame->selectionController()->state()) {
diff --git a/WebCore/editing/Editor.h b/WebCore/editing/Editor.h
index 41803c6..0ecffc8 100644
--- a/WebCore/editing/Editor.h
+++ b/WebCore/editing/Editor.h
@@ -90,10 +90,12 @@
     void indent();
     void outdent();
 
+    bool shouldInsertFragment(PassRefPtr<DocumentFragment> fragment, PassRefPtr<Range> replacingDOMRange, EditorInsertAction givenAction);
     bool shouldInsertText(String, Range*, EditorInsertAction) const;
     bool shouldShowDeleteInterface(HTMLElement*) const;
     bool shouldDeleteRange(Range*) const;
-
+    bool shouldApplyStyle(CSSStyleDeclaration*, Range*);
+    
     void respondToChangedSelection(const Selection& oldSelection);
     void respondToChangedContents(const Selection& endingSelection);
     
@@ -170,6 +172,8 @@
     void toggleUnderline();
     void setBaseWritingDirection(String);
 
+    bool smartInsertDeleteEnabled();
+    
 #if PLATFORM(MAC)
     NSString* userVisibleString(NSURL*);
     void setStartNewKillRingSequence(bool flag) { m_startNewKillRingSequence = flag; }
@@ -190,7 +194,6 @@
     void pasteWithPasteboard(Pasteboard*, bool allowPlainText);
     void replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment, bool selectReplacement, bool smartReplace, bool matchStyle);
     void replaceSelectionWithText(String text, bool selectReplacement, bool smartReplace);
-    bool shouldInsertFragment(PassRefPtr<DocumentFragment> fragment, PassRefPtr<Range> replacingDOMRange, EditorInsertAction givenAction);
     void writeSelectionToPasteboard(Pasteboard*);
 
 #if PLATFORM(MAC)
diff --git a/WebCore/page/DragActions.h b/WebCore/page/DragActions.h
new file mode 100644
index 0000000..11d7651
--- /dev/null
+++ b/WebCore/page/DragActions.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef DragActions_h
+#define DragActions_h
+
+namespace WebCore {
+
+    // WebCoreDragDestinationAction should be kept in sync with WebDragDestinationAction
+    typedef enum {
+        DragDestinationActionNone    = 0,
+        DragDestinationActionDHTML   = 1,
+        DragDestinationActionEdit    = 2,
+        DragDestinationActionLoad    = 4,
+        DragDestinationActionAny     = UINT_MAX
+    } DragDestinationAction;
+    
+    // WebCoreDragSourceAction should be kept in sync with WebDragSourceAction
+    typedef enum {
+        DragSourceActionNone         = 0,
+        DragSourceActionDHTML        = 1,
+        DragSourceActionImage        = 2,
+        DragSourceActionLink         = 4,
+        DragSourceActionSelection    = 8,
+        DragSourceActionAny          = UINT_MAX
+    } DragSourceAction;
+    
+    //matches NSDragOperation
+    typedef enum {
+        DragOperationNone    = 0,
+        DragOperationCopy    = 1,
+        DragOperationLink    = 2,
+        DragOperationGeneric = 4,
+        DragOperationPrivate = 8,
+        DragOperationMove    = 16,
+        DragOperationDelete  = 32,
+        DragOperationEvery   = UINT_MAX
+    } DragOperation;
+    
+}
+
+#endif // !DragActions_h
diff --git a/WebCore/page/DragClient.h b/WebCore/page/DragClient.h
new file mode 100644
index 0000000..bddd667
--- /dev/null
+++ b/WebCore/page/DragClient.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+
+#ifndef DragClient_h
+#define DragClient_h
+
+#include "DragActions.h"
+#include "IntPoint.h"
+
+namespace WebCore {
+
+    class DragData;
+    
+    class DragClient {
+    public:
+        virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*) = 0;
+        virtual DragDestinationAction actionMaskForDrag(DragData*) = 0;
+        virtual void dragControllerDestroyed() = 0;
+        virtual ~DragClient() {};
+    };
+    
+}
+
+#endif // !DragClient_h
+
diff --git a/WebCore/page/DragController.cpp b/WebCore/page/DragController.cpp
new file mode 100644
index 0000000..d9f76b3
--- /dev/null
+++ b/WebCore/page/DragController.cpp
@@ -0,0 +1,411 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "DragController.h"
+
+#include "Clipboard.h"
+#include "ClipboardAccessPolicy.h"
+#include "CSSStyleDeclaration.h"
+#include "Document.h"
+#include "DocumentFragment.h"
+#include "DragActions.h"
+#include "Editor.h"
+#include "EditorClient.h"
+#include "Element.h"
+#include "EventHandler.h"
+#include "DragClient.h"
+#include "DragData.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "FrameView.h"
+#include "HTMLAnchorElement.h"
+#include "MarkUp.h"
+#include "MoveSelectionCommand.h"
+#include "Node.h"
+#include "Page.h"
+#include "ReplaceSelectionCommand.h"
+#include "ResourceRequest.h"
+#include "SelectionController.h"
+#include "Text.h"
+#include "wtf/RefPtr.h"
+
+namespace WebCore {
+
+static PlatformMouseEvent createMouseEvent(DragData* dragData)
+{
+    // FIXME: We should fake modifier keys here.
+    return PlatformMouseEvent(dragData->clientPosition(), dragData->globalPosition(),
+                              LeftButton, 0, false, false, false, false);
+
+}
+    
+DragController::DragController(Page* page, DragClient* client)
+    : m_page(page)
+    , m_client(client)
+    , m_document(0)
+    , m_dragInitiator(0)
+    , m_dragDestinationAction(DragDestinationActionNone)
+    , m_dragSourceAction(DragSourceActionNone)
+    , m_didInitiateDrag(false)
+    , m_dragOperation(DragOperationNone)
+{
+}
+    
+DragController::~DragController()
+{   
+    m_client->dragControllerDestroyed();
+}
+    
+static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragData, RefPtr<Range> context,
+                                          bool allowPlainText, bool chosePlainText)
+{
+    ASSERT(dragData);
+    chosePlainText = false;
+
+    Document* document = context->startNode()->document();
+    ASSERT(document);
+    if (document && dragData->containsCompatibleContent()) {
+        if (DocumentFragment* fragment = dragData->asFragment(document).get())
+            return fragment;
+
+        if (dragData->containsURL()) {
+            String title;
+            String url = dragData->asURL(&title);
+            if (document && !url.isEmpty()) {
+                ExceptionCode ec;
+                RefPtr<HTMLAnchorElement> anchor = static_cast<HTMLAnchorElement*>(document->createElement("a", ec).get());
+                anchor->setHref(url);
+                RefPtr<Node> anchorText = document->createTextNode(title);
+                anchor->appendChild(anchorText, ec);
+                RefPtr<DocumentFragment> fragment = document->createDocumentFragment();
+                fragment->appendChild(anchor, ec);
+                return fragment.get();
+            }
+        }
+    }
+    if (allowPlainText && dragData->containsPlainText()) {
+        chosePlainText = true;
+        return createFragmentFromText(context.get(), dragData->asPlainText()).get();
+    }
+    
+    return 0;
+}
+
+bool DragController::dragIsMove(SelectionController* selectionController, DragData* dragData) 
+{
+    return m_document == m_dragInitiator
+        && selectionController->isContentEditable()
+        && !isCopyKeyDown();
+}
+
+static VisiblePosition visiblePositionForPoint(Frame* frame, IntPoint outerPoint)
+{
+    ASSERT(frame);
+    HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(outerPoint, true);
+    Node* node = result.innerNode();
+    if (!node)
+        return VisiblePosition();
+    RenderObject* renderer = node->renderer();
+    if (!renderer)
+        return VisiblePosition();
+    VisiblePosition visiblePos = renderer->positionForCoordinates(result.localPoint().x(), result.localPoint().y());
+    if (visiblePos.isNull())
+        visiblePos = VisiblePosition(Position(node, 0));
+    return visiblePos;
+}
+
+void DragController::cancelDrag()
+{
+    m_page->dragCaretController()->clear();
+}
+
+static Document* documentAtPoint(Frame* frame, const IntPoint& point)
+{  
+    if (!frame) 
+        return 0;
+
+    IntPoint pt = frame->view()->windowToContents(point);
+    HitTestResult result = HitTestResult(pt);
+    
+    if (frame->renderer())
+        result = frame->eventHandler()->hitTestResultAtPoint(pt, false);
+    return result.innerNode() ? result.innerNode()->document() : 0;
+}
+    
+DragOperation DragController::dragEntered(DragData* dragData) 
+{
+    return dragEnteredOrUpdated(dragData);
+}
+    
+void DragController::dragExited(DragData* dragData) 
+{   
+    ASSERT(dragData);
+    Frame* mainFrame = m_page->mainFrame();
+    
+    if (mainFrame->view()) {
+        ClipboardAccessPolicy policy = mainFrame->loader()->baseURL().isLocalFile() ? ClipboardReadable : ClipboardTypesReadable;
+        RefPtr<Clipboard> clipboard = dragData->createClipboard(policy);
+        clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
+        mainFrame->eventHandler()->cancelDragAndDrop(createMouseEvent(dragData), clipboard.get());
+        clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
+    }
+
+    cancelDrag();
+    m_document = 0;
+}
+    
+DragOperation DragController::dragUpdated(DragData* dragData) 
+{
+    return dragEnteredOrUpdated(dragData);
+}
+    
+bool DragController::performDrag(DragData* dragData)
+{   
+    ASSERT(dragData);
+    ASSERT(m_document == documentAtPoint(m_page->mainFrame(), dragData->clientPosition()));
+    if (m_isHandlingDrag) {
+        ASSERT(m_dragDestinationAction & DragDestinationActionDHTML);
+        m_client->willPerformDragDestinationAction(DragDestinationActionDHTML, dragData);
+        Frame* mainFrame = m_page->mainFrame();
+        if (mainFrame->view()) {
+            // Sending an event can result in the destruction of the view and part.
+            RefPtr<Clipboard> clipboard = dragData->createClipboard(ClipboardReadable);
+            clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
+            mainFrame->eventHandler()->performDragAndDrop(createMouseEvent(dragData), clipboard.get());
+            clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
+        }
+        m_document = 0;
+        return true;
+    } 
+    
+    if ((m_dragDestinationAction & DragDestinationActionEdit) && concludeDrag(dragData, m_dragDestinationAction)) {
+        m_document = 0;
+        return true;
+    }
+    
+    m_document = 0;
+
+    if (operationForLoad(dragData) != DragOperationNone)
+        return false;
+      
+    //FIXME: should we pass the event?
+    m_page->mainFrame()->loader()->load(ResourceRequest(dragData->asURL()));
+    return true;
+}
+    
+DragOperation DragController::dragEnteredOrUpdated(DragData* dragData)
+{
+    ASSERT(dragData);
+    IntPoint windowPoint = dragData->clientPosition();
+    Document* newDraggingDoc = documentAtPoint(m_page->mainFrame(), windowPoint);
+    if (m_document != newDraggingDoc) {
+        if (m_document)
+            cancelDrag();
+        m_document = newDraggingDoc;
+    }
+    
+    m_dragDestinationAction = m_client->actionMaskForDrag(dragData);
+    
+    DragOperation operation = DragOperationNone;
+    
+    if (m_dragDestinationAction == DragDestinationActionNone)
+        cancelDrag();
+    else {
+        operation = tryDocumentDrag(dragData, m_dragDestinationAction);
+        if (operation == DragOperationNone)
+            return operationForLoad(dragData);
+    }
+    
+    return operation;
+}
+    
+DragOperation DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction actionMask)
+{
+    ASSERT(dragData);
+    DragOperation operation = DragOperationNone;
+    if (actionMask & DragDestinationActionDHTML)
+        operation = tryDHTMLDrag(dragData);
+    m_isHandlingDrag = operation != DragOperationNone; 
+
+    FrameView *frameView = m_document->view();
+    if (!m_document || !frameView)
+        return operation;
+    
+    
+    
+    if ((actionMask & DragDestinationActionEdit) && !m_isHandlingDrag && canProcessDrag(dragData)) {
+        if (dragData->containsColor()) 
+            return DragOperationGeneric;
+        
+        IntPoint dragPos = dragData->clientPosition();
+        IntPoint point = frameView->windowToContents(dragPos);
+        Selection dragCaret(visiblePositionForPoint(m_document->frame(), point));
+        m_page->dragCaretController()->setSelection(dragCaret);
+        Element* element = m_document->elementFromPoint(point.x(), point.y());
+        ASSERT(element);
+        Frame* innerFrame = element->document()->frame();
+        ASSERT(innerFrame);
+        return dragIsMove(innerFrame->selectionController(), dragData) ? DragOperationMove : DragOperationCopy;
+    } 
+    
+    m_page->dragCaretController()->clear();
+    return operation;
+}
+    
+DragOperation DragController::operationForLoad(DragData* dragData)
+{
+    ASSERT(dragData);
+    Document* doc = documentAtPoint(m_page->mainFrame(), dragData->clientPosition());
+    if (!doc || m_didInitiateDrag || doc->isPluginDocument() || (doc->frame() && doc->frame()->editor()->clientIsEditable()))
+        return DragOperationNone;
+    return dragOperation(dragData);
+}
+
+bool DragController::concludeDrag(DragData* dragData, DragDestinationAction actionMask)
+{
+    ASSERT(dragData);
+    ASSERT(!m_isHandlingDrag);
+    
+    ASSERT(actionMask & DragDestinationActionEdit);
+    IntPoint point = m_document->view()->windowToContents(dragData->clientPosition());
+    Element* element =  m_document->elementFromPoint(point.x(), point.y());
+    ASSERT(element);
+    Frame* innerFrame = element->ownerDocument()->frame();
+    ASSERT(innerFrame);    
+
+    if (dragData->containsColor()) {
+        Color color = dragData->asColor();
+        if (!color.isValid())
+            return false;
+        if (!innerFrame)
+            return false;
+        RefPtr<Range> innerRange = innerFrame->selectionController()->toRange();
+        RefPtr<CSSStyleDeclaration> style = m_document->createCSSStyleDeclaration();
+        ExceptionCode ec;
+        style->setProperty("color", color.name(), ec);
+        if (!innerFrame->editor()->shouldApplyStyle(style.get(), innerRange.get()))
+            return false;
+        m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
+        innerFrame->editor()->applyStyle(style.get(), EditActionSetColor);
+        return true;
+    }
+
+    if (!m_page->dragController()->canProcessDrag(dragData)) {
+        m_page->dragCaretController()->clear();
+        return false;
+    }
+
+
+    RefPtr<Range> range = m_page->dragCaretController()->toRange();
+    if (dragIsMove(innerFrame->selectionController(), dragData) || m_page->dragCaretController()->isContentRichlyEditable()) { 
+        bool chosePlainText = false;
+        RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, range, true, chosePlainText);
+        if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, range, EditorInsertActionDropped))
+            return false;
+        
+        m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
+        if (dragIsMove(innerFrame->selectionController(), dragData)) {
+            bool smartMove = innerFrame->selectionGranularity() == WordGranularity 
+                          && innerFrame->editor()->smartInsertDeleteEnabled() 
+                          && dragData->canSmartReplace();
+            applyCommand(new MoveSelectionCommand(fragment, innerFrame->dragCaretController()->base(), smartMove));
+        } else {
+            innerFrame->selectionController()->setSelection(innerFrame->dragCaretController()->selection());
+            applyCommand(new ReplaceSelectionCommand(m_document, fragment, true, dragData->canSmartReplace(), chosePlainText)); 
+        }    
+    } else {
+        String text = dragData->asPlainText();
+        if (text.isEmpty() || !innerFrame->editor()->shouldInsertText(text, range.get(), EditorInsertActionDropped))
+            return false;
+        
+        m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
+        innerFrame->selectionController()->setSelection(innerFrame->dragCaretController()->selection());
+        applyCommand(new ReplaceSelectionCommand(m_document, createFragmentFromText(range.get(), text), true, false, true)); 
+    }
+
+    return true;
+}
+    
+    
+bool DragController::canProcessDrag(DragData* dragData) 
+{
+    ASSERT(dragData);
+
+    if (!dragData->containsCompatibleContent())
+        return false;
+    
+    IntPoint point = m_document->view()->windowToContents(dragData->clientPosition());
+    HitTestResult result = HitTestResult(point);
+    
+    if (!m_page->mainFrame()->renderer())
+        return false;
+
+    result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(point, true);
+    if (!result.innerNonSharedNode() || !result.innerNonSharedNode()->isContentEditable()) 
+        return false;
+    if (m_didInitiateDrag && m_document == m_dragInitiator && result.isSelected())
+        return false;
+    return true;
+}
+
+DragOperation DragController::tryDHTMLDrag(DragData* dragData)
+{   
+    ASSERT(dragData);
+    DragOperation op = DragOperationNone;
+    Frame* frame = m_page->mainFrame();
+    if (!frame->view())
+        return DragOperationNone;
+    
+    ClipboardAccessPolicy policy = frame->loader()->baseURL().isLocalFile() ? ClipboardReadable : ClipboardTypesReadable;
+    RefPtr<Clipboard> clipboard = dragData->createClipboard(policy);
+    DragOperation srcOp = dragData->draggingSourceOperationMask();
+    clipboard->setSourceOperation(srcOp);
+    
+    PlatformMouseEvent event = createMouseEvent(dragData);
+    if (frame->eventHandler()->updateDragAndDrop(event, clipboard.get())) {
+        // *op unchanged if no source op was set
+        if (!clipboard->destinationOperation(op)) {
+            // The element accepted but they didn't pick an operation, so we pick one for them
+            // (as does WinIE).
+            if (srcOp & DragOperationCopy)
+                op = DragOperationCopy;
+            else if (srcOp & DragOperationMove || srcOp & DragOperationGeneric)
+                op = DragOperationMove;
+            else if (srcOp & DragOperationLink)
+                op = DragOperationLink;
+            else
+                op = DragOperationGeneric;
+        } else if (!(op & srcOp)) {
+            op = DragOperationNone;
+        }
+
+        clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
+        return op;
+    }
+    return op;
+}
+
+}
diff --git a/WebCore/page/DragController.h b/WebCore/page/DragController.h
new file mode 100644
index 0000000..3e5a138
--- /dev/null
+++ b/WebCore/page/DragController.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef DragController_h
+#define DragController_h
+
+#include "DragActions.h"
+
+namespace WebCore {
+
+    class Clipboard;
+    class Document;
+    class DragClient;
+    class DragData;
+    class SelectionController;
+    class Page;
+    
+    class DragController {
+    public:
+        DragController(Page*, DragClient*);
+        ~DragController();
+        DragClient* client() const { return m_client; }
+
+        DragOperation dragEntered(DragData*);
+        void dragExited(DragData*);
+        DragOperation dragUpdated(DragData*);
+        bool performDrag(DragData*);
+        
+        //FIXME: It should be possible to remove a number of these accessors once all
+        //drag logic is in WebCore
+        void setDidInitiateDrag(bool initiated) { m_didInitiateDrag = initiated; } 
+        bool didInitiateDrag() const { return m_didInitiateDrag; }
+        void setIsHandlingDrag(bool handling) { m_isHandlingDrag = handling; }
+        bool isHandlingDrag() const { return m_isHandlingDrag; }
+        void setDragOperation(DragOperation dragOp) { m_dragOperation = dragOp; }
+        DragOperation dragOperation() const { return m_dragOperation; }        
+        void setDragInitiator(Document* initiator) { m_dragInitiator = initiator; m_didInitiateDrag = true; }
+        Document* dragInitiator() const { return m_dragInitiator; }
+        void setDragSourceAction(DragSourceAction action) { m_dragSourceAction = action; }
+        DragSourceAction dragSourceAction() const { return m_dragSourceAction; }
+        
+        Document* document() const { return m_document; }
+        DragDestinationAction dragDestinationAction() const { return m_dragDestinationAction; }
+        
+        void dragEnded() { m_dragInitiator = 0; m_didInitiateDrag = false; }
+        
+    private:
+        bool canProcessDrag(DragData*);
+        bool concludeDrag(DragData*, DragDestinationAction);
+        DragOperation dragEnteredOrUpdated(DragData*);
+        DragOperation operationForLoad(DragData*);
+        DragOperation tryDocumentDrag(DragData*, DragDestinationAction);
+        DragOperation tryDHTMLDrag(DragData*);
+        DragOperation dragOperation(DragData*);
+        void cancelDrag();
+        bool dragIsMove(SelectionController*, DragData*);
+        bool isCopyKeyDown();
+        
+        Page* m_page;
+        DragClient* m_client;
+        
+        //The Document the mouse was last dragged over
+        Document* m_document;
+        
+        //The Document (if any) that initiated the drag
+        Document* m_dragInitiator;
+        
+        DragDestinationAction m_dragDestinationAction;
+        DragSourceAction m_dragSourceAction;
+        bool m_didInitiateDrag;
+        bool m_isHandlingDrag;
+        DragOperation m_dragOperation;
+    };
+
+}
+
+#endif
diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp
index 4857ede..452af4e 100644
--- a/WebCore/page/Page.cpp
+++ b/WebCore/page/Page.cpp
@@ -26,6 +26,7 @@
 #include "ContextMenuClient.h"
 #include "ContextMenuController.h"
 #include "EditorClient.h"
+#include "DragController.h"
 #include "FocusController.h"
 #include "Frame.h"
 #include "FrameLoader.h"
@@ -49,9 +50,10 @@
 static HashSet<Page*>* allPages;
 static HashMap<String, HashSet<Page*>*>* frameNamespaces;
 
-Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient)
+Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient, DragClient* dragClient)
     : m_chrome(new Chrome(this, chromeClient))
     , m_dragCaretController(new SelectionController(0, true))
+    , m_dragController(new DragController(this, dragClient))
     , m_focusController(new FocusController(this))
     , m_contextMenuController(new ContextMenuController(this, contextMenuClient))
     , m_backForwardList(new BackForwardList)
diff --git a/WebCore/page/Page.h b/WebCore/page/Page.h
index dd6dcd3..07d6c26 100644
--- a/WebCore/page/Page.h
+++ b/WebCore/page/Page.h
@@ -39,6 +39,8 @@
     class ChromeClient;
     class ContextMenuClient;
     class ContextMenuController;
+    class DragClient;
+    class DragController;
     class EditorClient;
     class FocusController;
     class Frame;
@@ -49,7 +51,7 @@
 
     class Page : Noncopyable {
     public:
-        Page(ChromeClient*, ContextMenuClient*, EditorClient*);
+        Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*);
         ~Page();
         
         EditorClient* editorClient() const { return m_editorClient; }
@@ -82,6 +84,7 @@
 
         Chrome* chrome() const { return m_chrome.get(); }
         SelectionController* dragCaretController() const { return m_dragCaretController.get(); }
+        DragController* dragController() const { return m_dragController.get(); }
         FocusController* focusController() const { return m_focusController.get(); }
         ContextMenuController* contextMenuController() const { return m_contextMenuController.get(); }
         Settings* settings() const { return m_settings.get(); }
@@ -99,6 +102,7 @@
     private:
         OwnPtr<Chrome> m_chrome;
         OwnPtr<SelectionController> m_dragCaretController;
+        OwnPtr<DragController> m_dragController;
         OwnPtr<FocusController> m_focusController;
         OwnPtr<ContextMenuController> m_contextMenuController;
         RefPtr<BackForwardList> m_backForwardList;
diff --git a/WebCore/page/mac/DragControllerMac.mm b/WebCore/page/mac/DragControllerMac.mm
new file mode 100644
index 0000000..d6e0205
--- /dev/null
+++ b/WebCore/page/mac/DragControllerMac.mm
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+#import "DragController.h"
+
+#import "DragData.h"
+#import "Frame.h"
+#import "FrameView.h"
+#import "Page.h"
+
+namespace WebCore {
+
+bool DragController::isCopyKeyDown()
+{
+    return [[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask;
+}
+    
+DragOperation DragController::dragOperation(DragData* dragData)
+{
+    ASSERT(dragData);
+    if (![NSApp modalWindow] 
+        && ![[m_page->mainFrame()->view()->getOuterView() window] attachedSheet] 
+        && [dragData->platformData() draggingSource] != m_page->mainFrame()->view()->getOuterView() 
+        && dragData->containsURL())
+        return DragOperationCopy;
+        
+    return DragOperationNone;
+} 
+
+}
diff --git a/WebCore/page/mac/EventHandlerMac.mm b/WebCore/page/mac/EventHandlerMac.mm
index 76c6909..0922714 100644
--- a/WebCore/page/mac/EventHandlerMac.mm
+++ b/WebCore/page/mac/EventHandlerMac.mm
@@ -472,7 +472,7 @@
 
                 NSImage *dragImage = nil;       // we use these values if WC is out of the loop
                 NSPoint dragLoc = NSZeroPoint;
-                NSDragOperation srcOp = NSDragOperationNone;                
+                DragOperation srcOp = DragOperationNone;                
                 BOOL wcWrotePasteboard = NO;
                 if (dragState().m_dragSrcMayBeDHTML) {
                     NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
@@ -857,7 +857,7 @@
 void EventHandler::dragSourceEndedAt(const PlatformMouseEvent& event, NSDragOperation operation)
 {
     if (dragState().m_dragSrc && dragState().m_dragSrcMayBeDHTML) {
-        dragState().m_dragClipboard->setDestinationOperation(operation);
+        dragState().m_dragClipboard->setDestinationOperation((DragOperation)operation);
         // for now we don't care if event handler cancels default behavior, since there is none
         dispatchDragSrcEvent(dragendEvent, event);
     }
diff --git a/WebCore/page/mac/WebCoreFrameBridge.h b/WebCore/page/mac/WebCoreFrameBridge.h
index f9a579c..be1c122 100644
--- a/WebCore/page/mac/WebCoreFrameBridge.h
+++ b/WebCore/page/mac/WebCoreFrameBridge.h
@@ -242,9 +242,6 @@
 - (void)setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebCore::EditAction)undoAction;
 - (NSCellStateValue)selectionHasStyle:(DOMCSSStyleDeclaration *)style;
 
-- (NSDragOperation)dragOperationForDraggingInfo:(id <NSDraggingInfo>)info;
-- (void)dragExitedWithDraggingInfo:(id <NSDraggingInfo>)info;
-- (BOOL)concludeDragForDraggingInfo:(id <NSDraggingInfo>)info;
 - (void)dragSourceMovedTo:(NSPoint)windowLoc;
 - (void)dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation;
 
diff --git a/WebCore/page/mac/WebCoreFrameBridge.mm b/WebCore/page/mac/WebCoreFrameBridge.mm
index 0f4f521..651bf84 100644
--- a/WebCore/page/mac/WebCoreFrameBridge.mm
+++ b/WebCore/page/mac/WebCoreFrameBridge.mm
@@ -1327,83 +1327,6 @@
     return m_frame ? m_frame->baseWritingDirectionForSelectionStart() : (NSWritingDirection)NSWritingDirectionLeftToRight;
 }
 
-static PlatformMouseEvent createMouseEventFromDraggingInfo(NSWindow* window, id <NSDraggingInfo> info)
-{
-    // FIXME: Fake modifier keys here.
-    // [info draggingLocation] is in window coords
-    return PlatformMouseEvent(IntPoint([info draggingLocation]), globalPoint([info draggingLocation], window),
-        LeftButton, 0, false, false, false, false);
-}
-
-- (NSDragOperation)dragOperationForDraggingInfo:(id <NSDraggingInfo>)info
-{
-    NSDragOperation op = NSDragOperationNone;
-    if (m_frame) {
-        RefPtr<FrameView> v = m_frame->view();
-        if (v) {
-            ClipboardAccessPolicy policy = m_frame->loader()->baseURL().isLocalFile() ? ClipboardReadable : ClipboardTypesReadable;
-            RefPtr<ClipboardMac> clipboard = new ClipboardMac(true, [info draggingPasteboard], policy);
-            NSDragOperation srcOp = [info draggingSourceOperationMask];
-            clipboard->setSourceOperation(srcOp);
-
-            PlatformMouseEvent event = createMouseEventFromDraggingInfo([self window], info);
-            if (m_frame->eventHandler()->updateDragAndDrop(event, clipboard.get())) {
-                // *op unchanged if no source op was set
-                if (!clipboard->destinationOperation(op)) {
-                    // The element accepted but they didn't pick an operation, so we pick one for them
-                    // (as does WinIE).
-                    if (srcOp & NSDragOperationCopy)
-                        op = NSDragOperationCopy;
-                    else if (srcOp & NSDragOperationMove || srcOp & NSDragOperationGeneric)
-                        op = NSDragOperationMove;
-                    else if (srcOp & NSDragOperationLink)
-                        op = NSDragOperationLink;
-                    else
-                        op = NSDragOperationGeneric;
-                } else if (!(op & srcOp)) {
-                    // make sure WC picked an op that was offered.  Cocoa doesn't seem to enforce this,
-                    // but IE does.
-                    op = NSDragOperationNone;
-                }
-            }
-            clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
-            return op;
-        }
-    }
-    return op;
-}
-
-- (void)dragExitedWithDraggingInfo:(id <NSDraggingInfo>)info
-{
-    if (m_frame) {
-        RefPtr<FrameView> v = m_frame->view();
-        if (v) {
-            // Sending an event can result in the destruction of the view and part.
-            ClipboardAccessPolicy policy = m_frame->loader()->baseURL().isLocalFile() ? ClipboardReadable : ClipboardTypesReadable;
-            RefPtr<ClipboardMac> clipboard = new ClipboardMac(true, [info draggingPasteboard], policy);
-            clipboard->setSourceOperation([info draggingSourceOperationMask]);            
-            m_frame->eventHandler()->cancelDragAndDrop(createMouseEventFromDraggingInfo([self window], info), clipboard.get());
-            clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
-        }
-    }
-}
-
-- (BOOL)concludeDragForDraggingInfo:(id <NSDraggingInfo>)info
-{
-    if (m_frame) {
-        RefPtr<FrameView> v = m_frame->view();
-        if (v) {
-            // Sending an event can result in the destruction of the view and part.
-            RefPtr<ClipboardMac> clipboard = new ClipboardMac(true, [info draggingPasteboard], ClipboardReadable);
-            clipboard->setSourceOperation([info draggingSourceOperationMask]);
-            BOOL result = m_frame->eventHandler()->performDragAndDrop(createMouseEventFromDraggingInfo([self window], info), clipboard.get());
-            clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
-            return result;
-        }
-    }
-    return NO;
-}
-
 - (void)dragSourceMovedTo:(NSPoint)windowLoc
 {
     if (m_frame) {
diff --git a/WebCore/page/qt/DragControllerQt.cpp b/WebCore/page/qt/DragControllerQt.cpp
new file mode 100644
index 0000000..29a4e6a
--- /dev/null
+++ b/WebCore/page/qt/DragControllerQt.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "DragController.h"
+
+#include "DragData.h"
+#include "Frame.h"
+#include "FrameView.h"
+#include "Page.h"
+
+namespace WebCore
+{
+
+bool DragController::isCopyKeyDown()
+{
+    return false;
+}
+    
+DragOperation DragController::dragOperation(DragData* dragData)
+{
+    //FIXME: This logic is incomplete
+    if (dragData->containsURL())
+        return DragOperationCopy;
+        
+    return DragOperationNone;
+} 
+
+}
diff --git a/WebCore/platform/DragData.cpp b/WebCore/platform/DragData.cpp
new file mode 100644
index 0000000..bf2275a
--- /dev/null
+++ b/WebCore/platform/DragData.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "DragData.h"
+
+namespace WebCore {
+
+#if !PLATFORM(MAC)
+DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, 
+    DragOperation sourceOperationMask)
+    : m_clientPosition(clientPosition)
+    , m_globalPosition(globalPosition)
+    , m_platformDragData(data)
+    , m_draggingSourceOperationMask(sourceOperationMask)
+{  
+}
+#endif
+
+}
diff --git a/WebCore/platform/DragData.h b/WebCore/platform/DragData.h
new file mode 100644
index 0000000..2ebc448
--- /dev/null
+++ b/WebCore/platform/DragData.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef DragData_h
+#define DragData_h
+
+#include "ClipboardAccessPolicy.h"
+#include "Color.h"
+#include "DragActions.h"
+#include "IntPoint.h"
+
+#include <wtf/Forward.h>
+
+#if PLATFORM(MAC)
+#ifdef __OBJC__ 
+#import <Foundation/Foundation.h>
+#import <AppKit/NSDragging.h>
+typedef id <NSDraggingInfo> DragDataRef;
+#else
+typedef void* DragDataRef;
+#endif
+#elif PLATFORM(QT)
+typedef class QMimeData* DragDataRef;
+#elif PLATFORM(WIN)
+typedef struct IDataObject* DragDataRef;
+#endif
+
+
+namespace WebCore {
+    
+    class Clipboard;
+    class Document;
+    class DocumentFragment;
+    class KURL;
+    
+#if PLATFORM(MAC)
+    class PasteboardHelper;
+#endif
+
+    
+    class DragData {
+    public:
+#if PLATFORM(MAC)
+        //FIXME: In the future the WebKit functions provided by the helper class should be moved into WebCore, 
+        //after which this constructor should be removed
+        DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition,
+                 DragOperation operation, PasteboardHelper*);
+#else
+        //clientPosition is taken to be the position of the drag event within the target window, with (0,0) at the top left
+        DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation operation);
+#endif
+        const IntPoint& clientPosition() const { return m_clientPosition; }
+        const IntPoint& globalPosition() const { return m_globalPosition; }
+        DragDataRef platformData() const { return m_platformDragData; }
+        DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; }
+        Clipboard* createClipboard(ClipboardAccessPolicy) const;
+        bool containsURL() const;
+        bool containsPlainText() const;
+        bool containsCompatibleContent() const;
+        String asURL(String* title = 0) const;
+        String asPlainText() const;
+        Color asColor() const;
+        PassRefPtr<DocumentFragment> asFragment(Document*) const;
+        bool canSmartReplace() const;
+        bool containsColor() const;
+        
+    private:
+        IntPoint m_clientPosition;
+        IntPoint m_globalPosition;
+        DragDataRef m_platformDragData;
+        DragOperation m_draggingSourceOperationMask;
+#if PLATFORM(MAC)
+        PasteboardHelper* m_pasteboardHelper;
+#endif
+};
+    
+} //namespace WebCore
+
+#endif //!DragData_h
+
diff --git a/WebCore/platform/graphics/svg/SVGImage.cpp b/WebCore/platform/graphics/svg/SVGImage.cpp
index ddfe985..99d3eb4 100644
--- a/WebCore/platform/graphics/svg/SVGImage.cpp
+++ b/WebCore/platform/graphics/svg/SVGImage.cpp
@@ -125,11 +125,12 @@
         static FrameLoaderClient* dummyFrameLoaderClient =  new SVGEmptyFrameLoaderClient;
         static EditorClient* dummyEditorClient = new SVGEmptyEditorClient;
         static ContextMenuClient* dummyContextMenuClient = new SVGEmptyContextMenuClient;
+        static DragClient* dummyDragClient = new SVGEmptyDragClient;
         static Settings* dummySettings = new Settings;
 
         // FIXME: If this SVG ends up loading itself, we'll leak this Frame (and associated DOM & render trees).
         // The Cache code does not know about CachedImages holding Frames and won't know to break the cycle.
-        m_page.set(new Page(dummyChromeClient, dummyContextMenuClient, dummyEditorClient));
+        m_page.set(new Page(dummyChromeClient, dummyContextMenuClient, dummyEditorClient, dummyDragClient));
         m_frame = new FrameMac(m_page.get(), 0, dummyFrameLoaderClient);
         m_frameView = new FrameView(m_frame.get());
         m_frameView->deref(); // FIXME: FrameView starts with a refcount of 1
diff --git a/WebCore/platform/graphics/svg/SVGImageEmptyClients.h b/WebCore/platform/graphics/svg/SVGImageEmptyClients.h
index 228c738..656e196 100644
--- a/WebCore/platform/graphics/svg/SVGImageEmptyClients.h
+++ b/WebCore/platform/graphics/svg/SVGImageEmptyClients.h
@@ -30,6 +30,7 @@
 
 #include "ChromeClient.h"
 #include "ContextMenuClient.h"
+#include "DragClient.h"
 #include "EditorClient.h"
 #include "FocusDirection.h"
 #include "FrameLoaderClient.h"
@@ -352,6 +353,14 @@
 #endif
 };
 
+class SVGEmptyDragClient : public DragClient {
+public:
+    virtual ~SVGEmptyDragClient() {}
+    virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*) { }
+    virtual DragDestinationAction actionMaskForDrag(DragData*) { return DragDestinationActionNone; }
+    virtual void dragControllerDestroyed() { }
+};
+    
 }
 
 #endif // SVG_SUPPORT
diff --git a/WebCore/platform/mac/ClipboardMac.h b/WebCore/platform/mac/ClipboardMac.h
index 8b6483d..6c3703b 100644
--- a/WebCore/platform/mac/ClipboardMac.h
+++ b/WebCore/platform/mac/ClipboardMac.h
@@ -32,6 +32,7 @@
 #include "Clipboard.h"
 #include "ClipboardAccessPolicy.h"
 #include "CachedResourceClient.h"
+#include "RetainPtr.h"
 
 #ifdef __OBJC__
 @class NSImage;
@@ -53,11 +54,6 @@
 
     bool isForDragging() const;
     
-    String dropEffect() const;
-    void setDropEffect(const String&);
-    String effectAllowed() const;
-    void setEffectAllowed(const String&);
-    
     void clearData(const String& type);
     void clearAllData();
     String getData(const String& type, bool& success) const;
@@ -74,25 +70,17 @@
 
     // Methods for getting info in Cocoa's type system
     NSImage *dragNSImage(NSPoint&); // loc converted from dragLoc, based on whole image size
-    bool sourceOperation(NSDragOperation&) const;
-    bool destinationOperation(NSDragOperation&) const;
-    void setSourceOperation(NSDragOperation);
-    void setDestinationOperation(NSDragOperation);
 
-    void setAccessPolicy(ClipboardAccessPolicy);
     void setDragHasStarted() { m_dragStarted = true; }
     
 private:
     void setDragImage(CachedImage*, Node*, const IntPoint&);
 
-    NSPasteboard *m_pasteboard;
+    RetainPtr<NSPasteboard> m_pasteboard;
     bool m_forDragging;
-    String m_dropEffect;
-    String m_effectAllowed;
     IntPoint m_dragLoc;
     CachedImage* m_dragImage;
     RefPtr<Node> m_dragImageElement;
-    ClipboardAccessPolicy m_policy;
     int m_changeCount;
     bool m_dragStarted;
     FrameMac* m_frame; // used on the source side to generate dragging images
diff --git a/WebCore/platform/mac/ClipboardMac.mm b/WebCore/platform/mac/ClipboardMac.mm
index 6b0fac6..6b5d780 100644
--- a/WebCore/platform/mac/ClipboardMac.mm
+++ b/WebCore/platform/mac/ClipboardMac.mm
@@ -37,19 +37,18 @@
 namespace WebCore {
 
 ClipboardMac::ClipboardMac(bool forDragging, NSPasteboard *pasteboard, ClipboardAccessPolicy policy, FrameMac *frame)
-    : m_pasteboard(HardRetain(pasteboard))
+    : Clipboard(policy)
+    , m_pasteboard(pasteboard)
     , m_forDragging(forDragging)
     , m_dragImage(0)
-    , m_policy(policy)
     , m_dragStarted(false)
     , m_frame(frame)
 {
-    m_changeCount = [m_pasteboard changeCount];
+    m_changeCount = [m_pasteboard.get() changeCount];
 }
 
 ClipboardMac::~ClipboardMac()
 {
-    HardRelease(m_pasteboard);
 }
 
 bool ClipboardMac::isForDragging() const
@@ -57,13 +56,6 @@
     return m_forDragging;
 }
 
-void ClipboardMac::setAccessPolicy(ClipboardAccessPolicy policy)
-{
-    // once you go numb, can never go back
-    ASSERT(m_policy != ClipboardNumb || policy == ClipboardNumb);
-    m_policy = policy;
-}
-
 static NSString *cocoaTypeFromMIMEType(const String& type)
 {
     String qType = type.stripWhiteSpace();
@@ -121,36 +113,36 @@
 
 void ClipboardMac::clearData(const String& type)
 {
-    if (m_policy != ClipboardWritable)
+    if (policy() != ClipboardWritable)
         return;
 
     // note NSPasteboard enforces changeCount itself on writing - can't write if not the owner
 
     NSString *cocoaType = cocoaTypeFromMIMEType(type);
     if (cocoaType) {
-        [m_pasteboard setString:@"" forType:cocoaType];
+        [m_pasteboard.get() setString:@"" forType:cocoaType];
     }
 }
 
 void ClipboardMac::clearAllData()
 {
-    if (m_policy != ClipboardWritable)
+    if (policy() != ClipboardWritable)
         return;
 
     // note NSPasteboard enforces changeCount itself on writing - can't write if not the owner
 
-    [m_pasteboard declareTypes:[NSArray array] owner:nil];
+    [m_pasteboard.get() declareTypes:[NSArray array] owner:nil];
 }
 
 String ClipboardMac::getData(const String& type, bool& success) const
 {
     success = false;
-    if (m_policy != ClipboardReadable)
+    if (policy() != ClipboardReadable)
         return String();
     
     NSString *cocoaType = cocoaTypeFromMIMEType(type);
     NSString *cocoaValue = nil;
-    NSArray *availableTypes = [m_pasteboard types];
+    NSArray *availableTypes = [m_pasteboard.get() types];
 
     // Fetch the data in different ways for the different Cocoa types
 
@@ -158,7 +150,7 @@
         // When both URL and filenames are present, filenames is superior since it can contain a list.
         // must check this or we get a printf from CF when there's no data of this type
         if ([availableTypes containsObject:NSFilenamesPboardType]) {
-            NSArray *fileList = [m_pasteboard propertyListForType:NSFilenamesPboardType];
+            NSArray *fileList = [m_pasteboard.get() propertyListForType:NSFilenamesPboardType];
             if (fileList && [fileList isKindOfClass:[NSArray class]]) {
                 unsigned count = [fileList count];
                 if (count > 0) {
@@ -184,19 +176,19 @@
         if (!cocoaValue) {
             // must check this or we get a printf from CF when there's no data of this type
             if ([availableTypes containsObject:NSURLPboardType]) {
-                NSURL *url = [NSURL URLFromPasteboard:m_pasteboard];
+                NSURL *url = [NSURL URLFromPasteboard:m_pasteboard.get()];
                 if (url) {
                     cocoaValue = [url absoluteString];
                 }
             }
         }
     } else if (cocoaType) {        
-        cocoaValue = [m_pasteboard stringForType:cocoaType];
+        cocoaValue = [m_pasteboard.get() stringForType:cocoaType];
     }
 
     // Enforce changeCount ourselves for security.  We check after reading instead of before to be
     // sure it doesn't change between our testing the change count and accessing the data.
-    if (cocoaValue && m_changeCount == [m_pasteboard changeCount]) {
+    if (cocoaValue && m_changeCount == [m_pasteboard.get() changeCount]) {
         success = true;
         return String(DeprecatedString::fromNSString(cocoaValue));
     }
@@ -206,7 +198,7 @@
 
 bool ClipboardMac::setData(const String &type, const String &data)
 {
-    if (m_policy != ClipboardWritable)
+    if (policy() != ClipboardWritable)
         return false;
     // note NSPasteboard enforces changeCount itself on writing - can't write if not the owner
 
@@ -214,14 +206,14 @@
     NSString *cocoaData = data;
 
     if ([cocoaType isEqualToString:NSURLPboardType]) {
-        [m_pasteboard addTypes:[NSArray arrayWithObject:NSURLPboardType] owner:nil];
+        [m_pasteboard.get() addTypes:[NSArray arrayWithObject:NSURLPboardType] owner:nil];
         NSURL *url = [[NSURL alloc] initWithString:cocoaData];
-        [url writeToPasteboard:m_pasteboard];
+        [url writeToPasteboard:m_pasteboard.get()];
 
         if ([url isFileURL]) {
-            [m_pasteboard addTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil];
+            [m_pasteboard.get() addTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil];
             NSArray *fileList = [NSArray arrayWithObject:[url path]];
-            [m_pasteboard setPropertyList:fileList forType:NSFilenamesPboardType];
+            [m_pasteboard.get() setPropertyList:fileList forType:NSFilenamesPboardType];
         }
 
         [url release];
@@ -230,8 +222,8 @@
 
     if (cocoaType) {
         // everything else we know of goes on the pboard as a string
-        [m_pasteboard addTypes:[NSArray arrayWithObject:cocoaType] owner:nil];
-        return [m_pasteboard setString:cocoaData forType:cocoaType];
+        [m_pasteboard.get() addTypes:[NSArray arrayWithObject:cocoaType] owner:nil];
+        return [m_pasteboard.get() setString:cocoaData forType:cocoaType];
     }
 
     return false;
@@ -239,14 +231,14 @@
 
 HashSet<String> ClipboardMac::types() const
 {
-    if (m_policy != ClipboardReadable && m_policy != ClipboardTypesReadable)
+    if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
         return HashSet<String>();
 
-    NSArray *types = [m_pasteboard types];
+    NSArray *types = [m_pasteboard.get() types];
 
     // Enforce changeCount ourselves for security.  We check after reading instead of before to be
     // sure it doesn't change between our testing the change count and accessing the data.
-    if (m_changeCount != [m_pasteboard changeCount])
+    if (m_changeCount != [m_pasteboard.get() changeCount])
         return HashSet<String>();
 
     HashSet<String> result;
@@ -295,7 +287,7 @@
 
 void ClipboardMac::setDragImage(CachedImage* image, Node *node, const IntPoint &loc)
 {
-    if (m_policy == ClipboardImageWritable || m_policy == ClipboardWritable) {
+    if (policy() == ClipboardImageWritable || policy() == ClipboardWritable) {
         if (m_dragImage)
             m_dragImage->deref(this);
         m_dragImage = image;
@@ -305,7 +297,7 @@
         m_dragLoc = loc;
         m_dragImageElement = node;
         
-        if (m_dragStarted && m_changeCount == [m_pasteboard changeCount]) {
+        if (m_dragStarted && m_changeCount == [m_pasteboard.get() changeCount]) {
             NSPoint cocoaLoc;
             NSImage* cocoaImage = dragNSImage(cocoaLoc);
             if (cocoaImage) {
@@ -350,100 +342,4 @@
     return result;
 }
 
-String ClipboardMac::dropEffect() const
-{
-    return m_dropEffect;
-}
-
-void ClipboardMac::setDropEffect(const String &s)
-{
-    if (m_policy == ClipboardReadable || m_policy == ClipboardTypesReadable) {
-        m_dropEffect = s;
-    }
-}
-
-String ClipboardMac::effectAllowed() const
-{
-    return m_effectAllowed;
-}
-
-void ClipboardMac::setEffectAllowed(const String &s)
-{
-    if (m_policy == ClipboardWritable)
-        m_effectAllowed = s;
-}
-
-// These "conversion" methods are called by the bridge and part, and never make sense to JS, so we don't
-// worry about security for these. They don't allow access to the pasteboard anyway.
-
-static NSDragOperation cocoaOpFromIEOp(const String& op)
-{
-    // yep, it's really just this fixed set
-    if (op == "none")
-        return NSDragOperationNone;
-    if (op == "copy")
-        return NSDragOperationCopy;
-    if (op == "link")
-        return NSDragOperationLink;
-    if (op == "move")
-        return NSDragOperationGeneric;
-    if (op == "copyLink")
-        return NSDragOperationCopy | NSDragOperationLink;
-    if (op == "copyMove")
-        return NSDragOperationCopy | NSDragOperationGeneric | NSDragOperationMove;
-    if (op == "linkMove")
-        return NSDragOperationLink | NSDragOperationGeneric | NSDragOperationMove;
-    if (op == "all")
-        return NSDragOperationEvery;
-    return NSDragOperationPrivate;  // really a marker for "no conversion"
-}
-
-static String IEOpFromCocoaOp(NSDragOperation op)
-{
-    bool moveSet = ((NSDragOperationGeneric | NSDragOperationMove) & op) != 0;
-    
-    if ((moveSet && (op & NSDragOperationCopy) && (op & NSDragOperationLink))
-        || (op == NSDragOperationEvery))
-        return "all";
-    if (moveSet && (op & NSDragOperationCopy))
-        return "copyMove";
-    if (moveSet && (op & NSDragOperationLink))
-        return "linkMove";
-    if ((op & NSDragOperationCopy) && (op & NSDragOperationLink))
-        return "copyLink";
-    if (moveSet)
-        return "move";
-    if (op & NSDragOperationCopy)
-        return "copy";
-    if (op & NSDragOperationLink)
-        return "link";
-    return "none";
-}
-
-bool ClipboardMac::sourceOperation(NSDragOperation& op) const
-{
-    if (m_effectAllowed.isNull())
-        return false;
-    op = cocoaOpFromIEOp(m_effectAllowed);
-    return true;
-}
-
-bool ClipboardMac::destinationOperation(NSDragOperation& op) const
-{
-    if (m_dropEffect.isNull())
-        return false;
-    op = cocoaOpFromIEOp(m_dropEffect);
-    return true;
-}
-
-void ClipboardMac::setSourceOperation(NSDragOperation op)
-{
-    m_effectAllowed = IEOpFromCocoaOp(op);
-}
-
-void ClipboardMac::setDestinationOperation(NSDragOperation op)
-{
-    m_dropEffect = IEOpFromCocoaOp(op);
-}
-
 }
diff --git a/WebCore/platform/mac/DragDataMac.mm b/WebCore/platform/mac/DragDataMac.mm
new file mode 100644
index 0000000..353d321
--- /dev/null
+++ b/WebCore/platform/mac/DragDataMac.mm
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+#import "DragData.h"
+
+#import "ClipboardMac.h"
+#import "ClipboardAccessPolicy.h"
+#import "Document.h"
+#import "DocumentFragment.h"
+#import "DOMDocumentFragment.h"
+#import "DOMDocumentFragmentInternal.h"
+#import "MimeTypeRegistry.h"
+#import "Pasteboard.h"
+#import "PasteboardHelper.h"
+
+namespace WebCore {
+
+DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, 
+    DragOperation sourceOperationMask, PasteboardHelper* pasteboardHelper)
+    : m_clientPosition(clientPosition)
+    , m_globalPosition(globalPosition)
+    , m_platformDragData(data)
+    , m_draggingSourceOperationMask(sourceOperationMask)
+    , m_pasteboardHelper(pasteboardHelper)
+{
+    ASSERT(pasteboardHelper);  
+}
+    
+bool DragData::canSmartReplace() const
+{
+    //Need to call this so that the various Pasteboard type strings are intialised
+    Pasteboard::generalPasteboard();
+    return [[[m_platformDragData draggingPasteboard] types] containsObject:WebSmartPastePboardType];
+}
+    
+bool DragData::containsColor() const
+{
+    return [[[m_platformDragData draggingPasteboard] types] containsObject:NSColorPboardType];
+}
+
+bool DragData::containsPlainText() const
+{
+    NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard];
+    NSArray *types = [pasteboard types];
+    
+    return [types containsObject:NSStringPboardType] 
+        || [types containsObject:NSRTFDPboardType]
+        || [types containsObject:NSRTFPboardType]
+        || [types containsObject:NSFilenamesPboardType]
+        || [NSURL URLFromPasteboard:pasteboard];
+}
+
+String DragData::asPlainText() const
+{
+    return m_pasteboardHelper->plainTextFromPasteboard([m_platformDragData draggingPasteboard]);
+}
+    
+Color DragData::asColor() const
+{
+    NSColor *color = [NSColor colorFromPasteboard:[m_platformDragData draggingPasteboard]];
+    return makeRGBA((int)([color redComponent] * 255.0 + 0.5), (int)([color greenComponent] * 255.0 + 0.5), 
+                    (int)([color blueComponent] * 255.0 + 0.5), (int)([color alphaComponent] * 255.0 + 0.5));
+}
+
+Clipboard* DragData::createClipboard(ClipboardAccessPolicy policy) const
+{
+    return new ClipboardMac(true, [m_platformDragData draggingPasteboard], policy);
+}
+
+static bool imageExistsAtPaths(NSArray* paths)
+{
+    NSEnumerator *enumerator = [paths objectEnumerator];
+    NSString *path;
+    
+    while ((path = [enumerator nextObject]) != nil)
+        if (MimeTypeRegistry::isSupportedImageResourceMIMEType(MimeTypeRegistry::getMIMETypeForExtension([path pathExtension])))
+            return true;
+    
+    return false;
+}
+    
+bool DragData::containsCompatibleContent() const
+{
+    
+    NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard];
+    NSMutableSet *types = [NSMutableSet setWithArray:[pasteboard types]];
+    [types intersectSet:[NSSet setWithArray:m_pasteboardHelper->insertablePasteboardTypes()]];
+    if ([types count] == 0)
+        return false;
+    return !([types count] == 1 && [types containsObject:NSFilenamesPboardType] &&
+        !imageExistsAtPaths([pasteboard propertyListForType:NSFilenamesPboardType]));
+}
+    
+bool DragData::containsURL() const
+{
+    //FIXME: is it worth doing the initial [types contains URL] check?
+    return [[[m_platformDragData draggingPasteboard] types] containsObject:NSURLPboardType] || !asURL().isEmpty();
+}
+    
+String DragData::asURL(String* title) const
+{
+    return m_pasteboardHelper->urlFromPasteboard([m_platformDragData draggingPasteboard], title);
+}
+    
+    
+PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
+{
+    return [m_pasteboardHelper->fragmentFromPasteboard([m_platformDragData draggingPasteboard]) _documentFragment];
+}
+    
+}
+
diff --git a/WebCore/platform/mac/PasteboardHelper.h b/WebCore/platform/mac/PasteboardHelper.h
new file mode 100644
index 0000000..4ae964d
--- /dev/null
+++ b/WebCore/platform/mac/PasteboardHelper.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef PasteboardHelper_h
+#define PasteboardHelper_h
+
+/* FIXME: This is a helper class used to provide access to functionality inside 
+ * WebKit.  The required functionality should eventually be migrated to WebCore
+ * so that this class can be removed.
+ */
+#if PLATFORM(MAC)
+
+#import <wtf/Forward.h>
+
+#ifdef __OBJC__
+@class DOMDocumentFragment;
+#else
+class DOMDocumentFragment;
+#endif
+
+namespace WebCore {
+
+    class String;
+    class Document;
+    
+    class PasteboardHelper {
+    public:
+        virtual ~PasteboardHelper() {}
+        virtual String urlFromPasteboard(const NSPasteboard*, String* title) const = 0;
+        virtual String plainTextFromPasteboard(const NSPasteboard*) const = 0;
+        virtual DOMDocumentFragment* fragmentFromPasteboard(const NSPasteboard*) const = 0;
+        virtual NSArray* insertablePasteboardTypes() const = 0;
+    };
+    
+}
+#endif // PLATFORM(MAC)
+
+#endif // !PasteboardHelper_h
diff --git a/WebCore/platform/qt/DragDataQt.cpp b/WebCore/platform/qt/DragDataQt.cpp
new file mode 100644
index 0000000..5269388
--- /dev/null
+++ b/WebCore/platform/qt/DragDataQt.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "DragData.h"
+
+namespace WebCore {
+
+bool DragData::canSmartReplace()
+{
+    return false;
+}
+    
+bool DragData::containsColor()
+{
+    return false;
+}
+
+bool DragData::containsPlainText()
+{
+    return false;
+}
+
+String DragData::asPlainText()
+{
+    return String();
+}
+    
+Color DragData::asColor()
+{
+    return Color();
+}
+
+Clipboard* DragData::createClipboard(ClipboardAccessPolicy)
+{
+    return 0;
+}
+    
+bool DragData::containsCompatibleContent()
+{
+    return false;
+}
+    
+bool DragData::containsURL() 
+{
+    return false;
+}
+    
+String DragData::asURL(String* title)
+{
+    return String();
+}
+    
+    
+PassRefPtr<DocumentFragment> DragData::asFragment(Document*)
+{
+    return 0;
+}
+    
+}
+
diff --git a/WebCore/rendering/HitTestResult.cpp b/WebCore/rendering/HitTestResult.cpp
index 0260499..f354d0f 100644
--- a/WebCore/rendering/HitTestResult.cpp
+++ b/WebCore/rendering/HitTestResult.cpp
@@ -51,6 +51,7 @@
     : m_innerNode(other.innerNode())
     , m_innerNonSharedNode(other.innerNonSharedNode())
     , m_point(other.point())
+    , m_localPoint(other.localPoint())
     , m_innerURLElement(other.URLElement())
     , m_scrollbar(other.scrollbar())
 {