Title: [205765] trunk
Revision
205765
Author
[email protected]
Date
2016-09-09 13:46:23 -0700 (Fri, 09 Sep 2016)

Log Message

Text replacement candidates don't always overwrite the entire original string
https://bugs.webkit.org/show_bug.cgi?id=161779
<rdar://problem/28033492>

Reviewed by Simon Fraser.

Source/WebCore:

New test: editing/mac/spelling/accept-candidate-replacing-multiple-words.html.

* editing/Editor.cpp:
(WebCore::Editor::contextRangeForCandidateRequest):
Factor contextRangeForCandidateRequest out of the WebKits, into Editor.
This just expands to paragraph boundaries from the cursor.

(WebCore::Editor::selectTextCheckingResult):
Add selectTextCheckingResult, which, given a TextCheckingResult,
selects the range represented by the result's location and length, which
indicate the portion of the context string that the result refers to.
In the case of accepting a candidate, we want to select that range
so that our insertion will overwrite it.

(WebCore::Editor::handleAcceptedCandidate):
Make use of selectTextCheckingResult instead of just assuming that we want
to replace the word to the left of the insertion point.

(WebCore::Editor::stringForCandidateRequest): Deleted.
* editing/Editor.h:

* testing/Internals.cpp:
(WebCore::Internals::handleAcceptedCandidate):
* testing/Internals.h:
* testing/Internals.idl:
Internals' handleAcceptedCandidate assumed (wrongly) that the length
of a TextCheckerResult was the length of the candidate, when really it is
the length of the text that the candidate would replace. Adjust this,
and expose the replacement range to _javascript_, so we can test this.

Source/WebKit/mac:

* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::requestCandidatesForSelection):
Make use of the shared implementation of contextRangeForCandidateRequest.

Source/WebKit2:

* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformEditorState):
Make use of the shared implementation of contextRangeForCandidateRequest.

LayoutTests:

* editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html:
* editing/mac/spelling/accept-misspelled-candidate.html:
Adjust tests to send the correct replacement range.

* editing/mac/spelling/accept-candidate-replacing-multiple-words.html:
Add a test that ensures that we will replace the entire string for a
candidate that replaces multiple words.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (205764 => 205765)


--- trunk/LayoutTests/ChangeLog	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/LayoutTests/ChangeLog	2016-09-09 20:46:23 UTC (rev 205765)
@@ -1,3 +1,19 @@
+2016-09-09  Tim Horton  <[email protected]>
+
+        Text replacement candidates don't always overwrite the entire original string
+        https://bugs.webkit.org/show_bug.cgi?id=161779
+        <rdar://problem/28033492>
+
+        Reviewed by Simon Fraser.
+
+        * editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html:
+        * editing/mac/spelling/accept-misspelled-candidate.html:
+        Adjust tests to send the correct replacement range.
+
+        * editing/mac/spelling/accept-candidate-replacing-multiple-words.html:
+        Add a test that ensures that we will replace the entire string for a
+        candidate that replaces multiple words.
+
 2016-09-09  Ryan Haddad  <[email protected]>
 
         Rebaseline js/dom/global-constructors-attributes.html for mac-wk1  after r205755.

Added: trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words-expected.txt (0 => 205765)


--- trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words-expected.txt	2016-09-09 20:46:23 UTC (rev 205765)
@@ -0,0 +1,48 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 2 of #text > DIV > DIV > BODY > HTML > #document to 2 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of #text > DIV > DIV > BODY > HTML > #document to 2 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > DIV > DIV > BODY > HTML > #document to 3 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV > DIV > BODY > HTML > #document to 3 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > DIV > BODY > HTML > #document to 4 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV > DIV > BODY > HTML > #document to 3 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 6 of #text > DIV > DIV > BODY > HTML > #document to 6 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of #text > DIV > DIV > BODY > HTML > #document to 6 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 7 of #text > DIV > DIV > BODY > HTML > #document to 7 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > DIV > DIV > BODY > HTML > #document to 7 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 8 of #text > DIV > DIV > BODY > HTML > #document to 8 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > DIV > DIV > BODY > HTML > #document to 8 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertText:good idea replacingDOMRange:range from 0 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionTyped
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldInsertText:  replacingDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionTyped
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 10 of #text > DIV > DIV > BODY > HTML > #document to 10 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This test verifies that accepted candidates replace the entire range of the candidate source.
+
+good idea 

