Commit 07e006df authored by zack's avatar zack

Implementing some load progress tracking in the Qt port.

Reviewed by Lars.


git-svn-id: svn://svn.chromium.org/blink/trunk@18932 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent fc2d14b4
......@@ -48,6 +48,8 @@ QWebFrame::QWebFrame(QWebPage *parent)
: QScrollArea(parent)
, d(new QWebFramePrivate)
{
d->page = parent;
d->frameLoaderClient = new FrameLoaderClientQt();
d->frame = new FrameQt(parent->d->page, 0, new FrameQtClient(), d->frameLoaderClient);
d->frameLoaderClient->setFrame(this, d->frame);
......@@ -62,6 +64,7 @@ QWebFrame::QWebFrame(QWebFrame *parent)
: QScrollArea(parent)
, d(new QWebFramePrivate)
{
d->page = parent->d->page;
// d->frameLoaderClient = new FrameLoaderClientQt();
// d->frame = new FrameQt(page, 0, new FrameQtClient(), frameLoaderClient);
// d->frameLoaderClient->setFrame(d->frame);
......@@ -112,4 +115,9 @@ QString QWebFrame::renderTreeDump() const
}
QWebPage * QWebFrame::page() const
{
return d->page;
}
#include "qwebframe.moc"
......@@ -40,6 +40,8 @@ public:
QWebFrame(QWebFrame *parent);
~QWebFrame();
QWebPage *page() const;
void addToJSWindowObject(const QByteArray &name, QObject *object);
QString markup() const;
QString innerText() const;
......
......@@ -31,6 +31,7 @@ namespace WebCore
class FrameQt;
class FrameView;
}
class QWebPage;
class QWebFramePrivate
{
......@@ -39,10 +40,12 @@ public:
: frameLoaderClient(0)
, frame(0)
, frameView(0)
, page(0)
{}
WebCore::FrameLoaderClientQt *frameLoaderClient;
WebCore::FrameQt *frame;
WebCore::FrameView *frameView;
QWebPage *page;
};
......
......@@ -46,6 +46,25 @@ public:
QSize sizeHint() const;
signals:
/**
* Signal is emitted when load is started on one of the child
* frames of the page. The frame on which the load started
* is passed.
*/
void loadStarted(QWebFrame *frame);
/**
* Signal is emitted when the global progress status changes.
* It accumulates changes from all the child frames.
*/
void loadProgressChanged(double progress);
/**
* Signal is emitted when load has been finished on one of
* the child frames of the page. The frame on which the
* load finished is passed as an argument.
*/
void loadFinished(QWebFrame *frame);
private:
friend class QWebFrame;
......
2007-01-18 Zack Rusin <zack@kde.org>
Reviewed by Lars.
Implementing a little bit of load progress tracking in the Qt port.
* Api/qwebframe.cpp:
(QWebFrame::QWebFrame):
(QWebFrame::page):
* Api/qwebframe.h:
* Api/qwebframe_p.h:
(QWebFramePrivate::QWebFramePrivate):
* Api/qwebpage.h:
* QtLauncher/main.cpp:
(main):
* WebCoreSupport/FrameLoaderClientQt.cpp:
(WebCore::FrameLoaderClientQt::setFrame):
(WebCore::FrameLoaderClientQt::detachFrameLoader):
(WebCore::FrameLoaderClientQt::postProgressStartedNotification):
(WebCore::FrameLoaderClientQt::postProgressEstimateChangedNotification):
(WebCore::FrameLoaderClientQt::postProgressFinishedNotification):
* WebCoreSupport/FrameLoaderClientQt.h:
2007-01-17 Alice Liu <alice.liu@apple.com>
Added these stubs to keep the Qt build from failing.
......
......@@ -30,11 +30,59 @@
#include <QApplication>
#include <qwebpage.h>
#include <qwebframe.h>
#include <QVBoxLayout>
#include <QDir>
#include <QUrl>
#include <QProgressBar>
#include <QWidget>
#include <QPainter>
#include <QPen>
#include <QBrush>
#include <QTimer>
#include <QDebug>
class InfoWidget :public QProgressBar {
Q_OBJECT
public:
InfoWidget(QWidget *parent)
: QProgressBar(parent), m_progress(0)
{
setMinimum(0);
setMaximum(100);
}
QSize sizeHint() const
{
QSize size(100, 20);
return size;
}
public slots:
void startLoad()
{
setValue(int(m_progress*100));
show();
}
void changeLoad(double change)
{
m_progress = change;
setValue(int(change*100));
//update();
}
void endLoad()
{
QTimer::singleShot(1000, this, SLOT(hide()));
m_progress = 0;
}
protected:
qreal m_progress;
};
#include "main.moc"
int main(int argc, char **argv)
{
QString url = QString("%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html"));
......@@ -48,11 +96,24 @@ int main(int argc, char **argv)
QBoxLayout *l = new QVBoxLayout(&topLevel);
QWebPage *page = new QWebPage(&topLevel);
InfoWidget *info = new InfoWidget(page);
info->setGeometry(20, 20, info->sizeHint().width(),
info->sizeHint().height());
QObject::connect(page, SIGNAL(loadStarted(QWebFrame*)),
info, SLOT(startLoad()));
QObject::connect(page, SIGNAL(loadProgressChanged(double)),
info, SLOT(changeLoad(double)));
QObject::connect(page, SIGNAL(loadFinished(QWebFrame*)),
info, SLOT(endLoad()));
l->addWidget(page);
topLevel.show();
page->open(url);
info->raise();
app.exec();
return 0;
......
......@@ -30,9 +30,14 @@
#include "FrameLoaderClientQt.h"
#include "DocumentLoader.h"
#include "ResourceResponse.h"
#include "qdebug.h"
#include "Page.h"
#include "ProgressTracker.h"
#include "qwebpage.h"
#include "qwebframe.h"
#include "qdebug.h"
#define notImplemented() qDebug("FIXME: UNIMPLEMENTED: %s:%d (%s)", __FILE__, __LINE__, __FUNCTION__)
namespace WebCore
......@@ -56,10 +61,24 @@ void FrameLoaderClientQt::setFrame(QWebFrame *webFrame, FrameQt *frame)
{
m_webFrame = webFrame;
m_frame = frame;
if (!m_webFrame || !m_webFrame->page()) {
qWarning("FrameLoaderClientQt::setFrame frame without Page!");
return;
}
connect(this, SIGNAL(loadStarted(QWebFrame*)),
m_webFrame->page(), SIGNAL(loadStarted(QWebFrame *)));
connect(this, SIGNAL(loadProgressChanged(double)),
m_webFrame->page(), SIGNAL(loadProgressChanged(double)));
connect(this, SIGNAL(loadFinished(QWebFrame*)),
m_webFrame->page(), SIGNAL(loadFinished(QWebFrame *)));
}
void FrameLoaderClientQt::detachFrameLoader()
{
disconnect(this, SIGNAL(loadStarted(QWebFrame*)));
disconnect(this, SIGNAL(loadProgressChanged(double)));
disconnect(this, SIGNAL(loadFinished(QWebFrame*)));
m_webFrame = 0;
m_frame = 0;
}
......@@ -382,17 +401,17 @@ void FrameLoaderClientQt::clearUnarchivingState(DocumentLoader*)
void FrameLoaderClientQt::postProgressStartedNotification()
{
// no progress notification for now
emit loadStarted(m_webFrame);
}
void FrameLoaderClientQt::postProgressEstimateChangedNotification()
{
// no progress notification for now
emit loadProgressChanged(m_frame->page()->progress()->estimatedProgress());
}
void FrameLoaderClientQt::postProgressFinishedNotification()
{
// no progress notification for now
emit loadFinished(m_webFrame);
}
void FrameLoaderClientQt::setMainFrameDocumentReady(bool b)
......
......@@ -58,6 +58,9 @@ namespace WebCore {
void slotCallPolicyFunction(int);
signals:
void sigCallPolicyFunction(int);
void loadStarted(QWebFrame *frame);
void loadProgressChanged(double d);
void loadFinished(QWebFrame *frame);
public:
FrameLoaderClientQt();
~FrameLoaderClientQt();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment