Title: [258087] trunk/Source
Revision
258087
Author
[email protected]
Date
2020-03-07 16:30:28 -0800 (Sat, 07 Mar 2020)

Log Message

[iOS] Implement support for dictation alternatives
https://bugs.webkit.org/show_bug.cgi?id=208720
<rdar://problem/58540114>

Reviewed by Brent Fulgham.

Part 3

Source/WebCore:

Separate code that is actually USE(AUTOCORRECTION_PANEL)-specific from code that can also
be used when building with USE(DICTATION_ALTERNATIVES) enabled.

Note that I haven't enable USE_DICTATION_ALTERNATIVES on iOS. So, this code isn't being
compiled for iOS. I will do that in a subsequent change once after all the code is in place
to do so.

* SourcesCocoa.txt: Mark TextAlternativeWithRange.mm as @no-unify to fix build breakage when
a unified source file includes both TextAlternativeWithRange.mm and a file that ultimately
includes LengthBox.h (e.g. WebArchiveResourceFromNSAttributedString.mm). TextAlternativeWithRange.mm
ultimately includes SFNTLayoutTypes.h, which defines a Fixed type that conflicts with enumerator
Fixed (part of the LengthType enumeration) defined in Length.h. Ideally the LengthType enumeration
would be an enum class or scoped to Length to avoid this ambiguity. This would be a big change to do
and so for now I am fixing the build breakage using @no-unify.
* WebCore.xcodeproj/project.pbxproj: Add TextAlternativeWithRange.mm to the project now that
it is excluded from the unified build.
* editing/AlternativeTextController.cpp:
(WebCore::markerTypesForAppliedDictationAlternative):
(WebCore::AlternativeTextController::alternativeTextClient):
(WebCore::AlternativeTextController::markerDescriptionForAppliedAlternativeText):
(WebCore::AlternativeTextController::applyAlternativeTextToRange):
* editing/AlternativeTextController.h:

Source/WebKit:

Move code that was guarded under PLATFORM(MAC) outside of that guard so that we compile it
so long as USE(DICTATION_ALTERNATIVES) is enabled.

Note that I haven't enable USE_DICTATION_ALTERNATIVES on iOS. So, this code isn't being
compiled for iOS. I will do that in a subsequent change once after all the code is in place
to do so.

* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
* UIProcess/WebPageProxy.h:

Source/WebKitLegacy/mac:

Guard code that requires USE(AUTOCORRECTION_PANEL) to be enabled. Specifically, -_showDictationAlternativeUI
calls -handleAcceptedAlternativeText, but the latter is only compiled in when USE(AUTOCORRECTION_PANEL)
is enabled.

Note that I haven't enable USE_DICTATION_ALTERNATIVES on iOS. So, this code isn't being
compiled for iOS. I will do that in a subsequent change once after all the code is in place
to do so.

* WebView/WebView.mm:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (258086 => 258087)


--- trunk/Source/WebCore/ChangeLog	2020-03-08 00:27:55 UTC (rev 258086)
+++ trunk/Source/WebCore/ChangeLog	2020-03-08 00:30:28 UTC (rev 258087)
@@ -4,6 +4,39 @@
         https://bugs.webkit.org/show_bug.cgi?id=208720
         <rdar://problem/58540114>
 
