Diff
Modified: trunk/Source/WebKit2/ChangeLog (102665 => 102666)
--- trunk/Source/WebKit2/ChangeLog 2011-12-13 10:14:46 UTC (rev 102665)
+++ trunk/Source/WebKit2/ChangeLog 2011-12-13 10:24:44 UTC (rev 102666)
@@ -1,3 +1,40 @@
+2011-12-12 Caio Marcelo de Oliveira Filho <caio.olive...@openbossa.org>
+
+ [Qt][WK2] Move undo & edit command PageClient callbacks into QtWebUndoController
+ https://bugs.webkit.org/show_bug.cgi?id=74364
+
+ Reviewed by Simon Hausmann.
+
+ The four callbacks in PageClient related to Undo depend only on the QUndoStack. So we
+ move their handling to a QtWebUndoController (owned by QQuickWebViewPrivate). This also
+ make QtWebUndoCommand an implementation detail.
+
+ * Target.pri:
+ * UIProcess/API/qt/qquickwebview.cpp:
+ (QQuickWebViewPrivate::QQuickWebViewPrivate):
+ * UIProcess/API/qt/qquickwebview_p_p.h:
+ * UIProcess/qt/QtPageClient.cpp:
+ (QtPageClient::registerEditCommand):
+ (QtPageClient::clearAllEditCommands):
+ (QtPageClient::canUndoRedo):
+ (QtPageClient::executeUndoRedo):
+ * UIProcess/qt/QtPageClient.h:
+ (QtPageClient::initialize):
+ * UIProcess/qt/QtWebPageProxy.cpp:
+ * UIProcess/qt/QtWebPageProxy.h:
+ * UIProcess/qt/QtWebUndoController.cpp: Renamed from Source/WebKit2/UIProcess/qt/QtWebUndoCommand.cpp.
+ (QtWebUndoCommand::inUndoRedo):
+ (QtWebUndoCommand::QtWebUndoCommand):
+ (QtWebUndoCommand::~QtWebUndoCommand):
+ (QtWebUndoCommand::redo):
+ (QtWebUndoCommand::undo):
+ (QtWebUndoController::QtWebUndoController):
+ (QtWebUndoController::registerEditCommand):
+ (QtWebUndoController::clearAllEditCommands):
+ (QtWebUndoController::canUndoRedo):
+ (QtWebUndoController::executeUndoRedo):
+ * UIProcess/qt/QtWebUndoController.h: Renamed from Source/WebKit2/UIProcess/qt/QtWebUndoCommand.h.
+
2011-12-12 Andreas Kling <kl...@webkit.org>
Resizing Cappuccino is very laggy on WebKit since Safari 5.1
Modified: trunk/Source/WebKit2/Target.pri (102665 => 102666)
--- trunk/Source/WebKit2/Target.pri 2011-12-13 10:14:46 UTC (rev 102665)
+++ trunk/Source/WebKit2/Target.pri 2011-12-13 10:24:44 UTC (rev 102666)
@@ -269,7 +269,7 @@
UIProcess/qt/QtSGUpdateQueue.h \
UIProcess/qt/QtSGTileNode.h \
UIProcess/qt/QtViewportInteractionEngine.h \
- UIProcess/qt/QtWebUndoCommand.h \
+ UIProcess/qt/QtWebUndoController.h \
UIProcess/qt/WebContextMenuProxyQt.h \
UIProcess/qt/WebGeolocationProviderQt.h \
UIProcess/qt/WebPopupMenuProxyQt.h \
@@ -511,7 +511,7 @@
UIProcess/Downloads/DownloadProxy.cpp \
UIProcess/DrawingAreaProxy.cpp \
UIProcess/DrawingAreaProxyImpl.cpp \
- UIProcess/qt/QtWebUndoCommand.cpp \
+ UIProcess/qt/QtWebUndoController.cpp \
UIProcess/FindIndicator.cpp \
UIProcess/GeolocationPermissionRequestManagerProxy.cpp \
UIProcess/GeolocationPermissionRequestProxy.cpp \
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (102665 => 102666)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2011-12-13 10:14:46 UTC (rev 102665)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2011-12-13 10:24:44 UTC (rev 102666)
@@ -69,8 +69,7 @@
setUseTraditionalDesktopBehaviour(false);
QWebPreferencesPrivate::get(pageProxy->preferences())->setAttribute(QWebPreferencesPrivate::AcceleratedCompositingEnabled, true);
- pageClient->setEventHandler(eventHandler.data());
- pageClient->setPageProxy(pageProxy.data());
+ pageClient->initialize(pageProxy.data(), eventHandler.data(), &undoController);
// Creates a page with the page creation parameters.
pageProxy->init(eventHandler.data());
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h (102665 => 102666)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h 2011-12-13 10:14:46 UTC (rev 102665)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h 2011-12-13 10:24:44 UTC (rev 102666)
@@ -28,6 +28,7 @@
#include "QtWebPagePolicyClient.h"
#include "QtWebPageProxy.h"
#include "QtWebPageUIClient.h"
+#include "QtWebUndoController.h"
#include "qquickwebview_p.h"
#include "qquickwebpage_p.h"
@@ -116,6 +117,8 @@
QPoint position;
};
+ QtWebUndoController undoController;
+
QScopedPointer<QtPageClient> pageClient;
QScopedPointer<QtWebPageEventHandler> eventHandler;
Modified: trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp (102665 => 102666)
--- trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp 2011-12-13 10:14:46 UTC (rev 102665)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp 2011-12-13 10:24:44 UTC (rev 102666)
@@ -23,7 +23,7 @@
#include "QtWebPageEventHandler.h"
#include "QtWebPageProxy.h"
-#include "QtWebUndoCommand.h"
+#include "QtWebUndoController.h"
#include "WebContextMenuProxyQt.h"
#include "WebEditCommandProxy.h"
#include <QGuiApplication>
@@ -108,22 +108,22 @@
void QtPageClient::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
{
- m_qtWebPageProxy->registerEditCommand(command, undoOrRedo);
+ m_undoController->registerEditCommand(command, undoOrRedo);
}
void QtPageClient::clearAllEditCommands()
{
- m_qtWebPageProxy->clearAllEditCommands();
+ m_undoController->clearAllEditCommands();
}
bool QtPageClient::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
{
- return m_qtWebPageProxy->canUndoRedo(undoOrRedo);
+ return m_undoController->canUndoRedo(undoOrRedo);
}
void QtPageClient::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
{
- m_qtWebPageProxy->executeUndoRedo(undoOrRedo);
+ m_undoController->executeUndoRedo(undoOrRedo);
}
FloatRect QtPageClient::convertToDeviceSpace(const FloatRect& rect)
Modified: trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h (102665 => 102666)
--- trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h 2011-12-13 10:14:46 UTC (rev 102665)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h 2011-12-13 10:24:44 UTC (rev 102666)
@@ -28,6 +28,7 @@
#include "ViewportArguments.h"
class QtWebPageEventHandler;
+class QtWebUndoController;
using namespace WebKit;
@@ -59,10 +60,13 @@
virtual void setCursor(const WebCore::Cursor&);
virtual void setCursorHiddenUntilMouseMoves(bool);
virtual void toolTipChanged(const String&, const String&);
+
+ // QtWebUndoController
virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
virtual void clearAllEditCommands();
virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
+
virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
@@ -88,12 +92,17 @@
virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
#endif
- void setEventHandler(QtWebPageEventHandler* eventHandler) { m_eventHandler = eventHandler; }
- void setPageProxy(QtWebPageProxy* pageProxy) { m_qtWebPageProxy = pageProxy; }
+ void initialize(QtWebPageProxy* pageProxy, QtWebPageEventHandler* eventHandler, QtWebUndoController* undoController)
+ {
+ m_eventHandler = eventHandler;
+ m_qtWebPageProxy = pageProxy;
+ m_undoController = undoController;
+ }
private:
QtWebPageProxy* m_qtWebPageProxy;
QtWebPageEventHandler* m_eventHandler;
+ QtWebUndoController* m_undoController;
};
#endif /* QtPageClient_h */
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp (102665 => 102666)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp 2011-12-13 10:14:46 UTC (rev 102665)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp 2011-12-13 10:24:44 UTC (rev 102666)
@@ -39,7 +39,6 @@
#include "QtDownloadManager.h"
#include "QtPageClient.h"
#include "QtWebPageEventHandler.h"
-#include "QtWebUndoCommand.h"
#include "WebBackForwardList.h"
#include "WebContextMenuProxyQt.h"
#include "WebPopupMenuProxyQt.h"
@@ -142,36 +141,6 @@
m_qmlWebView->d_func()->didChangeViewportProperties(args);
}
-void QtWebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
-{
- if (undoOrRedo == WebPageProxy::Undo) {
- const QtWebUndoCommand* webUndoCommand = static_cast<const QtWebUndoCommand*>(m_undoStack->command(m_undoStack->index()));
- if (webUndoCommand && webUndoCommand->inUndoRedo())
- return;
- m_undoStack->push(new QtWebUndoCommand(command));
- }
-}
-
-void QtWebPageProxy::clearAllEditCommands()
-{
- m_undoStack->clear();
-}
-
-bool QtWebPageProxy::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
-{
- if (undoOrRedo == WebPageProxy::Undo)
- return m_undoStack->canUndo();
- return m_undoStack->canRedo();
-}
-
-void QtWebPageProxy::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
-{
- if (undoOrRedo == WebPageProxy::Undo)
- m_undoStack->undo();
- else
- m_undoStack->redo();
-}
-
PassRefPtr<WebPopupMenuProxy> QtWebPageProxy::createPopupMenuProxy(WebPageProxy*)
{
return WebPopupMenuProxyQt::create(m_webPageProxy.get(), m_qmlWebView);
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h (102665 => 102666)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h 2011-12-13 10:14:46 UTC (rev 102665)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h 2011-12-13 10:24:44 UTC (rev 102666)
@@ -69,11 +69,6 @@
void didChangeContentsSize(const WebCore::IntSize&);
void didChangeViewportProperties(const WebCore::ViewportArguments&);
- void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
- void clearAllEditCommands();
- bool canUndoRedo(WebPageProxy::UndoOrRedo);
- void executeUndoRedo(WebPageProxy::UndoOrRedo);
-
PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy(WebKit::WebPageProxy*);
void didReceiveMessageFromNavigatorQtObject(const String&);
Deleted: trunk/Source/WebKit2/UIProcess/qt/QtWebUndoCommand.cpp (102665 => 102666)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebUndoCommand.cpp 2011-12-13 10:14:46 UTC (rev 102665)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebUndoCommand.cpp 2011-12-13 10:24:44 UTC (rev 102666)
@@ -1,62 +0,0 @@
-/*
- 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 "QtWebUndoCommand.h"
-
-using namespace WebKit;
-
-QtWebUndoCommand::QtWebUndoCommand(PassRefPtr<WebEditCommandProxy> command, QUndoCommand* parent)
- : QUndoCommand(parent)
- , m_command(command)
- , m_first(true)
- , m_inUndoRedo(false)
-{
-}
-
-QtWebUndoCommand::~QtWebUndoCommand()
-{
-}
-
-void QtWebUndoCommand::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 QtWebUndoCommand::undo()
-{
- m_inUndoRedo = true;
-
- if (m_command)
- m_command->unapply();
-
- m_inUndoRedo = false;
-}
Deleted: trunk/Source/WebKit2/UIProcess/qt/QtWebUndoCommand.h (102665 => 102666)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebUndoCommand.h 2011-12-13 10:14:46 UTC (rev 102665)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebUndoCommand.h 2011-12-13 10:24:44 UTC (rev 102666)
@@ -1,45 +0,0 @@
-/*
- 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 QtWebUndoCommand_h
-#define QtWebUndoCommand_h
-
-#include "WebEditCommandProxy.h"
-#include <QUndoCommand>
-#include <qglobal.h>
-#include <wtf/RefPtr.h>
-
-class QtWebUndoCommand : public QUndoCommand {
-public:
- QtWebUndoCommand(PassRefPtr<WebKit::WebEditCommandProxy>, QUndoCommand* parent = 0);
- ~QtWebUndoCommand();
-
- void redo();
- void undo();
-
- bool inUndoRedo() const { return m_inUndoRedo; };
-
-private:
- RefPtr<WebKit::WebEditCommandProxy> m_command;
- bool m_first;
- bool m_inUndoRedo;
-};
-
-#endif // QtWebUndoCommand_h
Copied: trunk/Source/WebKit2/UIProcess/qt/QtWebUndoController.cpp (from rev 102665, trunk/Source/WebKit2/UIProcess/qt/QtWebUndoCommand.cpp) (0 => 102666)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebUndoController.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebUndoController.cpp 2011-12-13 10:24:44 UTC (rev 102666)
@@ -0,0 +1,116 @@
+/*
+ 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 "QtWebUndoController.h"
+
+#include "WebEditCommandProxy.h"
+#include <qglobal.h>
+#include <wtf/RefPtr.h>
+
+using namespace WebKit;
+
+class QtWebUndoCommand : public QUndoCommand {
+public:
+ QtWebUndoCommand(PassRefPtr<WebEditCommandProxy>, QUndoCommand* parent = 0);
+ ~QtWebUndoCommand();
+
+ void redo();
+ void undo();
+
+ bool inUndoRedo() const { return m_inUndoRedo; };
+
+private:
+ RefPtr<WebEditCommandProxy> m_command;
+ bool m_first;
+ bool m_inUndoRedo;
+};
+
+QtWebUndoCommand::QtWebUndoCommand(PassRefPtr<WebEditCommandProxy> command, QUndoCommand* parent)
+ : QUndoCommand(parent)
+ , m_command(command)
+ , m_first(true)
+ , m_inUndoRedo(false)
+{
+}
+
+QtWebUndoCommand::~QtWebUndoCommand()
+{
+}
+
+void QtWebUndoCommand::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 QtWebUndoCommand::undo()
+{
+ m_inUndoRedo = true;
+
+ if (m_command)
+ m_command->unapply();
+
+ m_inUndoRedo = false;
+}
+
+QtWebUndoController::QtWebUndoController()
+{
+}
+
+void QtWebUndoController::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ if (undoOrRedo == WebPageProxy::Undo) {
+ const QtWebUndoCommand* webUndoCommand = static_cast<const QtWebUndoCommand*>(m_undoStack.command(m_undoStack.index()));
+ if (webUndoCommand && webUndoCommand->inUndoRedo())
+ return;
+ m_undoStack.push(new QtWebUndoCommand(command));
+ }
+}
+
+void QtWebUndoController::clearAllEditCommands()
+{
+ m_undoStack.clear();
+}
+
+bool QtWebUndoController::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ if (undoOrRedo == WebPageProxy::Undo)
+ return m_undoStack.canUndo();
+ return m_undoStack.canRedo();
+}
+
+void QtWebUndoController::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ if (undoOrRedo == WebPageProxy::Undo)
+ m_undoStack.undo();
+ else
+ m_undoStack.redo();
+}
Copied: trunk/Source/WebKit2/UIProcess/qt/QtWebUndoController.h (from rev 102665, trunk/Source/WebKit2/UIProcess/qt/QtWebUndoCommand.h) (0 => 102666)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebUndoController.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebUndoController.h 2011-12-13 10:24:44 UTC (rev 102666)
@@ -0,0 +1,44 @@
+/*
+ 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 QtWebUndoController_h
+#define QtWebUndoController_h
+
+#include "PageClient.h"
+#include "WebPageProxy.h"
+#include <QUndoStack>
+
+class QtWebUndoController {
+public:
+ QtWebUndoController();
+
+private:
+ friend class QtPageClient;
+
+ // Page Client.
+ void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
+ void clearAllEditCommands();
+ bool canUndoRedo(WebKit::WebPageProxy::UndoOrRedo);
+ void executeUndoRedo(WebKit::WebPageProxy::UndoOrRedo);
+
+ QUndoStack m_undoStack;
+};
+
+#endif // QtWebUndoController_h