2011-06-16 Chang Shu <cshu@webkit.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jun 2011 18:23:36 +0000 (18:23 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jun 2011 18:23:36 +0000 (18:23 +0000)
        Reviewed by Sam Weinig.

        [Qt] [WK2] Qt WebKit2 needs undo/redo support
        https://bugs.webkit.org/show_bug.cgi?id=62637

        Unskip passed tests.

        * platform/qt-wk2/Skipped:
2011-06-16  Chang Shu  <cshu@webkit.org>

        Reviewed by Sam Weinig.

        [Qt] [WK2] Qt WebKit2 needs undo/redo support
        https://bugs.webkit.org/show_bug.cgi?id=62637

        Implement undo/redo support for document.execCommand().

        * UIProcess/API/qt/qwkpage.cpp:
        (QWKPagePrivate::QWKPagePrivate):
        (QWKPagePrivate::~QWKPagePrivate):
        (QWKPagePrivate::registerEditCommand):
        (QWKPagePrivate::clearAllEditCommands):
        (QWKPagePrivate::canUndoRedo):
        (QWKPagePrivate::executeUndoRedo):
        * UIProcess/API/qt/qwkpage_p.h:
        * UIProcess/qt/WebUndoCommandQt.cpp: Added.
        (WebUndoCommandQt::WebUndoCommandQt):
        (WebUndoCommandQt::~WebUndoCommandQt):
        (WebUndoCommandQt::redo):
        (WebUndoCommandQt::undo):
        * UIProcess/qt/WebUndoCommandQt.h: Added.
        (WebUndoCommandQt::inUndoRedo):
        * WebKit2.pro:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@89050 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/qt-wk2/Skipped
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/qwkpage.cpp
Source/WebKit2/UIProcess/API/qt/qwkpage_p.h
Source/WebKit2/UIProcess/qt/WebUndoCommandQt.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/qt/WebUndoCommandQt.h [new file with mode: 0644]
Source/WebKit2/WebKit2.pro

index 0ba8067..23d929c 100644 (file)
@@ -1,3 +1,14 @@
+2011-06-16  Chang Shu  <cshu@webkit.org>
+
+        Reviewed by Sam Weinig.
+
+        [Qt] [WK2] Qt WebKit2 needs undo/redo support
+        https://bugs.webkit.org/show_bug.cgi?id=62637
+
+        Unskip passed tests.
+
+        * platform/qt-wk2/Skipped:
+
 2011-06-16  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Reviewed by Pavel Feldman.
index 35120de..72700ed 100644 (file)
@@ -199,9 +199,6 @@ editing/selection/triple-click-in-pre.html
 editing/selection/user-drag-element-and-user-select-none.html
 editing/selection/word-granularity.html
 editing/spelling/context-menu-suggestions.html
-editing/undo/undo-deleteWord.html
-editing/undo/undo-smart-delete-reversed-selection.html
-editing/undo/undo-smart-delete-word.html
 fast/blockflow/horizontal-bt-replaced-selection.html
 fast/blockflow/japanese-lr-selection.html
 fast/blockflow/japanese-rl-selection.html
@@ -1297,7 +1294,6 @@ editing/spelling/design-mode-spellcheck-off.html
 editing/style/remove-underline-from-stylesheet.html
 editing/style/typing-style-003.html
 editing/text-iterator/thai-cursor-movement.html
-editing/undo/replace-by-span-then-remove.html
 editing/deleting/5168598.html
 editing/deleting/delete-line-011.html
 editing/pasteboard/createMarkup-assert.xml
@@ -1749,28 +1745,6 @@ printing/page-rule-selection.html
 fast/dom/Window/window-resize-and-move-arguments.html
 fast/dom/Window/window-resize.html
 
-# WebKit2 needs undo/redo support
-editing/undo/remove-css-property-and-remove-style.html
-editing/deleting/delete-and-undo.html
-editing/execCommand/convert-style-elements-to-spans.html
-editing/inserting/redo.html
-editing/undo/4063751.html
-editing/undo/5378473.html
-editing/undo/redo-split-text-node.html
-editing/undo/redo-split-text-with-removal.html
-editing/undo/redo-style.html
-editing/undo/redo-typing-001.html
-editing/undo/undo-combined-delete-boundary.html
-editing/undo/undo-combined-delete.html
-editing/undo/undo-delete-boundary.html
-editing/undo/undo-delete.html
-editing/undo/undo-forward-delete-boundary.html
-editing/undo/undo-forward-delete.html
-editing/undo/undo-iframe-location-change.html
-editing/undo/undo-indent.html
-editing/undo/undo-misspellings.html
-editing/undo/undo-typing-001.html
-
 # WebKit2 needs to define a default charset (Settings::defaultTextEncodingName)
 fast/dom/Document/document-charset.html
 
@@ -2968,6 +2942,7 @@ tables/mozilla_expected_failures/dom/appendCells1.html
 tables/mozilla_expected_failures/dom/appendCellsRebuild1.html
 tables/mozilla_expected_failures/dom/insertTbodyExpand1.html
 tables/mozilla_expected_failures/dom/insertTbodyRebuild1.html
+editing/deleting/delete-and-undo.html
 
 # [Qt][WK2]http/tests/loading/preload-append-scan.php fails
 # https://bugs.webkit.org/show_bug.cgi?id=58253
@@ -3018,9 +2993,6 @@ fast/replaced/object-with-non-empty-classid-triggers-fallback.html
 # fail after http://trac.webkit.org/changeset/87067
 fast/forms/textfield-overflow.html
 
-# new test inroduced in r87204, but fail
-editing/undo/undo-after-setting-value.html
-
 # unskipped by r88152, but fail on Qt-WK2 platform
 editing/selection/select-across-readonly-input-1.html
 editing/selection/select-across-readonly-input-2.html
index 81e04a2..5b1deab 100644 (file)
@@ -1,3 +1,29 @@
+2011-06-16  Chang Shu  <cshu@webkit.org>
+
+        Reviewed by Sam Weinig.
+
+        [Qt] [WK2] Qt WebKit2 needs undo/redo support
+        https://bugs.webkit.org/show_bug.cgi?id=62637
+
+        Implement undo/redo support for document.execCommand().
+
+        * UIProcess/API/qt/qwkpage.cpp:
+        (QWKPagePrivate::QWKPagePrivate):
+        (QWKPagePrivate::~QWKPagePrivate):
+        (QWKPagePrivate::registerEditCommand):
+        (QWKPagePrivate::clearAllEditCommands):
+        (QWKPagePrivate::canUndoRedo):
+        (QWKPagePrivate::executeUndoRedo):
+        * UIProcess/API/qt/qwkpage_p.h:
+        * UIProcess/qt/WebUndoCommandQt.cpp: Added.
+        (WebUndoCommandQt::WebUndoCommandQt):
+        (WebUndoCommandQt::~WebUndoCommandQt):
+        (WebUndoCommandQt::redo):
+        (WebUndoCommandQt::undo):
+        * UIProcess/qt/WebUndoCommandQt.h: Added.
+        (WebUndoCommandQt::inUndoRedo):
+        * WebKit2.pro:
+
 2011-06-16  Anders Carlsson  <andersca@apple.com>
 
         Fix build.
index 978d04a..5144c31 100644 (file)
 #include "TiledDrawingAreaProxy.h"
 #include "WebContext.h"
 #include "WebContextMenuProxyQt.h"
+#include "WebEditCommandProxy.h"
 #include "WebEventFactoryQt.h"
 #include "WebPopupMenuProxyQt.h"
+#include "WebUndoCommandQt.h"
 #include "WKStringQt.h"
 #include "WKURLQt.h"
 #include "ViewportArguments.h"
@@ -51,6 +53,7 @@
 #include <QGraphicsSceneMouseEvent>
 #include <QStyle>
 #include <QTouchEvent>
+#include <QUndoStack>
 #include <QtDebug>
 #include <WebCore/Cursor.h>
 #include <WebCore/FloatRect.h>
@@ -96,6 +99,9 @@ QWKPagePrivate::QWKPagePrivate(QWKPage* qq, QWKContext* c, WKPageGroupRef pageGr
     , createNewPageFn(0)
     , backingStoreType(QGraphicsWKView::Simple)
     , isConnectedToEngine(true)
+#ifndef QT_NO_UNDOSTACK
+    , undoStack(adoptPtr(new QUndoStack(qq)))
+#endif
 {
     memset(actions, 0, sizeof(actions));
     page = context->d->context->createWebPage(this, toImpl(pageGroupRef));
@@ -206,21 +212,44 @@ void QWKPagePrivate::toolTipChanged(const String&, const String& newTooltip)
     emit q->toolTipChanged(QString(newTooltip));
 }
 
-void QWKPagePrivate::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
+void QWKPagePrivate::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
 {
+#ifndef QT_NO_UNDOSTACK
+    if (undoOrRedo == WebPageProxy::Undo) {
+        const WebUndoCommandQt* webUndoCommand = static_cast<const WebUndoCommandQt*>(undoStack->command(undoStack->index()));
+        if (webUndoCommand && webUndoCommand->inUndoRedo())
+            return;
+        undoStack->push(new WebUndoCommandQt(command));
+    }
+#endif
 }
 
 void QWKPagePrivate::clearAllEditCommands()
 {
+#ifndef QT_NO_UNDOSTACK
+    undoStack->clear();
+#endif
 }
 
-bool QWKPagePrivate::canUndoRedo(WebPageProxy::UndoOrRedo)
+bool QWKPagePrivate::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
 {
+#ifdef QT_NO_UNDOSTACK
     return false;
+#else
+    if (undoOrRedo == WebPageProxy::Undo)
+        return undoStack->canUndo();
+    return undoStack->canRedo();
+#endif
 }
 
-void QWKPagePrivate::executeUndoRedo(WebPageProxy::UndoOrRedo)
+void QWKPagePrivate::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
 {
+#ifndef QT_NO_UNDOSTACK
+    if (undoOrRedo == WebPageProxy::Undo)
+        undoStack->undo();
+    else
+        undoStack->redo();
+#endif
 }
 
 FloatRect QWKPagePrivate::convertToDeviceSpace(const FloatRect& rect)
index a48b278..d249df0 100644 (file)
@@ -34,6 +34,7 @@
 #include <QKeyEvent>
 
 class QGraphicsWKView;
+class QUndoStack;
 class QWKPreferences;
 
 using namespace WebKit;
@@ -138,6 +139,10 @@ public:
     QGraphicsWKView::BackingStoreType backingStoreType;
 
     bool isConnectedToEngine;
+
+#ifndef QT_NO_UNDOSTACK
+    OwnPtr<QUndoStack> undoStack;
+#endif
 };
 
 class QtViewportAttributesPrivate : public QSharedData {
diff --git a/Source/WebKit2/UIProcess/qt/WebUndoCommandQt.cpp b/Source/WebKit2/UIProcess/qt/WebUndoCommandQt.cpp
new file mode 100644 (file)
index 0000000..2a3d951
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+    Copyright (C) 2007 Staikos Computing Services Inc.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "WebUndoCommandQt.h"
+
+using namespace WebKit;
+
+#ifndef QT_NO_UNDOCOMMAND
+WebUndoCommandQt::WebUndoCommandQt(PassRefPtr<WebEditCommandProxy> command, QUndoCommand* parent)
+    : QUndoCommand(parent)
+    , m_command(command)
+    , m_first(true)
+    , m_inUndoRedo(false)
+{
+}
+#else
+WebUndoCommandQt::WebUndoCommandQt(PassRefPtr<WebEditCommandProxy> command)
+    : m_command(command)
+    , m_first(true)
+    , m_inUndoRedo(false)
+{
+}
+#endif
+
+WebUndoCommandQt::~WebUndoCommandQt()
+{
+}
+
+void WebUndoCommandQt::redo()
+{
+    m_inUndoRedo = true;
+
+    // Ignore the first redo called from QUndoStack::push().
+    if (m_first) {
+        m_first = false;
+        m_inUndoRedo = false;
+        return;
+    }
+    if (m_command)
+        m_command->reapply();
+
+    m_inUndoRedo = false;
+}
+
+void WebUndoCommandQt::undo()
+{
+    m_inUndoRedo = true;
+
+    if (m_command)
+        m_command->unapply();
+
+    m_inUndoRedo = false;
+}
diff --git a/Source/WebKit2/UIProcess/qt/WebUndoCommandQt.h b/Source/WebKit2/UIProcess/qt/WebUndoCommandQt.h
new file mode 100644 (file)
index 0000000..1b29bb5
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+    Copyright (C) 2007 Staikos Computing Services Inc.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef WebUndoCommandQt_h
+#define WebUndoCommandQt_h
+
+#include "WebEditCommandProxy.h"
+#include <QUndoCommand>
+#include <qglobal.h>
+#include <wtf/RefPtr.h>
+
+class WebUndoCommandQt
+#ifndef QT_NO_UNDOCOMMAND
+    : public QUndoCommand
+#endif
+{
+public:
+#ifndef QT_NO_UNDOCOMMAND
+    WebUndoCommandQt(PassRefPtr<WebKit::WebEditCommandProxy>, QUndoCommand* parent = 0);
+#else
+    WebUndoCommandQt(PassRefPtr<WebKit::WebEditCommandProxy>);
+#endif
+    ~WebUndoCommandQt();
+
+    void redo();
+    void undo();
+
+    bool inUndoRedo() const { return m_inUndoRedo; };
+
+private:
+    RefPtr<WebKit::WebEditCommandProxy> m_command;
+    bool m_first;
+    bool m_inUndoRedo;
+};
+
+#endif // WebUndoCommandQt_h
index aebd781..eeb9f28 100644 (file)
@@ -232,6 +232,7 @@ HEADERS += \
     UIProcess/WebResourceCacheManagerProxy.h \
     UIProcess/WebResourceLoadClient.h \
     UIProcess/WebUIClient.h \
+    UIProcess/qt/WebUndoCommandQt.h \
     UIProcess/qt/WebContextMenuProxyQt.h \
     UIProcess/qt/WebPopupMenuProxyQt.h \
     WebProcess/ApplicationCache/WebApplicationCacheManager.h \
@@ -391,6 +392,7 @@ SOURCES += \
     UIProcess/Downloads/DownloadProxy.cpp \
     UIProcess/DrawingAreaProxy.cpp \
     UIProcess/DrawingAreaProxyImpl.cpp \
+    UIProcess/qt/WebUndoCommandQt.cpp \
     UIProcess/FindIndicator.cpp \
     UIProcess/GeolocationPermissionRequestManagerProxy.cpp \
     UIProcess/GeolocationPermissionRequestProxy.cpp \