Moved all the event handlers from QWebFrame into QWebPage.
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:17:54 +0000 (14:17 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:17:54 +0000 (14:17 +0000)
This cleans up the public API and allows us to remove the
HackWebFrame hack in DumpRenderTree.

Signed-off-by: Lars Knoll <lars@trolltech.com>
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27525 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/Api/qwebframe.cpp
WebKit/qt/Api/qwebframe.h
WebKit/qt/Api/qwebframe_p.h
WebKit/qt/Api/qwebpage.cpp
WebKit/qt/Api/qwebpage_p.h
WebKit/qt/ChangeLog
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/qt/jsobjects.cpp

index 8ea8db53000d54906de4d18b3fa3208c3eb36f95..5b24f73e45d12a03b74a49ea7ac0dc6bf16971aa 100644 (file)
@@ -262,7 +262,7 @@ void QWebFrame::layout()
 QPoint QWebFrame::pos() const
 {
     Q_ASSERT(d->frameView);
 QPoint QWebFrame::pos() const
 {
     Q_ASSERT(d->frameView);
-    return d->frameView->frameGeometry().topLeft();
+    return d->pos();
 }
 
 QRect QWebFrame::geometry() const
 }
 
 QRect QWebFrame::geometry() const
@@ -284,71 +284,3 @@ QString QWebFrame::evaluateJavaScript(const QString& scriptSource)
     return rc;
 }
 
     return rc;
 }
 
-void QWebFrame::mouseMoveEvent(QMouseEvent *ev)
-{
-    if (!d->frameView)
-        return;
-
-    d->eventHandler->handleMouseMoveEvent(PlatformMouseEvent(ev, 0));
-    const int xOffset =
-        d->horizontalScrollBar() ? d->horizontalScrollBar()->value() : 0;
-    const int yOffset =
-        d->verticalScrollBar() ? d->verticalScrollBar()->value() : 0;
-    IntPoint pt(ev->x() + xOffset, ev->y() + yOffset);
-    WebCore::HitTestResult result = d->eventHandler->hitTestResultAtPoint(pt, false);
-    WebCore::Element *link = result.URLElement();
-    if (link != d->lastHoverElement) {
-        d->lastHoverElement = link;
-        emit hoveringOverLink(result.absoluteLinkURL().prettyURL(), result.title());
-    }
-}
-
-void QWebFrame::mousePressEvent(QMouseEvent *ev)
-{
-    if (!d->eventHandler)
-        return;
-
-    if (ev->button() == Qt::RightButton)
-        d->eventHandler->sendContextMenuEvent(PlatformMouseEvent(ev, 1));
-    else
-        d->eventHandler->handleMousePressEvent(PlatformMouseEvent(ev, 1));
-
-    //FIXME need to keep track of subframe focus for key events!
-    d->page->setFocus();
-}
-
-void QWebFrame::mouseDoubleClickEvent(QMouseEvent *ev)
-{
-    if (!d->eventHandler)
-        return;
-
-    d->eventHandler->handleMousePressEvent(PlatformMouseEvent(ev, 2));
-
-    //FIXME need to keep track of subframe focus for key events!
-    d->page->setFocus();
-}
-
-void QWebFrame::mouseReleaseEvent(QMouseEvent *ev)
-{
-    if (!d->frameView)
-        return;
-
-    d->eventHandler->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
-
-    //FIXME need to keep track of subframe focus for key events!
-    d->page->setFocus();
-}
-
-void QWebFrame::wheelEvent(QWheelEvent *ev)
-{
-    PlatformWheelEvent wkEvent(ev);
-    bool accepted = false;
-    if (d->eventHandler)
-        accepted = d->eventHandler->handleWheelEvent(wkEvent);
-
-    ev->setAccepted(accepted);
-
-    //FIXME need to keep track of subframe focus for key events!
-    d->page->setFocus();
-}
-
index 10d10a418117f7c0026d5cdca7ccd6e0d85006c1..7d0d12a9616b61cf557d9d841d0b0ac7690253ed 100644 (file)
@@ -86,14 +86,6 @@ signals:
     void titleChanged(const QString &title);
     void hoveringOverLink(const QString &link, const QString &title);
 
     void titleChanged(const QString &title);
     void hoveringOverLink(const QString &link, const QString &title);
 
