Changeset 177152 in webkit


Ignore:
Timestamp:
Dec 11, 2014 9:23:34 AM (9 years ago)
Author:
ap@apple.com
Message:

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.

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:
Location:
trunk/Source
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r177151 r177152  
     12014-12-11  Alexey Proskuryakov  <ap@apple.com>
     2
     3        REGRESSION (Async Text Input): Text input method state is not reset when reloading a page
     4        https://bugs.webkit.org/show_bug.cgi?id=139504
     5        rdar://problem/19034674
     6
     7        Reviewed by Enrica Casucci.
     8
     9        Explicitly notify EditorClient when a composition is voluntarily canceled by WebCore.
     10        These are almost certainly not all the places where this happens, but this fixes the bug,
     11        and lays the groundwork for using this new client call instead of didChangeSelection
     12        hacks.
     13
     14        * editing/Editor.cpp:
     15        (WebCore::Editor::clear):
     16        (WebCore::Editor::cancelComposition):
     17        * loader/EmptyClients.h:
     18        * loader/FrameLoader.cpp:
     19        (WebCore::FrameLoader::willTransitionToCommitted):
     20        * page/EditorClient.h:
     21
    1222014-12-10  Anders Carlsson  <andersca@apple.com>
    223
  • trunk/Source/WebCore/editing/Editor.cpp

    r176780 r177152  
    10921092void Editor::clear()
    10931093{
    1094     m_compositionNode = 0;
     1094    if (m_compositionNode) {
     1095        m_compositionNode = nullptr;
     1096        if (EditorClient* client = this->client())
     1097            client->discardedComposition(&m_frame);
     1098    }
    10951099    m_customCompositionUnderlines.clear();
    10961100    m_shouldStyleWithCSS = false;
  • trunk/Source/WebCore/loader/EmptyClients.h

    r176697 r177152  
    453453    virtual void respondToChangedContents() override { }
    454454    virtual void respondToChangedSelection(Frame*) override { }
     455    virtual void discardedComposition(Frame*) override { }
    455456    virtual void didEndEditing() override { }
    456457    virtual void willWriteSelectionToPasteboard(Range*) override { }
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r177035 r177152  
    530530        // The text was already present in DOM, so it's better to confirm than to cancel the composition.
    531531        m_frame.editor().confirmComposition();
    532         if (EditorClient* editorClient = m_frame.editor().client())
     532        if (EditorClient* editorClient = m_frame.editor().client()) {
    533533            editorClient->respondToChangedSelection(&m_frame);
     534            editorClient->discardedComposition(&m_frame);
     535        }
    534536    }
    535537}
  • trunk/Source/WebCore/page/EditorClient.h

    r175647 r177152  
    9898    virtual void didWriteSelectionToPasteboard() = 0;
    9999    virtual void getClientPasteboardDataForRange(Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<SharedBuffer>>& pasteboardData) = 0;
    100    
     100
     101    // Notify an input method that a composition was voluntarily discarded by WebCore, so that it could clean up too.
     102    // This function is not called when a composition is closed per a request from an input method.
     103    virtual void discardedComposition(Frame*) = 0;
     104
    101105    virtual void registerUndoStep(PassRefPtr<UndoStep>) = 0;
    102106    virtual void registerRedoStep(PassRefPtr<UndoStep>) = 0;
  • trunk/Source/WebKit/mac/ChangeLog

    r177151 r177152  
     12014-12-11  Alexey Proskuryakov  <ap@apple.com>
     2
     3        REGRESSION (Async Text Input): Text input method state is not reset when reloading a page
     4        https://bugs.webkit.org/show_bug.cgi?id=139504
     5        rdar://problem/19034674
     6
     7        Reviewed by Enrica Casucci.
     8
     9        Stub out new client calls, this patch does not attempt to make any changes on WebKit1.
     10
     11        * WebCoreSupport/WebEditorClient.h:
     12        * WebCoreSupport/WebEditorClient.mm:
     13        (WebEditorClient::discardedComposition):
     14
    1152014-12-10  Anders Carlsson  <andersca@apple.com>
    216
  • trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h

    r175647 r177152  
    111111    virtual void respondToChangedContents() override;
    112112    virtual void respondToChangedSelection(WebCore::Frame*) override;
     113    virtual void discardedComposition(WebCore::Frame*) override;
    113114
    114115    virtual void registerUndoStep(PassRefPtr<WebCore::UndoStep>) override;
  • trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm

    r175647 r177152  
    352352        WebThreadPostNotification(WebViewDidChangeSelectionNotification, m_webView, nil);
    353353#endif
     354}
     355
     356void WebEditorClient::discardedComposition(Frame*)
     357{
     358    // The effects of this function are currently achieved via -[WebHTMLView _updateSelectionForInputManager].
    354359}
    355360
  • trunk/Source/WebKit/win/ChangeLog

    r177151 r177152  
     12014-12-11  Alexey Proskuryakov  <ap@apple.com>
     2
     3        REGRESSION (Async Text Input): Text input method state is not reset when reloading a page
     4        https://bugs.webkit.org/show_bug.cgi?id=139504
     5        rdar://problem/19034674
     6
     7        Reviewed by Enrica Casucci.
     8
     9        Stub out new client calls, this patch doesn't attempt to make any changes on Windows.
     10
     11        * WebCoreSupport/WebEditorClient.cpp:
     12        (WebEditorClient::discardedComposition):
     13        * WebCoreSupport/WebEditorClient.h:
     14
    1152014-12-10  Anders Carlsson  <andersca@apple.com>
    216
  • trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp

    r176892 r177152  
    218218    IWebNotificationCenter* notifyCenter = WebNotificationCenter::defaultCenterInternal();
    219219    notifyCenter->postNotificationName(webViewDidChangeSelectionNotificationName, static_cast<IWebView*>(m_webView), 0);
     220}
     221
     222void WebEditorClient::discardedComposition(Frame*)
     223{
     224    notImplemented();
    220225}
    221226
  • trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h

    r171403 r177152  
    6161    virtual void respondToChangedContents();
    6262    virtual void respondToChangedSelection(WebCore::Frame*);
     63    virtual void discardedComposition(WebCore::Frame*) override;
    6364
    6465    bool shouldDeleteRange(WebCore::Range*);
  • trunk/Source/WebKit2/ChangeLog

    r177151 r177152  
     12014-12-11  Alexey Proskuryakov  <ap@apple.com>
     2
     3        REGRESSION (Async Text Input): Text input method state is not reset when reloading a page
     4        https://bugs.webkit.org/show_bug.cgi?id=139504
     5        rdar://problem/19034674
     6
     7        Reviewed by Enrica Casucci.
     8
     9        WebKit2 used to look at EditorState changes and guess when to cancel a composition.
     10        This was quite unreliable, and needlessly complicated - WebCore knows when it decides
     11        to destroy a composition, so it now explicitly notifies the clients.
     12
     13        * UIProcess/API/mac/WKView.mm: (-[WKView _processDidExit]): Address crashing case too.
     14        * UIProcess/WebPageProxy.cpp:
     15        (WebKit::WebPageProxy::resetStateAfterProcessExited):
     16        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
     17        (WebKit::WebEditorClient::discardedComposition):
     18        * WebProcess/WebCoreSupport/WebEditorClient.h:
     19        * WebProcess/WebPage/WebPage.cpp:
     20        (WebKit::WebPage::didChangeSelection):
     21        (WebKit::WebPage::discardedComposition):
     22        * WebProcess/WebPage/WebPage.h:
     23
    1242014-12-10  Anders Carlsson  <andersca@apple.com>
    225
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r177116 r177152  
    28922892- (void)_processDidExit
    28932893{
     2894    [self _notifyInputContextAboutDiscardedComposition];
     2895
    28942896    if (_data->_layerHostingView)
    28952897        [self _setAcceleratedCompositingModeRootLayer:nil];
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r177123 r177152  
    45584558    m_isPageSuspended = false;
    45594559
     4560    m_editorState = EditorState();
     4561#if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
     4562    m_temporarilyClosedComposition = false;
     4563#endif
     4564
    45604565    m_pageClient.processDidExit();
    45614566
     
    45774582#if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
    45784583    m_touchEventQueue.clear();
    4579 #endif
    4580 
    4581     // FIXME: Reset m_editorState.
    4582     // FIXME: Notify input methods about abandoned composition.
    4583 #if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
    4584     m_temporarilyClosedComposition = false;
    45854584#endif
    45864585
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp

    r175647 r177152  
    191191}
    192192
     193void WebEditorClient::discardedComposition(Frame*)
     194{
     195    m_page->discardedComposition();
     196}
     197
    193198void WebEditorClient::didEndEditing()
    194199{
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h

    r175647 r177152  
    6565    virtual void respondToChangedContents() override;
    6666    virtual void respondToChangedSelection(WebCore::Frame*) override;
     67    virtual void discardedComposition(WebCore::Frame*) override;
    6768    virtual void didEndEditing() override;
    6869    virtual void willWriteSelectionToPasteboard(WebCore::Range*) override;
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r177118 r177152  
    43804380    Frame& frame = m_page->focusController().focusedOrMainFrame();
    43814381    // Abandon the current inline input session if selection changed for any other reason but an input method direct action.
     4382    // FIXME: This logic should be in WebCore.
    43824383    // 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.
    43834384    // FIXME: We can't cancel composition when selection changes to NoSelection, but we probably should.
     
    43964397}
    43974398
     4399void WebPage::discardedComposition()
     4400{
     4401    send(Messages::WebPageProxy::CompositionWasCanceled(editorState()));
     4402}
     4403
    43984404void WebPage::setMinimumLayoutSize(const IntSize& minimumLayoutSize)
    43994405{
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r177104 r177152  
    601601
    602602    void didChangeSelection();
     603    void discardedComposition();
    603604
    604605#if PLATFORM(COCOA)
Note: See TracChangeset for help on using the changeset viewer.