<!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>[177339] 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/177339">177339</a></dd>
<dt>Author</dt> <dd>dburkart@apple.com</dd>
<dt>Date</dt> <dd>2014-12-16 00:15:25 -0800 (Tue, 16 Dec 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/177180">r177180</a>. <rdar://problem/19208291></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6003branchSourceWebCoreChangeLog">branches/safari-600.3-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6003branchSourceWebCoreplatformspimacNSImmediateActionGestureRecognizerSPIh">branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2ChangeLog">branches/safari-600.3-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2SharedAPIcWKImmediateActionTypesh">branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessAPImacWKViewmm">branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessmacWKActionMenuControllerh">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessmacWKActionMenuControllermm">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.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="#branchessafari6003branchSourceWebKit2WebKit2xcodeprojprojectpbxproj">branches/safari-600.3-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<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>
</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 (177338 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/ChangeLog        2014-12-16 08:08:44 UTC (rev 177338)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -1,5 +1,47 @@
</span><span class="cx"> 2014-12-16 Dana Burkart <dburkart@apple.com>
</span><span class="cx">
</span><ins>+ Merged r177180. <rdar://problem/19208291>
+
+ 2014-12-11 Timothy Horton <timothy_horton@apple.com>
+
+ Move the preview popover to WKImmediateActionController
+ https://bugs.webkit.org/show_bug.cgi?id=139560
+ <rdar://problem/19208291>
+
+ Reviewed by Beth Dakin.
+
+ * platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h:
+ Add some requisite SPI.
+
+ 2014-12-11 Jer Noble <jer.noble@apple.com>
+
+ [Mac] Crash in -[WebVideoFullscreenHUDWindowController playing] in WK1 clients without FULLSCREEN_API enabled.
+ https://bugs.webkit.org/show_bug.cgi?id=139546
+
+ Reviewed by Eric Carlson.
+
+ Finish the work started by r173230 and rename mediaElement -> videoElement in WebVideoFullscreenHUDWindowController.
+
+ * platform/mac/WebVideoFullscreenHUDWindowController.h:
+ * platform/mac/WebVideoFullscreenHUDWindowController.mm:
+ (-[WebVideoFullscreenHUDWindowController endScrubbing]):
+ (-[WebVideoFullscreenHUDWindowController timelinePositionChanged:]):
+ (-[WebVideoFullscreenHUDWindowController currentTime]):
+ (-[WebVideoFullscreenHUDWindowController setCurrentTime:]):
+ (-[WebVideoFullscreenHUDWindowController duration]):
+ (-[WebVideoFullscreenHUDWindowController decrementVolume]):
+ (-[WebVideoFullscreenHUDWindowController incrementVolume]):
+ (-[WebVideoFullscreenHUDWindowController volume]):
+ (-[WebVideoFullscreenHUDWindowController setVolume:]):
+ (-[WebVideoFullscreenHUDWindowController playing]):
+ (-[WebVideoFullscreenHUDWindowController setPlaying:]):
+ (-[WebVideoFullscreenHUDWindowController remainingTimeText]):
+ (-[WebVideoFullscreenHUDWindowController elapsedTimeText]):
+ (-[WebVideoFullscreenHUDWindowController rewind:]):
+ (-[WebVideoFullscreenHUDWindowController fastForward:]):
+
+2014-12-16 Dana Burkart <dburkart@apple.com>
+
</ins><span class="cx"> Merged r177124. <rdar://problem/19198539>
</span><span class="cx">
</span><span class="cx"> 2014-12-10 Beth Dakin <bdakin@apple.com>
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebCoreplatformspimacNSImmediateActionGestureRecognizerSPIh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h (177338 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h        2014-12-16 08:08:44 UTC (rev 177338)
+++ branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -27,13 +27,26 @@
</span><span class="cx">
</span><span class="cx"> #import <AppKit/NSGestureRecognizer.h>
</span><span class="cx">
</span><del>-#if __has_include(<AppKit/NSImmediateActionGestureRecognizer.h>)
</del><ins>+#if __has_include(<AppKit/NSImmediateActionGestureRecognizer_Private.h>)
</ins><span class="cx">
</span><del>-#import <AppKit/NSImmediateActionGestureRecognizer.h>
</del><ins>+#import <AppKit/NSImmediateActionGestureRecognizer_Private.h>
</ins><span class="cx">
</span><span class="cx"> #else
</span><span class="cx">
</span><ins>+@protocol NSImmediateActionAnimationController <NSObject>
+@optional
+
+- (void)recognizerWillBeginAnimation:(NSImmediateActionGestureRecognizer *)recognizer;
+- (void)recognizerDidUpdateAnimation:(NSImmediateActionGestureRecognizer *)recognizer;
+- (void)recognizerDidCancelAnimation:(NSImmediateActionGestureRecognizer *)recognizer;
+- (void)recognizerDidCompleteAnimation:(NSImmediateActionGestureRecognizer *)recognizer;
+- (void)recognizerDidDismissAnimation:(NSImmediateActionGestureRecognizer *)recognizer;
+@end
+
</ins><span class="cx"> @interface NSImmediateActionGestureRecognizer : NSGestureRecognizer
</span><ins>+
+@property (strong) id<NSImmediateActionAnimationController> animationController;
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif // __has_include(<AppKit/NSImmediateActionGestureRecognizer.h>)
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (177338 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-12-16 08:08:44 UTC (rev 177338)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -1,5 +1,45 @@
</span><span class="cx"> 2014-12-16 Dana Burkart <dburkart@apple.com>
</span><span class="cx">
</span><ins>+ Merged r177180. <rdar://problem/19208291>
+
+ 2014-12-11 Timothy Horton <timothy_horton@apple.com>
+
+ Move the preview popover to WKImmediateActionController
+ https://bugs.webkit.org/show_bug.cgi?id=139560
+ <rdar://problem/19208291>
+
+ Reviewed by Beth Dakin.
+
+ * Shared/API/c/WKImmediateActionTypes.h:
+ Add a link preview type.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView initWithFrame:context:configuration:webView:]):
+ Pass the gesture recognizer to the WKImmediateActionController.
+
+ (-[WKView _setPreviewTitle:]):
+ Forward preview title changes to the WKImmediateActionController,
+ because that's where the preview popover lives now.
+
+ * UIProcess/mac/WKActionMenuController.h:
+ * UIProcess/mac/WKActionMenuController.mm:
+ Move WKPagePreviewViewController into its own file.
+ Move page preview popover related code to WKImmediateActionController.
+
+ * UIProcess/mac/WKImmediateActionController.h:
+ * UIProcess/mac/WKImmediateActionController.mm:
+ Compare the gesture recognizers directly instead of their views, for accuracy.
+ Move page preview popover related code in from WKActionMenuController.
+ Some of this should eventually move to WKPagePreviewViewController, but
+ for now for ease of transition we will move it here.
+
+ * UIProcess/mac/WKPagePreviewViewController.h: Added.
+ * UIProcess/mac/WKPagePreviewViewController.mm: Added.
+ * WebKit2.xcodeproj/project.pbxproj:
+ Move WKPagePreviewViewController into its own file.
+
+2014-12-16 Dana Burkart <dburkart@apple.com>
+
</ins><span class="cx"> Merged r177116. <rdar://problem/19198539>
</span><span class="cx">
</span><span class="cx"> 2014-12-10 Beth Dakin <bdakin@apple.com>
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedAPIcWKImmediateActionTypesh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h (177338 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h        2014-12-16 08:08:44 UTC (rev 177338)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx">
</span><span class="cx"> enum {
</span><span class="cx"> kWKImmediateActionNone = 0,
</span><ins>+ kWKImmediateActionLinkPreview,
</ins><span class="cx"> };
</span><span class="cx"> typedef uint32_t _WKImmediateActionType;
</span><span class="cx">
</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 (177338 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-12-16 08:08:44 UTC (rev 177338)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -3624,7 +3624,7 @@
</span><span class="cx">
</span><span class="cx"> if (Class gestureClass = NSClassFromString(@"NSImmediateActionGestureRecognizer")) {
</span><span class="cx"> RetainPtr<NSImmediateActionGestureRecognizer> recognizer = adoptNS([(NSImmediateActionGestureRecognizer *)[gestureClass alloc] initWithTarget:nil action:NULL]);
</span><del>- _data->_immediateActionController = adoptNS([[WKImmediateActionController alloc] initWithPage:*_data->_page view:self]);
</del><ins>+ _data->_immediateActionController = adoptNS([[WKImmediateActionController alloc] initWithPage:*_data->_page view:self recognizer:recognizer.get()]);
</ins><span class="cx"> [recognizer setDelegate:_data->_immediateActionController.get()];
</span><span class="cx"> [self addGestureRecognizer:recognizer.get()];
</span><span class="cx"> }
</span><span class="lines">@@ -4323,7 +4323,7 @@
</span><span class="cx"> - (void)_setPreviewTitle:(NSString *)previewTitle
</span><span class="cx"> {
</span><span class="cx"> #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
</span><del>- [_data->_actionMenuController setPreviewTitle:previewTitle];
</del><ins>+ [_data->_immediateActionController setPreviewTitle:previewTitle];
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKActionMenuControllerh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.h (177338 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.h        2014-12-16 08:08:44 UTC (rev 177338)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.h        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -48,10 +48,6 @@
</span><span class="cx"> @class DDActionContext;
</span><span class="cx"> @class WKView;
</span><span class="cx">
</span><del>-#if WK_API_ENABLED
-@class WKPagePreviewViewController;
-#endif
-
</del><span class="cx"> @interface WKActionMenuController : NSObject <NSMenuDelegate> {
</span><span class="cx"> @private
</span><span class="cx"> WebKit::WebPageProxy *_page;
</span><span class="lines">@@ -63,18 +59,9 @@
</span><span class="cx"> _WKActionMenuType _type;
</span><span class="cx"> RetainPtr<NSSharingServicePicker> _sharingServicePicker;
</span><span class="cx">
</span><del>- RetainPtr<NSPopover> _previewPopover;
- NSPoint _eventLocationInView;
- NSRect _popoverOriginRect;
-
</del><span class="cx"> BOOL _isShowingTextIndicator;
</span><del>- BOOL _shouldKeepPreviewPopoverOpen;
</del><span class="cx"> BOOL _hasActivatedActionContext;
</span><span class="cx">
</span><del>-#if WK_API_ENABLED
- RetainPtr<WKPagePreviewViewController> _previewViewController;
-#endif
-
</del><span class="cx"> RetainPtr<DDActionContext> _currentActionContext;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -89,7 +76,6 @@
</span><span class="cx"> - (void)didPerformActionMenuHitTest:(const WebKit::ActionMenuHitTestResult&)hitTestResult userData:(API::Object*)userData;
</span><span class="cx">
</span><span class="cx"> - (void)dismissActionMenuPopovers;
</span><del>-- (void)setPreviewTitle:(NSString *)previewTitle;
</del><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKActionMenuControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (177338 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-12-16 08:08:44 UTC (rev 177338)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -30,8 +30,6 @@
</span><span class="cx">
</span><span class="cx"> #import "WKNSURLExtras.h"
</span><span class="cx"> #import "WKViewInternal.h"
</span><del>-#import "WKWebView.h"
-#import "WKWebViewInternal.h"
</del><span class="cx"> #import "WebContext.h"
</span><span class="cx"> #import "WebKitSystemInterface.h"
</span><span class="cx"> #import "WebPageMessages.h"
</span><span class="lines">@@ -42,28 +40,23 @@
</span><span class="cx"> #import <ImageIO/ImageIO.h>
</span><span class="cx"> #import <ImageKit/ImageKit.h>
</span><span class="cx"> #import <WebCore/DataDetectorsSPI.h>
</span><del>-#import <WebCore/GeometryUtilities.h>
</del><span class="cx"> #import <WebCore/LocalizedStrings.h>
</span><span class="cx"> #import <WebCore/LookupSPI.h>
</span><span class="cx"> #import <WebCore/NSMenuSPI.h>
</span><span class="cx"> #import <WebCore/NSSharingServiceSPI.h>
</span><span class="cx"> #import <WebCore/NSSharingServicePickerSPI.h>
</span><span class="cx"> #import <WebCore/NSViewSPI.h>
</span><del>-#import <WebCore/QuickLookMacSPI.h>
</del><span class="cx"> #import <WebCore/SoftLinking.h>
</span><span class="cx"> #import <WebCore/TextIndicator.h>
</span><span class="cx"> #import <WebCore/URL.h>
</span><span class="cx">
</span><del>-SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, QuickLookUI)
-SOFT_LINK_CLASS(QuickLookUI, QLPreviewMenuItem)
-
</del><span class="cx"> SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, ImageKit)
</span><span class="cx"> SOFT_LINK_CLASS(ImageKit, IKSlideshow)
</span><span class="cx">
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> using namespace WebKit;
</span><span class="cx">
</span><del>-@interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSPopoverDelegate, QLPreviewMenuItemDelegate>
</del><ins>+@interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate>
</ins><span class="cx"> - (void)_updateActionMenuItems;
</span><span class="cx"> - (BOOL)_canAddMediaToPhotos;
</span><span class="cx"> - (void)_showTextIndicator;
</span><span class="lines">@@ -75,150 +68,6 @@
</span><span class="cx"> - (NSArray *)_actionMenuItemsForHitTestResult:(WKHitTestResultRef)hitTestResult defaultActionMenuItems:(NSArray *)defaultMenuItems;
</span><span class="cx"> @end
</span><span class="cx">
</span><del>-#if WK_API_ENABLED
-
-static const CGFloat previewViewInset = 3;
-static const CGFloat previewViewTitleHeight = 34;
-
-@class WKPagePreviewViewController;
-
-@protocol WKPagePreviewViewControllerDelegate <NSObject>
-- (NSView *)pagePreviewViewController:(WKPagePreviewViewController *)pagePreviewViewController viewForPreviewingURL:(NSURL *)url initialFrameSize:(NSSize)initialFrameSize;
-- (NSString *)pagePreviewViewController:(WKPagePreviewViewController *)pagePreviewViewController titleForPreviewOfURL:(NSURL *)url;
-- (void)pagePreviewViewControllerWasClicked:(WKPagePreviewViewController *)pagePreviewViewController;
-@end
-
-@interface WKPagePreviewViewController : NSViewController {
-@public
- NSSize _mainViewSize;
- RetainPtr<NSURL> _url;
- RetainPtr<NSView> _previewView;
- RetainPtr<NSTextField> _titleTextField;
- RetainPtr<NSString> _previewTitle;
- id <WKPagePreviewViewControllerDelegate> _delegate;
- CGFloat _popoverToViewScale;
-}
-
-@property (nonatomic, copy) NSString *previewTitle;
-
-- (instancetype)initWithPageURL:(NSURL *)URL mainViewSize:(NSSize)size popoverToViewScale:(CGFloat)scale;
-
-+ (NSSize)previewPadding;
-
-@end
-
-@implementation WKPagePreviewViewController
-
-- (instancetype)initWithPageURL:(NSURL *)URL mainViewSize:(NSSize)size popoverToViewScale:(CGFloat)scale
-{
- if (!(self = [super init]))
- return nil;
-
- _url = URL;
- _mainViewSize = size;
- _popoverToViewScale = scale;
-
- return self;
-}
-
-- (NSString *)previewTitle
-{
- return _previewTitle.get();
-}
-
-- (void)setPreviewTitle:(NSString *)previewTitle
-{
- if ([_previewTitle isEqualToString:previewTitle])
- return;
-
- // Keep a separate copy around in case this is received before the view hierarchy is created.
- _previewTitle = adoptNS([previewTitle copy]);
- [_titleTextField setStringValue:previewTitle ? previewTitle : @""];
-}
-
-+ (NSSize)previewPadding
-{
- return NSMakeSize(2 * previewViewInset, previewViewTitleHeight + 2 * previewViewInset);
-}
-
-- (void)loadView
-{
- NSRect defaultFrame = NSMakeRect(0, 0, _mainViewSize.width, _mainViewSize.height);
- _previewView = [_delegate pagePreviewViewController:self viewForPreviewingURL:_url.get() initialFrameSize:defaultFrame.size];
- if (!_previewView) {
- RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:defaultFrame]);
- [webView _setIgnoresNonWheelEvents:YES];
- if (_url) {
- NSURLRequest *request = [NSURLRequest requestWithURL:_url.get()];
- [webView loadRequest:request];
- }
- _previewView = webView;
- }
-
- RetainPtr<NSClickGestureRecognizer> clickRecognizer = adoptNS([[NSClickGestureRecognizer alloc] initWithTarget:self action:@selector(_clickRecognized:)]);
- [_previewView addGestureRecognizer:clickRecognizer.get()];
-
- NSRect previewFrame = [_previewView frame];
- NSRect containerFrame = previewFrame;
- NSSize totalPadding = [[self class] previewPadding];
- containerFrame.size.width += totalPadding.width;
- containerFrame.size.height += totalPadding.height;
- previewFrame = NSOffsetRect(previewFrame, previewViewInset, previewViewInset);
-
- RetainPtr<NSView> containerView = adoptNS([[NSView alloc] initWithFrame:containerFrame]);
- [containerView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
- [containerView addSubview:_previewView.get()];
- [_previewView setFrame:previewFrame];
- [_previewView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
-
- _titleTextField = adoptNS([[NSTextField alloc] init]);
- [_titleTextField setWantsLayer:YES];
- [_titleTextField setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin];
- [_titleTextField setEditable:NO];
- [_titleTextField setBezeled:NO];
- [_titleTextField setDrawsBackground:NO];
- [_titleTextField setAlignment:NSCenterTextAlignment];
- [_titleTextField setUsesSingleLineMode:YES];
- [_titleTextField setLineBreakMode:NSLineBreakByTruncatingTail];
- [_titleTextField setTextColor:[NSColor labelColor]];
-
- NSString *title = _previewTitle.get();
- if (!title)
- title = [_delegate pagePreviewViewController:self titleForPreviewOfURL:_url.get()];
- if (!title)
- title = [_url absoluteString];
-
- [_titleTextField setStringValue:title ? title : @""];
-
- [_titleTextField sizeToFit];
- NSSize titleFittingSize = [_titleTextField frame].size;
- CGFloat textFieldCenteringOffset = (NSMaxY(containerFrame) - NSMaxY(previewFrame) - titleFittingSize.height) / 2;
-
- NSRect titleFrame = previewFrame;
- titleFrame.size.height = titleFittingSize.height;
- titleFrame.origin.y = NSMaxY(previewFrame) + textFieldCenteringOffset;
- [_titleTextField setFrame:titleFrame];
- [containerView addSubview:_titleTextField.get()];
-
- // Setting the webView bounds will scale it to 75% of the _mainViewSize.
- [_previewView setBounds:NSMakeRect(0, 0, _mainViewSize.width / _popoverToViewScale, _mainViewSize.height / _popoverToViewScale)];
-
- self.view = containerView.get();
-}
-
-- (void)_clickRecognized:(NSGestureRecognizer *)gestureRecognizer
-{
- if (gestureRecognizer.state == NSGestureRecognizerStateBegan)
- [_delegate pagePreviewViewControllerWasClicked:self];
-}
-
-@end
-
-@interface WKActionMenuController () <WKPagePreviewViewControllerDelegate>
-@end
-
-#endif
-
</del><span class="cx"> @implementation WKActionMenuController
</span><span class="cx">
</span><span class="cx"> - (instancetype)initWithPage:(WebPageProxy&)page view:(WKView *)wkView
</span><span class="lines">@@ -255,13 +104,10 @@
</span><span class="cx">
</span><span class="cx"> [self dismissActionMenuPopovers];
</span><span class="cx">
</span><del>- _eventLocationInView = [_wkView convertPoint:event.locationInWindow fromView:nil];
- _page->performActionMenuHitTestAtLocation(_eventLocationInView);
</del><ins>+ _page->performActionMenuHitTestAtLocation([_wkView convertPoint:event.locationInWindow fromView:nil]);
</ins><span class="cx">
</span><span class="cx"> _state = ActionMenuState::Pending;
</span><span class="cx"> [self _updateActionMenuItems];
</span><del>-
- _shouldKeepPreviewPopoverOpen = NO;
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (BOOL)isMenuForTextContent
</span><span class="lines">@@ -290,11 +136,6 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if WK_API_ENABLED
- if (_type == kWKActionMenuLink)
- [self _createPreviewPopover];
-#endif
-
</del><span class="cx"> if (![self isMenuForTextContent]) {
</span><span class="cx"> _page->clearSelection();
</span><span class="cx"> return;
</span><span class="lines">@@ -312,10 +153,6 @@
</span><span class="cx"> if (menu != _wkView.actionMenu)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- [_previewPopover setBehavior:NSPopoverBehaviorTransient];
- if (!_shouldKeepPreviewPopoverOpen)
- [self _clearPreviewPopover];
-
</del><span class="cx"> [self _clearActionMenuState];
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -351,16 +188,8 @@
</span><span class="cx"> [actionsManager requestBubbleClosureUnanchorOnFailure:YES];
</span><span class="cx">
</span><span class="cx"> [self _hideTextIndicator];
</span><del>- [self _clearPreviewPopover];
</del><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)setPreviewTitle:(NSString *)previewTitle
-{
-#if WK_API_ENABLED
- [_previewViewController setPreviewTitle:previewTitle];
-#endif
-}
-
</del><span class="cx"> #pragma mark Text Indicator
</span><span class="cx">
</span><span class="cx"> - (void)_showTextIndicator
</span><span class="lines">@@ -388,25 +217,9 @@
</span><span class="cx"> - (NSArray *)_defaultMenuItemsForLink
</span><span class="cx"> {
</span><span class="cx"> RetainPtr<NSMenuItem> openLinkItem = [self _createActionMenuItemForTag:kWKContextActionItemTagOpenLinkInDefaultBrowser];
</span><del>-
- BOOL shouldUseStandardQuickLookPreview = [_wkView _shouldUseStandardQuickLookPreview] && [NSMenuItem respondsToSelector:@selector(standardQuickLookMenuItem)];
- RetainPtr<NSMenuItem> previewLinkItem;
- RetainPtr<QLPreviewMenuItem> qlPreviewLinkItem;
- if (shouldUseStandardQuickLookPreview) {
- qlPreviewLinkItem = [NSMenuItem standardQuickLookMenuItem];
- [qlPreviewLinkItem setPreviewStyle:QLPreviewStylePopover];
- [qlPreviewLinkItem setDelegate:self];
- } else {
-#if WK_API_ENABLED
- previewLinkItem = [self _createActionMenuItemForTag:kWKContextActionItemTagPreviewLink];
-#else
- previewLinkItem = [NSMenuItem separatorItem];
-#endif
- }
-
</del><span class="cx"> RetainPtr<NSMenuItem> readingListItem = [self _createActionMenuItemForTag:kWKContextActionItemTagAddLinkToSafariReadingList];
</span><span class="cx">
</span><del>- return @[ openLinkItem.get(), shouldUseStandardQuickLookPreview ? qlPreviewLinkItem.get() : previewLinkItem.get(), [NSMenuItem separatorItem], readingListItem.get() ];
</del><ins>+ return @[ openLinkItem.get(), [NSMenuItem separatorItem], [NSMenuItem separatorItem], readingListItem.get() ];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_openURLFromActionMenu:(id)sender
</span><span class="lines">@@ -422,156 +235,6 @@
</span><span class="cx"> [service performWithItems:@[ [NSURL _web_URLWithWTFString:hitTestResult->absoluteLinkURL()] ]];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if WK_API_ENABLED
-- (void)_keepPreviewOpenFromActionMenu:(id)sender
-{
- _shouldKeepPreviewPopoverOpen = YES;
-}
-
-- (void)_previewURLFromActionMenu:(id)sender
-{
- ASSERT(_previewPopover);
-
- // We might already have a preview showing if the menu item was highlighted earlier.
- if ([_previewPopover isShown])
- return;
-
- RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
- dispatch_async(dispatch_get_main_queue(), ^{
- [_previewPopover showRelativeToRect:_popoverOriginRect ofView:_wkView preferredEdge:NSMaxYEdge];
- });
-}
-
-- (void)_createPreviewPopover
-{
- RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
- NSURL *url = [NSURL _web_URLWithWTFString:hitTestResult->absoluteLinkURL()];
- _popoverOriginRect = hitTestResult->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->_delegate = self;
- [_previewViewController loadView];
-
- _previewPopover = adoptNS([[NSPopover alloc] init]);
- [_previewPopover setBehavior:NSPopoverBehaviorApplicationDefined];
- [_previewPopover setContentSize:popoverSize];
- [_previewPopover setContentViewController:_previewViewController.get()];
- [_previewPopover setDelegate:self];
-}
-
-static bool targetSizeFitsInAvailableSpace(NSSize targetSize, NSSize availableSpace)
-{
- return targetSize.width <= availableSpace.width && targetSize.height <= availableSpace.height;
-}
-
-- (NSSize)largestPopoverSize
-{
- NSSize screenSize = _wkView.window.screen.frame.size;
-
- if (screenSize.width == 1280 && screenSize.height == 800)
- return NSMakeSize(1240, 674);
-
- if (screenSize.width == 1366 && screenSize.height == 768)
- return NSMakeSize(1264, 642);
-
- if (screenSize.width == 1440 && screenSize.height == 900)
- return NSMakeSize(1264, 760);
-
- if (screenSize.width == 1680 && 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, 300);
-
- 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) && 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) && targetSizeFitsInAvailableSpace(targetSize, largestPopoverSize))
- return targetSize;
-
- // Adjust the maximum space available if it is larger than the largest popover size.
- if (maxSpaceAvailableOnYEdge.width > largestPopoverSize.width && maxSpaceAvailableOnYEdge.height > largestPopoverSize.height)
- maxSpaceAvailableOnYEdge = largestPopoverSize;
- if (maxSpaceAvailableOnXEdge.width > largestPopoverSize.width && maxSpaceAvailableOnXEdge.height > 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) > (maxHortizontalTargetSizePreservingAspectRatio.width * maxHortizontalTargetSizePreservingAspectRatio.height))
- computedTargetSize = maxVerticalTargetSizePreservingAspectRatio;
- computedTargetSize = maxHortizontalTargetSizePreservingAspectRatio;
-
- // Now make sure what we've computed isn't too small.
- if (computedTargetSize.width < smallestPopoverSize.width && computedTargetSize.height < smallestPopoverSize.height) {
- float limitWidth = smallestPopoverSize.width > computedTargetSize.width ? smallestPopoverSize.width : computedTargetSize.width;
- float limitHeight = smallestPopoverSize.height > 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;
-}
-
-#endif // WK_API_ENABLED
-
-- (void)_clearPreviewPopover
-{
-#if WK_API_ENABLED
- if (_previewViewController) {
- _previewViewController->_delegate = nil;
- [_wkView _finishPreviewingURL:_previewViewController->_url.get() withPreviewView:_previewViewController->_previewView.get()];
- _previewViewController = nil;
- }
-#endif
-
- [_previewPopover close];
- [_previewPopover setDelegate:nil];
- _previewPopover = nil;
-}
-
</del><span class="cx"> #pragma mark Video actions
</span><span class="cx">
</span><span class="cx"> - (NSArray *)_defaultMenuItemsForVideo
</span><span class="lines">@@ -912,15 +575,6 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
-{
-#if WK_API_ENABLED
- if (item.tag != kWKContextActionItemTagPreviewLink)
- return;
- [self _previewURLFromActionMenu:item];
-#endif
-}
-
</del><span class="cx"> #pragma mark NSSharingServicePickerDelegate implementation
</span><span class="cx">
</span><span class="cx"> - (NSArray *)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker sharingServicesForItems:(NSArray *)items mask:(NSSharingServiceMask)mask proposedSharingServices:(NSArray *)proposedServices
</span><span class="lines">@@ -948,35 +602,6 @@
</span><span class="cx"> return _wkView.window;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#pragma mark NSPopoverDelegate implementation
-
-- (void)popoverWillClose:(NSNotification *)notification
-{
- _shouldKeepPreviewPopoverOpen = NO;
- [self _clearPreviewPopover];
-}
-
-#pragma mark QLPreviewMenuItemDelegate implementation
-
-- (NSView *)menuItem:(NSMenuItem *)menuItem viewAtScreenPoint:(NSPoint)screenPoint
-{
- return _wkView;
-}
-
-- (id<QLPreviewItem>)menuItem:(NSMenuItem *)menuItem previewItemAtPoint:(NSPoint)point
-{
- if (!_wkView)
- return nil;
-
- RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
- return [NSURL _web_URLWithWTFString:hitTestResult->absoluteLinkURL()];
-}
-
-- (NSRectEdge)menuItem:(NSMenuItem *)menuItem preferredEdgeForPoint:(NSPoint)point
-{
- return NSMaxYEdge;
-}
-
</del><span class="cx"> #pragma mark Menu Items
</span><span class="cx">
</span><span class="cx"> - (RetainPtr<NSMenuItem>)_createActionMenuItemForTag:(uint32_t)tag
</span><span class="lines">@@ -994,13 +619,9 @@
</span><span class="cx"> image = [NSImage imageNamed:@"NSActionMenuOpenInNewWindow"];
</span><span class="cx"> break;
</span><span class="cx">
</span><del>-#if WK_API_ENABLED
</del><span class="cx"> case kWKContextActionItemTagPreviewLink:
</span><del>- selector = @selector(_keepPreviewOpenFromActionMenu:);
- title = @"";
- image = [NSImage imageNamed:@"NSActionMenuQuickLook"];
</del><ins>+ ASSERT_NOT_REACHED();
</ins><span class="cx"> break;
</span><del>-#endif
</del><span class="cx">
</span><span class="cx"> case kWKContextActionItemTagAddLinkToSafariReadingList:
</span><span class="cx"> selector = @selector(_addToReadingListFromActionMenu:);
</span><span class="lines">@@ -1195,28 +816,6 @@
</span><span class="cx"> [_wkView.actionMenu cancelTracking];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if WK_API_ENABLED
-
-#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->_url.get())
- [_wkView _handleClickInPreviewView:pagePreviewViewController->_previewView.get() URL:url];
-}
-
-#endif
-
</del><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKImmediateActionControllerh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h (177338 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h        2014-12-16 08:08:44 UTC (rev 177338)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -43,6 +43,8 @@
</span><span class="cx"> };
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+@class NSImmediateActionGestureRecognizer;
+@class WKPagePreviewViewController;
</ins><span class="cx"> @class WKView;
</span><span class="cx">
</span><span class="cx"> @interface WKImmediateActionController : NSObject <NSGestureRecognizerDelegate> {
</span><span class="lines">@@ -53,14 +55,24 @@
</span><span class="cx"> WebKit::ImmediateActionState _state;
</span><span class="cx"> WebKit::ActionMenuHitTestResult _hitTestResult;
</span><span class="cx"> _WKImmediateActionType _type;
</span><ins>+ NSImmediateActionGestureRecognizer *_immediateActionRecognizer;
</ins><span class="cx">
</span><span class="cx"> NSPoint _eventLocationInView;
</span><ins>+
+#if WK_API_ENABLED
+ RetainPtr<NSPopover> _previewPopover;
+ String _previewPopoverOriginalURL;
+ NSRect _popoverOriginRect;
+ RetainPtr<WKPagePreviewViewController> _previewViewController;
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-- (instancetype)initWithPage:(WebKit::WebPageProxy&)page view:(WKView *)wkView;
</del><ins>+- (instancetype)initWithPage:(WebKit::WebPageProxy&)page view:(WKView *)wkView recognizer:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer;
</ins><span class="cx"> - (void)willDestroyView:(WKView *)view;
</span><span class="cx"> - (void)didPerformActionMenuHitTest:(const WebKit::ActionMenuHitTestResult&)hitTestResult userData:(API::Object*)userData;
</span><span class="cx">
</span><ins>+- (void)setPreviewTitle:(NSString *)previewTitle;
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKImmediateActionControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm (177338 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm        2014-12-16 08:08:44 UTC (rev 177338)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -28,19 +28,37 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
</span><span class="cx">
</span><ins>+#import "WKNSURLExtras.h"
+#import "WKPagePreviewViewController.h"
</ins><span class="cx"> #import "WKViewInternal.h"
</span><span class="cx"> #import "WebPageMessages.h"
</span><span class="cx"> #import "WebPageProxy.h"
</span><span class="cx"> #import "WebPageProxyMessages.h"
</span><span class="cx"> #import "WebProcessProxy.h"
</span><ins>+#import <WebCore/GeometryUtilities.h>
</ins><span class="cx"> #import <WebCore/NSImmediateActionGestureRecognizerSPI.h>
</span><ins>+#import <WebCore/NSMenuSPI.h>
+#import <WebCore/QuickLookMacSPI.h>
+#import <WebCore/SoftLinking.h>
+#import <WebCore/URL.h>
</ins><span class="cx">
</span><ins>+SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, QuickLookUI)
+SOFT_LINK_CLASS(QuickLookUI, QLPreviewMenuItem)
+
</ins><span class="cx"> using namespace WebCore;
</span><span class="cx"> using namespace WebKit;
</span><span class="cx">
</span><ins>+@interface WKImmediateActionController () <NSPopoverDelegate, QLPreviewMenuItemDelegate>
+@end
+
+#if WK_API_ENABLED
+@interface WKImmediateActionController () <WKPagePreviewViewControllerDelegate>
+@end
+#endif
+
</ins><span class="cx"> @implementation WKImmediateActionController
</span><span class="cx">
</span><del>-- (instancetype)initWithPage:(WebPageProxy&)page view:(WKView *)wkView
</del><ins>+- (instancetype)initWithPage:(WebPageProxy&)page view:(WKView *)wkView recognizer:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
</ins><span class="cx"> {
</span><span class="cx"> self = [super init];
</span><span class="cx">
</span><span class="lines">@@ -50,6 +68,7 @@
</span><span class="cx"> _page = &page;
</span><span class="cx"> _wkView = wkView;
</span><span class="cx"> _type = kWKImmediateActionNone;
</span><ins>+ _immediateActionRecognizer = immediateActionRecognizer;
</ins><span class="cx">
</span><span class="cx"> return self;
</span><span class="cx"> }
</span><span class="lines">@@ -81,7 +100,7 @@
</span><span class="cx">
</span><span class="cx"> - (void)immediateActionRecognizerWillPrepare:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
</span><span class="cx"> {
</span><del>- if (immediateActionRecognizer.view != _wkView)
</del><ins>+ if (immediateActionRecognizer != _immediateActionRecognizer)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> _eventLocationInView = [immediateActionRecognizer locationInView:immediateActionRecognizer.view];
</span><span class="lines">@@ -93,7 +112,7 @@
</span><span class="cx">
</span><span class="cx"> - (void)immediateActionRecognizerWillBeginAnimation:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
</span><span class="cx"> {
</span><del>- if (immediateActionRecognizer.view != _wkView)
</del><ins>+ if (immediateActionRecognizer != _immediateActionRecognizer)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> ASSERT(_state != ImmediateActionState::None);
</span><span class="lines">@@ -114,7 +133,7 @@
</span><span class="cx">
</span><span class="cx"> - (void)immediateActionRecognizerDidCancelAnimation:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
</span><span class="cx"> {
</span><del>- if (immediateActionRecognizer.view != _wkView)
</del><ins>+ if (immediateActionRecognizer != _immediateActionRecognizer)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> [self _clearImmediateActionState];
</span><span class="lines">@@ -122,19 +141,247 @@
</span><span class="cx">
</span><span class="cx"> - (void)immediateActionRecognizerDidCompleteAnimation:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
</span><span class="cx"> {
</span><del>- if (immediateActionRecognizer.view != _wkView)
</del><ins>+ if (immediateActionRecognizer != _immediateActionRecognizer)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // FIXME: Add support for the types of functionality provided in Action menu's willOpenMenu.
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (PassRefPtr<WebHitTestResult>)_webHitTestResult
+{
+ RefPtr<WebHitTestResult> hitTestResult;
+ if (_state == ImmediateActionState::Ready)
+ hitTestResult = WebHitTestResult::create(_hitTestResult.hitTestResult);
+ else
+ hitTestResult = _page->lastMouseMoveHitTestResult();
+
+ return hitTestResult.release();
+}
+
</ins><span class="cx"> #pragma mark Immediate actions
</span><span class="cx">
</span><span class="cx"> - (void)_updateImmediateActionItem
</span><span class="cx"> {
</span><del>- // FIXME: Implement.
</del><ins>+ RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
+
+ _type = kWKImmediateActionNone;
+ _immediateActionRecognizer.animationController = nil;
+
+ if (!hitTestResult)
+ return;
+
+ String absoluteLinkURL = hitTestResult->absoluteLinkURL();
+ if (!absoluteLinkURL.isEmpty() && WebCore::protocolIsInHTTPFamily(absoluteLinkURL)) {
+ _type = kWKImmediateActionLinkPreview;
+
+ BOOL shouldUseStandardQuickLookPreview = [_wkView _shouldUseStandardQuickLookPreview] && [NSMenuItem respondsToSelector:@selector(standardQuickLookMenuItem)];
+ if (shouldUseStandardQuickLookPreview) {
+ RetainPtr<NSMenuItem> previewLinkItem;
+ RetainPtr<QLPreviewMenuItem> qlPreviewLinkItem;
+ if (shouldUseStandardQuickLookPreview) {
+ qlPreviewLinkItem = [NSMenuItem standardQuickLookMenuItem];
+ [qlPreviewLinkItem setPreviewStyle:QLPreviewStylePopover];
+ [qlPreviewLinkItem setDelegate:self];
+ }
+ _immediateActionRecognizer.animationController = (id<NSImmediateActionAnimationController>)qlPreviewLinkItem.get();
+ } else {
+#if WK_API_ENABLED
+ [self _createPreviewPopoverIfNeededForURL:absoluteLinkURL];
+ _immediateActionRecognizer.animationController = (id<NSImmediateActionAnimationController>)_previewPopover.get();
+#endif // WK_API_ENABLED
+ }
+
+ return;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma mark Link Preview action
+
+#if WK_API_ENABLED
+
+- (void)_createPreviewPopoverIfNeededForURL:(String)absoluteLinkURL
+{
+ if (_previewPopoverOriginalURL == absoluteLinkURL)
+ return;
+
+ _previewPopoverOriginalURL = absoluteLinkURL;
+
+ NSURL *url = [NSURL _web_URLWithWTFString:absoluteLinkURL];
+ RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
+ _popoverOriginRect = hitTestResult->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->_delegate = self;
+ [_previewViewController loadView];
+
+ _previewPopover = adoptNS([[NSPopover alloc] init]);
+ [_previewPopover setBehavior:NSPopoverBehaviorTransient];
+ [_previewPopover setContentSize:popoverSize];
+ [_previewPopover setContentViewController:_previewViewController.get()];
+ [_previewPopover setDelegate:self];
+}
+
+- (void)_clearPreviewPopover
+{
+ if (_previewViewController) {
+ _previewViewController->_delegate = nil;
+ [_wkView _finishPreviewingURL:_previewViewController->_url.get() withPreviewView:_previewViewController->_previewView.get()];
+ _previewViewController = nil;
+ }
+
+ [_previewPopover close];
+ [_previewPopover setDelegate:nil];
+ _previewPopover = nil;
+ _previewPopoverOriginalURL = String();
+}
+
+- (void)setPreviewTitle:(NSString *)previewTitle
+{
+ [_previewViewController setPreviewTitle:previewTitle];
+}
+
+- (void)popoverWillClose:(NSNotification *)notification
+{
+ [self _clearPreviewPopover];
+}
+
+static bool targetSizeFitsInAvailableSpace(NSSize targetSize, NSSize availableSpace)
+{
+ return targetSize.width <= availableSpace.width && targetSize.height <= availableSpace.height;
+}
+
+- (NSSize)largestPopoverSize
+{
+ NSSize screenSize = _wkView.window.screen.frame.size;
+
+ if (screenSize.width == 1280 && screenSize.height == 800)
+ return NSMakeSize(1240, 674);
+
+ if (screenSize.width == 1366 && screenSize.height == 768)
+ return NSMakeSize(1264, 642);
+
+ if (screenSize.width == 1440 && screenSize.height == 900)
+ return NSMakeSize(1264, 760);
+
+ if (screenSize.width == 1680 && 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, 300);
+
+ 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) && 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) && targetSizeFitsInAvailableSpace(targetSize, largestPopoverSize))
+ return targetSize;
+
+ // Adjust the maximum space available if it is larger than the largest popover size.
+ if (maxSpaceAvailableOnYEdge.width > largestPopoverSize.width && maxSpaceAvailableOnYEdge.height > largestPopoverSize.height)
+ maxSpaceAvailableOnYEdge = largestPopoverSize;
+ if (maxSpaceAvailableOnXEdge.width > largestPopoverSize.width && maxSpaceAvailableOnXEdge.height > 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) > (maxHortizontalTargetSizePreservingAspectRatio.width * maxHortizontalTargetSizePreservingAspectRatio.height))
+ computedTargetSize = maxVerticalTargetSizePreservingAspectRatio;
+ computedTargetSize = maxHortizontalTargetSizePreservingAspectRatio;
+
+ // Now make sure what we've computed isn't too small.
+ if (computedTargetSize.width < smallestPopoverSize.width && computedTargetSize.height < smallestPopoverSize.height) {
+ float limitWidth = smallestPopoverSize.width > computedTargetSize.width ? smallestPopoverSize.width : computedTargetSize.width;
+ float limitHeight = smallestPopoverSize.height > 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;
+}
+
+#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->_url.get())
+ [_wkView _handleClickInPreviewView:pagePreviewViewController->_previewView.get() URL:url];
+}
+
+#endif // WK_API_ENABLED
+
+#pragma mark QLPreviewMenuItemDelegate implementation
+
+- (NSView *)menuItem:(NSMenuItem *)menuItem viewAtScreenPoint:(NSPoint)screenPoint
+{
+ return _wkView;
+}
+
+- (id<QLPreviewItem>)menuItem:(NSMenuItem *)menuItem previewItemAtPoint:(NSPoint)point
+{
+ if (!_wkView)
+ return nil;
+
+ RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
+ return [NSURL _web_URLWithWTFString:hitTestResult->absoluteLinkURL()];
+}
+
+- (NSRectEdge)menuItem:(NSMenuItem *)menuItem preferredEdgeForPoint:(NSPoint)point
+{
+ return NSMaxYEdge;
+}
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKPagePreviewViewControllerhfromrev177180trunkSourceWebKit2UIProcessmacWKPagePreviewViewControllerh"></a>
<div class="copfile"><h4>Copied: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.h (from rev 177180, trunk/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.h) (0 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.h         (rev 0)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.h        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -0,0 +1,66 @@
</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 WKPagePreviewViewController_h
+#define WKPagePreviewViewController_h
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+
+#import <wtf/RetainPtr.h>
+
+@class NSString;
+@class NSTextField;
+@class NSURL;
+@class NSView;
+@class WKPagePreviewViewController;
+
+@protocol WKPagePreviewViewControllerDelegate <NSObject>
+- (NSView *)pagePreviewViewController:(WKPagePreviewViewController *)pagePreviewViewController viewForPreviewingURL:(NSURL *)url initialFrameSize:(NSSize)initialFrameSize;
+- (NSString *)pagePreviewViewController:(WKPagePreviewViewController *)pagePreviewViewController titleForPreviewOfURL:(NSURL *)url;
+- (void)pagePreviewViewControllerWasClicked:(WKPagePreviewViewController *)pagePreviewViewController;
+@end
+
+@interface WKPagePreviewViewController : NSViewController {
+@public
+ NSSize _mainViewSize;
+ RetainPtr<NSURL> _url;
+ RetainPtr<NSView> _previewView;
+ RetainPtr<NSTextField> _titleTextField;
+ RetainPtr<NSString> _previewTitle;
+ id <WKPagePreviewViewControllerDelegate> _delegate;
+ CGFloat _popoverToViewScale;
+}
+
+@property (nonatomic, copy) NSString *previewTitle;
+
+- (instancetype)initWithPageURL:(NSURL *)URL mainViewSize:(NSSize)size popoverToViewScale:(CGFloat)scale;
+
++ (NSSize)previewPadding;
+
+@end
+
+#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+
+#endif // WKPagePreviewViewController_h
</ins></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKPagePreviewViewControllermmfromrev177180trunkSourceWebKit2UIProcessmacWKPagePreviewViewControllermm"></a>
<div class="copfile"><h4>Copied: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.mm (from rev 177180, trunk/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.mm) (0 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.mm         (rev 0)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKPagePreviewViewController.mm        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -0,0 +1,143 @@
</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 "config.h"
+#import "WKPagePreviewViewController.h"
+
+#import "WKWebViewInternal.h"
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 && WK_API_ENABLED
+
+static const CGFloat previewViewInset = 3;
+static const CGFloat previewViewTitleHeight = 34;
+
+@implementation WKPagePreviewViewController
+
+- (instancetype)initWithPageURL:(NSURL *)URL mainViewSize:(NSSize)size popoverToViewScale:(CGFloat)scale
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _url = URL;
+ _mainViewSize = size;
+ _popoverToViewScale = scale;
+
+ return self;
+}
+
+- (NSString *)previewTitle
+{
+ return _previewTitle.get();
+}
+
+- (void)setPreviewTitle:(NSString *)previewTitle
+{
+ if ([_previewTitle isEqualToString:previewTitle])
+ return;
+
+ // Keep a separate copy around in case this is received before the view hierarchy is created.
+ _previewTitle = adoptNS([previewTitle copy]);
+ [_titleTextField setStringValue:previewTitle ? previewTitle : @""];
+}
+
++ (NSSize)previewPadding
+{
+ return NSMakeSize(2 * previewViewInset, previewViewTitleHeight + 2 * previewViewInset);
+}
+
+- (void)loadView
+{
+ NSRect defaultFrame = NSMakeRect(0, 0, _mainViewSize.width, _mainViewSize.height);
+ _previewView = [_delegate pagePreviewViewController:self viewForPreviewingURL:_url.get() initialFrameSize:defaultFrame.size];
+ if (!_previewView) {
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:defaultFrame]);
+ [webView _setIgnoresNonWheelEvents:YES];
+ if (_url) {
+ NSURLRequest *request = [NSURLRequest requestWithURL:_url.get()];
+ [webView loadRequest:request];
+ }
+ _previewView = webView;
+ }
+
+ RetainPtr<NSClickGestureRecognizer> clickRecognizer = adoptNS([[NSClickGestureRecognizer alloc] initWithTarget:self action:@selector(_clickRecognized:)]);
+ [_previewView addGestureRecognizer:clickRecognizer.get()];
+
+ NSRect previewFrame = [_previewView frame];
+ NSRect containerFrame = previewFrame;
+ NSSize totalPadding = [[self class] previewPadding];
+ containerFrame.size.width += totalPadding.width;
+ containerFrame.size.height += totalPadding.height;
+ previewFrame = NSOffsetRect(previewFrame, previewViewInset, previewViewInset);
+
+ RetainPtr<NSView> containerView = adoptNS([[NSView alloc] initWithFrame:containerFrame]);
+ [containerView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+ [containerView addSubview:_previewView.get()];
+ [_previewView setFrame:previewFrame];
+ [_previewView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+
+ _titleTextField = adoptNS([[NSTextField alloc] init]);
+ [_titleTextField setWantsLayer:YES];
+ [_titleTextField setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin];
+ [_titleTextField setEditable:NO];
+ [_titleTextField setBezeled:NO];
+ [_titleTextField setDrawsBackground:NO];
+ [_titleTextField setAlignment:NSCenterTextAlignment];
+ [_titleTextField setUsesSingleLineMode:YES];
+ [_titleTextField setLineBreakMode:NSLineBreakByTruncatingTail];
+ [_titleTextField setTextColor:[NSColor labelColor]];
+
+ NSString *title = _previewTitle.get();
+ if (!title)
+ title = [_delegate pagePreviewViewController:self titleForPreviewOfURL:_url.get()];
+ if (!title)
+ title = [_url absoluteString];
+
+ [_titleTextField setStringValue:title ? title : @""];
+
+ [_titleTextField sizeToFit];
+ NSSize titleFittingSize = [_titleTextField frame].size;
+ CGFloat textFieldCenteringOffset = (NSMaxY(containerFrame) - NSMaxY(previewFrame) - titleFittingSize.height) / 2;
+
+ NSRect titleFrame = previewFrame;
+ titleFrame.size.height = titleFittingSize.height;
+ titleFrame.origin.y = NSMaxY(previewFrame) + textFieldCenteringOffset;
+ [_titleTextField setFrame:titleFrame];
+ [containerView addSubview:_titleTextField.get()];
+
+ // Setting the webView bounds will scale it to 75% of the _mainViewSize.
+ [_previewView setBounds:NSMakeRect(0, 0, _mainViewSize.width / _popoverToViewScale, _mainViewSize.height / _popoverToViewScale)];
+
+ self.view = containerView.get();
+}
+
+- (void)_clickRecognized:(NSGestureRecognizer *)gestureRecognizer
+{
+ if (gestureRecognizer.state == NSGestureRecognizerStateBegan)
+ [_delegate pagePreviewViewControllerWasClicked:self];
+}
+
+@end
+
+#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 && WK_API_ENABLED
</ins></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (177338 => 177339)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-12-16 08:08:44 UTC (rev 177338)
+++ branches/safari-600.3-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-12-16 08:15:25 UTC (rev 177339)
</span><span class="lines">@@ -632,6 +632,8 @@
</span><span class="cx">                 2DDF731618E95060004F5A66 /* RemoteLayerBackingStoreCollection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DDF731418E95060004F5A66 /* RemoteLayerBackingStoreCollection.mm */; };
</span><span class="cx">                 2DE6943D18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2DE6943B18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp */; };
</span><span class="cx">                 2DE6943E18BD2A68005C15E5 /* SmartMagnificationControllerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DE6943C18BD2A68005C15E5 /* SmartMagnificationControllerMessages.h */; };
</span><ins>+                2DEB34711A3987AB0030E2BA /* WKPagePreviewViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DEB346F1A3987AB0030E2BA /* WKPagePreviewViewController.h */; };
+                2DEB34721A3987AB0030E2BA /* WKPagePreviewViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DEB34701A3987AB0030E2BA /* WKPagePreviewViewController.mm */; };
</ins><span class="cx">                 2DF9593B18A42412009785A1 /* ViewGestureControllerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DF9593418A42412009785A1 /* ViewGestureControllerIOS.mm */; };
</span><span class="cx">                 31099973146C75A20029DEB9 /* WebNotificationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31099971146C759B0029DEB9 /* WebNotificationClient.cpp */; };
</span><span class="cx">                 310999C7146C9E3D0029DEB9 /* WebNotificationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 31099968146C71F50029DEB9 /* WebNotificationClient.h */; };
</span><span class="lines">@@ -2646,6 +2648,8 @@
</span><span class="cx">                 2DDF731418E95060004F5A66 /* RemoteLayerBackingStoreCollection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerBackingStoreCollection.mm; sourceTree = "<group>"; };
</span><span class="cx">                 2DE6943B18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartMagnificationControllerMessageReceiver.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 2DE6943C18BD2A68005C15E5 /* SmartMagnificationControllerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmartMagnificationControllerMessages.h; sourceTree = "<group>"; };
</span><ins>+                2DEB346F1A3987AB0030E2BA /* WKPagePreviewViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPagePreviewViewController.h; sourceTree = "<group>"; };
+                2DEB34701A3987AB0030E2BA /* WKPagePreviewViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPagePreviewViewController.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 2DF9593418A42412009785A1 /* ViewGestureControllerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ViewGestureControllerIOS.mm; path = ios/ViewGestureControllerIOS.mm; sourceTree = "<group>"; };
</span><span class="cx">                 31099968146C71F50029DEB9 /* WebNotificationClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebNotificationClient.h; sourceTree = "<group>"; };
</span><span class="cx">                 31099971146C759B0029DEB9 /* WebNotificationClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNotificationClient.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -6647,6 +6651,8 @@
</span><span class="cx">                                 CDCA85C6132ABA4E00E961DF /* WKFullScreenWindowController.mm */,
</span><span class="cx">                                 9321D5851A38EE3C008052BE /* WKImmediateActionController.h */,
</span><span class="cx">                                 9321D5871A38EE74008052BE /* WKImmediateActionController.mm */,
</span><ins>+                                2DEB346F1A3987AB0030E2BA /* WKPagePreviewViewController.h */,
+                                2DEB34701A3987AB0030E2BA /* WKPagePreviewViewController.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">@@ -7352,6 +7358,7 @@
</span><span class="cx">                                 1A4A9F3312B844E2008FE984 /* PluginQuirks.h in Headers */,
</span><span class="cx">                                 7CD622781739D863005BD7FF /* PluginSandboxProfile.h in Headers */,
</span><span class="cx">                                 1AAB037A185A7C6A00EDF501 /* MessageSender.h in Headers */,
</span><ins>+                                2DEB34711A3987AB0030E2BA /* WKPagePreviewViewController.h in Headers */,
</ins><span class="cx">                                 1A6FB7AF11E64B6800DB1371 /* PluginView.h in Headers */,
</span><span class="cx">                                 1AFE436618B6C081009C7A48 /* UIDelegate.h in Headers */,
</span><span class="cx">                                 E1CC1B9012D7EADF00625838 /* PrintInfo.h in Headers */,
</span><span class="lines">@@ -9480,6 +9487,7 @@
</span><span class="cx">                                 1AC1338518590C4600F3EC05 /* RemoteObjectRegistryMessageReceiver.cpp in Sources */,
</span><span class="cx">                                 BC40760B124FF0270068F20A /* WKURLRequest.cpp in Sources */,
</span><span class="cx">                                 BC40762A124FF0400068F20A /* WKURLRequestNS.mm in Sources */,
</span><ins>+                                2DEB34721A3987AB0030E2BA /* WKPagePreviewViewController.mm in Sources */,
</ins><span class="cx">                                 512A9760180E031D0039A149 /* DatabaseProcessMessageReceiver.cpp in Sources */,
</span><span class="cx">                                 BC40760D124FF0270068F20A /* WKURLResponse.cpp in Sources */,
</span><span class="cx">                                 379A873918BBFE0F00588AF2 /* _WKElementAction.mm in Sources */,
</span></span></pre>
</div>
</div>
</body>
</html>