+        Reviewed by Brent Fulgham.
+
+        Part 3
+
+        Separate code that is actually USE(AUTOCORRECTION_PANEL)-specific from code that can also
+        be used when building with USE(DICTATION_ALTERNATIVES) enabled.
+
+        Note that I haven't enable USE_DICTATION_ALTERNATIVES on iOS. So, this code isn't being
+        compiled for iOS. I will do that in a subsequent change once after all the code is in place
+        to do so.
+
+        * SourcesCocoa.txt: Mark TextAlternativeWithRange.mm as @no-unify to fix build breakage when
+        a unified source file includes both TextAlternativeWithRange.mm and a file that ultimately
+        includes LengthBox.h (e.g. WebArchiveResourceFromNSAttributedString.mm). TextAlternativeWithRange.mm
+        ultimately includes SFNTLayoutTypes.h, which defines a Fixed type that conflicts with enumerator
+        Fixed (part of the LengthType enumeration) defined in Length.h. Ideally the LengthType enumeration
+        would be an enum class or scoped to Length to avoid this ambiguity. This would be a big change to do
+        and so for now I am fixing the build breakage using @no-unify.
+        * WebCore.xcodeproj/project.pbxproj: Add TextAlternativeWithRange.mm to the project now that
+        it is excluded from the unified build.
+        * editing/AlternativeTextController.cpp:
+        (WebCore::markerTypesForAppliedDictationAlternative):
+        (WebCore::AlternativeTextController::alternativeTextClient):
+        (WebCore::AlternativeTextController::markerDescriptionForAppliedAlternativeText):
+        (WebCore::AlternativeTextController::applyAlternativeTextToRange):
+        * editing/AlternativeTextController.h:
+
+2020-03-07  Daniel Bates  <[email protected]>
+
+        [iOS] Implement support for dictation alternatives
+        https://bugs.webkit.org/show_bug.cgi?id=208720
+        <rdar://problem/58540114>
+
         Reviewed by Wenson Hsieh.
 
         Part 2

Modified: trunk/Source/WebCore/SourcesCocoa.txt (258086 => 258087)


--- trunk/Source/WebCore/SourcesCocoa.txt	2020-03-08 00:27:55 UTC (rev 258086)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2020-03-08 00:30:28 UTC (rev 258087)
@@ -99,7 +99,7 @@
 editing/mac/DictionaryLookupLegacy.mm
 editing/mac/EditorMac.mm
 editing/mac/FrameSelectionMac.mm