-protected:
-    //for dumprendertree
-    virtual void mouseMoveEvent(QMouseEvent*);
-    virtual void mousePressEvent(QMouseEvent*);
-    virtual void mouseDoubleClickEvent(QMouseEvent*);
-    virtual void mouseReleaseEvent(QMouseEvent*);
-    virtual void wheelEvent(QWheelEvent*);
-
 private:
     friend class QWebPage;
     friend class QWebPagePrivate;
 private:
     friend class QWebPage;
     friend class QWebPagePrivate;
index ab0a9c7092200d24091756376742b40622255b51..f4061f5c977b42239d2a5a42e36312ab150866c3 100644 (file)
@@ -76,6 +76,9 @@ public:
     WebCore::PlatformScrollbar *horizontalScrollBar() const;
     WebCore::PlatformScrollbar *verticalScrollBar() const;
 
     WebCore::PlatformScrollbar *horizontalScrollBar() const;
     WebCore::PlatformScrollbar *verticalScrollBar() const;
 
+    inline QPoint pos() const
+    { return frameView->frameGeometry().topLeft(); }
+
     QWebFrame *q;
     WebCore::FrameLoaderClientQt *frameLoaderClient;
     WTF::RefPtr<WebCore::Frame> frame;
     QWebFrame *q;
     WebCore::FrameLoaderClientQt *frameLoaderClient;
     WTF::RefPtr<WebCore::Frame> frame;
index b62a1239fab16fc44aa2d5212af4ecaec158c12f..05a7697ebd1bd566e02fa20bf720390cdd42d4f1 100644 (file)
@@ -49,7 +49,9 @@
 #include "Editor.h"
 #include "PlatformScrollBar.h"
 #include "PlatformKeyboardEvent.h"
 #include "Editor.h"
 #include "PlatformScrollBar.h"
 #include "PlatformKeyboardEvent.h"
+#include "PlatformWheelEvent.h"
 #include "ProgressTracker.h"
 #include "ProgressTracker.h"
+#include "HitTestResult.h"
 
 #include <QDebug>
 #include <QDragEnterEvent>
 
 #include <QDebug>
 #include <QDragEnterEvent>
@@ -117,6 +119,22 @@ void QWebPagePrivate::createMainFrame()
     }
 }
 
     }
 }
 
+QWebFrame *QWebPagePrivate::frameAt(const QPoint &pos) const
+{
+    QWebFrame *frame = mainFrame;
+
+redo:
+    QList<QWebFrame*> children = frame->childFrames();
+    for (int i = 0; i < children.size(); ++i) {
+        if (children.at(i)->geometry().contains(pos)) {
+            frame = children.at(i);
+            goto redo;
+        }
+    }
+    if (frame->geometry().contains(pos))
+        return frame;
+    return 0;
+}
 
 QWebPage::QWebPage(QWidget *parent)
     : QWidget(parent)
 
 QWebPage::QWebPage(QWidget *parent)
     : QWidget(parent)
