Index: third_party/WebKit/Source/core/page/DragController.cpp |
diff --git a/third_party/WebKit/Source/core/page/DragController.cpp b/third_party/WebKit/Source/core/page/DragController.cpp |
index 8dd8b7d81e128e2c81270e7177f003a7055cf92f..fb4ec956ca8765ebb2169060af6fc81f608aa5ad 100644 |
--- a/third_party/WebKit/Source/core/page/DragController.cpp |
+++ b/third_party/WebKit/Source/core/page/DragController.cpp |
@@ -797,15 +797,15 @@ Node* DragController::draggableNode(const LocalFrame* src, |
return node; |
} |
// Other draggable elements are considered unselectable. |
+ if (dragMode == DRAG_ELEMENT) { |
+ candidateDragType = DragSourceActionDHTML; |
+ break; |
+ } |
if (isHTMLAnchorElement(*node) && |
toHTMLAnchorElement(node)->isLiveLink()) { |
candidateDragType = DragSourceActionLink; |
break; |
} |
- if (dragMode == DRAG_ELEMENT) { |
- candidateDragType = DragSourceActionDHTML; |
- break; |
- } |
} |
} |
@@ -883,6 +883,11 @@ bool DragController::populateDragDataTransfer(LocalFrame* src, |
if (!src->view() || src->contentLayoutItem().isNull()) |
return false; |
+ // Check to see if this a DOM based drag, if it is get the DOM specified drag |
+ // image and offset |
+ if (state.m_dragType == DragSourceActionDHTML) { |
dcheng
2016/10/27 06:37:54
Is this leftover from an earlier CL?
pwnall
2016/10/29 00:24:24
Done.
It was a previous host for the block of code
|
+ } |
+ |
HitTestResult hitTestResult = |
src->eventHandler().hitTestResultAtPoint(dragOrigin); |
// FIXME: Can this even happen? I guess it's possible, but should verify |
@@ -916,9 +921,30 @@ bool DragController::populateDragDataTransfer(LocalFrame* src, |
// user sees on the web page. This includes replacing newlines with spaces. |
dataTransfer->writeURL(node, linkURL, |
hitTestResult.textContent().simplifyWhiteSpace()); |
+ } else if (state.m_dragType == DragSourceActionDHTML) { |
+ if (LayoutObject* layoutObject = node->layoutObject()) { |
+ IntRect boundingIncludingDescendants = |
+ layoutObject->absoluteBoundingBoxRectIncludingDescendants(); |
+ IntSize delta = dragOrigin - boundingIncludingDescendants.location(); |
+ dataTransfer->setDragImageElement(node, IntPoint(delta)); |
+ } else { |
+ // The layoutObject has disappeared, this can happen if the onStartDrag |
+ // handler has hidden the element in some way. In this case we just kill |
+ // the drag. |
+ return false; |
+ } |
+ |
+ // Links with draggable="true" follow this code path. We still need to |
+ // populate the DataTransfer with a text/uri-list. |
+ if (isHTMLAnchorElement(*node) && toHTMLAnchorElement(node)->isLiveLink() && |
+ !linkURL.isEmpty()) { |
+ dataTransfer->writeURL(node, linkURL, |
+ hitTestResult.textContent().simplifyWhiteSpace()); |
+ } |
+ |
+ // FIXME: For DHTML/draggable element drags, write element markup to |
+ // clipboard. |
} |
- // FIXME: For DHTML/draggable element drags, write element markup to |
- // clipboard. |
return true; |
} |