-editing/mac/TextAlternativeWithRange.mm
+editing/mac/TextAlternativeWithRange.mm @no-unify
 editing/mac/TextUndoInsertionMarkupMac.mm
 
 fileapi/FileCocoa.mm

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (258086 => 258087)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-03-08 00:27:55 UTC (rev 258086)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-03-08 00:30:28 UTC (rev 258087)
@@ -4256,6 +4256,7 @@
 		CE7B2DB31586ABAD0098B3FA /* AlternativeTextUIController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CE7B2DB51586ABAD0098B3FA /* TextAlternativeWithRange.h in Headers */ = {isa = PBXBuildFile; fileRef = CE7B2DB11586ABAD0098B3FA /* TextAlternativeWithRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CE7E17831C83A49100AD06AF /* ContentSecurityPolicyHash.h in Headers */ = {isa = PBXBuildFile; fileRef = CE7E17821C83A49100AD06AF /* ContentSecurityPolicyHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		CE88EE262414467B007F29C2 /* TextAlternativeWithRange.mm in Sources */ = {isa = PBXBuildFile; fileRef = CE7B2DB21586ABAD0098B3FA /* TextAlternativeWithRange.mm */; };
 		CEA284662141E84900E407E8 /* PlatformEventFactoryIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26601EBE14B3B9AD0012C0FE /* PlatformEventFactoryIOS.mm */; };
 		CEBB8C3320786DCB00039547 /* FetchIdioms.h in Headers */ = {isa = PBXBuildFile; fileRef = CEBB8C3120786DCB00039547 /* FetchIdioms.h */; };
 		CECADFC7153778FF00E37068 /* DictationAlternative.h in Headers */ = {isa = PBXBuildFile; fileRef = CECADFC3153778FF00E37068 /* DictationAlternative.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -33761,6 +33762,7 @@
 				A833C7CA0A2CF06B00D57664 /* SVGNames.cpp in Sources */,
 				C1692DD223D23ABD006E88F7 /* SystemBattery.mm in Sources */,
 				6E72F54F229DCD1300B3E151 /* TemporaryANGLESetting.cpp in Sources */,
+				CE88EE262414467B007F29C2 /* TextAlternativeWithRange.mm in Sources */,
 				9759E93F14EF1CF80026A2DD /* TextTrack.cpp in Sources */,
 				9759E94214EF1CF80026A2DD /* TextTrackCue.cpp in Sources */,
 				071A9EC2168FBC43002629F9 /* TextTrackCueGeneric.cpp in Sources */,

Modified: trunk/Source/WebCore/editing/AlternativeTextController.cpp (258086 => 258087)


--- trunk/Source/WebCore/editing/AlternativeTextController.cpp	2020-03-08 00:27:55 UTC (rev 258086)
+++ trunk/Source/WebCore/editing/AlternativeTextController.cpp	2020-03-08 00:30:28 UTC (rev 258087)
@@ -47,6 +47,16 @@
 
 namespace WebCore {
 
+
+#if USE(DICTATION_ALTERNATIVES) || USE(AUTOCORRECTION_PANEL)
+
+constexpr OptionSet<DocumentMarker::MarkerType> markerTypesForAppliedDictationAlternative()
+{
+    return DocumentMarker::SpellCheckingExemption;
+}
+
+#endif
+
 #if USE(AUTOCORRECTION_PANEL)
 
 static inline OptionSet<DocumentMarker::MarkerType> markerTypesForAutocorrection()
@@ -59,11 +69,6 @@
     return { DocumentMarker::Replacement, DocumentMarker::SpellCheckingExemption };
 }
 
-static inline OptionSet<DocumentMarker::MarkerType> markerTypesForAppliedDictationAlternative()
-{
-    return DocumentMarker::SpellCheckingExemption;
-}
-
 static bool markersHaveIdenticalDescription(const Vector<RenderedDocumentMarker*>& markers)
 {
     if (markers.isEmpty())
@@ -187,56 +192,6 @@
     return String();
 }
 
-void AlternativeTextController::applyAlternativeTextToRange(const Range& range, const String& alternative, AlternativeTextType alternativeType, OptionSet<DocumentMarker::MarkerType> markerTypesToAdd)
-{
-    auto paragraphRangeContainingCorrection = range.cloneRange();
-
-    setStart(paragraphRangeContainingCorrection.ptr(), startOfParagraph(range.startPosition()));
-    setEnd(paragraphRangeContainingCorrection.ptr(), endOfParagraph(range.endPosition()));
-
-    // After we replace the word at range rangeWithAlternative, we need to add markers to that range.
-    // However, once the replacement took place, the value of rangeWithAlternative is not valid anymore.
-    // So before we carry out the replacement, we need to store the start position of rangeWithAlternative
-    // relative to the start position of the containing paragraph. We use correctionStartOffsetInParagraph
-    // to store this value. In order to obtain this offset, we need to first create a range
-    // which spans from the start of paragraph to the start position of rangeWithAlternative.
-    auto correctionStartOffsetInParagraphAsRange = Range::create(paragraphRangeContainingCorrection->startContainer().document(), paragraphRangeContainingCorrection->startPosition(), paragraphRangeContainingCorrection->startPosition());
-
-    Position startPositionOfRangeWithAlternative = range.startPosition();
-    if (!startPositionOfRangeWithAlternative.containerNode())
-        return;
-    auto setEndResult = correctionStartOffsetInParagraphAsRange->setEnd(*startPositionOfRangeWithAlternative.containerNode(), startPositionOfRangeWithAlternative.computeOffsetInContainerNode());
-    if (setEndResult.hasException())
-        return;
-
-    // Take note of the location of autocorrection so that we can add marker after the replacement took place.
-    int correctionStartOffsetInParagraph = TextIterator::rangeLength(correctionStartOffsetInParagraphAsRange.ptr());
-
-    // Clone the range, since the caller of this method may want to keep the original range around.
-    auto rangeWithAlternative = range.cloneRange();
-
-    ContainerNode& rootNode = paragraphRangeContainingCorrection->startContainer().treeScope().rootNode();
-    int paragraphStartIndex = TextIterator::rangeLength(Range::create(rootNode.document(), &rootNode, 0, &paragraphRangeContainingCorrection->startContainer(), paragraphRangeContainingCorrection->startOffset()).ptr());
-    SpellingCorrectionCommand::create(rangeWithAlternative, alternative)->apply();
-    // Recalculate pragraphRangeContainingCorrection, since SpellingCorrectionCommand modified the DOM, such that the original paragraphRangeContainingCorrection is no longer valid. Radar: 10305315 Bugzilla: 89526
-    auto updatedParagraphRangeContainingCorrection = TextIterator::rangeFromLocationAndLength(&rootNode, paragraphStartIndex, correctionStartOffsetInParagraph + alternative.length());
-    if (!updatedParagraphRangeContainingCorrection)
-        return;
-    
-    setEnd(updatedParagraphRangeContainingCorrection.get(), m_frame.selection().selection().start());
-    RefPtr<Range> replacementRange = TextIterator::subrange(*updatedParagraphRangeContainingCorrection, correctionStartOffsetInParagraph, alternative.length());
-    String newText = plainText(replacementRange.get());
-
-    // Check to see if replacement succeeded.
-    if (newText != alternative)
-        return;
-
-    DocumentMarkerController& markers = replacementRange->startContainer().document().markers();
-
-    for (auto markerType : markerTypesToAdd)
-        markers.addMarker(*replacementRange, markerType, markerDescriptionForAppliedAlternativeText(alternativeType, markerType));
-}
-
 bool AlternativeTextController::applyAutocorrectionBeforeTypingIfAppropriate()
 {
     if (!m_rangeWithAlternative || !m_isActive)
@@ -449,11 +404,6 @@
     markers.addMarker(range, DocumentMarker::SpellCheckingExemption);
 }
 
-AlternativeTextClient* AlternativeTextController::alternativeTextClient()
-{
-    return m_frame.page() ? m_frame.page()->alternativeTextClient() : nullptr;
-}
-
 EditorClient* AlternativeTextController::editorClient()
 {
     return m_frame.page() ? &m_frame.page()->editorClient() : nullptr;
@@ -607,14 +557,77 @@
     return true;
 }
 
+#endif // USE(AUTOCORRECTION_PANEL)
+
+#if USE(DICTATION_ALTERNATIVES) || USE(AUTOCORRECTION_PANEL)
+
+AlternativeTextClient* AlternativeTextController::alternativeTextClient()
+{
+    return m_frame.page() ? m_frame.page()->alternativeTextClient() : nullptr;
+}
+
 String AlternativeTextController::markerDescriptionForAppliedAlternativeText(AlternativeTextType alternativeTextType, DocumentMarker::MarkerType markerType)
 {
-
+#if USE(AUTOCORRECTION_PANEL)
     if (alternativeTextType != AlternativeTextTypeReversion && alternativeTextType != AlternativeTextTypeDictationAlternatives && (markerType == DocumentMarker::Replacement || markerType == DocumentMarker::Autocorrected))
         return m_originalText;
+#else
+    UNUSED_PARAM(alternativeTextType);
+    UNUSED_PARAM(markerType);
+#endif
     return emptyString();
 }
 
+void AlternativeTextController::applyAlternativeTextToRange(const Range& range, const String& alternative, AlternativeTextType alternativeType, OptionSet<DocumentMarker::MarkerType> markerTypesToAdd)
+{
+    auto paragraphRangeContainingCorrection = range.cloneRange();
+
+    setStart(paragraphRangeContainingCorrection.ptr(), startOfParagraph(range.startPosition()));
+    setEnd(paragraphRangeContainingCorrection.ptr(), endOfParagraph(range.endPosition()));
+
+    // After we replace the word at range rangeWithAlternative, we need to add markers to that range.
+    // However, once the replacement took place, the value of rangeWithAlternative is not valid anymore.
+    // So before we carry out the replacement, we need to store the start position of rangeWithAlternative
+    // relative to the start position of the containing paragraph. We use correctionStartOffsetInParagraph
+    // to store this value. In order to obtain this offset, we need to first create a range
+    // which spans from the start of paragraph to the start position of rangeWithAlternative.
+    auto correctionStartOffsetInParagraphAsRange = Range::create(paragraphRangeContainingCorrection->startContainer().document(), paragraphRangeContainingCorrection->startPosition(), paragraphRangeContainingCorrection->startPosition());
+
+    Position startPositionOfRangeWithAlternative = range.startPosition();
+    if (!startPositionOfRangeWithAlternative.containerNode())
+        return;
+    auto setEndResult = correctionStartOffsetInParagraphAsRange->setEnd(*startPositionOfRangeWithAlternative.containerNode(), startPositionOfRangeWithAlternative.computeOffsetInContainerNode());
+    if (setEndResult.hasException())
+        return;
+
+    // Take note of the location of autocorrection so that we can add marker after the replacement took place.
+    int correctionStartOffsetInParagraph = TextIterator::rangeLength(correctionStartOffsetInParagraphAsRange.ptr());
+
+    // Clone the range, since the caller of this method may want to keep the original range around.
+    auto rangeWithAlternative = range.cloneRange();
+
+    ContainerNode& rootNode = paragraphRangeContainingCorrection->startContainer().treeScope().rootNode();
+    int paragraphStartIndex = TextIterator::rangeLength(Range::create(rootNode.document(), &rootNode, 0, &paragraphRangeContainingCorrection->startContainer(), paragraphRangeContainingCorrection->startOffset()).ptr());
+    SpellingCorrectionCommand::create(rangeWithAlternative, alternative)->apply();
+    // Recalculate pragraphRangeContainingCorrection, since SpellingCorrectionCommand modified the DOM, such that the original paragraphRangeContainingCorrection is no longer valid. Radar: 10305315 Bugzilla: 89526
+    auto updatedParagraphRangeContainingCorrection = TextIterator::rangeFromLocationAndLength(&rootNode, paragraphStartIndex, correctionStartOffsetInParagraph + alternative.length());
+    if (!updatedParagraphRangeContainingCorrection)
+        return;
+
+    setEnd(updatedParagraphRangeContainingCorrection.get(), m_frame.selection().selection().start());
+    RefPtr<Range> replacementRange = TextIterator::subrange(*updatedParagraphRangeContainingCorrection, correctionStartOffsetInParagraph, alternative.length());
+    String newText = plainText(replacementRange.get());
+
+    // Check to see if replacement succeeded.
+    if (newText != alternative)
+        return;
+
+    DocumentMarkerController& markers = replacementRange->startContainer().document().markers();
+
+    for (auto markerType : markerTypesToAdd)
+        markers.addMarker(*replacementRange, markerType, markerDescriptionForAppliedAlternativeText(alternativeType, markerType));
+}
+
 #endif
 
 bool AlternativeTextController::insertDictatedText(const String& text, const Vector<DictationAlternative>& dictationAlternatives, Event* triggeringEvent)

Modified: trunk/Source/WebCore/editing/AlternativeTextController.h (258086 => 258087)


--- trunk/Source/WebCore/editing/AlternativeTextController.h	2020-03-08 00:27:55 UTC (rev 258086)
+++ trunk/Source/WebCore/editing/AlternativeTextController.h	2020-03-08 00:30:28 UTC (rev 258087)
@@ -115,15 +115,12 @@
     };
 
     String dismissSoon(ReasonForDismissingAlternativeText);
-    void applyAlternativeTextToRange(const Range&, const String& alternative, AlternativeTextType, OptionSet<DocumentMarker::MarkerType>);
     void timerFired();
     void recordSpellcheckerResponseForModifiedCorrection(Range& rangeOfCorrection, const String& corrected, const String& correction);
-    String markerDescriptionForAppliedAlternativeText(AlternativeTextType, DocumentMarker::MarkerType);
 
     bool shouldStartTimerFor(const DocumentMarker&, int endOffset) const;
     bool respondToMarkerAtEndOfWord(const DocumentMarker&, const Position& endOfWordPosition);
 
-    AlternativeTextClient* alternativeTextClient();
     EditorClient* editorClient();
     
     TextCheckerClient* textChecker();
@@ -141,6 +138,11 @@
     String m_originalStringForLastDeletedAutocorrection;
     Position m_positionForLastDeletedAutocorrection;
 #endif
+#if USE(DICTATION_ALTERNATIVES) || USE(AUTOCORRECTION_PANEL)
+    String markerDescriptionForAppliedAlternativeText(AlternativeTextType, DocumentMarker::MarkerType);
+    void applyAlternativeTextToRange(const Range&, const String&, AlternativeTextType, OptionSet<DocumentMarker::MarkerType>);
+    AlternativeTextClient* alternativeTextClient();
+#endif
 
     Frame& m_frame;
 };