@@ -398,27 +416,79 @@ void QWebPage::paintEvent(QPaintEvent *ev)
 
 void QWebPage::mouseMoveEvent(QMouseEvent *ev)
 {
 
 void QWebPage::mouseMoveEvent(QMouseEvent *ev)
 {
-    mainFrame()->mouseMoveEvent(ev);
+    QWebFramePrivate *frame = d->currentFrame(ev->pos())->d;
+    if (!frame->frameView)
+        return;
+
+    frame->eventHandler->handleMouseMoveEvent(PlatformMouseEvent(ev, 0));
+    const int xOffset =
+        frame->horizontalScrollBar() ? frame->horizontalScrollBar()->value() : 0;
+    const int yOffset =
+        frame->verticalScrollBar() ? frame->verticalScrollBar()->value() : 0;
+    IntPoint pt(ev->x() + xOffset, ev->y() + yOffset);
+    WebCore::HitTestResult result = frame->eventHandler->hitTestResultAtPoint(pt, false);
+    WebCore::Element *link = result.URLElement();
+    if (link != frame->lastHoverElement) {
+        frame->lastHoverElement = link;
+        emit hoveringOverLink(result.absoluteLinkURL().prettyURL(), result.title());
+    }
 }
 
 void QWebPage::mousePressEvent(QMouseEvent *ev)
 {
 }
 
 void QWebPage::mousePressEvent(QMouseEvent *ev)
 {
-    mainFrame()->mousePressEvent(ev);
+    d->frameUnderMouse = d->frameAt(ev->pos());
+    QWebFramePrivate *frame = d->frameUnderMouse->d;
+    if (!frame->eventHandler)
+        return;
+
+    if (ev->button() == Qt::RightButton)
+        frame->eventHandler->sendContextMenuEvent(PlatformMouseEvent(ev, 1));
+    else
+        frame->eventHandler->handleMousePressEvent(PlatformMouseEvent(ev, 1));
+
+    //FIXME need to keep track of subframe focus for key events!
+    frame->page->setFocus();
 }
 
 void QWebPage::mouseDoubleClickEvent(QMouseEvent *ev)
 {
 }
 
 void QWebPage::mouseDoubleClickEvent(QMouseEvent *ev)
 {
-    mainFrame()->mouseDoubleClickEvent(ev);
+    QWebFramePrivate *frame = d->currentFrame(ev->pos())->d;
+    if (!frame->eventHandler)
+        return;
+
+    frame->eventHandler->handleMousePressEvent(PlatformMouseEvent(ev, 2));
+
+    //FIXME need to keep track of subframe focus for key events!
+    frame->page->setFocus();
 }
 
 void QWebPage::mouseReleaseEvent(QMouseEvent *ev)
 {
 }
 
 void QWebPage::mouseReleaseEvent(QMouseEvent *ev)
 {
-    mainFrame()->mouseReleaseEvent(ev);
+    QWebFramePrivate *frame = d->currentFrame(ev->pos())->d;
+    if (frame->frameView) {
+        frame->eventHandler->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
+
+        //FIXME need to keep track of subframe focus for key events!
+        frame->page->setFocus();
+    }
+    d->frameUnderMouse = 0;
 }
 
 void QWebPage::wheelEvent(QWheelEvent *ev)
 {
 }
 
 void QWebPage::wheelEvent(QWheelEvent *ev)
 {
-    mainFrame()->wheelEvent(ev);
+    QWebFramePrivate *frame = d->currentFrame(ev->pos())->d;
+
+    bool accepted = false;
+    if (frame->eventHandler) {
+        WebCore::PlatformWheelEvent pev(ev);
+        accepted = frame->eventHandler->handleWheelEvent(pev);
+    }
+
+    ev->setAccepted(accepted);
+
+    //FIXME need to keep track of subframe focus for key events!
+    frame->page->setFocus();
+
     if (!ev->isAccepted())
         QWidget::wheelEvent(ev);
 }
     if (!ev->isAccepted())
         QWidget::wheelEvent(ev);
 }
index aa320f5da23e3545eb261d30c6a0552a378cb035..b9fe140051e994490e316b842694ff54a332c067 100644 (file)
@@ -45,12 +45,18 @@ public:
     ~QWebPagePrivate();
     void createMainFrame();
 
     ~QWebPagePrivate();
     void createMainFrame();
 
+    QWebFrame *frameAt(const QPoint &pos) const;
+
     WebCore::ChromeClientQt *chromeClient;
     WebCore::ContextMenuClientQt *contextMenuClient;
     WebCore::EditorClientQt *editorClient;
     WebCore::Page *page;
 
     QPointer<QWebFrame> mainFrame;
     WebCore::ChromeClientQt *chromeClient;
     WebCore::ContextMenuClientQt *contextMenuClient;
     WebCore::EditorClientQt *editorClient;
     WebCore::Page *page;
 
     QPointer<QWebFrame> mainFrame;
+    QPointer<QWebFrame> frameUnderMouse;
+
+    inline QWebFrame *currentFrame(const QPoint &pos) const
+    { return frameUnderMouse ? static_cast<QWebFrame *>(frameUnderMouse) : frameAt(pos); }
 
     QWebPage *q;
     QUndoStack *undoStack;
 
     QWebPage *q;
     QUndoStack *undoStack;
index 6faf75408a1165ffc4c765253bcb3361bffa7a8a..1624027a9464cb2b755fc0ba79c2b3f59a9b6881 100644 (file)
@@ -1,3 +1,26 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars Knoll <lars@trolltech.com>.
+
+        Moved all the event handlers from QWebFrame into QWebPage.
+        
+        This cleans up the public API and allows us to remove the
+        HackWebFrame hack in DumpRenderTree.
+        
+
+        * Api/qwebframe.cpp:
+        (QWebFrame::pos):
+        * Api/qwebframe.h:
+        * Api/qwebframe_p.h:
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::frameAt):
+        (QWebPage::mouseMoveEvent):
+        (QWebPage::mousePressEvent):
+        (QWebPage::mouseDoubleClickEvent):
+        (QWebPage::mouseReleaseEvent):
+        (QWebPage::wheelEvent):
+        * Api/qwebpage_p.h:
+
 2007-11-07  Holger Freyther  <holger.freyther@trolltech.com>
 
         Reviewed by Lars Knoll <lars@trolltech.com>.
 2007-11-07  Holger Freyther  <holger.freyther@trolltech.com>
 
         Reviewed by Lars Knoll <lars@trolltech.com>.
