Moved QWebPage::open to QWebFrame::load and added setHtml.
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Jan 2008 13:53:08 +0000 (13:53 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Jan 2008 13:53:08 +0000 (13:53 +0000)
Signed-off-by: Lars
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29123 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/Api/qwebframe.cpp
WebKit/qt/Api/qwebframe.h
WebKit/qt/Api/qwebpage.cpp
WebKit/qt/Api/qwebpage.h
WebKit/qt/Api/qwebview.cpp
WebKit/qt/Api/qwebview.h
WebKit/qt/ChangeLog
WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp

index 46832955620853ccf5c428e180876495acb542b2..a695695a3524886b1601b9310a18d57f5025160d 100644 (file)
@@ -25,6 +25,7 @@
 #include "qwebpage.h"
 #include "qwebpage_p.h"
 #include "qwebframe_p.h"
+#include "qwebnetworkinterface.h"
 
 #include "FocusController.h"
 #include "FrameLoaderClientQt.h"
@@ -35,6 +36,7 @@
 #include "ResourceRequest.h"
 #include "SelectionController.h"
 #include "PlatformScrollBar.h"
+#include "SubstituteData.h"
 
 #include "markup.h"
 #include "RenderTreeAsText.h"
@@ -195,6 +197,69 @@ QWebPage * QWebFrame::page() const
     return d->page;
 }
 
+void QWebFrame::load(const QUrl &url)
+{
+    load(QWebNetworkRequest(url));
+}
+
+void QWebFrame::load(const QWebNetworkRequest &req)
+{
+    if (d->parentFrame())
+        d->page->d->insideOpenCall = true;
+
+    QUrl url = req.url();
+    QHttpRequestHeader httpHeader = req.httpHeader();
+    QByteArray postData = req.postData();
+
+    WebCore::ResourceRequest request(KURL(url.toString()));
+
+    QString method = httpHeader.method();
+    if (!method.isEmpty())
+        request.setHTTPMethod(method);
+
+    QList<QPair<QString, QString> > values = httpHeader.values();
+    for (int i = 0; i < values.size(); ++i) {
+        const QPair<QString, QString> &val = values.at(i);
+        request.addHTTPHeaderField(val.first, val.second);
+    }
+
+    if (!postData.isEmpty()) {
+        WTF::RefPtr<WebCore::FormData> formData = new WebCore::FormData(postData.constData(), postData.size());
+        request.setHTTPBody(formData);
+    }
+
+    d->frame->loader()->load(request);
+
+    if (d->parentFrame())
+        d->page->d->insideOpenCall = false;
+}
+
+void QWebFrame::setHtml(const QString &html, const QUrl &baseUrl)
+{
+    KURL kurl(baseUrl.toString());
+    WebCore::ResourceRequest request(kurl);
+    WTF::RefPtr<WebCore::SharedBuffer> data = new WebCore::SharedBuffer(reinterpret_cast<const uchar *>(html.unicode()), html.length() * 2);
+    WebCore::SubstituteData substituteData(data, WebCore::String("text/html"), WebCore::String("utf-16"), kurl);
+    d->frame->loader()->load(request, substituteData);
+}
+
+void QWebFrame::setHtml(const QByteArray &html, const QUrl &baseUrl)
+{
+    setContent(html, QString(), baseUrl);
+}
+
+void QWebFrame::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
+{
+    KURL kurl(baseUrl.toString());
+    WebCore::ResourceRequest request(kurl);
+    WTF::RefPtr<WebCore::SharedBuffer> buffer = new WebCore::SharedBuffer(data.constData(), data.length());
+    QString actualMimeType = mimeType;
+    if (actualMimeType.isEmpty())
+        actualMimeType = QLatin1String("text/html");
+    WebCore::SubstituteData substituteData(buffer, WebCore::String(actualMimeType), WebCore::String(), kurl);
+    d->frame->loader()->load(request, substituteData);
+}
+
 QList<QWebFrame*> QWebFrame::childFrames() const
 {
     QList<QWebFrame*> rc;
index 9eda6e48926fe52c3e8d1d54ac4ea11f4c1def14..597b091b2ea619ec492b36f7041d7c2d6563ed9a 100644 (file)
@@ -25,6 +25,7 @@
 #define QWEBFRAME_H
 
 #include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
 
 #include "qwebkitglobal.h"
 
@@ -33,6 +34,7 @@ class QPoint;
 class QPainter;
 class QMouseEvent;
 class QWheelEvent;
+class QWebNetworkRequest;
 
 class QWebFramePrivate;
 class QWebPage;
@@ -55,6 +57,12 @@ protected:
 public:
     QWebPage *page() const;
 
+    void load(const QUrl &url);
+    void load(const QWebNetworkRequest &request);
+    void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
+    void setHtml(const QByteArray &html, const QUrl &baseUrl = QUrl());
+    void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
+
     void addToJSWindowObject(const QByteArray &name, QObject *object);
     QString markup() const;
     QString innerText() const;
index fabe52300f58c6e3694307afa2943d337ea460a8..ab4fcfd94f42b1ed60433d49bf2ac6687b0b07d3 100644 (file)
@@ -308,40 +308,6 @@ QWebPage::~QWebPage()
     delete d;
 }
 