Modified: trunk/Source/WebKit/ChangeLog (258086 => 258087)


--- trunk/Source/WebKit/ChangeLog	2020-03-08 00:27:55 UTC (rev 258086)
+++ trunk/Source/WebKit/ChangeLog	2020-03-08 00:30:28 UTC (rev 258087)
@@ -4,6 +4,27 @@
         https://bugs.webkit.org/show_bug.cgi?id=208720
         <rdar://problem/58540114>
 
+        Reviewed by Brent Fulgham.
+
+        Part 3
+
+        Move code that was guarded under PLATFORM(MAC) outside of that guard so that we compile it
+        so long as USE(DICTATION_ALTERNATIVES) is enabled.
+
+        Note that I haven't enable USE_DICTATION_ALTERNATIVES on iOS. So, this code isn't being
+        compiled for iOS. I will do that in a subsequent change once after all the code is in place
+        to do so.
+
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        * UIProcess/WebPageProxy.h:
+
+2020-03-07  Daniel Bates  <[email protected]>
+
+        [iOS] Implement support for dictation alternatives
+        https://bugs.webkit.org/show_bug.cgi?id=208720
+        <rdar://problem/58540114>
+
         Reviewed by Wenson Hsieh.
 
         Part 2

Modified: trunk/Source/WebKit/UIProcess/PageClient.h (258086 => 258087)


