Bug 143341 - InjectedBundleNodeHandle::renderedImage() needs to be exposed from the Cocoa WebAPI layer
Summary: InjectedBundleNodeHandle::renderedImage() needs to be exposed from the Cocoa ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-04-02 13:31 PDT by Said Abou-Hallawa
Modified: 2015-04-03 13:13 PDT (History)
3 users (show)

See Also:


Attachments
Patch (3.32 KB, patch)
2015-04-02 13:35 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (3.54 KB, patch)
2015-04-03 11:39 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2015-04-02 13:31:22 PDT
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.
Comment 1 Said Abou-Hallawa 2015-04-02 13:35:59 PDT
Created attachment 250004 [details]
Patch
Comment 2 Darin Adler 2015-04-02 13:49:42 PDT
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.
Comment 3 Anders Carlsson 2015-04-03 11:26:11 PDT
(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:
Comment 4 Said Abou-Hallawa 2015-04-03 11:39:57 PDT
Created attachment 250091 [details]
Patch
Comment 5 Said Abou-Hallawa 2015-04-03 12:18:59 PDT
(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.
Comment 6 Said Abou-Hallawa 2015-04-03 12:19:14 PDT
(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.
Comment 7 Radar WebKit Bug Importer 2015-04-03 12:20:48 PDT
<rdar://problem/20419231>
Comment 8 WebKit Commit Bot 2015-04-03 13:13:17 PDT
Comment on attachment 250091 [details]
Patch

Clearing flags on attachment: 250091

Committed r182327: <http://trac.webkit.org/changeset/182327>
Comment 9 WebKit Commit Bot 2015-04-03 13:13:21 PDT
All reviewed patches have been landed.  Closing bug.