Changeset 84526 in webkit


Ignore:
Timestamp:
Apr 21, 2011 11:29:00 AM (13 years ago)
Author:
ap@apple.com
Message:

Reviewed by Maciej Stachowiak.

WebKit2: Unconfirmed inline input session persists after reload
https://bugs.webkit.org/show_bug.cgi?id=59054
<rdar://problem/9291086>

Makes the inline input get properly confirmed or discarded when changing selection,
navigating to another page, focusing another view in the window, or after a web process
crash.

  • Shared/EditorState.h: (WebKit::EditorState::EditorState):
  • WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::editorState): Added a variable that Editor sets while processing input method calls. We don't want selection changes caused by -setMarkedText: discard the composition!


  • UIProcess/PageClient.h:
  • UIProcess/API/mac/PageClientImpl.h:
  • UIProcess/API/mac/PageClientImpl.mm: (WebKit::PageClientImpl::updateTextInputState): (WebKit::PageClientImpl::resetTextInputState): Extended updateSecureInputState() to potentially confirm the current inline input session. Added resetTextInputState, which is to be called when we get out of the current web page.
  • UIProcess/API/mac/WKView.mm: (-[WKView resignFirstResponder]): Just call _resetTextInputState instead of dealing with input state here. (-[WKView _updateSecureInputState]): Use _isFocused to make the code simpler. (-[WKView _updateTextInputStateIncludingSecureInputState:]): Confirm the current inline input session if selection changed for any other reason but an input method changing the composition. We will want to do other work here, like dismissing a dictionary pop-up, updating a font panel etc. (-[WKView _resetTextInputState]): Added. We don't want secure text input persist after navigations, crashes an such, and we also don't want input methods to remember inline input state. Relying on selection changed notifications is fragile and insufficient.
  • UIProcess/API/mac/WKViewInternal.h: Added internal functions to keep the build unbroken.
  • UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::didCommitLoadForFrame): This is the best chance we have to reset input state for a new page. This doesn't work well for cached page loads, but WK1 is quite broken in that case, too. (WebKit::WebPageProxy::editorStateChanged): Moved some logic up to the client, since the function now does much more than before.
  • UIProcess/WebPageProxy.h:
  • UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::confirmCompositionWithoutDisturbingSelection):
  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
  • WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::confirmCompositionWithoutDisturbingSelection): Added confirmCompositionWithoutDisturbingSelection(). When we confirm the composition due to selection change, we obvisouly don't want the selection to move back.
