make QWebPage a QObject and get things to compile.
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jan 2008 14:47:45 +0000 (14:47 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jan 2008 14:47:45 +0000 (14:47 +0000)
Nothing works currently though.

Signed-off-by: Simon
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29162 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
WebCore/ChangeLog
WebCore/platform/qt/ScrollViewQt.cpp
WebCore/platform/qt/WidgetQt.cpp
WebKit/qt/Api/qwebobjectpluginconnector.cpp
WebKit/qt/Api/qwebpage.cpp
WebKit/qt/Api/qwebpage.h
WebKit/qt/Api/qwebpage_p.h
WebKit/qt/Api/qwebview.cpp
WebKit/qt/Api/qwebview.h
WebKit/qt/ChangeLog
WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
WebKit/qt/WebCoreSupport/DragClientQt.cpp
WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp

index 7a94c20e71310e9d78c1b236c9d7921269e89a99..33f3e62d839f0e234ce23d316810d1ef94702c07 100644 (file)
@@ -1,3 +1,18 @@
+2008-01-04  Lars Knoll  <lars@trolltech.com>
+
+        Reviewed by Simon.
+
+        make QWebPage a QObject and get things to compile.
+
+        Nothing works currently though.
+
+        * platform/qt/ScrollViewQt.cpp:
+        (WebCore::ScrollView::updateContents):
+        (WebCore::ScrollView::update):
+        * platform/qt/WidgetQt.cpp:
+        (WebCore::Widget::qwidget):
+        (WebCore::Widget::invalidateRect):
+
 2008-01-04  Alp Toker  <alp@atoker.com>
 
         Reviewed by Mark Rowe.
index 341216924a8f575f7bc98b1310503339a9ecd787..2058beb8bb4d7e72ace562b17e8813e927a2ed29 100644 (file)
@@ -211,8 +211,8 @@ void ScrollView::updateContents(const IntRect& rect, bool now)
     //an actual paint occurs in ScrollView::paint...
 
     QRect r(containingWindowRect);
-    QWidget *container = containingWindow();
-    r = r.intersect(container->rect());
+    QWebPage* page = qwebframe()->page();
+    r = r.intersect(QRect(QPoint(0, 0), page->viewportSize()));
     if (r.isEmpty())
         return;
     // Cache the dirty spot.
@@ -221,6 +221,8 @@ void ScrollView::updateContents(const IntRect& rect, bool now)
     else
         m_data->m_dirtyRegion = QRegion(r);
 
+#if 0
+    // ### QWebPage
     bool painting = containingWindow()->testAttribute(Qt::WA_WState_InPaintEvent);
     if (painting && now) {
         QWebPage *page = qobject_cast<QWebPage*>(containingWindow());
@@ -231,11 +233,14 @@ void ScrollView::updateContents(const IntRect& rect, bool now)
     } else {
         containingWindow()->update(m_data->m_dirtyRegion.boundingRect());
     }
+#endif
 }
 
 void ScrollView::update()
 {
-    containingWindow()->update(frameGeometry());
+    QWidget* window = containingWindow();
+    if (window)
+        window->update(frameGeometry());
 }
 
 int ScrollView::visibleWidth() const
index ace77cc07019c7959c50a70fdab0a242d9ac4475..92adc1891ab49e1e05945c228b65c0314fd315ae 100644 (file)
@@ -146,7 +146,7 @@ QWidget* Widget::qwidget() const
         return data->m_widget;
 
     if (data->m_webFrame)
-        return data->m_webFrame->page();
+        return data->m_webFrame->page()->view();
 
     return 0;
 }
@@ -215,6 +215,8 @@ void Widget::invalidateRect(const IntRect& r)
     if (parent() && parent()->isFrameView() && static_cast<FrameView*>(parent())->needsLayout())
         shouldPaint = false;
 
+#if 0
+    // ### QWebPage
     if (shouldPaint) {
         QWebPage* page = qobject_cast<QWebPage*>(canvas);
         QPainter p(page);
@@ -222,6 +224,7 @@ void Widget::invalidateRect(const IntRect& r)
     } else {
         canvas->update(windowRect);
     }
+#endif
 }
 
 void Widget::removeFromParent()
