Changeset 75098 in webkit


Ignore:
Timestamp:
Jan 5, 2011 1:22:04 PM (13 years ago)
Author:
andersca@apple.com
Message:

2011-01-05 Anders Carlsson <andersca@apple.com>

Reviewed by Adele Peterson.

Implement word transformation
https://bugs.webkit.org/show_bug.cgi?id=51943

Export Editor functions needed by WebKit2.

  • WebCore.exp.in:

2011-01-05 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.

Handle smart insert/delete
https://bugs.webkit.org/show_bug.cgi?id=51946

  • Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode): (WebKit::WebPageCreationParameters::decode):
  • Shared/WebPageCreationParameters.h: Add isSmartInsertDelete enabled.
  • UIProcess/API/mac/WKView.mm: (-[WKView validateUserInterfaceItem:]): Handle toggleSmartInsertDelete:.

(-[WKView toggleSmartInsertDelete:]):
Toggle the smart insert/delete state.

  • UIProcess/TextChecker.h: Add isSmartInsertDeleteEnabled and setSmartInsertDeleteEnabled.
  • UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::WebPageProxy): Initialize m_isSmartInsertDeleteEnabled.

(WebKit::WebPageProxy::contextMenuItemSelected):
Handle ContextMenuItemTagSmartCopyPaste.

(WebKit::WebPageProxy::setSmartInsertDeleteEnabled):
Update the state and send a SetSmartInsertDeleteEnabled message.

(WebKit::WebPageProxy::creationParameters):
Initialize isSmartInsertDeleteEnabled.

  • UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::isSmartInsertDeleteEnabled): Return m_isSmartInsertDeleteEnabled.
  • UIProcess/mac/TextCheckerMac.mm: (WebKit::TextChecker::isSmartInsertDeleteEnabled): (WebKit::TextChecker::setSmartInsertDeleteEnabled): Store and fetch the smart insert delete state.
  • WebProcess/WebCoreSupport/WebEditorClient.cpp: (WebKit::WebEditorClient::smartInsertDeleteEnabled): Call WebPage::isSmartInsertDeleteEnabled.
  • WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm: (WebKit::WebEditorClient::toggleSmartInsertDelete): Assert that this is never called.
  • WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::WebPage): Initialize m_isSmartInsertDeleteEnabled
  • WebProcess/WebPage/WebPage.h: (WebKit::WebPage::isSmartInsertDeleteEnabled): (WebKit::WebPage::setSmartInsertDeleteEnabled): Add getter and setter.
  • WebProcess/WebPage/WebPage.messages.in: Add SetSmartInsertDeleteEnabled message.
