[Qt] Move away from QPointer as it is slow and it has a replacement QWeakPointer.
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Sep 2011 01:55:23 +0000 (01:55 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Sep 2011 01:55:23 +0000 (01:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=67673

Reviewed by Ariya Hidayat.

Source/WebCore:

Move away from QPointer to QWeakPointer, it is faster.

No new tests, the existing ones should cover.

* bridge/qt/qt_instance.cpp:
(JSC::Bindings::QtInstance::~QtInstance):
(JSC::Bindings::QtInstance::getClass):
(JSC::Bindings::QtField::name):
(JSC::Bindings::QtField::valueFromInstance):
* bridge/qt/qt_instance.h:
(JSC::Bindings::QtInstance::getObject):
* bridge/qt/qt_runtime.h:
* platform/qt/SharedTimerQt.cpp:
(WebCore::SharedTimerQt::inst):

Source/WebKit/qt:

Move away from QPointer as Qt provides a better and faster solution : QWeakPointer.

* Api/qwebframe.cpp:
(QWebHitTestResult::linkTargetFrame):
(QWebHitTestResult::frame):
* Api/qwebframe_p.h:
* Api/qwebpage.cpp:
(QWebPagePrivate::QWebPagePrivate):
(QWebPagePrivate::~QWebPagePrivate):
(QWebPagePrivate::acceptNavigationRequest):
(QWebPagePrivate::createMainFrame):
(QWebPagePrivate::updateAction):
(QWebPagePrivate::mouseMoveEvent):
(QWebPagePrivate::mousePressEvent):
(QWebPagePrivate::mouseDoubleClickEvent):
(QWebPagePrivate::mouseTripleClickEvent):
(QWebPagePrivate::mouseReleaseEvent):
(QWebPage::createStandardContextMenu):
(QWebPagePrivate::wheelEvent):
(QWebPagePrivate::focusInEvent):
(QWebPage::setPalette):
(QWebPagePrivate::touchEvent):
(QWebPage::~QWebPage):
(QWebPage::mainFrame):
(QWebPage::viewportSize):
(QWebPage::preferredContentsSize):
(QWebPage::setContentEditable):
(QWebPage::updatePositionDependentActions):
* Api/qwebpage_p.h:
* Api/qwebview.cpp:
* WebCoreSupport/DumpRenderTreeSupportQt.cpp:
(DumpRenderTreeSupportQt::contextMenu):
* WebCoreSupport/FrameLoaderClientQt.cpp:
(WebCore::FrameLoaderClientQt::createFrame):
* tests/qwebframe/tst_qwebframe.cpp:
(tst_QWebFrame::ownership):
* tests/qwebpage/tst_qwebpage.cpp:
(PluginCounterPage::PluginCounterPage):
(PluginTracerPage::createPlugin):
(tst_QWebPage::createViewlessPlugin):
* tests/qwebview/tst_qwebview.cpp:
(tst_QWebView::reusePage):

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

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bridge/qt/qt_instance.cpp
Source/WebCore/bridge/qt/qt_instance.h
Source/WebCore/bridge/qt/qt_runtime.h
Source/WebCore/platform/qt/SharedTimerQt.cpp
Source/WebKit/qt/Api/qwebframe.cpp
Source/WebKit/qt/Api/qwebframe_p.h
Source/WebKit/qt/Api/qwebpage.cpp
Source/WebKit/qt/Api/qwebpage_p.h
Source/WebKit/qt/Api/qwebview.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp

index f9d4272..74b7446 100644 (file)
@@ -1,3 +1,25 @@
+2011-09-06  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt] Move away from QPointer as it is slow and it has a replacement QWeakPointer.
+        https://bugs.webkit.org/show_bug.cgi?id=67673
+
+        Reviewed by Ariya Hidayat.
+
+        Move away from QPointer to QWeakPointer, it is faster.
+
+        No new tests, the existing ones should cover.
+
+        * bridge/qt/qt_instance.cpp:
+        (JSC::Bindings::QtInstance::~QtInstance):
+        (JSC::Bindings::QtInstance::getClass):
+        (JSC::Bindings::QtField::name):
+        (JSC::Bindings::QtField::valueFromInstance):
+        * bridge/qt/qt_instance.h:
+        (JSC::Bindings::QtInstance::getObject):
+        * bridge/qt/qt_runtime.h:
+        * platform/qt/SharedTimerQt.cpp:
+        (WebCore::SharedTimerQt::inst):
+
 2011-09-06  Oliver Hunt  <oliver@apple.com>
 
         Update expected results of bindings tests.
index 691b42e..9899160 100644 (file)
@@ -116,11 +116,11 @@ QtInstance::~QtInstance()
         case QScriptEngine::QtOwnership:
             break;
         case QScriptEngine::AutoOwnership:
-            if (m_object->parent())
+            if (m_object.data()->parent())
                 break;
             // fall through!
         case QScriptEngine::ScriptOwnership:
-            delete m_object;
+            delete m_object.data();
             break;
         }
     }
