Have insertDictatedTextAsync() take an InsertTextOptions
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Mar 2020 22:45:25 +0000 (22:45 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Mar 2020 22:45:25 +0000 (22:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=209308
<rdar://problem/60652838>

Reviewed by Darin Adler.

This will provide future extensibility, which I plan to make use of in a subsequent patch,
in addition to making the interface for insertDictatedTextAsync() more like insertTextAsync().

* UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::insertDictatedTextAsync): Pass the options through. The caller is now
responsible for setting the registerUndoGroup insertion option.
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::insertText): Stack-allocate a InsertTextOptions setting its registerUndoGroup
field and pass this object through.
* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView insertText:alternatives:style:]): Pass the default constructed InsertTextOptions,
which defaults registerUndoGroup to false to keep the current behavior.
* WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::insertDictatedTextAsync): Write in terms of InsertTextOptions.registerUndoGroup.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258796 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in

index 7e9722c..4063d1c 100644 (file)
@@ -1,5 +1,31 @@
 2020-03-20  Daniel Bates  <dabates@apple.com>
 
+        Have insertDictatedTextAsync() take an InsertTextOptions
+        https://bugs.webkit.org/show_bug.cgi?id=209308
+        <rdar://problem/60652838>
+
+        Reviewed by Darin Adler.
+
+        This will provide future extensibility, which I plan to make use of in a subsequent patch,
+        in addition to making the interface for insertDictatedTextAsync() more like insertTextAsync().
+
+        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+        (WebKit::WebPageProxy::insertDictatedTextAsync): Pass the options through. The caller is now
+        responsible for setting the registerUndoGroup insertion option.
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::insertText): Stack-allocate a InsertTextOptions setting its registerUndoGroup
+        field and pass this object through.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView insertText:alternatives:style:]): Pass the default constructed InsertTextOptions,
+        which defaults registerUndoGroup to false to keep the current behavior.
+        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+        (WebKit::WebPage::insertDictatedTextAsync): Write in terms of InsertTextOptions.registerUndoGroup.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
+2020-03-20  Daniel Bates  <dabates@apple.com>
+
         Replace "deferred element focus" functionality with alternative solution
         https://bugs.webkit.org/show_bug.cgi?id=201608
 
index cd0f0d4..f957616 100644 (file)
@@ -232,7 +232,7 @@ void WebPageProxy::performDictionaryLookupOfCurrentSelection()
     process().send(Messages::WebPage::PerformDictionaryLookupOfCurrentSelection(), m_webPageID);
 }
 
-void WebPageProxy::insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<TextAlternativeWithRange>& dictationAlternativesWithRange, bool registerUndoGroup)
+void WebPageProxy::insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<TextAlternativeWithRange>& dictationAlternativesWithRange, InsertTextOptions&& options)
 {
 #if USE(DICTATION_ALTERNATIVES)
     if (!hasRunningProcess())
@@ -246,18 +246,12 @@ void WebPageProxy::insertDictatedTextAsync(const String& text, const EditingRang
     }
 
     if (dictationAlternatives.isEmpty()) {
-        InsertTextOptions options;
-        options.registerUndoGroup = registerUndoGroup;
-
         insertTextAsync(text, replacementRange, WTFMove(options));
         return;
     }
 
-    process().send(Messages::WebPage::InsertDictatedTextAsync { text, replacementRange, dictationAlternatives, registerUndoGroup }, m_webPageID);
+    process().send(Messages::WebPage::InsertDictatedTextAsync { text, replacementRange, dictationAlternatives, WTFMove(options) }, m_webPageID);
 #else
-    InsertTextOptions options;
-    options.registerUndoGroup = registerUndoGroup;
-
     insertTextAsync(text, replacementRange, WTFMove(options));
 #endif
 }
index bcbb760..f9d7abe 100644 (file)
@@ -4844,9 +4844,11 @@ void WebViewImpl::insertText(id string, NSRange replacementRange)
 
     String eventText = text;
     eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore
-    if (!dictationAlternatives.isEmpty())
-        m_page->insertDictatedTextAsync(eventText, replacementRange, dictationAlternatives, registerUndoGroup);
-    else {
+    if (!dictationAlternatives.isEmpty()) {
+        InsertTextOptions options;
+        options.registerUndoGroup = registerUndoGroup;
+        m_page->insertDictatedTextAsync(eventText, replacementRange, dictationAlternatives, WTFMove(options));
+    } else {
         InsertTextOptions options;
         options.registerUndoGroup = registerUndoGroup;
         options.editingRangeIsRelativeTo = m_isTextInsertionReplacingSoftSpace ? EditingRangeIsRelativeTo::Paragraph : EditingRangeIsRelativeTo::EditableRoot;
index c8e32ad..903c70f 100644 (file)
@@ -848,7 +848,7 @@ public:
     void setTextAsync(const String&);
 
     void insertTextAsync(const String&, const EditingRange& replacementRange, InsertTextOptions&&);
-    void insertDictatedTextAsync(const String&, const EditingRange& replacementRange, const Vector<WebCore::TextAlternativeWithRange>&, bool registerUndoGroup);
+    void insertDictatedTextAsync(const String&, const EditingRange& replacementRange, const Vector<WebCore::TextAlternativeWithRange>&, InsertTextOptions&&);
 
     void hasMarkedText(CompletionHandler<void(bool)>&&);
     void getMarkedRangeAsync(WTF::Function<void (EditingRange, CallbackBase::Error)>&&);
index 777d2c8..7754d6e 100644 (file)
@@ -4731,7 +4731,7 @@ static WebKit::WritingDirection coreWritingDirection(NSWritingDirection directio
         BOOL isLowConfidence = style == UITextAlternativeStyleLowConfidence;
         auto textAlternatives = adoptNS([[NSTextAlternatives alloc] initWithPrimaryString:aStringValue alternativeStrings:alternatives isLowConfidence:isLowConfidence]);
         WebCore::TextAlternativeWithRange textAlternativeWithRange { textAlternatives.get(), NSMakeRange(0, aStringValue.length) };
-        _page->insertDictatedTextAsync(aStringValue, WebKit::EditingRange { }, { textAlternativeWithRange }, false /* registerUndoGroup */);
+        _page->insertDictatedTextAsync(aStringValue, { }, { textAlternativeWithRange }, { });
     }
 }
 
index 11013ce..9ab9b8a 100644 (file)
@@ -27,6 +27,7 @@
 #import "WebPage.h"
 
 #import "AttributedString.h"
+#import "InsertTextOptions.h"
 #import "LoadParameters.h"
 #import "PluginView.h"
 #import "WKAccessibilityWebPageObjectBase.h"
@@ -182,7 +183,7 @@ DictionaryPopupInfo WebPage::dictionaryPopupInfoForRange(Frame& frame, Range& ra
     return dictionaryPopupInfo;
 }
 
-void WebPage::insertDictatedTextAsync(const String& text, const EditingRange& replacementEditingRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool registerUndoGroup)
+void WebPage::insertDictatedTextAsync(const String& text, const EditingRange& replacementEditingRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, InsertTextOptions&& options)
 {
     auto& frame = m_page->focusController().focusedOrMainFrame();
     Ref<Frame> protector { frame };
@@ -193,7 +194,7 @@ void WebPage::insertDictatedTextAsync(const String& text, const EditingRange& re
             frame.selection().setSelection(VisibleSelection { *replacementRange, SEL_DEFAULT_AFFINITY });
     }
 
-    if (registerUndoGroup)
+    if (options.registerUndoGroup)
         send(Messages::WebPageProxy::RegisterInsertionUndoGrouping { });
 
     ASSERT(!frame.editor().hasComposition());
index 4dc4e10..6b28372 100644 (file)
@@ -846,7 +846,7 @@ public:
     void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, CompletionHandler<void(bool)>&&);
     bool performNonEditingBehaviorForSelector(const String&, WebCore::KeyboardEvent*);
 
-    void insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool registerUndoGroup = false);
+    void insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, InsertTextOptions&&);
 #endif
 
 #if PLATFORM(MAC)
index f84373f..76202e5 100644 (file)
@@ -442,7 +442,7 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType
     SetTextAsync(String text)
 
     InsertTextAsync(String text, struct WebKit::EditingRange replacementRange, struct WebKit::InsertTextOptions options)
-    InsertDictatedTextAsync(String text, struct WebKit::EditingRange replacementRange, Vector<WebCore::DictationAlternative> dictationAlternatives, bool registerUndoGroup)
+    InsertDictatedTextAsync(String text, struct WebKit::EditingRange replacementRange, Vector<WebCore::DictationAlternative> dictationAlternatives, struct WebKit::InsertTextOptions options)
 
     HasMarkedText() -> (bool hasMarkedText) Async
     GetMarkedRangeAsync(WebKit::CallbackID callbackID)