Title: [186008] trunk/Source/WebKit2
Revision
186008
Author
bda...@apple.com
Date
2015-06-26 14:24:03 -0700 (Fri, 26 Jun 2015)

Log Message

Add support for image previews
https://bugs.webkit.org/show_bug.cgi?id=146350
-and corresponding-
rdar://problem/20640234

Reviewed by Tim Horton.

For images, use the actual image instead of a snapshot.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getPositionInformation):

ViewController for image preview.
* UIProcess/WKImagePreviewViewController.h: Added.
* UIProcess/WKImagePreviewViewController.mm: Added.
(-[WKImagePreviewViewController loadView]):
(-[WKImagePreviewViewController initWithCGImage:]):
(-[WKImagePreviewViewController viewDidLayoutSubviews]):
(_scaleSizeWithinSize):

New enum and member variable to keep track of preview type.
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:

Only apply the http restriction to non-image links since we can still preview the 
image of a non-http image link.
(-[WKContentView gestureRecognizerShouldBegin:]):

Handle links and images.
(-[WKContentView previewViewControllerForPosition:inSourceView:]):

Return early for non-link previews.
(-[WKContentView commitPreviewViewController:]):

New files.
* WebKit2.xcodeproj/project.pbxproj:

Just use the actual image in the PositionInformation for image elements rather 
than taking a screen shot.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getPositionInformation):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (186007 => 186008)


--- trunk/Source/WebKit2/ChangeLog	2015-06-26 20:42:38 UTC (rev 186007)
+++ trunk/Source/WebKit2/ChangeLog	2015-06-26 21:24:03 UTC (rev 186008)
@@ -1,3 +1,46 @@
+2015-06-26  Beth Dakin  <bda...@apple.com>
+
+        Add support for image previews
+        https://bugs.webkit.org/show_bug.cgi?id=146350
+        -and corresponding-
+        rdar://problem/20640234
+
+        Reviewed by Tim Horton.
+
+        For images, use the actual image instead of a snapshot.
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getPositionInformation):
+
+        ViewController for image preview.
+        * UIProcess/WKImagePreviewViewController.h: Added.
+        * UIProcess/WKImagePreviewViewController.mm: Added.
+        (-[WKImagePreviewViewController loadView]):
+        (-[WKImagePreviewViewController initWithCGImage:]):
+        (-[WKImagePreviewViewController viewDidLayoutSubviews]):
+        (_scaleSizeWithinSize):
+
+        New enum and member variable to keep track of preview type.
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+
+        Only apply the http restriction to non-image links since we can still preview the 
+        image of a non-http image link.
+        (-[WKContentView gestureRecognizerShouldBegin:]):
+
+        Handle links and images.
+        (-[WKContentView previewViewControllerForPosition:inSourceView:]):
+
+        Return early for non-link previews.
+        (-[WKContentView commitPreviewViewController:]):
+
+        New files.
+        * WebKit2.xcodeproj/project.pbxproj:
+
+        Just use the actual image in the PositionInformation for image elements rather 
+        than taking a screen shot.
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getPositionInformation):
+
 2015-06-26  Matt Rajca  <mra...@apple.com>
 
         Wireless Playback Target-related #import should be a #include

Added: trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.h (0 => 186008)


--- trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.h	2015-06-26 21:24:03 UTC (rev 186008)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import <UIKit/UIKit.h>
+
+#import <wtf/RetainPtr.h>
+
+@interface WKImagePreviewViewController : UIViewController
+
+- (id)initWithCGImage:(RetainPtr<CGImageRef>)image;
+@end
+
+#endif // PLATFORM(IOS)

Added: trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.mm (0 => 186008)


--- trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.mm	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.mm	2015-06-26 21:24:03 UTC (rev 186008)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKImagePreviewViewController.h"
+
+#import <WebCore/IntSize.h>
+
+#if PLATFORM(IOS)
+
+@implementation WKImagePreviewViewController {
+    RetainPtr<CGImageRef> _image;
+    RetainPtr<UIImageView> _imageView;
+}
+
+- (void)loadView
+{
+    [super loadView];
+    self.view.backgroundColor = [UIColor whiteColor];
+    [self.view addSubview:_imageView.get()];
+}
+
+- (id)initWithCGImage:(RetainPtr<CGImageRef>)image
+{
+    self = [super initWithNibName:nil bundle:nil];
+    if (!self)
+        return nil;
+
+    _image = image;
+
+    _imageView = adoptNS([[UIImageView alloc] initWithFrame:CGRectZero]);
+    RetainPtr<UIImage> uiImage = adoptNS([[UIImage alloc] initWithCGImage:_image.get()]);
+    [_imageView setImage:uiImage.get()];
+
+    CGSize screenSize = UIApplication.sharedApplication.delegate.window.bounds.size;
+    CGSize imageSize = _scaleSizeWithinSize(CGSizeMake(CGImageGetWidth(_image.get()), CGImageGetHeight(_image.get())), screenSize);
+    [_imageView setFrame:CGRectMake([_imageView frame].origin.x, [_imageView frame].origin.y, imageSize.width, imageSize.height)];
+    [self setPreferredContentSize:imageSize];
+
+    return self;
+}
+
+- (void)viewDidLayoutSubviews
+{
+    [super viewDidLayoutSubviews];
+
+    [_imageView setFrame:self.view.bounds];
+}
+
+static CGSize _scaleSizeWithinSize(CGSize source, CGSize destination)
+{
+    CGSize size = destination;
+    CGFloat sourceAspectRatio = (source.width / source.height);
+    CGFloat destinationAspectRatio = (destination.width / destination.height);
+    
+    if (sourceAspectRatio > destinationAspectRatio) {
+        size.width = destination.width;
+        size.height = (source.height * (destination.width / source.width));
+    } else if (sourceAspectRatio < destinationAspectRatio) {
+        size.width = (source.width * (destination.height / source.height));
+        size.height = destination.height;
+    }
+    
+    return size;
+}
+
+@end
+
+#endif

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (186007 => 186008)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2015-06-26 20:42:38 UTC (rev 186007)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2015-06-26 21:24:03 UTC (rev 186008)
@@ -93,6 +93,13 @@
     UIWKAutocorrectionCompletionHandler autocorrectionHandler;
     UIWKAutocorrectionContextHandler autocorrectionContextHandler;
 };
+
+enum class PreviewElementType {
+    None = 0,
+    Link,
+    Image
+};
+
 }
 
 @interface WKContentView () {
@@ -120,6 +127,7 @@
     RetainPtr<WKFormInputSession> _formInputSession;
     RetainPtr<WKFileUploadPanel> _fileUploadPanel;
     RetainPtr<UIGestureRecognizer> _previewGestureRecognizer;
+    WebKit::PreviewElementType _previewType;
 
     std::unique_ptr<WebKit::SmartMagnificationController> _smartMagnificationController;
 

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (186007 => 186008)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-06-26 20:42:38 UTC (rev 186007)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-06-26 21:24:03 UTC (rev 186008)
@@ -41,7 +41,9 @@
 #import "WKActionSheetAssistant.h"
 #import "WKFormInputControl.h"
 #import "WKFormSelectControl.h"
+#import "WKImagePreviewViewController.h"
 #import "WKInspectorNodeSearchGestureRecognizer.h"
+#import "WKNSURLExtras.h"
 #import "WKUIDelegatePrivate.h"
 #import "WKWebViewConfiguration.h"
 #import "WKWebViewInternal.h"
@@ -958,7 +960,7 @@
             return NO;
 
         String absoluteLinkURL = _positionInformation.url;
-        if (absoluteLinkURL.isEmpty() || !WebCore::protocolIsInHTTPFamily(absoluteLinkURL))
+        if (_positionInformation.clickableElementName == "A" && (absoluteLinkURL.isEmpty() || !WebCore::protocolIsInHTTPFamily(absoluteLinkURL)))
             return NO;
     }
 
