Attachment drag preview should not have the attachment outline
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 01:44:56 +0000 (01:44 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 01:44:56 +0000 (01:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172327
<rdar://problem/32282831>

Reviewed by Tim Horton.

When creating a drag image for an attachment element, don't include borders around the attachment.

* page/DragController.cpp:
(WebCore::DragController::startDrag):
* rendering/RenderAttachment.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::paintAttachment):

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

Source/WebCore/ChangeLog
Source/WebCore/page/DragController.cpp
Source/WebCore/rendering/RenderAttachment.h
Source/WebCore/rendering/RenderThemeIOS.mm

index 8c7c327a34c7dedcb52d5f8d5b4e1ea829d95b3f..0eb8a17f72110457e3b20db1e1d6493441290987 100644 (file)
@@ -1,3 +1,19 @@
+2017-05-18  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Attachment drag preview should not have the attachment outline
+        https://bugs.webkit.org/show_bug.cgi?id=172327
+        <rdar://problem/32282831>
+
+        Reviewed by Tim Horton.
+
+        When creating a drag image for an attachment element, don't include borders around the attachment.
+
+        * page/DragController.cpp:
+        (WebCore::DragController::startDrag):
+        * rendering/RenderAttachment.h:
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::paintAttachment):
+
 2017-05-18  Youenn Fablet  <youenn@apple.com>
 
         Make WebRTC logging happen in Release
index 0f41b6bf758f9c1c8d5cabcf8104d900d6add377..06ac575aa74f3c999f71149086714edcb60af92a 100644 (file)
@@ -65,6 +65,7 @@
 #include "PluginDocument.h"
 #include "PluginViewBase.h"
 #include "Position.h"
+#include "RenderAttachment.h"
 #include "RenderFileUploadControl.h"
 #include "RenderImage.h"
 #include "RenderView.h"
@@ -1056,6 +1057,10 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation
 
 #if ENABLE(ATTACHMENT_ELEMENT)
     if (is<HTMLAttachmentElement>(element) && m_dragSourceAction & DragSourceActionAttachment) {
+        auto* attachmentRenderer = downcast<HTMLAttachmentElement>(element).renderer();
+        if (!attachmentRenderer)
+            return false;
+
         src.editor().setIgnoreSelectionChanges(true);
         auto previousSelection = src.selection().selection();
         if (!dataTransfer.pasteboard().hasData()) {
@@ -1079,7 +1084,9 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation
         
         if (!dragImage) {
             TextIndicatorData textIndicator;
+            attachmentRenderer->setShouldDrawBorder(false);
             dragImage = DragImage { dissolveDragImageToFraction(createDragImageForSelection(src, textIndicator), DragImageAlpha) };
+            attachmentRenderer->setShouldDrawBorder(true);
             if (textIndicator.contentImage)
                 dragImage.setIndicatorData(textIndicator);
             dragLoc = dragLocForSelectionDrag(src);
index 556ff31e02f2b6bcc71bd1c4ffb3ac9cdcada03d..b55b5d2b6431baaf282045a3adc095783d36d11d 100644 (file)
@@ -38,6 +38,9 @@ public:
 
     HTMLAttachmentElement& attachmentElement() const;
 
+    void setShouldDrawBorder(bool drawBorder) { m_shouldDrawBorder = drawBorder; }
+    bool shouldDrawBorder() const { return m_shouldDrawBorder; }
+
     void invalidate();
 
 private:
@@ -52,6 +55,7 @@ private:
     int baselinePosition(FontBaseline, bool, LineDirectionMode, LinePositionMode) const override;
 
     LayoutUnit m_minimumIntrinsicWidth;
+    bool m_shouldDrawBorder { true };
 };
 
 inline RenderAttachment* HTMLAttachmentElement::renderer() const
index 768a5c591867b7731ed663535fed5e922d866a08..826dad8690c1c299da9f0e35b0fdcc0c26735f6a 100644 (file)
@@ -1771,9 +1771,11 @@ bool RenderThemeIOS::paintAttachment(const RenderObject& renderer, const PaintIn
 
     context.translate(toFloatSize(paintRect.location()));
 
-    Path borderPath = attachmentBorderPath(info);
-    paintAttachmentBorder(context, borderPath);
-    context.clipPath(borderPath);
+    if (attachment.shouldDrawBorder()) {
+        auto borderPath = attachmentBorderPath(info);
+        paintAttachmentBorder(context, borderPath);
+        context.clipPath(borderPath);
+    }
 
     context.translate(FloatSize(0, info.contentYOrigin));