Copied: trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words.html (from rev 205764, trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html) (0 => 205765)


--- trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words.html	                        (rev 0)
+++ trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words.html	2016-09-09 20:46:23 UTC (rev 205765)
@@ -0,0 +1,39 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function editingTest() {
+    edit = document.getElementById('edit');
+    edit.focus();
+    typeCharacterCommand('g');
+    typeCharacterCommand('o');
+    typeCharacterCommand('o');
+    typeCharacterCommand(' ');
+    typeCharacterCommand('d');
+    typeCharacterCommand('i');
+    typeCharacterCommand('d');
+    typeCharacterCommand('e');
+    typeCharacterCommand('a');
+    
+    if (window.internals)
+        internals.handleAcceptedCandidate("good idea", 0, 9);
+
+    if (window.testRunner)
+        testRunner.dumpAsText(true);
+}
+
+</script>
+</head>
+<body>
+<p>This test verifies that accepted candidates replace the entire range of the candidate source.</p>
+<div style="border:1px solid black;">
+    <div contenteditable="true" id="edit"></div>
+</div>
+<script>
+runEditingTest();
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html (205764 => 205765)


--- trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html	2016-09-09 20:46:23 UTC (rev 205765)
@@ -10,7 +10,7 @@
     typeCharacterCommand('h');
     typeCharacterCommand('a');
     if (window.internals)
-        internals.handleAcceptedCandidate("happy");
+        internals.handleAcceptedCandidate("happy", 0, 2);
 
     if (window.testRunner)
         testRunner.dumpAsText(true);

Modified: trunk/LayoutTests/editing/mac/spelling/accept-misspelled-candidate.html (205764 => 205765)


--- trunk/LayoutTests/editing/mac/spelling/accept-misspelled-candidate.html	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/LayoutTests/editing/mac/spelling/accept-misspelled-candidate.html	2016-09-09 20:46:23 UTC (rev 205765)
@@ -16,7 +16,7 @@
     typeCharacterCommand('a');
     typeCharacterCommand(' ');
     if (window.internals)
-        internals.handleAcceptedCandidate("mesage");
+        internals.handleAcceptedCandidate("mesage", 0, 0);
     typeCharacterCommand(' ');
 
     if (window.testRunner)

Modified: trunk/Source/WebCore/ChangeLog (205764 => 205765)


--- trunk/Source/WebCore/ChangeLog	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/Source/WebCore/ChangeLog	2016-09-09 20:46:23 UTC (rev 205765)
@@ -1,3 +1,41 @@
+2016-09-09  Tim Horton  <[email protected]>
+
+        Text replacement candidates don't always overwrite the entire original string
+        https://bugs.webkit.org/show_bug.cgi?id=161779
+        <rdar://problem/28033492>
+
+        Reviewed by Simon Fraser.
+
+        New test: editing/mac/spelling/accept-candidate-replacing-multiple-words.html.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::contextRangeForCandidateRequest):
+        Factor contextRangeForCandidateRequest out of the WebKits, into Editor.
+        This just expands to paragraph boundaries from the cursor.
+
+        (WebCore::Editor::selectTextCheckingResult):
+        Add selectTextCheckingResult, which, given a TextCheckingResult,
+        selects the range represented by the result's location and length, which
+        indicate the portion of the context string that the result refers to.
+        In the case of accepting a candidate, we want to select that range
+        so that our insertion will overwrite it.
+
+        (WebCore::Editor::handleAcceptedCandidate):
+        Make use of selectTextCheckingResult instead of just assuming that we want
+        to replace the word to the left of the insertion point.
+
+        (WebCore::Editor::stringForCandidateRequest): Deleted.
+        * editing/Editor.h:
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::handleAcceptedCandidate):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        Internals' handleAcceptedCandidate assumed (wrongly) that the length
+        of a TextCheckerResult was the length of the candidate, when really it is
+        the length of the text that the candidate would replace. Adjust this,
+        and expose the replacement range to _javascript_, so we can test this.
+
 2016-09-09  Brady Eidson  <[email protected]>
 
         Soft-link GameController.framework.

