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

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: Attempted to address feedback. Created 4 years, 2 months 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
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 5de205080b24a0b001d7a42737d5eab67d2173f2..a4b724a3438320ee95747e49d6df2ad6ba8a4596 100644
--- a/third_party/WebKit/Source/core/page/DragController.cpp
+++ b/third_party/WebKit/Source/core/page/DragController.cpp
@@ -798,15 +798,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;
- }
}
}
@@ -910,16 +910,36 @@ bool DragController::populateDragDataTransfer(LocalFrame* src,
Element* element = toElement(node);
prepareDataTransferForImageDrag(src, dataTransfer, element, linkURL,
imageURL, hitTestResult.altDisplayString());
- } 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 (isHTMLAnchorElement(*node) && toHTMLAnchorElement(node)->isLiveLink() &&
dcheng 2016/10/31 22:31:35 I was thinking we could make this a top-level if (
pwnall 2016/11/04 23:08:29 Done. I'll learn about this more as I work through
+ !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 == DragSourceActionLink) {
+ if (linkURL.isEmpty())
+ return false;
+ } 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;
+ }
+
+ // FIXME: For DHTML/draggable element drags, write element markup to
+ // clipboard.
+ }
}
- // FIXME: For DHTML/draggable element drags, write element markup to
- // clipboard.
return true;
}

Powered by Google App Engine
This is Rietveld 408576698