Changeset 102666 in webkit


Ignore:
Timestamp:
Dec 13, 2011 2:24:44 AM (12 years ago)
Author:
caio.oliveira@openbossa.org
Message:

[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.
Location:
trunk/Source/WebKit2
Files:
8 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r102652 r102666  
     12011-12-12  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
     2
     3        [Qt][WK2] Move undo & edit command PageClient callbacks into QtWebUndoController
     4        https://bugs.webkit.org/show_bug.cgi?id=74364
     5
     6        Reviewed by Simon Hausmann.
     7
     8        The four callbacks in PageClient related to Undo depend only on the QUndoStack. So we
     9        move their handling to a QtWebUndoController (owned by QQuickWebViewPrivate). This also
     10        make QtWebUndoCommand an implementation detail.
     11
     12        * Target.pri:
     13        * UIProcess/API/qt/qquickwebview.cpp:
     14        (QQuickWebViewPrivate::QQuickWebViewPrivate):
     15        * UIProcess/API/qt/qquickwebview_p_p.h:
     16        * UIProcess/qt/QtPageClient.cpp:
     17        (QtPageClient::registerEditCommand):
     18        (QtPageClient::clearAllEditCommands):
     19        (QtPageClient::canUndoRedo):
     20        (QtPageClient::executeUndoRedo):
     21        * UIProcess/qt/QtPageClient.h:
     22        (QtPageClient::initialize):
     23        * UIProcess/qt/QtWebPageProxy.cpp:
     24        * UIProcess/qt/QtWebPageProxy.h:
     25        * UIProcess/qt/QtWebUndoController.cpp: Renamed from Source/WebKit2/UIProcess/qt/QtWebUndoCommand.cpp.
     26        (QtWebUndoCommand::inUndoRedo):
     27        (QtWebUndoCommand::QtWebUndoCommand):
     28        (QtWebUndoCommand::~QtWebUndoCommand):
     29        (QtWebUndoCommand::redo):
     30        (QtWebUndoCommand::undo):
     31        (QtWebUndoController::QtWebUndoController):
     32        (QtWebUndoController::registerEditCommand):
     33        (QtWebUndoController::clearAllEditCommands):
     34        (QtWebUndoController::canUndoRedo):
     35        (QtWebUndoController::executeUndoRedo):
     36        * UIProcess/qt/QtWebUndoController.h: Renamed from Source/WebKit2/UIProcess/qt/QtWebUndoCommand.h.
     37
    1382011-12-12  Andreas Kling  <kling@webkit.org>
    239
  • trunk/Source/WebKit2/Target.pri

    r102640 r102666  
    270270    UIProcess/qt/QtSGTileNode.h \
    271271    UIProcess/qt/QtViewportInteractionEngine.h \
    272     UIProcess/qt/QtWebUndoCommand.h \
     272    UIProcess/qt/QtWebUndoController.h \
    273273    UIProcess/qt/WebContextMenuProxyQt.h \
    274274    UIProcess/qt/WebGeolocationProviderQt.h \
     
    512512    UIProcess/DrawingAreaProxy.cpp \
    513513    UIProcess/DrawingAreaProxyImpl.cpp \
    514     UIProcess/qt/QtWebUndoCommand.cpp \
     514    UIProcess/qt/QtWebUndoController.cpp \
    515515    UIProcess/FindIndicator.cpp \
    516516    UIProcess/GeolocationPermissionRequestManagerProxy.cpp \
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp

    r102593 r102666  
    7070    QWebPreferencesPrivate::get(pageProxy->preferences())->setAttribute(QWebPreferencesPrivate::AcceleratedCompositingEnabled, true);
    7171
    72     pageClient->setEventHandler(eventHandler.data());
    73     pageClient->setPageProxy(pageProxy.data());
     72    pageClient->initialize(pageProxy.data(), eventHandler.data(), &undoController);
    7473
    7574    // Creates a page with the page creation parameters.
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h

    r102593 r102666  
    2929#include "QtWebPageProxy.h"
    3030#include "QtWebPageUIClient.h"
     31#include "QtWebUndoController.h"
    3132
    3233#include "qquickwebview_p.h"
     
    117118    };
    118119
     120    QtWebUndoController undoController;
     121
    119122    QScopedPointer<QtPageClient> pageClient;
    120123    QScopedPointer<QtWebPageEventHandler> eventHandler;
  • trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp

    r102579 r102666  
    2424#include "QtWebPageEventHandler.h"
    2525#include "QtWebPageProxy.h"
    26 #include "QtWebUndoCommand.h"
     26#include "QtWebUndoController.h"
    2727#include "WebContextMenuProxyQt.h"
    2828#include "WebEditCommandProxy.h"
     
    109109void QtPageClient::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
    110110{
    111     m_qtWebPageProxy->registerEditCommand(command, undoOrRedo);
     111    m_undoController->registerEditCommand(command, undoOrRedo);
    112112}
    113113
    114114void QtPageClient::clearAllEditCommands()
    115115{
    116     m_qtWebPageProxy->clearAllEditCommands();
     116    m_undoController->clearAllEditCommands();
    117117}
    118118
    119119bool QtPageClient::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
    120120{
    121     return m_qtWebPageProxy->canUndoRedo(undoOrRedo);
     121    return m_undoController->canUndoRedo(undoOrRedo);
    122122}
    123123
    124124void QtPageClient::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
    125125{
    126     m_qtWebPageProxy->executeUndoRedo(undoOrRedo);
     126    m_undoController->executeUndoRedo(undoOrRedo);
    127127}
    128128
  • trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h

    r102136 r102666  
    2929
    3030class QtWebPageEventHandler;
     31class QtWebUndoController;
    3132
    3233using namespace WebKit;
     
    6061    virtual void setCursorHiddenUntilMouseMoves(bool);
    6162    virtual void toolTipChanged(const String&, const String&);
     63
     64    // QtWebUndoController
    6265    virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
    6366    virtual void clearAllEditCommands();
    6467    virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
    6568    virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
     69
    6670    virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
    6771    virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
     
    8993#endif
    9094
    91     void setEventHandler(QtWebPageEventHandler* eventHandler) { m_eventHandler = eventHandler; }
    92     void setPageProxy(QtWebPageProxy* pageProxy) { m_qtWebPageProxy = pageProxy; }
     95    void initialize(QtWebPageProxy* pageProxy, QtWebPageEventHandler* eventHandler, QtWebUndoController* undoController)
     96    {
     97        m_eventHandler = eventHandler;
     98        m_qtWebPageProxy = pageProxy;
     99        m_undoController = undoController;
     100    }
    93101
    94102private:
    95103    QtWebPageProxy* m_qtWebPageProxy;
    96104    QtWebPageEventHandler* m_eventHandler;
     105    QtWebUndoController* m_undoController;
    97106};
    98107
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp

    r102586 r102666  
    4040#include "QtPageClient.h"
    4141#include "QtWebPageEventHandler.h"
    42 #include "QtWebUndoCommand.h"
    4342#include "WebBackForwardList.h"
    4443#include "WebContextMenuProxyQt.h"
     
    143142}
    144143
    145 void QtWebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
    146 {
    147     if (undoOrRedo == WebPageProxy::Undo) {
    148         const QtWebUndoCommand* webUndoCommand = static_cast<const QtWebUndoCommand*>(m_undoStack->command(m_undoStack->index()));
    149         if (webUndoCommand && webUndoCommand->inUndoRedo())
    150             return;
    151         m_undoStack->push(new QtWebUndoCommand(command));
    152     }
    153 }
    154 
    155 void QtWebPageProxy::clearAllEditCommands()
    156 {
    157     m_undoStack->clear();
    158 }
    159 
    160 bool QtWebPageProxy::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
    161 {
    162     if (undoOrRedo == WebPageProxy::Undo)
    163         return m_undoStack->canUndo();
    164     return m_undoStack->canRedo();
    165 }
    166 
    167 void QtWebPageProxy::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
    168 {
    169     if (undoOrRedo == WebPageProxy::Undo)
    170         m_undoStack->undo();
    171     else
    172         m_undoStack->redo();
    173 }
    174 
    175144PassRefPtr<WebPopupMenuProxy> QtWebPageProxy::createPopupMenuProxy(WebPageProxy*)
    176145{
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h

    r102586 r102666  
    6969    void didChangeContentsSize(const WebCore::IntSize&);
    7070    void didChangeViewportProperties(const WebCore::ViewportArguments&);
    71 
    72     void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
    73     void clearAllEditCommands();
    74     bool canUndoRedo(WebPageProxy::UndoOrRedo);
    75     void executeUndoRedo(WebPageProxy::UndoOrRedo);
    7671
    7772    PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy(WebKit::WebPageProxy*);
  • trunk/Source/WebKit2/UIProcess/qt/QtWebUndoController.cpp

    r102665 r102666  
    2020
    2121#include "config.h"
    22 #include "QtWebUndoCommand.h"
     22#include "QtWebUndoController.h"
     23
     24#include "WebEditCommandProxy.h"
     25#include <qglobal.h>
     26#include <wtf/RefPtr.h>
    2327
    2428using namespace WebKit;
     29
     30class QtWebUndoCommand : public QUndoCommand {
     31public:
     32    QtWebUndoCommand(PassRefPtr<WebEditCommandProxy>, QUndoCommand* parent = 0);
     33    ~QtWebUndoCommand();
     34
     35    void redo();
     36    void undo();
     37
     38    bool inUndoRedo() const { return m_inUndoRedo; };
     39
     40private:
     41    RefPtr<WebEditCommandProxy> m_command;
     42    bool m_first;
     43    bool m_inUndoRedo;
     44};
    2545
    2646QtWebUndoCommand::QtWebUndoCommand(PassRefPtr<WebEditCommandProxy> command, QUndoCommand* parent)
     
    6181    m_inUndoRedo = false;
    6282}
     83
     84QtWebUndoController::QtWebUndoController()
     85{
     86}
     87
     88void QtWebUndoController::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
     89{
     90    if (undoOrRedo == WebPageProxy::Undo) {
     91        const QtWebUndoCommand* webUndoCommand = static_cast<const QtWebUndoCommand*>(m_undoStack.command(m_undoStack.index()));
     92        if (webUndoCommand && webUndoCommand->inUndoRedo())
     93            return;
     94        m_undoStack.push(new QtWebUndoCommand(command));
     95    }
     96}
     97
     98void QtWebUndoController::clearAllEditCommands()
     99{
     100    m_undoStack.clear();
     101}
     102
     103bool QtWebUndoController::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
     104{
     105    if (undoOrRedo == WebPageProxy::Undo)
     106        return m_undoStack.canUndo();
     107    return m_undoStack.canRedo();
     108}
     109
     110void QtWebUndoController::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
     111{
     112    if (undoOrRedo == WebPageProxy::Undo)
     113        m_undoStack.undo();
     114    else
     115        m_undoStack.redo();
     116}
  • trunk/Source/WebKit2/UIProcess/qt/QtWebUndoController.h

    r102665 r102666  
    1919*/
    2020
    21 #ifndef QtWebUndoCommand_h
    22 #define QtWebUndoCommand_h
     21#ifndef QtWebUndoController_h
     22#define QtWebUndoController_h
    2323
    24 #include "WebEditCommandProxy.h"
    25 #include <QUndoCommand>
    26 #include <qglobal.h>
    27 #include <wtf/RefPtr.h>
     24#include "PageClient.h"
     25#include "WebPageProxy.h"
     26#include <QUndoStack>
    2827
    29 class QtWebUndoCommand : public QUndoCommand {
     28class QtWebUndoController {
    3029public:
    31     QtWebUndoCommand(PassRefPtr<WebKit::WebEditCommandProxy>, QUndoCommand* parent = 0);
    32     ~QtWebUndoCommand();
    33 
    34     void redo();
    35     void undo();
    36 
    37     bool inUndoRedo() const { return m_inUndoRedo; };
     30    QtWebUndoController();
    3831
    3932private:
    40     RefPtr<WebKit::WebEditCommandProxy> m_command;
    41     bool m_first;
    42     bool m_inUndoRedo;
     33    friend class QtPageClient;
     34
     35    // Page Client.
     36    void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
     37    void clearAllEditCommands();
     38    bool canUndoRedo(WebKit::WebPageProxy::UndoOrRedo);
     39    void executeUndoRedo(WebKit::WebPageProxy::UndoOrRedo);
     40
     41    QUndoStack m_undoStack;
    4342};
    4443
    45 #endif // QtWebUndoCommand_h
     44#endif // QtWebUndoController_h
Note: See TracChangeset for help on using the changeset viewer.