InjectedBundleNodeHandle::renderedImage() needs to be exposed from the Cocoa WebAPI...
[WebKit-https.git] / Source / WebKit2 / WebProcess / InjectedBundle / API / Cocoa / WKWebProcessPlugInNodeHandle.mm
index 4bad43483a2738ba022afc154662430d99632f8c..d57d04584ebcbb05587863ed25ebebee7b4d71f2 100644 (file)
@@ -28,6 +28,7 @@
 
 #import "WKWebProcessPlugInFrameInternal.h"
 #import <WebCore/IntRect.h>
+#import <WebKit/WebImage.h>
 
 #if WK_API_ENABLED
 
@@ -63,6 +64,28 @@ using namespace WebKit;
     return [wrapper(*frame.release().leakRef()) autorelease];
 }
 
+#if PLATFORM(IOS)
+- (UIImage *)renderedImageWithOptions:(WKSnapshotOptions)options
+{
+    RefPtr<WebImage> image = _nodeHandle->renderedImage(options);
+    if (!image || !image->bitmap())
+        return nil;
+
+    return [[[UIImage alloc] initWithCGImage:image->bitmap()->makeCGImage().get()] autorelease];
+}
+#endif
+
+#if PLATFORM(MAC)
+- (NSImage *)renderedImageWithOptions:(WKSnapshotOptions)options
+{
+    RefPtr<WebImage> image = _nodeHandle->renderedImage(options);
+    if (!image || !image->bitmap())
+        return nil;
+
+    return [[[NSImage alloc] initWithCGImage:image->bitmap()->makeCGImage().get() size:NSZeroSize] autorelease];
+}
+#endif
+
 - (CGRect)elementBounds
 {
     return _nodeHandle->elementBounds();