A given node in the web page can render itself to an NSImage or UIImage. This can be useful for the UI process to draw complex static html elements (e.g. table, SVG etc) without having to create a WKView for the drawing. All it needs is to create a background WebProcess, load a local web page, get the node of a specific item and draw it to a bitmap.
Created attachment 250004 [details] Patch
Comment on attachment 250004 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=250004&action=review > Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.h:46 > +#if TARGET_OS_IPHONE > +- (UIImage *)renderedImage:(WKSnapshotOptions)options; > +#else > +- (NSImage *)renderedImage:(WKSnapshotOptions)options; > +#endif I think we need new availability annotation when we add a new method. > Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:74 > + return [[UIImage alloc] initWithCGImage:image->bitmap()->makeCGImage().get()]; This is missing an autorelease. > Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:85 > + return [[NSImage alloc] initWithCGImage:image->bitmap()->makeCGImage().get() size:NSZeroSize]; This is missing an autorelease.
(In reply to comment #2) > Comment on attachment 250004 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=250004&action=review > > > Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.h:46 > > +#if TARGET_OS_IPHONE > > +- (UIImage *)renderedImage:(WKSnapshotOptions)options; > > +#else > > +- (NSImage *)renderedImage:(WKSnapshotOptions)options; > > +#endif > > I think we need new availability annotation when we add a new method. > Yes. I also think we should call this renderedImageWithOptions:
Created attachment 250091 [details] Patch
(In reply to comment #2) > Comment on attachment 250004 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=250004&action=review > > > Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.h:46 > > +#if TARGET_OS_IPHONE > > +- (UIImage *)renderedImage:(WKSnapshotOptions)options; > > +#else > > +- (NSImage *)renderedImage:(WKSnapshotOptions)options; > > +#endif > > I think we need new availability annotation when we add a new method. > Done. I was not aware of the Cocoa availability annotation. > > Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:74 > > + return [[UIImage alloc] initWithCGImage:image->bitmap()->makeCGImage().get()]; > > This is missing an autorelease. > Done. > > Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:85 > > + return [[NSImage alloc] initWithCGImage:image->bitmap()->makeCGImage().get() size:NSZeroSize]; > > This is missing an autorelease. Done.
(In reply to comment #3) > (In reply to comment #2) > > Comment on attachment 250004 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=250004&action=review > > > > > Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.h:46 > > > +#if TARGET_OS_IPHONE > > > +- (UIImage *)renderedImage:(WKSnapshotOptions)options; > > > +#else > > > +- (NSImage *)renderedImage:(WKSnapshotOptions)options; > > > +#endif > > > > I think we need new availability annotation when we add a new method. > > > > Yes. I also think we should call this renderedImageWithOptions: Done.
<rdar://problem/20419231>
Comment on attachment 250091 [details] Patch Clearing flags on attachment: 250091 Committed r182327: <http://trac.webkit.org/changeset/182327>
All reviewed patches have been landed. Closing bug.