<!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>[175674] branches/safari-600.3-branch/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/175674">175674</a></dd>
<dt>Author</dt> <dd>dburkart@apple.com</dd>
<dt>Date</dt> <dd>2014-11-05 21:53:29 -0800 (Wed, 05 Nov 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/175632">r175632</a>. <rdar://problems/18774264></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6003branchSourceWebKit2ChangeLog">branches/safari-600.3-branch/Source/WebKit2/ChangeLog</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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6003branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (175673 => 175674)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-11-06 05:50:58 UTC (rev 175673)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-11-06 05:53:29 UTC (rev 175674)
</span><span class="lines">@@ -1,5 +1,52 @@
</span><span class="cx"> 2014-11-05 Dana Burkart <dburkart@apple.com>
</span><span class="cx">
</span><ins>+ Merge r175632. <rdar://problem/18774264>
+
+ 2014-11-05 Beth Dakin <bdakin@apple.com>
+
+ Action menu URL preview should "peek," i.e. appear when the menu item is
+ highlighted
+ https://bugs.webkit.org/show_bug.cgi?id=138432
+ -and corresponding-
+ rdar://problem/18774264
+
+ Reviewed by Anders Carlsson.
+
+ New ivars. Keep a reference to the popover, and a BOOL that indicates whether we
+ should close the popover when the menu goes away.
+ * UIProcess/mac/WKActionMenuController.h:
+ * UIProcess/mac/WKActionMenuController.mm:
+
+ Re-set the preview bool to NO whenever we are about to pop up a new menu.
+ (-[WKActionMenuController prepareForMenu:withEvent:]):
+
+ Close the popover when the menu closes unless _shouldKeepPreviewPopoverOpen has
+ been set.
+ (-[WKActionMenuController didCloseMenu:withEvent:]):
+
+ Set _shouldKeepPreviewPopoverOpen.
+ (-[WKActionMenuController _keepPreviewOpen:]):
+
+ Re-factored to use ivar.
+ (-[WKActionMenuController _previewURLFromActionMenu:]):
+ (-[WKActionMenuController _createPreviewPopoverForURL:]):
+
+ Now call _previewURLFromActionMenu on menu item highlight.
+ (-[WKActionMenuController menu:willHighlightItem:]):
+
+ NSPopover delegate method so that we can keep our BOOL and ivar accurate in the
+ case where the popover is closed by some other mechanism than the action menu
+ going away.
+ (-[WKActionMenuController popoverWillClose:]):
+
+ New selector for the preview. Now when this item is actually selected, we just
+ want to set the BOOL _shouldKeepPreviewPopoverOpen to YES so that we keep the
+ preview open.
+ (-[WKActionMenuController _createActionMenuItemForTag:]):
+
+
+2014-11-05 Dana Burkart <dburkart@apple.com>
+
</ins><span class="cx"> Merge r175630. <rdar://problem/18876437>
</span><span class="cx">
</span><span class="cx"> 2014-11-05 Conrad Shultz <conrad_shultz@apple.com>
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKActionMenuControllerh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.h (175673 => 175674)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.h        2014-11-06 05:50:58 UTC (rev 175673)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.h        2014-11-06 05:53:29 UTC (rev 175674)
</span><span class="lines">@@ -56,8 +56,10 @@
</span><span class="cx"> RefPtr<API::Object> _userData;
</span><span class="cx"> _WKActionMenuType _type;
</span><span class="cx"> RetainPtr<NSSharingServicePicker> _sharingServicePicker;
</span><ins>+ RetainPtr<NSPopover> _previewPopover;
</ins><span class="cx">
</span><span class="cx"> BOOL _isShowingTextIndicator;
</span><ins>+ BOOL _shouldKeepPreviewPopoverOpen;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (instancetype)initWithPage:(WebKit::WebPageProxy&)page view:(WKView *)wkView;
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKActionMenuControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (175673 => 175674)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-11-06 05:50:58 UTC (rev 175673)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-11-06 05:53:29 UTC (rev 175674)
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> using namespace WebKit;
</span><span class="cx">
</span><del>-@interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate>
</del><ins>+@interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSPopoverDelegate>
</ins><span class="cx"> - (void)_updateActionMenuItemsForStage:(MenuUpdateStage)stage;
</span><span class="cx"> - (BOOL)_canAddImageToPhotos;
</span><span class="cx"> - (void)_showTextIndicator;
</span><span class="lines">@@ -132,6 +132,8 @@
</span><span class="cx"> _page = nullptr;
</span><span class="cx"> _wkView = nullptr;
</span><span class="cx"> _hitTestResult = ActionMenuHitTestResult();
</span><ins>+ [_previewPopover setDelegate:nil];
+ _previewPopover = nil;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)prepareForMenu:(NSMenu *)menu withEvent:(NSEvent *)event
</span><span class="lines">@@ -145,6 +147,7 @@
</span><span class="cx"> [self _updateActionMenuItemsForStage:MenuUpdateStage::PrepareForMenu];
</span><span class="cx">
</span><span class="cx"> [self _hideTextIndicator];
</span><ins>+ _shouldKeepPreviewPopoverOpen = NO;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (BOOL)isMenuForTextContent
</span><span class="lines">@@ -177,7 +180,13 @@
</span><span class="cx">
</span><span class="cx"> if (_type == kWKActionMenuDataDetectedItem && menu.numberOfItems > 1)
</span><span class="cx"> [self _hideTextIndicator];
</span><del>-
</del><ins>+
+ if (!_shouldKeepPreviewPopoverOpen) {
+ [_previewPopover close];
+ [_previewPopover setDelegate:nil];
+ _previewPopover = nil;
+ }
+
</ins><span class="cx"> _state = ActionMenuState::None;
</span><span class="cx"> _hitTestResult = ActionMenuHitTestResult();
</span><span class="cx"> _type = kWKActionMenuNone;
</span><span class="lines">@@ -251,24 +260,33 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if WK_API_ENABLED
</span><ins>+- (void)_keepPreviewOpenFromActionMenu:(id)sender
+{
+ _shouldKeepPreviewPopoverOpen = YES;
+}
+
</ins><span class="cx"> - (void)_previewURLFromActionMenu:(id)sender
</span><span class="cx"> {
</span><ins>+ // We might already have a preview showing if the menu item was highlighted earlier.
+ if (_previewPopover)
+ return;
+
</ins><span class="cx"> WebHitTestResult* hitTestResult = _page->lastMouseMoveHitTestResult();
</span><span class="cx"> NSURL *url = [NSURL _web_URLWithWTFString:hitTestResult->absoluteLinkURL()];
</span><del>- RetainPtr<NSPopover> popover = [self _createPreviewPopoverForURL:url];
- [popover showRelativeToRect:hitTestResult->elementBoundingBox() ofView:_wkView preferredEdge:NSMaxYEdge];
</del><ins>+ [self _createPreviewPopoverForURL:url];
+ [_previewPopover showRelativeToRect:hitTestResult->elementBoundingBox() ofView:_wkView preferredEdge:NSMaxYEdge];
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-- (RetainPtr<NSPopover>)_createPreviewPopoverForURL:(NSURL *)url
</del><ins>+- (void)_createPreviewPopoverForURL:(NSURL *)url
</ins><span class="cx"> {
</span><span class="cx"> RetainPtr<WKPagePreviewViewController> previewViewController = adoptNS([[WKPagePreviewViewController alloc] initWithPageURL:url]);
</span><span class="cx"> NSRect wkViewBounds = [_wkView bounds];
</span><span class="cx"> previewViewController->_preferredSize = NSMakeSize(NSWidth(wkViewBounds) * 0.75, NSHeight(wkViewBounds) * 0.75);
</span><span class="cx">
</span><del>- RetainPtr<NSPopover> popover = adoptNS([[NSPopover alloc] init]);
- [popover setBehavior:NSPopoverBehaviorTransient];
- [popover setContentViewController:previewViewController.get()];
- return popover;
</del><ins>+ _previewPopover = adoptNS([[NSPopover alloc] init]);
+ [_previewPopover setBehavior:NSPopoverBehaviorTransient];
+ [_previewPopover setContentViewController:previewViewController.get()];
+ [_previewPopover setDelegate:self];
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -505,6 +523,15 @@
</span><span class="cx"> [self _updateActionMenuItemsForStage:MenuUpdateStage::MenuNeedsUpdate];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
+{
+#if WK_API_ENABLED
+ if (item.tag != kWKContextActionItemTagPreviewLink)
+ return;
+ [self _previewURLFromActionMenu:item];
+#endif
+}
+
</ins><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">@@ -532,6 +559,14 @@
</span><span class="cx"> return _wkView.window;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma mark NSPopoverDelegate implementation
+
+- (void)popoverWillClose:(NSNotification *)notification
+{
+ _shouldKeepPreviewPopoverOpen = NO;
+ _previewPopover = nil;
+}
+
</ins><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">@@ -550,7 +585,7 @@
</span><span class="cx">
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> case kWKContextActionItemTagPreviewLink:
</span><del>- selector = @selector(_previewURLFromActionMenu:);
</del><ins>+ selector = @selector(_keepPreviewOpenFromActionMenu:);
</ins><span class="cx"> title = @"Preview";
</span><span class="cx"> image = [NSImage imageNamed:@"NSActionMenuQuickLook"];
</span><span class="cx"> break;
</span></span></pre>
</div>
</div>
</body>
</html>