index 350281e31c1ff299216557e4f2bcb328794e50ff..89fb2947a0c0108cfd1be76ba40b6c70e6a5674c 100644 (file)
@@ -41,7 +41,7 @@ QWebFrame *QWebObjectPluginConnector::frame() const
 
 QWidget *QWebObjectPluginConnector::pluginParentWidget() const
 {
-    return d->frame->page();
+    return d->frame->page()->view();
 }
 
 QWebNetworkJob *QWebObjectPluginConnector::requestUrl(const QWebNetworkRequest &request, Target target)
index 973cfca265f025da63480e04d123ab5be8ab71b6..8eebf4abe394ef1b1cede34c849def79469acea0 100644 (file)
@@ -78,10 +78,9 @@ using namespace WebCore;
 
 QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
     : q(qq)
+    , view(0)
     , modified(false)
 {
-    q->setMouseTracking(true);
-    q->setFocusPolicy(Qt::ClickFocus);
     chromeClient = new ChromeClientQt(q);
     contextMenuClient = new ContextMenuClientQt();
     editorClient = new EditorClientQt(q);
@@ -126,7 +125,7 @@ void QWebPagePrivate::createMainFrame()
         frameData.marginWidth = 0;
         frameData.marginHeight = 0;
         mainFrame = new QWebFrame(q, &frameData);
-        mainFrame->d->frameView->setFrameGeometry(q->geometry());
+        mainFrame->d->frameView->setFrameGeometry(IntRect(IntPoint(0,0), q->viewportSize()));
 
         emit q->frameCreated(mainFrame);
     }
@@ -284,18 +283,12 @@ void QWebPagePrivate::updateEditorActions()
     updateAction(QWebPage::Paste);
 }
 
-QWebPage::QWebPage(QWidget *parent)
-    : QWidget(parent)
+QWebPage::QWebPage(QObject *parent)
+    : QObject(parent)
     , d(new QWebPagePrivate(this))
 {
+    setView(qobject_cast<QWidget *>(parent));
 
-    QPalette pal = palette();
-    pal.setBrush(QPalette::Background, Qt::white);
-
-    setAttribute(Qt::WA_OpaquePaintEvent);
-
-    setPalette(pal);
-    setAcceptDrops(true);
     connect(this, SIGNAL(loadProgressChanged(int)), this, SLOT(_q_onLoadProgressChanged(int)));
 }
 
@@ -323,6 +316,18 @@ QWebPageHistory *QWebPage::history() const
     return &d->history;
 }
 
+void QWebPage::setView(QWidget *view)
+{
+    d->view = view;
+    setViewportSize(view ? view->size() : QSize(0, 0));
+}
+
+QWidget *QWebPage::view() const
+{
+    return d->view;
+}
+
+
 void QWebPage::javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID)
 {
 }
@@ -330,13 +335,13 @@ void QWebPage::javaScriptConsoleMessage(const QString& message, unsigned int lin
 void QWebPage::javaScriptAlert(QWebFrame *frame, const QString& msg)
 {
     //FIXME frame pos...
-    QMessageBox::information(this, mainFrame()->title(), msg, QMessageBox::Ok);
+    QMessageBox::information(d->view, mainFrame()->title(), msg, QMessageBox::Ok);
 }
 
 bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg)
 {
     //FIXME frame pos...
-    return 0 == QMessageBox::information(this, mainFrame()->title(), msg, QMessageBox::Yes, QMessageBox::No);
+    return 0 == QMessageBox::information(d->view, mainFrame()->title(), msg, QMessageBox::Yes, QMessageBox::No);
 }
 
 bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result)
@@ -344,7 +349,7 @@ bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QStr
     //FIXME frame pos...
     bool ok = false;
 #ifndef QT_NO_INPUTDIALOG
-    QString x = QInputDialog::getText(this, mainFrame()->title(), msg, QLineEdit::Normal, defaultValue, &ok);
+    QString x = QInputDialog::getText(d->view, mainFrame()->title(), msg, QLineEdit::Normal, defaultValue, &ok);
     if (ok && result) {
         *result = x;
     }
