Add support for Undo/Redo
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Sep 2010 19:18:03 +0000 (19:18 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Sep 2010 19:18:03 +0000 (19:18 +0000)
commitc741258daf0aceba09af4291294ee2eccb597910
treeb1dbc3c1709b65ee1c01f68e7d44c96fc0d3497d
parent837b2d0b43952c29f4ffc8e5d073b35ff080a8a5
Add support for Undo/Redo
<rdar://problem/7660519>
https://bugs.webkit.org/show_bug.cgi?id=42781

Reviewed by Darin Adler.

Adds platform independent parts of Undo/Redo support and the mac
platform support.

To work around the common assumption made by platforms, that a redo
item will be added synchronously while an undo is in progress, we
ignore the calls from WebCore to add redo items, and instead add add
them after telling WebCore to unapply the EditCommand. We similarly
need to ignore undos, that take place during a redo, and force the
addition ourselves.

* Shared/CoreIPCSupport/WebPageMessageKinds.h:
* Shared/CoreIPCSupport/WebPageProxyMessageKinds.h:
Add new messages.

* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(-[WebEditCommandObjC initWithWebEditCommandProxy:WebKit::]):
(-[WebEditCommandObjC WebKit::]):
(-[WebEditorUndoTargetObjC undoEditing:]):
(-[WebEditorUndoTargetObjC redoEditing:]):
(WebKit::PageClientImpl::PageClientImpl):
(WebKit::nameForEditAction):
(WebKit::PageClientImpl::registerEditCommand):
(WebKit::PageClientImpl::clearAllEditCommands):
* UIProcess/API/qt/qwkpage.cpp:
(QWKPagePrivate::registerEditCommand):
(QWKPagePrivate::clearAllEditCommands):
* UIProcess/API/qt/qwkpage_p.h:
* UIProcess/PageClient.h:
* UIProcess/win/WebView.cpp:
(WebKit::WebView::registerEditCommand):
(WebKit::WebView::clearAllEditCommands):
* UIProcess/win/WebView.h:
Add platform specific hooks for undo/redo.

* UIProcess/WebEditCommandProxy.cpp: Added.
(WebKit::WebEditCommandProxy::WebEditCommandProxy):
(WebKit::WebEditCommandProxy::~WebEditCommandProxy):
(WebKit::WebEditCommandProxy::unapply):
(WebKit::WebEditCommandProxy::reapply):
* UIProcess/WebEditCommandProxy.h: Added.
(WebKit::WebEditCommandProxy::create):
(WebKit::WebEditCommandProxy::commandID):
(WebKit::WebEditCommandProxy::editAction):
(WebKit::WebEditCommandProxy::invalidate):
A proxy for the WebEditCommands in the WebProcess. These are owned
by the platform back/forward list, with a weak reference back to the
WebPageProxy (which holds a weakset of live WebEditCommandProxys).

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close):
(WebKit::WebPageProxy::didReceiveMessage):
(WebKit::WebPageProxy::registerEditCommandForUndo):
(WebKit::WebPageProxy::clearAllEditCommands):
(WebKit::WebPageProxy::registerEditCommandForRedo):
(WebKit::WebPageProxy::addEditCommand):
(WebKit::WebPageProxy::removeEditCommand):
(WebKit::WebPageProxy::processDidExit):
* UIProcess/WebPageProxy.h:
Forward messages.

* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::registerCommandForUndo):
(WebKit::WebEditorClient::registerCommandForRedo):
(WebKit::WebEditorClient::clearUndoRedoOperations):
Send undo/redo registration and clearing to the UIProcess.

* WebProcess/WebPage/WebEditCommand.cpp: Added.
(WebKit::generateCommandID):
(WebKit::WebEditCommand::WebEditCommand):
* WebProcess/WebPage/WebEditCommand.h: Added.
(WebKit::WebEditCommand::create):
(WebKit::WebEditCommand::command):
(WebKit::WebEditCommand::commandID):
Wrapper for WebCore::EditCommand, with an added unique ID.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::webEditCommand):
(WebKit::WebPage::addWebEditCommand):
(WebKit::WebPage::removeWebEditCommand):
(WebKit::WebPage::unapplyEditCommand):
(WebKit::WebPage::reapplyEditCommand):
(WebKit::WebPage::didRemoveEditCommand):
(WebKit::WebPage::didReceiveMessage):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::isInRedo):
Forward messages.

* WebKit2.pro:
* WebKit2.xcodeproj/project.pbxproj:
* win/WebKit2.vcproj:
Add new files.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66897 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
WebKit2/ChangeLog
WebKit2/Shared/CoreIPCSupport/WebPageMessageKinds.h
WebKit2/Shared/CoreIPCSupport/WebPageProxyMessageKinds.h
WebKit2/UIProcess/API/mac/PageClientImpl.h
WebKit2/UIProcess/API/mac/PageClientImpl.mm
WebKit2/UIProcess/API/qt/qwkpage.cpp
WebKit2/UIProcess/API/qt/qwkpage_p.h
WebKit2/UIProcess/PageClient.h
WebKit2/UIProcess/WebEditCommandProxy.cpp [new file with mode: 0644]
WebKit2/UIProcess/WebEditCommandProxy.h [new file with mode: 0644]
WebKit2/UIProcess/WebPageProxy.cpp
WebKit2/UIProcess/WebPageProxy.h
WebKit2/UIProcess/win/WebView.cpp
WebKit2/UIProcess/win/WebView.h
WebKit2/WebKit2.pro
WebKit2/WebKit2.xcodeproj/project.pbxproj
WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
WebKit2/WebProcess/WebPage/WebEditCommand.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebPage/WebEditCommand.h [new file with mode: 0644]
WebKit2/WebProcess/WebPage/WebPage.cpp
WebKit2/WebProcess/WebPage/WebPage.h
WebKit2/win/WebKit2.vcproj