Skip to content

Commit

Permalink
Merge r177152 - REGRESSION (Async Text Input): Text input method stat…
Browse files Browse the repository at this point in the history
…e is not reset when reloading a page

https://bugs.webkit.org/show_bug.cgi?id=139504
rdar://problem/19034674

Reviewed by Enrica Casucci.

Source/WebCore:

Explicitly notify EditorClient when a composition is voluntarily canceled by WebCore.
These are almost certainly not all the places where this happens, but this fixes the bug,
and lays the groundwork for using this new client call instead of didChangeSelection
hacks.

* editing/Editor.cpp:
(WebCore::Editor::clear):
(WebCore::Editor::cancelComposition):
* loader/EmptyClients.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::willTransitionToCommitted):
* page/EditorClient.h:

Source/WebKit/mac:

Stub out new client calls, this patch does not attempt to make any changes on WebKit1.

* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::discardedComposition):

Source/WebKit/win:

Stub out new client calls, this patch doesn't attempt to make any changes on Windows.

* WebCoreSupport/WebEditorClient.cpp:
(WebEditorClient::discardedComposition):
* WebCoreSupport/WebEditorClient.h:

Source/WebKit2:

WebKit2 used to look at EditorState changes and guess when to cancel a composition.
This was quite unreliable, and needlessly complicated - WebCore knows when it decides
to destroy a composition, so it now explicitly notifies the clients.

* UIProcess/API/mac/WKView.mm: (-[WKView _processDidExit]): Address crashing case too.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetStateAfterProcessExited):
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::discardedComposition):
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didChangeSelection):
(WebKit::WebPage::discardedComposition):
* WebProcess/WebPage/WebPage.h:

Canonical link: https://commits.webkit.org/154760.280@webkitgtk/2.6
git-svn-id: https://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.6@178350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aproskuryakov authored and carlosgcampos committed Jan 13, 2015
1 parent 857f149 commit 28da89d
Show file tree
Hide file tree
Showing 18 changed files with 118 additions and 9 deletions.
21 changes: 21 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,24 @@
2014-12-11 Alexey Proskuryakov <ap@apple.com>

REGRESSION (Async Text Input): Text input method state is not reset when reloading a page
https://bugs.webkit.org/show_bug.cgi?id=139504
rdar://problem/19034674

Reviewed by Enrica Casucci.

Explicitly notify EditorClient when a composition is voluntarily canceled by WebCore.
These are almost certainly not all the places where this happens, but this fixes the bug,
and lays the groundwork for using this new client call instead of didChangeSelection
hacks.

* editing/Editor.cpp:
(WebCore::Editor::clear):
(WebCore::Editor::cancelComposition):
* loader/EmptyClients.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::willTransitionToCommitted):
* page/EditorClient.h:

2014-12-10 Chris Dumez <cdumez@apple.com>

http://omfgdogs.info/ only animates when you resize the window
Expand Down
6 changes: 5 additions & 1 deletion Source/WebCore/editing/Editor.cpp
Expand Up @@ -1165,7 +1165,11 @@ Editor::~Editor()

