WebKit Bugzilla
Attachment 373069 Details for
Bug 199299
: macCatalyst: Selected range sometimes wrong after autocorrection
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199299-20190627163824.patch (text/plain), 9.82 KB, created by
Tim Horton
on 2019-06-27 16:38:25 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tim Horton
Created:
2019-06-27 16:38:25 PDT
Size:
9.82 KB
patch
obsolete
>Subversion Revision: 246898 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index dcb3e109101ae7c82471a0356db0837bcc825f13..ac74c9669e693648a77d5ea7dc6f50f35e5e0296 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,25 @@ >+2019-06-27 Tim Horton <timothy_horton@apple.com> >+ >+ macCatalyst: Selected range sometimes wrong after autocorrection >+ https://bugs.webkit.org/show_bug.cgi?id=199299 >+ <rdar://problem/49717224> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UIProcess/Cocoa/TextCheckingController.h: >+ * UIProcess/Cocoa/TextCheckingController.mm: >+ (WebKit::TextCheckingController::replaceRelativeToSelection): >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView replaceSelectionOffset:length:withAnnotatedString:relativeReplacementRange:]): >+ Plumb the whole relative replacement range through to the Web Content process. >+ >+ * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h: >+ * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in: >+ * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm: >+ (WebKit::TextCheckingControllerProxy::replaceRelativeToSelection): >+ Only replace the text of the substring that changed (the replacement range), >+ and fix up the selection offset math (it was really just wrong before). >+ > 2019-06-27 Carlos Garcia Campos <cgarcia@igalia.com> > > WebSockets: avoid data copies when queuing tasks in WebSocketChannel >diff --git a/Source/WebKit/UIProcess/Cocoa/TextCheckingController.h b/Source/WebKit/UIProcess/Cocoa/TextCheckingController.h >index 81a82fc35113a849077aa1e868bb2051e66cbeb0..0c2d6df54639a5f40efa4a81c177f9ac67766a05 100644 >--- a/Source/WebKit/UIProcess/Cocoa/TextCheckingController.h >+++ b/Source/WebKit/UIProcess/Cocoa/TextCheckingController.h >@@ -42,7 +42,7 @@ public: > explicit TextCheckingController(WebPageProxy&); > ~TextCheckingController() = default; > >- void replaceRelativeToSelection(NSAttributedString *annotatedString, int64_t selectionOffset, uint64_t length, bool textChanged); >+ void replaceRelativeToSelection(NSAttributedString *annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength); > void removeAnnotationRelativeToSelection(NSString *annotationName, int64_t selectionOffset, uint64_t length); > > private: >diff --git a/Source/WebKit/UIProcess/Cocoa/TextCheckingController.mm b/Source/WebKit/UIProcess/Cocoa/TextCheckingController.mm >index d370f0340dd5a9baf0b020ebdeaa36c91be8b014..f02083dcec733183f46c53ef63ab14ac145db801 100644 >--- a/Source/WebKit/UIProcess/Cocoa/TextCheckingController.mm >+++ b/Source/WebKit/UIProcess/Cocoa/TextCheckingController.mm >@@ -39,12 +39,12 @@ TextCheckingController::TextCheckingController(WebPageProxy& webPageProxy) > { > } > >-void TextCheckingController::replaceRelativeToSelection(NSAttributedString *annotatedString, int64_t selectionOffset, uint64_t length, bool textChanged) >+void TextCheckingController::replaceRelativeToSelection(NSAttributedString *annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength) > { > if (!m_page.hasRunningProcess()) > return; > >- m_page.process().send(Messages::TextCheckingControllerProxy::ReplaceRelativeToSelection(annotatedString, selectionOffset, length, textChanged), m_page.pageID()); >+ m_page.process().send(Messages::TextCheckingControllerProxy::ReplaceRelativeToSelection(annotatedString, selectionOffset, length, relativeReplacementLocation, relativeReplacementLength), m_page.pageID()); > } > > void TextCheckingController::removeAnnotationRelativeToSelection(NSString *annotationName, int64_t selectionOffset, uint64_t length) >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index 33938e495dfeb5b35d950d41cae488b982b2490f..88103601b21a534c1118cf1ea34a6fc8f73af497 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -5804,7 +5804,7 @@ - (void)selectWordForReplacement > #if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING) > - (void)replaceSelectionOffset:(NSInteger)selectionOffset length:(NSUInteger)length withAnnotatedString:(NSAttributedString *)annotatedString relativeReplacementRange:(NSRange)relativeReplacementRange > { >- _textCheckingController->replaceRelativeToSelection(annotatedString, selectionOffset, length, relativeReplacementRange.location != NSNotFound); >+ _textCheckingController->replaceRelativeToSelection(annotatedString, selectionOffset, length, relativeReplacementRange.location, relativeReplacementRange.length); > } > > - (void)removeAnnotation:(NSAttributedStringKey)annotationName forSelectionOffset:(NSInteger)selectionOffset length:(NSUInteger)length >diff --git a/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h b/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h >index 8dbc2b04e050bcea6f7205352564724f91906086..00a1e2e8e2633563c306998dd15a218b96d16512 100644 >--- a/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h >+++ b/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h >@@ -64,7 +64,7 @@ private: > Optional<RangeAndOffset> rangeAndOffsetRelativeToSelection(int64_t offset, uint64_t length); > > // Message handlers. >- void replaceRelativeToSelection(AttributedString, int64_t selectionOffset, uint64_t length, bool textChanged); >+ void replaceRelativeToSelection(AttributedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength); > void removeAnnotationRelativeToSelection(String annotationName, int64_t selectionOffset, uint64_t length); > > WebPage& m_page; >diff --git a/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in b/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in >index 1ffa271ce310a94348e21673822d21faaa43b3e9..6a425f7c32a6531e6b90736fc1ee686714382b69 100644 >--- a/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in >@@ -23,9 +23,9 @@ > #if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING) > > messages -> TextCheckingControllerProxy { >- ReplaceRelativeToSelection(struct WebKit::AttributedString annotatedString, int64_t selectionOffset, uint64_t length, bool textChanged) >+ ReplaceRelativeToSelection(struct WebKit::AttributedString annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength) > > RemoveAnnotationRelativeToSelection(String annotationName, int64_t selectionOffset, uint64_t length) > } > >-#endif >\ No newline at end of file >+#endif >diff --git a/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm b/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm >index b0b04674cb15e0410255b40615f2d06a06c0dfb9..1d5c0a6da552c65553fc18cfecad429b170c4ac9 100644 >--- a/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm >+++ b/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm >@@ -90,7 +90,7 @@ Optional<TextCheckingControllerProxy::RangeAndOffset> TextCheckingControllerProx > return {{ TextIterator::rangeFromLocationAndLength(root, selectionLocation, length), selectionLocation }}; > } > >-void TextCheckingControllerProxy::replaceRelativeToSelection(AttributedString annotatedString, int64_t selectionOffset, uint64_t length, bool textChanged) >+void TextCheckingControllerProxy::replaceRelativeToSelection(AttributedString annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength) > { > Frame& frame = m_page.corePage()->focusController().focusedOrMainFrame(); > FrameSelection& frameSelection = frame.selection(); >@@ -107,16 +107,20 @@ void TextCheckingControllerProxy::replaceRelativeToSelection(AttributedString an > auto& markers = frame.document()->markers(); > markers.removeMarkers(*range, relevantMarkerTypes()); > >- if (textChanged) { >- bool restoreSelection = frameSelection.selection().isRange(); >- >- frame.editor().replaceRangeForSpellChecking(*range, [annotatedString.string string]); >- >- size_t selectionLocationToRestore = locationInRoot - selectionOffset; >- if (restoreSelection && selectionLocationToRestore > locationInRoot + length) { >- selectionLocationToRestore -= locationInRoot - length; >- auto selectionToRestore = TextIterator::rangeFromLocationAndLength(root, selectionLocationToRestore, 0); >- frameSelection.moveTo(selectionToRestore.get()); >+ if (relativeReplacementLocation != NSNotFound) { >+ auto rangeAndOffsetOfReplacement = rangeAndOffsetRelativeToSelection(selectionOffset + relativeReplacementLocation, relativeReplacementLength); >+ if (rangeAndOffsetOfReplacement) { >+ auto replacementRange = rangeAndOffsetOfReplacement->range; >+ if (replacementRange) { >+ bool restoreSelection = frameSelection.selection().isRange(); >+ frame.editor().replaceRangeForSpellChecking(*replacementRange, [[annotatedString.string string] substringWithRange:NSMakeRange(relativeReplacementLocation, relativeReplacementLength)]); >+ >+ size_t selectionLocationToRestore = locationInRoot - selectionOffset; >+ if (restoreSelection && selectionLocationToRestore > locationInRoot + relativeReplacementLocation + relativeReplacementLength) { >+ auto selectionToRestore = TextIterator::rangeFromLocationAndLength(root, selectionLocationToRestore, 0); >+ frameSelection.moveTo(selectionToRestore.get()); >+ } >+ } > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199299
: 373069