<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[186008] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/186008">186008</a></dd>
<dt>Author</dt> <dd>bdakin@apple.com</dd>
<dt>Date</dt> <dd>2015-06-26 14:24:03 -0700 (Fri, 26 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>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):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionh">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessWKImagePreviewViewControllerh">trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWKImagePreviewViewControllermm">trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (186007 => 186008)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,46 @@
</span><ins>+2015-06-26  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        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):
+
</ins><span class="cx"> 2015-06-26  Matt Rajca  &lt;mrajca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Wireless Playback Target-related #import should be a #include
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWKImagePreviewViewControllerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.h (0 => 186008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.h        2015-06-26 21:24:03 UTC (rev 186008)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * 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 &lt;UIKit/UIKit.h&gt;
+
+#import &lt;wtf/RetainPtr.h&gt;
+
+@interface WKImagePreviewViewController : UIViewController
+
+- (id)initWithCGImage:(RetainPtr&lt;CGImageRef&gt;)image;
+@end
+
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWKImagePreviewViewControllermm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.mm (0 => 186008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.mm                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/WKImagePreviewViewController.mm        2015-06-26 21:24:03 UTC (rev 186008)
</span><span class="lines">@@ -0,0 +1,91 @@
</span><ins>+/*
+ * 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 &quot;config.h&quot;
+#import &quot;WKImagePreviewViewController.h&quot;
+
+#import &lt;WebCore/IntSize.h&gt;
+
+#if PLATFORM(IOS)
+
+@implementation WKImagePreviewViewController {
+    RetainPtr&lt;CGImageRef&gt; _image;
+    RetainPtr&lt;UIImageView&gt; _imageView;
+}
+
+- (void)loadView
+{
+    [super loadView];
+    self.view.backgroundColor = [UIColor whiteColor];
+    [self.view addSubview:_imageView.get()];
+}
+
+- (id)initWithCGImage:(RetainPtr&lt;CGImageRef&gt;)image
+{
+    self = [super initWithNibName:nil bundle:nil];
+    if (!self)
+        return nil;
+
+    _image = image;
+
+    _imageView = adoptNS([[UIImageView alloc] initWithFrame:CGRectZero]);
+    RetainPtr&lt;UIImage&gt; 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 &gt; destinationAspectRatio) {
+        size.width = destination.width;
+        size.height = (source.height * (destination.width / source.width));
+    } else if (sourceAspectRatio &lt; destinationAspectRatio) {
+        size.width = (source.width * (destination.height / source.height));
+        size.height = destination.height;
+    }
+    
+    return size;
+}
+
+@end
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (186007 => 186008)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -93,6 +93,13 @@
</span><span class="cx">     UIWKAutocorrectionCompletionHandler autocorrectionHandler;
</span><span class="cx">     UIWKAutocorrectionContextHandler autocorrectionContextHandler;
</span><span class="cx"> };
</span><ins>+
+enum class PreviewElementType {
+    None = 0,
+    Link,
+    Image
+};
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> @interface WKContentView () {
</span><span class="lines">@@ -120,6 +127,7 @@
</span><span class="cx">     RetainPtr&lt;WKFormInputSession&gt; _formInputSession;
</span><span class="cx">     RetainPtr&lt;WKFileUploadPanel&gt; _fileUploadPanel;
</span><span class="cx">     RetainPtr&lt;UIGestureRecognizer&gt; _previewGestureRecognizer;
</span><ins>+    WebKit::PreviewElementType _previewType;
</ins><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;WebKit::SmartMagnificationController&gt; _smartMagnificationController;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (186007 => 186008)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -41,7 +41,9 @@
</span><span class="cx"> #import &quot;WKActionSheetAssistant.h&quot;
</span><span class="cx"> #import &quot;WKFormInputControl.h&quot;
</span><span class="cx"> #import &quot;WKFormSelectControl.h&quot;
</span><ins>+#import &quot;WKImagePreviewViewController.h&quot;
</ins><span class="cx"> #import &quot;WKInspectorNodeSearchGestureRecognizer.h&quot;
</span><ins>+#import &quot;WKNSURLExtras.h&quot;
</ins><span class="cx"> #import &quot;WKUIDelegatePrivate.h&quot;
</span><span class="cx"> #import &quot;WKWebViewConfiguration.h&quot;
</span><span class="cx"> #import &quot;WKWebViewInternal.h&quot;
</span><span class="lines">@@ -958,7 +960,7 @@
</span><span class="cx">             return NO;
</span><span class="cx"> 
</span><span class="cx">         String absoluteLinkURL = _positionInformation.url;
</span><del>-        if (absoluteLinkURL.isEmpty() || !WebCore::protocolIsInHTTPFamily(absoluteLinkURL))
</del><ins>+        if (_positionInformation.clickableElementName == &quot;A&quot; &amp;&amp; (absoluteLinkURL.isEmpty() || !WebCore::protocolIsInHTTPFamily(absoluteLinkURL)))
</ins><span class="cx">             return NO;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -3118,32 +3120,52 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(self == sourceView);
</span><span class="cx"> 
</span><del>-    if (_positionInformation.clickableElementName != &quot;A&quot; &amp;&amp; _positionInformation.clickableElementName != &quot;IMG&quot;)
</del><ins>+    _previewType = PreviewElementType::None;
+
+    BOOL canShowImagePreview = _positionInformation.clickableElementName == &quot;IMG&quot;;
+    BOOL canShowLinkPreview = _positionInformation.clickableElementName == &quot;A&quot; || canShowImagePreview;
+
+    if (!canShowLinkPreview &amp;&amp; !canShowImagePreview)
</ins><span class="cx">         return nil;
</span><span class="cx"> 
</span><span class="cx">     String absoluteLinkURL = _positionInformation.url;
</span><del>-    if (absoluteLinkURL.isEmpty() || !WebCore::protocolIsInHTTPFamily(absoluteLinkURL))
-        return nil;
</del><ins>+    if (absoluteLinkURL.isEmpty() || !WebCore::protocolIsInHTTPFamily(absoluteLinkURL)) {
+        if (canShowLinkPreview &amp;&amp; !canShowImagePreview)
+            return nil;
+        canShowLinkPreview = NO;
+    }
</ins><span class="cx"> 
</span><del>-    NSURL *targetURL = [NSURL URLWithString:_positionInformation.url];
-    id&lt;WKUIDelegatePrivate&gt; uiDelegate = static_cast&lt;id &lt;WKUIDelegatePrivate&gt;&gt;([_webView UIDelegate]);
-    if ([uiDelegate respondsToSelector:@selector(_webView:previewViewControllerForURL:)]) {
</del><ins>+    if (canShowLinkPreview) {
+        _previewType = PreviewElementType::Link;
+        NSURL *targetURL = [NSURL _web_URLWithWTFString:_positionInformation.url];
+        id&lt;WKUIDelegatePrivate&gt; uiDelegate = static_cast&lt;id &lt;WKUIDelegatePrivate&gt;&gt;([_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;
</ins><span class="cx">         _highlightLongPressCanClick = NO;
</span><del>-        return [uiDelegate _webView:_webView previewViewControllerForURL:targetURL];
</del><ins>+        return [previewViewController autorelease];
+#else
+        return nil;
+#endif
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-#if HAVE(SAFARI_SERVICES_FRAMEWORK)
-    SFSafariViewController *previewViewController = [allocSFSafariViewControllerInstance() initWithURL:targetURL];
-    previewViewController._showingLinkPreview = YES;
-    _highlightLongPressCanClick = NO;
-    return previewViewController;
-#else
</del><ins>+    if (canShowImagePreview) {
+        _previewType = PreviewElementType::Image;
+        return [[[WKImagePreviewViewController alloc] initWithCGImage:_positionInformation.image-&gt;makeCGImageCopy()] autorelease];
+    }
+
</ins><span class="cx">     return nil;
</span><del>-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)commitPreviewViewController:(UIViewController *)viewController
</span><span class="cx"> {
</span><ins>+    if (_previewType != PreviewElementType::Link)
+        return;
+
</ins><span class="cx">     id&lt;WKUIDelegatePrivate&gt; uiDelegate = static_cast&lt;id &lt;WKUIDelegatePrivate&gt;&gt;([_webView UIDelegate]);
</span><span class="cx">     if ([uiDelegate respondsToSelector:@selector(_webView:commitPreviewedViewController:)]) {
</span><span class="cx">         [uiDelegate _webView:_webView commitPreviewedViewController:viewController];
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (186007 => 186008)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1186,6 +1186,8 @@
</span><span class="cx">                 9321D5881A38EE74008052BE /* WKImmediateActionController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9321D5871A38EE74008052BE /* WKImmediateActionController.mm */; };
</span><span class="cx">                 9321D58A1A38F196008052BE /* WKImmediateActionTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 9321D5891A38F196008052BE /* WKImmediateActionTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 9323611E1B015DA800FA9232 /* _WKOverlayScrollbarStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 9323611D1B015DA800FA9232 /* _WKOverlayScrollbarStyle.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                933DF82E1B3BC09000AEA9E3 /* WKImagePreviewViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 933DF82D1B3BC09000AEA9E3 /* WKImagePreviewViewController.h */; };
+                933DF8301B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 933DF82F1B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm */; };
</ins><span class="cx">                 934B724419F5B9BE00AE96D6 /* WKActionMenuItemTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 934B724319F5B9BE00AE96D6 /* WKActionMenuItemTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 935EEB9B1277617C003322B8 /* WKBundleBackForwardListItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 935EEB981277616D003322B8 /* WKBundleBackForwardListItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 935EEB9E127761AC003322B8 /* WKBundleBackForwardList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 935EEB951277616D003322B8 /* WKBundleBackForwardList.cpp */; };
</span><span class="lines">@@ -3374,6 +3376,8 @@
</span><span class="cx">                 9321D5871A38EE74008052BE /* WKImmediateActionController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKImmediateActionController.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9321D5891A38F196008052BE /* WKImmediateActionTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKImmediateActionTypes.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9323611D1B015DA800FA9232 /* _WKOverlayScrollbarStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKOverlayScrollbarStyle.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                933DF82D1B3BC09000AEA9E3 /* WKImagePreviewViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKImagePreviewViewController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                933DF82F1B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKImagePreviewViewController.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 934B724319F5B9BE00AE96D6 /* WKActionMenuItemTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKActionMenuItemTypes.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 935EEB8F1277615D003322B8 /* InjectedBundleBackForwardList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleBackForwardList.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 935EEB901277615D003322B8 /* InjectedBundleBackForwardList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleBackForwardList.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5140,6 +5144,8 @@
</span><span class="cx">                                 0FCB4E3F18BBE044000FCFC9 /* WKGeolocationProviderIOS.h */,
</span><span class="cx">                                 0FCB4E4018BBE044000FCFC9 /* WKGeolocationProviderIOS.mm */,
</span><span class="cx">                                 0FCB4E4118BBE044000FCFC9 /* WKGeolocationProviderIOSObjCSecurityOrigin.mm */,
</span><ins>+                                933DF82D1B3BC09000AEA9E3 /* WKImagePreviewViewController.h */,
+                                933DF82F1B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm */,
</ins><span class="cx">                                 0F3C7259196F5F6800AEDD0C /* WKInspectorHighlightView.h */,
</span><span class="cx">                                 0F3C7257196F5F5000AEDD0C /* WKInspectorHighlightView.mm */,
</span><span class="cx">                                 A54293A2195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.h */,
</span><span class="lines">@@ -8022,6 +8028,7 @@
</span><span class="cx">                                 1A043F6A12514D8B00FFBFB5 /* WebProcessConnectionMessages.h in Headers */,
</span><span class="cx">                                 BC306824125A6B9400E71278 /* WebProcessCreationParameters.h in Headers */,
</span><span class="cx">                                 2DB9C4AC1B3251BD0070F27F /* SafariServicesSPI.h in Headers */,
</span><ins>+                                933DF82E1B3BC09000AEA9E3 /* WKImagePreviewViewController.h in Headers */,
</ins><span class="cx">                                 1AFA4B901A65A9E2006C4AB4 /* WebProcessLifetimeObserver.h in Headers */,
</span><span class="cx">                                 1AFA4B8C1A65A1D0006C4AB4 /* WebProcessLifetimeTracker.h in Headers */,
</span><span class="cx">                                 BC3066BF125A442100E71278 /* WebProcessMessages.h in Headers */,
</span><span class="lines">@@ -9563,6 +9570,7 @@
</span><span class="cx">                                 0FCB4E4718BBE044000FCFC9 /* PageClientImplIOS.mm in Sources */,
</span><span class="cx">                                 1AC7537B183A9FDB0072CB15 /* PageLoadState.cpp in Sources */,
</span><span class="cx">                                 C574A58212E66681002DFE98 /* PasteboardTypes.mm in Sources */,
</span><ins>+                                933DF8301B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm in Sources */,
</ins><span class="cx">                                 E19582D6153CC05400B60875 /* PDFKitImports.mm in Sources */,
</span><span class="cx">                                 2D870D1016234FFE000A3F20 /* PDFPlugin.mm in Sources */,
</span><span class="cx">                                 2D2ADF0B16362DDB00197E47 /* PDFPluginAnnotation.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (186007 => 186008)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -2131,9 +2131,22 @@
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             if (elementIsLinkOrImage) {
</span><del>-                // Ensure that the image contains at most 600K pixels, so that it is not too big.
-                if (RefPtr&lt;WebImage&gt; snapshot = snapshotNode(*element, SnapshotOptionsShareable, 600 * 1024))
-                    info.image = snapshot-&gt;bitmap();
</del><ins>+                if (linkElement) {
+                    // Ensure that the image contains at most 600K pixels, so that it is not too big.
+                    if (RefPtr&lt;WebImage&gt; snapshot = snapshotNode(*element, SnapshotOptionsShareable, 600 * 1024))
+                        info.image = snapshot-&gt;bitmap();
+                } else if (element-&gt;renderer() &amp;&amp; element-&gt;renderer()-&gt;isRenderImage()) {
+                    auto&amp; renderImage = downcast&lt;RenderImage&gt;(*(element-&gt;renderer()));
+                    if (renderImage.cachedImage() &amp;&amp; !renderImage.cachedImage()-&gt;errorOccurred()) {
+                        if (Image* image = renderImage.cachedImage()-&gt;imageForRenderer(&amp;renderImage)) {
+                            if (RefPtr&lt;ShareableBitmap&gt; sharedBitmap = ShareableBitmap::createShareable(IntSize(image-&gt;size()), ShareableBitmap::SupportsAlpha)) {
+                                auto graphicsContext = sharedBitmap-&gt;createGraphicsContext();
+                                graphicsContext-&gt;drawImage(image, ColorSpaceDeviceRGB, FloatPoint(0, 0));
+                                info.image = sharedBitmap;
+                            }
+                        }
+                    }
+                }
</ins><span class="cx">             }
</span><span class="cx">             if (linkElement)
</span><span class="cx">                 info.url = [(NSURL *)linkElement-&gt;document().completeURL(stripLeadingAndTrailingHTMLSpaces(linkElement-&gt;getAttribute(HTMLNames::hrefAttr))) absoluteString];
</span></span></pre>
</div>
</div>

</body>
</html>