<!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>[177555] branches/safari-600.3-branch/Source</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/177555">177555</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2014-12-18 18:56:54 -0800 (Thu, 18 Dec 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/177522">r177522</a>. rdar://problem/19288547</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6003branchSourceWebCoreChangeLog">branches/safari-600.3-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6003branchSourceWebCoreWebCoreexpin">branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#branchessafari6003branchSourceWebCoreplatformspimacNSPopoverSPIh">branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSPopoverSPI.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2ChangeLog">branches/safari-600.3-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2SharedmacActionMenuHitTestResulth">branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2SharedmacActionMenuHitTestResultmm">branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessAPICocoaWKViewPrivateh">branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessAPImacWKViewmm">branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessmacWKImmediateActionControllerh">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessmacWKImmediateActionControllermm">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessmacWKPagePreviewViewControllerh">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessmacWKPagePreviewViewControllermm">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2WebKit2xcodeprojprojectpbxproj">branches/safari-600.3-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2WebProcessWebPagemacWebPageMacmm">branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessmacWKPreviewPopoverAnimationControllerh">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPreviewPopoverAnimationController.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessmacWKPreviewPopoverAnimationControllermm">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPreviewPopoverAnimationController.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6003branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebCore/ChangeLog (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/ChangeLog        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2014-12-18  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+        Merge r177522. rdar://problem/19288547
+
+    2014-12-18  Timothy Horton  &lt;timothy_horton@apple.com&gt;
+
+            Change page preview loading order, and add a TextIndicator
+            https://bugs.webkit.org/show_bug.cgi?id=139793
+            &lt;rdar://problem/19288547&gt;
+
+            Reviewed by Beth Dakin.
+
+            * WebCore.exp.in:
+            * platform/spi/mac/NSPopoverSPI.h:
+            Add an export and some SPI.
+
</ins><span class="cx"> 2014-12-17  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r177427. rdar://problem/19237945
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -679,6 +679,7 @@
</span><span class="cx"> __ZN7WebCore15mimeTypeFromURLERKNS_3URLE
</span><span class="cx"> __ZN7WebCore15originalURLDataEP5NSURL
</span><span class="cx"> __ZN7WebCore15pathGetFileNameERKN3WTF6StringE
</span><ins>+__ZN7WebCore15rangeOfContentsERNS_4NodeE
</ins><span class="cx"> __ZN7WebCore15reportExceptionEPN3JSC9ExecStateENS0_7JSValueEPNS_12CachedScriptE
</span><span class="cx"> __ZN7WebCore15setDOMExceptionEPN3JSC9ExecStateEi
</span><span class="cx"> __ZN7WebCore15toDOMStringListEPN3JSC9ExecStateENS0_7JSValueE
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebCoreplatformspimacNSPopoverSPIh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSPopoverSPI.h (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSPopoverSPI.h        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSPopoverSPI.h        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -38,4 +38,13 @@
</span><span class="cx"> @property NSRect positioningRect;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+typedef NS_OPTIONS(NSUInteger, NSPopoverPositioningOptions) {
+    NSPopoverPositioningOptionNone              = 0,
+    NSPopoverPositioningOptionKeepTopStable     = (1 &lt;&lt; 0)
+};
+
+@interface NSPopover (WKDetails)
+@property NSPopoverPositioningOptions positioningOptions;
+@end
+
</ins><span class="cx"> #endif // __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -1,3 +1,104 @@
</span><ins>+2014-12-18  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+        Merge r177522. rdar://problem/19288547
+
+    2014-12-18  Timothy Horton  &lt;timothy_horton@apple.com&gt;
+
+            Change page preview loading order, and add a TextIndicator
+            https://bugs.webkit.org/show_bug.cgi?id=139793
+            &lt;rdar://problem/19288547&gt;
+
+            Reviewed by Beth Dakin.
+
+            * Shared/mac/ActionMenuHitTestResult.h:
+            * Shared/mac/ActionMenuHitTestResult.mm:
+            (WebKit::ActionMenuHitTestResult::encode):
+            (WebKit::ActionMenuHitTestResult::decode):
+            * WebProcess/WebPage/mac/WebPageMac.mm:
+            (WebKit::WebPage::performActionMenuHitTestAtLocation):
+            Build a TextIndicator for links.
+
+            * UIProcess/API/Cocoa/WKViewPrivate.h:
+            * UIProcess/API/mac/WKView.mm:
+            (-[WKView _dismissContentRelativeChildWindows]):
+            (-[WKView _setPreviewTitle:]):
+            (-[WKView _setPreviewLoading:]):
+            Remove unneeded WK_API_ENABLED #ifs.
+
+            (-[WKView _setPreviewOverrideImage:]):
+            Add; forward to WKImmediateActionController.
+
+            * UIProcess/mac/WKImmediateActionController.h:
+            * UIProcess/mac/WKImmediateActionController.mm:
+            (-[WKImmediateActionController willDestroyView:]):
+            Shut down the WKPreviewPopoverAnimationController.
+
+            (-[WKImmediateActionController _clearImmediateActionState]):
+            (-[WKImmediateActionController immediateActionRecognizerWillPrepare:]):
+            Don't build an immediate action item here; we'll always build it in
+            willBeginAnimation, and the one we build here is likely to be wrong.
+
+            (-[WKImmediateActionController _defaultAnimationController]):
+            (-[WKImmediateActionController hidePreview]):
+            (-[WKImmediateActionController setPreviewTitle:]):
+            (-[WKImmediateActionController setPreviewLoading:]):
+            (-[WKImmediateActionController setPreviewOverrideImage:]):
+            (-[WKImmediateActionController _animationControllerForCustomPreview]):
+            (-[WKImmediateActionController _createPreviewPopoverIfNeededForURL:]): Deleted.
+            (-[WKImmediateActionController popoverWillClose:]): Deleted.
+            (targetSizeFitsInAvailableSpace): Deleted.
+            (-[WKImmediateActionController largestPopoverSize]): Deleted.
+            (-[WKImmediateActionController _preferredPopoverSizeWithPreviewPadding:]): Deleted.
+            (-[WKImmediateActionController pagePreviewViewController:viewForPreviewingURL:initialFrameSize:]): Deleted.
+            (-[WKImmediateActionController pagePreviewViewController:titleForPreviewOfURL:]): Deleted.
+            (-[WKImmediateActionController pagePreviewViewControllerWasClicked:]): Deleted.
+            Move preview popover code to WKPreviewPopoverAnimationController.
+            Install and uninstall the link text indicator when necessary.
+
+            * UIProcess/mac/WKPagePreviewViewController.h:
+            * UIProcess/mac/WKPagePreviewViewController.mm:
+            (-[WKPagePreviewViewController setLoading:]):
+            (-[WKPagePreviewViewController loadView]):
+            (-[WKPagePreviewViewController replacePreviewWithImage:atSize:]):
+            Allow overriding the preview with a full-view NSImage.
+            Hide the preview view until the loading spinner goes away.
+
+            * UIProcess/mac/WKPreviewPopoverAnimationController.h: Copied from Source/WebKit2/UIProcess/mac/WKImmediateActionController.h.
+            * UIProcess/mac/WKPreviewPopoverAnimationController.mm: Added.
+            (+[WKPreviewPopoverAnimationController _shouldImmediatelyShowPreview]):
+            (-[WKPreviewPopoverAnimationController initWithURL:view:page:originRect:eventLocationInView:]):
+            (-[WKPreviewPopoverAnimationController close]):
+            (-[WKPreviewPopoverAnimationController setPreviewLoading:]):
+            (-[WKPreviewPopoverAnimationController setPreviewOverrideImage:]):
+            If we have shown the popover, choose a size strictly smaller than
+            its current size.
+
+            (-[WKPreviewPopoverAnimationController _hidePreview]):
+            (-[WKPreviewPopoverAnimationController setPreviewTitle:]):
+            (-[WKPreviewPopoverAnimationController _createPreviewPopover]):
+            (-[WKPreviewPopoverAnimationController _showPreview]):
+            (targetSizeFitsInAvailableSpace):
+            (-[WKPreviewPopoverAnimationController largestPopoverSize]):
+            (-[WKPreviewPopoverAnimationController _targetSizeForPagePreview]):
+            (-[WKPreviewPopoverAnimationController _preferredPopoverSizeWithPreviewPadding:forTargetSize:]):
+            (-[WKPreviewPopoverAnimationController _previewWatchdogTimerFired:]):
+            (-[WKPreviewPopoverAnimationController recognizerWillBeginAnimation:]):
+            (-[WKPreviewPopoverAnimationController recognizerDidUpdateAnimation:]):
+            (-[WKPreviewPopoverAnimationController recognizerDidCancelAnimation:]):
+            (-[WKPreviewPopoverAnimationController recognizerDidCompleteAnimation:]):
+            (-[WKPreviewPopoverAnimationController recognizerDidDismissAnimation:]):
+            (-[WKPreviewPopoverAnimationController pagePreviewViewController:viewForPreviewingURL:initialFrameSize:]):
+            (-[WKPreviewPopoverAnimationController pagePreviewViewController:titleForPreviewOfURL:]):
+            (-[WKPreviewPopoverAnimationController pagePreviewViewControllerWasClicked:]):
+            (-[WKPreviewPopoverAnimationController popoverWillClose:]):
+            Move code in from WKImmediateActionController.
+            Forward NSImmediateActionAnimationControllerDelegate methods
+            to the popover's animation controller if we've popped it.
+            Pop the popover if we've loaded or 1 second has passed, whichever
+            comes first.
+
+            * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2014-12-17  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r177473. rdar://problem/19286550
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedmacActionMenuHitTestResulth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -62,6 +62,8 @@
</span><span class="cx">     WebCore::PageOverlay::PageOverlayID detectedDataOriginatingPageOverlay;
</span><span class="cx"> 
</span><span class="cx">     DictionaryPopupInfo dictionaryPopupInfo;
</span><ins>+
+    RefPtr&lt;WebCore::TextIndicator&gt; linkTextIndicator;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedmacActionMenuHitTestResultmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -63,13 +63,18 @@
</span><span class="cx">         encoder &lt;&lt; detectedDataBoundingBox;
</span><span class="cx">         encoder &lt;&lt; detectedDataOriginatingPageOverlay;
</span><span class="cx"> 
</span><del>-        bool hasTextIndicator = detectedDataTextIndicator;
-        encoder &lt;&lt; hasTextIndicator;
-        if (hasTextIndicator)
</del><ins>+        bool hasDetectedDataTextIndicator = detectedDataTextIndicator;
+        encoder &lt;&lt; hasDetectedDataTextIndicator;
+        if (hasDetectedDataTextIndicator)
</ins><span class="cx">             encoder &lt;&lt; detectedDataTextIndicator-&gt;data();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     encoder &lt;&lt; dictionaryPopupInfo;
</span><ins>+
+    bool hasLinkTextIndicator = linkTextIndicator;
+    encoder &lt;&lt; hasLinkTextIndicator;
+    if (hasLinkTextIndicator)
+        encoder &lt;&lt; linkTextIndicator-&gt;data();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ActionMenuHitTestResult::decode(IPC::ArgumentDecoder&amp; decoder, ActionMenuHitTestResult&amp; actionMenuHitTestResult)
</span><span class="lines">@@ -119,11 +124,11 @@
</span><span class="cx">         if (!decoder.decode(actionMenuHitTestResult.detectedDataOriginatingPageOverlay))
</span><span class="cx">             return false;
</span><span class="cx"> 
</span><del>-        bool hasTextIndicator;
-        if (!decoder.decode(hasTextIndicator))
</del><ins>+        bool hasDetectedDataTextIndicator;
+        if (!decoder.decode(hasDetectedDataTextIndicator))
</ins><span class="cx">             return false;
</span><span class="cx"> 
</span><del>-        if (hasTextIndicator) {
</del><ins>+        if (hasDetectedDataTextIndicator) {
</ins><span class="cx">             WebCore::TextIndicatorData indicatorData;
</span><span class="cx">             if (!decoder.decode(indicatorData))
</span><span class="cx">                 return false;
</span><span class="lines">@@ -135,6 +140,18 @@
</span><span class="cx">     if (!decoder.decode(actionMenuHitTestResult.dictionaryPopupInfo))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    bool hasLinkTextIndicator;
+    if (!decoder.decode(hasLinkTextIndicator))
+        return false;
+
+    if (hasLinkTextIndicator) {
+        WebCore::TextIndicatorData indicatorData;
+        if (!decoder.decode(indicatorData))
+            return false;
+
+        actionMenuHitTestResult.linkTextIndicator = WebCore::TextIndicator::create(indicatorData);
+    }
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx">     
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessAPICocoaWKViewPrivateh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -132,6 +132,7 @@
</span><span class="cx"> - (NSString *)_titleForPreviewOfURL:(NSURL *)url;
</span><span class="cx"> - (void)_setPreviewTitle:(NSString *)previewTitle;
</span><span class="cx"> - (void)_setPreviewLoading:(BOOL)loading;
</span><ins>+- (void)_setPreviewOverrideImage:(NSImage *)image;
</ins><span class="cx"> - (void)_finishPreviewingURL:(NSURL *)url withPreviewView:(NSView *)previewView;
</span><span class="cx"> - (void)_handleClickInPreviewView:(NSView *)previewView URL:(NSURL *)url;
</span><span class="cx"> - (BOOL)_shouldUseStandardQuickLookPreview;
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -4324,7 +4324,7 @@
</span><span class="cx">     if ([actionsManager respondsToSelector:@selector(requestBubbleClosureUnanchorOnFailure:)])
</span><span class="cx">         [actionsManager requestBubbleClosureUnanchorOnFailure:YES];
</span><span class="cx"> 
</span><del>-#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000 &amp;&amp; WK_API_ENABLED
</del><ins>+#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
</ins><span class="cx">     [_data-&gt;_immediateActionController hidePreview];
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -4345,18 +4345,23 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setPreviewTitle:(NSString *)previewTitle
</span><span class="cx"> {
</span><del>-#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000 &amp;&amp; WK_API_ENABLED
</del><ins>+#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
</ins><span class="cx">     [_data-&gt;_immediateActionController setPreviewTitle:previewTitle];
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_setPreviewLoading:(BOOL)loading
</span><span class="cx"> {
</span><del>-#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000 &amp;&amp; WK_API_ENABLED
</del><ins>+#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
</ins><span class="cx">     [_data-&gt;_immediateActionController setPreviewLoading:loading];
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_setPreviewOverrideImage:(NSImage *)image
+{
+    [_data-&gt;_immediateActionController setPreviewOverrideImage:image];
+}
+
</ins><span class="cx"> - (void)_finishPreviewingURL:(NSURL *)url withPreviewView:(NSView *)previewView
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKImmediateActionControllerh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> 
</span><span class="cx"> @class DDActionContext;
</span><span class="cx"> @class WKPagePreviewViewController;
</span><ins>+@class WKPreviewPopoverAnimationController;
</ins><span class="cx"> @class WKView;
</span><span class="cx"> 
</span><span class="cx"> @interface WKImmediateActionController : NSObject &lt;NSImmediateActionGestureRecognizerDelegate&gt; {
</span><span class="lines">@@ -64,12 +65,7 @@
</span><span class="cx">     BOOL _hasActivatedActionContext;
</span><span class="cx">     RetainPtr&lt;DDActionContext&gt; _currentActionContext;
</span><span class="cx"> 
</span><del>-#if WK_API_ENABLED
-    RetainPtr&lt;NSPopover&gt; _previewPopover;
-    String _previewPopoverOriginalURL;
-    NSRect _popoverOriginRect;
-    RetainPtr&lt;WKPagePreviewViewController&gt; _previewViewController;
-#endif
</del><ins>+    RetainPtr&lt;WKPreviewPopoverAnimationController&gt; _previewAnimationController;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)initWithPage:(WebKit::WebPageProxy&amp;)page view:(WKView *)wkView recognizer:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer;
</span><span class="lines">@@ -77,11 +73,10 @@
</span><span class="cx"> - (void)didPerformActionMenuHitTest:(const WebKit::ActionMenuHitTestResult&amp;)hitTestResult userData:(API::Object*)userData;
</span><span class="cx"> - (void)wkView:(WKView *)wkView willHandleMouseDown:(NSEvent *)event;
</span><span class="cx"> 
</span><del>-#if WK_API_ENABLED
</del><span class="cx"> - (void)hidePreview;
</span><span class="cx"> - (void)setPreviewTitle:(NSString *)previewTitle;
</span><span class="cx"> - (void)setPreviewLoading:(BOOL)loading;
</span><del>-#endif // WK_API_ENABLED
</del><ins>+- (void)setPreviewOverrideImage:(NSImage *)image;
</ins><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKImmediateActionControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -30,13 +30,13 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;WKNSURLExtras.h&quot;
</span><span class="cx"> #import &quot;WKPagePreviewViewController.h&quot;
</span><ins>+#import &quot;WKPreviewPopoverAnimationController.h&quot;
</ins><span class="cx"> #import &quot;WKViewInternal.h&quot;
</span><span class="cx"> #import &quot;WebPageMessages.h&quot;
</span><span class="cx"> #import &quot;WebPageProxy.h&quot;
</span><span class="cx"> #import &quot;WebPageProxyMessages.h&quot;
</span><span class="cx"> #import &quot;WebProcessProxy.h&quot;
</span><span class="cx"> #import &lt;WebCore/DataDetectorsSPI.h&gt;
</span><del>-#import &lt;WebCore/GeometryUtilities.h&gt;
</del><span class="cx"> #import &lt;WebCore/LookupSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/NSMenuSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/NSPopoverSPI.h&gt;
</span><span class="lines">@@ -51,14 +51,9 @@
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> using namespace WebKit;
</span><span class="cx"> 
</span><del>-@interface WKImmediateActionController () &lt;NSPopoverDelegate, QLPreviewMenuItemDelegate&gt;
</del><ins>+@interface WKImmediateActionController () &lt;QLPreviewMenuItemDelegate&gt;
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><del>-#if WK_API_ENABLED
-@interface WKImmediateActionController () &lt;WKPagePreviewViewControllerDelegate&gt;
-@end
-#endif
-
</del><span class="cx"> @implementation WKImmediateActionController
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)initWithPage:(WebPageProxy&amp;)page view:(WKView *)wkView recognizer:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
</span><span class="lines">@@ -78,6 +73,8 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)willDestroyView:(WKView *)view
</span><span class="cx"> {
</span><ins>+    [_previewAnimationController close];
+
</ins><span class="cx">     _page = nullptr;
</span><span class="cx">     _wkView = nil;
</span><span class="cx">     _hitTestResult = ActionMenuHitTestResult();
</span><span class="lines">@@ -101,9 +98,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_clearImmediateActionState
</span><span class="cx"> {
</span><del>-#if WK_API_ENABLED
</del><span class="cx">     [self hidePreview];
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx">     _page-&gt;clearTextIndicator();
</span><span class="cx"> 
</span><span class="lines">@@ -144,7 +139,7 @@
</span><span class="cx">     _page-&gt;performActionMenuHitTestAtLocation(_eventLocationInView, true);
</span><span class="cx"> 
</span><span class="cx">     _state = ImmediateActionState::Pending;
</span><del>-    [self _updateImmediateActionItem];
</del><ins>+    immediateActionRecognizer.animationController = nil;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)immediateActionRecognizerWillBeginAnimation:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
</span><span class="lines">@@ -243,14 +238,10 @@
</span><span class="cx">             return (id&lt;NSImmediateActionAnimationController&gt;)qlPreviewLinkItem.get();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-#if WK_API_ENABLED
-        [self _createPreviewPopoverIfNeededForURL:absoluteLinkURL];
</del><span class="cx">         if (id&lt;NSImmediateActionAnimationController&gt; previewController = [self _animationControllerForCustomPreview])
</span><span class="cx">             return previewController;
</span><del>-        return (id&lt;NSImmediateActionAnimationController&gt;)_previewPopover.get();
-#else
</del><span class="cx">         return nil;
</span><del>-#endif // WK_API_ENABLED
</del><ins>+
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (hitTestResult-&gt;isTextNode() || hitTestResult-&gt;isOverTextInsideFormControlElement()) {
</span><span class="lines">@@ -288,189 +279,39 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma mark Link Preview action
</span><span class="cx"> 
</span><del>-#if WK_API_ENABLED
-
-- (void)_createPreviewPopoverIfNeededForURL:(String)absoluteLinkURL
-{
-    if (_previewPopoverOriginalURL == absoluteLinkURL)
-        return;
-
-    _previewPopoverOriginalURL = absoluteLinkURL;
-
-    NSURL *url = [NSURL _web_URLWithWTFString:absoluteLinkURL];
-    RefPtr&lt;WebHitTestResult&gt; hitTestResult = [self _webHitTestResult];
-    _popoverOriginRect = hitTestResult-&gt;elementBoundingBox();
-
-    NSSize previewPadding = [WKPagePreviewViewController previewPadding];
-    NSSize popoverSize = [self _preferredPopoverSizeWithPreviewPadding:previewPadding];
-    CGFloat actualPopoverToViewScale = popoverSize.width / NSWidth(_wkView.bounds);
-    popoverSize.width += previewPadding.width;
-    popoverSize.height += previewPadding.height;
-
-    _previewViewController = adoptNS([[WKPagePreviewViewController alloc] initWithPageURL:url mainViewSize:_wkView.bounds.size popoverToViewScale:actualPopoverToViewScale]);
-    _previewViewController-&gt;_delegate = self;
-    [_previewViewController setLoading:YES];
-    [_previewViewController loadView];
-
-    _previewPopover = adoptNS([[NSPopover alloc] init]);
-    [_previewPopover setBehavior:NSPopoverBehaviorTransient];
-    [_previewPopover setContentSize:popoverSize];
-    [_previewPopover setContentViewController:_previewViewController.get()];
-    [_previewPopover setDelegate:self];
-}
-
</del><span class="cx"> - (void)hidePreview
</span><span class="cx"> {
</span><del>-    if (_previewViewController) {
-        _previewViewController-&gt;_delegate = nil;
-        [_wkView _finishPreviewingURL:_previewViewController-&gt;_url.get() withPreviewView:_previewViewController-&gt;_previewView.get()];
-        _previewViewController = nil;
-    }
-
-    [_previewPopover close];
-    [_previewPopover setDelegate:nil];
-    _previewPopover = nil;
-    _previewPopoverOriginalURL = String();
</del><ins>+    [_previewAnimationController close];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)setPreviewTitle:(NSString *)previewTitle
</span><span class="cx"> {
</span><del>-    [_previewViewController setPreviewTitle:previewTitle];
</del><ins>+    [_previewAnimationController setPreviewTitle:previewTitle];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)setPreviewLoading:(BOOL)loading
</span><span class="cx"> {
</span><del>-    [_previewViewController setLoading:loading];
</del><ins>+    [_previewAnimationController setPreviewLoading:loading];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)popoverWillClose:(NSNotification *)notification
</del><ins>+- (void)setPreviewOverrideImage:(NSImage *)image
</ins><span class="cx"> {
</span><del>-    [self hidePreview];
</del><ins>+    [_previewAnimationController setPreviewOverrideImage:image];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool targetSizeFitsInAvailableSpace(NSSize targetSize, NSSize availableSpace)
-{
-    return targetSize.width &lt;= availableSpace.width &amp;&amp; targetSize.height &lt;= availableSpace.height;
-}
-
-- (NSSize)largestPopoverSize
-{
-    NSSize screenSize = _wkView.window.screen.frame.size;
-
-    if (screenSize.width == 1280 &amp;&amp; screenSize.height == 800)
-        return NSMakeSize(1240, 674);
-
-    if (screenSize.width == 1366 &amp;&amp; screenSize.height == 768)
-        return NSMakeSize(1264, 642);
-
-    if (screenSize.width == 1440 &amp;&amp; screenSize.height == 900)
-        return NSMakeSize(1264, 760);
-
-    if (screenSize.width == 1680 &amp;&amp; screenSize.height == 1050)
-        return NSMakeSize(1324, 910);
-
-    return NSMakeSize(1324, 940);
-}
-
-- (NSSize)_preferredPopoverSizeWithPreviewPadding:(NSSize)previewPadding
-{
-    static const CGFloat preferredPopoverToViewScale = 0.75;
-    static const NSSize screenPadding = {40, 40};
-    static const NSSize smallestPopoverSize = NSMakeSize(500, 500);
-
-    const NSSize effectivePadding = NSMakeSize(screenPadding.width + previewPadding.width, screenPadding.height + previewPadding.height);
-
-    NSWindow *window = _wkView.window;
-    NSRect originScreenRect = [window convertRectToScreen:[_wkView convertRect:_popoverOriginRect toView:nil]];
-    NSRect screenFrame = window.screen.visibleFrame;
-
-    NSRect wkViewBounds = _wkView.bounds;
-    NSSize targetSize = NSMakeSize(NSWidth(wkViewBounds) * preferredPopoverToViewScale, NSHeight(wkViewBounds) * preferredPopoverToViewScale);
-    NSSize largestPopoverSize = [self largestPopoverSize];
-
-    CGFloat availableSpaceAbove = NSMaxY(screenFrame) - NSMaxY(originScreenRect);
-    CGFloat availableSpaceBelow = NSMinY(originScreenRect) - NSMinY(screenFrame);
-    CGFloat maxAvailableVerticalSpace = fmax(availableSpaceAbove, availableSpaceBelow) - effectivePadding.height;
-    NSSize maxSpaceAvailableOnYEdge = NSMakeSize(screenFrame.size.width - effectivePadding.height, maxAvailableVerticalSpace);
-    if (targetSizeFitsInAvailableSpace(targetSize, maxSpaceAvailableOnYEdge) &amp;&amp; targetSizeFitsInAvailableSpace(targetSize, largestPopoverSize))
-        return targetSize;
-
-    CGFloat availableSpaceAtLeft = NSMinX(originScreenRect) - NSMinX(screenFrame);
-    CGFloat availableSpaceAtRight = NSMaxX(screenFrame) - NSMaxX(originScreenRect);
-    CGFloat maxAvailableHorizontalSpace = fmax(availableSpaceAtLeft, availableSpaceAtRight) - effectivePadding.width;
-    NSSize maxSpaceAvailableOnXEdge = NSMakeSize(maxAvailableHorizontalSpace, screenFrame.size.height - effectivePadding.width);
-    if (targetSizeFitsInAvailableSpace(targetSize, maxSpaceAvailableOnXEdge) &amp;&amp; targetSizeFitsInAvailableSpace(targetSize, largestPopoverSize))
-        return targetSize;
-
-    // Adjust the maximum space available if it is larger than the largest popover size.
-    if (maxSpaceAvailableOnYEdge.width &gt; largestPopoverSize.width &amp;&amp; maxSpaceAvailableOnYEdge.height &gt; largestPopoverSize.height)
-        maxSpaceAvailableOnYEdge = largestPopoverSize;
-    if (maxSpaceAvailableOnXEdge.width &gt; largestPopoverSize.width &amp;&amp; maxSpaceAvailableOnXEdge.height &gt; largestPopoverSize.height)
-        maxSpaceAvailableOnXEdge = largestPopoverSize;
-
-    // If the target size doesn't fit anywhere, we'll find the largest rect that does fit that also maintains the original view's aspect ratio.
-    CGFloat aspectRatio = wkViewBounds.size.width / wkViewBounds.size.height;
-    FloatRect maxVerticalTargetSizePreservingAspectRatioRect = largestRectWithAspectRatioInsideRect(aspectRatio, FloatRect(0, 0, maxSpaceAvailableOnYEdge.width, maxSpaceAvailableOnYEdge.height));
-    FloatRect maxHorizontalTargetSizePreservingAspectRatioRect = largestRectWithAspectRatioInsideRect(aspectRatio, FloatRect(0, 0, maxSpaceAvailableOnXEdge.width, maxSpaceAvailableOnXEdge.height));
-
-    NSSize maxVerticalTargetSizePreservingAspectRatio = NSMakeSize(maxVerticalTargetSizePreservingAspectRatioRect.width(), maxVerticalTargetSizePreservingAspectRatioRect.height());
-    NSSize maxHortizontalTargetSizePreservingAspectRatio = NSMakeSize(maxHorizontalTargetSizePreservingAspectRatioRect.width(), maxHorizontalTargetSizePreservingAspectRatioRect.height());
-
-    NSSize computedTargetSize;
-    if ((maxVerticalTargetSizePreservingAspectRatio.width * maxVerticalTargetSizePreservingAspectRatio.height) &gt; (maxHortizontalTargetSizePreservingAspectRatio.width * maxHortizontalTargetSizePreservingAspectRatio.height))
-        computedTargetSize = maxVerticalTargetSizePreservingAspectRatio;
-    else
-        computedTargetSize = maxHortizontalTargetSizePreservingAspectRatio;
-
-    // Now make sure what we've computed isn't too small.
-    if (computedTargetSize.width &lt; smallestPopoverSize.width &amp;&amp; computedTargetSize.height &lt; smallestPopoverSize.height) {
-        float limitWidth = smallestPopoverSize.width &gt; computedTargetSize.width ? smallestPopoverSize.width : computedTargetSize.width;
-        float limitHeight = smallestPopoverSize.height &gt; computedTargetSize.height ? smallestPopoverSize.height : computedTargetSize.height;
-        FloatRect targetRectLargerThanMinSize = largestRectWithAspectRatioInsideRect(aspectRatio, FloatRect(0, 0, limitWidth, limitHeight));
-        computedTargetSize = NSMakeSize(targetRectLargerThanMinSize.size().width(), targetRectLargerThanMinSize.size().height());
-
-        // If our orignal computedTargetSize was so small that we had to get here and make a new computedTargetSize that is
-        // larger than the minimum, then the elementBoundingBox of the _hitTestResult is probably huge. So we should use
-        // the event origin as the popover origin in this case and not worry about obscuring the _hitTestResult.
-        _popoverOriginRect.origin = _eventLocationInView;
-        _popoverOriginRect.size = NSMakeSize(1, 1);
-    }
-    
-    return computedTargetSize;
-}
-
</del><span class="cx"> - (id&lt;NSImmediateActionAnimationController&gt;)_animationControllerForCustomPreview
</span><span class="cx"> {
</span><del>-    Class nsPopoverAnimationControllerClass = NSClassFromString(@&quot;NSPopoverAnimationController&quot;);
-    if (!nsPopoverAnimationControllerClass)
-        return nil;
-    NSPopoverAnimationController *popoverController = [nsPopoverAnimationControllerClass popoverAnimationControllerWithPopover:_previewPopover.get()];
-    popoverController.preferredEdge = NSMaxYEdge;
-    popoverController.anchorView = _wkView;
-    popoverController.positioningRect = _popoverOriginRect;
-    return popoverController;
-}
</del><ins>+    RefPtr&lt;WebHitTestResult&gt; hitTestResult = [self _webHitTestResult];
+    RetainPtr&lt;NSURL&gt; url = [NSURL _web_URLWithWTFString:hitTestResult-&gt;absoluteLinkURL()];
</ins><span class="cx"> 
</span><del>-#pragma mark WKPagePreviewViewControllerDelegate
</del><ins>+    if (_hitTestResult.linkTextIndicator)
+        _page-&gt;setTextIndicator(_hitTestResult.linkTextIndicator-&gt;data(), false);
</ins><span class="cx"> 
</span><del>-- (NSView *)pagePreviewViewController:(WKPagePreviewViewController *)pagePreviewViewController viewForPreviewingURL:(NSURL *)url initialFrameSize:(NSSize)initialFrameSize
-{
-    return [_wkView _viewForPreviewingURL:url initialFrameSize:initialFrameSize];
-}
</del><ins>+    _previewAnimationController = adoptNS([[WKPreviewPopoverAnimationController alloc] initWithURL:url.get() view:_wkView page:*_page originRect:hitTestResult-&gt;elementBoundingBox() eventLocationInView:_eventLocationInView]);
</ins><span class="cx"> 
</span><del>-- (NSString *)pagePreviewViewController:(WKPagePreviewViewController *)pagePreviewViewController titleForPreviewOfURL:(NSURL *)url
-{
-    return [_wkView _titleForPreviewOfURL:url];
</del><ins>+    return _previewAnimationController.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)pagePreviewViewControllerWasClicked:(WKPagePreviewViewController *)pagePreviewViewController
-{
-    if (NSURL *url = pagePreviewViewController-&gt;_url.get())
-        [_wkView _handleClickInPreviewView:pagePreviewViewController-&gt;_previewView.get() URL:url];
-}
-
-#endif // WK_API_ENABLED
-
</del><span class="cx"> #pragma mark QLPreviewMenuItemDelegate implementation
</span><span class="cx"> 
</span><span class="cx"> - (NSView *)menuItem:(NSMenuItem *)menuItem viewAtScreenPoint:(NSPoint)screenPoint
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKPagePreviewViewControllerh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.h (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.h        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.h        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx"> @property (nonatomic, getter=isLoading) BOOL loading;
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)initWithPageURL:(NSURL *)URL mainViewSize:(NSSize)size popoverToViewScale:(CGFloat)scale;
</span><ins>+- (void)replacePreviewWithImage:(NSImage *)image atSize:(NSSize)size;
</ins><span class="cx"> 
</span><span class="cx"> + (NSSize)previewPadding;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKPagePreviewViewControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.mm (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.mm        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.mm        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -26,10 +26,8 @@
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> #import &quot;WKPagePreviewViewController.h&quot;
</span><span class="cx"> 
</span><del>-#import &quot;WKWebViewInternal.h&quot;
</del><ins>+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
</ins><span class="cx"> 
</span><del>-#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000 &amp;&amp; WK_API_ENABLED
-
</del><span class="cx"> static const CGFloat previewViewInset = 3;
</span><span class="cx"> static const CGFloat previewViewTitleHeight = 34;
</span><span class="cx"> 
</span><span class="lines">@@ -74,6 +72,8 @@
</span><span class="cx"> 
</span><span class="cx">     _loading = loading;
</span><span class="cx"> 
</span><ins>+    [_previewView setHidden:loading];
+
</ins><span class="cx">     if (_loading)
</span><span class="cx">         [_spinner startAnimation:nil];
</span><span class="cx">     else
</span><span class="lines">@@ -89,15 +89,7 @@
</span><span class="cx"> {
</span><span class="cx">     NSRect defaultFrame = NSMakeRect(0, 0, _mainViewSize.width, _mainViewSize.height);
</span><span class="cx">     _previewView = [_delegate pagePreviewViewController:self viewForPreviewingURL:_url.get() initialFrameSize:defaultFrame.size];
</span><del>-    if (!_previewView) {
-        RetainPtr&lt;WKWebView&gt; webView = adoptNS([[WKWebView alloc] initWithFrame:defaultFrame]);
-        [webView _setIgnoresNonWheelEvents:YES];
-        if (_url) {
-            NSURLRequest *request = [NSURLRequest requestWithURL:_url.get()];
-            [webView loadRequest:request];
-        }
-        _previewView = webView;
-    }
</del><ins>+    ASSERT(_previewView);
</ins><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;NSClickGestureRecognizer&gt; clickRecognizer = adoptNS([[NSClickGestureRecognizer alloc] initWithTarget:self action:@selector(_clickRecognized:)]);
</span><span class="cx">     [_previewView addGestureRecognizer:clickRecognizer.get()];
</span><span class="lines">@@ -114,6 +106,7 @@
</span><span class="cx">     [containerView addSubview:_previewView.get()];
</span><span class="cx">     [_previewView setFrame:previewFrame];
</span><span class="cx">     [_previewView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
</span><ins>+    [_previewView setHidden:YES];
</ins><span class="cx"> 
</span><span class="cx">     _titleTextField = adoptNS([[NSTextField alloc] init]);
</span><span class="cx">     [_titleTextField setWantsLayer:YES];
</span><span class="lines">@@ -166,6 +159,15 @@
</span><span class="cx">     self.view = containerView.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)replacePreviewWithImage:(NSImage *)image atSize:(NSSize)size
+{
+    RetainPtr&lt;NSClickGestureRecognizer&gt; clickRecognizer = adoptNS([[NSClickGestureRecognizer alloc] initWithTarget:self action:@selector(_clickRecognized:)]);
+    RetainPtr&lt;NSImageView&gt; imageView = adoptNS([[NSImageView alloc] initWithFrame:NSMakeRect(0, 0, size.width, size.height)]);
+    [imageView setImage:image];
+    [imageView addGestureRecognizer:clickRecognizer.get()];
+    self.view = imageView.get();
+}
+
</ins><span class="cx"> - (void)_clickRecognized:(NSGestureRecognizer *)gestureRecognizer
</span><span class="cx"> {
</span><span class="cx">     if (gestureRecognizer.state == NSGestureRecognizerStateBegan)
</span><span class="lines">@@ -174,4 +176,4 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><del>-#endif // PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000 &amp;&amp; WK_API_ENABLED
</del><ins>+#endif // PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
</ins></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKPreviewPopoverAnimationControllerhfromrev177554branchessafari6003branchSourceWebKit2UIProcessmacWKImmediateActionControllerh"></a>
<div class="copfile"><h4>Copied: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPreviewPopoverAnimationController.h (from rev 177554, branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h) (0 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPreviewPopoverAnimationController.h                                (rev 0)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPreviewPopoverAnimationController.h        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#ifndef WKPreviewPopoverAnimationController_h
+#define WKPreviewPopoverAnimationController_h
+
+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
+
+#import &lt;WebCore/NSImmediateActionGestureRecognizerSPI.h&gt;
+#import &lt;wtf/Forward.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+namespace WebKit {
+class WebPageProxy;
+};
+
+@class NSImmediateActionGestureRecognizer;
+@class NSPopoverAnimationController;
+@class NSString;
+@class NSURL;
+@class WKPagePreviewViewController;
+@class WKView;
+
+@interface WKPreviewPopoverAnimationController : NSObject &lt;NSImmediateActionAnimationController&gt; {
+    bool _shouldShowPreviewWhenLoaded;
+    bool _hasFinishedLoading;
+
+    WKView *_wkView;
+    RetainPtr&lt;NSURL&gt; _url;
+    WebKit::WebPageProxy* _page;
+
+    RetainPtr&lt;NSPopover&gt; _previewPopover;
+    NSRect _popoverOriginRect;
+    RetainPtr&lt;WKPagePreviewViewController&gt; _previewViewController;
+    NSPoint _eventLocationInView;
+
+    RetainPtr&lt;NSPopoverAnimationController&gt; _popoverAnimationController;
+
+    NSImmediateActionGestureRecognizer *_recognizer;
+    bool _didCompleteAnimation;
+    RetainPtr&lt;NSTimer&gt; _previewWatchdogTimer;
+}
+
+- (instancetype)initWithURL:(NSURL *)url view:(WKView *)wkView page:(WebKit::WebPageProxy&amp;)page originRect:(NSRect)originRect eventLocationInView:(NSPoint)eventLocationInView;
+- (void)close;
+
+- (void)setPreviewTitle:(NSString *)previewTitle;
+- (void)setPreviewLoading:(BOOL)loading;
+- (void)setPreviewOverrideImage:(NSImage *)image;
+
+@end
+
+
+#endif // PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
+
+#endif // WKPreviewPopoverAnimationController_h
</ins></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKPreviewPopoverAnimationControllermm"></a>
<div class="addfile"><h4>Added: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPreviewPopoverAnimationController.mm (0 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPreviewPopoverAnimationController.mm                                (rev 0)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPreviewPopoverAnimationController.mm        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -0,0 +1,339 @@
</span><ins>+/*
+ * Copyright (C) 2014 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;WKPreviewPopoverAnimationController.h&quot;
+
+#import &quot;WKPagePreviewViewController.h&quot;
+#import &quot;WKViewInternal.h&quot;
+#import &quot;WebPageProxy.h&quot;
+#import &lt;WebCore/FloatRect.h&gt;
+#import &lt;WebCore/GeometryUtilities.h&gt;
+#import &lt;WebCore/NSPopoverSPI.h&gt;
+
+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
+
+using namespace WebCore;
+using namespace WebKit;
+
+@interface WKPreviewPopoverAnimationController () &lt;WKPagePreviewViewControllerDelegate, NSPopoverDelegate&gt;
+@end
+
+@implementation WKPreviewPopoverAnimationController
+
++ (bool)_shouldImmediatelyShowPreview
+{
+    static bool shouldImmediatelyShowPreview;
+    static dispatch_once_t onceToken;
+    dispatch_once(&amp;onceToken, ^{
+        shouldImmediatelyShowPreview = [[NSUserDefaults standardUserDefaults] boolForKey:@&quot;WebKitShouldImmediatelyShowPreview&quot;];
+    });
+    return shouldImmediatelyShowPreview;
+}
+
+- (instancetype)initWithURL:(NSURL *)url view:(WKView *)wkView page:(WebPageProxy&amp;)page originRect:(NSRect)originRect eventLocationInView:(NSPoint)eventLocationInView
+{
+    self = [super init];
+
+    if (!self)
+        return nil;
+
+    _url = url;
+    _wkView = wkView;
+    _page = &amp;page;
+    _popoverOriginRect = originRect;
+
+    // FIXME: We should be able to get this from the recognizer.
+    _eventLocationInView = eventLocationInView;
+
+    return self;
+}
+
+- (void)close
+{
+    [self _hidePreview];
+
+    _wkView = nil;
+    _page = nullptr;
+}
+
+- (void)setPreviewLoading:(BOOL)loading
+{
+    [_previewViewController setLoading:loading];
+    _hasFinishedLoading = !loading;
+    if (!loading &amp;&amp; _shouldShowPreviewWhenLoaded)
+        [self _showPreview];
+}
+
+- (void)setPreviewOverrideImage:(NSImage *)image
+{
+    NSSize imageSize = image.size;
+    NSSize scaledImageSize;
+    if ([_previewPopover isShown]) {
+        NSSize currentPopoverContentSize = [_previewPopover contentSize];
+        float scale = std::min(std::min(currentPopoverContentSize.width / imageSize.width, 1.0), std::min(currentPopoverContentSize.height / imageSize.height, 1.0));
+        scaledImageSize = NSMakeSize(imageSize.width * scale, imageSize.height * scale);
+    } else
+        scaledImageSize = [self _preferredPopoverSizeWithPreviewPadding:[WKPagePreviewViewController previewPadding] forTargetSize:imageSize];
+
+    [_previewPopover setContentSize:scaledImageSize];
+    [_previewViewController replacePreviewWithImage:image atSize:scaledImageSize];
+}
+
+- (void)_hidePreview
+{
+    if (_page)
+        _page-&gt;clearTextIndicator();
+
+    if (_previewViewController) {
+        _previewViewController-&gt;_delegate = nil;
+        [_wkView _finishPreviewingURL:_previewViewController-&gt;_url.get() withPreviewView:_previewViewController-&gt;_previewView.get()];
+        _previewViewController = nil;
+    }
+
+    [_previewPopover close];
+    [_previewPopover setDelegate:nil];
+    _previewPopover = nil;
+}
+
+- (void)setPreviewTitle:(NSString *)previewTitle
+{
+    [_previewViewController setPreviewTitle:previewTitle];
+}
+
+- (void)_createPreviewPopover
+{
+    NSSize previewPadding = [WKPagePreviewViewController previewPadding];
+    NSSize popoverSize = [self _preferredPopoverSizeWithPreviewPadding:previewPadding forTargetSize:[self _targetSizeForPagePreview]];
+    CGFloat actualPopoverToViewScale = popoverSize.width / NSWidth(_wkView.bounds);
+    popoverSize.width += previewPadding.width;
+    popoverSize.height += previewPadding.height;
+
+    _previewViewController = adoptNS([[WKPagePreviewViewController alloc] initWithPageURL:_url.get() mainViewSize:_wkView.bounds.size popoverToViewScale:actualPopoverToViewScale]);
+    _previewViewController-&gt;_delegate = self;
+    [_previewViewController setLoading:YES];
+    [_previewViewController loadView];
+
+    _previewPopover = adoptNS([[NSPopover alloc] init]);
+    [_previewPopover setBehavior:NSPopoverBehaviorTransient];
+    [_previewPopover setContentSize:popoverSize];
+    [_previewPopover setContentViewController:_previewViewController.get()];
+    [_previewPopover setDelegate:self];
+    [_previewPopover setPositioningOptions:NSPopoverPositioningOptionKeepTopStable];
+}
+
+- (void)_showPreview
+{
+    _shouldShowPreviewWhenLoaded = false;
+    [_previewWatchdogTimer invalidate];
+    _previewWatchdogTimer = nil;
+
+    Class nsPopoverAnimationControllerClass = NSClassFromString(@&quot;NSPopoverAnimationController&quot;);
+    if (nsPopoverAnimationControllerClass) {
+        _popoverAnimationController = [nsPopoverAnimationControllerClass popoverAnimationControllerWithPopover:_previewPopover.get()];
+        [_popoverAnimationController setPreferredEdge:NSMaxYEdge];
+        [_popoverAnimationController setAnchorView:_wkView];
+        [_popoverAnimationController setPositioningRect:_popoverOriginRect];
+
+        [_popoverAnimationController recognizerWillBeginAnimation:_recognizer];
+
+        if (_didCompleteAnimation)
+            [_popoverAnimationController recognizerDidCompleteAnimation:_recognizer];
+        else
+            [_popoverAnimationController recognizerDidUpdateAnimation:_recognizer];
+    }
+}
+
+static bool targetSizeFitsInAvailableSpace(NSSize targetSize, NSSize availableSpace)
+{
+    return targetSize.width &lt;= availableSpace.width &amp;&amp; targetSize.height &lt;= availableSpace.height;
+}
+
+- (NSSize)largestPopoverSize
+{
+    NSSize screenSize = _wkView.window.screen.frame.size;
+
+    if (screenSize.width == 1280 &amp;&amp; screenSize.height == 800)
+        return NSMakeSize(1240, 674);
+
+    if (screenSize.width == 1366 &amp;&amp; screenSize.height == 768)
+        return NSMakeSize(1264, 642);
+
+    if (screenSize.width == 1440 &amp;&amp; screenSize.height == 900)
+        return NSMakeSize(1264, 760);
+
+    if (screenSize.width == 1680 &amp;&amp; screenSize.height == 1050)
+        return NSMakeSize(1324, 910);
+
+    return NSMakeSize(1324, 940);
+}
+
+- (NSSize)_targetSizeForPagePreview
+{
+    static const CGFloat preferredPopoverToViewScale = 0.75;
+    NSRect wkViewBounds = _wkView.bounds;
+    return NSMakeSize(NSWidth(wkViewBounds) * preferredPopoverToViewScale, NSHeight(wkViewBounds) * preferredPopoverToViewScale);
+}
+
+- (NSSize)_preferredPopoverSizeWithPreviewPadding:(NSSize)previewPadding forTargetSize:(NSSize)targetSize
+{
+    static const NSSize screenPadding = NSMakeSize(40, 40);
+    static const NSSize smallestPopoverSize = NSMakeSize(500, 500);
+
+    const NSSize effectivePadding = NSMakeSize(screenPadding.width + previewPadding.width, screenPadding.height + previewPadding.height);
+
+    NSWindow *window = _wkView.window;
+    NSRect originScreenRect = [window convertRectToScreen:[_wkView convertRect:_popoverOriginRect toView:nil]];
+    NSRect screenFrame = window.screen.visibleFrame;
+
+    NSSize largestPopoverSize = [self largestPopoverSize];
+
+    CGFloat availableSpaceAbove = NSMaxY(screenFrame) - NSMaxY(originScreenRect);
+    CGFloat availableSpaceBelow = NSMinY(originScreenRect) - NSMinY(screenFrame);
+    CGFloat maxAvailableVerticalSpace = fmax(availableSpaceAbove, availableSpaceBelow) - effectivePadding.height;
+    NSSize maxSpaceAvailableOnYEdge = NSMakeSize(screenFrame.size.width - effectivePadding.height, maxAvailableVerticalSpace);
+    if (targetSizeFitsInAvailableSpace(targetSize, maxSpaceAvailableOnYEdge) &amp;&amp; targetSizeFitsInAvailableSpace(targetSize, largestPopoverSize))
+        return targetSize;
+
+    CGFloat availableSpaceAtLeft = NSMinX(originScreenRect) - NSMinX(screenFrame);
+    CGFloat availableSpaceAtRight = NSMaxX(screenFrame) - NSMaxX(originScreenRect);
+    CGFloat maxAvailableHorizontalSpace = fmax(availableSpaceAtLeft, availableSpaceAtRight) - effectivePadding.width;
+    NSSize maxSpaceAvailableOnXEdge = NSMakeSize(maxAvailableHorizontalSpace, screenFrame.size.height - effectivePadding.width);
+    if (targetSizeFitsInAvailableSpace(targetSize, maxSpaceAvailableOnXEdge) &amp;&amp; targetSizeFitsInAvailableSpace(targetSize, largestPopoverSize))
+        return targetSize;
+
+    // Adjust the maximum space available if it is larger than the largest popover size.
+    if (maxSpaceAvailableOnYEdge.width &gt; largestPopoverSize.width &amp;&amp; maxSpaceAvailableOnYEdge.height &gt; largestPopoverSize.height)
+        maxSpaceAvailableOnYEdge = largestPopoverSize;
+    if (maxSpaceAvailableOnXEdge.width &gt; largestPopoverSize.width &amp;&amp; maxSpaceAvailableOnXEdge.height &gt; largestPopoverSize.height)
+        maxSpaceAvailableOnXEdge = largestPopoverSize;
+
+    // If the target size doesn't fit anywhere, we'll find the largest rect that does fit that also maintains the original view's aspect ratio.
+    CGFloat aspectRatio = targetSize.width / targetSize.height;
+    FloatRect maxVerticalTargetSizePreservingAspectRatioRect = largestRectWithAspectRatioInsideRect(aspectRatio, FloatRect(FloatPoint(), FloatSize(maxSpaceAvailableOnYEdge)));
+    FloatRect maxHorizontalTargetSizePreservingAspectRatioRect = largestRectWithAspectRatioInsideRect(aspectRatio, FloatRect(FloatPoint(), FloatSize(maxSpaceAvailableOnXEdge)));
+
+    NSSize maxVerticalTargetSizePreservingAspectRatio = NSMakeSize(maxVerticalTargetSizePreservingAspectRatioRect.width(), maxVerticalTargetSizePreservingAspectRatioRect.height());
+    NSSize maxHortizontalTargetSizePreservingAspectRatio = NSMakeSize(maxHorizontalTargetSizePreservingAspectRatioRect.width(), maxHorizontalTargetSizePreservingAspectRatioRect.height());
+
+    NSSize computedTargetSize;
+    if ((maxVerticalTargetSizePreservingAspectRatio.width * maxVerticalTargetSizePreservingAspectRatio.height) &gt; (maxHortizontalTargetSizePreservingAspectRatio.width * maxHortizontalTargetSizePreservingAspectRatio.height))
+        computedTargetSize = maxVerticalTargetSizePreservingAspectRatio;
+    else
+        computedTargetSize = maxHortizontalTargetSizePreservingAspectRatio;
+
+    // Now make sure what we've computed isn't too small.
+    if (computedTargetSize.width &lt; smallestPopoverSize.width &amp;&amp; computedTargetSize.height &lt; smallestPopoverSize.height) {
+        float limitWidth = smallestPopoverSize.width &gt; computedTargetSize.width ? smallestPopoverSize.width : computedTargetSize.width;
+        float limitHeight = smallestPopoverSize.height &gt; computedTargetSize.height ? smallestPopoverSize.height : computedTargetSize.height;
+        FloatRect targetRectLargerThanMinSize = largestRectWithAspectRatioInsideRect(aspectRatio, FloatRect(0, 0, limitWidth, limitHeight));
+        computedTargetSize = NSMakeSize(targetRectLargerThanMinSize.size().width(), targetRectLargerThanMinSize.size().height());
+
+        // If our orignal computedTargetSize was so small that we had to get here and make a new computedTargetSize that is
+        // larger than the minimum, then the elementBoundingBox of the _hitTestResult is probably huge. So we should use
+        // the event origin as the popover origin in this case and not worry about obscuring the _hitTestResult.
+        _popoverOriginRect.origin = _eventLocationInView;
+        _popoverOriginRect.size = NSMakeSize(1, 1);
+    }
+    
+    return computedTargetSize;
+}
+
+- (void)_previewWatchdogTimerFired:(NSTimer *)timer
+{
+    [self _showPreview];
+    _previewWatchdogTimer = nil;
+}
+
+#pragma mark NSImmediateActionAnimationController
+
+- (void)recognizerWillBeginAnimation:(NSImmediateActionGestureRecognizer *)recognizer
+{
+    _recognizer = recognizer;
+    _didCompleteAnimation = false;
+    [self _createPreviewPopover];
+
+    if ([self.class _shouldImmediatelyShowPreview])
+        [self _showPreview];
+    else {
+        _shouldShowPreviewWhenLoaded = true;
+        _previewWatchdogTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(_previewWatchdogTimerFired:) userInfo:nil repeats:NO];
+    }
+}
+
+- (void)recognizerDidUpdateAnimation:(NSImmediateActionGestureRecognizer *)recognizer
+{
+    [_popoverAnimationController recognizerDidUpdateAnimation:recognizer];
+}
+
+- (void)recognizerDidCancelAnimation:(NSImmediateActionGestureRecognizer *)recognizer
+{
+    [self _hidePreview];
+
+    [_popoverAnimationController recognizerDidCancelAnimation:recognizer];
+}
+
+- (void)recognizerDidCompleteAnimation:(NSImmediateActionGestureRecognizer *)recognizer
+{
+    _didCompleteAnimation = true;
+    [_popoverAnimationController recognizerDidCompleteAnimation:recognizer];
+}
+
+- (void)recognizerDidDismissAnimation:(NSImmediateActionGestureRecognizer *)recognizer
+{
+    [self _hidePreview];
+
+    [_popoverAnimationController recognizerDidDismissAnimation:recognizer];
+}
+
+#pragma mark WKPagePreviewViewControllerDelegate
+
+- (NSView *)pagePreviewViewController:(WKPagePreviewViewController *)pagePreviewViewController viewForPreviewingURL:(NSURL *)url initialFrameSize:(NSSize)initialFrameSize
+{
+    return [_wkView _viewForPreviewingURL:url initialFrameSize:initialFrameSize];
+}
+
+- (NSString *)pagePreviewViewController:(WKPagePreviewViewController *)pagePreviewViewController titleForPreviewOfURL:(NSURL *)url
+{
+    return [_wkView _titleForPreviewOfURL:url];
+}
+
+- (void)pagePreviewViewControllerWasClicked:(WKPagePreviewViewController *)pagePreviewViewController
+{
+    if (NSURL *url = pagePreviewViewController-&gt;_url.get())
+        [_wkView _handleClickInPreviewView:pagePreviewViewController-&gt;_previewView.get() URL:url];
+}
+
+#pragma mark NSPopoverDelegate
+
+- (void)popoverWillClose:(NSNotification *)notification
+{
+    [self _hidePreview];
+}
+
+@end
+
+
+#endif // PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
</ins></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -560,6 +560,8 @@
</span><span class="cx">                 29D55DF2161BF9F10031A2E3 /* WebPageGroupProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 29D55DF0161BF9F10031A2E3 /* WebPageGroupProxyMessages.h */; };
</span><span class="cx">                 2D0730A219F9C7DA00E9D9C4 /* WKActionMenuController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D0730A019F9C7DA00E9D9C4 /* WKActionMenuController.mm */; };
</span><span class="cx">                 2D0730A319F9C7DA00E9D9C4 /* WKActionMenuController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D0730A119F9C7DA00E9D9C4 /* WKActionMenuController.h */; };
</span><ins>+                2D0B8ACA1A42A39C006D7FC8 /* WKPreviewPopoverAnimationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D0B8AC81A42A39C006D7FC8 /* WKPreviewPopoverAnimationController.h */; };
+                2D0B8ACB1A42A39C006D7FC8 /* WKPreviewPopoverAnimationController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D0B8AC91A42A39C006D7FC8 /* WKPreviewPopoverAnimationController.mm */; };
</ins><span class="cx">                 2D125C5E1857EA05003BA3CB /* ViewGestureController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D125C5C1857EA05003BA3CB /* ViewGestureController.h */; };
</span><span class="cx">                 2D125C5F1857EA05003BA3CB /* ViewGestureControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D125C5D1857EA05003BA3CB /* ViewGestureControllerMac.mm */; };
</span><span class="cx">                 2D1B5D5D185869C8006C6596 /* ViewGestureControllerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D1B5D5B185869C8006C6596 /* ViewGestureControllerMessageReceiver.cpp */; };
</span><span class="lines">@@ -2563,6 +2565,8 @@
</span><span class="cx">                 29D55DF0161BF9F10031A2E3 /* WebPageGroupProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPageGroupProxyMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D0730A019F9C7DA00E9D9C4 /* WKActionMenuController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKActionMenuController.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D0730A119F9C7DA00E9D9C4 /* WKActionMenuController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKActionMenuController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                2D0B8AC81A42A39C006D7FC8 /* WKPreviewPopoverAnimationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPreviewPopoverAnimationController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                2D0B8AC91A42A39C006D7FC8 /* WKPreviewPopoverAnimationController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPreviewPopoverAnimationController.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2D125C5C1857EA05003BA3CB /* ViewGestureController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewGestureController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D125C5D1857EA05003BA3CB /* ViewGestureControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewGestureControllerMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D1B5D5A18586599006C6596 /* ViewGestureController.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = ViewGestureController.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -6653,6 +6657,8 @@
</span><span class="cx">                                 9321D5871A38EE74008052BE /* WKImmediateActionController.mm */,
</span><span class="cx">                                 2DEB346F1A3987AB0030E2BA /* WKPagePreviewViewController.h */,
</span><span class="cx">                                 2DEB34701A3987AB0030E2BA /* WKPagePreviewViewController.mm */,
</span><ins>+                                2D0B8AC81A42A39C006D7FC8 /* WKPreviewPopoverAnimationController.h */,
+                                2D0B8AC91A42A39C006D7FC8 /* WKPreviewPopoverAnimationController.mm */,
</ins><span class="cx">                                 0FCB4E5C18BBE3D9000FCFC9 /* WKPrintingView.h */,
</span><span class="cx">                                 0FCB4E5D18BBE3D9000FCFC9 /* WKPrintingView.mm */,
</span><span class="cx">                                 0FCB4E5E18BBE3D9000FCFC9 /* WKTextInputWindowController.h */,
</span><span class="lines">@@ -7187,6 +7193,7 @@
</span><span class="cx">                                 1A7C6CDB1378950800B9C04D /* EnvironmentVariables.h in Headers */,
</span><span class="cx">                                 1AA575FB1496B52600A4EE06 /* EventDispatcher.h in Headers */,
</span><span class="cx">                                 1A90C1F41264FD71003E44D4 /* FindController.h in Headers */,
</span><ins>+                                2D0B8ACA1A42A39C006D7FC8 /* WKPreviewPopoverAnimationController.h in Headers */,
</ins><span class="cx">                                 515E7728183DD6F60007203F /* AsyncRequest.h in Headers */,
</span><span class="cx">                                 BCE81D8D1319F7EF00241910 /* FontInfo.h in Headers */,
</span><span class="cx">                                 1ABC3DFC1899F51C004F0626 /* WKNavigationDelegate.h in Headers */,
</span><span class="lines">@@ -9122,6 +9129,7 @@
</span><span class="cx">                                 BC72B9FA11E6476B001EB4EA /* WebBackForwardListProxy.cpp in Sources */,
</span><span class="cx">                                 BC111A5A112F4FBB00337BAB /* WebChromeClient.cpp in Sources */,
</span><span class="cx">                                 2D0730A219F9C7DA00E9D9C4 /* WKActionMenuController.mm in Sources */,
</span><ins>+                                2D0B8ACB1A42A39C006D7FC8 /* WKPreviewPopoverAnimationController.mm in Sources */,
</ins><span class="cx">                                 868160D0187645570021E79D /* WindowServerConnection.mm in Sources */,
</span><span class="cx">                                 3F87B9BD158940120090FF62 /* WebColorChooser.cpp in Sources */,
</span><span class="cx">                                 A58B6F0918FCA733008CBA53 /* WKFileUploadPanel.mm in Sources */,
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (177554 => 177555)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-12-19 02:56:17 UTC (rev 177554)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-12-19 02:56:54 UTC (rev 177555)
</span><span class="lines">@@ -999,6 +999,13 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Range&gt; selectionRange = corePage()-&gt;focusController().focusedOrMainFrame().selection().selection().firstRange();
</span><span class="cx"> 
</span><ins>+    URL absoluteLinkURL = hitTestResult.absoluteLinkURL();
+    Node *innerNode = hitTestResult.innerNode();
+    if (!absoluteLinkURL.isEmpty() &amp;&amp; innerNode) {
+        RefPtr&lt;Range&gt; linkRange = rangeOfContents(*innerNode);
+        actionMenuResult.linkTextIndicator = TextIndicator::createWithRange(*linkRange, textIndicatorTransitionForActionMenu(selectionRange.get(), *linkRange, forImmediateAction, false));
+    }
+
</ins><span class="cx">     NSDictionary *options = nil;
</span><span class="cx">     RefPtr&lt;Range&gt; lookupRange = lookupTextAtLocation(locationInViewCooordinates, &amp;options);
</span><span class="cx">     actionMenuResult.lookupText = lookupRange ? lookupRange-&gt;text() : String();
</span></span></pre>
</div>
</div>

</body>
</html>