Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Unified Diff: third_party/WebKit/Source/core/page/DragController.cpp

Issue 2441023003: Align drag feedback for links with draggable="true" to Safari. (Closed)
Patch Set: Rebased, added dependency on CL that fixes testing logistical issue. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/input/MouseEventManager.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6d06e6f7a491bbe0dca3c03035542b162b441361 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,23 @@ 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) {
+ LayoutObject* layoutObject = node->layoutObject();
+ if (!layoutObject) {
+ // 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;
+ }
+
+ IntRect boundingIncludingDescendants =
+ layoutObject->absoluteBoundingBoxRectIncludingDescendants();
+ IntSize delta = dragOrigin - boundingIncludingDescendants.location();
+ dataTransfer->setDragImageElement(node, IntPoint(delta));
+
+ // FIXME: For DHTML/draggable element drags, write element markup to
+ // clipboard.
}
- // FIXME: For DHTML/draggable element drags, write element markup to
- // clipboard.
return true;
}
« no previous file with comments | « third_party/WebKit/Source/core/input/MouseEventManager.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698