WebKit Bugzilla
Attachment 371085 Details for
Bug 198427
: [iOS] Autocorrection menu font is Times New Roman when using font-family: UICTFontTextStyle*
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198427-20190531141854.patch (text/plain), 46.10 KB, created by
Wenson Hsieh
on 2019-05-31 14:18:55 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2019-05-31 14:18:55 PDT
Size:
46.10 KB
patch
obsolete
>Subversion Revision: 245902 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index f114cb09bd0ad1557b7932adde52ddf1ed367f2d..205ab851c593f6e662de120f9f61455c346ed085 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,61 @@ >+2019-05-31 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] Autocorrection menu font is Times New Roman when using font-family: UICTFontTextStyle* >+ https://bugs.webkit.org/show_bug.cgi?id=198427 >+ <rdar://problem/50031825> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When UICTFontTextStyle* is specified as the font-family in an editable element, text in autocorrection bubbles >+ always uses Times New Roman font. This is because we send a font family name, font size, and font attributes to >+ the UI process when computing autocorrection data for UIKit, and then assemble this information into a UIFont >+ object via +[UIFont fontWithFamilyName:traits:size:]. However, in the case where UICTFontTextStyle* is specified >+ as the font-family in CSS, the font family that we send to the UI process ends up being ".AppleSystemUIFont", >+ which +fontWithFamilyName:traits:size: fails to map to the system font as intended. >+ >+ To fix this, we propagate font information to the UI process by encoding the UIFont itself via IPC, which >+ serializes the font descriptor, and then deserializes into a UIFont in the UI process. This allows the system >+ font to be returned in -fontForCaretSelection, which is invoked by UIKit when determining the font for the >+ autocorrection bubble. See below for more details. >+ >+ Test: AutocorrectionTests.FontAtCaretWhenUsingUICTFontTextStyle >+ >+ * Shared/ios/WebAutocorrectionData.h: Copied from Source/WebKit/UIProcess/AutoCorrectionCallback.h. >+ * Shared/ios/WebAutocorrectionData.mm: Renamed from Source/WebKit/UIProcess/AutoCorrectionCallback.h. >+ (WebKit::WebAutocorrectionData::encode const): >+ (WebKit::WebAutocorrectionData::decode): >+ >+ Introduce WebAutocorrectionData, a struct containing information used to show autocorrection UI on iOS (i.e. >+ highlights and the bubble). This consists of a list of rects, along with a UIFont. >+ >+ * SourcesCocoa.txt: >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/WebPageProxy.messages.in: >+ >+ Refactor requestAutocorrectionData to request a WebAutocorrectionData instead, and also use the new async IPC >+ reply mechanism. >+ >+ * UIProcess/ios/WKContentViewInteraction.h: >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView requestAutocorrectionRectsForString:withCompletionHandler:]): >+ (-[WKContentView fontForCaretSelection]): >+ >+ Grab the UIFont directly from the WebAutocorrectionData. Also, address a FIXME by scaling the font size by the >+ content scale. >+ >+ * UIProcess/ios/WebPageProxyIOS.mm: >+ (WebKit::WebPageProxy::requestAutocorrectionData): >+ (WebKit::WebPageProxy::autocorrectionDataCallback): Deleted. >+ (WebKit::WebPageProxy::autocorrectionContextCallback): Deleted. >+ >+ Remove some IPC callbacks that are now unused. >+ >+ * WebKit.xcodeproj/project.pbxproj: >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/WebPage.messages.in: >+ * WebProcess/WebPage/ios/WebPageIOS.mm: >+ (WebKit::WebPage::requestAutocorrectionData): >+ > 2019-05-30 Wenson Hsieh <wenson_hsieh@apple.com> > > Missing caret when focusing an editable field if the selection was set when WKWebView wasn't first responder >diff --git a/Source/WebKit/Shared/ios/WebAutocorrectionData.h b/Source/WebKit/Shared/ios/WebAutocorrectionData.h >new file mode 100644 >index 0000000000000000000000000000000000000000..d74014d57389a5b0b2be4cce617b8946a0169198 >--- /dev/null >+++ b/Source/WebKit/Shared/ios/WebAutocorrectionData.h >@@ -0,0 +1,57 @@ >+/* >+ * 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 >+ >+#if PLATFORM(IOS_FAMILY) >+ >+#include <wtf/Optional.h> >+#include <wtf/RetainPtr.h> >+#include <wtf/Vector.h> >+ >+namespace IPC { >+class Decoder; >+class Encoder; >+} >+ >+namespace WebCore { >+class FloatRect; >+} >+ >+OBJC_CLASS UIFont; >+ >+namespace WebKit { >+ >+struct WebAutocorrectionData { >+ Vector<WebCore::FloatRect> textRects; >+ RetainPtr<UIFont> font; >+ >+ void encode(IPC::Encoder&) const; >+ static Optional<WebAutocorrectionData> decode(IPC::Decoder&); >+}; >+ >+} // namespace WebKit >+ >+#endif // PLATFORM(IOS_FAMILY) >diff --git a/Source/WebKit/Shared/ios/WebAutocorrectionData.mm b/Source/WebKit/Shared/ios/WebAutocorrectionData.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..9a478f47d5a2055b8fb2b118afdf5b860f1cd8e2 >--- /dev/null >+++ b/Source/WebKit/Shared/ios/WebAutocorrectionData.mm >@@ -0,0 +1,58 @@ >+/* >+ * 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. >+ */ >+ >+#import "config.h" >+#import "WebAutocorrectionData.h" >+ >+#import "ArgumentCodersCocoa.h" >+#import "Decoder.h" >+#import "Encoder.h" >+#import "WebCoreArgumentCoders.h" >+#import <WebCore/FloatRect.h> >+ >+namespace WebKit { >+using namespace WebCore; >+ >+void WebAutocorrectionData::encode(IPC::Encoder& encoder) const >+{ >+ encoder << textRects; >+ IPC::encode(encoder, font.get()); >+} >+ >+Optional<WebAutocorrectionData> WebAutocorrectionData::decode(IPC::Decoder& decoder) >+{ >+ Optional<Vector<FloatRect>> textRects; >+ decoder >> textRects; >+ if (!textRects) >+ return WTF::nullopt; >+ >+ RetainPtr<UIFont> font; >+ if (!IPC::decode(decoder, font, @[ UIFont.class ])) >+ return WTF::nullopt; >+ >+ return {{ *textRects, font }}; >+} >+ >+} >diff --git a/Source/WebKit/SourcesCocoa.txt b/Source/WebKit/SourcesCocoa.txt >index a3fb03d2f35e4c85954cde8b3c397782e60c455a..ae6fe6ddc2f997778c49593a4cb1ec61f11a426e 100644 >--- a/Source/WebKit/SourcesCocoa.txt >+++ b/Source/WebKit/SourcesCocoa.txt >@@ -172,6 +172,7 @@ Shared/ios/NativeWebKeyboardEventIOS.mm > Shared/ios/NativeWebMouseEventIOS.mm > Shared/ios/NativeWebTouchEventIOS.mm > Shared/ios/QuickLookDocumentData.cpp >+Shared/ios/WebAutocorrectionData.mm > Shared/ios/WebIconUtilities.mm > Shared/ios/WebIOSEventFactory.mm > Shared/ios/WebPlatformTouchPointIOS.cpp >diff --git a/Source/WebKit/UIProcess/AutoCorrectionCallback.h b/Source/WebKit/UIProcess/AutoCorrectionCallback.h >deleted file mode 100644 >index 380856fadd8866771c5e312063b2363016b700f8..0000000000000000000000000000000000000000 >--- a/Source/WebKit/UIProcess/AutoCorrectionCallback.h >+++ /dev/null >@@ -1,45 +0,0 @@ >-/* >- * Copyright (C) 2013 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. >- */ >- >-#ifndef AutoCorrectionCallback_h >-#define AutoCorrectionCallback_h >- >-#include "APIError.h" >-#include "GenericCallback.h" >-#include "WKAPICast.h" >-#include <wtf/HashMap.h> >-#include <wtf/RefCounted.h> >- >-namespace WebKit { >- >-struct WebAutocorrectionContext; >- >-typedef GenericCallback<const Vector<WebCore::FloatRect>&, const String&, double, uint64_t> AutocorrectionDataCallback; >-typedef GenericCallback<const WebAutocorrectionContext&> AutocorrectionContextCallback; >-typedef GenericCallback<const String&, const String&, const String&> SelectionContextCallback; >- >-} // namespace WebKit >- >-#endif // AutoCorrectionCallback_h >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 4b003d689d882ff2dca5662df517a5b62aa7b011..6b4d34856c986d91b47052c75f51ba5987633b48 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -26,7 +26,6 @@ > #pragma once > > #include "APIObject.h" >-#include "AutoCorrectionCallback.h" > #include "Connection.h" > #include "ContextMenuContextData.h" > #include "DownloadID.h" >@@ -291,6 +290,7 @@ struct LoadParameters; > struct PlatformPopupMenuData; > struct PrintInfo; > struct TextInputContext; >+struct WebAutocorrectionData; > struct WebPopupItem; > struct URLSchemeTaskParameters; > >@@ -307,6 +307,7 @@ typedef GenericCallback<EditingRange> EditingRangeCallback; > typedef GenericCallback<const String&> StringCallback; > typedef GenericCallback<API::SerializedScriptValue*, bool, const WebCore::ExceptionDetails&> ScriptValueCallback; > typedef GenericCallback<const WebCore::FontAttributes&> FontAttributesCallback; >+typedef GenericCallback<const String&, const String&, const String&> SelectionContextCallback; > > #if HAVE(VISIBILITY_PROPAGATION_VIEW) > using LayerHostingContextID = uint32_t; >@@ -678,7 +679,7 @@ public: > void beginSelectionInDirection(WebCore::SelectionDirection, WTF::Function<void (uint64_t, CallbackBase::Error)>&&); > void updateSelectionWithExtentPoint(const WebCore::IntPoint, bool isInteractingWithFocusedElement, WTF::Function<void(uint64_t, CallbackBase::Error)>&&); > void updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint, WebCore::TextGranularity, bool isInteractingWithFocusedElement, WTF::Function<void(uint64_t, CallbackBase::Error)>&&); >- void requestAutocorrectionData(const String& textForAutocorrection, WTF::Function<void (const Vector<WebCore::FloatRect>&, const String&, double, uint64_t, CallbackBase::Error)>&&); >+ void requestAutocorrectionData(const String& textForAutocorrection, CompletionHandler<void(WebAutocorrectionData)>&&); > 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(); >@@ -1869,8 +1870,6 @@ private: > #if PLATFORM(IOS_FAMILY) > 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 WebAutocorrectionContext&, CallbackID); > void selectionContextCallback(const String& selectedText, const String& beforeText, const String& afterText, CallbackID); > void interpretKeyEvent(const EditorState&, bool isCharEvent, CompletionHandler<void(bool)>&&); > 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 a849847b535d26e14cbd28020b379a7f1757d715..c008f2cbfc44e9e6f87bf4087f60d591a39b47ac 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.messages.in >+++ b/Source/WebKit/UIProcess/WebPageProxy.messages.in >@@ -186,8 +186,6 @@ messages -> WebPageProxy { > #if PLATFORM(IOS_FAMILY) > 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(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) Synchronous > DidReceivePositionInformation(struct WebKit::InteractionInformationAtPosition information) >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >index 7917db6da7ef25e84997fda5876daeff2a12ab5e..e4bc469d28ff560b2376c6cb606380abc247556a 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >@@ -181,9 +181,7 @@ struct WKSelectionDrawingInfo { > WTF::TextStream& operator<<(WTF::TextStream&, const WKSelectionDrawingInfo&); > > struct WKAutoCorrectionData { >- String fontName; >- CGFloat fontSize; >- uint64_t fontTraits; >+ RetainPtr<UIFont> font; > CGRect textFirstRect; > CGRect textLastRect; > }; >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index d7840b9f691c2710ae0f3b6fa9a29bdbeca20bf9..02ae122553ea4a29078cca376a202daff6d586ce 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -65,6 +65,7 @@ > #import "WKWebViewInternal.h" > #import "WKWebViewPrivate.h" > #import "WebAutocorrectionContext.h" >+#import "WebAutocorrectionData.h" > #import "WebDataListSuggestionsDropdownIOS.h" > #import "WebEvent.h" > #import "WebIOSEventFactory.h" >@@ -3529,9 +3530,10 @@ - (void)requestAutocorrectionRectsForString:(NSString *)input withCompletionHand > return; > } > >- _page->requestAutocorrectionData(input, [view = retainPtr(self), completion = makeBlockPtr(completionHandler)](auto& rects, auto& fontName, double fontSize, uint64_t traits, auto) { >+ _page->requestAutocorrectionData(input, [view = retainPtr(self), completion = makeBlockPtr(completionHandler)](auto data) { > CGRect firstRect; > CGRect lastRect; >+ auto& rects = data.textRects; > if (rects.isEmpty()) { > firstRect = CGRectZero; > lastRect = CGRectZero; >@@ -3540,9 +3542,7 @@ - (void)requestAutocorrectionRectsForString:(NSString *)input withCompletionHand > lastRect = rects.last(); > } > >- view->_autocorrectionData.fontName = fontName; >- view->_autocorrectionData.fontSize = fontSize; >- view->_autocorrectionData.fontTraits = traits; >+ view->_autocorrectionData.font = data.font; > view->_autocorrectionData.textFirstRect = firstRect; > view->_autocorrectionData.textLastRect = lastRect; > >@@ -4900,11 +4900,9 @@ - (UIColor *)textColorForCaretSelection > > - (UIFont *)fontForCaretSelection > { >- CGFloat zoomScale = 1.0; // FIXME: retrieve the actual document scale factor. >- CGFloat scaledSize = _autocorrectionData.fontSize; >- if (CGFAbs(zoomScale - 1.0) > FLT_EPSILON) >- scaledSize *= zoomScale; >- return [UIFont fontWithFamilyName:_autocorrectionData.fontName traits:(UIFontTrait)_autocorrectionData.fontTraits size:scaledSize]; >+ UIFont *font = _autocorrectionData.font.get(); >+ double zoomScale = self._contentZoomScale; >+ return std::abs(zoomScale - 1) > FLT_EPSILON ? [font fontWithSize:font.pointSize * zoomScale] : font; > } > > - (BOOL)hasSelection >diff --git a/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm b/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >index 8e9bed5effd43f77e8ae85ed858a9015dd184560..a3f82eabddae10dc42e4e775093a2a600b6fd233 100644 >--- a/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >+++ b/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >@@ -52,6 +52,7 @@ > #import "ViewUpdateDispatcherMessages.h" > #import "WKBrowsingContextControllerInternal.h" > #import "WebAutocorrectionContext.h" >+#import "WebAutocorrectionData.h" > #import "WebPageMessages.h" > #import "WebProcessPool.h" > #import "WebProcessProxy.h" >@@ -160,17 +161,6 @@ void WebPageProxy::touchesCallback(const WebCore::IntPoint& point, uint32_t touc > callback->performCallbackWithReturnValue(point, touches, flags); > } > >-void WebPageProxy::autocorrectionDataCallback(const Vector<WebCore::FloatRect>& rects, const String& fontName, float fontSize, uint64_t fontTraits, CallbackID callbackID) >-{ >- auto callback = m_callbacks.take<AutocorrectionDataCallback>(callbackID); >- if (!callback) { >- ASSERT_NOT_REACHED(); >- return; >- } >- >- callback->performCallbackWithReturnValue(rects, fontName, fontSize, fontTraits); >-} >- > void WebPageProxy::selectionContextCallback(const String& selectedText, const String& beforeText, const String& afterText, CallbackID callbackID) > { > auto callback = m_callbacks.take<SelectionContextCallback>(callbackID); >@@ -182,17 +172,6 @@ void WebPageProxy::selectionContextCallback(const String& selectedText, const St > callback->performCallbackWithReturnValue(selectedText, beforeText, afterText); > } > >-void WebPageProxy::autocorrectionContextCallback(const WebAutocorrectionContext& context, CallbackID callbackID) >-{ >- auto callback = m_callbacks.take<AutocorrectionContextCallback>(callbackID); >- if (!callback) { >- ASSERT_NOT_REACHED(); >- return; >- } >- >- callback->performCallbackWithReturnValue(context); >-} >- > void WebPageProxy::selectionRectsCallback(const Vector<WebCore::SelectionRect>& selectionRects, CallbackID callbackID) > { > auto callback = m_callbacks.take<SelectionRectsCallback>(callbackID); >@@ -464,15 +443,13 @@ void WebPageProxy::replaceSelectedText(const String& oldText, const String& newT > m_process->send(Messages::WebPage::ReplaceSelectedText(oldText, newText), m_pageID); > } > >-void WebPageProxy::requestAutocorrectionData(const String& textForAutocorrection, WTF::Function<void (const Vector<WebCore::FloatRect>&, const String&, double, uint64_t, CallbackBase::Error)>&& callbackFunction) >+void WebPageProxy::requestAutocorrectionData(const String& textForAutocorrection, CompletionHandler<void(WebAutocorrectionData)>&& callback) > { > if (!hasRunningProcess()) { >- callbackFunction(Vector<WebCore::FloatRect>(), String(), 0, 0, CallbackBase::Error::Unknown); >+ callback({ }); > return; > } >- >- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivityToken()); >- m_process->send(Messages::WebPage::RequestAutocorrectionData(textForAutocorrection, callbackID), m_pageID); >+ m_process->connection()->sendWithAsyncReply(Messages::WebPage::RequestAutocorrectionData(textForAutocorrection), WTFMove(callback), m_pageID); > } > > void WebPageProxy::applyAutocorrection(const String& correction, const String& originalText, WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction) >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index ddb3a3000caef7235c2646cd0f4048cbceb560a2..a8e1c072bb4edabd6a3cb41e7446338381951bea 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -1192,7 +1192,6 @@ > 7CBB81211AA0F970006B1942 /* WKBundleFileHandleRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CBB811F1AA0F970006B1942 /* WKBundleFileHandleRef.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 7CC99A3618EF7CBC0048C8B4 /* WKScriptMessageInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC99A3518EF7CBC0048C8B4 /* WKScriptMessageInternal.h */; }; > 7CCCC8FB1A5F50FD008FB0DA /* WebNavigationState.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CCCC8F91A5F50FD008FB0DA /* WebNavigationState.h */; }; >- 7CD102DA1866770600ED429D /* AutoCorrectionCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD102D91866770600ED429D /* AutoCorrectionCallback.h */; }; > 7CD3A4831A5D02FA009623B8 /* APINavigation.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD3A4811A5D02FA009623B8 /* APINavigation.h */; }; > 7CD5EBB91746A15B000C1C45 /* WKObjCTypeWrapperRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD5EBB71746A15B000C1C45 /* WKObjCTypeWrapperRef.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 7CD5EBBB1746A83E000C1C45 /* WKBaseMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD5EBBA1746A83E000C1C45 /* WKBaseMac.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -1653,6 +1652,7 @@ > ECA680D81E690E2500731D20 /* WebProcessCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = ECA680D71E690DF800731D20 /* WebProcessCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; }; > ED82A7F2128C6FAF004477B3 /* WKBundlePageOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A22F0FF1289FCD90085E74F /* WKBundlePageOverlay.h */; settings = {ATTRIBUTES = (Private, ); }; }; > F409BA181E6E64BC009DA28E /* WKDragDestinationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = F409BA171E6E64B3009DA28E /* WKDragDestinationAction.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ F42D634122A0EFDF00D2FB3A /* WebAutocorrectionData.h in Headers */ = {isa = PBXBuildFile; fileRef = F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */; }; > F430E9422247335F005FE053 /* WebsiteMetaViewportPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E941224732A9005FE053 /* WebsiteMetaViewportPolicy.h */; }; > F430E94422473DFF005FE053 /* WebCompatibilityMode.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E94322473DB8005FE053 /* WebCompatibilityMode.h */; }; > F438CD1C2241421400DE6DDA /* WKWebpagePreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */; settings = {ATTRIBUTES = (Public, ); }; }; >@@ -3728,7 +3728,6 @@ > 7CC99A3518EF7CBC0048C8B4 /* WKScriptMessageInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKScriptMessageInternal.h; sourceTree = "<group>"; }; > 7CCCC8F81A5F50FD008FB0DA /* WebNavigationState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNavigationState.cpp; sourceTree = "<group>"; }; > 7CCCC8F91A5F50FD008FB0DA /* WebNavigationState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNavigationState.h; sourceTree = "<group>"; }; >- 7CD102D91866770600ED429D /* AutoCorrectionCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoCorrectionCallback.h; sourceTree = "<group>"; }; > 7CD3A4801A5D02FA009623B8 /* APINavigation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APINavigation.cpp; sourceTree = "<group>"; }; > 7CD3A4811A5D02FA009623B8 /* APINavigation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APINavigation.h; sourceTree = "<group>"; }; > 7CD5EBB61746A15B000C1C45 /* WKObjCTypeWrapperRef.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKObjCTypeWrapperRef.mm; sourceTree = "<group>"; }; >@@ -4624,6 +4623,8 @@ > 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>"; }; >+ F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAutocorrectionData.h; path = ios/WebAutocorrectionData.h; sourceTree = "<group>"; }; >+ F42D634022A0EFD300D2FB3A /* WebAutocorrectionData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebAutocorrectionData.mm; path = ios/WebAutocorrectionData.mm; sourceTree = "<group>"; }; > F430E941224732A9005FE053 /* WebsiteMetaViewportPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebsiteMetaViewportPolicy.h; sourceTree = "<group>"; }; > F430E94322473DB8005FE053 /* WebCompatibilityMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCompatibilityMode.h; sourceTree = "<group>"; }; > F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferences.h; sourceTree = "<group>"; }; >@@ -5900,6 +5901,8 @@ > 2DA944961884E4DA00ED86DB /* ios */ = { > isa = PBXGroup; > children = ( >+ F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */, >+ F42D634022A0EFD300D2FB3A /* WebAutocorrectionData.mm */, > A7E93CEB192531AA00A1DC48 /* AuxiliaryProcessIOS.mm */, > 2DA6731920C754B1003CB401 /* DynamicViewportSizeUpdate.h */, > 2DA9449D1884E4F000ED86DB /* GestureTypes.h */, >@@ -7518,7 +7521,6 @@ > 1AAF089E192681AC00B6390C /* UserContent */, > 57608294202BD84900116678 /* WebAuthentication */, > 1A53C2A31A325691004E8C70 /* WebsiteData */, >- 7CD102D91866770600ED429D /* AutoCorrectionCallback.h */, > E1513C64166EABB200149FCB /* AuxiliaryProcessProxy.cpp */, > E1513C65166EABB200149FCB /* AuxiliaryProcessProxy.h */, > 46A2B6061E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.cpp */, >@@ -9185,7 +9187,6 @@ > 57DCEDB1214C60480016B847 /* Authenticator.h in Headers */, > 57DCEDAF214C603B0016B847 /* AuthenticatorManager.h in Headers */, > 57DCEDB0214C60420016B847 /* AuthenticatorTransportService.h in Headers */, >- 7CD102DA1866770600ED429D /* AutoCorrectionCallback.h in Headers */, > 9955A6EF1C79810800EB6A93 /* Automation.json in Headers */, > 9955A6F51C7986E000EB6A93 /* AutomationBackendDispatchers.h in Headers */, > 99C81D5A1C20E7E2005C4C82 /* AutomationClient.h in Headers */, >@@ -9969,6 +9970,7 @@ > A518B5D21FE1D55B00F9FA28 /* WKInspectorWKWebView.h in Headers */, > 2DD5E129210ADC7B00DB6012 /* WKKeyboardScrollingAnimator.h in Headers */, > 51A9E10B1315CD18009E7031 /* WKKeyValueStorageManager.h in Headers */, >+ F42D634122A0EFDF00D2FB3A /* WebAutocorrectionData.h in Headers */, > 2D790A9F1AD7164900AB90B3 /* WKLayoutMode.h in Headers */, > 5CE912142293C280005BEC78 /* WKMain.h in Headers */, > C98C48AA1B6FD5B500145103 /* WKMediaSessionFocusManager.h in Headers */, >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index b0b13f78e423c0a25752554920d1996011add998..e0dc028302a57f34a86effb166a77ef3bc170580 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -264,6 +264,7 @@ struct InteractionInformationRequest; > struct LoadParameters; > struct PrintInfo; > struct TextInputContext; >+struct WebAutocorrectionData; > struct WebAutocorrectionContext; > struct WebPageCreationParameters; > struct WebPreferencesStore; >@@ -657,7 +658,7 @@ public: > void requestDictationContext(CallbackID); > void replaceDictatedText(const String& oldText, const String& newText); > void replaceSelectedText(const String& oldText, const String& newText); >- void requestAutocorrectionData(const String& textForAutocorrection, CallbackID); >+ void requestAutocorrectionData(const String& textForAutocorrection, CompletionHandler<void(WebAutocorrectionData)>&& reply); > void applyAutocorrection(const String& correction, const String& originalText, CallbackID); > void syncApplyAutocorrection(const String& correction, const String& originalText, CompletionHandler<void(bool)>&&); > void requestAutocorrectionContext(); >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >index a2f190601055771a4eef26ac84349c716f85b199..b06ab0f6eec1c7941cc9dc13c81ae1e703d4e8e7 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >@@ -77,7 +77,7 @@ messages -> WebPage LegacyReceiver { > RequestDictationContext(WebKit::CallbackID callbackID) > ReplaceDictatedText(String oldText, String newText) > ReplaceSelectedText(String oldText, String newText) >- RequestAutocorrectionData(String textForAutocorrection, WebKit::CallbackID callbackID) >+ RequestAutocorrectionData(String textForAutocorrection) -> (struct WebKit::WebAutocorrectionData data) Async > ApplyAutocorrection(String correction, String originalText, WebKit::CallbackID callbackID) > SyncApplyAutocorrection(String correction, String originalText) -> (bool autocorrectionApplied) Synchronous > RequestAutocorrectionContext() >diff --git a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >index e88a79f503af178db40b872d91ae9efd5aa8abb7..c9ce18f1f2519cf8d8008bf6b95ee8c2f2c225e8 100644 >--- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >+++ b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >@@ -50,6 +50,7 @@ > #import "VisibleContentRectUpdateInfo.h" > #import "WKAccessibilityWebPageObjectIOS.h" > #import "WebAutocorrectionContext.h" >+#import "WebAutocorrectionData.h" > #import "WebChromeClient.h" > #import "WebCoreArgumentCoders.h" > #import "WebFrame.h" >@@ -2244,22 +2245,22 @@ void WebPage::replaceDictatedText(const String& oldText, const String& newText) > frame.editor().setIgnoreSelectionChanges(false); > } > >-void WebPage::requestAutocorrectionData(const String& textForAutocorrection, CallbackID callbackID) >+void WebPage::requestAutocorrectionData(const String& textForAutocorrection, CompletionHandler<void(WebAutocorrectionData)>&& reply) > { >- Frame& frame = m_page->focusController().focusedOrMainFrame(); >+ auto& frame = m_page->focusController().focusedOrMainFrame(); > if (!frame.selection().isCaret()) { >- send(Messages::WebPageProxy::AutocorrectionDataCallback(Vector<FloatRect>(), String(), 0, 0, callbackID)); >+ reply({ }); > return; > } > > VisiblePosition position = frame.selection().selection().start(); >- RefPtr<Range> range = wordRangeFromPosition(position); >+ auto range = wordRangeFromPosition(position); > if (!range) { >- send(Messages::WebPageProxy::AutocorrectionDataCallback(Vector<FloatRect>(), String(), 0, 0, callbackID)); >+ reply({ }); > return; > } > >- String textForRange = plainTextReplacingNoBreakSpace(range.get()); >+ auto textForRange = plainTextReplacingNoBreakSpace(range.get()); > const unsigned maxSearchAttempts = 5; > for (size_t i = 0; i < maxSearchAttempts && textForRange != textForAutocorrection; ++i) > { >@@ -2286,10 +2287,7 @@ void WebPage::requestAutocorrectionData(const String& textForAutocorrection, Cal > if (auto* coreFont = frame.editor().fontForSelection(multipleFonts)) > font = coreFont->getCTFont(); > >- CGFloat fontSize = CTFontGetSize(font); >- uint64_t fontTraits = CTFontGetSymbolicTraits(font); >- RetainPtr<NSString> fontName = adoptNS((NSString *)CTFontCopyFamilyName(font)); >- send(Messages::WebPageProxy::AutocorrectionDataCallback(rectsForText, fontName.get(), fontSize, fontTraits, callbackID)); >+ reply({ WTFMove(rectsForText), (__bridge UIFont *)font }); > } > > void WebPage::applyAutocorrection(const String& correction, const String& originalText, CallbackID callbackID) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 3039459cece840218f1317dc00685d66836641bf..dc91a59c59ce3d3a4d06f37ae9f245d625b79b7a 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,21 @@ >+2019-05-31 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] Autocorrection menu font is Times New Roman when using font-family: UICTFontTextStyle* >+ https://bugs.webkit.org/show_bug.cgi?id=198427 >+ <rdar://problem/50031825> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a new API test to verify that -fontForCaretSelection returns the system font when using UICTFontTextStyle >+ in an editable web view. >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm: Added. >+ (-[TestWKWebView autocorrectionRectsForString:]): >+ (checkCGRectIsEqualToCGRectWithLogging): >+ * TestWebKitAPI/cocoa/TestWKWebView.h: >+ * TestWebKitAPI/ios/UIKitSPI.h: >+ > 2019-05-30 Wenson Hsieh <wenson_hsieh@apple.com> > > DragAndDropTests.DataTransferExposePlainTextWithFileURLAsFile API test is failing >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 57aa7d182e8fcf005390e22b654f306045e9c37f..0ea113ffbd12bb9dd601da34c52f39903745306a 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -892,6 +892,7 @@ > F41AB9A81EF4696B0083FA08 /* prevent-operation.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F41AB9941EF4692C0083FA08 /* prevent-operation.html */; }; > F41AB9A91EF4696B0083FA08 /* prevent-start.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F41AB99A1EF4692C0083FA08 /* prevent-start.html */; }; > F41AB9AA1EF4696B0083FA08 /* textarea-to-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F41AB9951EF4692C0083FA08 /* textarea-to-input.html */; }; >+ F42D634422A1729F00D2FB3A /* AutocorrectionTestsIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F42D634322A1729F00D2FB3A /* AutocorrectionTestsIOS.mm */; }; > F42DA5161D8CEFE400336F40 /* large-input-field-focus-onload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */; }; > F43E3BBF20DADA1E00A4E7ED /* WKScrollViewTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F43E3BBE20DADA1E00A4E7ED /* WKScrollViewTests.mm */; }; > F43E3BC120DADBC500A4E7ED /* fixed-nav-bar.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F43E3BC020DADB8000A4E7ED /* fixed-nav-bar.html */; }; >@@ -2279,6 +2280,7 @@ > F41AB99C1EF4692C0083FA08 /* contenteditable-and-textarea.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "contenteditable-and-textarea.html"; sourceTree = "<group>"; }; > F41AB99D1EF4692C0083FA08 /* link-and-target-div.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "link-and-target-div.html"; sourceTree = "<group>"; }; > F41AB99E1EF4692C0083FA08 /* div-and-large-image.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "div-and-large-image.html"; sourceTree = "<group>"; }; >+ F42D634322A1729F00D2FB3A /* AutocorrectionTestsIOS.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutocorrectionTestsIOS.mm; sourceTree = "<group>"; }; > F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "large-input-field-focus-onload.html"; path = "Tests/WebKitCocoa/large-input-field-focus-onload.html"; sourceTree = SOURCE_ROOT; }; > F43E3BBE20DADA1E00A4E7ED /* WKScrollViewTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKScrollViewTests.mm; sourceTree = "<group>"; }; > F43E3BC020DADB8000A4E7ED /* fixed-nav-bar.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "fixed-nav-bar.html"; sourceTree = "<group>"; }; >@@ -2854,6 +2856,7 @@ > A1C4FB6F1BACCEFA003742D0 /* Resources */, > 2E205BA31F527746005952DD /* AccessibilityTestsIOS.mm */, > F45B63FC1F19D410009D38B9 /* ActionSheetTests.mm */, >+ F42D634322A1729F00D2FB3A /* AutocorrectionTestsIOS.mm */, > F4D4F3B71E4E36E400BB2767 /* DragAndDropTestsIOS.mm */, > F4BC0B132146C849002A0478 /* FocusPreservationTests.mm */, > F45E15722112CE2900307E82 /* KeyboardInputTestsIOS.mm */, >@@ -4378,6 +4381,7 @@ > 37BCA61C1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm in Sources */, > 7C83E0C51D0A654600FEBCF3 /* ShrinkToFit.mm in Sources */, > 7CCE7ECD1A411A7E00447C4C /* SimplifyMarkup.mm in Sources */, >+ F42D634422A1729F00D2FB3A /* AutocorrectionTestsIOS.mm in Sources */, > 2DFF7B6D1DA487AF00814614 /* SnapshotStore.mm in Sources */, > 0F4FFA9E1ED3AA8500F7111F /* SnapshotViaRenderInContext.mm in Sources */, > 7CCE7F151A411AE600447C4C /* SpacebarScrolling.cpp in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm b/Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..697203a09346f2fc271387cbdd3d0c8d435cdd01 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm >@@ -0,0 +1,97 @@ >+/* >+ * 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. >+ */ >+ >+#import "config.h" >+ >+#if PLATFORM(IOS_FAMILY) >+ >+#import "PlatformUtilities.h" >+#import "TestInputDelegate.h" >+#import "TestWKWebView.h" >+#import "UIKitSPI.h" >+#import <WebKit/WKWebViewPrivate.h> >+ >+@interface TestWKWebView (AutocorrectionTests) >+- (UIWKAutocorrectionRects *)autocorrectionRectsForString:(NSString *)string; >+@end >+ >+@implementation TestWKWebView (AutocorrectionTests) >+ >+- (UIWKAutocorrectionRects *)autocorrectionRectsForString:(NSString *)string >+{ >+ RetainPtr<UIWKAutocorrectionRects> result; >+ bool done = false; >+ [self.textInputContentView requestAutocorrectionRectsForString:string withCompletionHandler:[&] (UIWKAutocorrectionRects *rects) { >+ result = rects; >+ done = true; >+ }]; >+ TestWebKitAPI::Util::run(&done); >+ return result.autorelease(); >+} >+ >+@end >+ >+static void checkCGRectIsEqualToCGRectWithLogging(CGRect expected, CGRect observed) >+{ >+ BOOL isEqual = CGRectEqualToRect(expected, observed); >+ EXPECT_TRUE(isEqual); >+ if (!isEqual) >+ NSLog(@"Expected: %@ but observed: %@", NSStringFromCGRect(expected), NSStringFromCGRect(observed)); >+} >+ >+TEST(AutocorrectionTests, FontAtCaretWhenUsingUICTFontTextStyle) >+{ >+ auto webView = adoptNS([[TestWKWebView alloc] init]); >+ auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]); >+ [inputDelegate setFocusStartsInputSessionPolicyHandler:[] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy { >+ return _WKFocusStartsInputSessionPolicyAllow; >+ }]; >+ >+ [webView _setInputDelegate:inputDelegate.get()]; >+ [webView _setEditable:YES]; >+ [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width, initial-scale=1'><body style='font-size: 16px; font-family: UICTFontTextStyleBody'>Wulk</body>"]; >+ [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.body.focus()"]; >+ [webView _executeEditCommand:@"MoveToEndOfLine" argument:nil completion:nil]; >+ >+ auto autocorrectionRects = retainPtr([webView autocorrectionRectsForString:@"Wulk"]); >+ checkCGRectIsEqualToCGRectWithLogging(CGRectMake(8, 8, 36, 21), [autocorrectionRects firstRect]); >+ checkCGRectIsEqualToCGRectWithLogging(CGRectMake(8, 8, 36, 21), [autocorrectionRects lastRect]); >+ >+ auto contentView = [webView textInputContentView]; >+ UIFont *fontBeforeScaling = [contentView fontForCaretSelection]; >+ UIFont *size16SystemFont = [UIFont systemFontOfSize:16]; >+ EXPECT_WK_STREQ(size16SystemFont.fontName, fontBeforeScaling.fontName); >+ EXPECT_WK_STREQ(size16SystemFont.familyName, fontBeforeScaling.familyName); >+ EXPECT_EQ(16, fontBeforeScaling.pointSize); >+ >+ [webView scrollView].zoomScale = 2; >+ UIFont *fontAfterScaling = [contentView fontForCaretSelection]; >+ UIFont *size32SystemFont = [UIFont systemFontOfSize:32]; >+ EXPECT_WK_STREQ(size32SystemFont.fontName, fontAfterScaling.fontName); >+ EXPECT_WK_STREQ(size32SystemFont.familyName, fontAfterScaling.familyName); >+ EXPECT_EQ(32, fontAfterScaling.pointSize); >+} >+ >+#endif // PLATFORM(IOS_FAMILY) >diff --git a/Tools/TestWebKitAPI/cocoa/TestWKWebView.h b/Tools/TestWebKitAPI/cocoa/TestWKWebView.h >index 1a4e04622a17d220aadb046dbbcd53451a98a6c0..b668a00c38e96affcb9041a545c7cf6748dc0ae1 100644 >--- a/Tools/TestWebKitAPI/cocoa/TestWKWebView.h >+++ b/Tools/TestWebKitAPI/cocoa/TestWKWebView.h >@@ -32,6 +32,7 @@ > @class _WKActivatedElementInfo; > @protocol UITextInputMultiDocument; > @protocol UITextInputPrivate; >+@protocol UIWKInteractionViewProtocol; > #endif > > @interface WKWebView (AdditionalDeclarations) >@@ -84,7 +85,7 @@ > @end > > @interface TestWKWebView (IOSOnly) >-@property (nonatomic, readonly) UIView <UITextInputPrivate, UITextInputMultiDocument> *textInputContentView; >+@property (nonatomic, readonly) UIView <UITextInputPrivate, UITextInputMultiDocument, UIWKInteractionViewProtocol> *textInputContentView; > @property (nonatomic, readonly) RetainPtr<NSArray> selectionRectsAfterPresentationUpdate; > @property (nonatomic, readonly) CGRect caretViewRectInContentCoordinates; > @property (nonatomic, readonly) NSArray<NSValue *> *selectionViewRectsInContentCoordinates; >diff --git a/Tools/TestWebKitAPI/ios/UIKitSPI.h b/Tools/TestWebKitAPI/ios/UIKitSPI.h >index 70273e8e76491ca879db0fd1d20ef5591bb40ae1..d930ae4e373a0bac6f8aa758b47521eee0d537a8 100644 >--- a/Tools/TestWebKitAPI/ios/UIKitSPI.h >+++ b/Tools/TestWebKitAPI/ios/UIKitSPI.h >@@ -83,6 +83,7 @@ WTF_EXTERN_C_END > - (void)handleKeyWebEvent:(WebEvent *)theEvent withCompletionHandler:(void (^)(WebEvent *, BOOL))completionHandler; > - (BOOL)_shouldSuppressSelectionCommands; > - (NSDictionary *)_autofillContext; >+- (UIFont *)fontForCaretSelection; > @end > > @interface UIWebFormAccessory : UIInputView >@@ -142,6 +143,15 @@ typedef NS_OPTIONS(NSInteger, UIWKDocumentRequestFlags) { > > @end > >+@interface UIWKAutocorrectionRects : NSObject >+@property (nonatomic) CGRect firstRect; >+@property (nonatomic) CGRect lastRect; >+@end >+ >+@protocol UIWKInteractionViewProtocol >+- (void)requestAutocorrectionRectsForString:(NSString *)input withCompletionHandler:(void (^)(UIWKAutocorrectionRects *rectsForInput))completionHandler; >+@end >+ > #endif > > #if __has_include(<UIKit/UITextAutofillSuggestion.h>) >@@ -175,7 +185,7 @@ typedef NS_OPTIONS(NSInteger, UIWKDocumentRequestFlags) { > + (BOOL)isInHardwareKeyboardMode; > @end > >-@protocol UIWKInteractionViewProtocol_Staging_49236384 >+@protocol UIWKInteractionViewProtocol_Staging_49236384 <UIWKInteractionViewProtocol> > - (void)pasteWithCompletionHandler:(void (^)(void))completionHandler; > @end >
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 198427
:
371085
|
371088