@@ -780,37 +785,6 @@ static inline Qt::DropAction dragOpToDropAction(unsigned actions)
     return result;    
 }
 
-void QWebPage::resizeEvent(QResizeEvent *e)
-{
-    QWidget::resizeEvent(e);
-    setViewportSize(rect().size());
-}
-
-void QWebPage::paintEvent(QPaintEvent *ev)
-{
-#ifdef QWEBKIT_TIME_RENDERING
-    QTime time;
-    time.start();
-#endif
-
-    mainFrame()->layout();
-    QPainter p(this);
-
-    QVector<QRect> vector = ev->region().rects();
-    if (!vector.isEmpty()) {
-        for (int i = 0; i < vector.size(); ++i) {
-            mainFrame()->render(&p, vector.at(i));
-        }
-    } else {
-        mainFrame()->render(&p, ev->rect());
-    }
-
-#ifdef    QWEBKIT_TIME_RENDERING
-    int elapsed = time.elapsed();
-    qDebug()<<"paint event on "<<ev->region()<<", took to render =  "<<elapsed;
-#endif
-}
-
 void QWebPage::mouseMoveEvent(QMouseEvent *ev)
 {
     QWebFrame *f = d->currentFrame(ev->pos());
@@ -846,9 +820,6 @@ void QWebPage::mousePressEvent(QMouseEvent *ev)
         return;
 
     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)
@@ -862,9 +833,6 @@ void QWebPage::mouseDoubleClickEvent(QMouseEvent *ev)
         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)
@@ -879,8 +847,6 @@ void QWebPage::mouseReleaseEvent(QMouseEvent *ev)
 
     frame->eventHandler->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
 
-    //FIXME need to keep track of subframe focus for key events!
-    frame->page->setFocus();
     d->frameUnderMouse = 0;
 }
 
@@ -922,11 +888,9 @@ void QWebPage::wheelEvent(QWheelEvent *ev)
 
     ev->setAccepted(accepted);
 
-    //FIXME need to keep track of subframe focus for key events!
-    frame->page->setFocus();
-
-    if (!ev->isAccepted())
-        QWidget::wheelEvent(ev);
+    // ### QWebPage
+//     if (!ev->isAccepted())
+//         QWidget::wheelEvent(ev);
 }
 
 void QWebPage::keyPressEvent(QKeyEvent *ev)