--- trunk/Source/WebKit/UIProcess/PageClient.h	2020-03-08 00:27:55 UTC (rev 258086)
+++ trunk/Source/WebKit/UIProcess/PageClient.h	2020-03-08 00:30:28 UTC (rev 258087)
@@ -54,6 +54,7 @@
 OBJC_CLASS NSFileWrapper;
 OBJC_CLASS NSMenu;
 OBJC_CLASS NSSet;
+OBJC_CLASS NSTextAlternatives;
 OBJC_CLASS UIGestureRecognizer;
 OBJC_CLASS WKDrawingView;
 OBJC_CLASS _WKRemoteObjectRegistry;
@@ -60,7 +61,6 @@
 
 #if USE(APPKIT)
 OBJC_CLASS WKView;
-OBJC_CLASS NSTextAlternatives;
 #endif
 #endif
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (258086 => 258087)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-03-08 00:27:55 UTC (rev 258086)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-03-08 00:30:28 UTC (rev 258087)
@@ -8342,6 +8342,25 @@
 
 #endif
 
+#if USE(DICTATION_ALTERNATIVES)
+
+void WebPageProxy::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
+{
+    pageClient().showDictationAlternativeUI(boundingBoxOfDictatedText, dictationContext);
+}
+
+void WebPageProxy::removeDictationAlternatives(uint64_t dictationContext)
+{
+    pageClient().removeDictationAlternatives(dictationContext);
+}
+
+void WebPageProxy::dictationAlternatives(uint64_t dictationContext, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
+{
+    completionHandler(pageClient().dictationAlternatives(dictationContext));
+}
+
+#endif
+
 #if PLATFORM(MAC)
 
 void WebPageProxy::substitutionsPanelIsShowing(CompletionHandler<void(bool)>&& completionHandler)
@@ -8379,23 +8398,6 @@
         send(Messages::WebPage::HandleAlternativeTextUIResult(result));
 }
 