-void QWebPage::open(const QUrl &url)
-{
-    open(QWebNetworkRequest(url));
-}
-
-void QWebPage::open(const QWebNetworkRequest &req)
-{
-    d->insideOpenCall = true;
-
-    QUrl url = req.url();
-    QHttpRequestHeader httpHeader = req.httpHeader();
-    QByteArray postData = req.postData();
-
-    WebCore::ResourceRequest request(KURL(url.toString()));
-
-    QString method = httpHeader.method();
-    if (!method.isEmpty())
-        request.setHTTPMethod(method);
-
-    QList<QPair<QString, QString> > values = httpHeader.values();
-    for (int i = 0; i < values.size(); ++i) {
-        const QPair<QString, QString> &val = values.at(i);
-        request.addHTTPHeaderField(val.first, val.second);
-    }
-
-    if (!postData.isEmpty()) {
-        WTF::RefPtr<WebCore::FormData> formData = new WebCore::FormData(postData.constData(), postData.size());
-        request.setHTTPBody(formData);
-    }
-
-    mainFrame()->d->frame->loader()->load(request);
-    d->insideOpenCall = false;
-}
-
 QUrl QWebPage::url() const
 {
     return QUrl((QString)mainFrame()->d->frame->loader()->url().string());
index 120321dfc6be87bdfd36a529e6f8df502acbbfd3..d0d011c55976a73b098c3e9ec055dbb855aa3911 100644 (file)
@@ -140,10 +140,6 @@ public:
     explicit QWebPage(QWidget *parent = 0);
     ~QWebPage();
 
-    // ### move to frame
-    void open(const QUrl &url);
-    void open(const QWebNetworkRequest &request);
-
     QWebFrame *mainFrame() const;
     QWebFrame *currentFrame() const;
 
index 31c1c098ba686b1b212d5a45128fddcac89f1664..b1802e3d4a2043c2b69cd23e20be9fe8f05d5dc9 100644 (file)
@@ -85,22 +85,27 @@ void QWebView::setPage(QWebPage *page)
 
 void QWebView::load(const QUrl &url)
 {
-    page()->open(url);
+    page()->mainFrame()->load(url);
 }
 
 void QWebView::load(const QWebNetworkRequest &request)
 {
-    page()->open(request);
+    page()->mainFrame()->load(request);
 }
 
 void QWebView::setHtml(const QString &html, const QUrl &baseUrl)
 {
-    // #### FIXME
+    page()->mainFrame()->setHtml(html, baseUrl);
 }
 
 void QWebView::setHtml(const QByteArray &html, const QUrl &baseUrl)
 {
-    // #### FIXME
+    page()->mainFrame()->setHtml(html, baseUrl);
+}
+
+void QWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
+{
+    page()->mainFrame()->setContent(data, mimeType, baseUrl);
 }
 
 QWebPageHistory *QWebView::history() const
index 536e11b8af91f45ffd8b335739a578bfc100c27c..c9487cfc90dacd483115e0840b8bd2678b52f899 100644 (file)
@@ -37,11 +37,11 @@ public:
     QWebPage *page() const;
     void setPage(QWebPage *page);
 
-    // ### also offer in QWebFrame
     void load(const QUrl &url);
     void load(const QWebNetworkRequest &request);
     void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
     void setHtml(const QByteArray &html, const QUrl &baseUrl = QUrl());
+    void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
 
     QWebPageHistory *history() const;
     QWebSettings *settings() const;
index c81e83c99dbb0aacfab5d8d920afcfcb4010a096..2e11f3fda4fd9c85948925b9aba4385b3b2c82fe 100644 (file)
@@ -1,3 +1,26 @@
+2008-01-03  Simon Hausmann  <hausmann@webkit.org>
+
+        Reviewed by Lars.
+
+        Moved QWebPage::open to QWebFrame::load and added setHtml.
+        
+
+        * Api/qwebframe.cpp:
+        (QWebFrame::load):
+        (QWebFrame::setHtml):
+        (QWebFrame::setContent):
+        * Api/qwebframe.h:
+        * Api/qwebpage.cpp:
+        * Api/qwebpage.h:
+        * Api/qwebview.cpp:
+        (QWebView::load):
+        (QWebView::setHtml):
+        * Api/qwebview.h:
+        * WebCoreSupport/ChromeClientQt.cpp:
+        (WebCore::ChromeClientQt::createWindow):
+        * WebCoreSupport/InspectorClientQt.cpp:
+        (WebCore::InspectorClientQt::createPage):
+
 2008-01-03  Simon Hausmann  <hausmann@webkit.org>
 
         Reviewed by Lars.
index e2a50f715ea3af347e6b9feb0d93a4e15169b084..7858ec858b420a4cb8552c1ee2c8f67c9504fed2 100644 (file)
@@ -125,7 +125,7 @@ Page* ChromeClientQt::createWindow(Frame*, const FrameLoadRequest& request, cons
     if (!newPage)
         return 0;
     KURL url = request.resourceRequest().url();
-    newPage->open(QUrl(url.prettyURL()));
+    newPage->mainFrame()->load(QUrl(url.prettyURL()));
     return newPage->d->page;
 }
 
index 58a25bf6a9424273b731e046f8e85868f73d7225..847fcdb5906d0d7e8d09bcbeed3804a54967c11c 100644 (file)
@@ -86,7 +86,7 @@ Page* InspectorClientQt::createPage()
         return m_webPage->d->page;
 
     m_webPage.set(new InspectorClientWebPage(m_inspectedWebPage->d->page->inspectorController()));
-    m_webPage->open(QString::fromLatin1("qrc:/webkit/inspector/inspector.html"));
+    m_webPage->mainFrame()->load(QString::fromLatin1("qrc:/webkit/inspector/inspector.html"));
     m_webPage->setMinimumSize(400,300);
     return m_webPage->d->page;
 }
index e4af68ebcb4bac3bb2254f973b3f5642a8ba4593..f49c5f9cb1767a2f8cc844f35f8c23ed7743e861 100644 (file)
@@ -1,3 +1,13 @@
+2008-01-03  Simon Hausmann  <hausmann@webkit.org>
+
+        Reviewed by Lars.
+
+        Moved QWebPage::open to QWebFrame::load and added setHtml.
+        
+
+        * DumpRenderTree/qt/DumpRenderTree.cpp:
+        (WebCore::DumpRenderTree::open):
+
 2008-01-03  Simon Hausmann  <hausmann@webkit.org>
 
         Reviewed by Lars.
index 0e8469bc158748198c3e91e63433e0b8ca02673b..05be4bc1b6689fa7e859a9e69fb3cd1e8742f835 100644 (file)
@@ -153,7 +153,7 @@ void DumpRenderTree::open()
 void DumpRenderTree::open(const QUrl& url)
 {
     resetJSObjects();
-    m_page->open(url);
+    m_page->mainFrame()->load(url);
 }
 
 void DumpRenderTree::readStdin(int /* socket */)