WebKit Bugzilla
Attachment 361374 Details for
Bug 194373
: [iOS] [WK2] Modernize autocorrection context code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194373-20190206203952.patch (text/plain), 27.05 KB, created by
Wenson Hsieh
on 2019-02-06 20:39:53 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2019-02-06 20:39:53 PST
Size:
27.05 KB
patch
obsolete
>Subversion Revision: 241111 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 1d2bcb01951eba41bb81cbcb0dfd40460f1700ae..e384b3ce62b370ccdbabd0227de3889c6f9943d5 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,49 @@ >+2019-02-06 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] [WK2] Modernize autocorrection context code >+ https://bugs.webkit.org/show_bug.cgi?id=194373 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Shared/ios/WebAutocorrectionContext.h: Added. >+ (WebKit::WebAutocorrectionContext::encode const): >+ (WebKit::WebAutocorrectionContext::decode): >+ >+ Introduce a WebAutocorrectionContext struct that encapsulates the individual pieces of autocorrection context. >+ Change to use this instead of a long list of arguments when propagating autocorrection context information over >+ IPC. >+ >+ * UIProcess/AutoCorrectionCallback.h: >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/WebPageProxy.messages.in: >+ * UIProcess/ios/WKContentViewInteraction.h: >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]): >+ (+[WKAutocorrectionContext autocorrectionContextWithContext:]): >+ (+[WKAutocorrectionContext autocorrectionContextWithData:markedText:selectedText:afterText:selectedRangeInMarkedText:]): Deleted. >+ >+ Change this constructor to take an entire WebAutocorrectionContext. >+ >+ * UIProcess/ios/WebPageProxyIOS.mm: >+ (WebKit::WebPageProxy::autocorrectionContextCallback): >+ (WebKit::WebPageProxy::requestAutocorrectionContext): >+ (WebKit::WebPageProxy::getAutocorrectionContext): >+ * WebKit.xcodeproj/project.pbxproj: >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/WebPage.messages.in: >+ >+ Use Delayed instead of LegacySync. >+ >+ * WebProcess/WebPage/ios/WebPageIOS.mm: >+ (WebKit::WebPage::autocorrectionContext): >+ >+ Renamed from computeAutocorrectionContext. This is now a private method on WebPage that uses the focused or main >+ frame to compute and return a WebAutocorrectionContext. >+ >+ (WebKit::WebPage::requestAutocorrectionContext): >+ (WebKit::WebPage::getAutocorrectionContext): >+ (WebKit::computeAutocorrectionContext): Deleted. >+ > 2019-02-06 Wenson Hsieh <wenson_hsieh@apple.com> > > Allow pages to trigger programmatic paste from script on iOS >diff --git a/Source/WebKit/Shared/ios/WebAutocorrectionContext.h b/Source/WebKit/Shared/ios/WebAutocorrectionContext.h >new file mode 100644 >index 0000000000000000000000000000000000000000..2db33e3afa51c3308be1257997ea2ce0ded1f86c >--- /dev/null >+++ b/Source/WebKit/Shared/ios/WebAutocorrectionContext.h >@@ -0,0 +1,87 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "Decoder.h" >+#include "Encoder.h" >+#include <wtf/Optional.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebKit { >+ >+struct WebAutocorrectionContext { >+ String contextBefore; >+ String markedText; >+ String selectedText; >+ String contextAfter; >+ uint64_t location { 0 }; >+ uint64_t length { 0 }; >+ >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<WebAutocorrectionContext> decode(Decoder&); >+}; >+ >+template<class Encoder> inline void WebAutocorrectionContext::encode(Encoder& encoder) const >+{ >+ encoder << contextBefore << markedText << selectedText << contextAfter << location << length; >+} >+ >+template<class Decoder> inline Optional<WebAutocorrectionContext> WebAutocorrectionContext::decode(Decoder& decoder) >+{ >+ Optional<String> contextBefore; >+ decoder >> contextBefore; >+ if (!contextBefore) >+ return WTF::nullopt; >+ >+ Optional<String> markedText; >+ decoder >> markedText; >+ if (!markedText) >+ return WTF::nullopt; >+ >+ Optional<String> selectedText; >+ decoder >> selectedText; >+ if (!selectedText) >+ return WTF::nullopt; >+ >+ Optional<String> contextAfter; >+ decoder >> contextAfter; >+ if (!contextAfter) >+ return WTF::nullopt; >+ >+ Optional<uint64_t> location; >+ decoder >> location; >+ if (!location) >+ return WTF::nullopt; >+ >+ Optional<uint64_t> length; >+ decoder >> length; >+ if (!length) >+ return WTF::nullopt; >+ >+ return {{ WTFMove(*contextBefore), WTFMove(*markedText), WTFMove(*selectedText), WTFMove(*contextAfter), WTFMove(*location), WTFMove(*length) }}; >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/UIProcess/AutoCorrectionCallback.h b/Source/WebKit/UIProcess/AutoCorrectionCallback.h >index fca183cdcc0e2908981e7073847faf9ee1a1de8f..c9ba42fd1d94af7621d481723e667f1b805d010a 100644 >--- a/Source/WebKit/UIProcess/AutoCorrectionCallback.h >+++ b/Source/WebKit/UIProcess/AutoCorrectionCallback.h >@@ -29,13 +29,14 @@ > #include "APIError.h" > #include "GenericCallback.h" > #include "WKAPICast.h" >+#include "WebAutocorrectionContext.h" > #include <wtf/HashMap.h> > #include <wtf/RefCounted.h> > > namespace WebKit { > > typedef GenericCallback<const Vector<WebCore::FloatRect>&, const String&, double, uint64_t> AutocorrectionDataCallback; >-typedef GenericCallback<const String&, const String&, const String&, const String&, uint64_t, uint64_t> AutocorrectionContextCallback; >+typedef GenericCallback<const WebAutocorrectionContext&> AutocorrectionContextCallback; > typedef GenericCallback<const String&, const String&, const String&> SelectionContextCallback; > > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index b5fe927bb683e5b0620d787365f91a9094568342..80d86642d49a0d1085f6685505f6e3c0a59a95c5 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -640,8 +640,8 @@ public: > void requestAutocorrectionData(const String& textForAutocorrection, WTF::Function<void (const Vector<WebCore::FloatRect>&, const String&, double, uint64_t, CallbackBase::Error)>&&); > void applyAutocorrection(const String& correction, const String& originalText, WTF::Function<void (const String&, CallbackBase::Error)>&&); > bool applyAutocorrection(const String& correction, const String& originalText); >- void requestAutocorrectionContext(WTF::Function<void (const String&, const String&, const String&, const String&, uint64_t, uint64_t, CallbackBase::Error)>&&); >- void getAutocorrectionContext(String& contextBefore, String& markedText, String& selectedText, String& contextAfter, uint64_t& location, uint64_t& length); >+ void requestAutocorrectionContext(Function<void(const WebAutocorrectionContext&, CallbackBase::Error)>&&); >+ WebAutocorrectionContext getAutocorrectionContext(); > void requestDictationContext(WTF::Function<void (const String&, const String&, const String&, CallbackBase::Error)>&&); > void replaceDictatedText(const String& oldText, const String& newText); > void replaceSelectedText(const String& oldText, const String& newText); >@@ -1763,7 +1763,7 @@ private: > void gestureCallback(const WebCore::IntPoint&, uint32_t gestureType, uint32_t gestureState, uint32_t flags, CallbackID); > void touchesCallback(const WebCore::IntPoint&, uint32_t touches, uint32_t flags, CallbackID); > void autocorrectionDataCallback(const Vector<WebCore::FloatRect>&, const String& fontName, float fontSize, uint64_t fontTraits, CallbackID); >- void autocorrectionContextCallback(const String& beforeText, const String& markedText, const String& selectedText, const String& afterText, uint64_t location, uint64_t length, CallbackID); >+ void autocorrectionContextCallback(const WebAutocorrectionContext&, CallbackID); > void selectionContextCallback(const String& selectedText, const String& beforeText, const String& afterText, CallbackID); > void interpretKeyEvent(const EditorState&, bool isCharEvent, bool& handled); > void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&); >diff --git a/Source/WebKit/UIProcess/WebPageProxy.messages.in b/Source/WebKit/UIProcess/WebPageProxy.messages.in >index baa5a79a2dea17d3d771c2a765b930af40cc226c..f58bc2333fe43008c0e7a73841218a096b4679a3 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.messages.in >+++ b/Source/WebKit/UIProcess/WebPageProxy.messages.in >@@ -188,7 +188,7 @@ messages -> WebPageProxy { > GestureCallback(WebCore::IntPoint point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, WebKit::CallbackID callbackID) > TouchesCallback(WebCore::IntPoint point, uint32_t touches, uint32_t flags, WebKit::CallbackID callbackID) > AutocorrectionDataCallback(Vector<WebCore::FloatRect> textRects, String fontName, double fontSize, uint64_t traits, WebKit::CallbackID callbackID) >- AutocorrectionContextCallback(String beforeText, String markedText, String selectedText, String afterText, uint64_t location, uint64_t length, WebKit::CallbackID callbackID) >+ AutocorrectionContextCallback(struct WebKit::WebAutocorrectionContext context, WebKit::CallbackID callbackID) > SelectionContextCallback(String selectedText, String beforeText, String afterText, WebKit::CallbackID callbackID) > InterpretKeyEvent(struct WebKit::EditorState state, bool isCharEvent) -> (bool handled) LegacySync > DidReceivePositionInformation(struct WebKit::InteractionInformationAtPosition information) >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >index 6a5dbab11c6acc7e077e1b833cb8e42c012f58e7..c5c6fa0081b41dfb558d0cdf97c22c73b8b82bdd 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >@@ -177,7 +177,6 @@ struct WKAutoCorrectionData { > CGRect textFirstRect; > CGRect textLastRect; > UIWKAutocorrectionCompletionHandler autocorrectionHandler; >- UIWKAutocorrectionContextHandler autocorrectionContextHandler; > }; > > } >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index 64a40ea15e6a8739fc7e753c65939a4ed4c0efa2..f4e1c68e170a43fba67f0d40299d4d766844cedd 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -64,6 +64,7 @@ > #import "WKWebViewConfigurationPrivate.h" > #import "WKWebViewInternal.h" > #import "WKWebViewPrivate.h" >+#import "WebAutocorrectionContext.h" > #import "WebDataListSuggestionsDropdownIOS.h" > #import "WebEvent.h" > #import "WebIOSEventFactory.h" >@@ -271,7 +272,7 @@ + (WKAutocorrectionRects *)autocorrectionRectsWithRects:(CGRect)firstRect lastRe > @end > > @interface WKAutocorrectionContext : UIWKAutocorrectionContext >-+ (WKAutocorrectionContext *)autocorrectionContextWithData:(NSString *)beforeText markedText:(NSString *)markedText selectedText:(NSString *)selectedText afterText:(NSString *)afterText selectedRangeInMarkedText:(NSRange)range; >++ (WKAutocorrectionContext *)autocorrectionContextWithContext:(const WebKit::WebAutocorrectionContext&)context; > @end > > @interface UITextInteractionAssistant (UITextInteractionAssistant_Internal) >@@ -3436,25 +3437,20 @@ - (void)applyAutocorrection:(NSString *)correction toString:(NSString *)input wi > > - (void)requestAutocorrectionContextWithCompletionHandler:(void (^)(UIWKAutocorrectionContext *autocorrectionContext))completionHandler > { >+ if (!completionHandler) >+ return; >+ > // FIXME: Remove the synchronous call when <rdar://problem/16207002> is fixed. > const bool useSyncRequest = true; > > if (useSyncRequest) { >- String beforeText; >- String markedText; >- String selectedText; >- String afterText; >- uint64_t location; >- uint64_t length; >- _page->getAutocorrectionContext(beforeText, markedText, selectedText, afterText, location, length); >- completionHandler([WKAutocorrectionContext autocorrectionContextWithData:beforeText markedText:markedText selectedText:selectedText afterText:afterText selectedRangeInMarkedText:NSMakeRange(location, length)]); >- } else { >- _autocorrectionData.autocorrectionContextHandler = [completionHandler copy]; >- RetainPtr<WKContentView> view = self; >- _page->requestAutocorrectionContext([view](const String& beforeText, const String& markedText, const String& selectedText, const String& afterText, uint64_t location, uint64_t length, WebKit::CallbackBase::Error) { >- view->_autocorrectionData.autocorrectionContextHandler([WKAutocorrectionContext autocorrectionContextWithData:beforeText markedText:markedText selectedText:selectedText afterText:afterText selectedRangeInMarkedText:NSMakeRange(location, length)]); >- }); >+ completionHandler([WKAutocorrectionContext autocorrectionContextWithContext:_page->getAutocorrectionContext()]); >+ return; > } >+ >+ _page->requestAutocorrectionContext([protectedSelf = retainPtr(self), completion = makeBlockPtr(completionHandler)] (auto& context, auto) { >+ completion([WKAutocorrectionContext autocorrectionContextWithContext:context]); >+ }); > } > > // UIWebFormAccessoryDelegate >@@ -7179,19 +7175,19 @@ @end > > @implementation WKAutocorrectionContext > >-+ (WKAutocorrectionContext *)autocorrectionContextWithData:(NSString *)beforeText markedText:(NSString *)markedText selectedText:(NSString *)selectedText afterText:(NSString *)afterText selectedRangeInMarkedText:(NSRange)range >++ (WKAutocorrectionContext *)autocorrectionContextWithContext:(const WebKit::WebAutocorrectionContext&)webContext > { > WKAutocorrectionContext *context = [[WKAutocorrectionContext alloc] init]; > >- if ([beforeText length]) >- context.contextBeforeSelection = beforeText; >- if ([selectedText length]) >- context.selectedText = selectedText; >- if ([markedText length]) >- context.markedText = markedText; >- if ([afterText length]) >- context.contextAfterSelection = afterText; >- context.rangeInMarkedText = range; >+ if (!webContext.contextBefore.isEmpty()) >+ context.contextBeforeSelection = webContext.contextBefore; >+ if (!webContext.selectedText.isEmpty()) >+ context.selectedText = webContext.selectedText; >+ if (!webContext.markedText.isEmpty()) >+ context.markedText = webContext.markedText; >+ if (!webContext.contextAfter.isEmpty()) >+ context.contextAfterSelection = webContext.contextAfter; >+ context.rangeInMarkedText = NSMakeRange(webContext.location, webContext.length); > return [context autorelease]; > } > >diff --git a/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm b/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >index 4726894a93a787190746fd53c67d92820eab7ddf..31bfab41184d782f03c436a8539d6c33ba712bac 100644 >--- a/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >+++ b/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >@@ -46,6 +46,7 @@ > #import "VideoFullscreenManagerProxy.h" > #import "ViewUpdateDispatcherMessages.h" > #import "WKBrowsingContextControllerInternal.h" >+#import "WebAutocorrectionContext.h" > #import "WebPageMessages.h" > #import "WebProcessProxy.h" > #import <WebCore/FrameView.h> >@@ -166,7 +167,7 @@ void WebPageProxy::selectionContextCallback(const String& selectedText, const St > callback->performCallbackWithReturnValue(selectedText, beforeText, afterText); > } > >-void WebPageProxy::autocorrectionContextCallback(const String& beforeText, const String& markedText, const String& selectedText, const String& afterText, uint64_t location, uint64_t length, CallbackID callbackID) >+void WebPageProxy::autocorrectionContextCallback(const WebAutocorrectionContext& context, CallbackID callbackID) > { > auto callback = m_callbacks.take<AutocorrectionContextCallback>(callbackID); > if (!callback) { >@@ -174,7 +175,7 @@ void WebPageProxy::autocorrectionContextCallback(const String& beforeText, const > return; > } > >- callback->performCallbackWithReturnValue(beforeText, markedText, selectedText, afterText, location, length); >+ callback->performCallbackWithReturnValue(context); > } > > void WebPageProxy::selectionRectsCallback(const Vector<WebCore::SelectionRect>& selectionRects, CallbackID callbackID) >@@ -566,20 +567,22 @@ void WebPageProxy::requestDictationContext(WTF::Function<void (const String&, co > m_process->send(Messages::WebPage::RequestDictationContext(callbackID), m_pageID); > } > >-void WebPageProxy::requestAutocorrectionContext(WTF::Function<void (const String&, const String&, const String&, const String&, uint64_t, uint64_t, CallbackBase::Error)>&& callbackFunction) >+void WebPageProxy::requestAutocorrectionContext(Function<void(const WebAutocorrectionContext&, CallbackBase::Error)>&& callback) > { > if (!isValid()) { >- callbackFunction(String(), String(), String(), String(), 0, 0, CallbackBase::Error::Unknown); >+ callback({ }, CallbackBase::Error::OwnerWasInvalidated); > return; > } > >- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivityToken()); >+ auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivityToken()); > m_process->send(Messages::WebPage::RequestAutocorrectionContext(callbackID), m_pageID); > } > >-void WebPageProxy::getAutocorrectionContext(String& beforeContext, String& markedText, String& selectedText, String& afterContext, uint64_t& location, uint64_t& length) >+WebAutocorrectionContext WebPageProxy::getAutocorrectionContext() > { >- m_process->sendSync(Messages::WebPage::GetAutocorrectionContext(), Messages::WebPage::GetAutocorrectionContext::Reply(beforeContext, markedText, selectedText, afterContext, location, length), m_pageID); >+ WebAutocorrectionContext context; >+ m_process->sendSync(Messages::WebPage::GetAutocorrectionContext(), Messages::WebPage::GetAutocorrectionContext::Reply(context), m_pageID); >+ return context; > } > > void WebPageProxy::getSelectionContext(WTF::Function<void(const String&, const String&, const String&, CallbackBase::Error)>&& callbackFunction) >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 19ff6c0acca060a1acf43d364618988e29b17a37..c357f79ec08d4f681a2c1d3507fb84e2fbaed2c9 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -4520,6 +4520,7 @@ > ECBFC1DB1E6A4D66000300C7 /* ExtraPublicSymbolsForTAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExtraPublicSymbolsForTAPI.h; sourceTree = "<group>"; }; > F036978715F4BF0500C3A80E /* WebColorPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebColorPicker.cpp; sourceTree = "<group>"; }; > F409BA171E6E64B3009DA28E /* WKDragDestinationAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDragDestinationAction.h; sourceTree = "<group>"; }; >+ F40D1B68220BDC0F00B49A01 /* WebAutocorrectionContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebAutocorrectionContext.h; path = ios/WebAutocorrectionContext.h; sourceTree = "<group>"; }; > F41056612130699A0092281D /* APIAttachmentCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = APIAttachmentCocoa.mm; sourceTree = "<group>"; }; > F44291911FA59107002CC93E /* _WKAttachment.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKAttachment.h; sourceTree = "<group>"; }; > F44291931FA59311002CC93E /* _WKAttachment.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKAttachment.mm; sourceTree = "<group>"; }; >@@ -5803,6 +5804,7 @@ > 2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */, > A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */, > A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */, >+ F40D1B68220BDC0F00B49A01 /* WebAutocorrectionContext.h */, > F44DFEB01E9E752F0038D196 /* WebIconUtilities.h */, > F44DFEB11E9E752F0038D196 /* WebIconUtilities.mm */, > 2DA944991884E4F000ED86DB /* WebIOSEventFactory.h */, >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index dbe542c1ee173baf222ad45ce6d854782b34d480..e4cf66858170cfd994a80d2a79e156e0560c6a8a 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -250,6 +250,7 @@ struct InteractionInformationAtPosition; > struct InteractionInformationRequest; > struct LoadParameters; > struct PrintInfo; >+struct WebAutocorrectionContext; > struct WebPageCreationParameters; > struct WebPreferencesStore; > struct WebSelectionData; >@@ -647,7 +648,7 @@ public: > void applyAutocorrection(const String& correction, const String& originalText, CallbackID); > void syncApplyAutocorrection(const String& correction, const String& originalText, bool& correctionApplied); > void requestAutocorrectionContext(CallbackID); >- void getAutocorrectionContext(String& beforeText, String& markedText, String& selectedText, String& afterText, uint64_t& location, uint64_t& length); >+ void getAutocorrectionContext(CompletionHandler<void(WebAutocorrectionContext&&)>&&); > void getPositionInformation(const InteractionInformationRequest&, CompletionHandler<void(InteractionInformationAtPosition&&)>&&); > void requestPositionInformation(const InteractionInformationRequest&); > void startInteractionWithElementAtPosition(const WebCore::IntPoint&); >@@ -1191,6 +1192,7 @@ private: > > void sendPositionInformation(InteractionInformationAtPosition&&); > InteractionInformationAtPosition positionInformation(const InteractionInformationRequest&); >+ WebAutocorrectionContext autocorrectionContext(); > #endif > > #if PLATFORM(IOS_FAMILY) && ENABLE(DATA_INTERACTION) >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >index 776ed755639356dc50e04f3acabbbc89aabb566d..03f1ab4157a91a2b2a13457413444ff19f3cbb04 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >@@ -79,7 +79,7 @@ messages -> WebPage LegacyReceiver { > ApplyAutocorrection(String correction, String originalText, WebKit::CallbackID callbackID) > SyncApplyAutocorrection(String correction, String originalText) -> (bool autocorrectionApplied) LegacySync > RequestAutocorrectionContext(WebKit::CallbackID callbackID) >- GetAutocorrectionContext() -> (String beforeContext, String markedText, String selectedText, String afterContext, uint64_t location, uint64_t length) LegacySync >+ GetAutocorrectionContext() -> (struct WebKit::WebAutocorrectionContext context) Delayed > GetPositionInformation(struct WebKit::InteractionInformationRequest request) -> (struct WebKit::InteractionInformationAtPosition information) Delayed > RequestPositionInformation(struct WebKit::InteractionInformationRequest request) > StartInteractionWithElementAtPosition(WebCore::IntPoint point) >diff --git a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >index aeca58cd2417834e889ff82892db77368f7d64ca..aec4e931cc0fdab9a2eb07a2646dfc74e5221f74 100644 >--- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >+++ b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >@@ -45,6 +45,7 @@ > #import "UserData.h" > #import "VisibleContentRectUpdateInfo.h" > #import "WKAccessibilityWebPageObjectIOS.h" >+#import "WebAutocorrectionContext.h" > #import "WebChromeClient.h" > #import "WebCoreArgumentCoders.h" > #import "WebFrame.h" >@@ -1975,13 +1976,19 @@ void WebPage::syncApplyAutocorrection(const String& correction, const String& or > correctionApplied = true; > } > >-static void computeAutocorrectionContext(Frame& frame, String& contextBefore, String& markedText, String& selectedText, String& contextAfter, uint64_t& location, uint64_t& length) >+WebAutocorrectionContext WebPage::autocorrectionContext() > { >+ String contextBefore; >+ String markedText; >+ String selectedText; >+ String contextAfter; >+ uint64_t location = NSNotFound; >+ uint64_t length = 0; >+ >+ auto& frame = m_page->focusController().focusedOrMainFrame(); > RefPtr<Range> range; > VisiblePosition startPosition = frame.selection().selection().start(); > VisiblePosition endPosition = frame.selection().selection().end(); >- location = NSNotFound; >- length = 0; > const unsigned minContextWordCount = 3; > const unsigned minContextLenght = 12; > const unsigned maxContextLength = 30; >@@ -2035,25 +2042,17 @@ static void computeAutocorrectionContext(Frame& frame, String& contextBefore, St > contextAfter = plainTextReplacingNoBreakSpace(Range::create(*frame.document(), endPosition, nextPosition).ptr()); > } > } >+ return { WTFMove(contextBefore), WTFMove(markedText), WTFMove(selectedText), WTFMove(contextAfter), location, length }; > } > > void WebPage::requestAutocorrectionContext(CallbackID callbackID) > { >- String contextBefore; >- String contextAfter; >- String selectedText; >- String markedText; >- uint64_t location; >- uint64_t length; >- >- computeAutocorrectionContext(m_page->focusController().focusedOrMainFrame(), contextBefore, markedText, selectedText, contextAfter, location, length); >- >- send(Messages::WebPageProxy::AutocorrectionContextCallback(contextBefore, markedText, selectedText, contextAfter, location, length, callbackID)); >+ send(Messages::WebPageProxy::AutocorrectionContextCallback(autocorrectionContext(), callbackID)); > } > >-void WebPage::getAutocorrectionContext(String& contextBefore, String& markedText, String& selectedText, String& contextAfter, uint64_t& location, uint64_t& length) >+void WebPage::getAutocorrectionContext(CompletionHandler<void(WebAutocorrectionContext&&)>&& completionHandler) > { >- computeAutocorrectionContext(m_page->focusController().focusedOrMainFrame(), contextBefore, markedText, selectedText, contextAfter, location, length); >+ completionHandler(autocorrectionContext()); > } > > static HTMLAnchorElement* containingLinkElement(Element* element)
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 194373
:
361373
|
361374
|
361393
|
361405
|
361439