Changeset 80609 in webkit


Ignore:
Timestamp:
Mar 8, 2011 5:35:18 PM (13 years ago)
Author:
jeffm@apple.com
Message:

2011-03-08 Jeff Miller <jeffm@apple.com>

Reviewed by Adele Peterson.

WebKit2: Implement Windows glue for Undo/Redo
https://bugs.webkit.org/show_bug.cgi?id=55961


Expose Undo/Redo infrastructure through WKView on Windows by
adding an undo client as well as APIs to reapply and unapply
an edit command.

  • UIProcess/API/C/win/WKView.cpp: (WKViewSetViewUndoClient): Added. (WKViewReapplyEditCommand): Added. (WKViewUnapplyEditCommand): Added.
  • UIProcess/API/C/win/WKView.h: Added WKViewUndoClient, WKViewSetViewUndoClient(), and WKViewUnapplyEditCommand().
  • UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::isValidEditCommand): Added, used to validated an edit command from a WKView API.
  • UIProcess/WebPageProxy.h: Added isValidEditCommand().
  • UIProcess/win/WebUndoClient.cpp: Added, APIClient for WKViewUndoClient. (WebKit::WebUndoClient::registerEditCommand): Added. (WebKit::WebUndoClient::clearAllEditCommands): Added.
  • UIProcess/win/WebUndoClient.h: Added, APIClient for WKViewUndoClient.
  • UIProcess/win/WebView.cpp: (WebKit::WebView::initializeUndoClient): Added. (WebKit::WebView::close): Clear out undo client. (WebKit::WebView::registerEditCommand): Implemented to call through to WKViewUndoClient. (WebKit::WebView::clearAllEditCommands): Implmented to call through to WKViewUndoClient. (WebKit::WebView::reapplyEditCommand): Added. (WebKit::WebView::unapplyEditCommand): Added.
  • UIProcess/win/WebView.h: Added undo client support.
  • win/WebKit2.vcproj: Added WebUndoClient.cpp and WebUndoClient.h.