Location:
trunk/WebKit2
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r75094 r75098  
     12011-01-05  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Handle smart insert/delete
     6        https://bugs.webkit.org/show_bug.cgi?id=51946
     7
     8        * Shared/WebPageCreationParameters.cpp:
     9        (WebKit::WebPageCreationParameters::encode):
     10        (WebKit::WebPageCreationParameters::decode):
     11        * Shared/WebPageCreationParameters.h:
     12        Add isSmartInsertDelete enabled.
     13
     14        * UIProcess/API/mac/WKView.mm:
     15        (-[WKView validateUserInterfaceItem:]):
     16        Handle toggleSmartInsertDelete:.
     17
     18        (-[WKView toggleSmartInsertDelete:]):
     19        Toggle the smart insert/delete state.
     20
     21        * UIProcess/TextChecker.h:
     22        Add isSmartInsertDeleteEnabled and setSmartInsertDeleteEnabled.
     23
     24        * UIProcess/WebPageProxy.cpp:
     25        (WebKit::WebPageProxy::WebPageProxy):
     26        Initialize m_isSmartInsertDeleteEnabled.
     27
     28        (WebKit::WebPageProxy::contextMenuItemSelected):
     29        Handle ContextMenuItemTagSmartCopyPaste.
     30
     31        (WebKit::WebPageProxy::setSmartInsertDeleteEnabled):
     32        Update the state and send a SetSmartInsertDeleteEnabled message.
     33
     34        (WebKit::WebPageProxy::creationParameters):
     35        Initialize isSmartInsertDeleteEnabled.
     36
     37        * UIProcess/WebPageProxy.h:
     38        (WebKit::WebPageProxy::isSmartInsertDeleteEnabled):
     39        Return m_isSmartInsertDeleteEnabled.
     40
     41        * UIProcess/mac/TextCheckerMac.mm:
     42        (WebKit::TextChecker::isSmartInsertDeleteEnabled):
     43        (WebKit::TextChecker::setSmartInsertDeleteEnabled):
     44        Store and fetch the smart insert delete state.
     45
     46        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
     47        (WebKit::WebEditorClient::smartInsertDeleteEnabled):
     48        Call WebPage::isSmartInsertDeleteEnabled.
     49
     50        * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
     51        (WebKit::WebEditorClient::toggleSmartInsertDelete):
     52        Assert that this is never called.
     53
     54        * WebProcess/WebPage/WebPage.cpp:
     55        (WebKit::WebPage::WebPage):
     56        Initialize m_isSmartInsertDeleteEnabled
     57
     58        * WebProcess/WebPage/WebPage.h:
     59        (WebKit::WebPage::isSmartInsertDeleteEnabled):
     60        (WebKit::WebPage::setSmartInsertDeleteEnabled):
     61        Add getter and setter.
     62
     63        * WebProcess/WebPage/WebPage.messages.in:
     64        Add SetSmartInsertDeleteEnabled message.
     65
    1662011-01-05  Anders Carlsson  <andersca@apple.com>
    267
  • trunk/WebKit2/Shared/WebPageCreationParameters.cpp

    r74000 r75098  
    4040    encoder->encode(userAgent);
    4141
     42#if PLATFORM(MAC)
     43    encoder->encode(isSmartInsertDeleteEnabled);
     44#endif
     45
    4246#if PLATFORM(WIN)
    4347    encoder->encode(reinterpret_cast<uint64_t>(nativeWindow));
     
    6165    if (!decoder->decode(parameters.userAgent))
    6266        return false;
     67#if PLATFORM(MAC)
     68    if (!decoder->decode(parameters.isSmartInsertDeleteEnabled))
     69        return false;
     70#endif
    6371
    6472#if PLATFORM(WIN)
  • trunk/WebKit2/Shared/WebPageCreationParameters.h

    r74000 r75098  
    5454    String userAgent;
    5555
     56#if PLATFORM(MAC)
     57    bool isSmartInsertDeleteEnabled;
     58#endif
    5659#if PLATFORM(WIN)
    5760    HWND nativeWindow;
  • trunk/WebKit2/UIProcess/API/mac/WKView.mm

    r75093 r75098  
    388388    }
    389389
     390    if (action == @selector(toggleSmartInsertDelete:)) {
     391        bool checked = _data->_page->isSmartInsertDeleteEnabled();
     392        [menuItem(item) setState:checked ? NSOnState : NSOffState];
     393        return _data->_page->selectionState().isContentEditable;
     394    }
     395
    390396    if (action == @selector(toggleAutomaticQuoteSubstitution:)) {
    391397        bool checked = TextChecker::state().isAutomaticQuoteSubstitutionEnabled;
     
    535541    }
    536542    [substitutionsPanel orderFront:sender];
     543}
     544
     545- (IBAction)toggleSmartInsertDelete:(id)sender
     546{
     547    _data->_page->setSmartInsertDeleteEnabled(!_data->_page->isSmartInsertDeleteEnabled());
    537548}
    538549
  • trunk/WebKit2/UIProcess/TextChecker.h

    r75086 r75098  
    4747    static void setAutomaticLinkDetectionEnabled(bool);
    4848    static void setAutomaticTextReplacementEnabled(bool);
     49
     50    static bool isSmartInsertDeleteEnabled();
     51    static void setSmartInsertDeleteEnabled(bool);
    4952#endif
    5053
  • trunk/WebKit2/UIProcess/WebPageProxy.cpp

    r75093 r75098  
    114114    , m_processingMouseMoveEvent(false)
    115115    , m_pageID(pageID)
     116#if PLATFORM(MAC)
     117    , m_isSmartInsertDeleteEnabled(TextChecker::isSmartInsertDeleteEnabled())
     118#endif
    116119    , m_spellDocumentTag(0)
    117120    , m_hasSpellDocumentTag(false)
     
    17091712
    17101713#if PLATFORM(MAC)
     1714    if (item.action() == ContextMenuItemTagSmartCopyPaste) {
     1715        setSmartInsertDeleteEnabled(!isSmartInsertDeleteEnabled());
     1716        return;
     1717    }
    17111718    if (item.action() == ContextMenuItemTagSmartQuotes) {
    17121719        TextChecker::setAutomaticQuoteSubstitutionEnabled(!TextChecker::state().isAutomaticQuoteSubstitutionEnabled);
     
    17971804{
    17981805    process()->send(Messages::WebPage::CapitalizeWord(), m_pageID);
     1806}
     1807
     1808void WebPageProxy::setSmartInsertDeleteEnabled(bool isSmartInsertDeleteEnabled)
     1809{
     1810    if (m_isSmartInsertDeleteEnabled == isSmartInsertDeleteEnabled)
     1811        return;
     1812
     1813    TextChecker::setSmartInsertDeleteEnabled(isSmartInsertDeleteEnabled);
     1814    m_isSmartInsertDeleteEnabled = isSmartInsertDeleteEnabled;
     1815    process()->send(Messages::WebPage::SetSmartInsertDeleteEnabled(isSmartInsertDeleteEnabled), m_pageID);
    17991816}
    18001817#endif
     
    20792096    parameters.userAgent = userAgent();
    20802097
     2098#if PLATFORM(MAC)
     2099    parameters.isSmartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled;
     2100#endif
     2101
    20812102#if PLATFORM(WIN)
    20822103    parameters.nativeWindow = m_pageClient->nativeWindow();
  • trunk/WebKit2/UIProcess/WebPageProxy.h

    r75093 r75098  
    308308    void lowercaseWord();
    309309    void capitalizeWord();
     310
     311    bool isSmartInsertDeleteEnabled() const { return m_isSmartInsertDeleteEnabled; }
     312    void setSmartInsertDeleteEnabled(bool);
    310313#endif
    311314
     
    550553    uint64_t m_pageID;
    551554
     555#if PLATFORM(MAC)
     556    bool m_isSmartInsertDeleteEnabled;
     557#endif
     558
    552559    int64_t m_spellDocumentTag;
    553560    bool m_hasSpellDocumentTag;
  • trunk/WebKit2/UIProcess/mac/TextCheckerMac.mm

    r75086 r75098  
    3636static const NSString * const WebContinuousSpellCheckingEnabled = @"WebContinuousSpellCheckingEnabled";
    3737static const NSString * const WebGrammarCheckingEnabled = @"WebGrammarCheckingEnabled";
     38static const NSString * const WebSmartInsertDeleteEnabled = @"WebSmartInsertDeleteEnabled";
    3839static const NSString * const WebAutomaticQuoteSubstitutionEnabled = @"WebAutomaticQuoteSubstitutionEnabled";
    3940static const NSString * const WebAutomaticDashSubstitutionEnabled = @"WebAutomaticDashSubstitutionEnabled";
     
    167168
    168169    [[NSSpellChecker sharedSpellChecker] updatePanels];
     170}
     171
     172static bool smartInsertDeleteEnabled;
     173   
     174bool TextChecker::isSmartInsertDeleteEnabled()
     175{
     176    static bool readSmartInsertDeleteEnabledDefault;
     177
     178    if (!readSmartInsertDeleteEnabledDefault) {
     179        smartInsertDeleteEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebSmartInsertDeleteEnabled];
     180
     181        readSmartInsertDeleteEnabledDefault = true;
     182    }
     183
     184    return smartInsertDeleteEnabled;
     185}
     186
     187void TextChecker::setSmartInsertDeleteEnabled(bool flag)
     188{
     189    if (flag == isSmartInsertDeleteEnabled())
     190        return;
     191
     192    smartInsertDeleteEnabled = flag;
     193
     194    [[NSUserDefaults standardUserDefaults] setBool:flag forKey:WebSmartInsertDeleteEnabled];
    169195}
    170196
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp

    r75086 r75098  
    7171bool WebEditorClient::smartInsertDeleteEnabled()
    7272{
    73     notImplemented();
     73    // FIXME: Why isn't this Mac specific like toggleSmartInsertDeleteEnabled?
     74#if PLATFORM(MAC)
     75    return m_page->isSmartInsertDeleteEnabled();
     76#else
    7477    return true;
     78#endif
    7579}
    7680 
  • trunk/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm

    r75093 r75098  
    171171void WebEditorClient::toggleSmartInsertDelete()
    172172{
    173     notImplemented();
     173    // This is handled in the UI process.
     174    ASSERT_NOT_REACHED();
    174175}
    175176
     
    181182void WebEditorClient::toggleAutomaticQuoteSubstitution()
    182183{
    183     // This should be handled in the UI process.
     184    // This is handled in the UI process.
    184185    ASSERT_NOT_REACHED();
    185186}
     
    192193void WebEditorClient::toggleAutomaticLinkDetection()
    193194{
    194     // This should be handled in the UI process.
     195    // This is handled in the UI process.
    195196    ASSERT_NOT_REACHED();
    196197}
     
    203204void WebEditorClient::toggleAutomaticDashSubstitution()
    204205{
    205     // This should be handled in the UI process.
     206    // This is handled in the UI process.
    206207    ASSERT_NOT_REACHED();
    207208}
     
    214215void WebEditorClient::toggleAutomaticTextReplacement()
    215216{
    216     // This should be handled in the UI process.
     217    // This is handled in the UI process.
    217218    ASSERT_NOT_REACHED();
    218219}
  • trunk/WebKit2/WebProcess/WebPage/WebPage.cpp

    r75094 r75098  
    131131#if PLATFORM(MAC)
    132132    , m_windowIsVisible(false)
     133    , m_isSmartInsertDeleteEnabled(parameters.isSmartInsertDeleteEnabled)
    133134#elif PLATFORM(WIN)
    134135    , m_nativeWindow(parameters.nativeWindow)
  • trunk/WebKit2/WebProcess/WebPage/WebPage.h

    r75093 r75098  
    287287    void speak(const String&);
    288288    void stopSpeaking();
     289
     290    bool isSmartInsertDeleteEnabled() const { return m_isSmartInsertDeleteEnabled; }
    289291#endif
    290292
     
    385387    void lowercaseWord();
    386388    void capitalizeWord();
     389
     390    void setSmartInsertDeleteEnabled(bool isSmartInsertDeleteEnabled) { m_isSmartInsertDeleteEnabled = isSmartInsertDeleteEnabled; }
    387391#endif
    388392
     
    413417    // Whether the containing window is visible or not.
    414418    bool m_windowIsVisible;
     419
     420    // Whether smart insert/delete is enabled or not.
     421    bool m_isSmartInsertDeleteEnabled;
    415422
    416423    // The frame of the containing window in screen coordinates.
  • trunk/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r75093 r75098  
    110110    LowercaseWord();
    111111    CapitalizeWord();
     112
     113    SetSmartInsertDeleteEnabled(bool isSmartInsertDeleteEnabled);
    112114#endif
    113115
Note: See TracChangeset for help on using the changeset viewer.