@@ -3118,32 +3120,52 @@
 {
     ASSERT(self == sourceView);
 
-    if (_positionInformation.clickableElementName != "A" && _positionInformation.clickableElementName != "IMG")
+    _previewType = PreviewElementType::None;
+
+    BOOL canShowImagePreview = _positionInformation.clickableElementName == "IMG";
+    BOOL canShowLinkPreview = _positionInformation.clickableElementName == "A" || canShowImagePreview;
+
+    if (!canShowLinkPreview && !canShowImagePreview)
         return nil;
 
     String absoluteLinkURL = _positionInformation.url;
-    if (absoluteLinkURL.isEmpty() || !WebCore::protocolIsInHTTPFamily(absoluteLinkURL))
-        return nil;
+    if (absoluteLinkURL.isEmpty() || !WebCore::protocolIsInHTTPFamily(absoluteLinkURL)) {
+        if (canShowLinkPreview && !canShowImagePreview)
+            return nil;
+        canShowLinkPreview = NO;
+    }
 
-    NSURL *targetURL = [NSURL URLWithString:_positionInformation.url];
-    id<WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>([_webView UIDelegate]);
-    if ([uiDelegate respondsToSelector:@selector(_webView:previewViewControllerForURL:)]) {
+    if (canShowLinkPreview) {
+        _previewType = PreviewElementType::Link;
+        NSURL *targetURL = [NSURL _web_URLWithWTFString:_positionInformation.url];
+        id<WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>([_webView UIDelegate]);
+        if ([uiDelegate respondsToSelector:@selector(_webView:previewViewControllerForURL:)]) {
+            _highlightLongPressCanClick = NO;
+            return [uiDelegate _webView:_webView previewViewControllerForURL:targetURL];
+        }
+#if HAVE(SAFARI_SERVICES_FRAMEWORK)
+        SFSafariViewController *previewViewController = [allocSFSafariViewControllerInstance() initWithURL:targetURL];
+        previewViewController._showingLinkPreview = YES;
         _highlightLongPressCanClick = NO;
-        return [uiDelegate _webView:_webView previewViewControllerForURL:targetURL];
+        return [previewViewController autorelease];
+#else
+        return nil;
+#endif
     }
 
-#if HAVE(SAFARI_SERVICES_FRAMEWORK)
-    SFSafariViewController *previewViewController = [allocSFSafariViewControllerInstance() initWithURL:targetURL];
-    previewViewController._showingLinkPreview = YES;
-    _highlightLongPressCanClick = NO;
-    return previewViewController;
-#else
+    if (canShowImagePreview) {
+        _previewType = PreviewElementType::Image;
+        return [[[WKImagePreviewViewController alloc] initWithCGImage:_positionInformation.image->makeCGImageCopy()] autorelease];
+    }
+
     return nil;
-#endif
 }
 
 - (void)commitPreviewViewController:(UIViewController *)viewController
 {
+    if (_previewType != PreviewElementType::Link)
+        return;
+
     id<WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>([_webView UIDelegate]);
     if ([uiDelegate respondsToSelector:@selector(_webView:commitPreviewedViewController:)]) {
         [uiDelegate _webView:_webView commitPreviewedViewController:viewController];

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (186007 => 186008)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-06-26 20:42:38 UTC (rev 186007)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-06-26 21:24:03 UTC (rev 186008)
@@ -1186,6 +1186,8 @@
 		9321D5881A38EE74008052BE /* WKImmediateActionController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9321D5871A38EE74008052BE /* WKImmediateActionController.mm */; };
 		9321D58A1A38F196008052BE /* WKImmediateActionTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 9321D5891A38F196008052BE /* WKImmediateActionTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9323611E1B015DA800FA9232 /* _WKOverlayScrollbarStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 9323611D1B015DA800FA9232 /* _WKOverlayScrollbarStyle.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		933DF82E1B3BC09000AEA9E3 /* WKImagePreviewViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 933DF82D1B3BC09000AEA9E3 /* WKImagePreviewViewController.h */; };
+		933DF8301B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 933DF82F1B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm */; };
 		934B724419F5B9BE00AE96D6 /* WKActionMenuItemTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 934B724319F5B9BE00AE96D6 /* WKActionMenuItemTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		935EEB9B1277617C003322B8 /* WKBundleBackForwardListItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 935EEB981277616D003322B8 /* WKBundleBackForwardListItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		935EEB9E127761AC003322B8 /* WKBundleBackForwardList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 935EEB951277616D003322B8 /* WKBundleBackForwardList.cpp */; };
