<!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>[175879] 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/175879">175879</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2014-11-11 01:18:50 -0800 (Tue, 11 Nov 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/175842">r175842</a>. rdar://problems/18877506</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6003branchSourceWebCoreChangeLog">branches/safari-600.3-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6003branchSourceWebCoreWebCoreexpin">branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#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="#branchessafari6003branchSourceWebKitmacWebViewWebHTMLViewmm">branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLView.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKitmacWebViewWebHTMLViewInternalh">branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLViewInternal.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKitmacWebViewWebUIDelegatePrivateh">branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h</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 (175878 => 175879)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/ChangeLog        2014-11-11 09:18:45 UTC (rev 175878)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog        2014-11-11 09:18:50 UTC (rev 175879)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-11-10 Beth Dakin <bdakin@apple.com>
+
+ WK1: Support default actions for editable text with misspelled word
+ https://bugs.webkit.org/show_bug.cgi?id=138590
+ -and corresponding-
+ rdar://problem/18877506
+
+ Reviewed by Tim Horton.
+
+ * WebCore.exp.in:
+
</ins><span class="cx"> 2014-11-11 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r175823. <rdar://problem/18877483>
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in (175878 => 175879)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in        2014-11-11 09:18:45 UTC (rev 175878)
+++ branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in        2014-11-11 09:18:50 UTC (rev 175879)
</span><span class="lines">@@ -1954,6 +1954,7 @@
</span><span class="cx"> __ZNK7WebCore5Range9textQuadsERN3WTF6VectorINS_9FloatQuadELm0ENS1_15CrashOnOverflowEEEbPNS0_20RangeInFixedPositionE
</span><span class="cx"> __ZNK7WebCore5Range9textRectsERN3WTF6VectorINS_7IntRectELm0ENS1_15CrashOnOverflowEEEbPNS0_20RangeInFixedPositionE
</span><span class="cx"> __ZNK7WebCore6Chrome12createWindowEPNS_5FrameERKNS_16FrameLoadRequestERKNS_14WindowFeaturesERKNS_16NavigationActionE
</span><ins>+__ZNK7WebCore6Editor11textCheckerEv
</ins><span class="cx"> __ZNK7WebCore6Editor12selectedTextEv
</span><span class="cx"> __ZNK7WebCore6Editor13canEditRichlyEv
</span><span class="cx"> __ZNK7WebCore6Editor16compositionRangeEv
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog (175878 => 175879)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog        2014-11-11 09:18:45 UTC (rev 175878)
+++ branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog        2014-11-11 09:18:50 UTC (rev 175879)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2014-11-10 Beth Dakin <bdakin@apple.com>
+
+ WK1: Support default actions for editable text with misspelled word
+ https://bugs.webkit.org/show_bug.cgi?id=138590
+ -and corresponding-
+ rdar://problem/18877506
+
+ Reviewed by Tim Horton.
+
+ If there are misspelled word suggestions for editable text, create a new type of
+ menu with a spelling suggestion sub-menu.
+
+ * WebView/WebActionMenuController.mm:
+ (-[WebActionMenuController isMenuForTextContent]):
+ (-[WebActionMenuController _defaultMenuItemsForEditableTextWithSuggestions:]):
+ (-[WebActionMenuController _changeSelectionToSuggestion:]):
+ (-[WebActionMenuController _createActionMenuItemForTag:withHitTestResult:]):
+ (-[WebActionMenuController _defaultMenuItemsForHitTestResult:]):
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView _changeSpellingToWord:]):
+ * WebView/WebHTMLViewInternal.h:
+ * WebView/WebUIDelegatePrivate.h:
+
</ins><span class="cx"> 2014-11-11 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r175837. <rdar://problem/18932048>
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKitmacWebViewWebActionMenuControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm (175878 => 175879)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm        2014-11-11 09:18:45 UTC (rev 175878)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm        2014-11-11 09:18:50 UTC (rev 175879)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #import "WebUIDelegatePrivate.h"
</span><span class="cx"> #import "WebViewInternal.h"
</span><span class="cx"> #import <WebCore/DictionaryLookup.h>
</span><ins>+#import <WebCore/Editor.h>
</ins><span class="cx"> #import <WebCore/Element.h>
</span><span class="cx"> #import <WebCore/EventHandler.h>
</span><span class="cx"> #import <WebCore/Frame.h>
</span><span class="lines">@@ -47,6 +48,7 @@
</span><span class="cx"> #import <WebCore/RenderElement.h>
</span><span class="cx"> #import <WebCore/RenderObject.h>
</span><span class="cx"> #import <WebCore/SoftLinking.h>
</span><ins>+#import <WebCore/TextCheckerClient.h>
</ins><span class="cx"> #import <WebKitSystemInterface.h>
</span><span class="cx"> #import <objc/objc-class.h>
</span><span class="cx"> #import <objc/objc.h>
</span><span class="lines">@@ -128,7 +130,7 @@
</span><span class="cx">
</span><span class="cx"> - (BOOL)isMenuForTextContent
</span><span class="cx"> {
</span><del>- return _type == WebActionMenuReadOnlyText || _type == WebActionMenuEditableText || _type == WebActionMenuWhitespaceInEditableArea;
</del><ins>+ return _type == WebActionMenuReadOnlyText || _type == WebActionMenuEditableText || _type == WebActionMenuEditableTextWithSuggestions || _type == WebActionMenuWhitespaceInEditableArea;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event
</span><span class="lines">@@ -273,6 +275,49 @@
</span><span class="cx"> return @[ copyTextItem.get(), lookupTextItem.get(), pasteItem.get() ];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (NSArray *)_defaultMenuItemsForEditableTextWithSuggestions:(WebElementDictionary *)hitTestResult
+{
+ Frame* frame = core([_webView _selectedOrMainFrame]);
+ if (!frame)
+ return @[ ];
+
+ NSDictionary *options = nil;
+ RefPtr<Range> lookupRange = rangeForDictionaryLookupAtHitTestResult(_hitTestResult, &options);
+ if (!lookupRange)
+ return @[ ];
+
+ String lookupText = lookupRange->text();
+ TextCheckerClient* textChecker = frame->editor().textChecker();
+ if (!textChecker)
+ return @[ ];
+
+ Vector<TextCheckingResult> results = textChecker->checkTextOfParagraph(lookupText, NSTextCheckingTypeSpelling);
+ if (results.isEmpty())
+ return @[ ];
+
+ Vector<String> guesses;
+ frame->editor().textChecker()->getGuessesForWord(lookupText, String(), guesses);
+ if (guesses.isEmpty())
+ return @[ ];
+
+ RetainPtr<NSMenu> spellingSubMenu = adoptNS([[NSMenu alloc] init]);
+ for (const auto& guess : guesses) {
+ RetainPtr<NSMenuItem> item = adoptNS([[NSMenuItem alloc] initWithTitle:guess action:@selector(_changeSelectionToSuggestion:) keyEquivalent:@""]);
+ [item setRepresentedObject:guess];
+ [item setTarget:self];
+ [spellingSubMenu addItem:item.get()];
+ }
+
+ RetainPtr<NSMenuItem> copyTextItem = [self _createActionMenuItemForTag:WebActionMenuItemTagCopyText withHitTestResult:hitTestResult];
+ RetainPtr<NSMenuItem> lookupTextItem = [self _createActionMenuItemForTag:WebActionMenuItemTagLookupText withHitTestResult:hitTestResult];
+ RetainPtr<NSMenuItem> pasteItem = [self _createActionMenuItemForTag:WebActionMenuItemTagPaste withHitTestResult:hitTestResult];
+ RetainPtr<NSMenuItem> textSuggestionsItem = [self _createActionMenuItemForTag:WebActionMenuItemTagTextSuggestions withHitTestResult:hitTestResult];
+
+ [textSuggestionsItem setSubmenu:spellingSubMenu.get()];
+
+ return @[ copyTextItem.get(), lookupTextItem.get(), pasteItem.get(), textSuggestionsItem.get() ];
+}
+
</ins><span class="cx"> - (void)_copySelection:(id)sender
</span><span class="cx"> {
</span><span class="cx"> [_webView _executeCoreCommandByName:@"copy" value:nil];
</span><span class="lines">@@ -317,6 +362,18 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)_changeSelectionToSuggestion:(id)sender
+{
+ NSString *selectedCorrection = [sender representedObject];
+ if (!selectedCorrection)
+ return;
+
+ ASSERT([selectedCorrection isKindOfClass:[NSString class]]);
+
+ WebHTMLView *documentView = [[[_webView _selectedOrMainFrame] frameView] documentView];
+ [documentView _changeSpellingToWord:selectedCorrection];
+}
+
</ins><span class="cx"> static DictionaryPopupInfo performDictionaryLookupForSelection(Frame* frame, const VisibleSelection& selection)
</span><span class="cx"> {
</span><span class="cx"> NSDictionary *options = nil;
</span><span class="lines">@@ -425,6 +482,11 @@
</span><span class="cx"> image = [NSImage imageNamed:@"NSActionMenuPaste"];
</span><span class="cx"> break;
</span><span class="cx">
</span><ins>+ case WebActionMenuItemTagTextSuggestions:
+ title = @"Suggestions";
+ image = [NSImage imageNamed:@"NSActionMenuSpelling"];
+ break;
+
</ins><span class="cx"> default:
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><span class="cx"> return nil;
</span><span class="lines">@@ -454,6 +516,12 @@
</span><span class="cx"> Node* node = _hitTestResult.innerNode();
</span><span class="cx"> if (node && node->isTextNode()) {
</span><span class="cx"> if (_hitTestResult.isContentEditable()) {
</span><ins>+ NSArray *editableTextWithSuggestions = [self _defaultMenuItemsForEditableTextWithSuggestions:hitTestResult];
+ if (editableTextWithSuggestions.count) {
+ _type = WebActionMenuEditableTextWithSuggestions;
+ return editableTextWithSuggestions;
+ }
+
</ins><span class="cx"> _type = WebActionMenuEditableText;
</span><span class="cx"> return [self _defaultMenuItemsForEditableText:hitTestResult];
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKitmacWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLView.mm (175878 => 175879)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLView.mm        2014-11-11 09:18:45 UTC (rev 175878)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLView.mm        2014-11-11 09:18:50 UTC (rev 175879)
</span><span class="lines">@@ -5226,24 +5226,6 @@
</span><span class="cx"> [spellingPanel orderFront:sender];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_changeSpellingToWord:(NSString *)newWord
-{
- if (![self _canEdit])
- return;
-
- // Don't correct to empty string. (AppKit checked this, we might as well too.)
- if (![NSSpellChecker sharedSpellChecker]) {
- LOG_ERROR("No NSSpellChecker");
- return;
- }
-
- if ([newWord isEqualToString:@""])
- return;
-
- if ([self _shouldReplaceSelectionWithText:newWord givenAction:WebViewInsertActionPasted])
- [[self _frame] _replaceSelectionWithText:newWord selectReplacement:YES smartReplace:NO];
-}
-
</del><span class="cx"> - (void)changeSpelling:(id)sender
</span><span class="cx"> {
</span><span class="cx"> COMMAND_PROLOGUE
</span><span class="lines">@@ -6027,6 +6009,24 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)_changeSpellingToWord:(NSString *)newWord
+{
+ if (![self _canEdit])
+ return;
+
+ if (![NSSpellChecker sharedSpellChecker]) {
+ LOG_ERROR("No NSSpellChecker");
+ return;
+ }
+
+ // Don't correct to empty string. (AppKit checked this, we might as well too.)
+ if ([newWord isEqualToString:@""])
+ return;
+
+ if ([self _shouldReplaceSelectionWithText:newWord givenAction:WebViewInsertActionPasted])
+ [[self _frame] _replaceSelectionWithText:newWord selectReplacement:YES smartReplace:NO];
+}
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @implementation WebHTMLView (WebNSTextInputSupport)
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKitmacWebViewWebHTMLViewInternalh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLViewInternal.h (175878 => 175879)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLViewInternal.h        2014-11-11 09:18:45 UTC (rev 175878)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLViewInternal.h        2014-11-11 09:18:50 UTC (rev 175879)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx"> - (void)_layoutIfNeeded;
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+- (void)_changeSpellingToWord:(NSString *)newWord;
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKitmacWebViewWebUIDelegatePrivateh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h (175878 => 175879)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h        2014-11-11 09:18:45 UTC (rev 175878)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h        2014-11-11 09:18:50 UTC (rev 175879)
</span><span class="lines">@@ -119,7 +119,8 @@
</span><span class="cx"> WebActionMenuItemTagAddLinkToSafariReadingList,
</span><span class="cx"> WebActionMenuItemTagCopyText,
</span><span class="cx"> WebActionMenuItemTagLookupText,
</span><del>- WebActionMenuItemTagPaste
</del><ins>+ WebActionMenuItemTagPaste,
+ WebActionMenuItemTagTextSuggestions
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span><span class="lines">@@ -127,7 +128,8 @@
</span><span class="cx"> WebActionMenuLink,
</span><span class="cx"> WebActionMenuReadOnlyText,
</span><span class="cx"> WebActionMenuEditableText,
</span><del>- WebActionMenuWhitespaceInEditableArea
</del><ins>+ WebActionMenuWhitespaceInEditableArea,
+ WebActionMenuEditableTextWithSuggestions
</ins><span class="cx"> } WebActionMenuType;
</span><span class="cx">
</span><span class="cx"> // Message Sources.
</span></span></pre>
</div>
</div>
</body>
</html>