Changeset 249145 in webkit
- Timestamp:
- Aug 27, 2019, 9:19:34 AM (7 years ago)
- Location:
- branches/safari-608-branch
- Files:
-
- 2 added
- 6 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/events/ios/autocorrect-with-apostrophe-expected.txt (added)
-
LayoutTests/fast/events/ios/autocorrect-with-apostrophe.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/editing/TextIterator.cpp (modified) (3 diffs)
-
Source/WebCore/editing/TextIterator.h (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-608-branch/LayoutTests/ChangeLog
r249050 r249145 1 2019-08-27 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r249074. rdar://problem/54735492 4 5 [iOS] [WebKit2] Tapping on the “I’m” text suggestion after typing “i’” does nothing 6 https://bugs.webkit.org/show_bug.cgi?id=201085 7 <rdar://problem/53056118> 8 9 Reviewed by Tim Horton. 10 11 Source/WebCore: 12 13 Exposes an existing quote folding function as a helper on TextIterator, and also adjusts foldQuoteMarks to take 14 a const String& rather than a String. See WebKit ChangeLog for more details. 15 16 * editing/TextIterator.cpp: 17 (WebCore::foldQuoteMarks): 18 (WebCore::SearchBuffer::SearchBuffer): 19 * editing/TextIterator.h: 20 21 Source/WebKit: 22 23 Currently, logic in applyAutocorrectionInternal only selects the range to autocorrect if the text of the range 24 matches the string to replace (delivered to us from UIKit). In the case of changing "I’" to "I’m", the string to 25 replace is "I'" (with a straight quote rather than an apostrophe), even though the DOM contains an apostrophe. 26 27 This is because kbd believes that the document context contains straight quotes (rather than apostrophes). For 28 native text views, this works out because UIKit uses relative UITextPositions to determine the replacement 29 range rather than by checking against the contents of the document. However, WKWebView does not have the ability 30 to synchronously compute and reason about arbitrary UITextPositions relative to the selection, so we instead 31 search for the string near the current selection when applying autocorrections. 32 33 Of course, this doesn't work in this scenario because the replacement string contains a straight quote, yet the 34 text node contains an apostrophe, so we bail and don't end up replacing any text. To address this, we repurpose 35 TextIterator helpers currently used to allow find-in-page to match straight quotes against apostrophes; instead 36 of matching the replacement string exactly, we instead match the quote-folded versions of these strings when 37 finding the range to replace. 38 39 Test: fast/events/ios/autocorrect-with-apostrophe.html 40 41 * WebProcess/WebPage/ios/WebPageIOS.mm: 42 (WebKit::WebPage::applyAutocorrectionInternal): 43 44 LayoutTests: 45 46 Add a new layout test to verify that "I’" can be autocorrected to "I’m". 47 48 * fast/events/ios/autocorrect-with-apostrophe-expected.txt: Added. 49 * fast/events/ios/autocorrect-with-apostrophe.html: Added. 50 51 52 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249074 268f45cc-cd09-0410-ab3c-d52691b4dbfc 53 54 2019-08-23 Wenson Hsieh <wenson_hsieh@apple.com> 55 56 [iOS] [WebKit2] Tapping on the “I’m” text suggestion after typing “i’” does nothing 57 https://bugs.webkit.org/show_bug.cgi?id=201085 58 <rdar://problem/53056118> 59 60 Reviewed by Tim Horton. 61 62 Add a new layout test to verify that "I’" can be autocorrected to "I’m". 63 64 * fast/events/ios/autocorrect-with-apostrophe-expected.txt: Added. 65 * fast/events/ios/autocorrect-with-apostrophe.html: Added. 66 1 67 2019-08-23 Ryan Haddad <ryanhaddad@apple.com> 2 68 -
branches/safari-608-branch/Source/WebCore/ChangeLog
r249144 r249145 1 2019-08-27 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r249074. rdar://problem/54735492 4 5 [iOS] [WebKit2] Tapping on the “I’m” text suggestion after typing “i’” does nothing 6 https://bugs.webkit.org/show_bug.cgi?id=201085 7 <rdar://problem/53056118> 8 9 Reviewed by Tim Horton. 10 11 Source/WebCore: 12 13 Exposes an existing quote folding function as a helper on TextIterator, and also adjusts foldQuoteMarks to take 14 a const String& rather than a String. See WebKit ChangeLog for more details. 15 16 * editing/TextIterator.cpp: 17 (WebCore::foldQuoteMarks): 18 (WebCore::SearchBuffer::SearchBuffer): 19 * editing/TextIterator.h: 20 21 Source/WebKit: 22 23 Currently, logic in applyAutocorrectionInternal only selects the range to autocorrect if the text of the range 24 matches the string to replace (delivered to us from UIKit). In the case of changing "I’" to "I’m", the string to 25 replace is "I'" (with a straight quote rather than an apostrophe), even though the DOM contains an apostrophe. 26 27 This is because kbd believes that the document context contains straight quotes (rather than apostrophes). For 28 native text views, this works out because UIKit uses relative UITextPositions to determine the replacement 29 range rather than by checking against the contents of the document. However, WKWebView does not have the ability 30 to synchronously compute and reason about arbitrary UITextPositions relative to the selection, so we instead 31 search for the string near the current selection when applying autocorrections. 32 33 Of course, this doesn't work in this scenario because the replacement string contains a straight quote, yet the 34 text node contains an apostrophe, so we bail and don't end up replacing any text. To address this, we repurpose 35 TextIterator helpers currently used to allow find-in-page to match straight quotes against apostrophes; instead 36 of matching the replacement string exactly, we instead match the quote-folded versions of these strings when 37 finding the range to replace. 38 39 Test: fast/events/ios/autocorrect-with-apostrophe.html 40 41 * WebProcess/WebPage/ios/WebPageIOS.mm: 42 (WebKit::WebPage::applyAutocorrectionInternal): 43 44 LayoutTests: 45 46 Add a new layout test to verify that "I’" can be autocorrected to "I’m". 47 48 * fast/events/ios/autocorrect-with-apostrophe-expected.txt: Added. 49 * fast/events/ios/autocorrect-with-apostrophe.html: Added. 50 51 52 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249074 268f45cc-cd09-0410-ab3c-d52691b4dbfc 53 54 2019-08-23 Wenson Hsieh <wenson_hsieh@apple.com> 55 56 [iOS] [WebKit2] Tapping on the “I’m” text suggestion after typing “i’” does nothing 57 https://bugs.webkit.org/show_bug.cgi?id=201085 58 <rdar://problem/53056118> 59 60 Reviewed by Tim Horton. 61 62 Exposes an existing quote folding function as a helper on TextIterator, and also adjusts foldQuoteMarks to take 63 a const String& rather than a String. See WebKit ChangeLog for more details. 64 65 * editing/TextIterator.cpp: 66 (WebCore::foldQuoteMarks): 67 (WebCore::SearchBuffer::SearchBuffer): 68 * editing/TextIterator.h: 69 1 70 2019-08-27 Alan Coon <alancoon@apple.com> 2 71 -
branches/safari-608-branch/Source/WebCore/editing/TextIterator.cpp
r244200 r249145 1783 1783 // of doing it in a separate replacement pass here, but ICU doesn't offer a way 1784 1784 // to add tailoring on top of the locale-specific tailoring as of this writing. 1785 static inline String foldQuoteMarks(String string) 1786 { 1787 string.replace(hebrewPunctuationGeresh, '\''); 1788 string.replace(hebrewPunctuationGershayim, '"'); 1789 string.replace(leftDoubleQuotationMark, '"'); 1790 string.replace(leftLowDoubleQuotationMark, '"'); 1791 string.replace(leftSingleQuotationMark, '\''); 1792 string.replace(leftLowSingleQuotationMark, '\''); 1793 string.replace(rightDoubleQuotationMark, '"'); 1794 string.replace(rightSingleQuotationMark, '\''); 1795 1796 return string; 1785 String foldQuoteMarks(const String& stringToFold) 1786 { 1787 String result(stringToFold); 1788 result.replace(hebrewPunctuationGeresh, '\''); 1789 result.replace(hebrewPunctuationGershayim, '"'); 1790 result.replace(leftDoubleQuotationMark, '"'); 1791 result.replace(leftLowDoubleQuotationMark, '"'); 1792 result.replace(leftSingleQuotationMark, '\''); 1793 result.replace(leftLowSingleQuotationMark, '\''); 1794 result.replace(rightDoubleQuotationMark, '"'); 1795 result.replace(rightSingleQuotationMark, '\''); 1796 1797 return result; 1797 1798 } 1798 1799 … … 2411 2412 2412 2413 inline SearchBuffer::SearchBuffer(const String& target, FindOptions options) 2413 : m_target( options & CaseInsensitive ? target.foldCase() : target)2414 : m_target(foldQuoteMarks(options & CaseInsensitive ? target.foldCase() : target)) 2414 2415 , m_options(options) 2415 2416 , m_buffer(m_target.length()) … … 2420 2421 ASSERT(!m_target.isEmpty()); 2421 2422 m_target.replace(noBreakSpace, ' '); 2422 foldQuoteMarks(m_target);2423 2423 } 2424 2424 -
branches/safari-608-branch/Source/WebCore/editing/TextIterator.h
r244200 r249145 55 55 WEBCORE_EXPORT bool hasAnyPlainText(const Range&, TextIteratorBehavior = TextIteratorDefaultBehavior); 56 56 bool findPlainText(const String& document, const String&, FindOptions); // Lets us use the search algorithm on a string. 57 WEBCORE_EXPORT String foldQuoteMarks(const String&); 57 58 58 59 // FIXME: Move this somewhere else in the editing directory. It doesn't belong here. -
branches/safari-608-branch/Source/WebKit/ChangeLog
r249012 r249145 1 2019-08-27 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r249074. rdar://problem/54735492 4 5 [iOS] [WebKit2] Tapping on the “I’m” text suggestion after typing “i’” does nothing 6 https://bugs.webkit.org/show_bug.cgi?id=201085 7 <rdar://problem/53056118> 8 9 Reviewed by Tim Horton. 10 11 Source/WebCore: 12 13 Exposes an existing quote folding function as a helper on TextIterator, and also adjusts foldQuoteMarks to take 14 a const String& rather than a String. See WebKit ChangeLog for more details. 15 16 * editing/TextIterator.cpp: 17 (WebCore::foldQuoteMarks): 18 (WebCore::SearchBuffer::SearchBuffer): 19 * editing/TextIterator.h: 20 21 Source/WebKit: 22 23 Currently, logic in applyAutocorrectionInternal only selects the range to autocorrect if the text of the range 24 matches the string to replace (delivered to us from UIKit). In the case of changing "I’" to "I’m", the string to 25 replace is "I'" (with a straight quote rather than an apostrophe), even though the DOM contains an apostrophe. 26 27 This is because kbd believes that the document context contains straight quotes (rather than apostrophes). For 28 native text views, this works out because UIKit uses relative UITextPositions to determine the replacement 29 range rather than by checking against the contents of the document. However, WKWebView does not have the ability 30 to synchronously compute and reason about arbitrary UITextPositions relative to the selection, so we instead 31 search for the string near the current selection when applying autocorrections. 32 33 Of course, this doesn't work in this scenario because the replacement string contains a straight quote, yet the 34 text node contains an apostrophe, so we bail and don't end up replacing any text. To address this, we repurpose 35 TextIterator helpers currently used to allow find-in-page to match straight quotes against apostrophes; instead 36 of matching the replacement string exactly, we instead match the quote-folded versions of these strings when 37 finding the range to replace. 38 39 Test: fast/events/ios/autocorrect-with-apostrophe.html 40 41 * WebProcess/WebPage/ios/WebPageIOS.mm: 42 (WebKit::WebPage::applyAutocorrectionInternal): 43 44 LayoutTests: 45 46 Add a new layout test to verify that "I’" can be autocorrected to "I’m". 47 48 * fast/events/ios/autocorrect-with-apostrophe-expected.txt: Added. 49 * fast/events/ios/autocorrect-with-apostrophe.html: Added. 50 51 52 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249074 268f45cc-cd09-0410-ab3c-d52691b4dbfc 53 54 2019-08-23 Wenson Hsieh <wenson_hsieh@apple.com> 55 56 [iOS] [WebKit2] Tapping on the “I’m” text suggestion after typing “i’” does nothing 57 https://bugs.webkit.org/show_bug.cgi?id=201085 58 <rdar://problem/53056118> 59 60 Reviewed by Tim Horton. 61 62 Currently, logic in applyAutocorrectionInternal only selects the range to autocorrect if the text of the range 63 matches the string to replace (delivered to us from UIKit). In the case of changing "I’" to "I’m", the string to 64 replace is "I'" (with a straight quote rather than an apostrophe), even though the DOM contains an apostrophe. 65 66 This is because kbd believes that the document context contains straight quotes (rather than apostrophes). For 67 native text views, this works out because UIKit uses relative UITextPositions to determine the replacement 68 range rather than by checking against the contents of the document. However, WKWebView does not have the ability 69 to synchronously compute and reason about arbitrary UITextPositions relative to the selection, so we instead 70 search for the string near the current selection when applying autocorrections. 71 72 Of course, this doesn't work in this scenario because the replacement string contains a straight quote, yet the 73 text node contains an apostrophe, so we bail and don't end up replacing any text. To address this, we repurpose 74 TextIterator helpers currently used to allow find-in-page to match straight quotes against apostrophes; instead 75 of matching the replacement string exactly, we instead match the quote-folded versions of these strings when 76 finding the range to replace. 77 78 Test: fast/events/ios/autocorrect-with-apostrophe.html 79 80 * WebProcess/WebPage/ios/WebPageIOS.mm: 81 (WebKit::WebPage::applyAutocorrectionInternal): 82 1 83 2019-08-22 Kocsen Chung <kocsen_chung@apple.com> 2 84 -
branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r249012 r249145 2370 2370 RefPtr<Range> range; 2371 2371 String textForRange; 2372 auto originalTextWithFoldedQuoteMarks = foldQuoteMarks(originalText); 2372 2373 2373 2374 if (frame.selection().isCaret()) { … … 2375 2376 range = wordRangeFromPosition(position); 2376 2377 textForRange = plainTextReplacingNoBreakSpace(range.get()); 2377 if ( textForRange != originalText) {2378 if (foldQuoteMarks(textForRange) != originalTextWithFoldedQuoteMarks) { 2378 2379 // Search for the original text before the selection caret. 2379 2380 for (size_t i = 0; i < originalText.length(); ++i) … … 2405 2406 } 2406 2407 2407 if ( textForRange != originalText)2408 if (foldQuoteMarks(textForRange) != originalTextWithFoldedQuoteMarks) 2408 2409 return false; 2409 2410
Note:
See TracChangeset
for help on using the changeset viewer.