https://bugs.webkit.org/show_bug.cgi?id=134807
Reviewed by Tim Horton.
Some editing commands have an effect on some parts of the system that
run inside the UIProcess. A good example are the cursor movement commands
that require an update of the autocorrection/autosuggestion machinery.
This patch adds a way to reliably know when the command has been executed
in the WebProcess. A previous attempt at solving this problem was added in
r170858 and was partially reverted in r170948.
The change also removes the selectionWillChange notification added in r170858.
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::editorStateChanged):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::selectionWillChange): Deleted.
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView executeEditCommandWithCallback:]):
(-[WKContentView _moveUp:withHistory:]):
(-[WKContentView _moveDown:withHistory:]):
(-[WKContentView _moveLeft:withHistory:]):
(-[WKContentView _moveRight:withHistory:]):
(-[WKContentView _moveToStartOfWord:withHistory:]):
(-[WKContentView _moveToStartOfParagraph:withHistory:]):
(-[WKContentView _moveToStartOfLine:withHistory:]):
(-[WKContentView _moveToStartOfDocument:withHistory:]):
(-[WKContentView _moveToEndOfWord:withHistory:]):
(-[WKContentView _moveToEndOfParagraph:withHistory:]):
(-[WKContentView _moveToEndOfLine:withHistory:]):
(-[WKContentView _moveToEndOfDocument:withHistory:]):
(-[WKContentView _selectionWillChange]): Deleted.
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::executeEditCommand):
(WebKit::WebPageProxy::notifySelectionWillChange): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::executeEditCommandWithCallback):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170981
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-07-10 Enrica Casucci <enrica@apple.com>
+
+ Add a mechanism to notify the UIProcess when an editing command is done executing.
+ https://bugs.webkit.org/show_bug.cgi?id=134807
+
+ Reviewed by Tim Horton.
+
+ Some editing commands have an effect on some parts of the system that
+ run inside the UIProcess. A good example are the cursor movement commands
+ that require an update of the autocorrection/autosuggestion machinery.
+ This patch adds a way to reliably know when the command has been executed
+ in the WebProcess. A previous attempt at solving this problem was added in
+ r170858 and was partially reverted in r170948.
+ The change also removes the selectionWillChange notification added in r170858.
+
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::editorStateChanged):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/PageClientImplIOS.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::selectionWillChange): Deleted.
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView executeEditCommandWithCallback:]):
+ (-[WKContentView _moveUp:withHistory:]):
+ (-[WKContentView _moveDown:withHistory:]):
+ (-[WKContentView _moveLeft:withHistory:]):
+ (-[WKContentView _moveRight:withHistory:]):
+ (-[WKContentView _moveToStartOfWord:withHistory:]):
+ (-[WKContentView _moveToStartOfParagraph:withHistory:]):
+ (-[WKContentView _moveToStartOfLine:withHistory:]):
+ (-[WKContentView _moveToStartOfDocument:withHistory:]):
+ (-[WKContentView _moveToEndOfWord:withHistory:]):
+ (-[WKContentView _moveToEndOfParagraph:withHistory:]):
+ (-[WKContentView _moveToEndOfLine:withHistory:]):
+ (-[WKContentView _moveToEndOfDocument:withHistory:]):
+ (-[WKContentView _selectionWillChange]): Deleted.
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::executeEditCommand):
+ (WebKit::WebPageProxy::notifySelectionWillChange): Deleted.
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::executeEditCommandWithCallback):
+
2014-07-10 Joseph Pecoraro <pecoraro@apple.com>
[Mac] NSWindow warning: adding an unknown subview opening detached Inspector
virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) = 0;
virtual void stopAssistingNode() = 0;
- virtual void selectionWillChange() = 0;
virtual void selectionDidChange() = 0;
virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) = 0;
virtual void positionInformationDidChange(const InteractionInformationAtPosition&) = 0;
m_temporarilyClosedComposition = editorState.shouldIgnoreCompositionSelectionChange && (m_temporarilyClosedComposition || m_editorState.hasComposition) && !editorState.hasComposition;
#endif
-#if PLATFORM(IOS)
- notifySelectionWillChange();
-#endif
m_editorState = editorState;
#if PLATFORM(COCOA)
void executeEditCommand(const String& commandName);
void validateCommand(const String& commandName, std::function<void (const String&, bool, int32_t, CallbackBase::Error)>);
#if PLATFORM(IOS)
+ void executeEditCommand(const String& commandName, std::function<void (CallbackBase::Error)>);
double displayedContentScale() const { return m_lastVisibleContentRectUpdate.scale(); }
const WebCore::FloatRect& exposedContentRect() const { return m_lastVisibleContentRectUpdate.exposedRect(); }
const WebCore::FloatRect& unobscuredContentRect() const { return m_lastVisibleContentRectUpdate.unobscuredRect(); }
void enableInspectorNodeSearch();
void disableInspectorNodeSearch();
#endif
- void notifySelectionWillChange();
void notifyRevealedSelection();
#endif // PLATFORM(IOS)
virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) override;
virtual void stopAssistingNode() override;
- virtual void selectionWillChange() override;
virtual void selectionDidChange() override;
virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) override;
virtual void positionInformationDidChange(const InteractionInformationAtPosition&) override;
notImplemented();
}
-void PageClientImpl::selectionWillChange()
-{
- [m_contentView _selectionWillChange];
-}
-
void PageClientImpl::selectionDidChange()
{
[m_contentView _selectionChanged];
- (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode userObject:(NSObject <NSSecureCoding> *)userObject;
- (void)_stopAssistingNode;
-- (void)_selectionWillChange;
- (void)_selectionChanged;
- (void)_updateChangedSelection;
- (BOOL)_interpretKeyEvent:(WebIOSEvent *)theEvent isCharEvent:(BOOL)isCharEvent;
return NO;
}
+- (void)executeEditCommandWithCallback:(NSString *)commandName
+{
+ [self beginSelectionChange];
+ _page->executeEditCommand(commandName, [self](CallbackBase::Error) {
+ [self endSelectionChange];
+ });
+}
+
- (UITextInputArrowKeyHistory *)_moveUp:(BOOL)extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveUp"));
+ [self executeEditCommandWithCallback:@"moveUp"];
return nil;
}
- (UITextInputArrowKeyHistory *)_moveDown:(BOOL)extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveDown"));
+ [self executeEditCommandWithCallback:@"moveDown"];
return nil;
}
- (UITextInputArrowKeyHistory *)_moveLeft:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveLeft"));
+ [self executeEditCommandWithCallback:@"moveLeft"];
return nil;
}
- (UITextInputArrowKeyHistory *)_moveRight:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveRight"));
+ [self executeEditCommandWithCallback:@"moveRight"];
return nil;
}
- (UITextInputArrowKeyHistory *)_moveToStartOfWord:(BOOL)extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveWordBackward"));
+ [self executeEditCommandWithCallback:@"moveWordBackward"];
return nil;
}
- (UITextInputArrowKeyHistory *)_moveToStartOfParagraph:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveToStartOfParagraph"));
+ [self executeEditCommandWithCallback:@"moveToStartOfParagraph"];
return nil;
}
- (UITextInputArrowKeyHistory *)_moveToStartOfLine:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveToStartOfLine"));
+ [self executeEditCommandWithCallback:@"moveToStartOfLine"];
return nil;
}
- (UITextInputArrowKeyHistory *)_moveToStartOfDocument:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveToBeginningOfDocument"));
+ [self executeEditCommandWithCallback:@"moveToBeginningOfDocument"];
return nil;
}
- (UITextInputArrowKeyHistory *)_moveToEndOfWord:(BOOL)extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveWordForward"));
+ [self executeEditCommandWithCallback:@"moveWordForward"];
return nil;
}
- (UITextInputArrowKeyHistory *)_moveToEndOfParagraph:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveToEndOfParagraph"));
+ [self executeEditCommandWithCallback:@"moveToEndOfParagraph"];
return nil;
}
- (UITextInputArrowKeyHistory *)_moveToEndOfLine:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveToEndOfLine"));
+ [self executeEditCommandWithCallback:@"moveToEndOfLine"];
return nil;
}
- (UITextInputArrowKeyHistory *)_moveToEndOfDocument:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
{
- _page->executeEditCommand(ASCIILiteral("moveToEndOfDocument"));
+ [self executeEditCommandWithCallback:@"moveToEndOfDocument"];
return nil;
}
[_webSelectionAssistant resignedFirstResponder];
}
-- (void)_selectionWillChange
-{
-}
-
- (void)_selectionChanged
{
_selectionNeedsUpdate = YES;
m_process->send(Messages::WebPage::ApplyAutocorrection(correction, originalText, callbackID), m_pageID);
}
+void WebPageProxy::executeEditCommand(const String& commandName, std::function<void (CallbackBase::Error)> callbackFunction)
+{
+ if (!isValid()) {
+ callbackFunction(CallbackBase::Error::Unknown);
+ return;
+ }
+
+ uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
+ m_process->send(Messages::WebPage::ExecuteEditCommandWithCallback(commandName, callbackID), m_pageID);
+}
+
bool WebPageProxy::applyAutocorrection(const String& correction, const String& originalText)
{
bool autocorrectionApplied = false;
m_process->send(Messages::WebPage::ApplicationDidBecomeActive(), m_pageID);
}
-void WebPageProxy::notifySelectionWillChange()
-{
- m_pageClient.selectionWillChange();
-}
-
void WebPageProxy::notifyRevealedSelection()
{
m_pageClient.selectionDidChange();
void dispatchAsynchronousTouchEvents(const Vector<WebTouchEvent, 1>& queue);
void contentSizeCategoryDidChange(const String&);
+ void executeEditCommandWithCallback(const String&, uint64_t callbackID);
#if ENABLE(INSPECTOR)
void showInspectorHighlight(const WebCore::Highlight&);
void hideInspectorHighlight();
ApplicationWillEnterForeground()
ApplicationDidBecomeActive()
ContentSizeCategoryDidChange(String contentSizeCategory)
+ ExecuteEditCommandWithCallback(String name, uint64_t callbackID)
#endif
#if ENABLE(REMOTE_INSPECTOR)
send(Messages::WebPageProxy::StringCallback(correctionApplied ? correction : String(), callbackID));
}
+void WebPage::executeEditCommandWithCallback(const String& commandName, uint64_t callbackID)
+{
+ executeEditCommand(commandName);
+ send(Messages::WebPageProxy::VoidCallback(callbackID));
+}
+
void WebPage::syncApplyAutocorrection(const String& correction, const String& originalText, bool& correctionApplied)
{
RefPtr<Range> range;