Location:
trunk/Source/WebKit2
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r84524 r84526  
     12011-04-20  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        WebKit2: Unconfirmed inline input session persists after reload
     6        https://bugs.webkit.org/show_bug.cgi?id=59054
     7        <rdar://problem/9291086>
     8
     9        Makes the inline input get properly confirmed or discarded when changing selection,
     10        navigating to another page, focusing another view in the window, or after a web process
     11        crash.
     12
     13        * Shared/EditorState.h: (WebKit::EditorState::EditorState):
     14        * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::editorState):
     15        Added a variable that Editor sets while processing input method calls. We don't want
     16        selection changes caused by -setMarkedText: discard the composition!
     17       
     18        * UIProcess/PageClient.h:
     19        * UIProcess/API/mac/PageClientImpl.h:
     20        * UIProcess/API/mac/PageClientImpl.mm:
     21        (WebKit::PageClientImpl::updateTextInputState):
     22        (WebKit::PageClientImpl::resetTextInputState):
     23        Extended updateSecureInputState() to potentially confirm the current inline input session.
     24        Added resetTextInputState, which is to be called when we get out of the current web page.
     25
     26        * UIProcess/API/mac/WKView.mm:
     27        (-[WKView resignFirstResponder]): Just call _resetTextInputState instead of dealing with
     28        input state here.
     29        (-[WKView _updateSecureInputState]): Use _isFocused to make the code simpler.
     30        (-[WKView _updateTextInputStateIncludingSecureInputState:]): Confirm the current inline
     31        input session if selection changed for any other reason but an input method changing the
     32        composition. We will want to do other work here, like dismissing a dictionary pop-up,
     33        updating a font panel etc.
     34        (-[WKView _resetTextInputState]): Added. We don't want secure text input persist after
     35        navigations, crashes an such, and we also don't want input methods to remember inline input
     36        state. Relying on selection changed notifications is fragile and insufficient.
     37
     38        * UIProcess/API/mac/WKViewInternal.h: Added internal functions to keep the build unbroken.
     39
     40        * UIProcess/WebPageProxy.cpp:
     41        (WebKit::WebPageProxy::didCommitLoadForFrame): This is the best chance we have to reset input
     42        state for a new page. This doesn't work well for cached page loads, but WK1 is quite broken
     43        in that case, too.
     44        (WebKit::WebPageProxy::editorStateChanged): Moved some logic up to the client, since the
     45        function now does much more than before.
     46
     47        * UIProcess/WebPageProxy.h:
     48        * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::confirmCompositionWithoutDisturbingSelection):
     49        * WebProcess/WebPage/WebPage.h:
     50        * WebProcess/WebPage/WebPage.messages.in:
     51        * WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::confirmCompositionWithoutDisturbingSelection):
     52        Added confirmCompositionWithoutDisturbingSelection(). When we confirm the composition due
     53        to selection change, we obvisouly don't want the selection to move back.
     54
    1552011-04-21  Sam Weinig  <sam@webkit.org>
    256
  • trunk/Source/WebKit2/Shared/EditorState.h

    r84304 r84526  
    4040        , isInPasswordField(false)
    4141        , hasComposition(false)
     42        , shouldIgnoreCompositionSelectionChange(false)
    4243    {
    4344    }
     
    4950    bool isInPasswordField;
    5051    bool hasComposition;
     52    bool shouldIgnoreCompositionSelectionChange;
    5153};
    5254
  • trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h

    r84304 r84526  
    7575    virtual bool executeSavedCommandBySelector(const String& selector);
    7676    virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag);
    77     virtual void updateSecureInputState();
     77    virtual void updateTextInputState(bool updateSecureInputState);
     78    virtual void resetTextInputState();
    7879
    7980    virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
  • trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm

    r84304 r84526  
    253253}
    254254
    255 void PageClientImpl::updateSecureInputState()
    256 {
    257     [m_wkView _updateSecureInputState];
     255void PageClientImpl::updateTextInputState(bool updateSecureInputState)
     256{
     257    [m_wkView _updateTextInputStateIncludingSecureInputState:updateSecureInputState];
     258}
     259
     260void PageClientImpl::resetTextInputState()
     261{
     262    [m_wkView _resetTextInputState];
    258263}
    259264
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r84434 r84526  
    311311    _data->_inResignFirstResponder = true;
    312312
    313     if (_data->_inSecureInputState) {
    314         DisableSecureEventInput();
    315         _data->_inSecureInputState = NO;
    316     }
     313    [self _resetTextInputState];
     314   
    317315    _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
    318316
     
    23082306- (void)_updateSecureInputState
    23092307{
    2310     if (![[self window] isKeyWindow] || ([[self window] firstResponder] != self && !_data->_inBecomeFirstResponder)) {
     2308    if (![[self window] isKeyWindow] || ![self _isFocused]) {
    23112309        if (_data->_inSecureInputState) {
    23122310            DisableSecureEventInput();
     
    23322330}
    23332331
     2332- (void)_updateTextInputStateIncludingSecureInputState:(BOOL)updateSecureInputState
     2333{
     2334    const EditorState& editorState = _data->_page->editorState();
     2335    if (updateSecureInputState) {
     2336        // This is a temporary state when editing. Flipping secure input state too quickly can expose race conditions.
     2337        if (!editorState.selectionIsNone)
     2338            [self _updateSecureInputState];
     2339    }
     2340
     2341    if (!editorState.hasComposition || editorState.shouldIgnoreCompositionSelectionChange)
     2342        return;
     2343
     2344    _data->_page->confirmCompositionWithoutDisturbingSelection();
     2345    [[super inputContext] discardMarkedText];
     2346}
     2347
     2348- (void)_resetTextInputState
     2349{
     2350    _data->_page->confirmCompositionWithoutDisturbingSelection();
     2351    [[super inputContext] discardMarkedText];
     2352
     2353    if (_data->_inSecureInputState) {
     2354        DisableSecureEventInput();
     2355        _data->_inSecureInputState = NO;
     2356    }
     2357}
     2358
    23342359- (void)_setDrawingAreaSize:(NSSize)size
    23352360{
  • trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h

    r84304 r84526  
    4141    class FindIndicator;
    4242    class LayerTreeContext;
     43    struct EditorState;
    4344}
    4445
     
    7576- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
    7677- (void)_updateSecureInputState;
     78- (void)_updateTextInputStateIncludingSecureInputState:(BOOL)updateSecureInputState;
     79- (void)_resetTextInputState;
    7780
    7881- (void)_setDrawingAreaSize:(NSSize)size;
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r84304 r84526  
    104104    virtual bool executeSavedCommandBySelector(const String& selector) = 0;
    105105    virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0;
    106     virtual void updateSecureInputState() = 0;
     106    virtual void updateTextInputState(bool updateSecureInputState) = 0;
     107    virtual void resetTextInputState() = 0;
    107108#endif
    108109#if PLATFORM(WIN)
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r84519 r84526  
    15381538        return;
    15391539
    1540 #if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
     1540    WebFrameProxy* frame = process()->webFrame(frameID);
     1541    MESSAGE_CHECK(frame);
     1542
     1543#if PLATFORM(MAC)
     1544    // FIXME (bug 59111): didCommitLoadForFrame comes too late when restoring a page from b/f cache, making us disable secure event mode in password fields.
     1545    // FIXME (bug 59121): A load going on in one frame shouldn't affect typing in sibling frames.
     1546    m_pageClient->resetTextInputState();
     1547#if !defined(BUILDING_ON_SNOW_LEOPARD)
     1548    // FIXME: Should this be moved inside resetTextInputState()?
    15411549    dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored);
    15421550    m_pageClient->dismissDictionaryLookupPanel();
    15431551#endif
    1544 
    1545     WebFrameProxy* frame = process()->webFrame(frameID);
    1546     MESSAGE_CHECK(frame);
     1552#endif
    15471553
    15481554    clearLoadDependentCallbacks();
     
    21522158
    21532159#if PLATFORM(MAC)
    2154     // This is a temporary state. Flipping secure input state too quickly can expose race conditions.
    2155     if (editorState.selectionIsNone)
    2156         return;
    2157 
    2158     if (couldChangeSecureInputState)
    2159         m_pageClient->updateSecureInputState();
     2160    m_pageClient->updateTextInputState(couldChangeSecureInputState);
    21602161#endif
    21612162}
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r84519 r84526  
    259259    void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
    260260    void confirmComposition();
     261    void confirmCompositionWithoutDisturbingSelection();
    261262    bool insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
    262263    void getMarkedRange(uint64_t& location, uint64_t& length);
  • trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm

    r84304 r84526  
    152152}
    153153
     154void WebPageProxy::confirmCompositionWithoutDisturbingSelection()
     155{
     156    process()->sendSync(Messages::WebPage::ConfirmCompositionWithoutDisturbingSelection(), Messages::WebPage::ConfirmComposition::Reply(m_editorState), m_pageID);
     157}
     158
    154159bool WebPageProxy::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
    155160{
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r84523 r84526  
    334334    result.isInPasswordField = frame->selection()->isInPasswordField();
    335335    result.hasComposition = frame->editor()->hasComposition();
     336    result.shouldIgnoreCompositionSelectionChange = frame->editor()->ignoreCompositionSelectionChange();
    336337   
    337338    return result;
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r84519 r84526  
    326326    void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState);
    327327    void confirmComposition(EditorState& newState);
     328    void confirmCompositionWithoutDisturbingSelection(EditorState& newState);
    328329    void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, EditorState& newState);
    329330    void getMarkedRange(uint64_t& location, uint64_t& length);
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r84519 r84526  
    188188    SetComposition(WTF::String text, WTF::Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) -> (WebKit::EditorState newState)
    189189    ConfirmComposition() -> (WebKit::EditorState newState)
     190    ConfirmCompositionWithoutDisturbingSelection() -> (WebKit::EditorState newState)
    190191    InsertText(WTF::String text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) -> (bool handled, WebKit::EditorState newState)
    191192    GetMarkedRange() -> (uint64_t location, uint64_t length)
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r84304 r84526  
    244244
    245245    frame->editor()->confirmComposition();
     246
     247    newState = editorState();
     248}
     249
     250void WebPage::confirmCompositionWithoutDisturbingSelection(EditorState& newState)
     251{
     252    Frame* frame = m_page->focusController()->focusedOrMainFrame();
     253
     254    frame->editor()->confirmCompositionWithoutDisturbingSelection();
    246255
    247256    newState = editorState();
Note: See TracChangeset for help on using the changeset viewer.