Don't set up connections inside QWebPage::createFrame, as users might be reimplementi...
authorlars <lars@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2007 13:58:19 +0000 (13:58 +0000)
committerlars <lars@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2007 13:58:19 +0000 (13:58 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@26164 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/Api/qwebpage.cpp
WebKit/qt/ChangeLog
WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp
WebKitTools/DumpRenderTree/qt/DumpRenderTree.h
WebKitTools/DumpRenderTree/qt/jsobjects.cpp
WebKitTools/DumpRenderTree/qt/jsobjects.h

index 25a59be268ee126ea45dc303c2e28660da84897c..9d4561298a39904f08b81e67868dcd58789b374a 100644 (file)
@@ -107,6 +107,11 @@ void QWebPagePrivate::createMainFrame()
         frameData.marginWidth = 0;
         frameData.marginHeight = 0;
         mainFrame = q->createFrame(0, &frameData);
+        QObject::connect(mainFrame, SIGNAL(titleChanged(const QString&)),
+                q, SIGNAL(titleChanged(const QString&)));
+        QObject::connect(mainFrame, SIGNAL(hoveringOverLink(const QString&, const QString&)),
+                q, SIGNAL(hoveringOverLink(const QString&, const QString&)));
+        
         mainFrame->d->frameView->setFrameGeometry(q->geometry());
     }
 }
@@ -140,10 +145,6 @@ QWebFrame *QWebPage::createFrame(QWebFrame *parentFrame, QWebFrameData *frameDat
     if (parentFrame)
         return new QWebFrame(parentFrame, frameData);
     QWebFrame *f = new QWebFrame(this, frameData);
-    connect(f, SIGNAL(titleChanged(const QString&)),
-            SIGNAL(titleChanged(const QString&)));
-    connect(f, SIGNAL(hoveringOverLink(const QString&, const QString&)),
-            SIGNAL(hoveringOverLink(const QString&, const QString&)));
     return f;
 }
 
index 5c0a71975f7e99c72a413dfc46566fd9c8ef3356..9803fb0e5fcfa04c8e6eb19f6809c36499e65566 100644 (file)
@@ -1,3 +1,16 @@
+2007-10-09  Lars Knoll  <lars@trolltech.com>
+
+        Reviewed by Simon.
+
+        Don't set up connections inside QWebPage::createFrame, as users might be reimplementing that method. Make sure we get only one titleChanged() signal per title change, and implement the support for testing this in DRT.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::createMainFrame):
+        (QWebPage::createFrame):
+        * WebCoreSupport/FrameLoaderClientQt.cpp:
+        (WebCore::FrameLoaderClientQt::dispatchDidReceiveTitle):
+        * WebCoreSupport/FrameLoaderClientQt.h:
+
 2007-10-09  Lars Knoll  <lars@trolltech.com>
 
         Reviewed by Simon.
index ab24ecfac01640919345a2a0fc72a701af64396b..d748e7ae2537603a643b3f9aee90badb3c1fae6d 100644 (file)
@@ -301,7 +301,8 @@ void FrameLoaderClientQt::dispatchDidStartProvisionalLoad()
 
 void FrameLoaderClientQt::dispatchDidReceiveTitle(const String& title)
 {
-    setTitle(title);
+    QString t = title;
+    emit titleChanged(t);
 }
 
 
@@ -415,9 +416,9 @@ void FrameLoaderClientQt::willChangeTitle(DocumentLoader*)
 }
 
 
-void FrameLoaderClientQt::didChangeTitle(DocumentLoader *l)
+void FrameLoaderClientQt::didChangeTitle(DocumentLoader *)
 {
-    setTitle(l->title());
+    // no need for, dispatchDidReceiveTitle is the right callback
 }
 
 
@@ -533,18 +534,9 @@ void FrameLoaderClientQt::prepareForDataSourceReplacement()
     m_frame->loader()->detachChildren();
 }
 
-
-void FrameLoaderClientQt::setTitle(const String& title)
-{
-    QString t = title;
-    emit titleChanged(t);
-}
-
-
-void FrameLoaderClientQt::setTitle(const String& title, const KURL& url)
+void FrameLoaderClientQt::setTitle(const String&, const KURL&)
 {
-    Q_UNUSED(url)
-    setTitle(title);
+    // no need for, dispatchDidReceiveTitle is the right callback
 }
 
 
