Title: [219998] trunk/Source/WebCore
- Revision
- 219998
- Author
- [email protected]
- Date
- 2017-07-28 00:31:06 -0700 (Fri, 28 Jul 2017)
Log Message
[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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (219997 => 219998)
--- trunk/Source/WebCore/ChangeLog 2017-07-28 07:25:57 UTC (rev 219997)
+++ trunk/Source/WebCore/ChangeLog 2017-07-28 07:31:06 UTC (rev 219998)
@@ -1,3 +1,31 @@
+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 Jeremy Jones <[email protected]>
Remove Web prefix from WebVideoFullscreen and WebPlaybackSession classes.
Modified: trunk/Source/WebCore/platform/DragImage.cpp (219997 => 219998)
--- trunk/Source/WebCore/platform/DragImage.cpp 2017-07-28 07:25:57 UTC (rev 219997)
+++ trunk/Source/WebCore/platform/DragImage.cpp 2017-07-28 07:31:06 UTC (rev 219998)
@@ -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: trunk/Source/WebCore/platform/ios/DragImageIOS.mm (219997 => 219998)
--- trunk/Source/WebCore/platform/ios/DragImageIOS.mm 2017-07-28 07:25:57 UTC (rev 219997)
+++ trunk/Source/WebCore/platform/ios/DragImageIOS.mm 2017-07-28 07:31:06 UTC (rev 219998)
@@ -209,6 +209,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);
@@ -223,6 +225,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>)
@@ -247,6 +275,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