<!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>[177352] 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/177352">177352</a></dd>
<dt>Author</dt> <dd>dburkart@apple.com</dd>
<dt>Date</dt> <dd>2014-12-16 01:01:53 -0800 (Tue, 16 Dec 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/177323">r177323</a>. <rdar://problem/19198414></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6003branchSourceWebCoreChangeLog">branches/safari-600.3-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6003branchSourceWebCoreplatformspimacLookupSPIh">branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/LookupSPI.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKitmacChangeLog">branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#branchessafari6003branchSourceWebKitmacWebViewWebActionMenuControllermm">branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKitmacWebViewWebImmediateActionControllermm">branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebImmediateActionController.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKitmacWebViewWebUIDelegatePrivateh">branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKitmacWebViewWebViewmm">branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKitmacWebViewWebViewInternalh">branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewInternal.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="#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="#branchessafari6003branchSourceWebKit2UIProcessmacWKActionMenuControllermm">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessmacWKImmediateActionControllermm">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2WebProcessWebPageWebPageh">branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2WebProcessWebPagemacWebPageMacmm">branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.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 (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/ChangeLog        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -1,5 +1,21 @@
</span><span class="cx"> 2014-12-16 Dana Burkart <dburkart@apple.com>
</span><span class="cx">
</span><ins>+ Merged r177323. <rdar://problem/19198414>
+
+ 2014-12-15 Beth Dakin <bdakin@apple.com>
+
+ Make lookup an immediate action instead of an action menu item
+ https://bugs.webkit.org/show_bug.cgi?id=139661
+ -and corresponding-
+ rdar://problem/19198414
+
+ Reviewed by Tim Horton.
+
+ New SPI.
+ * platform/spi/mac/LookupSPI.h:
+
+2014-12-16 Dana Burkart <dburkart@apple.com>
+
</ins><span class="cx"> Merged r177303. <rdar://problem/19198539>
</span><span class="cx">
</span><span class="cx"> 2014-12-15 Timothy Horton <timothy_horton@apple.com>
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebCoreplatformspimacLookupSPIh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/LookupSPI.h (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/LookupSPI.h        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/LookupSPI.h        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -47,4 +47,10 @@
</span><span class="cx">
</span><span class="cx"> #endif // !USE(APPLE_INTERNAL_SDK)
</span><span class="cx">
</span><ins>+@interface LULookupDefinitionModule (AnimationController)
+
++ (id<NSImmediateActionAnimationController>)lookupAnimationControllerForTerm:(NSAttributedString *)term atLocation:(NSPoint)screenPoint options:(NSDictionary *)options;
+
+@end
+
</ins><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -1,5 +1,44 @@
</span><span class="cx"> 2014-12-16 Dana Burkart <dburkart@apple.com>
</span><span class="cx">
</span><ins>+ Merged r177323. <rdar://problem/19198414>
+
+ 2014-12-15 Beth Dakin <bdakin@apple.com>
+
+ Make lookup an immediate action instead of an action menu item
+ https://bugs.webkit.org/show_bug.cgi?id=139661
+ -and corresponding-
+ rdar://problem/19198414
+
+ Reviewed by Tim Horton.
+
+ Remove the lookup menu items and non-unused static function associated with
+ lookup.
+ * WebView/WebActionMenuController.mm:
+ (-[WebActionMenuController _defaultMenuItemsForText]):
+ (-[WebActionMenuController _defaultMenuItemsForEditableText]):
+ (-[WebActionMenuController _defaultMenuItemsForEditableTextWithSuggestions]):
+ (-[WebActionMenuController _createActionMenuItemForTag:]):
+ (-[WebActionMenuController _lookupText:]): Deleted.
+ (performDictionaryLookupForSelection): Deleted.
+ (performDictionaryLookupForRange): Deleted.
+
+ Set the defaultAnimationController to the lookup-provided animation controller
+ when appropriate.
+ * WebView/WebImmediateActionController.mm:
+ (-[WebImmediateActionController _defaultAnimationController]):
+ (dictionaryPopupInfoForRange):
+ (-[WebImmediateActionController _animationControllerForText]):
+
+ New type.
+ * WebView/WebUIDelegatePrivate.h:
+
+ New function to get the lookup animation controller.
+ * WebView/WebView.mm:
+ (-[WebView _animationControllerForDictionaryLookupPopupInfo:]):
+ * WebView/WebViewInternal.h:
+
+2014-12-16 Dana Burkart <dburkart@apple.com>
+
</ins><span class="cx"> Merged r177304. <rdar://problem/19198539>
</span><span class="cx">
</span><span class="cx"> 2014-12-15 Timothy Horton <timothy_horton@apple.com>
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKitmacWebViewWebActionMenuControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> #import "DOMElementInternal.h"
</span><span class="cx"> #import "DOMNodeInternal.h"
</span><span class="cx"> #import "DOMRangeInternal.h"
</span><del>-#import "DictionaryPopupInfo.h"
</del><span class="cx"> #import "WebDocumentInternal.h"
</span><span class="cx"> #import "WebElementDictionary.h"
</span><span class="cx"> #import "WebFrameInternal.h"
</span><span class="lines">@@ -54,7 +53,6 @@
</span><span class="cx"> #import <WebCore/FrameView.h>
</span><span class="cx"> #import <WebCore/HTMLConverter.h>
</span><span class="cx"> #import <WebCore/LocalizedStrings.h>
</span><del>-#import <WebCore/LookupSPI.h>
</del><span class="cx"> #import <WebCore/NSMenuSPI.h>
</span><span class="cx"> #import <WebCore/NSSharingServicePickerSPI.h>
</span><span class="cx"> #import <WebCore/NSSharingServiceSPI.h>
</span><span class="lines">@@ -460,20 +458,18 @@
</span><span class="cx"> - (NSArray *)_defaultMenuItemsForText
</span><span class="cx"> {
</span><span class="cx"> RetainPtr<NSMenuItem> copyTextItem = [self _createActionMenuItemForTag:WebActionMenuItemTagCopyText];
</span><del>- RetainPtr<NSMenuItem> lookupTextItem = [self _createActionMenuItemForTag:WebActionMenuItemTagLookupText];
</del><span class="cx"> RetainPtr<NSMenuItem> pasteItem = [self _createActionMenuItemForTag:WebActionMenuItemTagPaste];
</span><span class="cx"> [pasteItem setEnabled:NO];
</span><span class="cx">
</span><del>- return @[ copyTextItem.get(), lookupTextItem.get(), pasteItem.get() ];
</del><ins>+ return @[ copyTextItem.get(), [NSMenuItem separatorItem], pasteItem.get() ];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (NSArray *)_defaultMenuItemsForEditableText
</span><span class="cx"> {
</span><span class="cx"> RetainPtr<NSMenuItem> copyTextItem = [self _createActionMenuItemForTag:WebActionMenuItemTagCopyText];
</span><del>- RetainPtr<NSMenuItem> lookupTextItem = [self _createActionMenuItemForTag:WebActionMenuItemTagLookupText];
</del><span class="cx"> RetainPtr<NSMenuItem> pasteItem = [self _createActionMenuItemForTag:WebActionMenuItemTagPaste];
</span><span class="cx">
</span><del>- return @[ copyTextItem.get(), lookupTextItem.get(), pasteItem.get() ];
</del><ins>+ return @[ copyTextItem.get(), [NSMenuItem separatorItem], pasteItem.get() ];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (NSArray *)_defaultMenuItemsForEditableTextWithSuggestions
</span><span class="lines">@@ -510,13 +506,12 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RetainPtr<NSMenuItem> copyTextItem = [self _createActionMenuItemForTag:WebActionMenuItemTagCopyText];
</span><del>- RetainPtr<NSMenuItem> lookupTextItem = [self _createActionMenuItemForTag:WebActionMenuItemTagLookupText];
</del><span class="cx"> RetainPtr<NSMenuItem> pasteItem = [self _createActionMenuItemForTag:WebActionMenuItemTagPaste];
</span><span class="cx"> RetainPtr<NSMenuItem> textSuggestionsItem = [self _createActionMenuItemForTag:WebActionMenuItemTagTextSuggestions];
</span><span class="cx">
</span><span class="cx"> [textSuggestionsItem setSubmenu:spellingSubMenu.get()];
</span><span class="cx">
</span><del>- return @[ copyTextItem.get(), lookupTextItem.get(), pasteItem.get(), textSuggestionsItem.get() ];
</del><ins>+ return @[ copyTextItem.get(), [NSMenuItem separatorItem], pasteItem.get(), textSuggestionsItem.get() ];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_selectDataDetectedText
</span><span class="lines">@@ -576,16 +571,6 @@
</span><span class="cx"> [_webView copy:self];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_lookupText:(id)sender
-{
- Frame* frame = core([_webView _selectedOrMainFrame]);
- if (!frame)
- return;
-
- DictionaryPopupInfo popupInfo = performDictionaryLookupForSelection(frame, frame->selection().selection());
- [_webView _showDictionaryLookupPopup:popupInfo];
-}
-
</del><span class="cx"> - (void)_paste:(id)sender
</span><span class="cx"> {
</span><span class="cx"> [_webView paste:self];
</span><span class="lines">@@ -617,56 +602,6 @@
</span><span class="cx"> [documentView _changeSpellingToWord:selectedCorrection];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static DictionaryPopupInfo performDictionaryLookupForSelection(Frame* frame, const VisibleSelection& selection)
-{
- NSDictionary *options = nil;
- DictionaryPopupInfo popupInfo;
- RefPtr<Range> selectedRange = rangeForDictionaryLookupForSelection(selection, &options);
- if (selectedRange)
- popupInfo = performDictionaryLookupForRange(frame, *selectedRange, options, TextIndicatorPresentationTransition::BounceAndCrossfade);
- return popupInfo;
-}
-
-static DictionaryPopupInfo performDictionaryLookupForRange(Frame* frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
-{
- DictionaryPopupInfo popupInfo;
- if (range.text().stripWhiteSpace().isEmpty())
- return popupInfo;
-
- RenderObject* renderer = range.startContainer()->renderer();
- const RenderStyle& style = renderer->style();
-
- Vector<FloatQuad> quads;
- range.textQuads(quads);
- if (quads.isEmpty())
- return popupInfo;
-
- IntRect rangeRect = frame->view()->contentsToWindow(quads[0].enclosingBoundingBox());
-
- popupInfo.origin = NSMakePoint(rangeRect.x(), rangeRect.y() + (style.fontMetrics().descent() * frame->page()->pageScaleFactor()));
- popupInfo.options = options;
-
- NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range, IncludeImagesInAttributedString::No);
- RetainPtr<NSMutableAttributedString> scaledNSAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[nsAttributedString string]]);
- NSFontManager *fontManager = [NSFontManager sharedFontManager];
-
- [nsAttributedString enumerateAttributesInRange:NSMakeRange(0, [nsAttributedString length]) options:0 usingBlock:^(NSDictionary *attributes, NSRange range, BOOL *stop) {
- RetainPtr<NSMutableDictionary> scaledAttributes = adoptNS([attributes mutableCopy]);
-
- NSFont *font = [scaledAttributes objectForKey:NSFontAttributeName];
- if (font) {
- font = [fontManager convertFont:font toSize:[font pointSize] * frame->page()->pageScaleFactor()];
- [scaledAttributes setObject:font forKey:NSFontAttributeName];
- }
-
- [scaledNSAttributedString addAttributes:scaledAttributes.get() range:range];
- }];
-
- popupInfo.attributedString = scaledNSAttributedString.get();
- popupInfo.textIndicator = TextIndicator::createWithRange(range, presentationTransition);
- return popupInfo;
-}
-
</del><span class="cx"> #pragma mark Whitespace actions
</span><span class="cx">
</span><span class="cx"> - (NSArray *)_defaultMenuItemsForWhitespaceInEditableArea
</span><span class="lines">@@ -734,13 +669,6 @@
</span><span class="cx"> enabled = _hitTestResult.allowsCopy();
</span><span class="cx"> break;
</span><span class="cx">
</span><del>- case WebActionMenuItemTagLookupText:
- selector = @selector(_lookupText:);
- title = WEB_UI_STRING_KEY("Look Up", "Look Up (action menu item)", "action menu item");
- image = [NSImage imageNamed:@"NSActionMenuLookup"];
- enabled = getLULookupDefinitionModuleClass() && _hitTestResult.allowsCopy();
- break;
-
</del><span class="cx"> case WebActionMenuItemTagPaste:
</span><span class="cx"> selector = @selector(_paste:);
</span><span class="cx"> title = WEB_UI_STRING_KEY("Paste", "Paste (action menu item)", "action menu item");
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKitmacWebViewWebImmediateActionControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebImmediateActionController.mm (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebImmediateActionController.mm        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebImmediateActionController.mm        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #import "DOMElementInternal.h"
</span><span class="cx"> #import "DOMNodeInternal.h"
</span><span class="cx"> #import "DOMRangeInternal.h"
</span><ins>+#import "DictionaryPopupInfo.h"
</ins><span class="cx"> #import "WebElementDictionary.h"
</span><span class="cx"> #import "WebFrameInternal.h"
</span><span class="cx"> #import "WebHTMLView.h"
</span><span class="lines">@@ -38,9 +39,15 @@
</span><span class="cx"> #import "WebViewInternal.h"
</span><span class="cx"> #import <WebCore/DataDetection.h>
</span><span class="cx"> #import <WebCore/DataDetectorsSPI.h>
</span><ins>+#import <WebCore/DictionaryLookup.h>
</ins><span class="cx"> #import <WebCore/EventHandler.h>
</span><span class="cx"> #import <WebCore/Frame.h>
</span><ins>+#import <WebCore/FrameView.h>
+#import <WebCore/HTMLConverter.h>
+#import <WebCore/LookupSPI.h>
</ins><span class="cx"> #import <WebCore/NSMenuSPI.h>
</span><ins>+#import <WebCore/Page.h>
+#import <WebCore/RenderObject.h>
</ins><span class="cx"> #import <WebCore/SoftLinking.h>
</span><span class="cx"> #import <WebCore/TextIndicator.h>
</span><span class="cx"> #import <objc/objc-class.h>
</span><span class="lines">@@ -176,6 +183,11 @@
</span><span class="cx"> _type = WebImmediateActionDataDetectedItem;
</span><span class="cx"> return (id<NSImmediateActionAnimationController>)immediateActionItem;
</span><span class="cx"> }
</span><ins>+
+ if (id<NSImmediateActionAnimationController> defaultTextController = [self _animationControllerForText]) {
+ _type = WebImmediateActionText;
+ return defaultTextController;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return nil;
</span><span class="lines">@@ -277,6 +289,71 @@
</span><span class="cx"> return menuItems.lastObject;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma mark Text action
+
+static DictionaryPopupInfo dictionaryPopupInfoForRange(Frame* frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
+{
+ DictionaryPopupInfo popupInfo;
+ if (range.text().stripWhiteSpace().isEmpty())
+ return popupInfo;
+
+ RenderObject* renderer = range.startContainer()->renderer();
+ const RenderStyle& style = renderer->style();
+
+ Vector<FloatQuad> quads;
+ range.textQuads(quads);
+ if (quads.isEmpty())
+ return popupInfo;
+
+ IntRect rangeRect = frame->view()->contentsToWindow(quads[0].enclosingBoundingBox());
+
+ popupInfo.origin = NSMakePoint(rangeRect.x(), rangeRect.y() + (style.fontMetrics().descent() * frame->page()->pageScaleFactor()));
+ popupInfo.options = options;
+
+ NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range, IncludeImagesInAttributedString::No);
+ RetainPtr<NSMutableAttributedString> scaledNSAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[nsAttributedString string]]);
+ NSFontManager *fontManager = [NSFontManager sharedFontManager];
+
+ [nsAttributedString enumerateAttributesInRange:NSMakeRange(0, [nsAttributedString length]) options:0 usingBlock:^(NSDictionary *attributes, NSRange range, BOOL *stop) {
+ RetainPtr<NSMutableDictionary> scaledAttributes = adoptNS([attributes mutableCopy]);
+
+ NSFont *font = [scaledAttributes objectForKey:NSFontAttributeName];
+ if (font) {
+ font = [fontManager convertFont:font toSize:[font pointSize] * frame->page()->pageScaleFactor()];
+ [scaledAttributes setObject:font forKey:NSFontAttributeName];
+ }
+
+ [scaledNSAttributedString addAttributes:scaledAttributes.get() range:range];
+ }];
+
+ popupInfo.attributedString = scaledNSAttributedString.get();
+ popupInfo.textIndicator = TextIndicator::createWithRange(range, presentationTransition);
+ return popupInfo;
+}
+
+- (id<NSImmediateActionAnimationController>)_animationControllerForText
+{
+ if (!getLULookupDefinitionModuleClass())
+ return nil;
+
+ Node* node = _hitTestResult.innerNode();
+ if (!node)
+ return nil;
+
+ Frame* frame = node->document().frame();
+ if (!frame)
+ return nil;
+
+ NSDictionary *options = nil;
+ RefPtr<Range> dictionaryRange = rangeForDictionaryLookupAtHitTestResult(_hitTestResult, &options);
+
+ DictionaryPopupInfo dictionaryPopupInfo = dictionaryPopupInfoForRange(frame, *dictionaryRange, options, TextIndicatorPresentationTransition::Bounce);
+ if (!dictionaryPopupInfo.attributedString)
+ return nil;
+
+ return [_webView _animationControllerForDictionaryLookupPopupInfo:dictionaryPopupInfo];
+}
+
</ins><span class="cx"> #pragma mark Text Indicator
</span><span class="cx">
</span><span class="cx"> - (void)_showTextIndicator
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKitmacWebViewWebUIDelegatePrivateh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -147,7 +147,8 @@
</span><span class="cx"> typedef enum {
</span><span class="cx"> WebImmediateActionNone = 0,
</span><span class="cx"> WebImmediateActionLinkPreview,
</span><del>- WebImmediateActionDataDetectedItem
</del><ins>+ WebImmediateActionDataDetectedItem,
+ WebImmediateActionText
</ins><span class="cx"> } WebImmediateActionType;
</span><span class="cx">
</span><span class="cx"> // Message Sources.
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -8656,6 +8656,33 @@
</span><span class="cx"> [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (id)_animationControllerForDictionaryLookupPopupInfo:(const DictionaryPopupInfo&)dictionaryPopupInfo
+{
+ if (!dictionaryPopupInfo.attributedString)
+ return nil;
+
+ NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
+
+ // Convert to screen coordinates.
+ textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
+
+ if (canLoadLUTermOptionDisableSearchTermIndicator() && canLoadLUNotificationPopoverWillClose()) {
+ if (!_private->hasInitializedLookupObserver) {
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil];
+ _private->hasInitializedLookupObserver = YES;
+ }
+
+ RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([dictionaryPopupInfo.options mutableCopy]);
+ if (!mutableOptions)
+ mutableOptions = adoptNS([[NSMutableDictionary alloc] init]);
+ [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
+ [self _setTextIndicator:dictionaryPopupInfo.textIndicator.get() fadeOut:NO animationCompletionHandler:[] { }];
+ return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
+ }
+
+ return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
+}
+
</ins><span class="cx"> - (void)_dictionaryLookupPopoverWillClose:(NSNotification *)notification
</span><span class="cx"> {
</span><span class="cx"> [self _setTextIndicator:nullptr fadeOut:NO animationCompletionHandler:[] { }];
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKitmacWebViewWebViewInternalh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewInternal.h (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewInternal.h        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewInternal.h        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -261,6 +261,7 @@
</span><span class="cx"> - (void)_setTextIndicator:(WebCore::TextIndicator*)textIndicator fadeOut:(BOOL)fadeOut animationCompletionHandler:(std::function<void ()>)completionHandler;
</span><span class="cx"> - (void)_clearTextIndicator;
</span><span class="cx"> - (void)_showDictionaryLookupPopup:(const DictionaryPopupInfo&)dictionaryPopupInfo;
</span><ins>+- (id)_animationControllerForDictionaryLookupPopupInfo:(const DictionaryPopupInfo&)dictionaryPopupInfo;
</ins><span class="cx"> #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
</span><span class="cx"> - (WebActionMenuController *)_actionMenuController;
</span><span class="cx"> - (WebImmediateActionController *)_immediateActionController;
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -1,5 +1,52 @@
</span><span class="cx"> 2014-12-16 Dana Burkart <dburkart@apple.com>
</span><span class="cx">
</span><ins>+ Merged r177323. <rdar://problem/19198414>
+
+ 2014-12-15 Beth Dakin <bdakin@apple.com>
+
+ Make lookup an immediate action instead of an action menu item
+ https://bugs.webkit.org/show_bug.cgi?id=139661
+ -and corresponding-
+ rdar://problem/19198414
+
+ Reviewed by Tim Horton.
+
+ New type.
+ * Shared/API/c/WKImmediateActionTypes.h:
+
+ ActionMenuHitTestResult now includes a DictionaryPopupInfo.
+ * Shared/mac/ActionMenuHitTestResult.h:
+ * Shared/mac/ActionMenuHitTestResult.mm:
+ (WebKit::ActionMenuHitTestResult::encode):
+ (WebKit::ActionMenuHitTestResult::decode):
+
+ Remove all lookup menu items.
+ * UIProcess/mac/WKActionMenuController.mm:
+ (-[WKActionMenuController _defaultMenuItemsForText]):
+ (-[WKActionMenuController _defaultMenuItemsForEditableText]):
+ (-[WKActionMenuController _defaultMenuItemsForEditableTextWithSuggestions]):
+ (-[WKActionMenuController _createActionMenuItemForTag:]):
+ (-[WKActionMenuController _lookupText:]): Deleted.
+
+ Set the defaultAnimationController to the lookup-provided animation controller
+ when appropriate.
+ * UIProcess/mac/WKImmediateActionController.mm:
+ (-[WKImmediateActionController _defaultAnimationController]):
+ (-[WKImmediateActionController _animationControllerForText]):
+
+ Re-factor performDictionaryLookupForRange() so that most of the work is done in a
+ new function called dictionaryPopupInfoForRange(). This was that code can be used
+ for both performing a dictionary lookup and just getting the DictionaryPopupInfo
+ for the ActionMenuHitTest.
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::dictionaryPopupInfoForRange):
+ (WebKit::WebPage::performDictionaryLookupForRange):
+ (WebKit::WebPage::performActionMenuHitTestAtLocation):
+ (WebKit::WebPage::lookupTextAtLocation):
+
+2014-12-16 Dana Burkart <dburkart@apple.com>
+
</ins><span class="cx"> Merged r177303. <rdar://problem/19198539>
</span><span class="cx">
</span><span class="cx"> 2014-12-15 Timothy Horton <timothy_horton@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 (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> kWKImmediateActionNone = 0,
</span><span class="cx"> kWKImmediateActionLinkPreview,
</span><span class="cx"> kWKImmediateActionDataDetectedItem,
</span><ins>+ kWKImmediateActionLookupText,
</ins><span class="cx"> };
</span><span class="cx"> typedef uint32_t _WKImmediateActionType;
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedmacActionMenuHitTestResulth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #define ActionMenuHitTestResult_h
</span><span class="cx">
</span><span class="cx"> #include "DataReference.h"
</span><ins>+#include "DictionaryPopupInfo.h"
</ins><span class="cx"> #include "ShareableBitmap.h"
</span><span class="cx"> #include "SharedMemory.h"
</span><span class="cx"> #include "WebHitTestResult.h"
</span><span class="lines">@@ -59,6 +60,8 @@
</span><span class="cx"> WebCore::FloatRect detectedDataBoundingBox;
</span><span class="cx"> RefPtr<WebCore::TextIndicator> detectedDataTextIndicator;
</span><span class="cx"> WebCore::PageOverlay::PageOverlayID detectedDataOriginatingPageOverlay;
</span><ins>+
+ DictionaryPopupInfo dictionaryPopupInfo;
</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 (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -68,6 +68,8 @@
</span><span class="cx"> if (hasTextIndicator)
</span><span class="cx"> encoder << detectedDataTextIndicator->data();
</span><span class="cx"> }
</span><ins>+
+ encoder << dictionaryPopupInfo;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool ActionMenuHitTestResult::decode(IPC::ArgumentDecoder& decoder, ActionMenuHitTestResult& actionMenuHitTestResult)
</span><span class="lines">@@ -130,6 +132,9 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ if (!decoder.decode(actionMenuHitTestResult.dictionaryPopupInfo))
+ return false;
+
</ins><span class="cx"> return true;
</span><span class="cx"> }
</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 (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -41,7 +41,6 @@
</span><span class="cx"> #import <ImageKit/ImageKit.h>
</span><span class="cx"> #import <WebCore/DataDetectorsSPI.h>
</span><span class="cx"> #import <WebCore/LocalizedStrings.h>
</span><del>-#import <WebCore/LookupSPI.h>
</del><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="lines">@@ -408,20 +407,18 @@
</span><span class="cx"> - (NSArray *)_defaultMenuItemsForText
</span><span class="cx"> {
</span><span class="cx"> RetainPtr<NSMenuItem> copyTextItem = [self _createActionMenuItemForTag:kWKContextActionItemTagCopyText];
</span><del>- RetainPtr<NSMenuItem> lookupTextItem = [self _createActionMenuItemForTag:kWKContextActionItemTagLookupText];
</del><span class="cx"> RetainPtr<NSMenuItem> pasteItem = [self _createActionMenuItemForTag:kWKContextActionItemTagPaste];
</span><span class="cx"> [pasteItem setEnabled:NO];
</span><span class="cx">
</span><del>- return @[ copyTextItem.get(), lookupTextItem.get(), pasteItem.get() ];
</del><ins>+ return @[ copyTextItem.get(), [NSMenuItem separatorItem], pasteItem.get() ];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (NSArray *)_defaultMenuItemsForEditableText
</span><span class="cx"> {
</span><span class="cx"> RetainPtr<NSMenuItem> copyTextItem = [self _createActionMenuItemForTag:kWKContextActionItemTagCopyText];
</span><del>- RetainPtr<NSMenuItem> lookupTextItem = [self _createActionMenuItemForTag:kWKContextActionItemTagLookupText];
</del><span class="cx"> RetainPtr<NSMenuItem> pasteItem = [self _createActionMenuItemForTag:kWKContextActionItemTagPaste];
</span><span class="cx">
</span><del>- return @[ copyTextItem.get(), lookupTextItem.get(), pasteItem.get() ];
</del><ins>+ return @[ copyTextItem.get(), [NSMenuItem separatorItem], pasteItem.get() ];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (NSArray *)_defaultMenuItemsForEditableTextWithSuggestions
</span><span class="lines">@@ -448,13 +445,12 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RetainPtr<NSMenuItem> copyTextItem = [self _createActionMenuItemForTag:kWKContextActionItemTagCopyText];
</span><del>- RetainPtr<NSMenuItem> lookupTextItem = [self _createActionMenuItemForTag:kWKContextActionItemTagLookupText];
</del><span class="cx"> RetainPtr<NSMenuItem> pasteItem = [self _createActionMenuItemForTag:kWKContextActionItemTagPaste];
</span><span class="cx"> RetainPtr<NSMenuItem> textSuggestionsItem = [self _createActionMenuItemForTag:kWKContextActionItemTagTextSuggestions];
</span><span class="cx">
</span><span class="cx"> [textSuggestionsItem setSubmenu:spellingSubMenu.get()];
</span><span class="cx">
</span><del>- return @[ copyTextItem.get(), lookupTextItem.get(), pasteItem.get(), textSuggestionsItem.get() ];
</del><ins>+ return @[ copyTextItem.get(), [NSMenuItem separatorItem], pasteItem.get(), textSuggestionsItem.get() ];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_copySelection:(id)sender
</span><span class="lines">@@ -467,11 +463,6 @@
</span><span class="cx"> _page->executeEditCommand("paste");
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_lookupText:(id)sender
-{
- _page->performDictionaryLookupOfCurrentSelection();
-}
-
</del><span class="cx"> - (void)_changeSelectionToSuggestion:(id)sender
</span><span class="cx"> {
</span><span class="cx"> NSString *selectedCorrection = [sender representedObject];
</span><span class="lines">@@ -627,13 +618,6 @@
</span><span class="cx"> enabled = hitTestResult->allowsCopy();
</span><span class="cx"> break;
</span><span class="cx">
</span><del>- case kWKContextActionItemTagLookupText:
- selector = @selector(_lookupText:);
- title = WEB_UI_STRING_KEY("Look Up", "Look Up (action menu item)", "action menu item");
- image = [NSImage imageNamed:@"NSActionMenuLookup"];
- enabled = getLULookupDefinitionModuleClass() && hitTestResult->allowsCopy();
- break;
-
</del><span class="cx"> case kWKContextActionItemTagPaste:
</span><span class="cx"> selector = @selector(_paste:);
</span><span class="cx"> title = WEB_UI_STRING_KEY("Paste", "Paste (action menu item)", "action menu item");
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKImmediateActionControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #import "WebProcessProxy.h"
</span><span class="cx"> #import <WebCore/DataDetectorsSPI.h>
</span><span class="cx"> #import <WebCore/GeometryUtilities.h>
</span><ins>+#import <WebCore/LookupSPI.h>
</ins><span class="cx"> #import <WebCore/NSMenuSPI.h>
</span><span class="cx"> #import <WebCore/QuickLookMacSPI.h>
</span><span class="cx"> #import <WebCore/SoftLinking.h>
</span><span class="lines">@@ -44,6 +45,7 @@
</span><span class="cx">
</span><span class="cx"> SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, QuickLookUI)
</span><span class="cx"> SOFT_LINK_CLASS(QuickLookUI, QLPreviewMenuItem)
</span><ins>+SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *)
</ins><span class="cx">
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> using namespace WebKit;
</span><span class="lines">@@ -235,6 +237,11 @@
</span><span class="cx"> _type = kWKImmediateActionDataDetectedItem;
</span><span class="cx"> return (id<NSImmediateActionAnimationController>)immediateActionItem;
</span><span class="cx"> }
</span><ins>+
+ if (id<NSImmediateActionAnimationController> textAnimationController = [self _animationControllerForText]) {
+ _type = kWKImmediateActionLookupText;
+ return textAnimationController;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return nil;
</span><span class="lines">@@ -485,6 +492,34 @@
</span><span class="cx"> return menuItems.lastObject;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma mark Text action
+
+- (id<NSImmediateActionAnimationController>)_animationControllerForText
+{
+ if (_state != ImmediateActionState::Ready)
+ return nil;
+
+ if (!getLULookupDefinitionModuleClass())
+ return nil;
+
+ DictionaryPopupInfo dictionaryPopupInfo = _hitTestResult.dictionaryPopupInfo;
+ if (!dictionaryPopupInfo.attributedString.string)
+ return nil;
+
+ // Convert baseline to screen coordinates.
+ NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
+ textBaselineOrigin = [_wkView convertPoint:textBaselineOrigin toView:nil];
+ textBaselineOrigin = [_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
+
+ RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
+ if (canLoadLUTermOptionDisableSearchTermIndicator() && dictionaryPopupInfo.textIndicator.contentImage) {
+ [_wkView _setTextIndicator:TextIndicator::create(dictionaryPopupInfo.textIndicator) fadeOut:NO animationCompletionHandler:[]{ }];
+ [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
+ return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
+ }
+ return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
+}
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include "APIInjectedBundleFormClient.h"
</span><span class="cx"> #include "APIInjectedBundlePageUIClient.h"
</span><span class="cx"> #include "APIObject.h"
</span><ins>+#include "DictionaryPopupInfo.h"
</ins><span class="cx"> #include "FindController.h"
</span><span class="cx"> #include "GeolocationPermissionRequestManager.h"
</span><span class="cx"> #include "ImageOptions.h"
</span><span class="lines">@@ -970,6 +971,7 @@
</span><span class="cx"> void performDictionaryLookupAtLocation(const WebCore::FloatPoint&);
</span><span class="cx"> void performDictionaryLookupOfCurrentSelection();
</span><span class="cx"> void performDictionaryLookupForRange(WebCore::Frame*, WebCore::Range&, NSDictionary *options, WebCore::TextIndicatorPresentationTransition);
</span><ins>+ DictionaryPopupInfo dictionaryPopupInfoForRange(WebCore::Frame* frame, WebCore::Range& range, NSDictionary **options, WebCore::TextIndicatorPresentationTransition presentationTransition);
</ins><span class="cx">
</span><span class="cx"> void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& windowFrameInUnflippedScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
</span><span class="cx">
</span><span class="lines">@@ -1044,7 +1046,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> void performActionMenuHitTestAtLocation(WebCore::FloatPoint);
</span><del>- PassRefPtr<WebCore::Range> lookupTextAtLocation(WebCore::FloatPoint);
</del><ins>+ PassRefPtr<WebCore::Range> lookupTextAtLocation(WebCore::FloatPoint, NSDictionary **options);
</ins><span class="cx"> void selectLastActionMenuRange();
</span><span class="cx"> void focusAndSelectLastActionMenuHitTestResult();
</span><span class="cx">
</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 (177351 => 177352)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-12-16 08:57:40 UTC (rev 177351)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-12-16 09:01:53 UTC (rev 177352)
</span><span class="lines">@@ -506,10 +506,11 @@
</span><span class="cx"> performDictionaryLookupForSelection(frame, frame->selection().selection(), TextIndicatorPresentationTransition::BounceAndCrossfade);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebPage::performDictionaryLookupForRange(Frame* frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
</del><ins>+DictionaryPopupInfo WebPage::dictionaryPopupInfoForRange(Frame* frame, Range& range, NSDictionary **options, TextIndicatorPresentationTransition presentationTransition)
</ins><span class="cx"> {
</span><ins>+ DictionaryPopupInfo dictionaryPopupInfo;
</ins><span class="cx"> if (range.text().stripWhiteSpace().isEmpty())
</span><del>- return;
</del><ins>+ return dictionaryPopupInfo;
</ins><span class="cx">
</span><span class="cx"> RenderObject* renderer = range.startContainer()->renderer();
</span><span class="cx"> const RenderStyle& style = renderer->style();
</span><span class="lines">@@ -517,13 +518,12 @@
</span><span class="cx"> Vector<FloatQuad> quads;
</span><span class="cx"> range.textQuads(quads);
</span><span class="cx"> if (quads.isEmpty())
</span><del>- return;
</del><ins>+ return dictionaryPopupInfo;
</ins><span class="cx">
</span><span class="cx"> IntRect rangeRect = frame->view()->contentsToWindow(quads[0].enclosingBoundingBox());
</span><span class="cx">
</span><del>- DictionaryPopupInfo dictionaryPopupInfo;
</del><span class="cx"> dictionaryPopupInfo.origin = FloatPoint(rangeRect.x(), rangeRect.y() + (style.fontMetrics().ascent() * pageScaleFactor()));
</span><del>- dictionaryPopupInfo.options = (CFDictionaryRef)options;
</del><ins>+ dictionaryPopupInfo.options = (CFDictionaryRef)*options;
</ins><span class="cx">
</span><span class="cx"> NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range, IncludeImagesInAttributedString::No);
</span><span class="cx">
</span><span class="lines">@@ -545,11 +545,17 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(range, presentationTransition);
</span><span class="cx"> if (!textIndicator)
</span><del>- return;
</del><ins>+ return dictionaryPopupInfo;
</ins><span class="cx">
</span><span class="cx"> dictionaryPopupInfo.textIndicator = textIndicator->data();
</span><span class="cx"> dictionaryPopupInfo.attributedString.string = scaledNSAttributedString;
</span><span class="cx">
</span><ins>+ return dictionaryPopupInfo;
+}
+
+void WebPage::performDictionaryLookupForRange(Frame* frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
+{
+ DictionaryPopupInfo dictionaryPopupInfo = dictionaryPopupInfoForRange(frame, range, &options, presentationTransition);
</ins><span class="cx"> send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfo));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -984,8 +990,16 @@
</span><span class="cx"> actionMenuResult.hitTestLocationInViewCooordinates = locationInViewCooordinates;
</span><span class="cx"> actionMenuResult.hitTestResult = WebHitTestResult::Data(hitTestResult);
</span><span class="cx">
</span><del>- RefPtr<WebCore::Range> lookupRange = lookupTextAtLocation(locationInViewCooordinates);
</del><ins>+ NSDictionary *options = nil;
+ RefPtr<WebCore::Range> lookupRange = lookupTextAtLocation(locationInViewCooordinates, &options);
</ins><span class="cx"> actionMenuResult.lookupText = lookupRange ? lookupRange->text() : String();
</span><ins>+ if (lookupRange) {
+ if (Node* node = hitTestResult.innerNode()) {
+ if (Frame* hitTestResultFrame = node->document().frame())
+ actionMenuResult.dictionaryPopupInfo = dictionaryPopupInfoForRange(hitTestResultFrame, *lookupRange.get(), &options, TextIndicatorPresentationTransition::Bounce);
+ }
+ }
+
</ins><span class="cx"> m_lastActionMenuRangeForSelection = lookupRange;
</span><span class="cx"> m_lastActionMenuHitTestResult = hitTestResult;
</span><span class="cx">
</span><span class="lines">@@ -1047,7 +1061,7 @@
</span><span class="cx"> send(Messages::WebPageProxy::DidPerformActionMenuHitTest(actionMenuResult, InjectedBundleUserMessageEncoder(userData.get())));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<WebCore::Range> WebPage::lookupTextAtLocation(FloatPoint locationInViewCooordinates)
</del><ins>+PassRefPtr<WebCore::Range> WebPage::lookupTextAtLocation(FloatPoint locationInViewCooordinates, NSDictionary **options)
</ins><span class="cx"> {
</span><span class="cx"> MainFrame& mainFrame = corePage()->mainFrame();
</span><span class="cx"> if (!mainFrame.view() || !mainFrame.view()->renderView())
</span><span class="lines">@@ -1055,8 +1069,7 @@
</span><span class="cx">
</span><span class="cx"> IntPoint point = roundedIntPoint(locationInViewCooordinates);
</span><span class="cx"> HitTestResult result = mainFrame.eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(point));
</span><del>- NSDictionary *options = nil;
- return rangeForDictionaryLookupAtHitTestResult(result, &options);
</del><ins>+ return rangeForDictionaryLookupAtHitTestResult(result, options);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebPage::selectLastActionMenuRange()
</span></span></pre>
</div>
</div>
</body>
</html>