index bda6de02b12e47f4c4e8023a0e5dcc8972293696..3e9895ed3f8792a84c157f56f566a0a8884038e0 100644 (file)
@@ -151,7 +151,6 @@ namespace WebCore {
         virtual void addHistoryItemForFragmentScroll();
         virtual void didFinishLoad();
         virtual void prepareForDataSourceReplacement();
-        virtual void setTitle(const String& title);
         virtual void setTitle(const String& title, const KURL&);
 
         virtual String userAgent(const WebCore::KURL&);
index 880418ca74ab0548dfa9e1d11f34521b7fbf3171..5eec325b05bc92f155d8a52a71f33f27149bcbf7 100644 (file)
@@ -1,3 +1,18 @@
+2007-10-09  Lars Knoll  <lars@trolltech.com>
+
+        Reviewed by Simon.
+
+        Don't set up connections inside QWebPage::createFrame, as users might be reimplementing that method. Make sure we get only one titleChanged() signal per title change, and implement the support for testing this in DRT.
+
+        * DumpRenderTree/qt/DumpRenderTree.cpp:
+        (WebCore::WebPage::createFrame):
+        (WebCore::DumpRenderTree::DumpRenderTree):
+        (WebCore::DumpRenderTree::titleChanged):
+        * DumpRenderTree/qt/DumpRenderTree.h:
+        * DumpRenderTree/qt/jsobjects.cpp:
+        (LayoutTestController::reset):
+        * DumpRenderTree/qt/jsobjects.h:
+
 2007-10-09  Lars Knoll  <lars@trolltech.com>
 
         Reviewed by Simon.
index fc42e6c43ffaf1c4729da2e079adc03903bcdedb..eb0acce62a0c9f0cf8aba021933d7ed1abd8da50 100644 (file)
@@ -91,10 +91,6 @@ QWebFrame *WebPage::createFrame(QWebFrame *parentFrame, QWebFrameData *frameData
         return f;
     }
     WebFrame *f = new WebFrame(this, frameData);
-    connect(f, SIGNAL(titleChanged(const QString&)),
-            SIGNAL(titleChanged(const QString&)));
-    connect(f, SIGNAL(hoveringOverLink(const QString&, const QString&)),
-            SIGNAL(hoveringOverLink(const QString&, const QString&)));
 
     connect(f, SIGNAL(cleared()), m_drt, SLOT(initJSObjects()));
     connect(f, SIGNAL(provisionalLoad()),
@@ -131,6 +127,8 @@ DumpRenderTree::DumpRenderTree()
     m_page->resize(maxViewWidth, maxViewHeight);
     m_page->mainFrame()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     m_page->mainFrame()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+    connect(m_page, SIGNAL(titleChanged(const QString&)),
+            SLOT(titleChanged(const QString&)));
 
     m_eventSender = new EventSender(m_page);
 
@@ -254,6 +252,12 @@ void DumpRenderTree::dump()
     }
 }
 
+void DumpRenderTree::titleChanged(const QString &s)
+{
+    if (m_controller->shouldDumpTitleChanges())
+        printf("TITLE CHANGED: %s\n", s.toUtf8().data());
+}
+
 
 QWebPage *DumpRenderTree::createWindow()
 {
index afafae882b3f19a247c81eea249437971412e49e..349aefa6f8d6e1fbf6f30169c5660c1d96a176dc 100644 (file)
@@ -70,6 +70,7 @@ public Q_SLOTS:
     void initJSObjects();
     void readStdin(int);
     void dump();
+    void titleChanged(const QString &s);
 
 Q_SIGNALS:
     void quit();
index 2889f79fb1f17ffc6aa992952ff8ed248578e98b..ef1b5f15ae644be9eece74e8a83c6adfba50aa27 100644 (file)
@@ -67,6 +67,7 @@ void LayoutTestController::reset()
     m_dumpChildrenAsText = false;
     m_canOpenWindows = false;
     m_waitForDone = false;
+    m_dumpTitleChanges = false;
     if (m_timeoutTimer) {
         killTimer(m_timeoutTimer);
         m_timeoutTimer = 0;
index 3054f04ac02dcdef6145f49d261cc77f6d4bea58..7f583c1aa46e0cc5688937bda178b6d3248aac7a 100644 (file)
@@ -49,6 +49,7 @@ public:
     bool shouldDumpChildrenAsText() const { return m_dumpChildrenAsText; }
     bool shouldWaitUntilDone() const { return m_waitForDone; }
     bool canOpenWindows() const { return m_canOpenWindows; }
+    bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; }
 
     void reset();
 
@@ -72,6 +73,7 @@ public slots:
     int windowCount();
     void display() {}
     void clearBackForwardList();
+    void dumpTitleChanges() { m_dumpTitleChanges = true; }
 
 private:
     bool m_isLoading;
@@ -79,6 +81,7 @@ private:
     bool m_dumpChildrenAsText;
     bool m_canOpenWindows;
     bool m_waitForDone;
+    bool m_dumpTitleChanges;
     int m_timeoutTimer;
     QWebFrame *m_topLoadingFrame;
     WebCore::DumpRenderTree *m_drt;