<!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>[167469] trunk/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/167469">167469</a></dd>
<dt>Author</dt> <dd>enrica@apple.com</dd>
<dt>Date</dt> <dd>2014-04-17 17:01:59 -0700 (Thu, 17 Apr 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[iOS WebKit2] support replacements for misspelled words.
https://bugs.webkit.org/show_bug.cgi?id=131827
<rdar://problem/16319657>
Reviewed by Benjamin Poulain.
This is the first part of the work to add support for replacements.
It handles _promptForReplace in canPerformAction to decide
whether to show the Replace button in the menu and add the
implementation of the replace action.
* Shared/EditorState.cpp:
(WebKit::EditorState::encode):
(WebKit::EditorState::decode):
* Shared/EditorState.h:
(WebKit::EditorState::EditorState):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView selectedText]):
(-[WKContentView replaceText:withText:]):
(-[WKContentView _promptForReplace:]):
(-[WKContentView replace:]):
(-[WKContentView canPerformAction:withSender:]):
(-[WKContentView selectWordForReplacement]): This is called
by UIKit when the user taps on a mispelled word to select it.
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::replaceSelectedText):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::editorState):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::selectWithGesture): Removed m_shouldReturnWordForSelection.
We now return always the word corresponding to the caret selection or
the selected text up to a maximum of 200 characters.
(WebKit::WebPage::extendSelection):
(WebKit::WebPage::replaceSelectedText):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedEditorStatecpp">trunk/Source/WebKit2/Shared/EditorState.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedEditorStateh">trunk/Source/WebKit2/Shared/EditorState.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm">trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (167468 => 167469)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-04-17 23:35:07 UTC (rev 167468)
+++ trunk/Source/WebKit2/ChangeLog        2014-04-18 00:01:59 UTC (rev 167469)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2014-04-17 Enrica Casucci <enrica@apple.com>
+
+ [iOS WebKit2] support replacements for misspelled words.
+ https://bugs.webkit.org/show_bug.cgi?id=131827
+ <rdar://problem/16319657>
+
+ Reviewed by Benjamin Poulain.
+
+ This is the first part of the work to add support for replacements.
+ It handles _promptForReplace in canPerformAction to decide
+ whether to show the Replace button in the menu and add the
+ implementation of the replace action.
+
+ * Shared/EditorState.cpp:
+ (WebKit::EditorState::encode):
+ (WebKit::EditorState::decode):
+ * Shared/EditorState.h:
+ (WebKit::EditorState::EditorState):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView selectedText]):
+ (-[WKContentView replaceText:withText:]):
+ (-[WKContentView _promptForReplace:]):
+ (-[WKContentView replace:]):
+ (-[WKContentView canPerformAction:withSender:]):
+ (-[WKContentView selectWordForReplacement]): This is called
+ by UIKit when the user taps on a mispelled word to select it.
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::replaceSelectedText):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::WebPage):
+ (WebKit::WebPage::editorState):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::selectWithGesture): Removed m_shouldReturnWordForSelection.
+ We now return always the word corresponding to the caret selection or
+ the selected text up to a maximum of 200 characters.
+ (WebKit::WebPage::extendSelection):
+ (WebKit::WebPage::replaceSelectedText):
+
</ins><span class="cx"> 2014-04-17 Tim Horton <timothy_horton@apple.com>
</span><span class="cx">
</span><span class="cx"> [iOS] REGRESSION (r166975): WKPDFView is broken
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEditorStatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EditorState.cpp (167468 => 167469)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EditorState.cpp        2014-04-17 23:35:07 UTC (rev 167468)
+++ trunk/Source/WebKit2/Shared/EditorState.cpp        2014-04-18 00:01:59 UTC (rev 167469)
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx"> encoder << hasComposition;
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+ encoder << isReplaceAllowed;
</ins><span class="cx"> encoder << caretRectAtStart;
</span><span class="cx"> encoder << caretRectAtEnd;
</span><span class="cx"> encoder << selectionRects;
</span><span class="lines">@@ -89,6 +90,8 @@
</span><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+ if (!decoder.decode(result.isReplaceAllowed))
+ return false;
</ins><span class="cx"> if (!decoder.decode(result.caretRectAtStart))
</span><span class="cx"> return false;
</span><span class="cx"> if (!decoder.decode(result.caretRectAtEnd))
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEditorStateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EditorState.h (167468 => 167469)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EditorState.h        2014-04-17 23:35:07 UTC (rev 167468)
+++ trunk/Source/WebKit2/Shared/EditorState.h        2014-04-18 00:01:59 UTC (rev 167469)
</span><span class="lines">@@ -47,7 +47,8 @@
</span><span class="cx"> , isInPlugin(false)
</span><span class="cx"> , hasComposition(false)
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>- , selectedTextLength(0)
</del><ins>+ , isReplaceAllowed(false)
+ , selectedTextLength(0)
</ins><span class="cx"> #endif
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -63,6 +64,7 @@
</span><span class="cx"> bool hasComposition;
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+ bool isReplaceAllowed;
</ins><span class="cx"> WebCore::IntRect caretRectAtStart;
</span><span class="cx"> WebCore::IntRect caretRectAtEnd;
</span><span class="cx"> Vector<WebCore::SelectionRect> selectionRects;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (167468 => 167469)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-04-17 23:35:07 UTC (rev 167468)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-04-18 00:01:59 UTC (rev 167469)
</span><span class="lines">@@ -593,6 +593,7 @@
</span><span class="cx"> void getAutocorrectionContext(String& contextBefore, String& markedText, String& selectedText, String& contextAfter, uint64_t& location, uint64_t& length);
</span><span class="cx"> void requestDictationContext(PassRefPtr<DictationContextCallback>);
</span><span class="cx"> void replaceDictatedText(const String& oldText, const String& newText);
</span><ins>+ void replaceSelectedText(const String& oldText, const String& newText);
</ins><span class="cx"> void didReceivePositionInformation(const InteractionInformationAtPosition&);
</span><span class="cx"> void getPositionInformation(const WebCore::IntPoint&, InteractionInformationAtPosition&);
</span><span class="cx"> void requestPositionInformation(const WebCore::IntPoint&);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (167468 => 167469)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2014-04-17 23:35:07 UTC (rev 167468)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2014-04-18 00:01:59 UTC (rev 167469)
</span><span class="lines">@@ -133,6 +133,10 @@
</span><span class="cx"> - (void)selectWord;
</span><span class="cx"> @end
</span><span class="cx">
</span><ins>+@interface UITextInteractionAssistant (StagingToRemove)
+- (void)scheduleReplacementsForText:(NSString *)text;
+@end
+
</ins><span class="cx"> @interface WKFormInputSession : NSObject <_WKFormInputSession>
</span><span class="cx">
</span><span class="cx"> - (instancetype)initWithContentView:(WKContentView *)view userObject:(NSObject <NSSecureCoding> *)userObject;
</span><span class="lines">@@ -851,14 +855,28 @@
</span><span class="cx"> // FIXME: To be implemented.
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (NSString *)selectedText
+{
+ return (NSString *)_page->editorState().wordAtSelection;
+}
+
+- (void)replaceText:(NSString *)text withText:(NSString *)word
+{
+ _page->replaceSelectedText(text, word);
+}
+
</ins><span class="cx"> - (void)_promptForReplace:(id)sender
</span><span class="cx"> {
</span><del>- // FIXME: To be implemented.
</del><ins>+ if (_page->editorState().wordAtSelection.isEmpty())
+ return;
+
+ if ([_textSelectionAssistant respondsToSelector:@selector(scheduleReplacementsForText:)])
+ [_textSelectionAssistant scheduleReplacementsForText:_page->editorState().wordAtSelection];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)replace:(id)sender
</span><span class="cx"> {
</span><del>- // FIXME: To be implemented.
</del><ins>+ [[UIKeyboardImpl sharedInstance] replaceText:sender];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
</span><span class="lines">@@ -908,10 +926,8 @@
</span><span class="cx"> return NO;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (action == @selector(_promptForReplace:)) {
- // FIXME: need to implement
- return NO;
- }
</del><ins>+ if (action == @selector(_promptForReplace:))
+ return _page->editorState().selectionIsRange && _page->editorState().isReplaceAllowed && [[UIKeyboardImpl activeInstance] autocorrectSpellingEnabled];
</ins><span class="cx">
</span><span class="cx"> if (action == @selector(select:)) {
</span><span class="cx"> // Disable select in password fields so that you can't see word boundaries.
</span><span class="lines">@@ -2019,6 +2035,11 @@
</span><span class="cx"> [self _updateChangedSelection];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)selectWordForReplacement
+{
+ _page->extendSelection(WordGranularity);
+}
+
</ins><span class="cx"> - (void)_updateChangedSelection
</span><span class="cx"> {
</span><span class="cx"> if (!_selectionNeedsUpdate)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (167468 => 167469)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-04-17 23:35:07 UTC (rev 167468)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-04-18 00:01:59 UTC (rev 167469)
</span><span class="lines">@@ -233,7 +233,12 @@
</span><span class="cx"> {
</span><span class="cx"> m_process->send(Messages::WebPage::ReplaceDictatedText(oldText, newText), m_pageID);
</span><span class="cx"> }
</span><del>-
</del><ins>+
+void WebPageProxy::replaceSelectedText(const String& oldText, const String& newText)
+{
+ m_process->send(Messages::WebPage::ReplaceSelectedText(oldText, newText), m_pageID);
+}
+
</ins><span class="cx"> void WebPageProxy::requestAutocorrectionData(const String& textForAutocorrection, PassRefPtr<AutocorrectionDataCallback> callback)
</span><span class="cx"> {
</span><span class="cx"> if (!isValid()) {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (167468 => 167469)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-04-17 23:35:07 UTC (rev 167468)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-04-18 00:01:59 UTC (rev 167469)
</span><span class="lines">@@ -286,7 +286,6 @@
</span><span class="cx"> , m_isShowingContextMenu(false)
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>- , m_shouldReturnWordAtSelection(false)
</del><span class="cx"> , m_lastVisibleContentRectUpdateID(0)
</span><span class="cx"> , m_hasReceivedVisibleContentRectsAfterDidCommitLoad(false)
</span><span class="cx"> , m_scaleWasSetByUIProcess(false)
</span><span class="lines">@@ -697,15 +696,22 @@
</span><span class="cx"> if (selection.isCaret()) {
</span><span class="cx"> result.caretRectAtStart = view->contentsToRootView(frame.selection().absoluteCaretBounds());
</span><span class="cx"> result.caretRectAtEnd = result.caretRectAtStart;
</span><del>- if (m_shouldReturnWordAtSelection)
- result.wordAtSelection = plainText(wordRangeFromPosition(selection.start()).get());
</del><ins>+ // FIXME: The following check should take into account writing direction.
+ result.isReplaceAllowed = result.isContentEditable && atBoundaryOfGranularity(selection.start(), WordGranularity, DirectionForward);
+ result.wordAtSelection = plainText(wordRangeFromPosition(selection.start()).get());
</ins><span class="cx"> } else if (selection.isRange()) {
</span><span class="cx"> result.caretRectAtStart = view->contentsToRootView(VisiblePosition(selection.start()).absoluteCaretBounds());
</span><span class="cx"> result.caretRectAtEnd = view->contentsToRootView(VisiblePosition(selection.end()).absoluteCaretBounds());
</span><span class="cx"> RefPtr<Range> selectedRange = selection.toNormalizedRange();
</span><span class="cx"> selectedRange->collectSelectionRects(result.selectionRects);
</span><span class="cx"> convertSelectionRectsToRootView(view, result.selectionRects);
</span><del>- result.selectedTextLength = plainText(selectedRange.get(), TextIteratorDefaultBehavior, true).length();
</del><ins>+ String selectedText = plainText(selectedRange.get(), TextIteratorDefaultBehavior, true);
+ // FIXME: We should disallow replace when the string contains only CJ characters.
+ result.isReplaceAllowed = result.isContentEditable && !result.isInPasswordField && !selectedText.containsOnlyWhitespace();
+ result.selectedTextLength = selectedText.length();
+ const int maxSelectedTextLength = 200;
+ if (selectedText.length() <= maxSelectedTextLength)
+ result.wordAtSelection = selectedText;
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (167468 => 167469)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-04-17 23:35:07 UTC (rev 167468)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-04-18 00:01:59 UTC (rev 167469)
</span><span class="lines">@@ -458,6 +458,7 @@
</span><span class="cx"> void elementDidBlur(WebCore::Node*);
</span><span class="cx"> void requestDictationContext(uint64_t callbackID);
</span><span class="cx"> void replaceDictatedText(const String& oldText, const String& newText);
</span><ins>+ void replaceSelectedText(const String& oldText, const String& newText);
</ins><span class="cx"> void requestAutocorrectionData(const String& textForAutocorrection, uint64_t callbackID);
</span><span class="cx"> void applyAutocorrection(const String& correction, const String& originalText, uint64_t callbackID);
</span><span class="cx"> void syncApplyAutocorrection(const String& correction, const String& originalText, bool& correctionApplied);
</span><span class="lines">@@ -1146,7 +1147,6 @@
</span><span class="cx"> RefPtr<WebCore::Node> m_assistedNode;
</span><span class="cx"> RefPtr<WebCore::Range> m_currentWordRange;
</span><span class="cx"> RefPtr<WebCore::Node> m_interactionNode;
</span><del>- bool m_shouldReturnWordAtSelection;
</del><span class="cx"> WebCore::IntPoint m_lastInteractionLocation;
</span><span class="cx">
</span><span class="cx"> WebCore::ViewportConfiguration m_viewportConfiguration;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (167468 => 167469)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-04-17 23:35:07 UTC (rev 167468)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-04-18 00:01:59 UTC (rev 167469)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> ExtendSelection(uint32_t granularity)
</span><span class="cx"> RequestDictationContext(uint64_t callbackID)
</span><span class="cx"> ReplaceDictatedText(String oldText, String newText)
</span><ins>+ ReplaceSelectedText(String oldText, String newText)
</ins><span class="cx"> RequestAutocorrectionData(String textForAutocorrection, uint64_t callbackID)
</span><span class="cx"> ApplyAutocorrection(String correction, String originalText, uint64_t callbackID)
</span><span class="cx"> SyncApplyAutocorrection(String correction, String originalText) -> (bool autocorrectionApplied)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (167468 => 167469)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-04-17 23:35:07 UTC (rev 167468)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-04-18 00:01:59 UTC (rev 167469)
</span><span class="lines">@@ -582,8 +582,6 @@
</span><span class="cx"> }
</span><span class="cx"> if (result.isNotNull())
</span><span class="cx"> range = Range::create(*frame.document(), result, result);
</span><del>- if (range)
- m_shouldReturnWordAtSelection = true;
</del><span class="cx"> }
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="lines">@@ -657,7 +655,6 @@
</span><span class="cx"> frame.selection().setSelectedRange(range.get(), position.affinity(), true);
</span><span class="cx">
</span><span class="cx"> send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, static_cast<uint32_t>(flags), callbackID));
</span><del>- m_shouldReturnWordAtSelection = false;
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static PassRefPtr<Range> rangeForPosition(Frame* frame, const VisiblePosition& position, bool baseIsStart)
</span><span class="lines">@@ -1211,12 +1208,11 @@
</span><span class="cx">
</span><span class="cx"> void WebPage::extendSelection(uint32_t granularity)
</span><span class="cx"> {
</span><ins>+ Frame& frame = m_page->focusController().focusedOrMainFrame();
</ins><span class="cx"> // For the moment we handle only WordGranularity.
</span><del>- if (granularity != WordGranularity)
</del><ins>+ if (granularity != WordGranularity || !frame.selection().isCaret())
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- Frame& frame = m_page->focusController().focusedOrMainFrame();
- ASSERT(frame.selection().isCaret());
</del><span class="cx"> VisiblePosition position = frame.selection().selection().start();
</span><span class="cx"> frame.selection().setSelectedRange(wordRangeFromPosition(position).get(), position.affinity(), true);
</span><span class="cx"> }
</span><span class="lines">@@ -1271,6 +1267,18 @@
</span><span class="cx"> send(Messages::WebPageProxy::DictationContextCallback(selectedText, contextBefore, contextAfter, callbackID));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPage::replaceSelectedText(const String& oldText, const String& newText)
+{
+ Frame& frame = m_page->focusController().focusedOrMainFrame();
+ if (!frame.selection().isRange())
+ return;
+
+ if (plainText(frame.selection().toNormalizedRange().get()) != oldText)
+ return;
+
+ frame.editor().insertText(newText, 0);
+}
+
</ins><span class="cx"> void WebPage::replaceDictatedText(const String& oldText, const String& newText)
</span><span class="cx"> {
</span><span class="cx"> Frame& frame = m_page->focusController().focusedOrMainFrame();
</span></span></pre>
</div>
</div>
</body>
</html>