Location:
trunk/Source/WebKit2
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r80605 r80609  
     12011-03-08  Jeff Miller  <jeffm@apple.com>
     2
     3        Reviewed by Adele Peterson.
     4
     5        WebKit2: Implement Windows glue for Undo/Redo
     6        https://bugs.webkit.org/show_bug.cgi?id=55961
     7       
     8        Expose Undo/Redo infrastructure through WKView on Windows by
     9        adding an undo client as well as APIs to reapply and unapply
     10        an edit command.
     11
     12        * UIProcess/API/C/win/WKView.cpp:
     13        (WKViewSetViewUndoClient): Added.
     14        (WKViewReapplyEditCommand): Added.
     15        (WKViewUnapplyEditCommand): Added.
     16        * UIProcess/API/C/win/WKView.h: Added WKViewUndoClient, WKViewSetViewUndoClient(), and WKViewUnapplyEditCommand().
     17        * UIProcess/WebPageProxy.cpp:
     18        (WebKit::WebPageProxy::isValidEditCommand): Added, used to validated an edit command from a WKView API.
     19        * UIProcess/WebPageProxy.h: Added isValidEditCommand().
     20        * UIProcess/win/WebUndoClient.cpp: Added, APIClient for WKViewUndoClient.
     21        (WebKit::WebUndoClient::registerEditCommand): Added.
     22        (WebKit::WebUndoClient::clearAllEditCommands): Added.
     23        * UIProcess/win/WebUndoClient.h: Added, APIClient for WKViewUndoClient.
     24        * UIProcess/win/WebView.cpp:
     25        (WebKit::WebView::initializeUndoClient): Added.
     26        (WebKit::WebView::close): Clear out undo client.
     27        (WebKit::WebView::registerEditCommand): Implemented to call through to WKViewUndoClient.
     28        (WebKit::WebView::clearAllEditCommands): Implmented to call through to WKViewUndoClient.
     29        (WebKit::WebView::reapplyEditCommand): Added.
     30        (WebKit::WebView::unapplyEditCommand): Added.
     31        * UIProcess/win/WebView.h: Added undo client support.
     32        * win/WebKit2.vcproj: Added WebUndoClient.cpp and WebUndoClient.h.
     33
    1342011-03-08  Jeff Miller  <jeffm@apple.com>
    235
  • trunk/Source/WebKit2/UIProcess/API/C/win/WKView.cpp

    r80365 r80609  
    8282    return toImpl(viewRef)->getFindIndicatorCallback(context);
    8383}
     84
     85void WKViewSetViewUndoClient(WKViewRef viewRef, const WKViewUndoClient* wkClient)
     86{
     87    if (wkClient && wkClient->version)
     88        return;
     89    toImpl(viewRef)->initializeUndoClient(wkClient);
     90}
     91
     92void WKViewReapplyEditCommand(WKViewRef viewRef, WKEditCommandRef command)
     93{
     94    toImpl(viewRef)->reapplyEditCommand(toImpl(command));
     95}
     96
     97void WKViewUnapplyEditCommand(WKViewRef viewRef, WKEditCommandRef command)
     98{
     99    toImpl(viewRef)->unapplyEditCommand(toImpl(command));
     100}
  • trunk/Source/WebKit2/UIProcess/API/C/win/WKView.h

    r80365 r80609  
    3434#endif
    3535
     36// Undo Client.
     37enum {
     38    kWKViewUndo = 0,
     39    kWKViewRedo = 1
     40};
     41typedef uint32_t WKViewUndoType;
     42
     43typedef void (*WKViewRegisterEditCommandCallback)(WKViewRef, WKEditCommandRef, int32_t undoOrRedo, const void *clientInfo);
     44typedef void (*WKViewClearAllEditCommandsCallback)(WKViewRef, const void *clientInfo);
     45
     46struct WKViewUndoClient {
     47    int                                                                 version;
     48    const void *                                                        clientInfo;
     49    WKViewRegisterEditCommandCallback                                   registerEditCommand;
     50    WKViewClearAllEditCommandsCallback                                  clearAllEditCommands;
     51};
     52typedef struct WKViewUndoClient WKViewUndoClient;
     53
    3654WK_EXPORT WKTypeID WKViewGetTypeID();
    3755
     
    4159
    4260WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);
     61
     62WK_EXPORT void WKViewSetViewUndoClient(WKViewRef view, const WKViewUndoClient* client);
     63WK_EXPORT void WKViewReapplyEditCommand(WKViewRef view, WKEditCommandRef command);
     64WK_EXPORT void WKViewUnapplyEditCommand(WKViewRef view, WKEditCommandRef command);
    4365
    4466WK_EXPORT void WKViewSetParentWindow(WKViewRef view, HWND parentWindow);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r80578 r80609  
    22992299}
    23002300
     2301bool WebPageProxy::isValidEditCommand(WebEditCommandProxy* command)
     2302{
     2303    return m_editCommandSet.find(command) != m_editCommandSet.end();
     2304}
     2305
    23012306int64_t WebPageProxy::spellDocumentTag()
    23022307{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r80578 r80609  
    396396    void addEditCommand(WebEditCommandProxy*);
    397397    void removeEditCommand(WebEditCommandProxy*);
     398    bool isValidEditCommand(WebEditCommandProxy*);
    398399    void registerEditCommand(PassRefPtr<WebEditCommandProxy>, UndoOrRedo);
    399400
  • trunk/Source/WebKit2/UIProcess/win/WebView.cpp

    r80596 r80609  
    285285}
    286286
     287void WebView::initializeUndoClient(const WKViewUndoClient* client)
     288{
     289    m_undoClient.initialize(client);
     290}
     291
    287292void WebView::setParentWindow(HWND parentWindow)
    288293{
     
    643648void WebView::close()
    644649{
     650    m_undoClient.initialize(0);
    645651    ::RevokeDragDrop(m_window);
    646652    setParentWindow(0);
     
    796802}
    797803
    798 void WebView::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
    799 {
     804void WebView::registerEditCommand(PassRefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo)
     805{
     806    RefPtr<WebEditCommandProxy> command = prpCommand;
     807    m_undoClient.registerEditCommand(this, command, undoOrRedo);
    800808}
    801809
    802810void WebView::clearAllEditCommands()
    803811{
     812    m_undoClient.clearAllEditCommands(this);
     813}
     814
     815void WebView::reapplyEditCommand(WebEditCommandProxy* command)
     816{
     817    if (!m_page->isValid() || !m_page->isValidEditCommand(command))
     818        return;
     819   
     820    command->reapply();
     821}
     822
     823void WebView::unapplyEditCommand(WebEditCommandProxy* command)
     824{
     825    if (!m_page->isValid() || !m_page->isValidEditCommand(command))
     826        return;
     827   
     828    command->unapply();
    804829}
    805830
  • trunk/Source/WebKit2/UIProcess/win/WebView.h

    r80578 r80609  
    3131#include "WKView.h"
    3232#include "WebPageProxy.h"
     33#include "WebUndoClient.h"
    3334#include <ShlObj.h>
    3435#include <WebCore/COMPtr.h>
     
    6566    WKViewFindIndicatorCallback getFindIndicatorCallback(void**);
    6667    void initialize();
     68   
     69    void initializeUndoClient(const WKViewUndoClient*);
     70    void reapplyEditCommand(WebEditCommandProxy*);
     71    void unapplyEditCommand(WebEditCommandProxy*);
    6772
    6873    // IUnknown
     
    195200    unsigned m_inIMEComposition;
    196201
     202    WebUndoClient m_undoClient;
     203
    197204    WKViewFindIndicatorCallback m_findIndicatorCallback;
    198205    void* m_findIndicatorCallbackContext;
  • trunk/Source/WebKit2/win/WebKit2.vcproj

    r80602 r80609  
    31273127                                </File>
    31283128                                <File
     3129                                        RelativePath="..\UIProcess\win\WebUndoClient.cpp"
     3130                                        >
     3131                                </File>
     3132                                <File
     3133                                        RelativePath="..\UIProcess\win\WebUndoClient.h"
     3134                                        >
     3135                                </File>
     3136                                <File
    31293137                                        RelativePath="..\UIProcess\win\WebView.cpp"
    31303138                                        >
Note: See TracChangeset for help on using the changeset viewer.