Commit 90a2a204 authored by hausmann@webkit.org's avatar hausmann@webkit.org

Many API changes and additions after a full review with Jasmin Blanchette <jasmin@trolltech.com>

The diff is too big to mention the changes individually, but most of the changes were of cosmetic
nature where methods or enums have been renamed or prefixed/suffixed according to the consistency
rules of the Qt API.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32209 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 05fa1868
2008-04-18 Simon Hausmann <hausmann@webkit.org>
Reviewed by Holger.
Adapt to the API changes in WebKit/qt/
* platform/graphics/qt/ImageQt.cpp:
(loadResourcePixmap):
2008-04-18 Ariya Hidayat <ariya.hidayat@trolltech.com>
Reviewed by Adam Roben.
......@@ -61,9 +61,9 @@ static QPixmap loadResourcePixmap(const char *name)
else if (resource == "nullPlugin")
pixmap = QWebSettings::webGraphic(QWebSettings::MissingPluginGraphic);
else if (resource == "urlIcon")
pixmap = QWebSettings::webGraphic(QWebSettings::DefaultFaviconGraphic);
pixmap = QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic);
else if (resource == "textAreaResizeCorner")
pixmap = QWebSettings::webGraphic(QWebSettings::TextAreaResizeCornerGraphic);
pixmap = QWebSettings::webGraphic(QWebSettings::TextAreaSizeGripCornerGraphic);
return pixmap;
}
......
......@@ -87,9 +87,6 @@ void QWebFramePrivate::init(QWebFrame *qframe, WebCore::Page *webcorePage, QWebF
frame = new Frame(webcorePage, frameData->ownerElement, frameLoaderClient);
frameLoaderClient->setFrame(qframe, frame);
frame->init();
QObject::connect(q, SIGNAL(hoveringOverLink(const QString&, const QString&, const QString&)),
page, SIGNAL(hoveringOverLink(const QString&, const QString&, const QString&)));
}
WebCore::PlatformScrollbar *QWebFramePrivate::horizontalScrollBar() const
......@@ -160,7 +157,7 @@ QWebFrame::~QWebFrame()
Qt properties will be exposed as JavaScript properties and slots as
JavaScript methods.
*/
void QWebFrame::addToJSWindowObject(const QString &name, QObject *object)
void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object)
{
KJS::JSLock lock;
JSDOMWindow *window = toJSDOMWindow(d->frame);
......@@ -179,7 +176,7 @@ void QWebFrame::addToJSWindowObject(const QString &name, QObject *object)
/*!
returns the markup (HTML) contained in the current frame.
*/
QString QWebFrame::markup() const
QString QWebFrame::toHtml() const
{
if (!d->frame->document())
return QString();
......@@ -189,7 +186,7 @@ QString QWebFrame::markup() const
/*!
returns the content of this frame as plain text.
*/
QString QWebFrame::innerText() const
QString QWebFrame::toPlainText() const
{
if (d->frame->view() && d->frame->view()->layoutPending())
d->frame->view()->layout();
......@@ -231,7 +228,7 @@ QUrl QWebFrame::url() const
/*!
The icon associated with this frame.
*/
QPixmap QWebFrame::icon() const
QIcon QWebFrame::icon() const
{
String url = d->frame->loader()->url().string();
......@@ -256,7 +253,7 @@ QPixmap QWebFrame::icon() const
/*!
The name of this frame as defined by the parent frame.
*/
QString QWebFrame::name() const
QString QWebFrame::frameName() const
{
return d->frame->tree()->name();
}
......@@ -388,9 +385,11 @@ void QWebFrame::setHtml(const QByteArray &html, const QUrl &baseUrl)
}
/*!
Sets the content of this frame to \a data assuming \a mimeType. If
\a mimeType is not specified it defaults to 'text/html'. \a baseUrl
us optional and used to resolve relative URLs in the document.
Sets the content of this frame to the specified content \a data. If the \a mimeType argument
is empty it is currently assumed that the content is HTML but in future versions we may introduce
auto-detection.
External objects referenced in the content are located relative to \a baseUrl.
*/
void QWebFrame::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
{
......@@ -436,45 +435,33 @@ QList<QWebFrame*> QWebFrame::childFrames() const
}
/*!
\property QWebFrame::verticalScrollBarPolicy
This property defines the vertical scrollbar policy.
\sa Qt::ScrollBarPolicy
Returns the scrollbar policy for the scrollbar defined by \a orientation.
*/
Qt::ScrollBarPolicy QWebFrame::verticalScrollBarPolicy() const
Qt::ScrollBarPolicy QWebFrame::scrollBarPolicy(Qt::Orientation orientation) const
{
if (orientation == Qt::Horizontal)
return d->horizontalScrollBarPolicy;
return d->verticalScrollBarPolicy;
}
void QWebFrame::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy)
/*!
Sets the scrollbar policy for the scrollbar defined by \a orientation to \a policy.
*/
void QWebFrame::setScrollBarPolicy(Qt::Orientation orientation, 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->verticalScrollBarPolicy = policy;
if (d->frame->view())
d->frame->view()->setVScrollbarMode((ScrollbarMode)policy);
}
/*!
\property QWebFrame::horizontalScrollBarPolicy
This property defines the horizontal scrollbar policy.
\sa Qt::ScrollBarPolicy
*/
Qt::ScrollBarPolicy QWebFrame::horizontalScrollBarPolicy() const
{
return d->horizontalScrollBarPolicy;
}
void QWebFrame::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy)
{
d->horizontalScrollBarPolicy = policy;
if (d->frame->view())
d->frame->view()->setHScrollbarMode((ScrollbarMode)policy);
if (orientation == Qt::Horizontal) {
d->horizontalScrollBarPolicy = policy;
if (d->frame->view())
d->frame->view()->setHScrollbarMode((ScrollbarMode)policy);
} else {
d->verticalScrollBarPolicy = policy;
if (d->frame->view())
d->frame->view()->setVScrollbarMode((ScrollbarMode)policy);
}
}
/*!
......@@ -543,7 +530,7 @@ void QWebFrame::render(QPainter *painter, const QRegion &clip)
if (!d->frame->view() || !d->frame->renderer())
return;
layout();
d->frame->view()->layoutIfNeededRecursive();
GraphicsContext ctx(painter);
QVector<QRect> vector = clip.rects();
......@@ -553,30 +540,34 @@ void QWebFrame::render(QPainter *painter, const QRegion &clip)
}
/*!
\property QWebFrame::textZoomFactor
This property defines the zoom factor for all text in percent.
Render the frame into \a painter.
*/
void QWebFrame::setTextZoomFactor(int percent)
void QWebFrame::render(QPainter *painter)
{
d->frame->setZoomFactor(percent, /*isTextOnly*/true);
}
if (!d->frame->view() || !d->frame->renderer())
return;
int QWebFrame::textZoomFactor() const
{
return d->frame->zoomFactor();
d->frame->view()->layoutIfNeededRecursive();
GraphicsContext ctx(painter);
WebCore::FrameView* view = d->frame->view();
view->paint(&ctx, view->frameGeometry());
}
/*!
Ensure that the content of the frame and all subframes are correctly layouted.
\property QWebFrame::textSizeMultiplier
This property defines the scaling factor for all text in the frame.
*/
void QWebFrame::layout()
void QWebFrame::setTextSizeMultiplier(qreal factor)
{
if (!d->frame->view())
return;
d->frame->setZoomFactor(factor, /*isTextOnly*/true);
}
d->frame->view()->layoutIfNeededRecursive();
qreal QWebFrame::textSizeMultiplier() const
{
return qreal(d->frame->zoomFactor()) / 100.;
}
/*!
......@@ -628,10 +619,10 @@ QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame)
/*!
\fn void QWebFrame::cleared()
\fn void QWebFrame::javaScriptWindowObjectCleared()
This signal is emitted whenever the content of the frame is cleared
(e.g. before starting a new load).
This signal is emitted whenever the global window object of the JavaScript environment
is cleared (e.g. before starting a new load).
*/
/*!
......@@ -664,15 +655,6 @@ QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame)
\sa url()
*/
/*!
\fn void QWebFrame::hoveringOverLink(const QString &link, const QString &title, const QString &textContent)
This signal is emitted whenever the mouse cursor is hovering over a
link. It can be used to display information about the link in
e.g. the status bar. The signal arguments consist of the \a link destination, the \a title and the
link text as \a textContent .
*/
/*!
\fn void QWebFrame::loadStarted()
......@@ -687,7 +669,7 @@ QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame)
*/
/*!
\fn void QWebFrame::initialLayoutComplete()
\fn void QWebFrame::initialLayoutCompleted()
This signal is emitted when the first (initial) layout of the frame
has happened. This is the earliest time something can be shown on
......@@ -695,7 +677,7 @@ QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame)
*/
/*!
\fn void QWebFrame::iconLoaded()
\fn void QWebFrame::iconChanged()
This signal is emitted when the icon ("favicon") associated with the frame has been loaded.
*/
......@@ -26,6 +26,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qurl.h>
#include <QtGui/qicon.h>
#if QT_VERSION >= 0x040400
#include <QtNetwork/qnetworkaccessmanager.h>
#endif
......@@ -56,9 +57,10 @@ class QWebFrameData;
class QWEBKIT_EXPORT QWebFrame : public QObject
{
Q_OBJECT
Q_PROPERTY(Qt::ScrollBarPolicy verticalScrollBarPolicy READ verticalScrollBarPolicy WRITE setVerticalScrollBarPolicy)
Q_PROPERTY(Qt::ScrollBarPolicy horizontalScrollBarPolicy READ horizontalScrollBarPolicy WRITE setHorizontalScrollBarPolicy)
Q_PROPERTY(int textZoomFactor READ textZoomFactor WRITE setTextZoomFactor)
Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier)
Q_PROPERTY(QString title READ title)
Q_PROPERTY(QUrl url READ url)
Q_PROPERTY(QIcon icon READ icon)
private:
QWebFrame(QWebPage *parent, QWebFrameData *frameData);
QWebFrame(QWebFrame *parent, QWebFrameData *frameData);
......@@ -79,24 +81,22 @@ public:
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 QString &name, QObject *object);
QString markup() const;
QString innerText() const;
void addToJavaScriptWindowObject(const QString &name, QObject *object);
QString toHtml() const;
QString toPlainText() const;
QString renderTreeDump() const;
QString title() const;
QUrl url() const;
QPixmap icon() const;
QIcon icon() const;
QString name() const;
QString frameName() const;
QWebFrame *parentFrame() const;
QList<QWebFrame*> childFrames() const;
Qt::ScrollBarPolicy verticalScrollBarPolicy() const;
void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy);
Qt::ScrollBarPolicy horizontalScrollBarPolicy() const;
void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy);
Qt::ScrollBarPolicy scrollBarPolicy(Qt::Orientation orientation) const;
void setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPolicy policy);
void setScrollBarValue(Qt::Orientation orientation, int value);
int scrollBarValue(Qt::Orientation orientation) const;
......@@ -104,10 +104,10 @@ public:
int scrollBarMaximum(Qt::Orientation orientation) const;
void render(QPainter *painter, const QRegion &clip);
void layout();
void render(QPainter *painter);
void setTextZoomFactor(int percent);
int textZoomFactor() const;
void setTextSizeMultiplier(qreal factor);
qreal textSizeMultiplier() const;
QPoint pos() const;
QRect geometry() const;
......@@ -116,25 +116,18 @@ public Q_SLOTS:
QString evaluateJavaScript(const QString& scriptSource);
Q_SIGNALS:
void cleared();
void javaScriptWindowObjectCleared();
void loadDone(bool ok);
void provisionalLoad();
void titleChanged(const QString &title);
void hoveringOverLink(const QString &link, const QString &title, const QString &textContent);
void urlChanged(const QUrl &url);
void loadStarted();
void loadFinished();
/**
* Signal is emitted when the mainframe()'s initial layout is completed.
*/
void initialLayoutComplete();
/**
* Signal is emitted when an icon ("favicon") is loaded from the site.
*/
void iconLoaded();
void initialLayoutCompleted();
void iconChanged();
private:
friend class QWebPage;
......
......@@ -73,9 +73,9 @@ QUrl QWebHistoryItem::originalUrl() const
/*!
The current url associated with the history item.
The url associated with the history item.
*/
QUrl QWebHistoryItem::currentUrl() const
QUrl QWebHistoryItem::url() const
{
return QUrl(d->item->url().string());
}
......@@ -103,7 +103,7 @@ QDateTime QWebHistoryItem::lastVisited() const
/*!
The icon associated with the history item.
*/
QPixmap QWebHistoryItem::icon() const
QIcon QWebHistoryItem::icon() const
{
return *d->item->icon()->getPixmap();
}
......@@ -217,7 +217,7 @@ bool QWebHistory::canGoForward() const
/*!
goes back one history item.
*/
void QWebHistory::goBack()
void QWebHistory::back()
{
d->lst->goBack();
}
......@@ -225,7 +225,7 @@ void QWebHistory::goBack()
/*!
goes forward one history item.
*/
void QWebHistory::goForward()
void QWebHistory::forward()
{
d->lst->goBack();
}
......@@ -271,7 +271,7 @@ QWebHistoryItem QWebHistory::forwardItem() const
/*!
returns the item at index \a i.
*/
QWebHistoryItem QWebHistory::itemAtIndex(int i) const
QWebHistoryItem QWebHistory::itemAt(int i) const
{
WebCore::HistoryItem *item = d->lst->itemAtIndex(i);
......@@ -279,3 +279,11 @@ QWebHistoryItem QWebHistory::itemAtIndex(int i) const
return QWebHistoryItem(priv);
}
/*!
Returns the total number of items in the back-forward history.
*/
int QWebHistory::count() const
{
return d->lst->entries().size();
}
......@@ -41,12 +41,12 @@ public:
~QWebHistoryItem();
QUrl originalUrl() const;
QUrl currentUrl() const;
QUrl url() const;
QString title() const;
QDateTime lastVisited() const;
QPixmap icon() const;
QIcon icon() const;
private:
QWebHistoryItem(QWebHistoryItemPrivate *priv);
......@@ -68,14 +68,16 @@ public:
bool canGoBack() const;
bool canGoForward() const;
void goBack();
void goForward();
void back();
void forward();
void goToItem(const QWebHistoryItem &item);
QWebHistoryItem backItem() const;
QWebHistoryItem currentItem() const;
QWebHistoryItem forwardItem() const;
QWebHistoryItem itemAtIndex(int i) const;
QWebHistoryItem itemAt(int i) const;
int count() const;
private:
QWebHistory();
......
......@@ -139,6 +139,8 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
pluginFactory = 0;
#endif
insideOpenCall = false;
forwardUnsupportedContent = false;
linkPolicy = QWebPage::DontDelegateLinks;
history.d = new QWebHistoryPrivate(page->backForwardList());
memset(actions, 0, sizeof(actions));
......@@ -155,20 +157,20 @@ QWebPagePrivate::~QWebPagePrivate()
}
#if QT_VERSION < 0x040400
QWebPage::NavigationRequestResponse QWebPagePrivate::navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
{
if (insideOpenCall
&& frame == mainFrame)
return QWebPage::AcceptNavigationRequest;
return q->navigationRequested(frame, request, type);
return true;
return q->acceptNavigationRequest(frame, request, type);
}
#else
QWebPage::NavigationRequestResponse QWebPagePrivate::navigationRequested(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
{
if (insideOpenCall
&& frame == mainFrame)
return QWebPage::AcceptNavigationRequest;
return q->navigationRequested(frame, request, type);
return true;
return q->acceptNavigationRequest(frame, request, type);
}
#endif
......@@ -198,8 +200,8 @@ static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAct
case WebCore::ContextMenuItemTagCopyImageToClipboard: return QWebPage::CopyImageToClipboard;
case WebCore::ContextMenuItemTagOpenFrameInNewWindow: return QWebPage::OpenFrameInNewWindow;
case WebCore::ContextMenuItemTagCopy: return QWebPage::Copy;
case WebCore::ContextMenuItemTagGoBack: return QWebPage::GoBack;
case WebCore::ContextMenuItemTagGoForward: return QWebPage::GoForward;
case WebCore::ContextMenuItemTagGoBack: return QWebPage::Back;
case WebCore::ContextMenuItemTagGoForward: return QWebPage::Forward;
case WebCore::ContextMenuItemTagStop: return QWebPage::Stop;
case WebCore::ContextMenuItemTagReload: return QWebPage::Reload;
case WebCore::ContextMenuItemTagCut: return QWebPage::Cut;
......@@ -294,10 +296,10 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action)
bool enabled = a->isEnabled();
switch (action) {
case QWebPage::GoBack:
case QWebPage::Back:
enabled = loader->canGoBackOrForward(-1);
break;
case QWebPage::GoForward:
case QWebPage::Forward:
enabled = loader->canGoBackOrForward(1);
break;
case QWebPage::Stop:
......@@ -327,8 +329,8 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action)
void QWebPagePrivate::updateNavigationActions()
{
updateAction(QWebPage::GoBack);
updateAction(QWebPage::GoForward);
updateAction(QWebPage::Back);
updateAction(QWebPage::Forward);
updateAction(QWebPage::Stop);
updateAction(QWebPage::Reload);
}
......@@ -581,9 +583,9 @@ void QWebPagePrivate::keyPressEvent(QKeyEvent *ev)
break;
case Qt::Key_Backspace:
if (ev->modifiers() == Qt::ShiftModifier)
q->triggerAction(QWebPage::GoForward);
q->triggerAction(QWebPage::Forward);
else
q->triggerAction(QWebPage::GoBack);
q->triggerAction(QWebPage::Back);
default:
handled = false;
break;
......@@ -745,8 +747,8 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
\value OpenImageInNewWindow Open the highlighted image in a new window.
\value DownloadImageToDisk Download the highlighted image to the disk.
\value CopyImageToClipboard Copy the highlighted image to the clipboard.
\value GoBack Navigate back in the history of navigated links.
\value GoForward Navigate forward in the history of navigated links.
\value Back Navigate back in the history of navigated links.
\value Forward Navigate forward in the history of navigated links.
\value Stop Stop loading the current page.
\value Reload Reload the current page.
\value Cut Cut the content currently selected into the clipboard.
......@@ -791,6 +793,13 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
*/
/*!
\enum QWebPage::WebWindowType
\value WebBrowserWindow The window is a regular web browser window.
\value WebModalDialog The window acts as modal dialog.
*/
/*!
\class QWebPage
\since 4.4
......@@ -810,7 +819,7 @@ QWebPage::QWebPage(QObject *parent)
{
setView(qobject_cast<QWidget *>(parent));
connect(this, SIGNAL(loadProgressChanged(int)), this, SLOT(_q_onLoadProgressChanged(int)));
connect(this, SIGNAL(loadProgress(int)), this, SLOT(_q_onLoadProgressChanged(int)));
}
/*!
......@@ -878,7 +887,7 @@ QWidget *QWebPage::view() const
/*!
This function is called whenever a JavaScript program tries to print to what is the console in web browsers.
*/
void QWebPage::javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID)
void QWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID)
{
}
......@@ -914,28 +923,20 @@ bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QStr
}
/*!
This function is called whenever WebKit wants to create a new window, for example as a result of
This function is called whenever WebKit wants to create a new window of the given \a type, for example as a result of
a JavaScript request to open a document in a new window.
*/
QWebPage *QWebPage::createWindow()
QWebPage *QWebPage::createWindow(WebWindowType type)
{
QWebView *webView = qobject_cast<QWebView *>(d->view);
if (webView) {
QWebView *newView = webView->createWindow();
QWebView *newView = webView->createWindow(type);
if (newView)
return newView->page();
}
return 0;
}
/*!
This function is called whenever WebKit wants to create a new window that should act as a modal dialog.
*/
QWebPage *QWebPage::createModalDialog()
{
return 0;
}
/*!
This function is called whenever WebKit encounters a HTML object element with type "application/x-qt-plugin".
The \a classid, \a url, \a paramNames and \a paramValues correspond to the HTML object element attributes and
......@@ -1019,10 +1020,10 @@ void QWebPage::triggerAction(WebAction action, bool checked)
case CopyImageToClipboard:
QApplication::clipboard()->setPixmap(d->currentContext.image());
break;
case GoBack:
case Back:
d->page->goBack();
break;
case GoForward:
case Forward:
d->page->goForward();
break;
case Stop:
......@@ -1186,14 +1187,38 @@ void QWebPage::setViewportSize(const QSize &size) const
}
/*!
\fn bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
This function is called whenever WebKit requests to navigate \a frame to the resource specified by \a request by means of
the specified navigation type \a type.
The default implementation interprets the page's linkDelegationPolicy and emits linkClicked accordingly or returns true
to let QWebPage handle the navigation itself.
*/
#if QT_VERSION < 0x040400
QWebPage::NavigationRequestResponse QWebPage::navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
#else
QWebPage::NavigationRequestResponse QWebPage::navigationRequested(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
#endif
{
Q_UNUSED(request)
return AcceptNavigationRequest;
if (type == NavigationTypeLinkClicked) {
switch (d->linkPolicy) {
case DontDelegateLinks:
return true;