index 54cb7be8123c13cfc1e94b4a2b7fa522a7d00d95..362a3e58a3b0f2ed1c87dff5f624392424e98fb5 100644 (file)
@@ -1,3 +1,18 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars Knoll <lars@trolltech.com>.
+
+        Moved all the event handlers from QWebFrame into QWebPage.
+        
+        This cleans up the public API and allows us to remove the
+        HackWebFrame hack in DumpRenderTree.
+        
+
+        * DumpRenderTree/qt/jsobjects.cpp:
+        (EventSender::mouseDown):
+        (EventSender::mouseUp):
+        (EventSender::mouseMoveTo):
+
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Mark.
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Mark.
index fae1447afa2141a082182a785a3ecce7812bb987..5ad452182405554f2dd475a418a3f3af76cf4106 100644 (file)
 #include "DumpRenderTree.h"
 extern void qt_dump_editing_callbacks(bool b);
 
 #include "DumpRenderTree.h"
 extern void qt_dump_editing_callbacks(bool b);
 
-class HackWebFrame : public QWebFrame
-{
-public:
-    void mousePressEvent(QMouseEvent *e) {
-        QWebFrame::mousePressEvent(e);
-    }
-    void mouseReleaseEvent(QMouseEvent *e) {
-        QWebFrame::mouseReleaseEvent(e);
-    }
-    void mouseMoveEvent(QMouseEvent *e) {
-        QWebFrame::mouseMoveEvent(e);
-    }
-
-protected:
-    HackWebFrame(QWebPage *parent, QWebFrameData *frameData) : QWebFrame(parent, frameData) {}
-    HackWebFrame(QWebFrame *parent, QWebFrameData *frameData) : QWebFrame(parent, frameData) {}
-    ~HackWebFrame() {}
-};
-
 LayoutTestController::LayoutTestController(WebCore::DumpRenderTree *drt)
     : QObject()
     , m_drt(drt)
 LayoutTestController::LayoutTestController(WebCore::DumpRenderTree *drt)
     : QObject()
     , m_drt(drt)
@@ -168,31 +149,24 @@ EventSender::EventSender(QWebPage *parent)
 
 void EventSender::mouseDown()
 {
 
 void EventSender::mouseDown()
 {
-    QWebFrame *frame = frameUnderMouse();
 //     qDebug() << "EventSender::mouseDown" << frame;
 //     qDebug() << "EventSender::mouseDown" << frame;
-    if (!frame)
-        return;
-    QMouseEvent event(QEvent::MouseButtonPress, m_mousePos - frame->pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
-    static_cast<HackWebFrame *>(frame)->mousePressEvent(&event);
+    QMouseEvent event(QEvent::MouseButtonPress, m_mousePos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
+    QApplication::sendEvent(m_page, &event);
 }
 
 void EventSender::mouseUp()
 {
 }
 
 void EventSender::mouseUp()
 {
-    QWebFrame *frame = frameUnderMouse();
 //     qDebug() << "EventSender::mouseUp" << frame;
 //     qDebug() << "EventSender::mouseUp" << frame;
-    if (!frame)
-        return;
-    QMouseEvent event(QEvent::MouseButtonRelease, m_mousePos - frame->pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
-    static_cast<HackWebFrame *>(frame)->mouseReleaseEvent(&event);
+    QMouseEvent event(QEvent::MouseButtonRelease, m_mousePos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
+    QApplication::sendEvent(m_page, &event);
 }
 
 void EventSender::mouseMoveTo(int x, int y)
 {
 }
 
 void EventSender::mouseMoveTo(int x, int y)
 {
-    QWebFrame *frame = frameUnderMouse();
 //     qDebug() << "EventSender::mouseMoveTo" << x << y;
     m_mousePos = QPoint(x, y);
 //     qDebug() << "EventSender::mouseMoveTo" << x << y;
     m_mousePos = QPoint(x, y);
-    QMouseEvent event(QEvent::MouseMove, m_mousePos - frame->pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
-    static_cast<HackWebFrame *>(frame)->mouseMoveEvent(&event);
+    QMouseEvent event(QEvent::MouseMove, m_mousePos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
+    QApplication::sendEvent(m_page, &event);
 }
 
 void EventSender::leapForward(int ms)
 }
 
 void EventSender::leapForward(int ms)