Modified: trunk/Source/WebCore/editing/Editor.cpp (205764 => 205765)


--- trunk/Source/WebCore/editing/Editor.cpp	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/Source/WebCore/editing/Editor.cpp	2016-09-09 20:46:23 UTC (rev 205765)
@@ -3610,18 +3610,37 @@
 
     return String();
 }
+    
+RefPtr<Range> Editor::contextRangeForCandidateRequest() const
+{
+    const VisibleSelection& selection = m_frame.selection().selection();
+    return makeRange(startOfParagraph(selection.visibleStart()), endOfParagraph(selection.visibleEnd()));
+}
+    
+void Editor::selectTextCheckingResult(const TextCheckingResult& result)
+{
+    if (!result.length)
+        return;
+    
+    RefPtr<Range> contextRange = contextRangeForCandidateRequest();
+    if (!contextRange)
+        return;
+    
+    RefPtr<Range> replacementRange = TextIterator::subrange(contextRange.get(), result.location, result.length);
+    if (!replacementRange)
+        return;
+    
+    m_frame.selection().setSelectedRange(replacementRange.get(), UPSTREAM, true);
+}
 
 void Editor::handleAcceptedCandidate(TextCheckingResult acceptedCandidate)
 {
     const VisibleSelection& selection = m_frame.selection().selection();
-    RefPtr<Range> candidateRange = candidateRangeForSelection(m_frame);
     int candidateLength = acceptedCandidate.length;
 
     m_isHandlingAcceptedCandidate = true;
 
-    if (candidateWouldReplaceText(selection))
-        m_frame.selection().setSelectedRange(candidateRange.get(), UPSTREAM, true);
-
+    selectTextCheckingResult(acceptedCandidate);
     insertText(acceptedCandidate.replacement, 0);
 
     // Some candidates come with a space built in, and we do not need to add another space in that case.

Modified: trunk/Source/WebCore/editing/Editor.h (205764 => 205765)


--- trunk/Source/WebCore/editing/Editor.h	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/Source/WebCore/editing/Editor.h	2016-09-09 20:46:23 UTC (rev 205765)
@@ -466,6 +466,8 @@
 
     WEBCORE_EXPORT String stringForCandidateRequest() const;
     WEBCORE_EXPORT void handleAcceptedCandidate(TextCheckingResult);
+    WEBCORE_EXPORT RefPtr<Range> contextRangeForCandidateRequest() const;
+    void selectTextCheckingResult(const TextCheckingResult&);
     bool isHandlingAcceptedCandidate() const { return m_isHandlingAcceptedCandidate; }
 
 private:

Modified: trunk/Source/WebCore/testing/Internals.cpp (205764 => 205765)


--- trunk/Source/WebCore/testing/Internals.cpp	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/Source/WebCore/testing/Internals.cpp	2016-09-09 20:46:23 UTC (rev 205765)
@@ -1684,7 +1684,7 @@
 #endif
 }
 
-void Internals::handleAcceptedCandidate(const String& candidate, ExceptionCode&)
+void Internals::handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length, ExceptionCode&)
 {
     if (!contextDocument() || !contextDocument()->frame())
         return;
@@ -1691,7 +1691,8 @@
 
     TextCheckingResult result;
     result.type = TextCheckingTypeNone;
-    result.length = candidate.length();
+    result.location = location;
+    result.length = length;
     result.replacement = candidate;
     contextDocument()->frame()->editor().handleAcceptedCandidate(result);
 }

Modified: trunk/Source/WebCore/testing/Internals.h (205764 => 205765)


--- trunk/Source/WebCore/testing/Internals.h	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/Source/WebCore/testing/Internals.h	2016-09-09 20:46:23 UTC (rev 205765)
@@ -218,7 +218,7 @@
     void setAutomaticTextReplacementEnabled(bool enabled, ExceptionCode&);
     void setAutomaticSpellingCorrectionEnabled(bool enabled, ExceptionCode&);
 
-    void handleAcceptedCandidate(const String& candidate, ExceptionCode&);
+    void handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length, ExceptionCode&);
 
     bool isOverwriteModeEnabled(ExceptionCode&);
     void toggleOverwriteModeEnabled(ExceptionCode&);

Modified: trunk/Source/WebCore/testing/Internals.idl (205764 => 205765)


