Title: [220028] branches/safari-604-branch/Source/WebCore

Diff

Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (220027 => 220028)


--- branches/safari-604-branch/Source/WebCore/ChangeLog	2017-07-28 22:20:02 UTC (rev 220027)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog	2017-07-28 22:20:04 UTC (rev 220028)
@@ -1,5 +1,37 @@
 2017-07-28  Jason Marcell  <[email protected]>
 
+        Cherry-pick r219998. rdar://problem/33595610
+
+    2017-07-28  Wenson Hsieh  <[email protected]>
+
+            [iOS DnD] [WK1] Snapshots generated using -[DOMRange renderImageForcingBlackText:] are upside down
+            https://bugs.webkit.org/show_bug.cgi?id=174928
+            <rdar://problem/33584280>
+
+            Reviewed by Tim Horton.
+
+            Pulls the implementation of createDragImageForRange out into DragImageIOS, and use TextIndicator to generate a
+            snapshot instead of FrameSelection's snapshotting utilities. This makes snapshotting a DOMRange behave the same
+            way as snapshotting a dragged selection.
+
+            No way of testing TextIndicator-based snapshotting yet.
+
+            * platform/DragImage.cpp:
+
+            Guard createDragImageForRange for !PLATFORM(IOS).
+
+            * platform/ios/DragImageIOS.mm:
+            (WebCore::createDragImageForSelection):
+
+            Add a FIXME to point out that having an additional context flip inside the UIGraphicsImageRenderer block results
+            in an upside-down drag image being returned from createDragImageFromImage. This image is being flipped elsewhere
+            in drag initiation code, which eventually results in the correct orientation; we'll need further investigation
+            to remove this extraneous flip.
+
+            (WebCore::createDragImageForRange):
+
+2017-07-28  Jason Marcell  <[email protected]>
+
         Cherry-pick r219992. rdar://problem/33595621
 
     2017-07-27  Jeremy Jones  <[email protected]>

Modified: branches/safari-604-branch/Source/WebCore/platform/DragImage.cpp (220027 => 220028)


--- branches/safari-604-branch/Source/WebCore/platform/DragImage.cpp	2017-07-28 22:20:02 UTC (rev 220027)
+++ branches/safari-604-branch/Source/WebCore/platform/DragImage.cpp	2017-07-28 22:20:04 UTC (rev 220028)
@@ -152,6 +152,8 @@
     std::optional<unsigned> endOffset;
 };
 
+#if !PLATFORM(IOS)
+
 DragImageRef createDragImageForRange(Frame& frame, Range& range, bool forceBlackText)
 {
     frame.document()->updateLayout();
@@ -190,6 +192,8 @@
     return createDragImageFromSnapshot(snapshotFrameRect(frame, view->selectionBounds(), options), nullptr);
 }
 
+#endif
+
 DragImageRef createDragImageForImage(Frame& frame, Node& node, IntRect& imageRect, IntRect& elementRect)
 {
     ScopedNodeDragEnabler enableDrag(frame, node);

Modified: branches/safari-604-branch/Source/WebCore/platform/ios/DragImageIOS.mm (220027 => 220028)


--- branches/safari-604-branch/Source/WebCore/platform/ios/DragImageIOS.mm	2017-07-28 22:20:02 UTC (rev 220027)
+++ branches/safari-604-branch/Source/WebCore/platform/ios/DragImageIOS.mm	2017-07-28 22:20:04 UTC (rev 220028)
@@ -210,6 +210,8 @@
     RetainPtr<UIGraphicsImageRenderer> render = adoptNS([allocUIGraphicsImageRendererInstance() initWithSize:imageRect.size()]);
     UIImage *finalImage = [render.get() imageWithActions:^(UIGraphicsImageRendererContext *rendererContext) {
         GraphicsContext context(rendererContext.CGContext);
+        // FIXME: The context flip here should not be necessary, and suggests that somewhere else in the regular
+        // drag initiation flow, we unnecessarily flip the graphics context.
         context.translate(0, imageRect.height());
         context.scale({ 1, -1 });
         context.drawImage(*image, imageRect);
@@ -224,6 +226,32 @@
     return image;
 }
 
+DragImageRef createDragImageForRange(Frame& frame, Range& range, bool forceBlackText)
+{
+    if (auto document = frame.document())
+        document->updateLayout();
+
+    if (range.collapsed())
+        return nil;
+
+    TextIndicatorOptions options = defaultSelectionDragImageTextIndicatorOptions;
+    if (!forceBlackText)
+        options |= TextIndicatorOptionRespectTextColor;
+
+    auto textIndicator = TextIndicator::createWithRange(range, options, TextIndicatorPresentationTransition::None);
+    if (!textIndicator || !textIndicator->contentImage())
+        return nil;
+
+    auto& image = *textIndicator->contentImage();
+    auto render = adoptNS([allocUIGraphicsImageRendererInstance() initWithSize:image.size()]);
+    UIImage *finalImage = [render.get() imageWithActions:[&image](UIGraphicsImageRendererContext *rendererContext) {
+        GraphicsContext context(rendererContext.CGContext);
+        context.drawImage(image, FloatPoint());
+    }];
+
+    return finalImage.CGImage;
+}
+
 #else
 
 void deleteDragImage(RetainPtr<CGImageRef>)
@@ -248,6 +276,11 @@
     return nullptr;
 }
 
+DragImageRef createDragImageForRange(Frame&, Range&, bool)
+{
+    return nullptr;
+}
+
 #endif
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to