Holger Hans Peter Freyther <holger.freyther@trolltech.com>
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Apr 2008 08:44:34 +0000 (08:44 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Apr 2008 08:44:34 +0000 (08:44 +0000)
* Do not store the FrameView in the QWebFrame and cope with the situation when
  a WebCore::Frame has no WebCore::FrameView.

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

WebKit/qt/Api/qwebframe.cpp
WebKit/qt/Api/qwebframe_p.h
WebKit/qt/Api/qwebpage.cpp
WebKit/qt/ChangeLog
WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp

index ce91ca3..88e4518 100644 (file)
@@ -83,8 +83,7 @@ void QWebFramePrivate::init(QWebFrame *qframe, WebCore::Page *webcorePage, QWebF
     frame = new Frame(webcorePage, frameData->ownerElement, frameLoaderClient);
     frameLoaderClient->setFrame(qframe, frame.get());
 
-    frameView = new FrameView(frame.get());
-    frameView->deref();
+    FrameView* frameView = new FrameView(frame.get());
     frameView->setQWebFrame(qframe);
     if (!frameData->allowsScrolling)
         frameView->setScrollbarsMode(ScrollbarAlwaysOff);
@@ -95,6 +94,7 @@ void QWebFramePrivate::init(QWebFrame *qframe, WebCore::Page *webcorePage, QWebF
 
     frame->setView(frameView.get());
     frame->init();
+    frameView->deref();
 
     QObject::connect(q, SIGNAL(hoveringOverLink(const QString&, const QString&, const QString&)),
                      page, SIGNAL(hoveringOverLink(const QString&, const QString&, const QString&)));
@@ -102,14 +102,16 @@ void QWebFramePrivate::init(QWebFrame *qframe, WebCore::Page *webcorePage, QWebF
 
 WebCore::PlatformScrollbar *QWebFramePrivate::horizontalScrollBar() const
 {
-    Q_ASSERT(frameView);
-    return frameView->horizontalScrollBar();
+    if (!frame->view())
+        return 0;
+    return frame->view()->horizontalScrollBar();
 }
 
 WebCore::PlatformScrollbar *QWebFramePrivate::verticalScrollBar() const
 {
-    Q_ASSERT(frameView);
-    return frameView->verticalScrollBar();
+    if (!frame->view())
+        return 0;
+    return frame->view()->verticalScrollBar();
 }
 
 /*!
@@ -153,7 +155,6 @@ QWebFrame::QWebFrame(QWebFrame *parent, QWebFrameData *frameData)
 QWebFrame::~QWebFrame()
 {
     Q_ASSERT(d->frame == 0);
-    Q_ASSERT(d->frameView == 0);
     delete d;
 }
 
@@ -196,8 +197,8 @@ QString QWebFrame::markup() const
 */
 QString QWebFrame::innerText() const
 {
-    if (d->frameView->layoutPending())
-        d->frameView->layout();
+    if (d->frame->view() && d->frame->view()->layoutPending())
+        d->frame->view()->layout();
 
     Element *documentElement = d->frame->document()->documentElement();
     return documentElement->innerText();
@@ -208,8 +209,8 @@ QString QWebFrame::innerText() const
 */
 QString QWebFrame::renderTreeDump() const
 {
-    if (d->frameView->layoutPending())
-        d->frameView->layout();
+    if (d->frame->view() && d->frame->view()->layoutPending())
+        d->frame->view()->layout();
 
     return externalRepresentation(d->frame->renderer());
 }
@@ -451,7 +452,7 @@ QList<QWebFrame*> QWebFrame::childFrames() const
 */
 Qt::ScrollBarPolicy QWebFrame::verticalScrollBarPolicy() const
 {
-    return (Qt::ScrollBarPolicy) d->frameView->vScrollbarMode();
+    return d->verticalScrollBarPolicy;
 }
 
 void QWebFrame::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy)
@@ -459,7 +460,10 @@ void QWebFrame::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy)
     Q_ASSERT((int)ScrollbarAuto == (int)Qt::ScrollBarAsNeeded);
     Q_ASSERT((int)ScrollbarAlwaysOff == (int)Qt::ScrollBarAlwaysOff);
     Q_ASSERT((int)ScrollbarAlwaysOn == (int)Qt::ScrollBarAlwaysOn);
-    d->frameView->setVScrollbarMode((ScrollbarMode)policy);
+
+    d->verticalScrollBarPolicy = policy;
+    if (d->frame->view())
+        d->frame->view()->setVScrollbarMode((ScrollbarMode)policy);
 }
 
 /*!
@@ -471,12 +475,14 @@ void QWebFrame::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy)
 */
 Qt::ScrollBarPolicy QWebFrame::horizontalScrollBarPolicy() const
 {
-    return (Qt::ScrollBarPolicy) d->frameView->hScrollbarMode();
+    return d->horizontalScrollBarPolicy;
 }
 
 void QWebFrame::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy)
 {
-    d->frameView->setHScrollbarMode((ScrollbarMode)policy);
+    d->horizontalScrollBarPolicy = policy;
+    if (d->frame->view())
+        d->frame->view()->setHScrollbarMode((ScrollbarMode)policy);
 }
 
 /*!
@@ -484,15 +490,16 @@ void QWebFrame::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy)
 */
 void QWebFrame::render(QPainter *painter, const QRegion &clip)
 {
-    if (!d->frameView || !d->frame->renderer())
+    if (!d->frame->view() || !d->frame->renderer())
         return;
 
     layout();
 
     GraphicsContext ctx(painter);
     QVector<QRect> vector = clip.rects();
+    WebCore::FrameView* view = d->frame->view();
     for (int i = 0; i < vector.size(); ++i) 
-        d->frameView->paint(&ctx, vector.at(i));
+        view->paint(&ctx, vector.at(i));
 }
 
 /*!
@@ -500,10 +507,10 @@ void QWebFrame::render(QPainter *painter, const QRegion &clip)
 */
 void QWebFrame::layout()
 {
-    if (!d->frameView)
+    if (!d->frame->view())
         return;
 
-    d->frameView->layoutIfNeededRecursive();
+    d->frame->view()->layoutIfNeededRecursive();
 }
 
 /*!
@@ -511,8 +518,10 @@ void QWebFrame::layout()
 */
 QPoint QWebFrame::pos() const
 {
-    Q_ASSERT(d->frameView);
-    return d->pos();
+    if (!d->frame->view())
+        return QPoint();
+
+    return d->frame->view()->frameGeometry().topLeft();
 }
 
 /*!
@@ -520,8 +529,9 @@ QPoint QWebFrame::pos() const
 */
 QRect QWebFrame::geometry() const
 {
-    Q_ASSERT(d->frameView);
-    return d->frameView->frameGeometry();
+    if (!d->frame->view())
+        return QRect();
+    return d->frame->view()->frameGeometry();
 }
 
 /*!
index dbe3617..d5741c2 100644 (file)
@@ -27,7 +27,6 @@
 #include "qwebpage_p.h"
 
 #include "EventHandler.h"
-#include "FrameView.h"
 #include "KURL.h"
 #include "PlatformString.h"
 #include "wtf/RefPtr.h"
@@ -61,9 +60,10 @@ class QWebFramePrivate
 public:
     QWebFramePrivate()
         : q(0)
+        , horizontalScrollBarPolicy(Qt::ScrollBarAsNeeded)
+        , verticalScrollBarPolicy(Qt::ScrollBarAsNeeded)
         , frameLoaderClient(0)
         , frame(0)
-        , frameView(0)
         , page(0)
         {}
     void init(QWebFrame *qframe, WebCore::Page *page,
@@ -74,8 +74,8 @@ public:
     WebCore::PlatformScrollbar *horizontalScrollBar() const;
     WebCore::PlatformScrollbar *verticalScrollBar() const;
 
-    inline QPoint pos() const
-    { return frameView->frameGeometry().topLeft(); }
+    Qt::ScrollBarPolicy horizontalScrollBarPolicy;
+    Qt::ScrollBarPolicy verticalScrollBarPolicy; 
 
     static WebCore::Frame* core(QWebFrame*);
     static QWebFrame* kit(WebCore::Frame*);
@@ -83,7 +83,6 @@ public:
     QWebFrame *q;
     WebCore::FrameLoaderClientQt *frameLoaderClient;
     WTF::RefPtr<WebCore::Frame> frame;
-    WTF::RefPtr<WebCore::FrameView> frameView;
     QWebPage *page;
 };
 
index 5e2eaa5..ebe94c2 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "Frame.h"
 #include "FrameLoaderClientQt.h"
+#include "FrameView.h"
 #include "ChromeClientQt.h"
 #include "ContextMenu.h"
 #include "ContextMenuClientQt.h"
@@ -336,22 +337,38 @@ void QWebPagePrivate::updateEditorActions()
 
 void QWebPagePrivate::mouseMoveEvent(QMouseEvent *ev)
 {
-    QWebFramePrivate::core(mainFrame)->eventHandler()->mouseMoved(PlatformMouseEvent(ev, 0));
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    if (!frame->view())
+        return;
+
+    frame->eventHandler()->mouseMoved(PlatformMouseEvent(ev, 0));
 }
 
 void QWebPagePrivate::mousePressEvent(QMouseEvent *ev)
 {
-    QWebFramePrivate::core(mainFrame)->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 1));
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    if (!frame->view())
+        return;
+
+    frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 1));
 }
 
 void QWebPagePrivate::mouseDoubleClickEvent(QMouseEvent *ev)
 {
-    QWebFramePrivate::core(mainFrame)->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 2));
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    if (!frame->view())
+        return;
+
+    frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 2));
 }
 
 void QWebPagePrivate::mouseReleaseEvent(QMouseEvent *ev)
 {
-    QWebFramePrivate::core(mainFrame)->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    if (!frame->view())
+        return;
+
+    frame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
 }
 
 void QWebPagePrivate::contextMenuEvent(QContextMenuEvent *ev)
@@ -381,8 +398,12 @@ void QWebPagePrivate::contextMenuEvent(QContextMenuEvent *ev)
 
 void QWebPagePrivate::wheelEvent(QWheelEvent *ev)
 {
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    if (!frame->view())
+        return;
+
     WebCore::PlatformWheelEvent pev(ev);
-    bool accepted = QWebFramePrivate::core(mainFrame)->eventHandler()->handleWheelEvent(pev);
+    bool accepted = frame->eventHandler()->handleWheelEvent(pev);
     ev->setAccepted(accepted);
 }
 
@@ -1035,8 +1056,8 @@ void QWebPage::triggerAction(WebAction action, bool checked)
 QSize QWebPage::viewportSize() const
 {
     QWebFrame *frame = mainFrame();
-    if (frame->d->frame && frame->d->frameView)
-        return frame->d->frameView->frameGeometry().size();
+    if (frame->d->frame && frame->d->frame->view())
+        return frame->d->frame->view()->frameGeometry().size();
     return QSize(0, 0);
 }
 
@@ -1049,10 +1070,11 @@ QSize QWebPage::viewportSize() const
 void QWebPage::setViewportSize(const QSize &size) const
 {
     QWebFrame *frame = mainFrame();
-    if (frame->d->frame && frame->d->frameView) {
-        frame->d->frameView->setFrameGeometry(QRect(QPoint(0, 0), size));
+    if (frame->d->frame && frame->d->frame->view()) {
+        WebCore::FrameView* view = frame->d->frame->view();
+        view->setFrameGeometry(QRect(QPoint(0, 0), size));
         frame->d->frame->forceLayout();
-        frame->d->frame->view()->adjustViewSize();
+        view->adjustViewSize();
     }
 }
 
index 027a122..6d8254f 100644 (file)
@@ -2,6 +2,37 @@
 
         Reviewed by Simon.
 
+        * Do not store the FrameView in the QWebFrame and cope with the situation when
+        a WebCore::Frame has no WebCore::FrameView.
+        
+
+        * Api/qwebframe.cpp:
+        (QWebFramePrivate::init):
+        (QWebFramePrivate::horizontalScrollBar):
+        (QWebFramePrivate::verticalScrollBar):
+        (QWebFrame::innerText):
+        (QWebFrame::renderTreeDump):
+        (QWebFrame::setVerticalScrollBarPolicy):
+        (QWebFrame::setHorizontalScrollBarPolicy):
+        (QWebFrame::render):
+        (QWebFrame::layout):
+        (QWebFrame::pos):
+        * Api/qwebframe_p.h:
+        (QWebFramePrivate::QWebFramePrivate):
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::updateEditorActions):
+        (QWebPagePrivate::mouseMoveEvent):
+        (QWebPagePrivate::mousePressEvent):
+        (QWebPagePrivate::mouseDoubleClickEvent):
+        (QWebPagePrivate::contextMenuEvent):
+        (QWebPagePrivate::wheelEvent):
+        (QWebPage::triggerAction):
+        * WebCoreSupport/FrameLoaderClientQt.cpp:
+
+2008-04-01  Holger Hans Peter Freyther  <holger.freyther@trolltech.com>
+
+        Reviewed by Simon.
+
         * Change the order of the methods to match with the FrameLoaderClient.h to ease
         removing methods in the future.
 
index 8cd6838..f086eb2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2006 Zack Rusin <zack@kde.org>
  * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
- * Copyright (C) 2007 Trolltech ASA
+ * Copyright (C) 2007-2008 Trolltech ASA
  *
  * All rights reserved.
  *
@@ -163,8 +163,7 @@ void FrameLoaderClientQt::makeRepresentation(DocumentLoader*)
 
 void FrameLoaderClientQt::forceLayout()
 {
-    m_frame->view()->setNeedsLayout();
-    m_frame->view()->layout();
+    m_frame->forceLayout(true);
 }
 
 
@@ -194,7 +193,6 @@ void FrameLoaderClientQt::detachedFromParent4()
     if (!m_webFrame)
         return;
     m_webFrame->d->frame = 0;
-    m_webFrame->d->frameView = 0;
     m_webFrame = 0;
     m_frame = 0;
 }