REGRESSION(r212681): Crash when dragging links without a drag image
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2017 10:37:31 +0000 (10:37 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2017 10:37:31 +0000 (10:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168648

Reviewed by Tim Horton.

This happens in GTK+ port, because we don't use a drag image for links.

Fixes: editing/pasteboard/drop-link.html
       editing/pasteboard/drop-text-without-selection.html
       editing/pasteboard/files-during-page-drags.html
       fast/events/content-changed-during-drop.html
       fast/events/drag-and-drop-link-fast-multiple-times-does-not-crash.html
       fast/events/drag-and-drop-link-into-focused-contenteditable.html
       fast/events/drag-and-drop-link.html
       fast/events/drag-in-frames.html
       fast/events/drag-parent-node.html
       fast/events/shift-drag-selection-on-link-triggers-drag-n-drop.html

* page/DragController.cpp:
(WebCore::DragController::startDrag): Do not try to use drag image and its size when createDragImageForLink
returns nullptr.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212711 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/DragController.cpp

index ea76e95..b1c2964 100644 (file)
@@ -1,3 +1,27 @@
+2017-02-21  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        REGRESSION(r212681): Crash when dragging links without a drag image
+        https://bugs.webkit.org/show_bug.cgi?id=168648
+
+        Reviewed by Tim Horton.
+
+        This happens in GTK+ port, because we don't use a drag image for links.
+
+        Fixes: editing/pasteboard/drop-link.html
+               editing/pasteboard/drop-text-without-selection.html
+               editing/pasteboard/files-during-page-drags.html
+               fast/events/content-changed-during-drop.html
+               fast/events/drag-and-drop-link-fast-multiple-times-does-not-crash.html
+               fast/events/drag-and-drop-link-into-focused-contenteditable.html
+               fast/events/drag-and-drop-link.html
+               fast/events/drag-in-frames.html
+               fast/events/drag-parent-node.html
+               fast/events/shift-drag-selection-on-link-triggers-drag-n-drop.html
+
+        * page/DragController.cpp:
+        (WebCore::DragController::startDrag): Do not try to use drag image and its size when createDragImageForLink
+        returns nullptr.
+
 2017-02-21  Alex Christensen  <achristensen@webkit.org>
 
         Unreviewed, rolling out r212699.
index 63796df..e6faabf 100644 (file)
@@ -966,13 +966,15 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation
         if (!dragImage) {
             TextIndicatorData textIndicator;
             dragImage = DragImage { createDragImageForLink(element, linkURL, hitTestResult.textContent(), textIndicator, src.settings().fontRenderingMode(), m_page.deviceScaleFactor()) };
-            IntSize size = dragImageSize(dragImage.get());
-            m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset);
-            dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDraggedPoint.y() + m_dragOffset.y());
-            dragImage = DragImage { platformAdjustDragImageForDeviceScaleFactor(dragImage.get(), m_page.deviceScaleFactor()) };
-            if (textIndicator.contentImage)
-                dragImage.setIndicatorData(textIndicator);
-            dragImageAnchorPoint = FloatPoint { 0.5, static_cast<float>((size.height() - LinkDragBorderInset) / size.height()) };
+            if (dragImage) {
+                IntSize size = dragImageSize(dragImage.get());
+                m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset);
+                dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDraggedPoint.y() + m_dragOffset.y());
+                dragImage = DragImage { platformAdjustDragImageForDeviceScaleFactor(dragImage.get(), m_page.deviceScaleFactor()) };
+                if (textIndicator.contentImage)
+                    dragImage.setIndicatorData(textIndicator);
+                dragImageAnchorPoint = FloatPoint { 0.5, static_cast<float>((size.height() - LinkDragBorderInset) / size.height()) };
+            }
         }
 
         if (mustUseLegacyDragClient) {