@@ -3374,6 +3376,8 @@
 		9321D5871A38EE74008052BE /* WKImmediateActionController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKImmediateActionController.mm; sourceTree = "<group>"; };
 		9321D5891A38F196008052BE /* WKImmediateActionTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKImmediateActionTypes.h; sourceTree = "<group>"; };
 		9323611D1B015DA800FA9232 /* _WKOverlayScrollbarStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKOverlayScrollbarStyle.h; sourceTree = "<group>"; };
+		933DF82D1B3BC09000AEA9E3 /* WKImagePreviewViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKImagePreviewViewController.h; sourceTree = "<group>"; };
+		933DF82F1B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKImagePreviewViewController.mm; sourceTree = "<group>"; };
 		934B724319F5B9BE00AE96D6 /* WKActionMenuItemTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKActionMenuItemTypes.h; sourceTree = "<group>"; };
 		935EEB8F1277615D003322B8 /* InjectedBundleBackForwardList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleBackForwardList.cpp; sourceTree = "<group>"; };
 		935EEB901277615D003322B8 /* InjectedBundleBackForwardList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleBackForwardList.h; sourceTree = "<group>"; };
@@ -5140,6 +5144,8 @@
 				0FCB4E3F18BBE044000FCFC9 /* WKGeolocationProviderIOS.h */,
 				0FCB4E4018BBE044000FCFC9 /* WKGeolocationProviderIOS.mm */,
 				0FCB4E4118BBE044000FCFC9 /* WKGeolocationProviderIOSObjCSecurityOrigin.mm */,
+				933DF82D1B3BC09000AEA9E3 /* WKImagePreviewViewController.h */,
+				933DF82F1B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm */,
 				0F3C7259196F5F6800AEDD0C /* WKInspectorHighlightView.h */,
 				0F3C7257196F5F5000AEDD0C /* WKInspectorHighlightView.mm */,
 				A54293A2195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.h */,
@@ -8022,6 +8028,7 @@
 				1A043F6A12514D8B00FFBFB5 /* WebProcessConnectionMessages.h in Headers */,
 				BC306824125A6B9400E71278 /* WebProcessCreationParameters.h in Headers */,
 				2DB9C4AC1B3251BD0070F27F /* SafariServicesSPI.h in Headers */,
+				933DF82E1B3BC09000AEA9E3 /* WKImagePreviewViewController.h in Headers */,
 				1AFA4B901A65A9E2006C4AB4 /* WebProcessLifetimeObserver.h in Headers */,
 				1AFA4B8C1A65A1D0006C4AB4 /* WebProcessLifetimeTracker.h in Headers */,
 				BC3066BF125A442100E71278 /* WebProcessMessages.h in Headers */,
@@ -9563,6 +9570,7 @@
 				0FCB4E4718BBE044000FCFC9 /* PageClientImplIOS.mm in Sources */,
 				1AC7537B183A9FDB0072CB15 /* PageLoadState.cpp in Sources */,
 				C574A58212E66681002DFE98 /* PasteboardTypes.mm in Sources */,
+				933DF8301B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm in Sources */,
 				E19582D6153CC05400B60875 /* PDFKitImports.mm in Sources */,
 				2D870D1016234FFE000A3F20 /* PDFPlugin.mm in Sources */,
 				2D2ADF0B16362DDB00197E47 /* PDFPluginAnnotation.mm in Sources */,

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (186007 => 186008)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2015-06-26 20:42:38 UTC (rev 186007)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2015-06-26 21:24:03 UTC (rev 186008)
@@ -2131,9 +2131,22 @@
             }
 
             if (elementIsLinkOrImage) {
-                // Ensure that the image contains at most 600K pixels, so that it is not too big.
-                if (RefPtr<WebImage> snapshot = snapshotNode(*element, SnapshotOptionsShareable, 600 * 1024))
-                    info.image = snapshot->bitmap();
+                if (linkElement) {
+                    // Ensure that the image contains at most 600K pixels, so that it is not too big.
+                    if (RefPtr<WebImage> snapshot = snapshotNode(*element, SnapshotOptionsShareable, 600 * 1024))
+                        info.image = snapshot->bitmap();
+                } else if (element->renderer() && element->renderer()->isRenderImage()) {
+                    auto& renderImage = downcast<RenderImage>(*(element->renderer()));
+                    if (renderImage.cachedImage() && !renderImage.cachedImage()->errorOccurred()) {
+                        if (Image* image = renderImage.cachedImage()->imageForRenderer(&renderImage)) {
+                            if (RefPtr<ShareableBitmap> sharedBitmap = ShareableBitmap::createShareable(IntSize(image->size()), ShareableBitmap::SupportsAlpha)) {
+                                auto graphicsContext = sharedBitmap->createGraphicsContext();
+                                graphicsContext->drawImage(image, ColorSpaceDeviceRGB, FloatPoint(0, 0));
+                                info.image = sharedBitmap;
+                            }
+                        }
+                    }
+                }
             }
             if (linkElement)
                 info.url = "" *)linkElement->document().completeURL(stripLeadingAndTrailingHTMLSpaces(linkElement->getAttribute(HTMLNames::hrefAttr))) absoluteString];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to