-#if USE(DICTATION_ALTERNATIVES)
-void WebPageProxy::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
-{
-    pageClient().showDictationAlternativeUI(boundingBoxOfDictatedText, dictationContext);
-}
-
-void WebPageProxy::removeDictationAlternatives(uint64_t dictationContext)
-{
-    pageClient().removeDictationAlternatives(dictationContext);
-}
-
-void WebPageProxy::dictationAlternatives(uint64_t dictationContext, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
-{
-    completionHandler(pageClient().dictationAlternatives(dictationContext));
-}
-#endif
-
 void WebPageProxy::setEditableElementIsFocused(bool editableElementIsFocused)
 {
     pageClient().setEditableElementIsFocused(editableElementIsFocused);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (258086 => 258087)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-03-08 00:27:55 UTC (rev 258086)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-03-08 00:30:28 UTC (rev 258087)
@@ -2074,6 +2074,12 @@
     void toggleAutomaticTextReplacement();
 #endif
 
+#if USE(DICTATION_ALTERNATIVES)
+    void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext);
+    void removeDictationAlternatives(uint64_t dictationContext);
+    void dictationAlternatives(uint64_t dictationContext, CompletionHandler<void(Vector<String>&&)>&&);
+#endif
+
 #if PLATFORM(MAC)
     void substitutionsPanelIsShowing(CompletionHandler<void(bool)>&&);
     void showCorrectionPanel(int32_t panelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings);
@@ -2081,12 +2087,6 @@
     void dismissCorrectionPanelSoon(int32_t reason, CompletionHandler<void(String)>&&);
     void recordAutocorrectionResponse(int32_t responseType, const String& replacedString, const String& replacementString);
 
-#if USE(DICTATION_ALTERNATIVES)
-    void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext);
-    void removeDictationAlternatives(uint64_t dictationContext);
-    void dictationAlternatives(uint64_t dictationContext, CompletionHandler<void(Vector<String>&&)>&&);
-#endif
-
     void setEditableElementIsFocused(bool);
 #endif // PLATFORM(MAC)
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (258086 => 258087)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2020-03-08 00:27:55 UTC (rev 258086)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2020-03-08 00:30:28 UTC (rev 258087)
@@ -1,3 +1,23 @@
+2020-03-07  Daniel Bates  <[email protected]>
+
+        [iOS] Implement support for dictation alternatives
+        https://bugs.webkit.org/show_bug.cgi?id=208720
+        <rdar://problem/58540114>
+
+        Reviewed by Brent Fulgham.
+
+        Part 3
+
+        Guard code that requires USE(AUTOCORRECTION_PANEL) to be enabled. Specifically, -_showDictationAlternativeUI
+        calls -handleAcceptedAlternativeText, but the latter is only compiled in when USE(AUTOCORRECTION_PANEL)
+        is enabled.
+
+        Note that I haven't enable USE_DICTATION_ALTERNATIVES on iOS. So, this code isn't being
+        compiled for iOS. I will do that in a subsequent change once after all the code is in place
+        to do so.
+
+        * WebView/WebView.mm:
+
 2020-03-05  Sam Weinig  <[email protected]>
 
         Move _javascript_Core related feature defines from FeatureDefines.xcconfig to PlatformEnableCocoa.h

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (258086 => 258087)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2020-03-08 00:27:55 UTC (rev 258086)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2020-03-08 00:30:28 UTC (rev 258087)
@@ -9449,9 +9449,11 @@
 
 - (void)_showDictationAlternativeUI:(const WebCore::FloatRect&)boundingBoxOfDictatedText forDictationContext:(uint64_t)dictationContext
 {
+#if USE(AUTOCORRECTION_PANEL)
     _private->m_alternativeTextUIController->showAlternatives(self, [self _convertRectFromRootView:boundingBoxOfDictatedText], dictationContext, ^(NSString* acceptedAlternative) {
         [self handleAcceptedAlternativeText:acceptedAlternative];
     });
+#endif
 }
 
 - (void)_removeDictationAlternatives:(uint64_t)dictationContext
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to