Chromium Code Reviews| 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 dab1f265a1cfb62ed8376d92624c8041b4aad96d..4d713b533817dac72729ccbc5c775e302f820ae1 100644 |
| --- a/third_party/WebKit/Source/core/page/DragController.cpp |
| +++ b/third_party/WebKit/Source/core/page/DragController.cpp |
| @@ -790,15 +790,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; |
| - } |
| } |
| } |
| @@ -894,6 +894,15 @@ bool DragController::populateDragDataTransfer(LocalFrame* src, |
| DataTransfer* dataTransfer = state.m_dragDataTransfer.get(); |
| Node* node = state.m_dragSrc.get(); |
| + if (isHTMLAnchorElement(*node) && toHTMLAnchorElement(node)->isLiveLink() && |
| + !linkURL.isEmpty()) { |
| + // Simplify whitespace so the title put on the clipboard resembles what |
| + // the user sees on the web page. This includes replacing newlines with |
| + // spaces. |
| + dataTransfer->writeURL(node, linkURL, |
| + hitTestResult.textContent().simplifyWhiteSpace()); |
| + } |
| + |
| if (state.m_dragType == DragSourceActionSelection) { |
| dataTransfer->writeSelection(src->selection()); |
| } else if (state.m_dragType == DragSourceActionImage) { |
| @@ -905,13 +914,22 @@ bool DragController::populateDragDataTransfer(LocalFrame* src, |
| } else if (state.m_dragType == DragSourceActionLink) { |
| if (linkURL.isEmpty()) |
| return false; |
| - // Simplify whitespace so the title put on the clipboard resembles what the |
| - // 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 |
|
dcheng
2016/11/07 22:16:55
Nit: usually, the error case is ordered first with
pwnall
2016/11/07 23:21:16
Done.
|
| + // handler has hidden the element in some way. In this case we just kill |
| + // the drag. |
| + return false; |
| + } |
| + |
| + // FIXME: For DHTML/draggable element drags, write element markup to |
| + // clipboard. |
| } |
| - // FIXME: For DHTML/draggable element drags, write element markup to |
| - // clipboard. |
| return true; |
| } |