@@ -1048,10 +1012,10 @@ void QWebPage::keyPressEvent(QKeyEvent *ev)
 
         if (ev == QKeySequence::MoveToNextPage) {
             if (v)
-                v->setValue(v->value() + height());
+                v->setValue(v->value() + viewportSize().height());
         } else if (ev == QKeySequence::MoveToPreviousPage) {
             if (v)
-                v->setValue(v->value() - height());
+                v->setValue(v->value() - viewportSize().height());
         } else {
             switch (ev->key()) {
             case Qt::Key_Up:
@@ -1098,12 +1062,14 @@ void QWebPage::focusInEvent(QFocusEvent *ev)
 {
     if (ev->reason() != Qt::PopupFocusReason) 
         mainFrame()->d->frame->page()->focusController()->setFocusedFrame(mainFrame()->d->frame);
-    QWidget::focusInEvent(ev);
+    // ### QWebPage
+    //QWidget::focusInEvent(ev);
 }
 
 void QWebPage::focusOutEvent(QFocusEvent *ev)
 {
-    QWidget::focusOutEvent(ev);
+    // ### QWebPage
+    //QWidget::focusOutEvent(ev);
     if (ev->reason() != Qt::PopupFocusReason) {
         mainFrame()->d->frame->selectionController()->clear();
         mainFrame()->d->frame->setIsActive(false);
@@ -1179,7 +1145,7 @@ QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& oldFile)
 {
     //FIXME frame pos...
 #ifndef QT_NO_FILEDIALOG
-    return QFileDialog::getOpenFileName(this, QString::null, oldFile);
+    return QFileDialog::getOpenFileName(d->view, QString::null, oldFile);
 #else
     return QString::null;
 #endif
index 768f677010f7f0039ff3f24692eb68ab22e61837..a08f4a404d59e290d6d10d879fbd11e648b947d8 100644 (file)
@@ -28,6 +28,7 @@
 #include "qwebsettings.h"
 #include "qwebkitglobal.h"
 
+#include <QtCore/qobject.h>
 #include <QtGui/qwidget.h>
 class QNetworkProxy;
 class QUndoStack;
@@ -49,7 +50,7 @@ namespace WebCore {
     class HitTestResult;
 }
 
-class QWEBKIT_EXPORT QWebPage : public QWidget
+class QWEBKIT_EXPORT QWebPage : public QObject
 {
     Q_OBJECT
 
@@ -137,7 +138,7 @@ public:
     };
 
 
-    explicit QWebPage(QWidget *parent = 0);
+    explicit QWebPage(QObject *parent = 0);
     ~QWebPage();
 
     QWebFrame *mainFrame() const;
@@ -147,6 +148,9 @@ public:
 
     QWebSettings *settings();
 
+    void setView(QWidget *view);
+    QWidget *view() const;
+
     bool isModified() const;
     QUndoStack *undoStack() const;
 
@@ -214,8 +218,6 @@ protected:
 
     virtual QString userAgentFor(const QUrl& url) const;
 
-    virtual void resizeEvent(QResizeEvent*);
-    virtual void paintEvent(QPaintEvent*);
     virtual void mouseMoveEvent(QMouseEvent*);
     virtual void mousePressEvent(QMouseEvent*);
     virtual void mouseDoubleClickEvent(QMouseEvent*);
index 98e4debd113ec8e79424abfca31231aa21f9dc28..1294260a6b717d6fd0b20a0ab00b8472cf815673 100644 (file)
@@ -109,6 +109,7 @@ public:
 
     QWebPage *q;
     QUndoStack *undoStack;
+    QWidget *view;
 
     QWebNetworkInterface *networkInterface;
 
index 8fac351d48e61878100f221ba4bb048b0da6a593..0bd40705a4dc06b5f6759834516aaebed2798319 100644 (file)
@@ -21,6 +21,7 @@
 #include "qwebview.h"
 #include "qwebframe.h"
 #include "qevent.h"
+#include "qpainter.h"
 
 class QWebViewPrivate
 {
@@ -44,6 +45,17 @@ QWebView::QWebView(QWidget *parent)
 {
     d = new QWebViewPrivate;
     d->page = 0;
+
+    QPalette pal = palette();
+    pal.setBrush(QPalette::Background, Qt::white);
+
+    setAttribute(Qt::WA_OpaquePaintEvent);
+
+    setPalette(pal);
+    setAcceptDrops(true);
+
+    setMouseTracking(true);
+    setFocusPolicy(Qt::ClickFocus);
 }
 
 /*!
@@ -92,6 +104,7 @@ void QWebView::setPage(QWebPage *page)
     }
     d->page = page;
     if (d->page) {
+        d->page->setView(this);
         // #### connect signals
         QWebFrame *mainFrame = d->page->mainFrame();
         connect(mainFrame, SIGNAL(loadStarted()),
@@ -353,6 +366,32 @@ void QWebView::reload()
 void QWebView::resizeEvent(QResizeEvent *e)
 {
     if (d->page)
-        d->page->resize(e->size());
+        d->page->setViewportSize(e->size());
 }
 
+
+void QWebView::paintEvent(QPaintEvent *ev)
+{
+#ifdef QWEBKIT_TIME_RENDERING
+    QTime time;
+    time.start();
+#endif
+
+    QWebFrame *frame = d->page->mainFrame();
+    frame->layout();
+    QPainter p(this);
+
+    QVector<QRect> vector = ev->region().rects();
+    if (!vector.isEmpty()) {
+        for (int i = 0; i < vector.size(); ++i) {
+            frame->render(&p, vector.at(i));
+        }
+    } else {
+        frame->render(&p, ev->rect());
+    }
+
+#ifdef    QWEBKIT_TIME_RENDERING
+    int elapsed = time.elapsed();
+    qDebug()<<"paint event on "<<ev->region()<<", took to render =  "<<elapsed;
+#endif
+}
index 54e6280d568ceea6c062929ec7a8a81a153d9ecc..b3de6ef92427d174e4288724b69a71ee71978dc4 100644 (file)
@@ -92,7 +92,8 @@ Q_SIGNALS:
     void iconLoaded();
 
 protected:
-    virtual void resizeEvent(QResizeEvent *e);
+    void resizeEvent(QResizeEvent *e);
+    void paintEvent(QPaintEvent *ev);
 
 private:
     QWebViewPrivate *d;
index b7f6bcc99406c69140d28a838926d2694e4a591a..7d5d772f3c92de8027d97b0e9ae5de942d07f2ef 100644 (file)
@@ -1,3 +1,58 @@
+2008-01-04  Lars Knoll  <lars@trolltech.com>
+
+        Reviewed by Simon.
+
+        make QWebPage a QObject and get things to compile.
+        
+        Nothing works currently though.
+        
+
+        * Api/qwebobjectpluginconnector.cpp:
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::QWebPagePrivate):
+        (QWebPagePrivate::createMainFrame):
+        (QWebPage::QWebPage):
+        (QWebPage::setView):
+        (QWebPage::view):
+        (QWebPage::javaScriptAlert):
+        (QWebPage::javaScriptPrompt):
+        (dragOpToDropAction):
+        (QWebPage::mousePressEvent):
+        (QWebPage::mouseDoubleClickEvent):
+        (QWebPage::mouseReleaseEvent):
+        (QWebPage::wheelEvent):
+        (QWebPage::keyPressEvent):
+        (QWebPage::focusInEvent):
+        * Api/qwebpage.h:
+        * Api/qwebpage_p.h:
+        * Api/qwebview.cpp:
+        (QWebView::QWebView):
+        (QWebView::setPage):
+        (QWebView::resizeEvent):
+        (QWebView::paintEvent):
+        * Api/qwebview.h:
+        * WebCoreSupport/ChromeClientQt.cpp:
+        (WebCore::ChromeClientQt::windowRect):
+        (WebCore::ChromeClientQt::pageRect):
+        (WebCore::ChromeClientQt::focus):
+        (WebCore::ChromeClientQt::unfocus):
+        (WebCore::ChromeClientQt::canTakeFocus):
+        (WebCore::ChromeClientQt::takeFocus):
+        (WebCore::ChromeClientQt::canRunModal):
+        (WebCore::ChromeClientQt::mouseDidMoveOverElement):
+        * WebCoreSupport/DragClientQt.cpp:
+        (WebCore::DragClientQt::startDrag):
+        * WebCoreSupport/FrameLoaderClientQt.cpp:
+        (WebCore::FrameLoaderClientQt::createPlugin):
+        * WebCoreSupport/InspectorClientQt.cpp:
+        (WebCore::InspectorClientWebPage::createWindow):
+        (WebCore::InspectorClientView::InspectorClientView):
+        (WebCore::InspectorClientView::page):
+        (WebCore::InspectorClientView::hideEvent):
+        (WebCore::InspectorClientView::closeEvent):
+        (WebCore::InspectorClientQt::createPage):
+        (WebCore::InspectorClientQt::closeWindow):
+
 2008-01-04  Simon Hausmann  <hausmann@webkit.org>
 
         Reviewed by Lars.
index 7858ec858b420a4cb8552c1ee2c8f67c9504fed2..b9e00d6cbb258aba105dee023373e6897437657b 100644 (file)
@@ -70,7 +70,10 @@ FloatRect ChromeClientQt::windowRect()
     if (!m_webPage)
         return FloatRect();
 
-    return IntRect(m_webPage->topLevelWidget()->geometry());
+    QWidget* view = m_webPage->view();
+    if (!view)
+        return FloatRect();
+    return IntRect(view->topLevelWidget()->geometry());
 }
 
 
@@ -78,7 +81,7 @@ FloatRect ChromeClientQt::pageRect()
 {
     if (!m_webPage)
         return FloatRect();
-    return FloatRect(QRectF(m_webPage->rect()));
+    return FloatRect(QRectF(QPointF(0,0), m_webPage->viewportSize()));
 }
 
 
@@ -93,7 +96,11 @@ void ChromeClientQt::focus()
 {
     if (!m_webPage)
         return;
-    m_webPage->setFocus();
+    QWidget* view = m_webPage->view();
+    if (!view)
+        return;
+    
+    view->setFocus();
 }
 
 
@@ -101,21 +108,30 @@ void ChromeClientQt::unfocus()
 {
     if (!m_webPage)
         return;
-    m_webPage->clearFocus();
+    QWidget* view = m_webPage->view();
+    if (!view)
+        return;
+    view->clearFocus();
 }
 
 bool ChromeClientQt::canTakeFocus(FocusDirection)
 {
     if (!m_webPage)
         return false;
-    return m_webPage->focusPolicy() != Qt::NoFocus;
+    QWidget* view = m_webPage->view();
+    if (!view)
+        return false;
+    return view->focusPolicy() != Qt::NoFocus;
 }
 
 void ChromeClientQt::takeFocus(FocusDirection)
 {
     if (!m_webPage)
         return;
-    m_webPage->clearFocus();
+    QWidget* view = m_webPage->view();
+    if (!view)
+        return;
+    view->clearFocus();
 }
 
 
@@ -133,7 +149,10 @@ void ChromeClientQt::show()
 {
     if (!m_webPage)
         return;
-    m_webPage->topLevelWidget()->show();
+    QWidget* view = m_webPage->view();
+    if (!view)
+        return;
+    view->topLevelWidget()->show();
 }
 
 
@@ -285,7 +304,8 @@ void ChromeClientQt::addToDirtyRegion(const IntRect& r)
 
 void ChromeClientQt::scrollBackingStore(int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect)
 {
-    m_webPage->scroll(dx, dy, scrollViewRect);
+    // #### QWebPage
+    //m_webPage->scroll(dx, dy, scrollViewRect);
 }
 
 void ChromeClientQt::updateBackingStore()
index e270162f3514eab3b0160626062b8f05d49970fb..b7198684d00f8e324f59fa10f715a3041cef7f46 100644 (file)
@@ -62,9 +62,12 @@ void DragClientQt::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Cli
 #ifndef QT_NO_DRAGANDDROP
     QMimeData* clipboardData = static_cast<ClipboardQt*>(clipboard)->clipboardData();
     static_cast<ClipboardQt*>(clipboard)->invalidateWritableData();
-    QDrag *drag = new QDrag(m_webPage);
-    drag->setMimeData(clipboardData);
-    drag->start();
+    QWidget* view = m_webPage->view();
+    if (view) {
+        QDrag *drag = new QDrag(view);
+        drag->setMimeData(clipboardData);
+        drag->start();
+    }
 #endif
 }
 
index 99dbf5b84fe767160555fa308f311298f75e1b59..0d8056bbeee582214478de9123ea8a31f48ab58c 100644 (file)
@@ -950,8 +950,9 @@ Widget* FrameLoaderClientQt::createPlugin(const IntSize&, Element* element, cons
 
     if (object) {
         QWidget *widget = qobject_cast<QWidget *>(object);
-        if (widget) {
-            widget->setParent(m_webFrame->page());
+        QWidget *view = m_webFrame->page()->view();
+        if (widget && view) {
+            widget->setParent(view);
             Widget* w= new Widget();
             w->setQWidget(widget);
             return w;
index 847fcdb5906d0d7e8d09bcbeed3804a54967c11c..9968bd7cef4117c6778079ad9347dac2be753bb4 100644 (file)
 
 namespace WebCore {
 
-class InspectorClientWebPage : public QWebPage {
+class InspectorClientWebPage : public QWebPage
+{
 public:
-    InspectorClientWebPage(InspectorController* controller)
-        : QWebPage(0)
-        , m_controller(controller)
-    {}
-
     QWebPage* createWindow()
     {
-        return new QWebPage(0);
+        QWidget *w = new QWidget(0);
+        QWebPage *page = new QWebPage(w);
+        page->setView(w);
+        connect(page, SIGNAL(destroyed()), w, SLOT(deleteLater()));
+        return page;
+    }
+};
+    
+
+class InspectorClientView : public QWidget {
+public:
+    InspectorClientView(InspectorController* controller)
+        : QWidget(0)
+        , m_controller(controller)
+        , m_page(new InspectorClientWebPage)
+    {
+        m_page->setView(this);
+        connect(m_page, SIGNAL(destroyed()), SLOT(deleteLater()));
     }
 
+    QWebPage* page() const { return m_page; }
 protected:
     void hideEvent(QHideEvent* ev)
     {
-        QWebPage::hideEvent(ev);
+        QWidget::hideEvent(ev);
         m_controller->setWindowVisible(false);
     }
 
     void closeEvent(QCloseEvent* ev)
     {
-        QWebPage::closeEvent(ev);
+        QWidget::closeEvent(ev);
         m_controller->setWindowVisible(false);
     }
 
 private:
     InspectorController* m_controller;
+    QWebPage* m_page;
 };
 
+
 InspectorClientQt::InspectorClientQt(QWebPage* page)
     : m_inspectedWebPage(page)
     , m_attached(false)
@@ -85,9 +101,10 @@ Page* InspectorClientQt::createPage()
     if (m_webPage)
         return m_webPage->d->page;
 
-    m_webPage.set(new InspectorClientWebPage(m_inspectedWebPage->d->page->inspectorController()));
+    InspectorClientView* view = new InspectorClientView(m_inspectedWebPage->d->page->inspectorController());
+    m_webPage.set(view->page());
     m_webPage->mainFrame()->load(QString::fromLatin1("qrc:/webkit/inspector/inspector.html"));
-    m_webPage->setMinimumSize(400,300);
+    m_webPage->view()->setMinimumSize(400,300);
     return m_webPage->d->page;
 }
 
@@ -103,7 +120,7 @@ void InspectorClientQt::showWindow()
         return;
 
     updateWindowTitle();
-    m_webPage->show();
+    m_webPage->view()->show();
     m_inspectedWebPage->d->page->inspectorController()->setWindowVisible(true);
 }
 
@@ -112,7 +129,7 @@ void InspectorClientQt::closeWindow()
     if (!m_webPage)
         return;
 
-    m_webPage->hide();
+    m_webPage->view()->hide();
     m_inspectedWebPage->d->page->inspectorController()->setWindowVisible(false);
 }
 
@@ -120,7 +137,7 @@ bool InspectorClientQt::windowVisible()
 {
     if (!m_webPage)
         return false;
-    return m_webPage->isVisible();
+    return m_webPage->view()->isVisible();
 }
 
 void InspectorClientQt::attachWindow()
@@ -165,7 +182,7 @@ void InspectorClientQt::updateWindowTitle()
         return;
 
     QString caption = QCoreApplication::translate("QWebPage", "Web Inspector - %2");
-    m_webPage->setWindowTitle(caption.arg(m_inspectedURL));
+    m_webPage->view()->setWindowTitle(caption.arg(m_inspectedURL));
 }
 
 }
index 0bba4809f75e5adc3de99f5b42fb3e68c9299237..2e6799505bf57cea65627f3c937b5f161732dc5e 100644 (file)
@@ -1,3 +1,15 @@
+2008-01-04  Lars Knoll  <lars@trolltech.com>
+
+        Reviewed by Simon.
+
+        make QWebPage a QObject and get things to compile.
+        
+        Nothing works currently though.
+        
+
+        * DumpRenderTree/qt/DumpRenderTree.cpp:
+        (WebCore::DumpRenderTree::DumpRenderTree):
+
 2008-01-04  Lars Knoll  <lars@trolltech.com>
 
         Reviewed by Simon.
index 40716faa538475c55aada55de9b79d931ade4314..7044e9fc9b6c197428d0b8c117f4a5f50fc20f44 100644 (file)
@@ -114,7 +114,7 @@ DumpRenderTree::DumpRenderTree()
 
     m_page = new WebPage(0, this);
     connect(m_page, SIGNAL(frameCreated(QWebFrame *)), this, SLOT(connectFrame(QWebFrame *)));
-    m_page->resize(maxViewWidth, maxViewHeight);
+    m_page->setViewportSize(QSize(maxViewWidth, maxViewHeight));
     m_page->mainFrame()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     m_page->mainFrame()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     connect(m_page->mainFrame(), SIGNAL(titleChanged(const QString&)),