void Editor::clear()
{
m_compositionNode = 0;
if (m_compositionNode) {
m_compositionNode = nullptr;
if (EditorClient* client = this->client())
client->discardedComposition(&m_frame);
}
m_customCompositionUnderlines.clear();
m_shouldStyleWithCSS = false;
m_defaultParagraphSeparator = EditorParagraphSeparatorIsDiv;
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/loader/EmptyClients.h
Expand Up @@ -449,6 +449,7 @@ class EmptyEditorClient : public EditorClient {
virtual void didBeginEditing() override { }
virtual void respondToChangedContents() override { }
virtual void respondToChangedSelection(Frame*) override { }
virtual void discardedComposition(Frame*) override { }
virtual void didEndEditing() override { }
virtual void willWriteSelectionToPasteboard(Range*) override { }
virtual void didWriteSelectionToPasteboard() override { }
Expand Down
4 changes: 3 additions & 1 deletion Source/WebCore/loader/FrameLoader.cpp
Expand Up @@ -528,8 +528,10 @@ void FrameLoader::willTransitionToCommitted()
if (m_frame.editor().hasComposition()) {
// The text was already present in DOM, so it's better to confirm than to cancel the composition.
m_frame.editor().confirmComposition();
if (EditorClient* editorClient = m_frame.editor().client())
if (EditorClient* editorClient = m_frame.editor().client()) {
editorClient->respondToChangedSelection(&m_frame);
editorClient->discardedComposition(&m_frame);
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion Source/WebCore/page/EditorClient.h
Expand Up @@ -97,7 +97,11 @@ class EditorClient {
virtual void willWriteSelectionToPasteboard(Range*) = 0;
virtual void didWriteSelectionToPasteboard() = 0;
virtual void getClientPasteboardDataForRange(Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<SharedBuffer>>& pasteboardData) = 0;


// Notify an input method that a composition was voluntarily discarded by WebCore, so that it could clean up too.
// This function is not called when a composition is closed per a request from an input method.
virtual void discardedComposition(Frame*) = 0;

virtual void registerUndoStep(PassRefPtr<UndoStep>) = 0;
virtual void registerRedoStep(PassRefPtr<UndoStep>) = 0;
virtual void clearUndoRedoOperations() = 0;
Expand Down
14 changes: 14 additions & 0 deletions Source/WebKit/mac/ChangeLog
@@ -1,3 +1,17 @@
2014-12-11 Alexey Proskuryakov <ap@apple.com>

REGRESSION (Async Text Input): Text input method state is not reset when reloading a page
https://bugs.webkit.org/show_bug.cgi?id=139504
rdar://problem/19034674

Reviewed by Enrica Casucci.

Stub out new client calls, this patch does not attempt to make any changes on WebKit1.

* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::discardedComposition):

2014-09-19 Dean Jackson <dino@apple.com>

Multithreaded WebGL is a bad idea - remove it
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/mac/WebCoreSupport/WebEditorClient.h
Expand Up @@ -114,6 +114,7 @@ class WebEditorClient : public WebCore::EditorClient, public WebCore::TextChecke

virtual void respondToChangedContents() override;
virtual void respondToChangedSelection(WebCore::Frame*) override;
virtual void discardedComposition(WebCore::Frame*) override;

virtual void registerUndoStep(PassRefPtr<WebCore::UndoStep>) override;
virtual void registerRedoStep(PassRefPtr<WebCore::UndoStep>) override;
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm
Expand Up @@ -361,6 +361,11 @@ - (void)redoEditing:(id)arg
#endif
}

void WebEditorClient::discardedComposition(Frame*)
{
// The effects of this function are currently achieved via -[WebHTMLView _updateSelectionForInputManager].
}

void WebEditorClient::didEndEditing()
{
#if !PLATFORM(IOS)
Expand Down
14 changes: 14 additions & 0 deletions Source/WebKit/win/ChangeLog
@@ -1,3 +1,17 @@
2014-12-11 Alexey Proskuryakov <ap@apple.com>

REGRESSION (Async Text Input): Text input method state is not reset when reloading a page
https://bugs.webkit.org/show_bug.cgi?id=139504
rdar://problem/19034674

Reviewed by Enrica Casucci.

Stub out new client calls, this patch doesn't attempt to make any changes on Windows.

* WebCoreSupport/WebEditorClient.cpp:
(WebEditorClient::discardedComposition):
* WebCoreSupport/WebEditorClient.h:

2014-09-06 Brian J. Burg <burg@cs.washington.edu>

Web Inspector: convert DockSide to an enum class
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp
Expand Up @@ -220,6 +220,11 @@ void WebEditorClient::respondToChangedSelection(Frame*)
notifyCenter->postNotificationName(webViewDidChangeSelectionNotificationName, static_cast<IWebView*>(m_webView), 0);
}

void WebEditorClient::discardedComposition(Frame*)
{
notImplemented();
}

void WebEditorClient::didEndEditing()
{
notImplemented();
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/win/WebCoreSupport/WebEditorClient.h
Expand Up @@ -60,6 +60,7 @@ class WebEditorClient : public WebCore::EditorClient, public WebCore::TextChecke

virtual void respondToChangedContents();
virtual void respondToChangedSelection(WebCore::Frame*);
virtual void discardedComposition(WebCore::Frame*) override;

bool shouldDeleteRange(WebCore::Range*);

Expand Down
23 changes: 23 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,26 @@
2014-12-11 Alexey Proskuryakov <ap@apple.com>

REGRESSION (Async Text Input): Text input method state is not reset when reloading a page
https://bugs.webkit.org/show_bug.cgi?id=139504
rdar://problem/19034674

Reviewed by Enrica Casucci.

WebKit2 used to look at EditorState changes and guess when to cancel a composition.
This was quite unreliable, and needlessly complicated - WebCore knows when it decides
to destroy a composition, so it now explicitly notifies the clients.

* UIProcess/API/mac/WKView.mm: (-[WKView _processDidExit]): Address crashing case too.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetStateAfterProcessExited):
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::discardedComposition):
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didChangeSelection):
(WebKit::WebPage::discardedComposition):
* WebProcess/WebPage/WebPage.h:

2014-12-11 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] Timers might never be fired during animations
Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit2/UIProcess/API/mac/WKView.mm
Expand Up @@ -2825,6 +2825,8 @@ - (BOOL)_isFocused