--- trunk/Source/WebCore/testing/Internals.idl	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/Source/WebCore/testing/Internals.idl	2016-09-09 20:46:23 UTC (rev 205765)
@@ -214,7 +214,7 @@
     [RaisesException] void setAutomaticTextReplacementEnabled(boolean enabled);
     [RaisesException] void setAutomaticSpellingCorrectionEnabled(boolean enabled);
 
-    [RaisesException] void handleAcceptedCandidate(DOMString candidate);
+    [RaisesException] void handleAcceptedCandidate(DOMString candidate, unsigned long location, unsigned long length);
 
     [RaisesException] boolean isOverwriteModeEnabled();
     [RaisesException] void toggleOverwriteModeEnabled();

Modified: trunk/Source/WebKit/mac/ChangeLog (205764 => 205765)


--- trunk/Source/WebKit/mac/ChangeLog	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-09-09 20:46:23 UTC (rev 205765)
@@ -1,3 +1,15 @@
+2016-09-09  Tim Horton  <[email protected]>
+
+        Text replacement candidates don't always overwrite the entire original string
+        https://bugs.webkit.org/show_bug.cgi?id=161779
+        <rdar://problem/28033492>
+
+        Reviewed by Simon Fraser.
+
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::requestCandidatesForSelection):
+        Make use of the shared implementation of contextRangeForCandidateRequest.
+
 2016-09-08  Said Abou-Hallawa  <[email protected]>
 
         Move the BitmapImage platform dependent code to a new file named NativeImage[CG|Cairo].cpp

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (205764 => 205765)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm	2016-09-09 20:46:23 UTC (rev 205765)
@@ -1163,6 +1163,10 @@
     RefPtr<Range> selectedRange = selection.toNormalizedRange();
     if (!selectedRange)
         return;
+    
+    Frame* frame = core([m_webView _selectedOrMainFrame]);
+    if (!frame)
+        return;
 
     m_lastSelectionForRequestedCandidates = selection;
 
@@ -1175,7 +1179,7 @@
     int lengthToSelectionStart = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
     int lengthToSelectionEnd = TextIterator::rangeLength(makeRange(paragraphStart, selectionEnd).get());
     m_rangeForCandidates = NSMakeRange(lengthToSelectionStart, lengthToSelectionEnd - lengthToSelectionStart);
-    m_paragraphContextForCandidateRequest = plainText(makeRange(paragraphStart, paragraphEnd).get());
+    m_paragraphContextForCandidateRequest = plainText(frame->editor().contextRangeForCandidateRequest().get());
 
     NSTextCheckingTypes checkingTypes = NSTextCheckingTypeSpelling | NSTextCheckingTypeReplacement | NSTextCheckingTypeCorrection;
     auto weakEditor = m_weakPtrFactory.createWeakPtr();

Modified: trunk/Source/WebKit2/ChangeLog (205764 => 205765)


--- trunk/Source/WebKit2/ChangeLog	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/Source/WebKit2/ChangeLog	2016-09-09 20:46:23 UTC (rev 205765)
@@ -1,3 +1,15 @@
+2016-09-09  Tim Horton  <[email protected]>
+
+        Text replacement candidates don't always overwrite the entire original string
+        https://bugs.webkit.org/show_bug.cgi?id=161779
+        <rdar://problem/28033492>
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::platformEditorState):
+        Make use of the shared implementation of contextRangeForCandidateRequest.
+
 2016-09-08  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix GTK+ build after r205689.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (205764 => 205765)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2016-09-09 20:27:34 UTC (rev 205764)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2016-09-09 20:46:23 UTC (rev 205765)
@@ -139,7 +139,7 @@
 
     postLayoutData.candidateRequestStartPosition = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
     postLayoutData.selectedTextLength = TextIterator::rangeLength(makeRange(paragraphStart, selectionEnd).get()) - postLayoutData.candidateRequestStartPosition;
-    postLayoutData.paragraphContextForCandidateRequest = plainText(makeRange(paragraphStart, paragraphEnd).get());
+    postLayoutData.paragraphContextForCandidateRequest = plainText(frame.editor().contextRangeForCandidateRequest().get());
     postLayoutData.stringForCandidateRequest = frame.editor().stringForCandidateRequest();
 
     IntRect rectForSelectionCandidates;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to