WebKit Bugzilla
Attachment 356259 Details for
Bug 192265
: Editable images should always return some data, even if the canvas doesn't have a size yet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192265-20181130161648.patch (text/plain), 5.50 KB, created by
Tim Horton
on 2018-11-30 16:16:49 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tim Horton
Created:
2018-11-30 16:16:49 PST
Size:
5.50 KB
patch
obsolete
>Subversion Revision: 238743 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index a287dca382250b0db99d4b8c3b872376203c600e..31008197d745e5f5a70bc57c91203fc1c6c66ce5 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,21 @@ >+2018-11-30 Tim Horton <timothy_horton@apple.com> >+ >+ Editable images should always return some data, even if the canvas doesn't have a size yet >+ https://bugs.webkit.org/show_bug.cgi?id=192265 >+ <rdar://problem/46385911> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UIProcess/ios/WKDrawingView.mm: >+ (-[WKDrawingView layoutSubviews]): >+ (emptyImage): >+ (-[WKDrawingView renderedDrawing]): >+ (-[WKDrawingView PNGRepresentation]): >+ Some clients strongly depend on there being some data in an image, even if >+ it's not of a usable size yet. We'll invalidate the attachment when the >+ canvas size changes, so it will eventually settle at a usable size (after >+ the first layer tree commit that includes the editable image). >+ > 2018-11-30 David Quesada <david_quesada@apple.com> > > -[WKProcessPool _downloadURLRequest:] should allow specifying the initiating web view >diff --git a/Source/WebKit/UIProcess/ios/WKDrawingView.mm b/Source/WebKit/UIProcess/ios/WKDrawingView.mm >index f8d2500e26427d8b9e1dfd8135c044f560aa0820..d0d903dea7279366be38b07c9e45cb95dad2b60f 100644 >--- a/Source/WebKit/UIProcess/ios/WKDrawingView.mm >+++ b/Source/WebKit/UIProcess/ios/WKDrawingView.mm >@@ -39,8 +39,10 @@ @end > @implementation WKDrawingView { > RetainPtr<PKCanvasView> _pencilView; > >+#if !PLATFORM(IOS_FAMILY_SIMULATOR) > OSObjectPtr<dispatch_queue_t> _renderQueue; > RetainPtr<PKImageRenderer> _renderer; >+#endif > > WeakPtr<WebKit::WebPageProxy> _webPageProxy; > } >@@ -70,18 +72,36 @@ - (void)layoutSubviews > if (!CGRectEqualToRect([_pencilView frame], self.bounds)) { > [_pencilView setFrame:self.bounds]; > >+#if !PLATFORM(IOS_FAMILY_SIMULATOR) > // The renderer is instantiated for a particular size output; if > // the size changes, we need to re-create the renderer. > _renderer = nil; >+#endif > > [self invalidateAttachment]; > } > } > >-- (NSData *)PNGRepresentation >+static UIImage *emptyImage() >+{ >+ UIGraphicsBeginImageContext(CGSizeMake(1, 1)); >+ CGContextClearRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, 1, 1)); >+ UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext(); >+ UIGraphicsEndImageContext(); >+ >+ return resultImage; >+} >+ >+- (UIImage *)renderedDrawing > { >+#if PLATFORM(IOS_FAMILY_SIMULATOR) >+ // PKImageRenderer currently doesn't work in the simulator. In order to >+ // allow strokes to persist regardless (mostly for testing), we'll >+ // synthesize an empty 1x1 image. >+ return emptyImage(); >+#else > if (!self.bounds.size.width || !self.bounds.size.height || !self.window.screen.scale) >- return nil; >+ return emptyImage(); > > if (!_renderQueue) > _renderQueue = adoptOSObject(dispatch_queue_create("com.apple.WebKit.WKDrawingView.Rendering", DISPATCH_QUEUE_SERIAL)); >@@ -89,31 +109,27 @@ - (NSData *)PNGRepresentation > if (!_renderer) > _renderer = adoptNS([WebKit::allocPKImageRendererInstance() initWithSize:self.bounds.size scale:self.window.screen.scale renderQueue:_renderQueue.get()]); > >- auto* drawing = [_pencilView drawing]; >- > __block RetainPtr<UIImage> resultImage; >-#if PLATFORM(IOS_FAMILY_SIMULATOR) >- // PKImageRenderer currently doesn't work in the simulator. In order to >- // allow strokes to persist regardless (mostly for testing), we'll >- // synthesize an empty 1x1 image. >- UIGraphicsBeginImageContext(CGSizeMake(1, 1)); >- CGContextClearRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, 1, 1)); >- resultImage = UIGraphicsGetImageFromCurrentImageContext(); >- UIGraphicsEndImageContext(); >-#else >- [_renderer renderDrawing:drawing completion:^(UIImage *image) { >+ >+ [_renderer renderDrawing:[_pencilView drawing] completion:^(UIImage *image) { > resultImage = image; > }]; >-#endif > > // FIXME: Ideally we would not synchronously wait for this rendering, > // but NSFileWrapper requires data synchronously, and our clients expect > // an NSFileWrapper to be available synchronously. > dispatch_sync(_renderQueue.get(), ^{ }); > >+ return resultImage.get(); >+#endif >+} >+ >+- (NSData *)PNGRepresentation >+{ >+ RetainPtr<UIImage> image = [self renderedDrawing]; > RetainPtr<NSMutableData> PNGData = adoptNS([[NSMutableData alloc] init]); > RetainPtr<CGImageDestinationRef> imageDestination = adoptCF(CGImageDestinationCreateWithData((__bridge CFMutableDataRef)PNGData.get(), kUTTypePNG, 1, nil)); >- NSString *base64Drawing = [[drawing serialize] base64EncodedStringWithOptions:0]; >+ NSString *base64Drawing = [[[_pencilView drawing] serialize] base64EncodedStringWithOptions:0]; > NSDictionary *properties = nil; > if (base64Drawing) { > // FIXME: We should put this somewhere less user-facing than the EXIF User Comment field. >@@ -124,7 +140,7 @@ - (NSData *)PNGRepresentation > }; > } > CGImageDestinationSetProperties(imageDestination.get(), (__bridge CFDictionaryRef)properties); >- CGImageDestinationAddImage(imageDestination.get(), [resultImage CGImage], (__bridge CFDictionaryRef)properties); >+ CGImageDestinationAddImage(imageDestination.get(), [image CGImage], (__bridge CFDictionaryRef)properties); > CGImageDestinationFinalize(imageDestination.get()); > > return PNGData.autorelease();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192265
: 356259