- (void)_processDidExit
{
[self _notifyInputContextAboutDiscardedComposition];

if (_data->_layerHostingView)
[self _setAcceleratedCompositingModeRootLayer:nil];

Expand Down
11 changes: 5 additions & 6 deletions Source/WebKit2/UIProcess/WebPageProxy.cpp
Expand Up @@ -4462,6 +4462,11 @@ void WebPageProxy::resetStateAfterProcessExited()
m_isValid = false;
m_isPageSuspended = false;

m_editorState = EditorState();
#if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
m_temporarilyClosedComposition = false;
#endif

if (m_mainFrame) {
m_urlAtProcessExit = m_mainFrame->url();
m_loadStateAtProcessExit = m_mainFrame->frameLoadState().m_state;
Expand All @@ -4488,12 +4493,6 @@ void WebPageProxy::resetStateAfterProcessExited()
m_touchEventQueue.clear();
#endif

// FIXME: Reset m_editorState.
// FIXME: Notify input methods about abandoned composition.
#if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
m_temporarilyClosedComposition = false;
#endif

#if PLATFORM(MAC)
dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
m_pageClient.dismissDictionaryLookupPanel();
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
Expand Up @@ -199,6 +199,11 @@ void WebEditorClient::respondToChangedSelection(Frame* frame)
#endif
}

void WebEditorClient::discardedComposition(Frame*)
{
m_page->discardedComposition();
}

void WebEditorClient::didEndEditing()
{
static NeverDestroyed<String> WebViewDidEndEditingNotification(ASCIILiteral("WebViewDidEndEditingNotification"));
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
Expand Up @@ -64,6 +64,7 @@ class WebEditorClient : public WebCore::EditorClient, public WebCore::TextChecke
virtual void didBeginEditing() override;
virtual void respondToChangedContents() override;
virtual void respondToChangedSelection(WebCore::Frame*) override;
virtual void discardedComposition(WebCore::Frame*) override;
virtual void didEndEditing() override;
virtual void willWriteSelectionToPasteboard(WebCore::Range*) override;
virtual void didWriteSelectionToPasteboard() override;
Expand Down
6 changes: 6 additions & 0 deletions Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Expand Up @@ -4314,6 +4314,7 @@ void WebPage::didChangeSelection()
#if PLATFORM(MAC) && USE(ASYNC_NSTEXTINPUTCLIENT)
Frame& frame = m_page->focusController().focusedOrMainFrame();
// Abandon the current inline input session if selection changed for any other reason but an input method direct action.
// FIXME: This logic should be in WebCore.
// FIXME: Many changes that affect composition node do not go through didChangeSelection(). We need to do something when DOM manipulation affects the composition, because otherwise input method's idea about it will be different from Editor's.
// FIXME: We can't cancel composition when selection changes to NoSelection, but we probably should.
if (frame.editor().hasComposition() && !frame.editor().ignoreCompositionSelectionChange() && !frame.selection().isNone()) {
Expand All @@ -4330,6 +4331,11 @@ void WebPage::didChangeSelection()
#endif
}

void WebPage::discardedComposition()
{
send(Messages::WebPageProxy::CompositionWasCanceled(editorState()));
}

void WebPage::setMinimumLayoutSize(const IntSize& minimumLayoutSize)
{
if (m_minimumLayoutSize == minimumLayoutSize)
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit2/WebProcess/WebPage/WebPage.h
Expand Up @@ -579,6 +579,7 @@ class WebPage : public API::ObjectImpl<API::Object::Type::BundlePage>, public IP
#endif

void didChangeSelection();
void discardedComposition();

#if PLATFORM(COCOA)
void registerUIProcessAccessibilityTokens(const IPC::DataReference& elemenToken, const IPC::DataReference& windowToken);
Expand Down

0 comments on commit 28da89d

Please sign in to comment.