@@ -182,7 +182,7 @@ Class* QtInstance::getClass() const
     if (!m_class) {
         if (!m_object)
             return 0;
-        m_class = QtClass::classForObject(m_object);
+        m_class = QtClass::classForObject(m_object.data());
     }
     return m_class;
 }
@@ -342,7 +342,7 @@ QByteArray QtField::name() const
     if (m_type == MetaProperty)
         return m_property.name();
     if (m_type == ChildObject && m_childObject)
-        return m_childObject->objectName().toLatin1();
+        return m_childObject.data()->objectName().toLatin1();
 #ifndef QT_NO_PROPERTIES
     if (m_type == DynamicProperty)
         return m_dynamicProperty;
@@ -363,7 +363,7 @@ JSValue QtField::valueFromInstance(ExecState* exec, const Instance* inst) const
             else
                 return jsUndefined();
         } else if (m_type == ChildObject)
-            val = QVariant::fromValue((QObject*) m_childObject);
+            val = QVariant::fromValue((QObject*) m_childObject.data());
 #ifndef QT_NO_PROPERTIES
         else if (m_type == DynamicProperty)
             val = obj->property(m_dynamicProperty);
index 3ee0caf..fa1fd1f 100644 (file)
@@ -23,9 +23,9 @@
 #include "BridgeJSC.h"
 #include "runtime_root.h"
 #include <QStack>
+#include <QWeakPointer>
 #include <QtScript/qscriptengine.h>
 #include <qhash.h>
-#include <qpointer.h>
 #include <qset.h>
 
 namespace JSC {
@@ -60,7 +60,7 @@ public:
     JSValue numberValue(ExecState* exec) const;
     JSValue booleanValue() const;
 
-    QObject* getObject() const { return m_object; }
+    QObject* getObject() const { return m_object.data(); }
     QObject* hashKey() const { return m_hashkey; }
 
     static PassRefPtr<QtInstance> getQtInstance(QObject*, PassRefPtr<RootObject>, QScriptEngine::ValueOwnership ownership);
@@ -94,7 +94,7 @@ private:
     friend class QtField;
     QtInstance(QObject*, PassRefPtr<RootObject>, QScriptEngine::ValueOwnership ownership); // Factory produced only..
     mutable QtClass* m_class;
-    QPointer<QObject> m_object;
+    QWeakPointer<QObject> m_object;
     QObject* m_hashkey;
     mutable QHash<QByteArray, WriteBarrier<JSObject> > m_methods;
     mutable QHash<QString, QtField*> m_fields;
index aad290c..dea67d3 100644 (file)
 #include "qt_instance.h"
 #include "runtime_method.h"
 
+#include <QWeakPointer>
+
 #include <qbytearray.h>
 #include <qmetaobject.h>
-#include <qpointer.h>
 #include <qvariant.h>
 
 namespace JSC {
@@ -68,7 +69,7 @@ private:
     QtFieldType m_type;
     QByteArray m_dynamicProperty;
     QMetaProperty m_property;
-    QPointer<QObject> m_childObject;
+    QWeakPointer<QObject> m_childObject;
 };
 
 
index 258cf3d..b872849 100644 (file)
@@ -33,7 +33,7 @@
 #include <QBasicTimer>
 #include <QCoreApplication>
 #include <QDebug>
-#include <QPointer>
+#include <QWeakPointer>
 #include <wtf/CurrentTime.h>
 
 namespace WebCore {
@@ -83,13 +83,13 @@ void SharedTimerQt::destroy()
 
 SharedTimerQt* SharedTimerQt::inst()
 {
-    static QPointer<SharedTimerQt> timer;
+    static QWeakPointer<SharedTimerQt> timer;
     if (!timer) {
         timer = new SharedTimerQt();
-        timer->connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(destroy()));
+        timer.data()->connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(destroy()));
     }
 
-    return timer;
+    return timer.data();
 }
 
 void SharedTimerQt::start(double interval)
index a0a2f3e..5f12e10 100644 (file)
@@ -1924,7 +1924,7 @@ QWebFrame *QWebHitTestResult::linkTargetFrame() const
 {
     if (!d)
         return 0;
-    return d->linkTargetFrame;
+    return d->linkTargetFrame.data();
 }
 
 /*!
@@ -1997,7 +1997,7 @@ QWebFrame *QWebHitTestResult::frame() const
 {
     if (!d)
         return 0;
-    return d->frame;
+    return d->frame.data();
 }
 
 #include "moc_qwebframe.cpp"
index 3763fe8..1e12259 100644 (file)
@@ -148,7 +148,7 @@ public:
     QString linkText;
     QUrl linkUrl;
     QString linkTitle;
-    QPointer<QWebFrame> linkTargetFrame;
+    QWeakPointer<QWebFrame> linkTargetFrame;
     QWebElement linkElement;
     QString alternateText;
     QUrl imageUrl;
@@ -156,7 +156,7 @@ public:
     bool isContentEditable;
     bool isContentSelected;
     bool isScrollBar;
-    QPointer<QWebFrame> frame;
+    QWeakPointer<QWebFrame> frame;
     RefPtr<WebCore::Node> innerNode;
     RefPtr<WebCore::Node> innerNonSharedNode;
 };
index 286fb95..b2374b6 100644 (file)
@@ -293,7 +293,6 @@ static inline Qt::DropAction dragOpToDropAction(unsigned actions)
 QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
     : q(qq)
     , page(0)
-    , mainFrame(0)
 #ifndef QT_NO_UNDOSTACK
     , undoStack(0)
 #endif
@@ -307,9 +306,6 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
     , selectTrailingWhitespaceEnabled(false)
     , linkPolicy(QWebPage::DontDelegateLinks)
     , viewportSize(QSize(0, 0))
-#ifndef QT_NO_CONTEXTMENU
-    , currentContextMenu(0)
-#endif
     , settings(0)
     , useFixedLayout(false)
     , pluginFactory(0)
@@ -379,7 +375,7 @@ QWebPagePrivate::~QWebPagePrivate()
         setInspector(0);
     }
 #ifndef QT_NO_CONTEXTMENU
-    delete currentContextMenu;
+    delete currentContextMenu.data();
 #endif
 #ifndef QT_NO_UNDOSTACK
     delete undoStack;
@@ -413,7 +409,7 @@ QWebPagePrivate* QWebPagePrivate::priv(QWebPage* page)
 bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
 {
     if (insideOpenCall
-        && frame == mainFrame)
+        && frame == mainFrame.data())
         return true;
     return q->acceptNavigationRequest(frame, request, type);
 }
@@ -424,7 +420,7 @@ void QWebPagePrivate::createMainFrame()
         QWebFrameData frameData(page);
         mainFrame = new QWebFrame(q, &frameData);
 
-        emit q->frameCreated(mainFrame);
+        emit q->frameCreated(mainFrame.data());
     }
 }
 
@@ -546,7 +542,7 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action)
     if (!a || !mainFrame)
         return;
 
-    WebCore::FrameLoader *loader = mainFrame->d->frame->loader();
+    WebCore::FrameLoader *loader = mainFrame.data()->d->frame->loader();
     WebCore::Editor *editor = page->focusController()->focusedOrMainFrame()->editor();
 
     bool enabled = a->isEnabled();
@@ -679,7 +675,7 @@ void QWebPagePrivate::timerEvent(QTimerEvent *ev)
 template<class T>
 void QWebPagePrivate::mouseMoveEvent(T* ev)
 {
-    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
     if (!frame->view())
         return;
 
@@ -690,7 +686,7 @@ void QWebPagePrivate::mouseMoveEvent(T* ev)
 template<class T>
 void QWebPagePrivate::mousePressEvent(T* ev)
 {
-    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
     if (!frame->view())
         return;
 
@@ -726,7 +722,7 @@ void QWebPagePrivate::mousePressEvent(T* ev)
 template<class T>
 void QWebPagePrivate::mouseDoubleClickEvent(T *ev)
 {
-    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
     if (!frame->view())
         return;
 
@@ -744,7 +740,7 @@ void QWebPagePrivate::mouseDoubleClickEvent(T *ev)
 template<class T>
 void QWebPagePrivate::mouseTripleClickEvent(T *ev)
 {
-    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
     if (!frame->view())
         return;
 
@@ -782,7 +778,7 @@ void QWebPagePrivate::handleClipboard(QEvent* ev, Qt::MouseButton button)
 template<class T>
 void QWebPagePrivate::mouseReleaseEvent(T *ev)
 {
-    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
     if (!frame->view())
         return;
 
@@ -842,8 +838,8 @@ void QWebPagePrivate::contextMenuEvent(const QPoint& globalPos)
 QMenu *QWebPage::createStandardContextMenu()
 {
 #ifndef QT_NO_CONTEXTMENU
-    QMenu *menu = d->currentContextMenu;
-    d->currentContextMenu = 0;
+    QMenu* menu = d->currentContextMenu.data();
+    d->currentContextMenu.clear();
     return menu;
 #else
     return 0;
@@ -854,7 +850,7 @@ QMenu *QWebPage::createStandardContextMenu()
 template<class T>
 void QWebPagePrivate::wheelEvent(T *ev)
 {
-    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
     if (!frame->view())
         return;
 
@@ -975,7 +971,7 @@ void QWebPagePrivate::focusInEvent(QFocusEvent*)
     focusController->setActive(true);
     focusController->setFocused(true);
     if (!focusController->focusedFrame())
-        focusController->setFocusedFrame(QWebFramePrivate::core(mainFrame));
+        focusController->setFocusedFrame(QWebFramePrivate::core(mainFrame.data()));
 }
 
 void QWebPagePrivate::focusOutEvent(QFocusEvent*)
@@ -1057,12 +1053,12 @@ void QWebPagePrivate::leaveEvent(QEvent*)
 void QWebPage::setPalette(const QPalette &pal)
 {
     d->palette = pal;
-    if (!d->mainFrame || !d->mainFrame->d->frame->view())
+    if (!d->mainFrame || !d->mainFrame.data()->d->frame->view())
         return;
 
     QBrush brush = pal.brush(QPalette::Base);
     QColor backgroundColor = brush.style() == Qt::SolidPattern ? brush.color() : QColor();
-    QWebFramePrivate::core(d->mainFrame)->view()->updateBackgroundRecursively(backgroundColor, !backgroundColor.alpha());
+    QWebFramePrivate::core(d->mainFrame.data())->view()->updateBackgroundRecursively(backgroundColor, !backgroundColor.alpha());
 }
 
 QPalette QWebPage::palette() const
@@ -1376,7 +1372,7 @@ void QWebPagePrivate::adjustPointForClicking(QGraphicsSceneMouseEvent* ev)
 bool QWebPagePrivate::touchEvent(QTouchEvent* event)
 {
 #if ENABLE(TOUCH_EVENTS)
-    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
     if (!frame->view())
         return false;
 
@@ -1984,7 +1980,7 @@ QWebPage::QWebPage(QObject *parent)
 QWebPage::~QWebPage()
 {
     d->createMainFrame();
-    FrameLoader *loader = d->mainFrame->d->frame->loader();
+    FrameLoader* loader = d->mainFrame.data()->d->frame->loader();
     if (loader)
         loader->detachFromParent();
     delete d;
@@ -2001,7 +1997,7 @@ QWebPage::~QWebPage()
 QWebFrame *QWebPage::mainFrame() const
 {
     d->createMainFrame();
-    return d->mainFrame;
+    return d->mainFrame.data();
 }
 
 /*!
@@ -2447,8 +2443,8 @@ void QWebPage::triggerAction(WebAction action, bool)
 
 QSize QWebPage::viewportSize() const
 {
-    if (d->mainFrame && d->mainFrame->d->frame->view())
-        return d->mainFrame->d->frame->view()->frameRect().size();
+    if (d->mainFrame && d->mainFrame.data()->d->frame->view())
+        return d->mainFrame.data()->d->frame->view()->frameRect().size();
 
     return d->viewportSize;
 }
@@ -2575,11 +2571,11 @@ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& av
 
 QSize QWebPage::preferredContentsSize() const
 {
-    QWebFrame* frame = d->mainFrame;
+    QWebFrame* frame = d->mainFrame.data();
     if (frame) {
         WebCore::FrameView* view = frame->d->frame->view();
         if (view && view->useFixedLayout())
-            return d->mainFrame->d->frame->view()->fixedLayoutSize();
+            return d->mainFrame.data()->d->frame->view()->fixedLayoutSize();
     }
 
     return d->fixedLayoutSize;
@@ -3199,7 +3195,7 @@ void QWebPage::setContentEditable(bool editable)
         d->page->setEditable(editable);
         d->page->setTabKeyCyclesThroughElements(!editable);
         if (d->mainFrame) {
-            WebCore::Frame* frame = d->mainFrame->d->frame;
+            WebCore::Frame* frame = d->mainFrame.data()->d->frame;
             if (editable) {
                 frame->editor()->applyEditingStyleToBodyElement();
                 // FIXME: mac port calls this if there is no selectedDOMRange
@@ -3323,7 +3319,7 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos)
     QBitArray visitedWebActions(QWebPage::WebActionCount);
 
 #ifndef QT_NO_CONTEXTMENU
-    delete d->currentContextMenu;
+    delete d->currentContextMenu.data();
 
     // Then we let createContextMenu() enable the actions that are put into the menu
     d->currentContextMenu = d->createContextMenu(d->page->contextMenuController()->contextMenu(), d->page->contextMenuController()->contextMenu()->platformDescription(), &visitedWebActions);
index 3c00e52..3e12655 100644 (file)
 #ifndef QWEBPAGE_P_H
 #define QWEBPAGE_P_H
 
+#include <QWeakPointer>
+
 #include <qbasictimer.h>
 #include <qnetworkproxy.h>
-#include <qpointer.h>
 #include <qevent.h>
 #include <qgraphicssceneevent.h>
 
@@ -164,7 +165,7 @@ public:
     QWebPage *q;
     WebCore::Page *page;
     OwnPtr<QWebPageClient> client;
-    QPointer<QWebFrame> mainFrame;
+    QWeakPointer<QWebFrame> mainFrame;
 
 #ifndef QT_NO_UNDOSTACK
     QUndoStack *undoStack;
@@ -195,7 +196,7 @@ public:
     QWebHistory history;
     QWebHitTestResult hitTestResult;
 #ifndef QT_NO_CONTEXTMENU
-    QPointer<QMenu> currentContextMenu;
+    QWeakPointer<QMenu> currentContextMenu;
 #endif
     QWebSettings *settings;
     QPalette palette;
index 76b927b..56820d2 100644 (file)
@@ -203,7 +203,7 @@ protected:
 
     QWebView* m_view;
     bool m_ignoreEvents;
-    QPointer<QWebFrame> m_frame;
+    QWeakPointer<QWebFrame> m_frame;
     Qt::ScrollBarPolicy m_oldVerticalScrollBarPolicy;
     Qt::ScrollBarPolicy m_oldHorizontalScrollBarPolicy;
 };
index 5169744..3d14e78 100644 (file)
@@ -1,5 +1,55 @@
 2011-09-06  Alexis Menard  <alexis.menard@openbossa.org>
 
+        [Qt] Move away from QPointer as it is slow and it has a replacement QWeakPointer.
+        https://bugs.webkit.org/show_bug.cgi?id=67673
+
+        Reviewed by Ariya Hidayat.
+
+        Move away from QPointer as Qt provides a better and faster solution : QWeakPointer.
+
+        * Api/qwebframe.cpp:
+        (QWebHitTestResult::linkTargetFrame):
+        (QWebHitTestResult::frame):
+        * Api/qwebframe_p.h:
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::QWebPagePrivate):
+        (QWebPagePrivate::~QWebPagePrivate):
+        (QWebPagePrivate::acceptNavigationRequest):
+        (QWebPagePrivate::createMainFrame):
+        (QWebPagePrivate::updateAction):
+        (QWebPagePrivate::mouseMoveEvent):
+        (QWebPagePrivate::mousePressEvent):
+        (QWebPagePrivate::mouseDoubleClickEvent):
+        (QWebPagePrivate::mouseTripleClickEvent):
+        (QWebPagePrivate::mouseReleaseEvent):
+        (QWebPage::createStandardContextMenu):
+        (QWebPagePrivate::wheelEvent):
+        (QWebPagePrivate::focusInEvent):
+        (QWebPage::setPalette):
+        (QWebPagePrivate::touchEvent):
+        (QWebPage::~QWebPage):
+        (QWebPage::mainFrame):
+        (QWebPage::viewportSize):
+        (QWebPage::preferredContentsSize):
+        (QWebPage::setContentEditable):
+        (QWebPage::updatePositionDependentActions):
+        * Api/qwebpage_p.h:
+        * Api/qwebview.cpp:
+        * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
+        (DumpRenderTreeSupportQt::contextMenu):
+        * WebCoreSupport/FrameLoaderClientQt.cpp:
+        (WebCore::FrameLoaderClientQt::createFrame):
+        * tests/qwebframe/tst_qwebframe.cpp:
+        (tst_QWebFrame::ownership):
+        * tests/qwebpage/tst_qwebpage.cpp:
+        (PluginCounterPage::PluginCounterPage):
+        (PluginTracerPage::createPlugin):
+        (tst_QWebPage::createViewlessPlugin):
+        * tests/qwebview/tst_qwebview.cpp:
+        (tst_QWebView::reusePage):
+
+2011-09-06  Alexis Menard  <alexis.menard@openbossa.org>
+
         [Qt] Fix API test failure after r92823 and r93001.
         https://bugs.webkit.org/show_bug.cgi?id=67676
 
index f4a1596..ead5ac2 100644 (file)
@@ -1057,7 +1057,7 @@ static QStringList iterateContextMenu(QMenu* menu)
 QStringList DumpRenderTreeSupportQt::contextMenu(QWebPage* page)
 {
 #ifndef QT_NO_CONTEXTMENU
-    return iterateContextMenu(page->d->currentContextMenu);
+    return iterateContextMenu(page->d->currentContextMenu.data());
 #else
     return QStringList();
 #endif
index 92bdbde..ae9b5f6 100644 (file)
@@ -1320,15 +1320,15 @@ PassRefPtr<Frame> FrameLoaderClientQt::createFrame(const KURL& url, const String
     frameData.marginWidth = marginWidth;
     frameData.marginHeight = marginHeight;
 
-    QPointer<QWebFrame> webFrame = new QWebFrame(m_webFrame, &frameData);
+    QWeakPointer<QWebFrame> webFrame = new QWebFrame(m_webFrame, &frameData);
     // The creation of the frame may have run arbitrary JavaScript that removed it from the page already.
-    if (!webFrame->d->frame->page()) {
+    if (!webFrame.data()->d->frame->page()) {
         frameData.frame.release();
-        ASSERT(webFrame.isNull());
+        ASSERT(webFrame.data().isNull());
         return 0;
     }
 
-    emit m_webFrame->page()->frameCreated(webFrame);
+    emit m_webFrame->page()->frameCreated(webFrame.data());
 
     // FIXME: Set override encoding if we have one.
 
index c0c4a35..8e98dfa 100644 (file)
@@ -2773,26 +2773,26 @@ void tst_QWebFrame::ownership()
 {
     // test ownership
     {
-        QPointer<QObject> ptr = new QObject();
+        QWeakPointer<QObject> ptr = new QObject();
         QVERIFY(ptr != 0);
         {
             QWebPage page;
             QWebFrame* frame = page.mainFrame();
-            frame->addToJavaScriptWindowObject("test", ptr, QScriptEngine::ScriptOwnership);
+            frame->addToJavaScriptWindowObject("test", ptr.data(), QScriptEngine::ScriptOwnership);
         }
         QVERIFY(ptr == 0);
     }
     {
-        QPointer<QObject> ptr = new QObject();
+        QWeakPointer<QObject> ptr = new QObject();
         QVERIFY(ptr != 0);
-        QObject* before = ptr;
+        QObject* before = ptr.data();
         {
             QWebPage page;
             QWebFrame* frame = page.mainFrame();
-            frame->addToJavaScriptWindowObject("test", ptr, QScriptEngine::QtOwnership);
+            frame->addToJavaScriptWindowObject("test", ptr.data(), QScriptEngine::QtOwnership);
         }
-        QVERIFY(ptr == before);
-        delete ptr;
+        QVERIFY(ptr.data() == before);
+        delete ptr.data();
     }
     {
         QObject* parent = new QObject();
@@ -2807,24 +2807,24 @@ void tst_QWebFrame::ownership()
         QCOMPARE(qvariant_cast<QObject*>(v), (QObject *)0);
     }
     {
-        QPointer<QObject> ptr = new QObject();
+        QWeakPointer<QObject> ptr = new QObject();
         QVERIFY(ptr != 0);
         {
             QWebPage page;
             QWebFrame* frame = page.mainFrame();
-            frame->addToJavaScriptWindowObject("test", ptr, QScriptEngine::AutoOwnership);
+            frame->addToJavaScriptWindowObject("test", ptr.data(), QScriptEngine::AutoOwnership);
         }
         // no parent, so it should be like ScriptOwnership
         QVERIFY(ptr == 0);
     }
     {
         QObject* parent = new QObject();
-        QPointer<QObject> child = new QObject(parent);
+        QWeakPointer<QObject> child = new QObject(parent);
         QVERIFY(child != 0);
         {
             QWebPage page;
             QWebFrame* frame = page.mainFrame();
-            frame->addToJavaScriptWindowObject("test", child, QScriptEngine::AutoOwnership);
+            frame->addToJavaScriptWindowObject("test", child.data(), QScriptEngine::AutoOwnership);
         }
         // has parent, so it should be like QtOwnership
         QVERIFY(child != 0);
index b1d855f..552f0bf 100644 (file)
@@ -374,7 +374,7 @@ public:
     TestPage(QObject* parent = 0) : QWebPage(parent) {}
 
     struct Navigation {
-        QPointer<QWebFrame> frame;
+        QWeakPointer<QWebFrame> frame;
         QNetworkRequest request;
         NavigationType type;
     };
@@ -846,12 +846,11 @@ void tst_QWebPage::createPluginWithPluginsDisabled()
 class PluginCounterPage : public QWebPage {
 public:
     int m_count;
-    QPointer<QObject> m_widget;
+    QWeakPointer<QObject> m_widget;
     QObject* m_pluginParent;
     PluginCounterPage(QObject* parent = 0)
         : QWebPage(parent)
         , m_count(0)
-        , m_widget(0)
         , m_pluginParent(0)
     {
        settings()->setAttribute(QWebSettings::PluginsEnabled, true);
@@ -881,7 +880,7 @@ public:
         // which also takes a QWidget* instead of a QObject*. Therefore we need to
         // upcast to T*, which is a QWidget.
         static_cast<T*>(m_widget.data())->setParent(static_cast<T*>(m_pluginParent));
-        return m_widget;
+        return m_widget.data();
     }
 };
 
@@ -948,7 +947,7 @@ void tst_QWebPage::createViewlessPlugin()
     QCOMPARE(page->m_count, 1);
     QVERIFY(page->m_widget);
     QVERIFY(page->m_pluginParent);
-    QVERIFY(page->m_widget->parent() == page->m_pluginParent);
+    QVERIFY(page->m_widget.data()->parent() == page->m_pluginParent);
     delete page;
 
 }
index 2b0a9f5..d27d2cb 100644 (file)
@@ -146,10 +146,10 @@ void tst_QWebView::reusePage()
 
     QFETCH(QString, html);
     QWebView* view1 = new QWebView;
-    QPointer<QWebPage> page = new QWebPage;
-    view1->setPage(page);
-    page->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
-    QWebFrame* mainFrame = page->mainFrame();
+    QWeakPointer<QWebPage> page = new QWebPage;
+    view1->setPage(page.data());
+    page.data()->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
+    QWebFrame* mainFrame = page.data()->mainFrame();
     mainFrame->setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR));
     if (html.contains("</embed>")) {
         // some reasonable time for the PluginStream to feed test.swf to flash and start painting
@@ -162,12 +162,12 @@ void tst_QWebView::reusePage()
     QVERIFY(page != 0); // deleting view must not have deleted the page, since it's not a child of view
 
     QWebView *view2 = new QWebView;
-    view2->setPage(page);
+    view2->setPage(page.data());
     view2->show(); // in Windowless mode, you should still be able to see the plugin here
     QTest::qWaitForWindowShown(view2);
     delete view2;
 
-    delete page; // must not crash
+    delete page.data(); // must not crash
 
     QDir::setCurrent(QApplication::applicationDirPath());
 }