diff options
Diffstat (limited to 'WebKit/qt')
59 files changed, 2984 insertions, 3491 deletions
diff --git a/WebKit/qt/Api/headers.pri b/WebKit/qt/Api/headers.pri index 5a95c67..1a42597 100644 --- a/WebKit/qt/Api/headers.pri +++ b/WebKit/qt/Api/headers.pri @@ -8,7 +8,6 @@ WEBKIT_API_HEADERS = $$PWD/qwebframe.h \ $$PWD/qwebdatabase.h \ $$PWD/qwebsecurityorigin.h \ $$PWD/qwebelement.h \ - $$PWD/qwebplugindatabase.h \ $$PWD/qwebpluginfactory.h \ $$PWD/qwebhistory.h \ $$PWD/qwebinspector.h \ diff --git a/WebKit/qt/Api/qcookiejar.cpp b/WebKit/qt/Api/qcookiejar.cpp deleted file mode 100644 index a02fe78..0000000 --- a/WebKit/qt/Api/qcookiejar.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - Copyright (C) 2007 Staikos Computing Services Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" -#include "qcookiejar.h" -#include <QCoreApplication> -uint qHash(const QUrl&); -#include <QHash> -#include <QPointer> - -class QCookieJarPrivate { - public: - QCookieJarPrivate() - { - enabled = true; - } - bool enabled; - QHash<QUrl, QString> jar; -}; - - -uint qHash(const QUrl& url) -{ - return qHash(url.toString()); -} - - -QCookieJar::QCookieJar() -: QObject(), d(new QCookieJarPrivate) -{ -} - - -QCookieJar::~QCookieJar() -{ - delete d; -} - - -void QCookieJar::setCookies(const QUrl& url, const QUrl& policyUrl, const QString& value) -{ - Q_UNUSED(policyUrl) - d->jar.insert(url, value); -} - - -QString QCookieJar::cookies(const QUrl& url) -{ - return d->jar.value(url); -} - - -bool QCookieJar::isEnabled() const -{ - return d->enabled; -} - - -void QCookieJar::setEnabled(bool enabled) -{ - d->enabled = enabled; -} - - -static QPointer<QCookieJar> gJar; -static bool gRoutineAdded = false; - -static void gCleanupJar() -{ - delete gJar; -} - - -void QCookieJar::setCookieJar(QCookieJar* jar) -{ - if (!gRoutineAdded) { - qAddPostRoutine(gCleanupJar); - gRoutineAdded = true; - } - delete gJar; - gJar = jar; -} - - -QCookieJar* QCookieJar::cookieJar() -{ - if (!gJar) - setCookieJar(new QCookieJar); - - return gJar; -} diff --git a/WebKit/qt/Api/qcookiejar.h b/WebKit/qt/Api/qcookiejar.h deleted file mode 100644 index 7885cc1..0000000 --- a/WebKit/qt/Api/qcookiejar.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright (C) 2007 Staikos Computing Services Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef QCOOKIEJAR_H -#define QCOOKIEJAR_H - -#include <QtCore/qobject.h> -#include <QtCore/qurl.h> -#include "qwebkitglobal.h" - -class QCookieJarPrivate; - -class QWEBKIT_EXPORT QCookieJar : public QObject { - Q_OBJECT - - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) -public: - QCookieJar(); - ~QCookieJar(); - - virtual void setCookies(const QUrl& url, const QUrl& policyUrl, const QString& value); - virtual QString cookies(const QUrl& url); - - bool isEnabled() const; - - static void setCookieJar(QCookieJar* jar); - static QCookieJar* cookieJar(); - -public slots: - virtual void setEnabled(bool enabled); - -private: - friend class QCookieJarPrivate; - QCookieJarPrivate* d; -}; - - -#endif diff --git a/WebKit/qt/Api/qgraphicswebview.cpp b/WebKit/qt/Api/qgraphicswebview.cpp index 50a0986..b25b53b 100644 --- a/WebKit/qt/Api/qgraphicswebview.cpp +++ b/WebKit/qt/Api/qgraphicswebview.cpp @@ -39,13 +39,13 @@ public: QGraphicsWebViewPrivate(QGraphicsWebView* parent) : q(parent) , page(0) - , interactive(true) - , progress(1.0) {} + virtual ~QGraphicsWebViewPrivate(); virtual void scroll(int dx, int dy, const QRect&); virtual void update(const QRect& dirtyRect); virtual void setInputMethodEnabled(bool enable); + virtual bool inputMethodEnabled() const; #if QT_VERSION >= 0x040600 virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable); #endif @@ -61,26 +61,14 @@ public: virtual QObject* pluginParent() const; - void _q_doLoadProgress(int progress); void _q_doLoadFinished(bool success); - void _q_setStatusBarMessage(const QString& message); QGraphicsWebView* q; QWebPage* page; - - QString statusBarMessage; - bool interactive; - qreal progress; }; -void QGraphicsWebViewPrivate::_q_doLoadProgress(int progress) +QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate() { - if (qFuzzyCompare(this->progress, qreal(progress / 100.))) - return; - - this->progress = progress / 100.; - - emit q->progressChanged(this->progress); } void QGraphicsWebViewPrivate::_q_doLoadFinished(bool success) @@ -105,8 +93,20 @@ void QGraphicsWebViewPrivate::update(const QRect & dirtyRect) void QGraphicsWebViewPrivate::setInputMethodEnabled(bool enable) { - q->setAttribute(Qt::WA_InputMethodEnabled, enable); +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + q->setFlag(QGraphicsItem::ItemAcceptsInputMethod, enable); +#endif } + +bool QGraphicsWebViewPrivate::inputMethodEnabled() const +{ +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + return q->flags() & QGraphicsItem::ItemAcceptsInputMethod; +#else + return false; +#endif +} + #if QT_VERSION >= 0x040600 void QGraphicsWebViewPrivate::setInputMethodHint(Qt::InputMethodHint hint, bool enable) { @@ -156,22 +156,78 @@ QObject* QGraphicsWebViewPrivate::pluginParent() const return q; } -void QGraphicsWebViewPrivate::_q_setStatusBarMessage(const QString& s) -{ - statusBarMessage = s; - emit q->statusChanged(); -} - /*! \class QGraphicsWebView - \brief The QGraphicsWebView class allows web content to be added to a GraphicsView. + \brief The QGraphicsWebView class allows Web content to be added to a GraphicsView. \since 4.6 - A WebGraphicsItem renders web content based on a URL or set data. + An instance of this class renders Web content from a URL or supplied as data, using + features of the QtWebKit module. + + If the width and height of the item are not set, they will default to 800 and 600, + respectively. If the Web page contents is larger than that, scrollbars will be shown + if not disabled explicitly. + + \section1 Browser Features + + Many of the functions, signals and properties provided by QWebView are also available + for this item, making it simple to adapt existing code to use QGraphicsWebView instead + of QWebView. - If the width and height of the item is not set, they will - dynamically adjust to a size appropriate for the content. - This width may be large (eg. 980) for typical online web pages. + The item uses a QWebPage object to perform the rendering of Web content, and this can + be obtained with the page() function, enabling the document itself to be accessed and + modified. + + As with QWebView, the item records the browsing history using a QWebHistory object, + accessible using the history() function. The QWebSettings object that defines the + configuration of the browser can be obtained with the settings() function, enabling + features like plugin support to be customized for each item. + + \sa QWebView, QGraphicsTextItem +*/ + +/*! + \fn void QGraphicsWebView::titleChanged(const QString &title) + + This signal is emitted whenever the \a title of the main frame changes. + + \sa title() +*/ + +/*! + \fn void QGraphicsWebView::urlChanged(const QUrl &url) + + This signal is emitted when the \a url of the view changes. + + \sa url(), load() +*/ + +/*! + \fn void QGraphicsWebView::iconChanged() + + This signal is emitted whenever the icon of the page is loaded or changes. + + In order for icons to be loaded, you will need to set an icon database path + using QWebSettings::setIconDatabasePath(). + + \sa icon(), QWebSettings::setIconDatabasePath() +*/ + +/*! + \fn void QGraphicsWebView::loadStarted() + + This signal is emitted when a new load of the page is started. + + \sa loadProgress(), loadFinished() +*/ + +/*! + \fn void QGraphicsWebView::loadFinished(bool ok) + + This signal is emitted when a load of the page is finished. + \a ok will indicate whether the load was successful or any error occurred. + + \sa loadStarted() */ /*! @@ -186,12 +242,13 @@ QGraphicsWebView::QGraphicsWebView(QGraphicsItem* parent) #if QT_VERSION >= 0x040600 setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); #endif + setAcceptDrops(true); setAcceptHoverEvents(true); setFocusPolicy(Qt::StrongFocus); } /*! - Destroys the web graphicsitem. + Destroys the item. */ QGraphicsWebView::~QGraphicsWebView() { @@ -272,6 +329,24 @@ QVariant QGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant& /*! \reimp */ +QSizeF QGraphicsWebView::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const +{ + if (which == Qt::PreferredSize) + return QSizeF(800, 600); // ### + return QGraphicsWidget::sizeHint(which, constraint); +} + +/*! \reimp +*/ +QVariant QGraphicsWebView::inputMethodQuery(Qt::InputMethodQuery query) const +{ + if (d->page) + return d->page->inputMethodQuery(query); + return QVariant(); +} + +/*! \reimp +*/ bool QGraphicsWebView::event(QEvent* event) { // Re-implemented in order to allows fixing event-related bugs in patch releases. @@ -293,7 +368,6 @@ bool QGraphicsWebView::event(QEvent* event) #endif // QT_NO_CONTEXTMENU { #ifndef QT_NO_CURSOR -#if QT_VERSION >= 0x040400 if (event->type() == QEvent::CursorChange) { // An unsetCursor will set the cursor to Qt::ArrowCursor. // Thus this cursor change might be a QWidget::unsetCursor() @@ -307,7 +381,6 @@ bool QGraphicsWebView::event(QEvent* event) d->resetCursor(); } #endif -#endif } } return QGraphicsWidget::event(event); @@ -345,20 +418,22 @@ void QGraphicsWebView::setPage(QWebPage* page) QWebFrame* mainFrame = d->page->mainFrame(); - connect(mainFrame, SIGNAL(titleChanged(const QString&)), - this, SIGNAL(titleChanged(const QString&))); + connect(mainFrame, SIGNAL(titleChanged(QString)), + this, SIGNAL(titleChanged(QString))); connect(mainFrame, SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); - connect(mainFrame, SIGNAL(urlChanged(const QUrl&)), - this, SIGNAL(urlChanged(const QUrl&))); + connect(mainFrame, SIGNAL(urlChanged(QUrl)), + this, SIGNAL(urlChanged(QUrl))); connect(d->page, SIGNAL(loadStarted()), this, SIGNAL(loadStarted())); connect(d->page, SIGNAL(loadProgress(int)), - this, SLOT(_q_doLoadProgress(int))); + this, SIGNAL(loadProgress(int))); connect(d->page, SIGNAL(loadFinished(bool)), this, SLOT(_q_doLoadFinished(bool))); - connect(d->page, SIGNAL(statusBarMessage(const QString&)), - this, SLOT(_q_setStatusBarMessage(const QString&))); + connect(d->page, SIGNAL(statusBarMessage(QString)), + this, SIGNAL(statusBarMessage(QString))); + connect(d->page, SIGNAL(linkClicked(QUrl)), + this, SIGNAL(linkClicked(QUrl))); } /*! @@ -429,7 +504,6 @@ void QGraphicsWebView::setZoomFactor(qreal factor) return; page()->mainFrame()->setZoomFactor(factor); - emit zoomFactorChanged(); } qreal QGraphicsWebView::zoomFactor() const @@ -466,21 +540,6 @@ void QGraphicsWebView::setGeometry(const QRectF& rect) } /*! - \property QGraphicsWebView::status - \brief the load status message. - - Provides the latest status message set during the load of a URL. - Commonly shown by Status Bar widgets. - - \sa statusChanged() -*/ - -QString QGraphicsWebView::status() const -{ - return d->statusBarMessage; -} - -/*! Convenience slot that stops loading the document. \sa reload(), loadFinished() @@ -527,15 +586,6 @@ void QGraphicsWebView::reload() } /*! - \property QGraphicsWebView::progress - \brief the progress of loading the current URL, from 0 to 1. -*/ -qreal QGraphicsWebView::progress() const -{ - return d->progress; -} - -/*! Loads the specified \a url and displays it. \note The view remains the same until enough data has arrived to display the new \a url. @@ -567,15 +617,14 @@ void QGraphicsWebView::load(const QNetworkRequest& request, } /*! - \property QGraphicsWebView::html - This property provides an HTML interface to the text in the webview. + Sets the content of the web view to the specified \a html. - When setting this property, external objects such as stylesheets or images - referenced in the HTML document are located relative to \a baseUrl. + External objects such as stylesheets or images referenced in the HTML + document are located relative to \a baseUrl. The \a html is loaded immediately; external objects are loaded asynchronously. - When using these methods, WebKit assumes that external resources such as + When using this method, WebKit assumes that external resources such as JavaScript programs or style sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external script can be specified through the charset attribute of the HTML script tag. Alternatively, the @@ -588,11 +637,6 @@ void QGraphicsWebView::setHtml(const QString& html, const QUrl& baseUrl) page()->mainFrame()->setHtml(html, baseUrl); } -QString QGraphicsWebView::toHtml() const -{ - return page()->mainFrame()->toHtml(); -} - /*! Sets the content of the web graphicsitem 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 @@ -622,22 +666,19 @@ QWebHistory* QGraphicsWebView::history() const } /*! - \property QGraphicsWebView::interactive - \brief controls whether the item responds to mouse and key events. -*/ + \property QGraphicsWebView::modified + \brief whether the document was modified by the user -bool QGraphicsWebView::isInteractive() const -{ - return d->interactive; -} + Parts of HTML documents can be editable for example through the + \c{contenteditable} attribute on HTML elements. -void QGraphicsWebView::setInteractive(bool allowed) + By default, this property is false. +*/ +bool QGraphicsWebView::isModified() const { - if (d->interactive == allowed) - return; - - d->interactive = allowed; - emit interactivityChanged(); + if (d->page) + return d->page->isModified(); + return false; } /*! @@ -654,11 +695,53 @@ QWebSettings* QGraphicsWebView::settings() const return page()->settings(); } +/*! + Returns a pointer to a QAction that encapsulates the specified web action \a action. +*/ +QAction *QGraphicsWebView::pageAction(QWebPage::WebAction action) const +{ + return page()->action(action); +} + +/*! + Triggers the specified \a action. If it is a checkable action the specified + \a checked state is assumed. + + \sa pageAction() +*/ +void QGraphicsWebView::triggerPageAction(QWebPage::WebAction action, bool checked) +{ + page()->triggerAction(action, checked); +} + +/*! + Finds the specified string, \a subString, in the page, using the given \a options. + + If the HighlightAllOccurrences flag is passed, the function will highlight all occurrences + that exist in the page. All subsequent calls will extend the highlight, rather than + replace it, with occurrences of the new string. + + If the HighlightAllOccurrences flag is not passed, the function will select an occurrence + and all subsequent calls will replace the current occurrence with the next one. + + To clear the selection, just pass an empty string. + + Returns true if \a subString was found; otherwise returns false. + + \sa QWebPage::selectedText(), QWebPage::selectionChanged() +*/ +bool QGraphicsWebView::findText(const QString &subString, QWebPage::FindFlags options) +{ + if (d->page) + return d->page->findText(subString, options); + return false; +} + /*! \reimp */ void QGraphicsWebView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); QMouseEvent me = QMouseEvent(QEvent::MouseMove, ev->pos().toPoint(), Qt::NoButton, @@ -682,7 +765,7 @@ void QGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent* ev) */ void QGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -696,7 +779,7 @@ void QGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -710,7 +793,7 @@ void QGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -724,7 +807,7 @@ void QGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -738,7 +821,7 @@ void QGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) */ void QGraphicsWebView::keyPressEvent(QKeyEvent* ev) { - if (d->interactive && d->page) + if (d->page) d->page->event(ev); if (!ev->isAccepted()) @@ -749,7 +832,7 @@ void QGraphicsWebView::keyPressEvent(QKeyEvent* ev) */ void QGraphicsWebView::keyReleaseEvent(QKeyEvent* ev) { - if (d->interactive && d->page) + if (d->page) d->page->event(ev); if (!ev->isAccepted()) @@ -791,10 +874,8 @@ bool QGraphicsWebView::focusNextPrevChild(bool next) void QGraphicsWebView::dragEnterEvent(QGraphicsSceneDragDropEvent* ev) { #ifndef QT_NO_DRAGANDDROP - //if (d->page) - // d->page->event(ev); - //Just remove this line below when the code above is working - Q_UNUSED(ev); + if (d->page) + d->page->event(ev); #else Q_UNUSED(ev); #endif @@ -805,7 +886,7 @@ void QGraphicsWebView::dragEnterEvent(QGraphicsSceneDragDropEvent* ev) void QGraphicsWebView::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev) { #ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -823,7 +904,7 @@ void QGraphicsWebView::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev) void QGraphicsWebView::dragMoveEvent(QGraphicsSceneDragDropEvent* ev) { #ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -841,7 +922,7 @@ void QGraphicsWebView::dragMoveEvent(QGraphicsSceneDragDropEvent* ev) void QGraphicsWebView::dropEvent(QGraphicsSceneDragDropEvent* ev) { #ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -872,7 +953,7 @@ void QGraphicsWebView::contextMenuEvent(QGraphicsSceneContextMenuEvent* ev) */ void QGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent* ev) { - if (d->interactive && d->page) { + if (d->page) { const bool accepted = ev->isAccepted(); d->page->event(ev); ev->setAccepted(accepted); @@ -887,11 +968,40 @@ void QGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent* ev) */ void QGraphicsWebView::inputMethodEvent(QInputMethodEvent* ev) { - if (d->interactive && d->page) + if (d->page) d->page->event(ev); if (!ev->isAccepted()) QGraphicsItem::inputMethodEvent(ev); } +/*! + \fn void QGraphicsWebView::statusBarMessage(const QString& text) + + This signal is emitted when the statusbar \a text is changed by the page. +*/ + +/*! + \fn void QGraphicsWebView::loadProgress(int progress) + + This signal is emitted every time an element in the web page + completes loading and the overall loading progress advances. + + This signal tracks the progress of all child frames. + + The current value is provided by \a progress and scales from 0 to 100, + which is the default range of QProgressBar. + + \sa loadStarted(), loadFinished() +*/ + +/*! + \fn void QGraphicsWebView::linkClicked(const QUrl &url) + + This signal is emitted whenever the user clicks on a link and the page's linkDelegationPolicy + property is set to delegate the link handling for the specified \a url. + + \sa QWebPage::linkDelegationPolicy() +*/ + #include "moc_qgraphicswebview.cpp" diff --git a/WebKit/qt/Api/qgraphicswebview.h b/WebKit/qt/Api/qgraphicswebview.h index 43cf59a..f3afb4c 100644 --- a/WebKit/qt/Api/qgraphicswebview.h +++ b/WebKit/qt/Api/qgraphicswebview.h @@ -21,6 +21,7 @@ #define QGraphicsWebView_h #include "qwebkitglobal.h" +#include "qwebpage.h" #include <QtCore/qurl.h> #include <QtGui/qevent.h> #include <QtGui/qgraphicswidget.h> @@ -39,17 +40,14 @@ class QWEBKIT_EXPORT QGraphicsWebView : public QGraphicsWidget { Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged) - Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) - Q_PROPERTY(QString status READ status NOTIFY statusChanged) + Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor) - Q_PROPERTY(QString html READ toHtml WRITE setHtml) Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) - Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) - Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactivityChanged) + Q_PROPERTY(bool modified READ isModified) public: - QGraphicsWebView(QGraphicsItem* parent = 0); + explicit QGraphicsWebView(QGraphicsItem* parent = 0); ~QGraphicsWebView(); QWebPage* page() const; @@ -64,15 +62,11 @@ public: qreal zoomFactor() const; void setZoomFactor(qreal); - bool isInteractive() const; - void setInteractive(bool); - - qreal progress() const; + bool isModified() const; void load(const QUrl &url); void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray& body = QByteArray()); - QString toHtml() const; void setHtml(const QString& html, const QUrl& baseUrl = QUrl()); // FIXME: Consider rename to setHtml? void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl()); @@ -80,7 +74,10 @@ public: QWebHistory* history() const; QWebSettings* settings() const; - QString status() const; + QAction* pageAction(QWebPage::WebAction action) const; + void triggerPageAction(QWebPage::WebAction action, bool checked = false); + + bool findText(const QString& subString, QWebPage::FindFlags options = 0); virtual void setGeometry(const QRectF& rect); virtual void updateGeometry(); @@ -88,6 +85,10 @@ public: virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value); virtual bool event(QEvent*); + virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint) const; + + virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; + public Q_SLOTS: void stop(); void back(); @@ -98,13 +99,12 @@ Q_SIGNALS: void loadStarted(); void loadFinished(bool); - void progressChanged(qreal); - void interactivityChanged(); + void loadProgress(int progress); void urlChanged(const QUrl&); void titleChanged(const QString&); void iconChanged(); - void statusChanged(); - void zoomFactorChanged(); + void statusBarMessage(const QString& message); + void linkClicked(const QUrl&); protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent*); @@ -133,9 +133,7 @@ protected: virtual bool sceneEvent(QEvent*); private: - Q_PRIVATE_SLOT(d, void _q_doLoadProgress(int progress)) Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success)) - Q_PRIVATE_SLOT(d, void _q_setStatusBarMessage(const QString& message)) QGraphicsWebViewPrivate* const d; friend class QGraphicsWebViewPrivate; diff --git a/WebKit/qt/Api/qwebelement.cpp b/WebKit/qt/Api/qwebelement.cpp index 6305d10..441bec7 100644 --- a/WebKit/qt/Api/qwebelement.cpp +++ b/WebKit/qt/Api/qwebelement.cpp @@ -99,6 +99,14 @@ public: It is possible to replace the contents of child elements using setPlainText() and setInnerXml(). To replace the element itself and its contents, use setOuterXml(). + + \section1 Examples + + The \l{DOM Traversal Example} shows one way to traverse documents in a running + example. + + The \l{Simple Selector Example} can be used to experiment with the searching + features of this class and provides sample code you can start working with. */ /*! @@ -195,8 +203,7 @@ bool QWebElement::isNull() const \a selectorQuery. If there are no matching elements, an empty list is returned. - \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} - syntax is used for the query. + \l{Standard CSS2 selector} syntax is used for the query. \note This search is performed recursively. @@ -211,8 +218,7 @@ QWebElementCollection QWebElement::findAll(const QString &selectorQuery) const Returns the first child element that matches the given CSS selector \a selectorQuery. - \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} - syntax is used for the query. + \l{Standard CSS2 selector} syntax is used for the query. \note This search is performed recursively. @@ -453,6 +459,30 @@ bool QWebElement::hasAttributes() const } /*! + Return the list of attributes for the namespace given as \a namespaceUri. + + \sa attribute(), setAttribute() +*/ +QStringList QWebElement::attributeNames(const QString& namespaceUri) const +{ + if (!m_element) + return QStringList(); + + QStringList attributeNameList; + const NamedNodeMap* const attrs = m_element->attributes(/* read only = */ true); + if (attrs) { + const String namespaceUriString(namespaceUri); // convert QString -> String once + const unsigned attrsCount = attrs->length(); + for (unsigned i = 0; i < attrsCount; ++i) { + const Attribute* const attribute = attrs->attributeItem(i); + if (namespaceUriString == attribute->namespaceURI()) + attributeNameList.append(attribute->localName()); + } + } + return attributeNameList; +} + +/*! Returns true if the element has keyboard input focus; otherwise, returns false \sa setFocus() @@ -1661,22 +1691,6 @@ QList<QWebElement> QWebElementCollection::toList() const QWebElementCollection provides STL style const iterators for fast low-level access to the elements. QWebElementCollection::const_iterator allows you to iterate over a QWebElementCollection. - - The default QWebElementCollection::const_iterator constructors creates an uninitialized iterator. You must initialize - it using a QWebElementCollection function like QWebElementCollection::begin() or QWebElementCollection::end() before you - can start iterating. -*/ - -/*! - \fn QWebElementCollection::const_iterator::const_iterator() - - Constructs an uninitialized iterator. - - Functions like operator*() and operator++() should not be called on - an uninitialized iterator. Use operator=() to assign a value - to it before using it. - - \sa QWebElementCollection::begin() */ /*! @@ -1824,3 +1838,193 @@ QList<QWebElement> QWebElementCollection::toList() const Returns true if the element pointed to by this iterator is greater than or equal to the element pointed to by the \a other iterator. */ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::begin() + + Returns an STL-style iterator pointing to the first element in the collection. + + \sa end() +*/ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::end() + + Returns an STL-style iterator pointing to the imaginary element after the + last element in the list. + + \sa begin() +*/ + +/*! + \fn QWebElementCollection::const_iterator QWebElementCollection::constBegin() const + + Returns an STL-style iterator pointing to the first element in the collection. + + \sa end() +*/ + +/*! + \fn QWebElementCollection::const_iterator QWebElementCollection::constEnd() const + + Returns an STL-style iterator pointing to the imaginary element after the + last element in the list. + + \sa begin() +*/ + +/*! + \class QWebElementCollection::iterator + \since 4.6 + \brief The QWebElementCollection::iterator class provides an STL-style iterator for QWebElementCollection. + + QWebElementCollection provides STL style iterators for fast low-level access to the elements. + + QWebElementCollection::iterator allows you to iterate over a QWebElementCollection. +*/ + +/*! + \fn QWebElementCollection::iterator::iterator(const iterator &other) + + Constructs a copy of \a other. +*/ + +/*! + \fn QWebElementCollection::iterator::iterator(const QWebElementCollection *collection, int index) + \internal +*/ + +/*! + \fn const QWebElement QWebElementCollection::iterator::operator*() const + + Returns the current element. +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator==(const iterator &other) const + + Returns true if \a other points to the same item as this iterator; + otherwise returns false. + + \sa operator!=() +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator!=(const iterator &other) const + + Returns true if \a other points to a different element than this; + iterator; otherwise returns false. + + \sa operator==() +*/ + +/*! + \fn QWebElementCollection::iterator &QWebElementCollection::iterator::operator++() + + The prefix ++ operator (\c{++it}) advances the iterator to the next element in the collection + and returns an iterator to the new current element. + + Calling this function on QWebElementCollection::end() leads to undefined results. + + \sa operator--() +*/ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::iterator::operator++(int) + + \overload + + The postfix ++ operator (\c{it++}) advances the iterator to the next element in the collection + and returns an iterator to the previously current element. + + Calling this function on QWebElementCollection::end() leads to undefined results. +*/ + +/*! + \fn QWebElementCollection::iterator &QWebElementCollection::iterator::operator--() + + The prefix -- operator (\c{--it}) makes the preceding element current and returns an + iterator to the new current element. + + Calling this function on QWebElementCollection::begin() leads to undefined results. + + \sa operator++() +*/ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::iterator::operator--(int) + + \overload + + The postfix -- operator (\c{it--}) makes the preceding element current and returns + an iterator to the previously current element. +*/ + +/*! + \fn QWebElementCollection::iterator &QWebElementCollection::iterator::operator+=(int j) + + Advances the iterator by \a j elements. If \a j is negative, the iterator goes backward. + + \sa operator-=(), operator+() +*/ + +/*! + \fn QWebElementCollection::iterator &QWebElementCollection::iterator::operator-=(int j) + + Makes the iterator go back by \a j elements. If \a j is negative, the iterator goes forward. + + \sa operator+=(), operator-() +*/ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::iterator::operator+(int j) const + + Returns an iterator to the element at \a j positions forward from this iterator. If \a j + is negative, the iterator goes backward. + + \sa operator-(), operator+=() +*/ + +/*! + \fn QWebElementCollection::iterator QWebElementCollection::iterator::operator-(int j) const + + Returns an iterator to the element at \a j positiosn backward from this iterator. + If \a j is negative, the iterator goes forward. + + \sa operator+(), operator-=() +*/ + +/*! + \fn int QWebElementCollection::iterator::operator-(iterator other) const + + Returns the number of elements between the item point to by \a other + and the element pointed to by this iterator. +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator<(const iterator &other) const + + Returns true if the element pointed to by this iterator is less than the element pointed to + by the \a other iterator. +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator<=(const iterator &other) const + + Returns true if the element pointed to by this iterator is less than or equal to the + element pointed to by the \a other iterator. +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator>(const iterator &other) const + + Returns true if the element pointed to by this iterator is greater than the element pointed to + by the \a other iterator. +*/ + +/*! + \fn bool QWebElementCollection::iterator::operator>=(const iterator &other) const + + Returns true if the element pointed to by this iterator is greater than or equal to the + element pointed to by the \a other iterator. +*/ diff --git a/WebKit/qt/Api/qwebelement.h b/WebKit/qt/Api/qwebelement.h index a18d262..3833070 100644 --- a/WebKit/qt/Api/qwebelement.h +++ b/WebKit/qt/Api/qwebelement.h @@ -21,6 +21,7 @@ #define QWEBELEMENT_H #include <QString> +#include <QStringList> #include <QRect> #include <QVariant> #include <QExplicitlySharedDataPointer> @@ -72,6 +73,7 @@ public: void removeAttribute(const QString& name); void removeAttributeNS(const QString& namespaceUri, const QString& name); bool hasAttributes() const; + QStringList attributeNames(const QString& namespaceUri = QString()) const; QStringList classes() const; bool hasClass(const QString& name) const; @@ -177,6 +179,7 @@ public: int count() const; QWebElement at(int i) const; + inline QWebElement operator[](int i) const { return at(i); } inline QWebElement first() const { return at(0); } inline QWebElement last() const { return at(count() - 1); } @@ -185,39 +188,69 @@ public: class const_iterator { public: - int i; - const QWebElementCollection *s; - - inline const_iterator(const QWebElementCollection *collection, int index) : i(index), s(collection) {} - inline const_iterator(const const_iterator &o) : i(o.i), s(o.s) {} + inline const_iterator(const QWebElementCollection* collection, int index) : i(index), collection(collection) {} + inline const_iterator(const const_iterator& o) : i(o.i), collection(o.collection) {} - inline const QWebElement operator*() const { return s->at(i); } + inline const QWebElement operator*() const { return collection->at(i); } - inline bool operator==(const const_iterator& o) const { return i == o.i && s == o.s; } - inline bool operator!=(const const_iterator& o) const { return i != o.i || s != o.s; } + inline bool operator==(const const_iterator& o) const { return i == o.i && collection == o.collection; } + inline bool operator!=(const const_iterator& o) const { return i != o.i || collection != o.collection; } inline bool operator<(const const_iterator& o) const { return i < o.i; } inline bool operator<=(const const_iterator& o) const { return i <= o.i; } inline bool operator>(const const_iterator& o) const { return i > o.i; } inline bool operator>=(const const_iterator& o) const { return i >= o.i; } - inline const_iterator &operator++() { ++i; return *this; } - inline const_iterator operator++(int) { const_iterator n(s, i); ++i; return n; } - inline const_iterator &operator--() { i--; return *this; } - inline const_iterator operator--(int) { const_iterator n(s, i); i--; return n; } - inline const_iterator &operator+=(int j) { i += j; return *this; } - inline const_iterator &operator-=(int j) { i -= j; return *this; } - inline const_iterator operator+(int j) const { return const_iterator(s, i + j); } - inline const_iterator operator-(int j) const { return const_iterator(s, i - j); } + inline const_iterator& operator++() { ++i; return *this; } + inline const_iterator operator++(int) { const_iterator n(collection, i); ++i; return n; } + inline const_iterator& operator--() { i--; return *this; } + inline const_iterator operator--(int) { const_iterator n(collection, i); i--; return n; } + inline const_iterator& operator+=(int j) { i += j; return *this; } + inline const_iterator& operator-=(int j) { i -= j; return *this; } + inline const_iterator operator+(int j) const { return const_iterator(collection, i + j); } + inline const_iterator operator-(int j) const { return const_iterator(collection, i - j); } inline int operator-(const_iterator j) const { return i - j.i; } private: - inline const_iterator() : i(0), s(0) {} + int i; + const QWebElementCollection* const collection; }; friend class const_iterator; - inline const_iterator begin() const { return const_iterator(this, 0); } - inline const_iterator end() const { return const_iterator(this, count()); } - inline QWebElement operator[](int i) const { return at(i); } + inline const_iterator begin() const { return constBegin(); } + inline const_iterator end() const { return constEnd(); } + inline const_iterator constBegin() const { return const_iterator(this, 0); } + inline const_iterator constEnd() const { return const_iterator(this, count()); }; + + class iterator { + public: + inline iterator(const QWebElementCollection* collection, int index) : i(index), collection(collection) {} + inline iterator(const iterator& o) : i(o.i), collection(o.collection) {} + + inline QWebElement operator*() const { return collection->at(i); } + + inline bool operator==(const iterator& o) const { return i == o.i && collection == o.collection; } + inline bool operator!=(const iterator& o) const { return i != o.i || collection != o.collection; } + inline bool operator<(const iterator& o) const { return i < o.i; } + inline bool operator<=(const iterator& o) const { return i <= o.i; } + inline bool operator>(const iterator& o) const { return i > o.i; } + inline bool operator>=(const iterator& o) const { return i >= o.i; } + + inline iterator& operator++() { ++i; return *this; } + inline iterator operator++(int) { iterator n(collection, i); ++i; return n; } + inline iterator& operator--() { i--; return *this; } + inline iterator operator--(int) { iterator n(collection, i); i--; return n; } + inline iterator& operator+=(int j) { i += j; return *this; } + inline iterator& operator-=(int j) { i -= j; return *this; } + inline iterator operator+(int j) const { return iterator(collection, i + j); } + inline iterator operator-(int j) const { return iterator(collection, i - j); } + inline int operator-(iterator j) const { return i - j.i; } + private: + int i; + const QWebElementCollection* const collection; + }; + friend class iterator; + inline iterator begin() { return iterator(this, 0); } + inline iterator end() { return iterator(this, count()); } private: QExplicitlySharedDataPointer<QWebElementCollectionPrivate> d; }; diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index 606dae4..ef97c3b 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -56,6 +56,7 @@ #include "Scrollbar.h" #include "SelectionController.h" #include "SubstituteData.h" +#include "SVGSMILElement.h" #include "htmlediting.h" #include "markup.h" #include "qt_instance.h" @@ -77,14 +78,7 @@ #include <qpainter.h> #include <qprinter.h> #include <qregion.h> - -#if QT_VERSION < 0x040400 -#include "qwebnetworkinterface.h" -#endif - -#if QT_VERSION >= 0x040400 #include <qnetworkrequest.h> -#endif using namespace WebCore; @@ -93,6 +87,11 @@ QT_BEGIN_NAMESPACE extern Q_GUI_EXPORT int qt_defaultDpi(); QT_END_NAMESPACE +bool QWEBKIT_EXPORT qt_drt_hasDocumentElement(QWebFrame* qframe) +{ + return QWebFramePrivate::core(qframe)->document()->documentElement(); +} + void QWEBKIT_EXPORT qt_drt_setJavaScriptProfilingEnabled(QWebFrame* qframe, bool enabled) { #if ENABLE(JAVASCRIPT_DEBUGGER) @@ -150,6 +149,31 @@ bool QWEBKIT_EXPORT qt_drt_pauseTransitionOfProperty(QWebFrame *qframe, const QS return controller->pauseTransitionAtTime(coreNode->renderer(), propertyName, time); } +// Pause a given SVG animation on the target node at a specific time. +// This method is only intended to be used for testing the SVG animation system. +bool QWEBKIT_EXPORT qt_drt_pauseSVGAnimation(QWebFrame *qframe, const QString &animationId, double time, const QString &elementId) +{ +#if !ENABLE(SVG) + return false; +#else + Frame* frame = QWebFramePrivate::core(qframe); + if (!frame) + return false; + + Document* doc = frame->document(); + Q_ASSERT(doc); + + if (!doc->svgExtensions()) + return false; + + Node* coreNode = doc->getElementById(animationId); + if (!coreNode || !SVGSMILElement::isSMILElement(coreNode)) + return false; + + return doc->accessSVGExtensions()->sampleAnimationAtTime(elementId, static_cast<SVGSMILElement*>(coreNode), time); +#endif +} + // Returns the total number of currently running animations (includes both CSS transitions and CSS animations). int QWEBKIT_EXPORT qt_drt_numberOfActiveAnimations(QWebFrame *qframe) { @@ -243,7 +267,7 @@ WebCore::Scrollbar* QWebFramePrivate::verticalScrollBar() const return frame->view()->verticalScrollbar(); } -void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer layer, const QRegion &clip) +void QWebFramePrivate::renderContentsLayerAbsoluteCoords(GraphicsContext* context, const QRegion& clip) { if (!frame->view() || !frame->contentRenderer()) return; @@ -252,15 +276,42 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l if (vector.isEmpty()) return; - GraphicsContext context(painter); - if (context.paintingDisabled() && !context.updatingControlTints()) + QPainter* painter = context->platformContext(); + + WebCore::FrameView* view = frame->view(); + view->layoutIfNeededRecursive(); + + for (int i = 0; i < vector.size(); ++i) { + const QRect& clipRect = vector.at(i); + + painter->save(); + painter->setClipRect(clipRect, Qt::IntersectClip); + + context->save(); + view->paintContents(context, clipRect); + context->restore(); + + painter->restore(); + } +} + +void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QWebFrame::RenderLayer layer, const QRegion& clip) +{ + if (!frame->view() || !frame->contentRenderer()) return; + QVector<QRect> vector = clip.rects(); + if (vector.isEmpty()) + return; + + QPainter* painter = context->platformContext(); + WebCore::FrameView* view = frame->view(); view->layoutIfNeededRecursive(); for (int i = 0; i < vector.size(); ++i) { const QRect& clipRect = vector.at(i); + QRect intersectedRect = clipRect.intersected(view->frameRect()); painter->save(); @@ -270,39 +321,41 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l int y = view->y(); if (layer & QWebFrame::ContentsLayer) { - context.save(); + context->save(); int scrollX = view->scrollX(); int scrollY = view->scrollY(); QRect rect = intersectedRect; - context.translate(x, y); + context->translate(x, y); rect.translate(-x, -y); - context.translate(-scrollX, -scrollY); + context->translate(-scrollX, -scrollY); rect.translate(scrollX, scrollY); - context.clip(view->visibleContentRect()); + context->clip(view->visibleContentRect()); - view->paintContents(&context, rect); + view->paintContents(context, rect); - context.restore(); + context->restore(); } if (layer & QWebFrame::ScrollBarLayer && !view->scrollbarsSuppressed() && (view->horizontalScrollbar() || view->verticalScrollbar())) { - context.save(); + context->save(); QRect rect = intersectedRect; - context.translate(x, y); + context->translate(x, y); rect.translate(-x, -y); - view->paintScrollbars(&context, rect); + view->paintScrollbars(context, rect); - context.restore(); + context->restore(); } +#if ENABLE(PAN_SCROLLING) if (layer & QWebFrame::PanIconLayer) - view->paintPanScrollIcon(&context); + view->paintPanScrollIcon(context); +#endif painter->restore(); } @@ -324,7 +377,7 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l the HTML content readily available, you can use setHtml() instead. The page() function returns a pointer to the web page object. See - \l{Elements of QWebView} for an explanation of how web + \l{QWebView}{Elements of QWebView} for an explanation of how web frames are related to a web page and web view. The QWebFrame class also offers methods to retrieve both the URL currently @@ -356,6 +409,19 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l \sa QWebPage */ +/*! + \enum QWebFrame::RenderLayer + + This enum describes the layers available for rendering using \l{QWebFrame::}{render()}. + The layers can be OR-ed together from the following list: + + \value ContentsLayer The web content of the frame + \value ScrollBarLayer The scrollbars of the frame + \value PanIconLayer The icon used when panning the frame + + \value AllLayers Includes all the above layers +*/ + QWebFrame::QWebFrame(QWebPage *parent, QWebFrameData *frameData) : QObject(parent) , d(new QWebFramePrivate) @@ -471,7 +537,9 @@ QString QWebFrame::toPlainText() const d->frame->view()->layout(); Element *documentElement = d->frame->document()->documentElement(); - return documentElement->innerText(); + if (documentElement) + return documentElement->innerText(); + return QString(); } /*! @@ -483,7 +551,7 @@ QString QWebFrame::renderTreeDump() const if (d->frame->view() && d->frame->view()->layoutPending()) d->frame->view()->layout(); - return externalRepresentation(d->frame->contentRenderer()); + return externalRepresentation(d->frame); } /*! @@ -655,51 +723,9 @@ QWebPage *QWebFrame::page() const */ void QWebFrame::load(const QUrl &url) { -#if QT_VERSION < 0x040400 - load(QWebNetworkRequest(ensureAbsoluteUrl(url))); -#else load(QNetworkRequest(ensureAbsoluteUrl(url))); -#endif -} - -#if QT_VERSION < 0x040400 -/*! - Loads a network request, \a req, into this frame. - - \note The view remains the same until enough data has arrived to display the new url. -*/ -void QWebFrame::load(const QWebNetworkRequest &req) -{ - if (d->parentFrame()) - d->page->d->insideOpenCall = true; - - QUrl url = ensureAbsoluteUrl(req.url()); - QHttpRequestHeader httpHeader = req.httpHeader(); - QByteArray postData = req.postData(); - - WebCore::ResourceRequest request(url); - - 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()) - request.setHTTPBody(WebCore::FormData::create(postData.constData(), postData.size())); - - d->frame->loader()->load(request, false); - - if (d->parentFrame()) - d->page->d->insideOpenCall = false; } -#else - /*! Loads a network request, \a req, into this frame, using the method specified in \a operation. @@ -734,6 +760,11 @@ void QWebFrame::load(const QNetworkRequest &req, case QNetworkAccessManager::PostOperation: request.setHTTPMethod("POST"); break; +#if QT_VERSION >= 0x040600 + case QNetworkAccessManager::DeleteOperation: + request.setHTTPMethod("DELETE"); + break; +#endif case QNetworkAccessManager::UnknownOperation: // eh? break; @@ -753,7 +784,6 @@ void QWebFrame::load(const QNetworkRequest &req, if (d->parentFrame()) d->page->d->insideOpenCall = false; } -#endif /*! Sets the content of this frame to \a html. \a baseUrl is optional and used to resolve relative @@ -862,11 +892,13 @@ void QWebFrame::setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPol d->horizontalScrollBarPolicy = policy; if (d->frame->view()) { d->frame->view()->setHorizontalScrollbarMode((ScrollbarMode)policy); + d->frame->view()->updateCanHaveScrollbars(); } } else { d->verticalScrollBarPolicy = policy; if (d->frame->view()) { d->frame->view()->setVerticalScrollbarMode((ScrollbarMode)policy); + d->frame->view()->updateCanHaveScrollbars(); } } } @@ -999,29 +1031,41 @@ void QWebFrame::setScrollPosition(const QPoint &pos) void QWebFrame::render(QPainter* painter, RenderLayer layer, const QRegion& clip) { + GraphicsContext context(painter); + if (context.paintingDisabled() && !context.updatingControlTints()) + return; + if (!clip.isEmpty()) - d->renderPrivate(painter, layer, clip); + d->renderRelativeCoords(&context, layer, clip); else if (d->frame->view()) - d->renderPrivate(painter, layer, QRegion(d->frame->view()->frameRect())); + d->renderRelativeCoords(&context, layer, QRegion(d->frame->view()->frameRect())); } /*! Render the frame into \a painter clipping to \a clip. */ -void QWebFrame::render(QPainter *painter, const QRegion &clip) +void QWebFrame::render(QPainter* painter, const QRegion& clip) { - d->renderPrivate(painter, AllLayers, clip); + GraphicsContext context(painter); + if (context.paintingDisabled() && !context.updatingControlTints()) + return; + + d->renderRelativeCoords(&context, AllLayers, clip); } /*! Render the frame into \a painter. */ -void QWebFrame::render(QPainter *painter) +void QWebFrame::render(QPainter* painter) { if (!d->frame->view()) return; - d->renderPrivate(painter, AllLayers, QRegion(d->frame->view()->frameRect())); + GraphicsContext context(painter); + if (context.paintingDisabled() && !context.updatingControlTints()) + return; + + d->renderRelativeCoords(&context, AllLayers, QRegion(d->frame->view()->frameRect())); } /*! diff --git a/WebKit/qt/Api/qwebframe.h b/WebKit/qt/Api/qwebframe.h index 08285f8..c2a6e9b 100644 --- a/WebKit/qt/Api/qwebframe.h +++ b/WebKit/qt/Api/qwebframe.h @@ -26,9 +26,7 @@ #include <QtCore/qvariant.h> #include <QtGui/qicon.h> #include <QtScript/qscriptengine.h> -#if QT_VERSION >= 0x040400 #include <QtNetwork/qnetworkaccessmanager.h> -#endif #include "qwebkitglobal.h" QT_BEGIN_NAMESPACE @@ -123,13 +121,9 @@ public: QWebPage *page() const; void load(const QUrl &url); -#if QT_VERSION < 0x040400 - void load(const QWebNetworkRequest &request); -#else void load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray()); -#endif void setHtml(const QString &html, const QUrl &baseUrl = QUrl()); void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl()); diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h index 081e65d..045c70e 100644 --- a/WebKit/qt/Api/qwebframe_p.h +++ b/WebKit/qt/Api/qwebframe_p.h @@ -25,6 +25,7 @@ #include "qwebpage_p.h" #include "EventHandler.h" +#include "GraphicsContext.h" #include "KURL.h" #include "PlatformString.h" #include "qwebelement.h" @@ -81,7 +82,8 @@ public: static WebCore::Frame* core(QWebFrame*); static QWebFrame* kit(WebCore::Frame*); - void renderPrivate(QPainter*, QWebFrame::RenderLayer, const QRegion& clip); + void renderRelativeCoords(WebCore::GraphicsContext*, QWebFrame::RenderLayer, const QRegion& clip); + void renderContentsLayerAbsoluteCoords(WebCore::GraphicsContext*, const QRegion& clip); QWebFrame *q; Qt::ScrollBarPolicy horizontalScrollBarPolicy; diff --git a/WebKit/qt/Api/qwebhistory.cpp b/WebKit/qt/Api/qwebhistory.cpp index f765daa..d852012 100644 --- a/WebKit/qt/Api/qwebhistory.cpp +++ b/WebKit/qt/Api/qwebhistory.cpp @@ -494,22 +494,16 @@ QDataStream& operator<<(QDataStream& target, const QWebHistory& history) { QWebHistoryPrivate* d = history.d; - QByteArray buffer; - QDataStream stream(&buffer, QIODevice::WriteOnly); - int version = DefaultHistoryVersion; - stream << version; - stream << history.count() << history.currentItemIndex(); + target << version; + target << history.count() << history.currentItemIndex(); const WebCore::HistoryItemVector &items = d->lst->entries(); for (unsigned i = 0; i < items.size(); i++) - items[i].get()->saveState(stream, version); - - if (stream.status() != QDataStream::Ok) - buffer = QByteArray(); // make buffer isNull()==true and isEmpty()==true + items[i].get()->saveState(target, version); - return target << buffer; + return target; } /*! @@ -526,18 +520,14 @@ QDataStream& operator>>(QDataStream& source, QWebHistory& history) { QWebHistoryPrivate* d = history.d; - QByteArray buffer; - source >> buffer; - - QDataStream stream(buffer); int version; - stream >> version; + source >> version; if (version == 1) { int count; int currentIndex; - stream >> count >> currentIndex; + source >> count >> currentIndex; history.clear(); // only if there are elements @@ -546,7 +536,7 @@ QDataStream& operator>>(QDataStream& source, QWebHistory& history) WebCore::HistoryItem* nullItem = d->lst->currentItem(); for (int i = 0; i < count; i++) { WTF::PassRefPtr<WebCore::HistoryItem> item = WebCore::HistoryItem::create(); - item->restoreState(stream, version); + item->restoreState(source, version); d->lst->addItem(item); } d->lst->removeItem(nullItem); diff --git a/WebKit/qt/Api/qwebinspector.cpp b/WebKit/qt/Api/qwebinspector.cpp index 4578dc9..f43cbbf 100644 --- a/WebKit/qt/Api/qwebinspector.cpp +++ b/WebKit/qt/Api/qwebinspector.cpp @@ -50,6 +50,7 @@ \section1 Resources + This class acts mostly as a container and a controller for the inspector. Most of the resources needed by the inspector are owned by the associated QWebPage and are allocated the first time that: \list @@ -57,11 +58,6 @@ \o the QWebInspector is shown. \endlist - This class acts mostly as a container and a controller for the inspector. - You can defer the creation and association of the QWebInspector until - the first emission of QWebPage::webInspectorTriggered() to save additional - resources. - \section1 Inspector configuration persistence The inspector allows the user to configure some options through its @@ -188,9 +184,3 @@ void QWebInspectorPrivate::adjustFrontendSize(const QSize& size) frontend->resize(size); } -/*! - \fn void QWebInspector::windowTitleChanged(const QString& newTitle); - - This is emitted to signal that this widget's title changed to \a newTitle. -*/ - diff --git a/WebKit/qt/Api/qwebinspector.h b/WebKit/qt/Api/qwebinspector.h index bb5bd64..a5c1ed5 100644 --- a/WebKit/qt/Api/qwebinspector.h +++ b/WebKit/qt/Api/qwebinspector.h @@ -39,9 +39,6 @@ public: QSize sizeHint() const; bool event(QEvent*); -Q_SIGNALS: - void windowTitleChanged(const QString& newTitle); - protected: void resizeEvent(QResizeEvent* event); void showEvent(QShowEvent* event); diff --git a/WebKit/qt/Api/qwebkitglobal.h b/WebKit/qt/Api/qwebkitglobal.h index 0885bdc..9e8979f 100644 --- a/WebKit/qt/Api/qwebkitglobal.h +++ b/WebKit/qt/Api/qwebkitglobal.h @@ -40,15 +40,4 @@ # endif #endif -#if QT_VERSION < 0x040400 - #ifndef QT_BEGIN_NAMESPACE - #define QT_BEGIN_NAMESPACE - #endif - - #ifndef QT_END_NAMESPACE - #define QT_END_NAMESPACE - #endif -#endif - - #endif // QWEBKITGLOBAL_H diff --git a/WebKit/qt/Api/qwebnetworkinterface.cpp b/WebKit/qt/Api/qwebnetworkinterface.cpp deleted file mode 100644 index cf99183..0000000 --- a/WebKit/qt/Api/qwebnetworkinterface.cpp +++ /dev/null @@ -1,1315 +0,0 @@ -/* - Copyright (C) 2006 Enrico Ros <enrico.ros@m31engineering.it> - Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" -#include <qglobal.h> -#if QT_VERSION < 0x040400 -#include "qwebframe.h" -#include "qwebnetworkinterface.h" -#include "qwebnetworkinterface_p.h" -#include "qwebpage.h" -#include "qcookiejar.h" -#include <qdebug.h> -#include <qfile.h> -#include <qnetworkproxy.h> -#include <qurl.h> -#include <QAuthenticator> -#include <QCoreApplication> -#include <QSslError> - -#include "ResourceHandle.h" -#include "ResourceHandleClient.h" -#include "ResourceHandleInternal.h" -#include "MIMETypeRegistry.h" -#include "CookieJar.h" - -#if 0 -#define DEBUG qDebug -#else -#define DEBUG if (1) {} else qDebug -#endif - -static QWebNetworkInterface *s_default_interface = 0; -static QWebNetworkManager *s_manager = 0; - -using namespace WebCore; - -uint qHash(const HostInfo &info) -{ - return qHash(info.host) + info.port; -} - -static bool operator==(const HostInfo &i1, const HostInfo &i2) -{ - return i1.port == i2.port && i1.host == i2.host; -} - -enum ParserState { - State_Begin, - State_FirstChar, - State_SecondChar -}; - -/* - * Decode URLs without doing any charset conversion. - * - * Most simple approach to do it without any lookahead. - */ -static QByteArray decodePercentEncoding(const QByteArray& input) -{ - int actualLength = 0; - QByteArray tmpVal; - QByteArray output; - ParserState state = State_Begin; - - output.resize(input.length()); - tmpVal.resize(2); - - for (int i = 0; i < input.length(); ++i) - if (state == State_Begin) { - if (input.at(i) == '%') - state = State_FirstChar; - else - output[actualLength++] = input[i]; - } else if (state == State_FirstChar) { - state = State_SecondChar; - tmpVal[0] = input[i]; - } else if (state == State_SecondChar) { - state = State_Begin; - tmpVal[1] = input[i]; - output[actualLength++] = tmpVal.toShort(0, 16); - } - - output.resize(actualLength); - return output; -} - -void QWebNetworkRequestPrivate::init(const WebCore::ResourceRequest &resourceRequest) -{ - KURL url = resourceRequest.url(); - QUrl qurl = QString(url.string()); - init(resourceRequest.httpMethod(), qurl, &resourceRequest); -} - -void QWebNetworkRequestPrivate::init(const QString& method, const QUrl& url, const WebCore::ResourceRequest* resourceRequest) -{ - httpHeader = QHttpRequestHeader(method, url.toString(QUrl::RemoveScheme|QUrl::RemoveAuthority)); - httpHeader.setValue(QLatin1String("Connection"), QLatin1String("Keep-Alive")); - setURL(url); - - if (resourceRequest) { - httpHeader.setValue(QLatin1String("User-Agent"), resourceRequest->httpUserAgent()); - const QString scheme = url.scheme().toLower(); - if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) { - QString cookies = QCookieJar::cookieJar()->cookies(resourceRequest->url()); - if (!cookies.isEmpty()) - httpHeader.setValue(QLatin1String("Cookie"), cookies); - } - - - const HTTPHeaderMap& loaderHeaders = resourceRequest->httpHeaderFields(); - HTTPHeaderMap::const_iterator end = loaderHeaders.end(); - for (HTTPHeaderMap::const_iterator it = loaderHeaders.begin(); it != end; ++it) - httpHeader.setValue(it->first, it->second); - - // handle and perform a 'POST' request - if (method == "POST") { - Vector<char> data; - resourceRequest->httpBody()->flatten(data); - postData = QByteArray(data.data(), data.size()); - httpHeader.setValue(QLatin1String("content-length"), QString::number(postData.size())); - } - } -} - -void QWebNetworkRequestPrivate::setURL(const QUrl& u) -{ - url = u; - int port = url.port(); - const QString scheme = u.scheme(); - if (port > 0 && (port != 80 || scheme != "http") && (port != 443 || scheme != "https")) - httpHeader.setValue(QLatin1String("Host"), url.host() + QLatin1Char(':') + QString::number(port)); - else - httpHeader.setValue(QLatin1String("Host"), url.host()); -} - -/*! - \class QWebNetworkRequest - \internal - - The QWebNetworkRequest class represents a request for data from the network with all the - necessary information needed for retrieval. This includes the url, extra HTTP header fields - as well as data for a HTTP POST request. -*/ - -QWebNetworkRequest::QWebNetworkRequest() - : d(new QWebNetworkRequestPrivate) -{ -} - -QWebNetworkRequest::QWebNetworkRequest(const QUrl& url, Method method, const QByteArray& postData) - : d(new QWebNetworkRequestPrivate) -{ - d->init(method == Get ? "GET" : "POST", url); - d->postData = postData; -} - -QWebNetworkRequest::QWebNetworkRequest(const QWebNetworkRequest &other) - : d(new QWebNetworkRequestPrivate(*other.d)) -{ -} - -QWebNetworkRequest &QWebNetworkRequest::operator=(const QWebNetworkRequest& other) -{ - *d = *other.d; - return *this; -} - -/*! - \internal -*/ -QWebNetworkRequest::QWebNetworkRequest(const QWebNetworkRequestPrivate& priv) - : d(new QWebNetworkRequestPrivate(priv)) -{ -} - -/*! - \internal -*/ -QWebNetworkRequest::QWebNetworkRequest(const WebCore::ResourceRequest& request) - : d(new QWebNetworkRequestPrivate) -{ - d->init(request); -} - -QWebNetworkRequest::~QWebNetworkRequest() -{ - delete d; -} - -/*! - \internal - The requested URL -*/ -QUrl QWebNetworkRequest::url() const -{ - return d->url; -} - -/*! - \internal - Sets the URL to request. - - Note that setting the URL also sets the "Host" field in the HTTP header. -*/ -void QWebNetworkRequest::setUrl(const QUrl& url) -{ - d->setURL(url); -} - -/*! - \internal - The http request header information. -*/ -QHttpRequestHeader QWebNetworkRequest::httpHeader() const -{ - return d->httpHeader; -} - -void QWebNetworkRequest::setHttpHeader(const QHttpRequestHeader& header) const -{ - d->httpHeader = header; -} - -QString QWebNetworkRequest::httpHeaderField(const QString& key) const -{ - return d->httpHeader.value(key); -} - -void QWebNetworkRequest::setHttpHeaderField(const QString& key, const QString& value) -{ - d->httpHeader.setValue(key, value); -} - -/*! - \internal - Post data sent with HTTP POST requests. -*/ -QByteArray QWebNetworkRequest::postData() const -{ - return d->postData; -} - -void QWebNetworkRequest::setPostData(const QByteArray& data) -{ - d->postData = data; -} - -/*! - \class QWebNetworkJob - \internal - - The QWebNetworkJob class represents a network job, that needs to be - processed by the QWebNetworkInterface. - - This class is only required when implementing a new network layer (or - support for a special protocol) using QWebNetworkInterface. - - QWebNetworkJob objects are created and owned by the QtWebKit library. - Most of it's properties are read-only. - - The job is reference counted. This can be used to ensure that the job doesn't - get deleted while it's still stored in some data structure. -*/ - -/*! - \internal -*/ -QWebNetworkJob::QWebNetworkJob() - : d(new QWebNetworkJobPrivate) -{ -} - -/*! - \internal -*/ -QWebNetworkJob::~QWebNetworkJob() -{ - delete d; - d = 0; -} - -/*! - \internal - The requested URL -*/ -QUrl QWebNetworkJob::url() const -{ - return d->request.url; -} - -/*! - \internal - Post data associated with the job -*/ -QByteArray QWebNetworkJob::postData() const -{ - return d->request.postData; -} - -/*! - \internal - The HTTP request header that should be used to download the job. -*/ -QHttpRequestHeader QWebNetworkJob::httpHeader() const -{ - return d->request.httpHeader; -} - -/*! - \internal - The complete network request that should be used to download the job. -*/ -QWebNetworkRequest QWebNetworkJob::request() const -{ - return QWebNetworkRequest(d->request); -} - -/*! - \internal - The HTTP response header received from the network. -*/ -QHttpResponseHeader QWebNetworkJob::response() const -{ - return d->response; -} - -/*! - \internal - The last error of the Job. -*/ -QString QWebNetworkJob::errorString() const -{ - return d->errorString; -} - -/*! - \internal - Sets the HTTP reponse header. The response header has to be called before - emitting QWebNetworkInterface::started. -*/ -void QWebNetworkJob::setResponse(const QHttpResponseHeader& response) -{ - d->response = response; -} - -void QWebNetworkJob::setErrorString(const QString& errorString) -{ - d->errorString = errorString; -} - -/*! - \internal - returns true if the job has been cancelled by the WebKit framework -*/ -bool QWebNetworkJob::cancelled() const -{ - return !d->resourceHandle; -} - -/*! - \internal - reference the job. -*/ -void QWebNetworkJob::ref() -{ - ++d->ref; -} - -/*! - \internal - derefence the job. - - If the reference count drops to 0 this method also deletes the job. - - Returns false if the reference count has dropped to 0. -*/ -bool QWebNetworkJob::deref() -{ - if (!--d->ref) { - delete this; - return false; - } - return true; -} - -/*! - \internal - Returns the network interface that is associated with this job. -*/ -QWebNetworkInterface *QWebNetworkJob::networkInterface() const -{ - return d->interface; -} - -/*! - \internal - Returns the network interface that is associated with this job. -*/ -QWebFrame *QWebNetworkJob::frame() const -{ - if (!d->resourceHandle) { - ResourceHandleInternal *rhi = d->resourceHandle->getInternal(); - if (rhi) - return rhi->m_frame; - } - return 0; -} - -QWebNetworkJob::JobStatus QWebNetworkJob::status() const -{ - return d->jobStatus; -} - -void QWebNetworkJob::setStatus(const JobStatus& status) -{ - d->jobStatus = status; -} - -/*! - \class QWebNetworkManager - \internal -*/ -QWebNetworkManager::QWebNetworkManager() - : QObject(0) - , m_scheduledWork(false) -{ - connect(this, SIGNAL(scheduleWork()), SLOT(doWork()), Qt::QueuedConnection); -} - -QWebNetworkManager *QWebNetworkManager::self() -{ - // ensure everything's constructed and connected - QWebNetworkInterface::defaultInterface(); - - return s_manager; -} - -bool QWebNetworkManager::add(ResourceHandle* handle, QWebNetworkInterface* interface, JobMode jobMode) -{ - if (!interface) - interface = s_default_interface; - - ASSERT(interface); - - QWebNetworkJob *job = new QWebNetworkJob(); - handle->getInternal()->m_job = job; - job->d->resourceHandle = handle; - job->d->interface = interface; - - job->d->request.init(handle->request()); - - const QString method = handle->getInternal()->m_request.httpMethod(); - if (method != "POST" && method != "GET" && method != "HEAD") { - qWarning("REQUEST: [%s]\n", qPrintable(job->d->request.httpHeader.toString())); - return false; - } - - DEBUG() << "QWebNetworkManager::add:" << job->d->request.httpHeader.toString(); - - if (jobMode == SynchronousJob) { - Q_ASSERT(!m_synchronousJobs.contains(job)); - m_synchronousJobs[job] = 1; - } - - interface->addJob(job); - - return true; -} - -void QWebNetworkManager::cancel(ResourceHandle* handle) -{ - QWebNetworkJob *job = handle->getInternal()->m_job; - if (!job) - return; - DEBUG() << "QWebNetworkManager::cancel:" << job->d->request.httpHeader.toString(); - job->d->resourceHandle = 0; - job->d->interface->cancelJob(job); - handle->getInternal()->m_job = 0; -} - -/*! - \internal -*/ -void QWebNetworkManager::started(QWebNetworkJob* job) -{ - Q_ASSERT(job->d); - Q_ASSERT(job->status() == QWebNetworkJob::JobCreated || - job->status() == QWebNetworkJob::JobRecreated); - - job->setStatus(QWebNetworkJob::JobStarted); - ResourceHandleClient* client = 0; - - if (!job->d->resourceHandle) - return; - - client = job->d->resourceHandle->client(); - if (!client) - return; - - DEBUG() << "ResourceHandleManager::receivedResponse:"; - DEBUG() << job->d->response.toString(); - - QStringList cookies = job->d->response.allValues("Set-Cookie"); - KURL url(job->url()); - - foreach (QString c, cookies) - QCookieJar::cookieJar()->setCookies(url, url, c); - - QString contentType = job->d->response.value("Content-Type"); - QString encoding; - int idx = contentType.indexOf(QLatin1Char(';')); - if (idx > 0) { - QString remainder = contentType.mid(idx + 1).toLower(); - contentType = contentType.left(idx).trimmed(); - - idx = remainder.indexOf("charset"); - if (idx >= 0) { - idx = remainder.indexOf(QLatin1Char('='), idx); - if (idx >= 0) - encoding = remainder.mid(idx + 1).trimmed(); - } - } - if (contentType.isEmpty()) { - // let's try to guess from the extension - QString extension = job->d->request.url.path(); - int index = extension.lastIndexOf(QLatin1Char('.')); - if (index > 0) { - extension = extension.mid(index + 1); - contentType = MIMETypeRegistry::getMIMETypeForExtension(extension); - } - } -// qDebug() << "Content-Type=" << contentType; -// qDebug() << "Encoding=" << encoding; - - - ResourceResponse response(url, contentType, - 0 /* FIXME */, - encoding, - String() /* FIXME */); - - int statusCode = job->d->response.statusCode(); - if (job->url().scheme() != QLatin1String("file")) - response.setHTTPStatusCode(statusCode); - else if (statusCode == 404) - response.setHTTPStatusCode(statusCode); - - /* Fill in the other fields */ - - if (statusCode >= 300 && statusCode < 400) { - // we're on a redirect page! if the 'Location:' field is valid, we redirect - QString location = job->d->response.value("location"); - DEBUG() << "Redirection"; - if (!location.isEmpty()) { - QUrl newUrl = job->d->request.url.resolved(location); - if (job->d->resourceHandle) { - ResourceRequest newRequest = job->d->resourceHandle->request(); - newRequest.setURL(KURL(newUrl)); - if (client) - client->willSendRequest(job->d->resourceHandle, newRequest, response); - } - - QString method; - if (statusCode == 302 || statusCode == 303) { - // this is standard-correct for 303 and practically-correct (no standard-correct) for 302 - // also, it's required for Yahoo's login process for flickr.com which responds to a POST - // with a 302 which must be GET'ed - method = "GET"; - job->d->request.httpHeader.setContentLength(0); - } else - method = job->d->request.httpHeader.method(); - - job->d->request.httpHeader.setRequest(method, - newUrl.toString(QUrl::RemoveScheme|QUrl::RemoveAuthority)); - job->d->request.setURL(newUrl); - job->d->redirected = true; - return; - } - } - - if (client) - client->didReceiveResponse(job->d->resourceHandle, response); - -} - -void QWebNetworkManager::data(QWebNetworkJob* job, const QByteArray& data) -{ - Q_ASSERT(job->status() == QWebNetworkJob::JobStarted || - job->status() == QWebNetworkJob::JobReceivingData); - - job->setStatus(QWebNetworkJob::JobReceivingData); - ResourceHandleClient* client = 0; - - if (!job->d->resourceHandle) - return; - - client = job->d->resourceHandle->client(); - if (!client) - return; - - if (job->d->redirected) - return; // don't emit the "Document has moved here" type of HTML - - DEBUG() << "receivedData" << job->d->request.url.path(); - client->didReceiveData(job->d->resourceHandle, data.constData(), data.length(), data.length() /*FixMe*/); -} - -void QWebNetworkManager::finished(QWebNetworkJob* job, int errorCode) -{ - Q_ASSERT(errorCode == 1 || - job->status() == QWebNetworkJob::JobStarted || - job->status() == QWebNetworkJob::JobReceivingData); - - if (m_synchronousJobs.contains(job)) - m_synchronousJobs.remove(job); - - job->setStatus(QWebNetworkJob::JobFinished); - ResourceHandleClient* client = 0; - if (job->d->resourceHandle) { - client = job->d->resourceHandle->client(); - if (!client) - return; - } else { - job->deref(); - return; - } - - DEBUG() << "receivedFinished" << errorCode << job->url(); - - if (job->d->redirected) { - job->d->redirected = false; - job->setStatus(QWebNetworkJob::JobRecreated); - job->d->interface->addJob(job); - return; - } - - if (job->d->resourceHandle) - job->d->resourceHandle->getInternal()->m_job = 0; - - if (client) { - if (errorCode) { - //FIXME: error setting error was removed from ResourceHandle - client->didFail(job->d->resourceHandle, - ResourceError(job->d->request.url.host(), job->d->response.statusCode(), - job->d->request.url.toString(), job->d->errorString)); - } else - client->didFinishLoading(job->d->resourceHandle); - } - - DEBUG() << "receivedFinished done" << job->d->request.url; - - job->deref(); -} - -void QWebNetworkManager::addHttpJob(QWebNetworkJob* job) -{ - HostInfo hostInfo(job->url()); - WebCoreHttp *httpConnection = m_hostMapping.value(hostInfo); - if (!httpConnection) { - // #### fix custom ports - DEBUG() << " new connection to" << hostInfo.host << hostInfo.port; - httpConnection = new WebCoreHttp(this, hostInfo); - QObject::connect(httpConnection, SIGNAL(connectionClosed(const WebCore::HostInfo&)), - this, SLOT(httpConnectionClosed(const WebCore::HostInfo&))); - - m_hostMapping[hostInfo] = httpConnection; - } - httpConnection->request(job); -} - -void QWebNetworkManager::cancelHttpJob(QWebNetworkJob* job) -{ - WebCoreHttp *httpConnection = m_hostMapping.value(job->url()); - if (httpConnection) - httpConnection->cancel(job); -} - -void QWebNetworkManager::httpConnectionClosed(const WebCore::HostInfo& info) -{ - WebCoreHttp *connection = m_hostMapping.take(info); - connection->deleteLater(); -} - -void QWebNetworkInterfacePrivate::sendFileData(QWebNetworkJob* job, int statusCode, const QByteArray& data) -{ - int error = statusCode >= 400 ? 1 : 0; - if (!job->cancelled()) { - QHttpResponseHeader response; - response.setStatusLine(statusCode); - response.setContentLength(data.length()); - job->setResponse(response); - q->started(job); - if (!data.isEmpty()) - q->data(job, data); - } - q->finished(job, error); -} - -void QWebNetworkInterfacePrivate::parseDataUrl(QWebNetworkJob* job) -{ - QByteArray data = job->url().toString().toLatin1(); - //qDebug() << "handling data url:" << data; - - ASSERT(data.startsWith("data:")); - - // Here's the syntax of data URLs: - // dataurl := "data:" [ mediatype ] [ ";base64" ] "," data - // mediatype := [ type "/" subtype ] *( ";" parameter ) - // data := *urlchar - // parameter := attribute "=" value - QByteArray header; - bool base64 = false; - - int index = data.indexOf(','); - if (index != -1) { - header = data.mid(5, index - 5).toLower(); - //qDebug() << "header=" << header; - data = data.mid(index+1); - //qDebug() << "data=" << data; - - if (header.endsWith(";base64")) { - //qDebug() << "base64"; - base64 = true; - header = header.left(header.length() - 7); - //qDebug() << "mime=" << header; - } - } else - data = QByteArray(); - - if (base64) - data = QByteArray::fromBase64(data); - else - data = decodePercentEncoding(data); - - if (header.isEmpty()) - header = "text/plain;charset=US-ASCII"; - int statusCode = 200; - QHttpResponseHeader response; - response.setContentType(header); - response.setContentLength(data.size()); - job->setResponse(response); - - int error = statusCode >= 400 ? 1 : 0; - q->started(job); - if (!data.isEmpty()) - q->data(job, data); - q->finished(job, error); -} - -void QWebNetworkManager::queueStart(QWebNetworkJob* job) -{ - Q_ASSERT(job->d); - - QMutexLocker locker(&m_queueMutex); - job->ref(); - m_pendingWork.append(new JobWork(job)); - doScheduleWork(); -} - -void QWebNetworkManager::queueData(QWebNetworkJob* job, const QByteArray& data) -{ - ASSERT(job->d); - - QMutexLocker locker(&m_queueMutex); - job->ref(); - m_pendingWork.append(new JobWork(job, data)); - doScheduleWork(); -} - -void QWebNetworkManager::queueFinished(QWebNetworkJob* job, int errorCode) -{ - Q_ASSERT(job->d); - - QMutexLocker locker(&m_queueMutex); - job->ref(); - m_pendingWork.append(new JobWork(job, errorCode)); - doScheduleWork(); -} - -void QWebNetworkManager::doScheduleWork() -{ - if (!m_scheduledWork) { - m_scheduledWork = true; - emit scheduleWork(); - } -} - - -/* - * We will work on a copy of m_pendingWork. While dispatching m_pendingWork - * new work will be added that will be handled at a later doWork call. doWork - * will be called we set m_scheduledWork to false early in this method. - */ -void QWebNetworkManager::doWork() -{ - m_queueMutex.lock(); - m_scheduledWork = false; - bool hasSyncJobs = m_synchronousJobs.size(); - const QHash<QWebNetworkJob*, int> syncJobs = m_synchronousJobs; - m_queueMutex.unlock(); - - foreach (JobWork* work, m_pendingWork) { - if (hasSyncJobs && !syncJobs.contains(work->job)) - continue; - - if (work->workType == JobWork::JobStarted) - started(work->job); - else if (work->workType == JobWork::JobData) { - // This job was not yet started - if (static_cast<int>(work->job->status()) < QWebNetworkJob::JobStarted) - continue; - - data(work->job, work->data); - } else if (work->workType == JobWork::JobFinished) { - // This job was not yet started... we have no idea if data comes by... - // and it won't start in case of errors - if (static_cast<int>(work->job->status()) < QWebNetworkJob::JobStarted && work->errorCode != 1) - continue; - - finished(work->job, work->errorCode); - } - - m_queueMutex.lock(); - m_pendingWork.removeAll(work); - m_queueMutex.unlock(); - - work->job->deref(); - delete work; - } - - m_queueMutex.lock(); - if (hasSyncJobs && !m_synchronousJobs.size()) - doScheduleWork(); - m_queueMutex.unlock(); -} - -/*! - \class QWebNetworkInterface - \internal - - The QWebNetworkInterface class provides an abstraction layer for - WebKit's network interface. It allows to completely replace or - extend the builtin network layer. - - QWebNetworkInterface contains two virtual methods, addJob and - cancelJob that have to be reimplemented when implementing your own - networking layer. - - QWebNetworkInterface can by default handle the http, https, file and - data URI protocols. - -*/ - -static bool gRoutineAdded = false; - -static void gCleanupInterface() -{ - delete s_default_interface; - s_default_interface = 0; -} - -/*! - \internal - Sets a new default interface that will be used by all of WebKit - for downloading data from the internet. -*/ -void QWebNetworkInterface::setDefaultInterface(QWebNetworkInterface* defaultInterface) -{ - if (s_default_interface == defaultInterface) - return; - if (s_default_interface) - delete s_default_interface; - s_default_interface = defaultInterface; - if (!gRoutineAdded) { - qAddPostRoutine(gCleanupInterface); - gRoutineAdded = true; - } -} - -/*! - \internal - Returns the default interface that will be used by WebKit. If no - default interface has been set, QtWebkit will create an instance of - QWebNetworkInterface to do the work. -*/ -QWebNetworkInterface *QWebNetworkInterface::defaultInterface() -{ - if (!s_default_interface) - setDefaultInterface(new QWebNetworkInterface); - - return s_default_interface; -} - - -/*! - \internal - Constructs a QWebNetworkInterface object. -*/ -QWebNetworkInterface::QWebNetworkInterface(QObject* parent) - : QObject(parent) -{ - d = new QWebNetworkInterfacePrivate; - d->q = this; - - if (!s_manager) - s_manager = new QWebNetworkManager; -} - -/*! - \internal - Destructs the QWebNetworkInterface object. -*/ -QWebNetworkInterface::~QWebNetworkInterface() -{ - delete d; -} - -/*! - \internal - This virtual method gets called whenever QtWebkit needs to add a - new job to download. - - The QWebNetworkInterface should process this job, by first emitting - the started signal, then emitting data repeatedly as new data for - the Job is available, and finally ending the job with emitting a - finished signal. - - After the finished signal has been emitted, the QWebNetworkInterface - is not allowed to access the job anymore. -*/ -void QWebNetworkInterface::addJob(QWebNetworkJob* job) -{ - QString protocol = job->url().scheme(); - if (protocol == QLatin1String("http") || protocol == QLatin1String("https")) { - QWebNetworkManager::self()->addHttpJob(job); - return; - } - - // "file", "data" and all unhandled stuff go through here - //DEBUG() << "fileRequest"; - DEBUG() << "FileLoader::request" << job->url(); - - if (job->cancelled()) { - d->sendFileData(job, 400, QByteArray()); - return; - } - - QUrl url = job->url(); - if (protocol == QLatin1String("data")) { - d->parseDataUrl(job); - return; - } - - int statusCode = 200; - QByteArray data; - QString path = url.path(); - if (protocol == QLatin1String("qrc")) { - protocol = "file"; - path.prepend(QLatin1Char(':')); - } - - if (!(protocol.isEmpty() || protocol == QLatin1String("file"))) { - statusCode = 404; - } else { - // we simply ignore post data here. - QFile f(path); - DEBUG() << "opening" << QString(url.path()); - - if (f.open(QIODevice::ReadOnly)) { - QHttpResponseHeader response; - response.setStatusLine(200); - job->setResponse(response); - data = f.readAll(); - } else - statusCode = 404; - } - - if (statusCode == 404) { - QHttpResponseHeader response; - response.setStatusLine(404); - job->setResponse(response); - } - - d->sendFileData(job, statusCode, data); -} - -/*! - \internal - This virtual method gets called whenever QtWebkit needs to cancel a - new job. - - The QWebNetworkInterface acknowledge the canceling of the job, by - emitting the finished signal with an error code of 1. After emitting - the finished signal, the interface should not access the job - anymore. -*/ -void QWebNetworkInterface::cancelJob(QWebNetworkJob* job) -{ - QString protocol = job->url().scheme(); - if (protocol == QLatin1String("http") || protocol == QLatin1String("https")) - QWebNetworkManager::self()->cancelHttpJob(job); -} - -/*! - \internal -*/ -void QWebNetworkInterface::started(QWebNetworkJob* job) -{ - Q_ASSERT(s_manager); - s_manager->queueStart(job); -} - -/*! - \internal -*/ -void QWebNetworkInterface::data(QWebNetworkJob* job, const QByteArray& data) -{ - Q_ASSERT(s_manager); - s_manager->queueData(job, data); -} - -/*! - \internal -*/ -void QWebNetworkInterface::finished(QWebNetworkJob* job, int errorCode) -{ - Q_ASSERT(s_manager); - s_manager->queueFinished(job, errorCode); -} - -/*! - \fn void QWebNetworkInterface::sslErrors(QWebFrame *frame, const QUrl& url, const QList<QSslError>& errors, bool *continueAnyway); - \internal - - Signal is emitted when an SSL error occurs. -*/ - -/*! - \fn void QWebNetworkInterface::authenticate(QWebFrame *frame, const QUrl& url, const QString& hostname, quint16 port, QAuthenticator *auth); - \internal - - Signal is emitted when network authentication is required. -*/ - -/*! - \fn void QWebNetworkInterface::authenticateProxy(QWebFrame *frame, const QUrl& url, const QNetworkProxy& proxy, QAuthenticator *auth); - \internal - - Signal is emitted when proxy authentication is required. -*/ - -///////////////////////////////////////////////////////////////////////////// -WebCoreHttp::WebCoreHttp(QObject* parent, const HostInfo& hi) - : QObject(parent) - , info(hi) - , m_inCancel(false) -{ - for (int i = 0; i < 2; ++i) { - connection[i].http = new QHttp(info.host, (hi.protocol == QLatin1String("https")) ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp, info.port); - connect(connection[i].http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader&)), - this, SLOT(onResponseHeaderReceived(const QHttpResponseHeader&))); - connect(connection[i].http, SIGNAL(readyRead(const QHttpResponseHeader&)), - this, SLOT(onReadyRead())); - connect(connection[i].http, SIGNAL(requestFinished(int, bool)), - this, SLOT(onRequestFinished(int, bool))); - connect(connection[i].http, SIGNAL(done(bool)), - this, SLOT(onDone(bool))); - connect(connection[i].http, SIGNAL(stateChanged(int)), - this, SLOT(onStateChanged(int))); - connect(connection[i].http, SIGNAL(authenticationRequired(const QString&, quint16, QAuthenticator*)), - this, SLOT(onAuthenticationRequired(const QString&, quint16, QAuthenticator*))); - connect(connection[i].http, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), - this, SLOT(onProxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); - connect(connection[i].http, SIGNAL(sslErrors(const QList<QSslError>&)), - this, SLOT(onSslErrors(const QList<QSslError>&))); - } -} - -WebCoreHttp::~WebCoreHttp() -{ - connection[0].http->deleteLater(); - connection[1].http->deleteLater(); -} - -void WebCoreHttp::request(QWebNetworkJob* job) -{ - m_pendingRequests.append(job); - scheduleNextRequest(); -} - -void WebCoreHttp::scheduleNextRequest() -{ - int c = 0; - for (; c < 2; ++c) { - if (!connection[c].current) - break; - } - if (c >= 2) - return; - - QWebNetworkJob *job = 0; - while (!job && !m_pendingRequests.isEmpty()) { - job = m_pendingRequests.takeFirst(); - if (job->cancelled()) { - job->networkInterface()->finished(job, 1); - job = 0; - } - } - if (!job) - return; - - QHttp* http = connection[c].http; - - connection[c].current = job; - connection[c].id = -1; -#ifndef QT_NO_NETWORKPROXY - int proxyId = http->setProxy(job->frame()->page()->networkProxy()); -#endif - - QByteArray postData = job->postData(); - if (!postData.isEmpty()) - connection[c].id = http->request(job->httpHeader(), postData); - else - connection[c].id = http->request(job->httpHeader()); - - DEBUG() << "WebCoreHttp::scheduleNextRequest: using connection" << c; - DEBUG() << job->httpHeader().toString(); -// DEBUG() << job->request.toString(); -} - -int WebCoreHttp::getConnection() -{ - QObject* o = sender(); - int c; - if (o == connection[0].http) { - c = 0; - } else { - Q_ASSERT(o == connection[1].http); - c = 1; - } - Q_ASSERT(connection[c].current); - return c; -} - -void WebCoreHttp::onResponseHeaderReceived(const QHttpResponseHeader& resp) -{ - QHttp* http = qobject_cast<QHttp*>(sender()); - if (!http->currentId()) { - qDebug() << "ERROR! Invalid job id. Why?"; // foxnews.com triggers this - return; - } - int c = getConnection(); - QWebNetworkJob* job = connection[c].current; - DEBUG() << "WebCoreHttp::slotResponseHeaderReceived connection=" << c; - DEBUG() << resp.toString(); - - job->setResponse(resp); - - job->networkInterface()->started(job); -} - -void WebCoreHttp::onReadyRead() -{ - QHttp* http = qobject_cast<QHttp*>(sender()); - if (!http->currentId()) { - qDebug() << "ERROR! Invalid job id. Why?"; // foxnews.com triggers this - return; - } - int c = getConnection(); - QWebNetworkJob* job = connection[c].current; - Q_ASSERT(http == connection[c].http); - //DEBUG() << "WebCoreHttp::slotReadyRead connection=" << c; - - QByteArray data; - data.resize(http->bytesAvailable()); - http->read(data.data(), data.length()); - job->networkInterface()->data(job, data); -} - -void WebCoreHttp::onRequestFinished(int id, bool error) -{ - int c = getConnection(); - if (connection[c].id != id) - return; - - QWebNetworkJob* job = connection[c].current; - if (!job) { - scheduleNextRequest(); - return; - } - - QHttp* http = connection[c].http; - DEBUG() << "WebCoreHttp::slotFinished connection=" << c << error << job; - if (error) { - DEBUG() << " error: " << http->errorString(); - job->setErrorString(http->errorString()); - } - - if (!error && http->bytesAvailable()) { - QByteArray data; - data.resize(http->bytesAvailable()); - http->read(data.data(), data.length()); - job->networkInterface()->data(job, data); - } - - job->networkInterface()->finished(job, error ? 1 : 0); - connection[c].current = 0; - connection[c].id = -1; - scheduleNextRequest(); -} - -void WebCoreHttp::onDone(bool error) -{ - DEBUG() << "WebCoreHttp::onDone" << error; -} - -void WebCoreHttp::onStateChanged(int state) -{ - DEBUG() << "State changed to" << state << "and connections are" << connection[0].current << connection[1].current; - if (state == QHttp::Closing || state == QHttp::Unconnected) { - if (!m_inCancel && m_pendingRequests.isEmpty() - && !connection[0].current && !connection[1].current) - emit connectionClosed(info); - } -} - -void WebCoreHttp::cancel(QWebNetworkJob* request) -{ - bool doEmit = true; - m_inCancel = true; - for (int i = 0; i < 2; ++i) { - if (request == connection[i].current) { - connection[i].http->abort(); - doEmit = false; - } - } - if (!m_pendingRequests.removeAll(request)) - doEmit = false; - m_inCancel = false; - - if (doEmit) - request->networkInterface()->finished(request, 1); - - if (m_pendingRequests.isEmpty() - && !connection[0].current && !connection[1].current) - emit connectionClosed(info); -} - -void WebCoreHttp::onSslErrors(const QList<QSslError>& errors) -{ - int c = getConnection(); - QWebNetworkJob *job = connection[c].current; - if (job) { - bool continueAnyway = false; - emit job->networkInterface()->sslErrors(job->frame(), job->url(), errors, &continueAnyway); -#ifndef QT_NO_OPENSSL - if (continueAnyway) - connection[c].http->ignoreSslErrors(); -#endif - } -} - -void WebCoreHttp::onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator* auth) -{ - int c = getConnection(); - QWebNetworkJob *job = connection[c].current; - if (job) { - emit job->networkInterface()->authenticate(job->frame(), job->url(), hostname, port, auth); - if (auth->isNull()) - connection[c].http->abort(); - } -} - -void WebCoreHttp::onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator* auth) -{ - int c = getConnection(); - QWebNetworkJob *job = connection[c].current; - if (job) { - emit job->networkInterface()->authenticateProxy(job->frame(), job->url(), proxy, auth); - if (auth->isNull()) - connection[c].http->abort(); - } -} - -HostInfo::HostInfo(const QUrl& url) - : protocol(url.scheme()) - , host(url.host()) - , port(url.port()) -{ - if (port < 0) { - if (protocol == QLatin1String("http")) - port = 80; - else if (protocol == QLatin1String("https")) - port = 443; - } -} - -#endif diff --git a/WebKit/qt/Api/qwebnetworkinterface.h b/WebKit/qt/Api/qwebnetworkinterface.h deleted file mode 100644 index 7f96155..0000000 --- a/WebKit/qt/Api/qwebnetworkinterface.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef QWEBNETWORKINTERFACE_H -#define QWEBNETWORKINTERFACE_H - -#include <QtCore/qobject.h> -#include <QtCore/qurl.h> -#include <QtNetwork/qhttp.h> -#include <QtCore/qbytearray.h> - -#include "qwebkitglobal.h" - -#if QT_VERSION < 0x040400 - -class QAuthenticator; -class QNetworkProxy; -class QSslError; -class QWebFrame; -class QWebNetworkJobPrivate; -class QWebNetworkInterface; -class QWebObjectPluginConnector; - -namespace WebCore { - class WebCoreHttp; - class ResourceRequest; - class FrameLoaderClientQt; -} - -struct QWebNetworkRequestPrivate; -class QWEBKIT_EXPORT QWebNetworkRequest { -public: - enum Method { - Get, - Post - //Head - }; - - QWebNetworkRequest(); - explicit QWebNetworkRequest(const QUrl &url, Method method = Get, const QByteArray &postData = QByteArray()); - QWebNetworkRequest(const QWebNetworkRequest &other); - - QWebNetworkRequest &operator=(const QWebNetworkRequest &other); - ~QWebNetworkRequest(); - - QUrl url() const; - void setUrl(const QUrl &url); - - QHttpRequestHeader httpHeader() const; - void setHttpHeader(const QHttpRequestHeader &header) const; - - QString httpHeaderField(const QString &key) const; - void setHttpHeaderField(const QString &key, const QString &value); - - QByteArray postData() const; - void setPostData(const QByteArray &data); - -private: - explicit QWebNetworkRequest(const QWebNetworkRequestPrivate &priv); - explicit QWebNetworkRequest(const WebCore::ResourceRequest &request); - friend class QWebNetworkJob; - friend class WebCore::FrameLoaderClientQt; - - QWebNetworkRequestPrivate *d; - friend class QWebObjectPluginConnector; -}; - -class QWEBKIT_EXPORT QWebNetworkJob { -public: - - QUrl url() const; - QByteArray postData() const; - QHttpRequestHeader httpHeader() const; - QWebNetworkRequest request() const; - QString errorString() const; - - QHttpResponseHeader response() const; - void setResponse(const QHttpResponseHeader &response); - void setErrorString(const QString&); - - bool cancelled() const; - - void ref(); - bool deref(); - - QWebNetworkInterface *networkInterface() const; - - QWebFrame *frame() const; - -protected: - enum JobStatus { - JobCreated, - JobRecreated, - JobStarted, - JobReceivingData, - JobFinished - }; - - JobStatus status() const; - void setStatus(const JobStatus&); - -private: - QWebNetworkJob(); - ~QWebNetworkJob(); - - friend class QWebNetworkManager; - friend class QWebObjectPluginConnector; - friend class QWebNetworkJobPrivate; - - QWebNetworkJobPrivate *d; -}; - -class QWebNetworkInterfacePrivate; - -class QWEBKIT_EXPORT QWebNetworkInterface : public QObject { - Q_OBJECT -public: - QWebNetworkInterface(QObject *parent = 0); - ~QWebNetworkInterface(); - - static void setDefaultInterface(QWebNetworkInterface *defaultInterface); - static QWebNetworkInterface *defaultInterface(); - - virtual void addJob(QWebNetworkJob *job); - virtual void cancelJob(QWebNetworkJob *job); - -protected: - void started(QWebNetworkJob*); - void data(QWebNetworkJob*, const QByteArray &data); - void finished(QWebNetworkJob*, int errorCode); - -signals: - void sslErrors(QWebFrame *frame, const QUrl& url, const QList<QSslError>& errors, bool *continueAnyway); - void authenticate(QWebFrame *frame, const QUrl& url, const QString& hostname, quint16 port, QAuthenticator *auth); - void authenticateProxy(QWebFrame *frame, const QUrl& url, const QNetworkProxy& proxy, QAuthenticator *auth); - -private: - friend class QWebNetworkInterfacePrivate; - friend class WebCore::WebCoreHttp; - QWebNetworkInterfacePrivate *d; -}; - -#endif - -#endif diff --git a/WebKit/qt/Api/qwebnetworkinterface_p.h b/WebKit/qt/Api/qwebnetworkinterface_p.h deleted file mode 100644 index aec104b..0000000 --- a/WebKit/qt/Api/qwebnetworkinterface_p.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef QWEBNETWORKINTERFACE_P_H -#define QWEBNETWORKINTERFACE_P_H - -#include "qwebnetworkinterface.h" -#if QT_VERSION < 0x040400 -#include <qthread.h> -#include <qmutex.h> - -namespace WebCore { - struct HostInfo; - class ResourceRequest; -}; -uint qHash(const WebCore::HostInfo &info); -#include <qhash.h> - -namespace WebCore { - class ResourceHandle; -} - -struct QWebNetworkRequestPrivate { - QUrl url; - QHttpRequestHeader httpHeader; - QByteArray postData; - - void init(const WebCore::ResourceRequest &resourceRequest); - void init(const QString &method, const QUrl &url, const WebCore::ResourceRequest *resourceRequest = 0); - void setURL(const QUrl &u); -}; - -class QWebNetworkJobPrivate { -public: - QWebNetworkJobPrivate() - : ref(1) - , resourceHandle(0) - , redirected(false) - , interface(0) - , jobStatus(QWebNetworkJob::JobCreated) - {} - int ref; - - QWebNetworkRequestPrivate request; - QHttpResponseHeader response; - - WebCore::ResourceHandle *resourceHandle; - bool redirected; - - QWebNetworkInterface *interface; - QWebNetworkJob::JobStatus jobStatus; - QString errorString; -}; - -class QWebNetworkManager : public QObject { - Q_OBJECT -public: - enum JobMode { - AsynchronousJob, - SynchronousJob - }; - - static QWebNetworkManager *self(); - - bool add(WebCore::ResourceHandle *resourceHandle, QWebNetworkInterface *interface, JobMode = AsynchronousJob); - void cancel(WebCore::ResourceHandle *resourceHandle); - - void addHttpJob(QWebNetworkJob *job); - void cancelHttpJob(QWebNetworkJob *job); - -protected: - void queueStart(QWebNetworkJob*); - void queueData(QWebNetworkJob*, const QByteArray&); - void queueFinished(QWebNetworkJob*, int errorCode); - -private: - void started(QWebNetworkJob *); - void data(QWebNetworkJob *, const QByteArray &data); - void finished(QWebNetworkJob *, int errorCode); - void doScheduleWork(); - -signals: - void fileRequest(QWebNetworkJob*); - void scheduleWork(); - -private slots: - void httpConnectionClosed(const WebCore::HostInfo &); - void doWork(); - -private: - friend class QWebNetworkInterface; - QWebNetworkManager(); - QHash<WebCore::HostInfo, WebCore::WebCoreHttp *> m_hostMapping; - - struct JobWork { - enum WorkType { - JobStarted, - JobData, - JobFinished - }; - - explicit JobWork(QWebNetworkJob* _job) - : workType(JobStarted) - , errorCode(-1) - , job(_job) - {} - - explicit JobWork(QWebNetworkJob* _job, int _errorCode) - : workType(JobFinished) - , errorCode(_errorCode) - , job(_job) - {} - - explicit JobWork(QWebNetworkJob* _job, const QByteArray& _data) - : workType(JobData) - , errorCode(-1) - , job(_job) - , data(_data) - {} - - const WorkType workType; - int errorCode; - QByteArray data; - QWebNetworkJob* job; - }; - - QMutex m_queueMutex; - bool m_scheduledWork; - QList<JobWork*> m_pendingWork; - QHash<QWebNetworkJob*, int> m_synchronousJobs; -}; - - -namespace WebCore { - - class NetworkLoader; - - struct HostInfo { - HostInfo() {} - HostInfo(const QUrl& url); - QString protocol; - QString host; - int port; - }; - - class WebCoreHttp : public QObject { - Q_OBJECT - public: - WebCoreHttp(QObject* parent, const HostInfo&); - ~WebCoreHttp(); - - void request(QWebNetworkJob* resource); - void cancel(QWebNetworkJob*); - - signals: - void connectionClosed(const WebCore::HostInfo&); - - private slots: - void onResponseHeaderReceived(const QHttpResponseHeader& resp); - void onReadyRead(); - void onRequestFinished(int, bool); - void onDone(bool); - void onStateChanged(int); - void onSslErrors(const QList<QSslError>&); - void onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator*); - void onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator*); - - void scheduleNextRequest(); - - int getConnection(); - - public: - HostInfo info; - private: - QList<QWebNetworkJob*> m_pendingRequests; - struct HttpConnection { - HttpConnection() : http(0), current(0), id(-1) {} - QHttp* http; - QWebNetworkJob* current; - int id; // the QHttp id - }; - HttpConnection connection[2]; - bool m_inCancel; - }; - -} - -class QWebNetworkInterfacePrivate { -public: - void sendFileData(QWebNetworkJob* job, int statusCode, const QByteArray& data); - void parseDataUrl(QWebNetworkJob* job); - - QWebNetworkInterface* q; -}; - -#endif - -#endif diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index 0b122b4..ba6b9f3 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -78,6 +78,7 @@ #include "Cache.h" #include "runtime/InitializeThreading.h" #include "PageGroup.h" +#include "QWebPageClient.h" #include <QApplication> #include <QBasicTimer> @@ -101,11 +102,10 @@ #include <QStyle> #include <QSysInfo> #include <QTextCharFormat> -#if QT_VERSION >= 0x040400 #include <QNetworkAccessManager> #include <QNetworkRequest> -#else -#include "qwebnetworkinterface.h" +#if defined(Q_WS_X11) +#include <QX11Info> #endif using namespace WebCore; @@ -138,6 +138,102 @@ QString QWEBKIT_EXPORT qt_webpage_groupName(QWebPage* page) return page->handle()->page->groupName(); } +class QWebPageWidgetClient : public QWebPageClient { +public: + QWebPageWidgetClient(QWidget* view) + : view(view) + { + Q_ASSERT(view); + } + + virtual void scroll(int dx, int dy, const QRect&); + virtual void update(const QRect& dirtyRect); + virtual void setInputMethodEnabled(bool enable); + virtual bool inputMethodEnabled() const; +#if QT_VERSION >= 0x040600 + virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable); +#endif + +#ifndef QT_NO_CURSOR + virtual QCursor cursor() const; + virtual void updateCursor(const QCursor& cursor); +#endif + + virtual QPalette palette() const; + virtual int screenNumber() const; + virtual QWidget* ownerWidget() const; + + virtual QObject* pluginParent() const; + + QWidget* view; +}; + +void QWebPageWidgetClient::scroll(int dx, int dy, const QRect& rectToScroll) +{ + view->scroll(qreal(dx), qreal(dy), rectToScroll); +} + +void QWebPageWidgetClient::update(const QRect & dirtyRect) +{ + view->update(dirtyRect); +} + +void QWebPageWidgetClient::setInputMethodEnabled(bool enable) +{ + view->setAttribute(Qt::WA_InputMethodEnabled, enable); +} + +bool QWebPageWidgetClient::inputMethodEnabled() const +{ + return view->testAttribute(Qt::WA_InputMethodEnabled); +} + +#if QT_VERSION >= 0x040600 +void QWebPageWidgetClient::setInputMethodHint(Qt::InputMethodHint hint, bool enable) +{ + if (enable) + view->setInputMethodHints(view->inputMethodHints() | hint); + else + view->setInputMethodHints(view->inputMethodHints() & ~hint); +} +#endif +#ifndef QT_NO_CURSOR +QCursor QWebPageWidgetClient::cursor() const +{ + return view->cursor(); +} + +void QWebPageWidgetClient::updateCursor(const QCursor& cursor) +{ + view->setCursor(cursor); +} +#endif + +QPalette QWebPageWidgetClient::palette() const +{ + return view->palette(); +} + +int QWebPageWidgetClient::screenNumber() const +{ +#if defined(Q_WS_X11) + if (view) + return view->x11Info().screen(); +#endif + + return 0; +} + +QWidget* QWebPageWidgetClient::ownerWidget() const +{ + return view; +} + +QObject* QWebPageWidgetClient::pluginParent() const +{ + return view; +} + // Lookup table mapping QWebPage::WebActions to the associated Editor commands static const char* editorCommandWebActions[] = { @@ -266,11 +362,11 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) #if QT_VERSION < 0x040600 , view(0) #endif + , clickCausedFocus(false) + , viewportSize(QSize(0, 0)) , inspectorFrontend(0) , inspector(0) , inspectorIsInternalOnly(false) - , viewportSize(QSize(0, 0)) - , clickCausedFocus(false) { WebCore::InitializeLoggingChannelsIfNecessary(); JSC::initializeThreading(); @@ -288,11 +384,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) undoStack = 0; #endif mainFrame = 0; -#if QT_VERSION < 0x040400 - networkInterface = 0; -#else networkManager = 0; -#endif pluginFactory = 0; insideOpenCall = false; forwardUnsupportedContent = false; @@ -321,15 +413,6 @@ QWebPagePrivate::~QWebPagePrivate() delete page; } -#if QT_VERSION < 0x040400 -bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type) -{ - if (insideOpenCall - && frame == mainFrame) - return true; - return q->acceptNavigationRequest(frame, request, type); -} -#else bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type) { if (insideOpenCall @@ -337,7 +420,6 @@ bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRe return true; return q->acceptNavigationRequest(frame, request, type); } -#endif void QWebPagePrivate::createMainFrame() { @@ -764,13 +846,18 @@ void QWebPagePrivate::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) void QWebPagePrivate::handleSoftwareInputPanel(Qt::MouseButton button) { #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) - if (q->view() && q->view()->testAttribute(Qt::WA_InputMethodEnabled) + Frame* frame = page->focusController()->focusedFrame(); + if (!frame) + return; + + if (client && client->inputMethodEnabled() + && frame->document()->focusedNode() && button == Qt::LeftButton && qApp->autoSipEnabled()) { QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( - q->view()->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); + client->ownerWidget()->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) { QEvent event(QEvent::RequestSoftwareInputPanel); - QApplication::sendEvent(q->view(), &event); + QApplication::sendEvent(client->ownerWidget(), &event); } } @@ -962,11 +1049,9 @@ void QWebPagePrivate::keyReleaseEvent(QKeyEvent *ev) void QWebPagePrivate::focusInEvent(QFocusEvent*) { FocusController *focusController = page->focusController(); - Frame *frame = focusController->focusedFrame(); focusController->setActive(true); - if (frame) - focusController->setFocused(true); - else + focusController->setFocused(true); + if (!focusController->focusedFrame()) focusController->setFocusedFrame(QWebFramePrivate::core(mainFrame)); } @@ -1210,16 +1295,16 @@ bool QWebPagePrivate::handleScrolling(QKeyEvent *ev, Frame *frame) granularity = ScrollByPage; direction = ScrollDown; } else if (ev == QKeySequence::MoveToPreviousPage - || (ev->key() == Qt::Key_Space) && (ev->modifiers() & Qt::ShiftModifier)) { + || ((ev->key() == Qt::Key_Space) && (ev->modifiers() & Qt::ShiftModifier))) { granularity = ScrollByPage; direction = ScrollUp; } else #endif // QT_NO_SHORTCUT - if (ev->key() == Qt::Key_Up && ev->modifiers() & Qt::ControlModifier + if ((ev->key() == Qt::Key_Up && ev->modifiers() & Qt::ControlModifier) || ev->key() == Qt::Key_Home) { granularity = ScrollByDocument; direction = ScrollUp; - } else if (ev->key() == Qt::Key_Down && ev->modifiers() & Qt::ControlModifier + } else if ((ev->key() == Qt::Key_Down && ev->modifiers() & Qt::ControlModifier) || ev->key() == Qt::Key_End) { granularity = ScrollByDocument; direction = ScrollDown; @@ -1378,8 +1463,6 @@ QWebInspector* QWebPagePrivate::getOrCreateInspector() if (!inspector) { QWebInspector* insp = new QWebInspector; insp->setPage(q); - insp->connect(q, SIGNAL(webInspectorTriggered(const QWebElement&)), SLOT(show())); - insp->show(); // The inspector is expected to be shown on inspection inspectorIsInternalOnly = true; Q_ASSERT(inspector); // Associated through QWebInspector::setPage(q) @@ -1584,7 +1667,7 @@ InspectorController* QWebPagePrivate::inspectorController() */ /*! - Constructs an empty QWebView with parent \a parent. + Constructs an empty QWebPage with parent \a parent. */ QWebPage::QWebPage(QObject *parent) : QObject(parent) @@ -1607,8 +1690,14 @@ QWebPage::~QWebPage() FrameLoader *loader = d->mainFrame->d->frame->loader(); if (loader) loader->detachFromParent(); - if (d->inspector) - d->inspector->setPage(0); + if (d->inspector) { + // Since we have to delete an internal inspector, + // call setInspector(0) directly to prevent potential crashes + if (d->inspectorIsInternalOnly) + d->setInspector(0); + else + d->inspector->setPage(0); + } delete d; } @@ -1672,6 +1761,15 @@ void QWebPage::setView(QWidget *view) { if (this->view() != view) { d->view = view; + if (!view) { + delete d->client; + d->client = 0; + } else { + if (!d->client) + d->client = new QWebPageWidgetClient(view); + else + static_cast<QWebPageWidgetClient*>(d->client)->view = view; + } setViewportSize(view ? view->size() : QSize(0, 0)); } } @@ -1916,11 +2014,9 @@ void QWebPage::triggerAction(WebAction action, bool) editor->setBaseWritingDirection(RightToLeftWritingDirection); break; case InspectElement: { - QWebElement inspectedElement(QWebElement::enclosingElement(d->hitTestResult.d->innerNonSharedNode.get())); - emit webInspectorTriggered(inspectedElement); - if (!d->hitTestResult.isNull()) { d->getOrCreateInspector(); // Make sure the inspector is created + d->inspector->show(); // The inspector is expected to be shown on inspection d->page->inspectorController()->inspect(d->hitTestResult.d->innerNonSharedNode.get()); } break; @@ -2019,11 +2115,7 @@ void QWebPage::setPreferredContentsSize(const QSize &size) const \sa createWindow() */ -#if QT_VERSION >= 0x040400 bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type) -#else -bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type) -#endif { Q_UNUSED(frame) if (type == NavigationTypeLinkClicked) { @@ -2111,27 +2203,19 @@ QAction *QWebPage::action(WebAction action) const case Back: text = contextMenuItemTagGoBack(); -#if QT_VERSION >= 0x040400 icon = style->standardIcon(QStyle::SP_ArrowBack); -#endif break; case Forward: text = contextMenuItemTagGoForward(); -#if QT_VERSION >= 0x040400 icon = style->standardIcon(QStyle::SP_ArrowForward); -#endif break; case Stop: text = contextMenuItemTagStop(); -#if QT_VERSION >= 0x040400 icon = style->standardIcon(QStyle::SP_BrowserStop); -#endif break; case Reload: text = contextMenuItemTagReload(); -#if QT_VERSION >= 0x040400 icon = style->standardIcon(QStyle::SP_BrowserReload); -#endif break; case Cut: @@ -2661,6 +2745,17 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) as a result of the user clicking on a "file upload" button in a HTML form where multiple file selection is allowed. + \omitvalue ErrorPageExtension (introduced in Qt 4.6) +*/ + +/*! + \enum QWebPage::ErrorDomain + \since 4.6 + \internal + + \value QtNetwork + \value Http + \value WebKit */ /*! @@ -2711,6 +2806,12 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) */ /*! + \fn QWebPage::ErrorPageExtensionReturn::ErrorPageExtensionReturn() + + Constructs a new error page object. +*/ + +/*! \class QWebPage::ChooseMultipleFilesExtensionOption \since 4.5 \brief The ChooseMultipleFilesExtensionOption class describes the option @@ -2844,35 +2945,6 @@ QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& suggestedFil #endif } -#if QT_VERSION < 0x040400 && !defined qdoc - -void QWebPage::setNetworkInterface(QWebNetworkInterface *interface) -{ - d->networkInterface = interface; -} - -QWebNetworkInterface *QWebPage::networkInterface() const -{ - if (d->networkInterface) - return d->networkInterface; - else - return QWebNetworkInterface::defaultInterface(); -} - -#ifndef QT_NO_NETWORKPROXY -void QWebPage::setNetworkProxy(const QNetworkProxy& proxy) -{ - d->networkProxy = proxy; -} - -QNetworkProxy QWebPage::networkProxy() const -{ - return d->networkProxy; -} -#endif - -#else - /*! Sets the QNetworkAccessManager \a manager responsible for serving network requests for this QWebPage. @@ -2906,8 +2978,6 @@ QNetworkAccessManager *QWebPage::networkAccessManager() const return d->networkManager; } -#endif - /*! Sets the QWebPluginFactory \a factory responsible for creating plugins embedded into this QWebPage. @@ -2955,7 +3025,7 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const Q_UNUSED(url) QString ua = QLatin1String("Mozilla/5.0 (" - // Plastform + // Platform #ifdef Q_WS_MAC "Macintosh" #elif defined Q_WS_QWS @@ -2964,19 +3034,22 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const "Windows" #elif defined Q_WS_X11 "X11" +#elif defined Q_OS_SYMBIAN + "SymbianOS" #else "Unknown" #endif - "; " + // Placeholder for Platform Version + "%1; " // Placeholder for security strength (N or U) - "%1; " + "%2; " // Subplatform" #ifdef Q_OS_AIX "AIX" #elif defined Q_OS_WIN32 - "%2" + "%3" #elif defined Q_OS_DARWIN #ifdef __i386__ || __x86_64__ "Intel Mac OS X" @@ -3028,6 +3101,8 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const "Sun Solaris" #elif defined Q_OS_ULTRIX "DEC Ultrix" +#elif defined Q_WS_S60 + "Series60" #elif defined Q_OS_UNIX "UNIX BSD/SYSV system" #elif defined Q_OS_UNIXWARE @@ -3035,7 +3110,28 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const #else "Unknown" #endif - "; "); + // Placeholder for SubPlatform Version + "%4; "); + + // Platform Version + QString osVer; +#ifdef Q_OS_SYMBIAN + QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); + switch (symbianVersion) { + case QSysInfo::SV_9_2: + osVer = "/9.2"; + break; + case QSysInfo::SV_9_3: + osVer = "/9.3"; + break; + case QSysInfo::SV_9_4: + osVer = "/9.4"; + break; + default: + osVer = "Unknown"; + } +#endif + ua = ua.arg(osVer); QChar securityStrength(QLatin1Char('N')); #if !defined(QT_NO_OPENSSL) @@ -3099,6 +3195,26 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const ua = QString(ua).arg(ver); #endif + // SubPlatform Version + QString subPlatformVer; +#ifdef Q_OS_SYMBIAN + QSysInfo::S60Version s60Version = QSysInfo::s60Version(); + switch (s60Version) { + case QSysInfo::SV_S60_3_1: + subPlatformVer = "/3.1"; + break; + case QSysInfo::SV_S60_3_2: + subPlatformVer = "/3.2"; + break; + case QSysInfo::SV_S60_5_0: + subPlatformVer = "/5.0"; + break; + default: + subPlatformVer = " Unknown"; + } +#endif + ua = ua.arg(subPlatformVer); + // Language QLocale locale; if (view()) @@ -3116,11 +3232,9 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const QString appName = QCoreApplication::applicationName(); if (!appName.isEmpty()) { ua.append(appName); -#if QT_VERSION >= 0x040400 QString appVer = QCoreApplication::applicationVersion(); if (!appVer.isEmpty()) ua.append(QLatin1Char('/') + appVer); -#endif } else { // Qt version ua.append(QLatin1String("Qt/")); @@ -3321,24 +3435,6 @@ quint64 QWebPage::bytesReceived() const */ /*! - \fn void QWebPage::webInspectorTriggered(const QWebElement& inspectedElement); - \since 4.6 - - This signal is emitted when the user triggered an inspection through the - context menu. If a QWebInspector is associated to this page, it should be - visible to the user after this signal has been emitted. - - If still no QWebInspector is associated to this QWebPage after the emission - of this signal, a privately owned inspector will be shown to the user. - - \note \a inspectedElement contains the QWebElement under the context menu. - It is not garanteed to be the same as the focused element in the web - inspector. - - \sa QWebInspector -*/ - -/*! \fn void QWebPage::toolBarVisibilityChangeRequested(bool visible) This signal is emitted whenever the visibility of the toolbar in a web browser @@ -3389,16 +3485,6 @@ quint64 QWebPage::bytesReceived() const */ /*! - \since 4.6 - \fn void QWebPage::networkRequestStarted(QWebFrame* frame, QNetworkRequest* request); - \preliminary - - This signal is emitted when a \a frame of the current page requests a web resource. The application - may want to associate the \a request with the \a frame that initiated it by storing the \a frame - as an attribute of the \a request. -*/ - -/*! \fn QWebPagePrivate* QWebPage::handle() const \internal */ diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index f2bbde0..4766cbd 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -208,20 +208,8 @@ public: QUndoStack *undoStack() const; #endif -#if QT_VERSION < 0x040400 && !defined(qdoc) - void setNetworkInterface(QWebNetworkInterface *interface); - QWebNetworkInterface *networkInterface() const; - - // #### why is this in the page itself? -#ifndef QT_NO_NETWORKPROXY - void setNetworkProxy(const QNetworkProxy& proxy); - QNetworkProxy networkProxy() const; -#endif - -#else void setNetworkAccessManager(QNetworkAccessManager *manager); QNetworkAccessManager *networkAccessManager() const; -#endif void setPluginFactory(QWebPluginFactory *factory); QWebPluginFactory *pluginFactory() const; @@ -329,16 +317,13 @@ Q_SIGNALS: void windowCloseRequested(); void printRequested(QWebFrame *frame); void linkClicked(const QUrl &url); - void webInspectorTriggered(const QWebElement& inspectedElement); void toolBarVisibilityChangeRequested(bool visible); void statusBarVisibilityChangeRequested(bool visible); void menuBarVisibilityChangeRequested(bool visible); -#if QT_VERSION >= 0x040400 void unsupportedContent(QNetworkReply *reply); void downloadRequested(const QNetworkRequest &request); -#endif void microFocusChanged(); void contentsChanged(); @@ -347,17 +332,11 @@ Q_SIGNALS: void saveFrameStateRequested(QWebFrame* frame, QWebHistoryItem* item); void restoreFrameStateRequested(QWebFrame* frame); - void networkRequestStarted(QWebFrame* frame, QNetworkRequest* request); - protected: virtual QWebPage *createWindow(WebWindowType type); virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); -#if QT_VERSION >= 0x040400 virtual bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type); -#else - virtual bool acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, NavigationType type); -#endif virtual QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile); virtual void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg); virtual bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg); diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h index f0f842d..5d97da4 100644 --- a/WebKit/qt/Api/qwebpage_p.h +++ b/WebKit/qt/Api/qwebpage_p.h @@ -151,18 +151,8 @@ public: bool clickCausedFocus; -#if QT_VERSION < 0x040400 - bool acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type); - - QWebNetworkInterface *networkInterface; -#ifndef QT_NO_NETWORKPROXY - QNetworkProxy networkProxy; -#endif - -#else bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type); QNetworkAccessManager *networkManager; -#endif bool forwardUnsupportedContent; QWebPage::LinkDelegationPolicy linkPolicy; diff --git a/WebKit/qt/Api/qwebplugindatabase.cpp b/WebKit/qt/Api/qwebplugindatabase.cpp index 623895f..758e257 100644 --- a/WebKit/qt/Api/qwebplugindatabase.cpp +++ b/WebKit/qt/Api/qwebplugindatabase.cpp @@ -18,7 +18,7 @@ */ #include "config.h" -#include "qwebplugindatabase.h" +#include "qwebplugindatabase_p.h" #include "PluginDatabase.h" #include "PluginPackage.h" @@ -26,6 +26,7 @@ using namespace WebCore; /*! + \internal \typedef QWebPluginInfo::MimeType \since 4.6 \brief Represents a single MIME type supported by a plugin. @@ -33,6 +34,7 @@ using namespace WebCore; /*! \class QWebPluginInfo + \internal \since 4.6 \brief The QWebPluginInfo class represents a single Netscape plugin. @@ -232,6 +234,7 @@ QWebPluginInfo &QWebPluginInfo::operator=(const QWebPluginInfo& other) /*! \class QWebPluginDatabase + \internal \since 4.6 \brief The QWebPluginDatabase class provides an interface for managing Netscape plugins used by WebKit in QWebPages. diff --git a/WebKit/qt/Api/qwebplugindatabase.h b/WebKit/qt/Api/qwebplugindatabase_p.h index b22c3de..b22c3de 100644 --- a/WebKit/qt/Api/qwebplugindatabase.h +++ b/WebKit/qt/Api/qwebplugindatabase_p.h diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp index ffa21e4..9a5ab46 100644 --- a/WebKit/qt/Api/qwebsettings.cpp +++ b/WebKit/qt/Api/qwebsettings.cpp @@ -22,7 +22,7 @@ #include "qwebpage.h" #include "qwebpage_p.h" -#include "qwebplugindatabase.h" +#include "qwebplugindatabase_p.h" #include "Cache.h" #include "CrossOriginPreflightResultCache.h" @@ -62,8 +62,6 @@ public: QString localStoragePath; QString offlineWebApplicationCachePath; qint64 offlineStorageDefaultQuota; - float printingMinimumShrinkFactor; - float printingMaximumShrinkFactor; void apply(); WebCore::Settings* settings; @@ -81,6 +79,7 @@ static WebGraphicHash* graphics() hash->insert(QWebSettings::MissingPluginGraphic, QPixmap(QLatin1String(":webkit/resources/nullPlugin.png"))); hash->insert(QWebSettings::DefaultFrameIconGraphic, QPixmap(QLatin1String(":webkit/resources/urlIcon.png"))); hash->insert(QWebSettings::TextAreaSizeGripCornerGraphic, QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png"))); + hash->insert(QWebSettings::DeleteButtonGraphic, QPixmap(QLatin1String(":webkit/resources/deleteButton.png"))); } return hash; @@ -176,12 +175,6 @@ void QWebSettingsPrivate::apply() QString storagePath = !localStoragePath.isEmpty() ? localStoragePath : global->localStoragePath; settings->setLocalStorageDatabasePath(storagePath); - float minimumShrinkFactor = printingMinimumShrinkFactor > 0.0f ? printingMinimumShrinkFactor : global->printingMinimumShrinkFactor; - settings->setPrintingMinimumShrinkFactor(minimumShrinkFactor); - - float maximumShrinkFactor = printingMaximumShrinkFactor > 0.0f ? printingMaximumShrinkFactor : global->printingMaximumShrinkFactor; - settings->setPrintingMaximumShrinkFactor(maximumShrinkFactor); - value = attributes.value(QWebSettings::ZoomTextOnly, global->attributes.value(QWebSettings::ZoomTextOnly)); settings->setZoomsTextOnly(value); @@ -206,10 +199,7 @@ void QWebSettingsPrivate::apply() value = attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls, global->attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls)); settings->setAllowUniversalAccessFromFileURLs(value); - - value = attributes.value(QWebSettings::SessionStorageEnabled, - global->attributes.value(QWebSettings::SessionStorageEnabled)); - settings->setSessionStorageEnabled(value); + settings->setUsesPageCache(WebCore::pageCache()->capacity()); } else { QList<QWebSettingsPrivate*> settings = *::allSettings(); for (int i = 0; i < settings.count(); ++i) @@ -273,7 +263,7 @@ QWebSettings* QWebSettings::globalSettings() setOfflineStoragePath() with an appropriate file path, and can limit the quota for each application by calling setOfflineStorageDefaultQuota(). - \sa QWebPage::settings(), QWebView::settings(), {Browser} + \sa QWebPage::settings(), QWebView::settings(), {Web Browser} */ /*! @@ -350,9 +340,9 @@ QWebSettings* QWebSettings::globalSettings() web application cache feature is enabled or not. Disabled by default. \value LocalStorageEnabled Specifies whether support for the HTML 5 local storage feature is enabled or not. Disabled by default. + \value LocalStorageDatabaseEnabled \e{This enum value is deprecated.} Use + QWebSettings::LocalStorageEnabled instead. \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are allowed to access remote urls. - \value SessionStorageEnabled Specifies whether support for the HTML 5 - session storage feature is enabled or not. Enabled by default. */ /*! @@ -383,11 +373,8 @@ QWebSettings::QWebSettings() d->attributes.insert(QWebSettings::OfflineWebApplicationCacheEnabled, false); d->attributes.insert(QWebSettings::LocalStorageEnabled, false); d->attributes.insert(QWebSettings::LocalContentCanAccessRemoteUrls, false); - d->attributes.insert(QWebSettings::SessionStorageEnabled, true); d->offlineStorageDefaultQuota = 5 * 1024 * 1024; d->defaultTextEncoding = QLatin1String("iso-8859-1"); - d->printingMinimumShrinkFactor = 0.0f; - d->printingMaximumShrinkFactor = 0.0f; } /*! @@ -502,60 +489,6 @@ QString QWebSettings::defaultTextEncoding() const } /*! - \since 4.7 - Specifies minimum shrink fator allowed for printing. If set to 0 a - default value is used. - - When printing, content will be shrunk to reduce page usage, it - will reduced by a factor between printingMinimumShrinkFactor and - printingMaximumShrinkFactor. - - \sa printingMinimumShrinkFactor() - \sa setPrintingMaximumShrinkFactor() - \sa printingMaximumShrinkFactor() -*/ -void QWebSettings::setPrintingMinimumShrinkFactor(float printingMinimumShrinkFactor) -{ - d->printingMinimumShrinkFactor = printingMinimumShrinkFactor; - d->apply(); -} - -/*! - \since 4.7 - returns the minimum shrink factor used for printing. - - \sa setPrintingMinimumShrinkFactor() -*/ -float QWebSettings::printingMinimumShrinkFactor() const -{ - return d->printingMinimumShrinkFactor; -} - -/*! - \since 4.7 - Specifies maximum shrink fator allowed for printing. If set to 0 a - default value is used. - - \sa setPrintingMinimumShrinkFactor() -*/ -void QWebSettings::setPrintingMaximumShrinkFactor(float printingMaximumShrinkFactor) -{ - d->printingMaximumShrinkFactor = printingMaximumShrinkFactor; - d->apply(); -} - -/*! - \since 4.7 - returns the maximum shrink factor used for printing. - - \sa setPrintingMinimumShrinkFactor() -*/ -float QWebSettings::printingMaximumShrinkFactor() const -{ - return d->printingMaximumShrinkFactor; -} - -/*! Sets the path of the icon database to \a path. The icon database is used to store "favicons" associated with web sites. @@ -625,9 +558,9 @@ QIcon QWebSettings::iconForUrl(const QUrl& url) return* icon; } -/*! +/* Returns the plugin database object. -*/ + QWebPluginDatabase *QWebSettings::pluginDatabase() { static QWebPluginDatabase* database = 0; @@ -635,6 +568,7 @@ QWebPluginDatabase *QWebSettings::pluginDatabase() database = new QWebPluginDatabase(); return database; } +*/ /*! Sets \a graphic to be drawn when QtWebKit needs to draw an image of the @@ -710,7 +644,9 @@ void QWebSettings::clearMemoryCaches() */ void QWebSettings::setMaximumPagesInCache(int pages) { + QWebSettingsPrivate* global = QWebSettings::globalSettings()->d; WebCore::pageCache()->setCapacity(qMax(0, pages)); + global->apply(); } /*! diff --git a/WebKit/qt/Api/qwebsettings.h b/WebKit/qt/Api/qwebsettings.h index e68ea53..69f3b11 100644 --- a/WebKit/qt/Api/qwebsettings.h +++ b/WebKit/qt/Api/qwebsettings.h @@ -67,14 +67,14 @@ public: LocalStorageDatabaseEnabled = LocalStorageEnabled, #endif LocalContentCanAccessRemoteUrls, - SessionStorageEnabled, DnsPrefetchEnabled }; enum WebGraphic { MissingImageGraphic, MissingPluginGraphic, DefaultFrameIconGraphic, - TextAreaSizeGripCornerGraphic + TextAreaSizeGripCornerGraphic, + DeleteButtonGraphic }; enum FontSize { MinimumFontSize, @@ -103,18 +103,12 @@ public: void setDefaultTextEncoding(const QString &encoding); QString defaultTextEncoding() const; - void setPrintingMinimumShrinkFactor(float printingMinimumShrinkFactor); - float printingMinimumShrinkFactor() const; - - void setPrintingMaximumShrinkFactor(float printingMaximimShrinkFactor); - float printingMaximumShrinkFactor() const; - static void setIconDatabasePath(const QString &location); static QString iconDatabasePath(); static void clearIconDatabase(); static QIcon iconForUrl(const QUrl &url); - static QWebPluginDatabase *pluginDatabase(); + //static QWebPluginDatabase *pluginDatabase(); static void setWebGraphic(WebGraphic type, const QPixmap &graphic); static QPixmap webGraphic(WebGraphic type); diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp index 4fa073d..7bc3168 100644 --- a/WebKit/qt/Api/qwebview.cpp +++ b/WebKit/qt/Api/qwebview.cpp @@ -32,11 +32,8 @@ #include "qprinter.h" #include "qdir.h" #include "qfile.h" -#if defined(Q_WS_X11) -#include <QX11Info> -#endif -class QWebViewPrivate : public QWebPageClient { +class QWebViewPrivate { public: QWebViewPrivate(QWebView *view) : view(view) @@ -46,24 +43,6 @@ public: Q_ASSERT(view); } - virtual void scroll(int dx, int dy, const QRect&); - virtual void update(const QRect& dirtyRect); - virtual void setInputMethodEnabled(bool enable); -#if QT_VERSION >= 0x040600 - virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable); -#endif - -#ifndef QT_NO_CURSOR - virtual QCursor cursor() const; - virtual void updateCursor(const QCursor& cursor); -#endif - - virtual QPalette palette() const; - virtual int screenNumber() const; - virtual QWidget* ownerWidget() const; - - virtual QObject* pluginParent() const; - void _q_pageDestroyed(); QWebView *view; @@ -72,66 +51,6 @@ public: QPainter::RenderHints renderHints; }; -void QWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll) -{ - view->scroll(qreal(dx), qreal(dy), rectToScroll); -} - -void QWebViewPrivate::update(const QRect & dirtyRect) -{ - view->update(dirtyRect); -} - -void QWebViewPrivate::setInputMethodEnabled(bool enable) -{ - view->setAttribute(Qt::WA_InputMethodEnabled, enable); -} -#if QT_VERSION >= 0x040600 -void QWebViewPrivate::setInputMethodHint(Qt::InputMethodHint hint, bool enable) -{ - if (enable) - view->setInputMethodHints(view->inputMethodHints() | hint); - else - view->setInputMethodHints(view->inputMethodHints() & ~hint); -} -#endif -#ifndef QT_NO_CURSOR -QCursor QWebViewPrivate::cursor() const -{ - return view->cursor(); -} - -void QWebViewPrivate::updateCursor(const QCursor& cursor) -{ - view->setCursor(cursor); -} -#endif - -QPalette QWebViewPrivate::palette() const -{ - return view->palette(); -} - -int QWebViewPrivate::screenNumber() const -{ -#if defined(Q_WS_X11) - if (view) - return view->x11Info().screen(); -#endif - - return 0; -} - -QWidget* QWebViewPrivate::ownerWidget() const -{ - return view; -} - -QObject* QWebViewPrivate::pluginParent() const -{ - return view; -} - void QWebViewPrivate::_q_pageDestroyed() { page = 0; @@ -151,7 +70,7 @@ void QWebViewPrivate::_q_pageDestroyed() It can be used in various applications to display web content live from the Internet. - The image below shows QWebView previewed in \QD with the Trolltech website. + The image below shows QWebView previewed in \QD with a Nokia website. \image qwebview-url.png @@ -251,6 +170,7 @@ QWebView::~QWebView() #else d->page->d->view = 0; #endif + delete d->page->d->client; d->page->d->client = 0; } @@ -296,16 +216,15 @@ void QWebView::setPage(QWebPage* page) d->page = page; if (d->page) { d->page->setView(this); - d->page->d->client = d; // set the page client d->page->setPalette(palette()); // #### connect signals QWebFrame *mainFrame = d->page->mainFrame(); - connect(mainFrame, SIGNAL(titleChanged(const QString&)), - this, SIGNAL(titleChanged(const QString&))); + connect(mainFrame, SIGNAL(titleChanged(QString)), + this, SIGNAL(titleChanged(QString))); connect(mainFrame, SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); - connect(mainFrame, SIGNAL(urlChanged(const QUrl &)), - this, SIGNAL(urlChanged(const QUrl &))); + connect(mainFrame, SIGNAL(urlChanged(QUrl)), + this, SIGNAL(urlChanged(QUrl))); connect(d->page, SIGNAL(loadStarted()), this, SIGNAL(loadStarted())); @@ -313,10 +232,10 @@ void QWebView::setPage(QWebPage* page) this, SIGNAL(loadProgress(int))); connect(d->page, SIGNAL(loadFinished(bool)), this, SIGNAL(loadFinished(bool))); - connect(d->page, SIGNAL(statusBarMessage(const QString &)), - this, SIGNAL(statusBarMessage(const QString &))); - connect(d->page, SIGNAL(linkClicked(const QUrl &)), - this, SIGNAL(linkClicked(const QUrl &))); + connect(d->page, SIGNAL(statusBarMessage(QString)), + this, SIGNAL(statusBarMessage(QString))); + connect(d->page, SIGNAL(linkClicked(QUrl)), + this, SIGNAL(linkClicked(QUrl))); connect(d->page, SIGNAL(microFocusChanged()), this, SLOT(updateMicroFocus())); @@ -328,84 +247,11 @@ void QWebView::setPage(QWebPage* page) } /*! - Returns a valid URL from a user supplied \a string if one can be deducted. - In the case that is not possible, an invalid QUrl() is returned. - - \since 4.6 - - Most applications that can browse the web, allow the user to input a URL - in the form of a plain string. This string can be manually typed into - a location bar, obtained from the clipboard, or passed in via command - line arguments. - - When the string is not already a valid URL, a best guess is performed, - making various web related assumptions. - - In the case the string corresponds to a valid file path on the system, - a file:// URL is constructed, using QUrl::fromLocalFile(). - - If that is not the case, an attempt is made to turn the string into a - http:// or ftp:// URL. The latter in the case the string starts with - 'ftp'. The result is then passed through QUrl's tolerant parser, and - in the case or success, a valid QUrl is returned, or else a QUrl(). - - \section1 Examples: - - \list - \o webkit.org becomes http://webkit.org - \o ftp.webkit.org becomes ftp://ftp.webkit.org - \o localhost becomes http://localhost - \o /home/user/test.html becomes file:///home/user/test.html (if exists) - \endlist - - \section2 Tips when dealing with URLs and strings: - - \list - \o When creating a QString from a QByteArray or a char*, always use - QString::fromUtf8(). - \o Do not use QUrl(string), nor QUrl::toString() anywhere where the URL might - be used, such as in the location bar, as those functions loose data. - Instead use QUrl::fromEncoded() and QUrl::toEncoded(), respectively. - \endlist - */ -QUrl QWebView::guessUrlFromString(const QString &string) -{ - QString trimmedString = string.trimmed(); - - // Check the most common case of a valid url with scheme and host first - QUrl url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode); - if (url.isValid() && !url.scheme().isEmpty() && !url.host().isEmpty()) - return url; - - // Absolute files that exists - if (QDir::isAbsolutePath(trimmedString) && QFile::exists(trimmedString)) - return QUrl::fromLocalFile(trimmedString); - - // If the string is missing the scheme or the scheme is not valid prepend a scheme - QString scheme = url.scheme(); - if (scheme.isEmpty() || scheme.contains(QLatin1Char('.')) || scheme == QLatin1String("localhost")) { - // Do not do anything for strings such as "foo", only "foo.com" - int dotIndex = trimmedString.indexOf(QLatin1Char('.')); - if (dotIndex != -1 || trimmedString.startsWith(QLatin1String("localhost"))) { - const QString hostscheme = trimmedString.left(dotIndex).toLower(); - QByteArray scheme = (hostscheme == QLatin1String("ftp")) ? "ftp" : "http"; - trimmedString = QLatin1String(scheme) + QLatin1String("://") + trimmedString; - } - url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode); - } - - if (url.isValid()) - return url; - - return QUrl(); -} - -/*! Loads the specified \a url and displays it. \note The view remains the same until enough data has arrived to display the new \a url. - \sa setUrl(), url(), urlChanged(), guessUrlFromString() + \sa setUrl(), url(), urlChanged(), QUrl::fromUserInput() */ void QWebView::load(const QUrl &url) { @@ -424,19 +270,11 @@ void QWebView::load(const QUrl &url) \sa url(), urlChanged() */ -#if QT_VERSION < 0x040400 && !defined(qdoc) -void QWebView::load(const QWebNetworkRequest &request) -#else void QWebView::load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation, const QByteArray &body) -#endif { - page()->mainFrame()->load(request -#if QT_VERSION >= 0x040400 - , operation, body -#endif - ); + page()->mainFrame()->load(request, operation, body); } /*! @@ -790,7 +628,6 @@ bool QWebView::event(QEvent *e) if (e->type() == QEvent::ShortcutOverride) { d->page->event(e); #ifndef QT_NO_CURSOR -#if QT_VERSION >= 0x040400 } else if (e->type() == QEvent::CursorChange) { // An unsetCursor will set the cursor to Qt::ArrowCursor. // Thus this cursor change might be a QWidget::unsetCursor() @@ -801,8 +638,7 @@ bool QWebView::event(QEvent *e) // WebCore. // FIXME: Add a QEvent::CursorUnset or similar to Qt. if (cursor().shape() == Qt::ArrowCursor) - d->resetCursor(); -#endif + d->page->d->client->resetCursor(); #endif } else if (e->type() == QEvent::Leave) d->page->event(e); @@ -913,8 +749,12 @@ void QWebView::paintEvent(QPaintEvent *ev) } /*! - 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. + This function is called from the createWindow() method of the associated QWebPage, + each time the page wants to create a new window of the given \a type. This might + be the result, for example, of a JavaScript request to open a document in a new window. + + \note If the createWindow() method of the associated page is reimplemented, this + method is not called, unless explicitly done so in the reimplementation. \sa QWebPage::createWindow() */ @@ -1128,7 +968,7 @@ void QWebView::changeEvent(QEvent *e) /*! \fn void QWebView::statusBarMessage(const QString& text) - This signal is emitted when the statusbar \a text is changed by the page. + This signal is emitted when the status bar \a text is changed by the page. */ /*! diff --git a/WebKit/qt/Api/qwebview.h b/WebKit/qt/Api/qwebview.h index b63a593..d7910d9 100644 --- a/WebKit/qt/Api/qwebview.h +++ b/WebKit/qt/Api/qwebview.h @@ -27,9 +27,7 @@ #include <QtGui/qicon.h> #include <QtGui/qpainter.h> #include <QtCore/qurl.h> -#if QT_VERSION >= 0x040400 #include <QtNetwork/qnetworkaccessmanager.h> -#endif QT_BEGIN_NAMESPACE class QNetworkRequest; @@ -65,16 +63,10 @@ public: QWebPage* page() const; void setPage(QWebPage* page); - static QUrl guessUrlFromString(const QString& string); - void load(const QUrl& url); -#if QT_VERSION < 0x040400 && !defined(qdoc) - void load(const QWebNetworkRequest& request); -#else void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray()); -#endif void setHtml(const QString& html, const QUrl& baseUrl = QUrl()); void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl()); diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog index 67cf7f3..2c2722b 100644 --- a/WebKit/qt/ChangeLog +++ b/WebKit/qt/ChangeLog @@ -1,3 +1,1237 @@ +2009-12-07 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Improve the autotests of QtWebkit + https://bugs.webkit.org/show_bug.cgi?id=32216 + + Remove the calls to qWait() of the autotest of QWebView + + * tests/qwebview/tst_qwebview.cpp: + (tst_QWebView::reusePage): + +2009-12-07 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Improve the autotests of QtWebkit + https://bugs.webkit.org/show_bug.cgi?id=32216 + + Refactor tst_qwebframe to remove qWait() and use + the function waitForSignal() from util.h + + * tests/qwebframe/tst_qwebframe.cpp: + +2009-12-07 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Improve the autotests of QtWebkit + https://bugs.webkit.org/show_bug.cgi?id=32216 + + Refactor the test of QGraphicsWebView: + -make waitForSignal() available to all the tests. + -remove QTest::qWait() + + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::crashOnViewlessWebPages): + * tests/util.h: + (waitForSignal): + +2009-12-07 Girish Ramakrishnan <girish@forwardbias.in> + + Reviewed by Simon Hausmann. + + [Qt] Plugins: Force windowless mode when there is no native window handle + + Inject wmode=opaque while instantiating the plugin for the case when the + webpage is not backed by a native window handle. + + https://bugs.webkit.org/show_bug.cgi?id=32059 + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::createPlugin): + +2009-12-04 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Corrects QtLauncher style + + * QtLauncher/main.cpp: + (WebPage::acceptNavigationRequest): + (MainWindow::MainWindow): + (MainWindow::webPage): + (MainWindow::webView): + (MainWindow::changeLocation): + (MainWindow::loadFinished): + (MainWindow::showLinkHover): + (MainWindow::zoomIn): + (MainWindow::zoomOut): + (MainWindow::print): + (MainWindow::setEditable): + (MainWindow::dumpHtml): + (MainWindow::selectElements): + (MainWindow::newWindow): + (MainWindow::setupUI): + (WebPage::createWindow): + (WebPage::createPlugin): + (main): + +2009-12-04 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] QtLauncher: add a menu to show or hide the web inspector. + https://bugs.webkit.org/show_bug.cgi?id=32149 + + * QtLauncher/main.cpp: + (WebInspector::WebInspector): + (WebInspector::showEvent): + (WebInspector::hideEvent): + (MainWindow::MainWindow): + (MainWindow::setupUI): + +2009-12-04 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Antti Koivisto. + + Split out the renderPrivate in two methods, one for working on + relative coordinates (relative to the viewport) and one for + working on absolute coordinates. The latter is more effecient + for implementing tiling, as you don't need translate the coords, + and because it avoid clipping to the viewport. + + No behaviour changes, so no new tests. + + * Api/qwebframe.cpp: + (QWebFramePrivate::renderContentsLayerAbsoluteCoords): + (QWebFramePrivate::renderRelativeCoords): + (QWebFrame::render): + * Api/qwebframe_p.h: + +2009-12-04 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Allow removing 'qrc' as a local security origin scheme + + * tests/qwebpage/tst_qwebpage.cpp: + +2009-12-04 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Clean up argument parsing in the QtLauncher + + * QtLauncher/main.cpp: + +2009-12-04 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Prevent the inspector from closing its wrapping widget. + This is not necessary anymore since we now hide the embedded + close button. + https://bugs.webkit.org/show_bug.cgi?id=32149 + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientQt::showWindow): + (WebCore::InspectorClientQt::closeWindow): + +2009-12-03 İsmail Dönmez <ismail@namtrac.org> + + Reviewed by Eric Seidel. + + Fix compilation when SVG is disabled. + + * Api/qwebframe.cpp: + (qt_drt_pauseSVGAnimation): + +2009-12-03 Brady Eidson <beidson@apple.com> + + Reviewed by Sam Weinig. + + <rdar://problem/7214236> and http://webkit.org/b/32052 - Implement HTML5 state object history API + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDidPushStateWithinPage): + (WebCore::FrameLoaderClientQt::dispatchDidReplaceStateWithinPage): + (WebCore::FrameLoaderClientQt::dispatchDidPopStateWithinPage): + * WebCoreSupport/FrameLoaderClientQt.h: + +2009-12-03 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com> + + Reviewed by Timothy Hatcher. + + Web Inspector: Simplify the settings support in inspector controller. + + https://bugs.webkit.org/show_bug.cgi?id=32076 + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientQt::populateSetting): + (WebCore::InspectorClientQt::storeSetting): + (WebCore::variantToSetting): + (WebCore::settingToVariant): + * WebCoreSupport/InspectorClientQt.h: + +2009-12-03 Ben Murdoch <benm@google.com> + + Reviewed by Brady Eidson. + + [Android] The FrameLoaderClient is unaware of BackForwardList changes. + https://bugs.webkit.org/show_bug.cgi?id=31914 + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDidAddBackForwardItem): Add an empty implementation. Method added to FrameLoaderClient by Android (see bug). + (WebCore::FrameLoaderClientQt::dispatchDidRemoveBackForwardItem): ditto. + (WebCore::FrameLoaderClientQt::dispatchDidChangeBackForwardIndex): ditto. + * WebCoreSupport/FrameLoaderClientQt.h: + +2009-12-01 Nikolas Zimmermann <nzimmermann@rim.com> + + Not reviewed. Try to fix Qt build. + + * Api/qwebframe.cpp: + (qt_drt_pauseSVGAnimation): + +2009-12-01 Nikolas Zimmermann <nzimmermann@rim.com> + + Reviewed by Simon Fraser. + + Add SVG animation test framework with 'snapshot' functionality + https://bugs.webkit.org/show_bug.cgi?id=31897 + + Add API used by the new 'sampleSVGAnimationForElementAtTime' DRT method, + forwarding the call to SVGDocumentExtensions, if SVG is enabled. + + Implemented just like the existing pauseAnimation* methods for CSS animations. + + * Api/qwebframe.cpp: + (qt_drt_pauseSVGAnimation): + +2009-12-01 Daniel Bates <dbates@webkit.org> + + Reviewed by Kenneth Rohde Christiansen. + + https://bugs.webkit.org/show_bug.cgi?id=31898 + + Makes QtLauncher default to the http scheme for URLs. + + * QtLauncher/main.cpp: + (MainWindow::MainWindow): + (MainWindow::changeLocation): + (main): + +2009-11-30 Abhinav Mithal <abhinav.mithal@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt][Symbian] Report SymbianOS in user agent string for Symbian + https://bugs.webkit.org/show_bug.cgi?id=31961 + + * Api/qwebpage.cpp: + (QWebPage::userAgentForUrl): + +2009-11-30 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Fix minor waning in QtWebKit + https://bugs.webkit.org/show_bug.cgi?id=31963 + + * tests/qwebpage/tst_qwebpage.cpp: + (ErrorPage::extension): Remove info wariable as it is + not used. + +2009-11-28 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] SoftwareInputPanelRequest event sent when clicking in newly loaded page + + https://bugs.webkit.org/show_bug.cgi?id=31401 + + Don't set the event unless there is a focused node we can use + for editing afterwards. + + * Api/qwebpage.cpp: + (QWebPagePrivate::handleSoftwareInputPanel): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::inputMethods): + +2009-11-26 Simon Hausmann <simon.hausmann@nokia.com> + + Rubber-stamped by Holger Freyther. + + Removed unused ICO image plugin handler. + + * Plugins/ICOHandler.cpp: Removed. + * Plugins/ICOHandler.h: Removed. + * Plugins/Plugins.pro: Removed. + +2009-11-12 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Do not show the QWidget when the WebCore::Widget is hidden + https://bugs.webkit.org/show_bug.cgi?id=31203 + + The clipping code was making a QWidget visible even if the + WebCore::Widget was hidden. Fix the bug by calling setVisible + only if the WebCore::Widget Widget::isSelfVisible. + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::QtPluginWidget::show): Override WebCore::Widget::show to call handleVisibility + (WebCore::QtPluginWidget::handleVisibility): New method to call setVisible when we are visible + (FrameLoaderClientQt::createPlugin): Hide the QWidget by default + +2009-11-23 David Boddie <dboddie@trolltech.com> + + Reviewed by Simon Hausmann. + + Updated the QWebElement documentation with links to examples and + external resources. + Fixed the project file for the webelement snippet and tidied up the + markers used for quoting the code. + + * Api/qwebelement.cpp: + * docs/webkitsnippets/webelement/main.cpp: + (findAll): + * docs/webkitsnippets/webelement/webelement.pro: + +2009-11-23 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Wrong runtime instance objects of wrapped QObjects may be used if + the wrapped object died before the gc removed the instance. + + https://bugs.webkit.org/show_bug.cgi?id=31681 + + Added a unit-test to verify that wrapping a QObject with the + same identity as a previously but now dead object works. + + * tests/qwebframe/tst_qwebframe.cpp: + +2009-11-19 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Add instantiation tests for QWebInspector. + + * tests/qwebinspector/qwebinspector.pro: Added. + * tests/qwebinspector/tst_qwebinspector.cpp: Added. + (tst_QWebInspector::attachAndDestroy): + * tests/tests.pro: + +2009-11-19 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Fix QWebInspector destruction problem. + https://bugs.webkit.org/show_bug.cgi?id=31664 + + * Api/qwebpage.cpp: + (QWebPage::~QWebPage): + +2009-11-19 Olivier Goffart <ogoffart@trolltech.com> + + Reviewed by Simon Hausmann. + + [Qt] Normalize signal and slot signatures. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::setPage): + * Api/qwebview.cpp: + (QWebView::setPage): + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::setFrame): + * docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp: + (wrapInFunction): + * tests/qwebframe/tst_qwebframe.cpp: + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::modified): + (tst_QWebPage::database): + +2009-11-18 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Remove support for Qt v4.3 or older versions + https://bugs.webkit.org/show_bug.cgi?id=29469 + + * Api/qcookiejar.cpp: Removed. + * Api/qcookiejar.h: Removed. + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::event): + * Api/qwebframe.cpp: + (QWebFrame::load): + * Api/qwebframe.h: + * Api/qwebkitglobal.h: + * Api/qwebnetworkinterface.cpp: Removed. + * Api/qwebnetworkinterface.h: Removed. + * Api/qwebnetworkinterface_p.h: Removed. + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): + (QWebPagePrivate::acceptNavigationRequest): + (QWebPage::acceptNavigationRequest): + (QWebPage::action): + (QWebPage::userAgentForUrl): + * Api/qwebpage.h: + * Api/qwebpage_p.h: + * Api/qwebview.cpp: + (QWebView::load): + (QWebView::event): + * Api/qwebview.h: + * QtLauncher/main.cpp: + (MainWindow::print): + (MainWindow::setupUI): + (main): + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::download): + (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction): + (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction): + (WebCore::FrameLoaderClientQt::startDownload): + (WebCore::FrameLoaderClientQt::createPlugin): + +2009-11-18 Shu Chang <Chang.Shu@nokia.com> + + Reviewed by Eric Seidel. + + [Qt] Add support for displaying deleteButton. + https://bugs.webkit.org/show_bug.cgi?id=31560 + + Test: LayoutTests/editing/deleting/5408255.html + + * Api/qwebsettings.cpp: + (graphics): + * Api/qwebsettings.h: + +2009-11-18 Paul Olav Tvete <paul.tvete@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Make the QWebElement::render() test pass when pixmaps aren't 32 bit. + + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::render): + +2009-11-18 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Tor Arne Vestbø. + + Clarify and simplify the legal section in the overview documentation, + after review with our legal team. + + * docs/qtwebkit.qdoc: + +2009-11-18 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Add QtLauncher support for opening links in the default browser + + This can be triggered by either the context menu or by clicking a link + while holding down the Alt key. Opening a link in a new windows is + triggered by holding down Shift. + + * QtLauncher/main.cpp: + +2009-11-17 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] QGLLauncher does not support drag&drop of local files + https://bugs.webkit.org/show_bug.cgi?id=31057 + + Enable accepting files in QGraphicsWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::QGraphicsWebView): + (QGraphicsWebView::dragEnterEvent): + +2009-11-17 Antonio Gomes <tonikitoo@webkit.org> + + Reviewed by Kenneth Christiansen. + + [Qt] better test coverage for ErrorPageExtension + https://bugs.webkit.org/show_bug.cgi?id=31583 + + Improved the coverage of current ErrorPageExtension tests by + adding autotests involving frameset and iframes. + + * tests/qwebpage/tst_qwebpage.cpp: + (ErrorPage::extension): Make the ErrorPageExtension + to work for all frames, not only the main frame. + (tst_QWebPage::errorPageExtension): Stop using + the 'frameset.html' resouce in this method since + an autotest specific for frameset's is being added. + (tst_QWebPage::errorPageExtensionInIFrames): Added. + (tst_QWebPage::errorPageExtensionInFrameset): Added. + +2009-11-16 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + API documentation fixes. + + * Api/qgraphicswebview.cpp: Removed duplicate docs. + * Api/qwebelement.cpp: Added missing docs. + * Api/qwebsettings.cpp: Ditto. + +2009-11-14 Antonio Gomes <tonikitoo@webkit.org> + + Reviewed by Antti Koivisto. + + [Qt] Broken back/forward after using ErrorPageExtension to set error page + https://bugs.webkit.org/show_bug.cgi?id=30573 + + Implemented autotests for covering the back/forward + reset problem involving error pages. + + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::errorPageExtension): + +2009-11-13 Adam Roben <aroben@apple.com> + + Update for changes to FrameLoaderClient + + Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when + window objects in isolated worlds are cleared + + Reviewed by Dave Hyatt. + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld): + * WebCoreSupport/FrameLoaderClientQt.h: + Replaced windowObjectCleared with this function. Does nothing if the + passed-in world is not the mainThreadNormalWorld(). + +2009-11-13 Andras Becsi <becsi.andras@stud.u-szeged.hu> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Enable Page Cache if setMaximumPagesInCache needs it. + This fixes https://bugs.webkit.org/show_bug.cgi?id=31266. + + * Api/qwebsettings.cpp: + (QWebSettingsPrivate::apply): + (QWebSettings::setMaximumPagesInCache): + +2009-11-13 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Fix initial QWebView focus behavior. + + focusController->setFocused(true) was not always called. + https://bugs.webkit.org/show_bug.cgi?id=31466 + + * Api/qwebpage.cpp: + (QWebPagePrivate::focusInEvent): + +2009-11-13 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + Update documentation for the Qt API + + * Api/qgraphicswebview.cpp: + * Api/qwebelement.cpp: + * Api/qwebframe.cpp: + * Api/qwebsettings.cpp: + * Api/qwebview.cpp: + +2009-11-13 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + Use correct install-path when running qdoc3 + + * docs/docs.pri: + +2009-11-12 Shinichiro Hamaji <hamaji@chromium.org> + + Reviewed by Darin Adler. + + externalRepresentation should take Frame as the argument + https://bugs.webkit.org/show_bug.cgi?id=31393 + + No new tests as this is just a refactoring. + + * Api/qwebframe.cpp: + (QWebFrame::renderTreeDump): + +2009-11-12 Antonio Gomes <tonikitoo@webkit.org> + + Reviewed by Jan Alonzo. + + [Qt] Various doc fixes + https://bugs.webkit.org/show_bug.cgi?id=31358 + + QWebPage's constructor docs are mentioning "QWebView": + "Constructs an empty QWebView with parent". + + * Api/qwebpage.cpp: + +2009-11-12 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + Custom printing shrink factors + https://bugs.webkit.org/show_bug.cgi?id=29042 + + This reverts commit r49769. The public API for this needs to be reviewed + before its inclusion in Qt. + + * Api/qwebsettings.cpp: + (QWebSettingsPrivate::apply): + (QWebSettings::QWebSettings): + * Api/qwebsettings.h: + +2009-11-11 Antonio Gomes <tonikitoo@webkit.org> + + Reviewed by Kenneth Christiansen. + + [Qt] Various doc fixes + https://bugs.webkit.org/show_bug.cgi?id=31358 + + Fixed wrong documentation: item's dimensions do fit to Web page + content by default. + + Kenneth agreed to land this as a followup patch to the + just landed documentation patch. + + * Api/qgraphicswebview.cpp: + +2009-11-11 David Boddie <dboddie@trolltech.com> + + Reviewed by Kenneth Christiansen. + + [Qt] Various doc fixes + https://bugs.webkit.org/show_bug.cgi?id=31323 + + Fixed and synchronized QWebView related documentation. + + * Api/qgraphicswebview.cpp: + * Api/qwebview.cpp: + +2009-11-11 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Unreviewed buildbot fix. + + Export a method to the DRT to know if the document has a + document element. + + * Api/qwebframe.cpp: + (qt_drt_hasDocumentElement): + +2009-11-11 Liang QI <liang.qi@nokia.com> + + [Qt] Fix tst_qwebpage and tst_qwebframe compilation on Symbian. + + * tests/qwebframe/qwebframe.pro: + * tests/qwebframe/tst_qwebframe.cpp: + * tests/qwebpage/qwebpage.pro: + * tests/qwebpage/tst_qwebpage.cpp: + +2009-11-11 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Simon Hausmann. + + Fix a crash in the layout test plugins/document-open.html + + * Api/qwebframe.cpp: + (QWebFrame::toPlainText): + +2009-11-11 Warwick Allison <warwick.allison@nokia.com>, Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Tor Arne Vestbø. + + [Qt] Regression: Preserve the parent of plugin objects when using + QtWebKit with only a QWebPage. + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::createPlugin): Don't reparent + plugins to 0. + * tests/qwebpage/tst_qwebpage.cpp: + (PluginCounterPage::PluginCounterPage): Initialize m_pluginParent to 0. + (PluginCounterPage::~PluginCounterPage): Delete the plugin parent later + (after the page) + (PluginTracerPage::createPlugin): Assign a dummy parent to the plugin. + (PluginTracerPage::PluginTracerPage): Set up the plugin parent. + (tst_QWebPage::createViewlessPlugin): Verify that for viewless pages the + plugin parent remains unchanged. + +2009-11-11 David Boddie <dboddie@trolltech.com> + + [Qt] Doc: Added internal or hidden placeholder documentation. + + * Api/qwebpage.cpp: + +2009-11-11 Martin Smith <msmith@trolltech.com> + + [Qt] doc: Changed Trolltech to Nokia + + * Api/qwebview.cpp: + +2009-11-11 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + https://bugs.webkit.org/show_bug.cgi?id=31323 + Fix a few compiler warnings + + * tests/qwebframe/tst_qwebframe.cpp: Add extra brackets + to make it explicit where the else case belongs + +2009-11-11 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Tor Arne Vestbø. + + Fix enabling of software input panel when activating editable elements + in QGraphicsWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::inputMethodEnabled): Implement method to + query for input method support. + * Api/qwebpage.cpp: + (QWebPageWidgetClient::inputMethodEnabled): Ditto for QWidget. + (QWebPagePrivate::handleSoftwareInputPanel): Don't use view() to + test for input method support. Instead query using QWebPageClient + and send the SIPR event to the ownerWidget() instead of the view(). + The latter is null for QGraphicsWebView. + * tests/qwebpage/tst_qwebpage.cpp: + (EventSpy::EventSpy): + (EventSpy::eventFilter): + (tst_QWebPage::inputMethods): Modify the test to verify that SIPR + events are dispatched when activating focusable content. + +2009-11-10 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Unreviewed documentation fixes. + + Added a few improvements from Jocelyn Turcotte to the + createWindow docs. + + * Api/qwebview.cpp: + +2009-11-10 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Unreviewed documentation fix. + + [Qt] Make qwebpage's createWindow not qwebview dependent. + https://bugs.webkit.org/show_bug.cgi?id=30771 + + Update documentation to make it clear that a reimplementation + of the createWindow method of the associated QWebPage can + result in the QWebView::createWindow method to never be called. + + * Api/qwebview.cpp: + +2009-11-09 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Few classes have virtual functions but non-virtual destructor + https://bugs.webkit.org/show_bug.cgi?id=31269 + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate): Add virtual + destructor. + +2009-11-09 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + https://bugs.webkit.org/show_bug.cgi?id=30628 + Add an API to get all the attributes from a QWebElement. + + * Api/qwebelement.cpp: + (QWebElement::attributesName): + * Api/qwebelement.h: + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::listAttributes): + +2009-11-09 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + Use explicit parentheses to silence gcc 4.4 -Wparentheses warnings + https://bugs.webkit.org/show_bug.cgi?id=31040 + + * Api/qwebpage.cpp: + (QWebPagePrivate::handleScrolling): + +2009-11-09 Mark Mentovai <mark@chromium.org> + + Reviewed by Dan Bernstein. + + Track "can have scrollbar" state within FrameView independently of the + individual scrollbar states in ScrollView. + + rdar://problem/7215132, https://bugs.webkit.org/show_bug.cgi?id=29167 + REGRESSION (r48064): mint.com loses scrollbars after coming out of + edit mode. + + rdar://problem/7314421, https://bugs.webkit.org/show_bug.cgi?id=30517 + REGRESSION (r48064): Extra scroll bars in GarageBand Lesson Store. + + Test: fast/overflow/scrollbar-restored.html + + * Api/qwebframe.cpp: + (QWebFrame::setScrollBarPolicy): + +2009-11-09 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + https://bugs.webkit.org/show_bug.cgi?id=30772 + Add a non-const iterator to QWebElementCollection. + Move the two attributes of the iterator to private. + + * Api/qwebelement.h: + (const_iterator::begin): + (const_iterator::end): + (const_iterator::constBegin): + (const_iterator::constEnd): + (const_iterator::iterator::iterator): + (const_iterator::iterator::operator*): + (const_iterator::iterator::operator==): + (const_iterator::iterator::operator!=): + (const_iterator::iterator::operator<): + (const_iterator::iterator::operator<=): + (const_iterator::iterator::operator>): + (const_iterator::iterator::operator>=): + (const_iterator::iterator::operator++): + (const_iterator::iterator::operator--): + (const_iterator::iterator::operator+=): + (const_iterator::iterator::operator-=): + (const_iterator::iterator::operator+): + (const_iterator::iterator::operator-): + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::nonConstIterator): + (tst_QWebElement::constIterator): + +2009-11-09 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Christiansen. + + [Qt] Remove the sessionStorage setting (per Page) + https://bugs.webkit.org/show_bug.cgi?id=31249 + + This setting allows to run sessionStorage on/off on a per page + basis. Remove this prematurely exposed API. + + * Api/qwebsettings.cpp: + (QWebSettingsPrivate::apply): + (QWebSettings::QWebSettings): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::database): + (tst_QWebPage::testOptionalJSObjects): + +2009-11-09 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Remove the QWebPage:webInspectorTriggered signal. + User customization of the communication between QWebPage + and QWebInspector will be properly designed in the next version. + https://bugs.webkit.org/show_bug.cgi?id=30773 + + * Api/qwebinspector.cpp: + * Api/qwebpage.cpp: + (QWebPagePrivate::getOrCreateInspector): + (QWebPage::triggerAction): + * Api/qwebpage.h: + * QtLauncher/main.cpp: + (MainWindow::MainWindow): + +2009-11-05 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Added a missing re-implementation of QGraphicsItem::inputMethodQuery(). + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::inputMethodQuery): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Provide a dummy re-implementation of QGraphicsLayoutItem::sizeHint(), + similar to QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::sizeHint): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Removed zoomFactoryChanged() signal and added + linkClicked() to QGraphicsWebView, for consistency with + QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::setPage): + (QGraphicsWebView::setZoomFactor): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Added QGraphicsWebView::findText() for convenience and consistency + with QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::findText): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Added QGraphicsWebView::pageAction() and triggerPageAction(), for + consistency with QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::pageAction): + (QGraphicsWebView::triggerPageAction): + * Api/qgraphicswebview.h: + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Removed QGraphicsWebView::toHtml() after API review. + + That's consistent with QWebView and also based on the assumption that + toHtml() is called less frequently than setHtml(). + + * Api/qgraphicswebview.cpp: + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Removed the interactive property of QGraphicsWebView. + + There are clearly use-cases for this feature, but it will require + more work to make this fully work with an enum to have fine-grained + control over the interactivity levels. For now it is easy to achieve + in user-code what the boolean property did. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate): + (QGraphicsWebView::hoverMoveEvent): + (QGraphicsWebView::mouseMoveEvent): + (QGraphicsWebView::mousePressEvent): + (QGraphicsWebView::mouseReleaseEvent): + (QGraphicsWebView::mouseDoubleClickEvent): + (QGraphicsWebView::keyPressEvent): + (QGraphicsWebView::keyReleaseEvent): + (QGraphicsWebView::dragLeaveEvent): + (QGraphicsWebView::dragMoveEvent): + (QGraphicsWebView::dropEvent): + (QGraphicsWebView::wheelEvent): + (QGraphicsWebView::inputMethodEvent): + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Make the QGraphicsWebView constructor explicit. + + * Api/qgraphicswebview.h: + +2009-11-05 Shu Chang <Chang.Shu@nokia.com> + + Reviewed by Tor Arne Vestbø. + + Add support for Shift-PageUp and Shift-PageDown key events. + https://bugs.webkit.org/show_bug.cgi?id=31166 + + Test: LayoutTests/editing/selection/shrink-selection-after-shift-pagedown.html + + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::handleKeyboardEvent): + +2009-11-05 Simon Hausmann <hausmann@webkit.org> + + Last Qt 4.5 build fix (*sigh*) + + * tests/qwebpage/tst_qwebpage.cpp: + (inputMethodHints): inputMethodHints() is only used for + Qt 4.6, so guard the whole function. + +2009-11-05 Simon Hausmann <hausmann@webkit.org> + + Another prospective build fix against Qt 4.5 (build bot) + + Don't compile & run the QGraphicsWebView portion of the + input methods auto test with Qt 4.5. + + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::inputMethods_data): + (inputMethodHints): + (inputMethodEnabled): + (tst_QWebPage::inputMethods): + +2009-11-05 Simon Hausmann <hausmann@webkit.org> + + Prospective build fix against Qt 4.5 (build bot) + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::setInputMethodEnabled): Guard the + use of Qt 4.6 specific API with #ifdefs. + +2009-11-01 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Kenneth Christiansen. + + [Qt] Fix enabling of input method support on QGraphicsWebView. + https://bugs.webkit.org/show_bug.cgi?id=30605 + + Instead of setting the unsupported widget attribute on the + QGraphicsWidget in setInputMethodEnabled() set the + ItemAcceptsInputMethod GraphicsItem flag directly. + + Changed the existing input method auto test to run once + on a QWebView and once on a QGraphicsWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::setInputMethodEnabled): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::inputMethods_data): + (inputMethodHints): + (inputMethodEnabled): + (tst_QWebPage::inputMethods): + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Kenneth Christiansen. + + Added QGraphicsWebView::modified property, for consistency + with QWebView. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::isModified): + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + +2009-11-04 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Kenneth Christiansen. + + Removed status and progress properties of QGraphicsWebView. + Added loadProgress and statusBarMessage signals instead, + after API review. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate): + (QGraphicsWebView::setPage): + * Api/qgraphicswebview.h: + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::qgraphicswebview): + +2009-11-04 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] REGRESSION: Allow applications to use their own QWidget bypassing QWebView. + https://bugs.webkit.org/show_bug.cgi?id=30979 + + Decouple QWebViewPrivate from QWebPageClient, and automatically create + QWebPageWidgetClient whenever the view is QWidget based. + + * Api/qwebpage.cpp: + (QWebPageWidgetClient::QWebPageWidgetClient): + (QWebPageWidgetClient::scroll): + (QWebPageWidgetClient::update): + (QWebPageWidgetClient::setInputMethodEnabled): + (QWebPageWidgetClient::setInputMethodHint): + (QWebPageWidgetClient::cursor): + (QWebPageWidgetClient::updateCursor): + (QWebPageWidgetClient::palette): + (QWebPageWidgetClient::screenNumber): + (QWebPageWidgetClient::ownerWidget): + (QWebPageWidgetClient::pluginParent): + (QWebPage::setView): + * Api/qwebview.cpp: + (QWebView::~QWebView): + (QWebView::setPage): + (QWebView::event): + +2009-11-03 Andras Becsi <becsi.andras@stud.u-szeged.hu> + + Reviewed by Simon Hausmann. + + [Qt] Fix build of unit-test after r50454. + + * tests/qwebpage/tst_qwebpage.cpp: + +2009-11-03 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Make QWebPluginDatabase private API for now. + + https://bugs.webkit.org/show_bug.cgi?id=30775 + + * Api/headers.pri: + * Api/qwebplugindatabase.cpp: + * Api/qwebplugindatabase_p.h: Renamed from WebKit/qt/Api/qwebplugindatabase.h. + * Api/qwebsettings.cpp: + * Api/qwebsettings.h: + * QtLauncher/main.cpp: + (MainWindow::setupUI): + * tests/tests.pro: + +2009-11-03 Simon Hausmann <hausmann@webkit.org> + + Rubber-stamped by Tor Arne Vestbø. + + Oops, also remove the API docs of the removed networkRequestStarted() signal. + + * Api/qwebpage.cpp: + +2009-11-03 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Replace the QWebPage::networkRequestStarted() signal with the originatingObject + property set to the QWebFrame that belongs to the request. + + https://bugs.webkit.org/show_bug.cgi?id=29975 + + * Api/qwebpage.h: + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction): + (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction): + (WebCore::FrameLoaderClientQt::startDownload): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::loadFinished): + (TestNetworkManager::createRequest): + (tst_QWebPage::originatingObjectInNetworkRequests): + +2009-11-02 Jedrzej Nowacki <jedrzej.nowacki@nokia.com> + + Reviewed by Adam Barth. + + QWebView crash fix. + + The QWebView should not crash if the stop() method is called from + a function triggered by the loadProgress signal. + + A null pointer protection was added in the ProgressTracker::incrementProgress. + + New autotest was created. + + https://bugs.webkit.org/show_bug.cgi?id=29425 + + * tests/qwebview/tst_qwebview.cpp: + (WebViewCrashTest::WebViewCrashTest): + (WebViewCrashTest::loading): + (tst_QWebView::crashTests): + +2009-11-01 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Eric Seidel. + + Turn on warnings for QtWebKit for gcc + https://bugs.webkit.org/show_bug.cgi?id=30958 + + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): Reorder initialization list + to fix compiler warnings. + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::FrameLoaderClientQt): Ditto. + +2009-10-30 Evan Stade <estade@chromium.org> + + Reviewed by David Levin. + + Notify the chrome when the focused node has changed. + https://bugs.webkit.org/show_bug.cgi?id=30832 + + Added stub implementation for new ChromeClient function. + + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::focusedNodeChanged): + * WebCoreSupport/ChromeClientQt.h: + +2009-10-30 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by Tor Arne Vestbø. + + [Qt] Remove the QWebInspector::windowTitleChanged signal, + QEvent::WindowTitleChange can be used to achieve the same. + https://bugs.webkit.org/show_bug.cgi?id=30927 + + * Api/qwebinspector.cpp: + * Api/qwebinspector.h: + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientQt::updateWindowTitle): + +2009-10-29 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Tor Arne Vestbø. + + [Qt] Implement DELETE HTTP method for XmlHttpRequest + https://bugs.webkit.org/show_bug.cgi?id=30894 + + No new tests as this functionality is already tested by the + xmlhttprequest LayoutTests. As this patch depends on an unreleased + version of the dependent QtNetwork library and the tests will be + enabled later once the dependent library is released (and the + buildbot is updated). + + * Api/qwebframe.cpp: + (QWebFrame::load): + +2009-10-29 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Remove QWebView::guessUrlFromString() and replace its use + with the new QUrl::fromUserInput() if using Qt 4.6 or newer. + + * Api/qwebview.cpp: + * Api/qwebview.h: + * QGVLauncher/main.cpp: + (urlFromUserInput): + (WebPage::applyProxy): + (MainWindow::load): + * QtLauncher/main.cpp: + (urlFromUserInput): + (MainWindow::MainWindow): + (MainWindow::changeLocation): + * tests/qwebview/tst_qwebview.cpp: + +2009-10-28 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Tor Arne Vestbø. + + Serialize directly to the stream, and not first to an QByteArray, + that is later serialized. That is slower and also uses more bytes. + + * Api/qwebhistory.cpp: + (operator<<): + (operator>>): + 2009-10-28 Shinichiro Hamaji <hamaji@chromium.org> Reviewed by Eric Seidel. diff --git a/WebKit/qt/Plugins/ICOHandler.cpp b/WebKit/qt/Plugins/ICOHandler.cpp deleted file mode 100644 index d7fae07..0000000 --- a/WebKit/qt/Plugins/ICOHandler.cpp +++ /dev/null @@ -1,460 +0,0 @@ -/* - * kimgio import filter for MS Windows .ico files - * - * Distributed under the terms of the LGPL - * Copyright (c) 2000 Malte Starostik <malte@kde.org> - * - */ - -#include "config.h" -#include "ICOHandler.h" - -#include <cstring> -#include <cstdlib> -#include <algorithm> -#include <vector> - -#include <QtGui/QImage> -#include <QtGui/QBitmap> -#include <QtGui/QApplication> -#include <QtCore/QVector> -#include <QtGui/QDesktopWidget> - -namespace -{ - // Global header (see http://www.daubnet.com/formats/ICO.html) - struct IcoHeader - { - enum Type { Icon = 1, Cursor }; - quint16 reserved; - quint16 type; - quint16 count; - }; - - inline QDataStream& operator >>( QDataStream& s, IcoHeader& h ) - { - return s >> h.reserved >> h.type >> h.count; - } - - // Based on qt_read_dib et al. from qimage.cpp - // (c) 1992-2002 Nokia Corporation and/or its subsidiary(-ies). - struct BMP_INFOHDR - { - static const quint32 Size = 40; - quint32 biSize; // size of this struct - quint32 biWidth; // pixmap width - quint32 biHeight; // pixmap height - quint16 biPlanes; // should be 1 - quint16 biBitCount; // number of bits per pixel - enum Compression { RGB = 0 }; - quint32 biCompression; // compression method - quint32 biSizeImage; // size of image - quint32 biXPelsPerMeter; // horizontal resolution - quint32 biYPelsPerMeter; // vertical resolution - quint32 biClrUsed; // number of colors used - quint32 biClrImportant; // number of important colors - }; - const quint32 BMP_INFOHDR::Size; - - QDataStream& operator >>( QDataStream &s, BMP_INFOHDR &bi ) - { - s >> bi.biSize; - if ( bi.biSize == BMP_INFOHDR::Size ) - { - s >> bi.biWidth >> bi.biHeight >> bi.biPlanes >> bi.biBitCount; - s >> bi.biCompression >> bi.biSizeImage; - s >> bi.biXPelsPerMeter >> bi.biYPelsPerMeter; - s >> bi.biClrUsed >> bi.biClrImportant; - } - return s; - } - -#if 0 - QDataStream &operator<<( QDataStream &s, const BMP_INFOHDR &bi ) - { - s << bi.biSize; - s << bi.biWidth << bi.biHeight; - s << bi.biPlanes; - s << bi.biBitCount; - s << bi.biCompression; - s << bi.biSizeImage; - s << bi.biXPelsPerMeter << bi.biYPelsPerMeter; - s << bi.biClrUsed << bi.biClrImportant; - return s; - } -#endif - - // Header for every icon in the file - struct IconRec - { - unsigned char width; - unsigned char height; - quint16 colors; - quint16 hotspotX; - quint16 hotspotY; - quint32 size; - quint32 offset; - }; - - inline QDataStream& operator >>( QDataStream& s, IconRec& r ) - { - return s >> r.width >> r.height >> r.colors - >> r.hotspotX >> r.hotspotY >> r.size >> r.offset; - } - - struct LessDifference - { - LessDifference( unsigned s, unsigned c ) - : size( s ), colors( c ) {} - - bool operator ()( const IconRec& lhs, const IconRec& rhs ) const - { - // closest size match precedes everything else - if ( std::abs( int( lhs.width - size ) ) < - std::abs( int( rhs.width - size ) ) ) return true; - else if ( std::abs( int( lhs.width - size ) ) > - std::abs( int( rhs.width - size ) ) ) return false; - else if ( colors == 0 ) - { - // high/true color requested - if ( lhs.colors == 0 ) return true; - else if ( rhs.colors == 0 ) return false; - else return lhs.colors > rhs.colors; - } - else - { - // indexed icon requested - if ( lhs.colors == 0 && rhs.colors == 0 ) return false; - else if ( lhs.colors == 0 ) return false; - else return std::abs( int( lhs.colors - colors ) ) < - std::abs( int( rhs.colors - colors ) ); - } - } - unsigned size; - unsigned colors; - }; - - bool loadFromDIB( QDataStream& stream, const IconRec& rec, QImage& icon ) - { - BMP_INFOHDR header; - stream >> header; - if ( stream.atEnd() || header.biSize != BMP_INFOHDR::Size || - header.biSize > rec.size || - header.biCompression != BMP_INFOHDR::RGB || - ( header.biBitCount != 1 && header.biBitCount != 4 && - header.biBitCount != 8 && header.biBitCount != 24 && - header.biBitCount != 32 ) ) return false; - - unsigned paletteSize, paletteEntries; - - if (header.biBitCount > 8) - { - paletteEntries = 0; - paletteSize = 0; - } - else - { - paletteSize = (1 << header.biBitCount); - paletteEntries = paletteSize; - if (header.biClrUsed && header.biClrUsed < paletteSize) - paletteEntries = header.biClrUsed; - } - - // Always create a 32-bit image to get the mask right - // Note: this is safe as rec.width, rec.height are bytes - icon = QImage( rec.width, rec.height, QImage::Format_ARGB32 ); - if ( icon.isNull() ) return false; - - QVector< QRgb > colorTable( paletteSize ); - - colorTable.fill( QRgb( 0 ) ); - for ( unsigned i = 0; i < paletteEntries; ++i ) - { - unsigned char rgb[ 4 ]; - stream.readRawData( reinterpret_cast< char* >( &rgb ), - sizeof( rgb ) ); - colorTable[ i ] = qRgb( rgb[ 2 ], rgb[ 1 ], rgb[ 0 ] ); - } - - unsigned bpl = ( rec.width * header.biBitCount + 31 ) / 32 * 4; - - unsigned char* buf = new unsigned char[ bpl ]; - for ( unsigned y = rec.height; !stream.atEnd() && y--; ) - { - stream.readRawData( reinterpret_cast< char* >( buf ), bpl ); - unsigned char* pixel = buf; - QRgb* p = reinterpret_cast< QRgb* >( icon.scanLine( y ) ); - switch ( header.biBitCount ) - { - case 1: - for ( unsigned x = 0; x < rec.width; ++x ) - *p++ = colorTable[ - ( pixel[ x / 8 ] >> ( 7 - ( x & 0x07 ) ) ) & 1 ]; - break; - case 4: - for ( unsigned x = 0; x < rec.width; ++x ) - if ( x & 1 ) *p++ = colorTable[ pixel[ x / 2 ] & 0x0f ]; - else *p++ = colorTable[ pixel[ x / 2 ] >> 4 ]; - break; - case 8: - for ( unsigned x = 0; x < rec.width; ++x ) - *p++ = colorTable[ pixel[ x ] ]; - break; - case 24: - for ( unsigned x = 0; x < rec.width; ++x ) - *p++ = qRgb( pixel[ 3 * x + 2 ], - pixel[ 3 * x + 1 ], - pixel[ 3 * x ] ); - break; - case 32: - for ( unsigned x = 0; x < rec.width; ++x ) - *p++ = qRgba( pixel[ 4 * x + 2 ], - pixel[ 4 * x + 1 ], - pixel[ 4 * x ], - pixel[ 4 * x + 3] ); - break; - } - } - delete[] buf; - - if ( header.biBitCount < 32 ) - { - // Traditional 1-bit mask - bpl = ( rec.width + 31 ) / 32 * 4; - buf = new unsigned char[ bpl ]; - for ( unsigned y = rec.height; y--; ) - { - stream.readRawData( reinterpret_cast< char* >( buf ), bpl ); - QRgb* p = reinterpret_cast< QRgb* >( icon.scanLine( y ) ); - for ( unsigned x = 0; x < rec.width; ++x, ++p ) - if ( ( ( buf[ x / 8 ] >> ( 7 - ( x & 0x07 ) ) ) & 1 ) ) - *p &= RGB_MASK; - } - delete[] buf; - } - return true; - } -} - -ICOHandler::ICOHandler() -{ -} - -bool ICOHandler::canRead() const -{ - return canRead(device()); -} - -bool ICOHandler::read(QImage *outImage) -{ - - qint64 offset = device()->pos(); - - QDataStream stream( device() ); - stream.setByteOrder( QDataStream::LittleEndian ); - IcoHeader header; - stream >> header; - if ( stream.atEnd() || !header.count || - ( header.type != IcoHeader::Icon && header.type != IcoHeader::Cursor) ) - return false; - - unsigned requestedSize = 32; - unsigned requestedColors = QApplication::desktop()->depth() > 8 ? 0 : QApplication::desktop()->depth(); - int requestedIndex = -1; -#if 0 - if ( io->parameters() ) - { - QStringList params = QString(io->parameters()).split( ';', QString::SkipEmptyParts ); - QMap< QString, QString > options; - for ( QStringList::ConstIterator it = params.begin(); - it != params.end(); ++it ) - { - QStringList tmp = (*it).split( '=', QString::SkipEmptyParts ); - if ( tmp.count() == 2 ) options[ tmp[ 0 ] ] = tmp[ 1 ]; - } - if ( options[ "index" ].toUInt() ) - requestedIndex = options[ "index" ].toUInt(); - if ( options[ "size" ].toUInt() ) - requestedSize = options[ "size" ].toUInt(); - if ( options[ "colors" ].toUInt() ) - requestedColors = options[ "colors" ].toUInt(); - } -#endif - - typedef std::vector< IconRec > IconList; - IconList icons; - for ( unsigned i = 0; i < header.count; ++i ) - { - if ( stream.atEnd() ) - return false; - IconRec rec; - stream >> rec; - icons.push_back( rec ); - } - IconList::const_iterator selected; - if (requestedIndex >= 0) { - selected = std::min( icons.begin() + requestedIndex, icons.end() ); - } else { - selected = std::min_element( icons.begin(), icons.end(), - LessDifference( requestedSize, requestedColors ) ); - } - if ( stream.atEnd() || selected == icons.end() || - offset + selected->offset > device()->size() ) - return false; - - device()->seek( offset + selected->offset ); - QImage icon; - if ( loadFromDIB( stream, *selected, icon ) ) - { -#ifndef QT_NO_IMAGE_TEXT - icon.setText( "X-Index", 0, QString::number( selected - icons.begin() ) ); - if ( header.type == IcoHeader::Cursor ) - { - icon.setText( "X-HotspotX", 0, QString::number( selected->hotspotX ) ); - icon.setText( "X-HotspotY", 0, QString::number( selected->hotspotY ) ); - } -#endif - *outImage = icon; - return true; - } - return false; -} - -bool ICOHandler::write(const QImage &/*image*/) -{ -#if 0 - if (image.isNull()) - return; - - QByteArray dibData; - QDataStream dib(dibData, QIODevice::ReadWrite); - dib.setByteOrder(QDataStream::LittleEndian); - - QImage pixels = image; - QImage mask; - if (io->image().hasAlphaBuffer()) - mask = image.createAlphaMask(); - else - mask = image.createHeuristicMask(); - mask.invertPixels(); - for ( int y = 0; y < pixels.height(); ++y ) - for ( int x = 0; x < pixels.width(); ++x ) - if ( mask.pixel( x, y ) == 0 ) pixels.setPixel( x, y, 0 ); - - if (!qt_write_dib(dib, pixels)) - return; - - uint hdrPos = dib.device()->at(); - if (!qt_write_dib(dib, mask)) - return; - memmove(dibData.data() + hdrPos, dibData.data() + hdrPos + BMP_WIN + 8, dibData.size() - hdrPos - BMP_WIN - 8); - dibData.resize(dibData.size() - BMP_WIN - 8); - - QDataStream ico(device()); - ico.setByteOrder(QDataStream::LittleEndian); - IcoHeader hdr; - hdr.reserved = 0; - hdr.type = Icon; - hdr.count = 1; - ico << hdr.reserved << hdr.type << hdr.count; - IconRec rec; - rec.width = image.width(); - rec.height = image.height(); - if (image.numColors() <= 16) - rec.colors = 16; - else if (image.depth() <= 8) - rec.colors = 256; - else - rec.colors = 0; - rec.hotspotX = 0; - rec.hotspotY = 0; - rec.dibSize = dibData.size(); - ico << rec.width << rec.height << rec.colors - << rec.hotspotX << rec.hotspotY << rec.dibSize; - rec.dibOffset = ico.device()->at() + sizeof(rec.dibOffset); - ico << rec.dibOffset; - - BMP_INFOHDR dibHeader; - dib.device()->at(0); - dib >> dibHeader; - dibHeader.biHeight = image.height() << 1; - dib.device()->at(0); - dib << dibHeader; - - ico.writeRawBytes(dibData.data(), dibData.size()); - return true; -#endif - return false; -} - -QByteArray ICOHandler::name() const -{ - return "ico"; -} - -bool ICOHandler::canRead(QIODevice *device) -{ - if (!device) { - qWarning("ICOHandler::canRead() called with no device"); - return false; - } - - const qint64 oldPos = device->pos(); - - char head[8]; - qint64 readBytes = device->read(head, sizeof(head)); - const bool readOk = readBytes == sizeof(head); - - if (device->isSequential()) { - while (readBytes > 0) - device->ungetChar(head[readBytes-- - 1]); - } else { - device->seek(oldPos); - } - - if ( !readOk ) - return false; - - return head[2] == '\001' && head[3] == '\000' && // type should be 1 - ( head[6] == 16 || head[6] == 32 || head[6] == 64 ) && // width can only be one of those - ( head[7] == 16 || head[7] == 32 || head[7] == 64 ); // same for height -} - -class ICOPlugin : public QImageIOPlugin -{ -public: - QStringList keys() const; - Capabilities capabilities(QIODevice *device, const QByteArray &format) const; - QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const; -}; - -QStringList ICOPlugin::keys() const -{ - return QStringList() << "ico" << "ICO"; -} - -QImageIOPlugin::Capabilities ICOPlugin::capabilities(QIODevice *device, const QByteArray &format) const -{ - if (format == "ico" || format == "ICO") - return Capabilities(CanRead); - if (!format.isEmpty()) - return 0; - if (!device->isOpen()) - return 0; - - Capabilities cap; - if (device->isReadable() && ICOHandler::canRead(device)) - cap |= CanRead; - return cap; -} - -QImageIOHandler *ICOPlugin::create(QIODevice *device, const QByteArray &format) const -{ - QImageIOHandler *handler = new ICOHandler; - handler->setDevice(device); - handler->setFormat(format); - return handler; -} - -Q_EXPORT_STATIC_PLUGIN(ICOPlugin) -Q_EXPORT_PLUGIN2(qtwebico, ICOPlugin) diff --git a/WebKit/qt/Plugins/ICOHandler.h b/WebKit/qt/Plugins/ICOHandler.h deleted file mode 100644 index 4f1f1d6..0000000 --- a/WebKit/qt/Plugins/ICOHandler.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * ico.h - kimgio import filter for MS Windows .ico files - * - * Distributed under the terms of the LGPL - * Copyright (c) 2000 Malte Starostik <malte@kde.org> - * - */ - -// You can use QImageIO::setParameters() to request a specific -// Icon out of an .ico file: -// -// Options consist of a name=value pair and are separated by a semicolon. -// Available options are: -// size=<size> select the icon that most closely matches <size> (pixels) -// default: 32 -// colors=<num> select the icon that has <num> colors (or comes closest) -// default: 1 << display depth or 0 (RGB) if display depth > 8 -// index=<index> select the indexth icon from the file. If this option -// is present, the size and colors options will be ignored. -// default: none -// If both size and colors are given, size takes precedence. -// -// The old format is still supported: -// the parameters consist of a single string in the form -// "<size>[:<colors>]" which correspond to the options above -// -// If an icon was returned (i.e. the file is valid and the index option -// if present was not out of range), the icon's index within the .ico -// file is returned in the text tag "X-Index" of the image. -// If the icon is in fact a cursor, its hotspot coordinates are returned -// in the text tags "X-HotspotX" and "X-HotspotY". - -#ifndef _ICOHANDLER_H_ -#define _ICOHANDLER_H_ - -#include <QtGui/QImageIOPlugin> - -class ICOHandler : public QImageIOHandler -{ -public: - ICOHandler(); - - bool canRead() const; - bool read(QImage *image); - bool write(const QImage &image); - - QByteArray name() const; - - static bool canRead(QIODevice *device); -}; - -#endif diff --git a/WebKit/qt/Plugins/Plugins.pro b/WebKit/qt/Plugins/Plugins.pro deleted file mode 100644 index a9b4f82..0000000 --- a/WebKit/qt/Plugins/Plugins.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = lib -TARGET = qtwebico -CONFIG += plugin -HEADERS += ICOHandler.h -SOURCES += ICOHandler.cpp - -include(../../WebKit.pri) - -contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols -unix:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions - -target.path = $$[QT_INSTALL_PLUGINS]/imageformats -INSTALLS += target - diff --git a/WebKit/qt/QGVLauncher/main.cpp b/WebKit/qt/QGVLauncher/main.cpp index 3632a33..2021cb6 100644 --- a/WebKit/qt/QGVLauncher/main.cpp +++ b/WebKit/qt/QGVLauncher/main.cpp @@ -50,6 +50,20 @@ #include <qwebsettings.h> #include <qwebview.h> +static QUrl urlFromUserInput(const QString& string) +{ + QString input(string); + QFileInfo fi(input); + if (fi.exists() && fi.isRelative()) + input = fi.absoluteFilePath(); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + return QUrl::fromUserInput(input); +#else + return QUrl(input); +#endif +} + class WebView : public QGraphicsWebView { Q_OBJECT Q_PROPERTY(qreal yRotation READ yRotation WRITE setYRotation) @@ -93,7 +107,7 @@ public: private: void applyProxy() { - QUrl proxyUrl = QWebView::guessUrlFromString(qgetenv("http_proxy")); + QUrl proxyUrl = urlFromUserInput(qgetenv("http_proxy")); if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) { int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080; @@ -278,7 +292,7 @@ public: void load(const QString& url) { - QUrl deducedUrl = guessUrlFromString(url); + QUrl deducedUrl = urlFromUserInput(url); if (!deducedUrl.isValid()) deducedUrl = QUrl("http://" + url + "/"); @@ -287,16 +301,6 @@ public: scene->webView()->setFocus(Qt::OtherFocusReason); } - QUrl guessUrlFromString(const QString& string) - { - QString input(string); - QFileInfo fi(input); - if (fi.exists() && fi.isRelative()) - input = fi.absoluteFilePath(); - - return QWebView::guessUrlFromString(input); - } - QWebPage* page() const { return scene->webView()->page(); diff --git a/WebKit/qt/QtLauncher/main.cpp b/WebKit/qt/QtLauncher/main.cpp index e3c6116..2286712 100644 --- a/WebKit/qt/QtLauncher/main.cpp +++ b/WebKit/qt/QtLauncher/main.cpp @@ -30,18 +30,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <qwebpage.h> -#include <qwebview.h> -#include <qwebframe.h> -#include <qwebsettings.h> -#include <qwebplugindatabase.h> -#include <qwebelement.h> -#include <qwebinspector.h> - #include <QtGui> -#include <QDebug> #include <QtNetwork/QNetworkProxy> -#if QT_VERSION >= 0x040400 && !defined(QT_NO_PRINTER) +#include <QtNetwork/QNetworkRequest> +#if !defined(QT_NO_PRINTER) #include <QPrintPreviewDialog> #endif @@ -49,17 +41,78 @@ #include <QtUiTools/QUiLoader> #endif -#include <QVector> -#include <QTextStream> +#include <QDebug> #include <QFile> +#include <QTextStream> +#include <QVector> + #include <cstdio> +#include <qwebelement.h> +#include <qwebframe.h> +#include <qwebinspector.h> +#include <qwebpage.h> +#include <qwebsettings.h> +#include <qwebview.h> + #ifndef NDEBUG void QWEBKIT_EXPORT qt_drt_garbageCollector_collect(); #endif -class WebPage : public QWebPage +static QUrl urlFromUserInput(const QString& input) { +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + return QUrl::fromUserInput(input); +#else + return QUrl(input); +#endif +} + +class WebView : public QWebView { + Q_OBJECT +public: + WebView(QWidget* parent) : QWebView(parent) {} + +protected: + virtual void contextMenuEvent(QContextMenuEvent* event) + { + QMenu* menu = page()->createStandardContextMenu(); + + QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos()); + + if (!r.linkUrl().isEmpty()) { + QAction* newTabAction = menu->addAction(tr("Open in Default &Browser"), this, SLOT(openUrlInDefaultBrowser())); + newTabAction->setData(r.linkUrl()); + menu->insertAction(menu->actions().at(2), newTabAction); + } + + menu->exec(mapToGlobal(event->pos())); + delete menu; + } + + virtual void mousePressEvent(QMouseEvent* event) + { + mouseButtons = event->buttons(); + keyboardModifiers = event->modifiers(); + + QWebView::mousePressEvent(event); + } + +public slots: + void openUrlInDefaultBrowser(const QUrl &url = QUrl()) + { + if (QAction* action = qobject_cast<QAction*>(sender())) + QDesktopServices::openUrl(action->data().toUrl()); + else + QDesktopServices::openUrl(url); + } + +public: + Qt::MouseButtons mouseButtons; + Qt::KeyboardModifiers keyboardModifiers; +}; + +class WebPage : public QWebPage { public: WebPage(QWidget *parent) : QWebPage(parent) {} @@ -72,13 +125,49 @@ public: return false; } virtual bool extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output); + + + virtual bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type) + { + WebView* webView = static_cast<WebView*>(view()); + if (webView->keyboardModifiers & Qt::ShiftModifier) { + QWebPage* page = createWindow(QWebPage::WebBrowserWindow); + page->mainFrame()->load(request); + return false; + } + if (webView->keyboardModifiers & Qt::AltModifier) { + webView->openUrlInDefaultBrowser(request.url()); + return false; + } + + return QWebPage::acceptNavigationRequest(frame, request, type); + } }; -class MainWindow : public QMainWindow -{ +class WebInspector : public QWebInspector { Q_OBJECT public: - MainWindow(QString url = QString()): currentZoom(100) { + WebInspector(QWidget* parent) : QWebInspector(parent) {} +signals: + void visibleChanged(bool nowVisible); +protected: + void showEvent(QShowEvent* event) + { + QWebInspector::showEvent(event); + emit visibleChanged(true); + } + void hideEvent(QHideEvent* event) + { + QWebInspector::hideEvent(event); + emit visibleChanged(false); + } +}; + +class MainWindow : public QMainWindow { + Q_OBJECT +public: + MainWindow(QString url = QString()): currentZoom(100) + { setAttribute(Qt::WA_DeleteOnClose); if (qgetenv("QTLAUNCHER_USE_ARGB_VISUALS").toInt() == 1) setAttribute(Qt::WA_TranslucentBackground); @@ -86,7 +175,7 @@ public: QSplitter* splitter = new QSplitter(Qt::Vertical, this); setCentralWidget(splitter); - view = new QWebView(splitter); + view = new WebView(splitter); WebPage* page = new WebPage(view); view->setPage(page); connect(view, SIGNAL(loadFinished(bool)), @@ -97,16 +186,16 @@ public: this, SLOT(showLinkHover(const QString&, const QString&))); connect(view->page(), SIGNAL(windowCloseRequested()), this, SLOT(close())); - inspector = new QWebInspector(splitter); + inspector = new WebInspector(splitter); inspector->setPage(page); inspector->hide(); connect(this, SIGNAL(destroyed()), inspector, SLOT(deleteLater())); - connect(page, SIGNAL(webInspectorTriggered(const QWebElement&)), inspector, SLOT(show())); setupUI(); // set the proxy to the http_proxy env variable - if present - QUrl proxyUrl = view->guessUrlFromString(qgetenv("http_proxy")); + QUrl proxyUrl = urlFromUserInput(qgetenv("http_proxy")); + if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) { int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080; page->networkAccessManager()->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyPort)); @@ -116,11 +205,12 @@ public: if (fi.exists() && fi.isRelative()) url = fi.absoluteFilePath(); - QUrl qurl = view->guessUrlFromString(url); + QUrl qurl = urlFromUserInput(url); + if (qurl.scheme().isEmpty()) + qurl = QUrl("http://" + url + "/"); if (qurl.isValid()) { urlEdit->setText(qurl.toEncoded()); view->load(qurl); - } // the zoom values are chosen to be like in Mozilla Firefox 3 @@ -129,27 +219,33 @@ public: zoomLevels << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300; } - QWebPage* webPage() const { + QWebPage* webPage() const + { return view->page(); } - QWebView* webView() const { + QWebView* webView() const + { return view; } protected slots: - void changeLocation() { + void changeLocation() + { QString string = urlEdit->text(); - QUrl url = view->guessUrlFromString(string); - if (!url.isValid()) + QUrl url = urlFromUserInput(string); + if (url.scheme().isEmpty()) url = QUrl("http://" + string + "/"); - urlEdit->setText(url.toEncoded()); - view->load(url); - view->setFocus(Qt::OtherFocusReason); + if (url.isValid()) { + urlEdit->setText(url.toEncoded()); + view->load(url); + view->setFocus(Qt::OtherFocusReason); + } } - void loadFinished() { + void loadFinished() + { urlEdit->setText(view->url().toString()); QUrl::FormattingOptions opts; @@ -166,7 +262,8 @@ protected slots: urlModel.setStringList(urlList); } - void showLinkHover(const QString &link, const QString &toolTip) { + void showLinkHover(const QString &link, const QString &toolTip) + { statusBar()->showMessage(link); #ifndef QT_NO_TOOLTIP if (!toolTip.isEmpty()) @@ -174,22 +271,24 @@ protected slots: #endif } - void zoomIn() { + void zoomIn() + { int i = zoomLevels.indexOf(currentZoom); Q_ASSERT(i >= 0); if (i < zoomLevels.count() - 1) currentZoom = zoomLevels[i + 1]; - view->setZoomFactor(qreal(currentZoom)/100.0); + view->setZoomFactor(qreal(currentZoom) / 100.0); } - void zoomOut() { + void zoomOut() + { int i = zoomLevels.indexOf(currentZoom); Q_ASSERT(i >= 0); if (i > 0) currentZoom = zoomLevels[i - 1]; - view->setZoomFactor(qreal(currentZoom)/100.0); + view->setZoomFactor(qreal(currentZoom) / 100.0); } void resetZoom() @@ -203,8 +302,9 @@ protected slots: view->page()->settings()->setAttribute(QWebSettings::ZoomTextOnly, b); } - void print() { -#if QT_VERSION >= 0x040400 && !defined(QT_NO_PRINTER) + void print() + { +#if !defined(QT_NO_PRINTER) QPrintPreviewDialog dlg(this); connect(&dlg, SIGNAL(paintRequested(QPrinter *)), view, SLOT(print(QPrinter *))); @@ -228,11 +328,13 @@ protected slots: } } - void setEditable(bool on) { + void setEditable(bool on) + { view->page()->setContentEditable(on); formatMenuAction->setVisible(on); } + /* void dumpPlugins() { QList<QWebPluginInfo> plugins = QWebSettings::pluginDatabase()->plugins(); foreach (const QWebPluginInfo plugin, plugins) { @@ -242,12 +344,15 @@ protected slots: } } } + */ - void dumpHtml() { + void dumpHtml() + { qDebug() << "HTML: " << view->page()->mainFrame()->toHtml(); } - void selectElements() { + void selectElements() + { bool ok; QString str = QInputDialog::getText(this, "Select elements", "Choose elements", QLineEdit::Normal, "a", &ok); @@ -262,8 +367,9 @@ protected slots: public slots: - void newWindow(const QString &url = QString()) { - MainWindow *mw = new MainWindow(url); + void newWindow(const QString &url = QString()) + { + MainWindow* mw = new MainWindow(url); mw->show(); } @@ -273,7 +379,8 @@ private: int currentZoom; // create the status bar, tool bar & menu - void setupUI() { + void setupUI() + { progress = new QProgressBar(this); progress->setRange(0, 100); progress->setMinimumSize(100, 20); @@ -289,26 +396,24 @@ private: urlEdit->setSizePolicy(QSizePolicy::Expanding, urlEdit->sizePolicy().verticalPolicy()); connect(urlEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); - QCompleter *completer = new QCompleter(this); + QCompleter* completer = new QCompleter(this); urlEdit->setCompleter(completer); completer->setModel(&urlModel); - QToolBar *bar = addToolBar("Navigation"); + QToolBar* bar = addToolBar("Navigation"); bar->addAction(view->pageAction(QWebPage::Back)); bar->addAction(view->pageAction(QWebPage::Forward)); bar->addAction(view->pageAction(QWebPage::Reload)); bar->addAction(view->pageAction(QWebPage::Stop)); bar->addWidget(urlEdit); - QMenu *fileMenu = menuBar()->addMenu("&File"); - QAction *newWindow = fileMenu->addAction("New Window", this, SLOT(newWindow())); -#if QT_VERSION >= 0x040400 + QMenu* fileMenu = menuBar()->addMenu("&File"); + QAction* newWindow = fileMenu->addAction("New Window", this, SLOT(newWindow())); fileMenu->addAction(tr("Print"), this, SLOT(print()), QKeySequence::Print); -#endif QAction* screenshot = fileMenu->addAction("Screenshot", this, SLOT(screenshot())); fileMenu->addAction("Close", this, SLOT(close())); - QMenu *editMenu = menuBar()->addMenu("&Edit"); + QMenu* editMenu = menuBar()->addMenu("&Edit"); editMenu->addAction(view->pageAction(QWebPage::Undo)); editMenu->addAction(view->pageAction(QWebPage::Redo)); editMenu->addSeparator(); @@ -316,30 +421,30 @@ private: editMenu->addAction(view->pageAction(QWebPage::Copy)); editMenu->addAction(view->pageAction(QWebPage::Paste)); editMenu->addSeparator(); - QAction *setEditable = editMenu->addAction("Set Editable", this, SLOT(setEditable(bool))); + QAction* setEditable = editMenu->addAction("Set Editable", this, SLOT(setEditable(bool))); setEditable->setCheckable(true); - QMenu *viewMenu = menuBar()->addMenu("&View"); + QMenu* viewMenu = menuBar()->addMenu("&View"); viewMenu->addAction(view->pageAction(QWebPage::Stop)); viewMenu->addAction(view->pageAction(QWebPage::Reload)); viewMenu->addSeparator(); - QAction *zoomIn = viewMenu->addAction("Zoom &In", this, SLOT(zoomIn())); - QAction *zoomOut = viewMenu->addAction("Zoom &Out", this, SLOT(zoomOut())); - QAction *resetZoom = viewMenu->addAction("Reset Zoom", this, SLOT(resetZoom())); - QAction *zoomTextOnly = viewMenu->addAction("Zoom Text Only", this, SLOT(toggleZoomTextOnly(bool))); + QAction* zoomIn = viewMenu->addAction("Zoom &In", this, SLOT(zoomIn())); + QAction* zoomOut = viewMenu->addAction("Zoom &Out", this, SLOT(zoomOut())); + QAction* resetZoom = viewMenu->addAction("Reset Zoom", this, SLOT(resetZoom())); + QAction* zoomTextOnly = viewMenu->addAction("Zoom Text Only", this, SLOT(toggleZoomTextOnly(bool))); zoomTextOnly->setCheckable(true); zoomTextOnly->setChecked(false); viewMenu->addSeparator(); viewMenu->addAction("Dump HTML", this, SLOT(dumpHtml())); - viewMenu->addAction("Dump plugins", this, SLOT(dumpPlugins())); + //viewMenu->addAction("Dump plugins", this, SLOT(dumpPlugins())); - QMenu *formatMenu = new QMenu("F&ormat", this); + QMenu* formatMenu = new QMenu("F&ormat", this); formatMenuAction = menuBar()->addMenu(formatMenu); formatMenuAction->setVisible(false); formatMenu->addAction(view->pageAction(QWebPage::ToggleBold)); formatMenu->addAction(view->pageAction(QWebPage::ToggleItalic)); formatMenu->addAction(view->pageAction(QWebPage::ToggleUnderline)); - QMenu *writingMenu = formatMenu->addMenu(tr("Writing Direction")); + QMenu* writingMenu = formatMenu->addMenu(tr("Writing Direction")); writingMenu->addAction(view->pageAction(QWebPage::SetTextDirectionDefault)); writingMenu->addAction(view->pageAction(QWebPage::SetTextDirectionLeftToRight)); writingMenu->addAction(view->pageAction(QWebPage::SetTextDirectionRightToLeft)); @@ -362,17 +467,21 @@ private: view->pageAction(QWebPage::ToggleItalic)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_I)); view->pageAction(QWebPage::ToggleUnderline)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U)); - QMenu *toolsMenu = menuBar()->addMenu("&Tools"); + QMenu* toolsMenu = menuBar()->addMenu("&Tools"); toolsMenu->addAction("Select elements...", this, SLOT(selectElements())); + QAction* showInspectorAction = toolsMenu->addAction("Show inspector", inspector, SLOT(setVisible(bool))); + showInspectorAction->setCheckable(true); + showInspectorAction->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("F12"))); + showInspectorAction->connect(inspector, SIGNAL(visibleChanged(bool)), SLOT(setChecked(bool))); } - QWebView *view; - QLineEdit *urlEdit; - QProgressBar *progress; - QWebInspector* inspector; + QWebView* view; + QLineEdit* urlEdit; + QProgressBar* progress; + WebInspector* inspector; - QAction *formatMenuAction; + QAction* formatMenuAction; QStringList urlList; QStringListModel urlModel; @@ -389,14 +498,14 @@ bool WebPage::extension(Extension extension, const ExtensionOption *option, Exte return true; } -QWebPage *WebPage::createWindow(QWebPage::WebWindowType) +QWebPage* WebPage::createWindow(QWebPage::WebWindowType) { - MainWindow *mw = new MainWindow; + MainWindow* mw = new MainWindow; mw->show(); return mw->webPage(); } -QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) +QObject* WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) { Q_UNUSED(url); Q_UNUSED(paramNames); @@ -410,8 +519,7 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS #endif } -class URLLoader : public QObject -{ +class URLLoader : public QObject { Q_OBJECT public: URLLoader(QWebView* view, const QString& inputFileName) @@ -492,14 +600,12 @@ int launcherMain(const QApplication& app) int main(int argc, char **argv) { QApplication app(argc, argv); - QString url = QString("%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html")); + QString defaultUrl = QString("file://%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html")); QWebSettings::setMaximumPagesInCache(4); app.setApplicationName("QtLauncher"); -#if QT_VERSION >= 0x040400 app.setApplicationVersion("0.1"); -#endif QWebSettings::setObjectCacheCapacities((16*1024*1024) / 8, (16*1024*1024) / 8, 16*1024*1024); @@ -521,21 +627,28 @@ int main(int argc, char **argv) exit(0); } MainWindow* window = new MainWindow; - QWebView *view = window->webView(); + QWebView* view = window->webView(); URLLoader loader(view, listFile); QObject::connect(view, SIGNAL(loadFinished(bool)), &loader, SLOT(loadNext())); loader.loadNext(); window->show(); launcherMain(app); } else { - if (args.count() > 1) - url = args.at(1); - - MainWindow* window = new MainWindow(url); + MainWindow* window = 0; + + // Look though the args for something we can open + for (int i = 1; i < args.count(); i++) { + if (!args.at(i).startsWith("-")) { + if (!window) + window = new MainWindow(args.at(i)); + else + window->newWindow(args.at(i)); + } + } - // Opens every given urls in new windows - for (int i = 2; i < args.count(); i++) - window->newWindow(args.at(i)); + // If not, just open the default URL + if (!window) + window = new MainWindow(defaultUrl); window->show(); launcherMain(app); diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index 26cf6f6..eb7ac9a 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -141,6 +141,11 @@ void ChromeClientQt::takeFocus(FocusDirection) } +void ChromeClientQt::focusedNodeChanged(WebCore::Node*) +{ +} + + Page* ChromeClientQt::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features) { QWebPage *newPage = m_webPage->createWindow(features.dialog ? QWebPage::WebModalDialog : QWebPage::WebBrowserWindow); diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h index 196c4fc..939fe04 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h @@ -63,6 +63,8 @@ namespace WebCore { virtual bool canTakeFocus(FocusDirection); virtual void takeFocus(FocusDirection); + virtual void focusedNodeChanged(Node*); + virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&); virtual void show(); diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp index 34241f0..3091a43 100644 --- a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp @@ -407,28 +407,38 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event) case VK_LEFT: if (kevent->shiftKey()) frame->editor()->command("MoveLeftAndModifySelection").execute(); - else frame->editor()->command("MoveLeft").execute(); + else + frame->editor()->command("MoveLeft").execute(); break; case VK_RIGHT: if (kevent->shiftKey()) frame->editor()->command("MoveRightAndModifySelection").execute(); - else frame->editor()->command("MoveRight").execute(); + else + frame->editor()->command("MoveRight").execute(); break; case VK_UP: if (kevent->shiftKey()) frame->editor()->command("MoveUpAndModifySelection").execute(); - else frame->editor()->command("MoveUp").execute(); + else + frame->editor()->command("MoveUp").execute(); break; case VK_DOWN: if (kevent->shiftKey()) frame->editor()->command("MoveDownAndModifySelection").execute(); - else frame->editor()->command("MoveDown").execute(); + else + frame->editor()->command("MoveDown").execute(); break; case VK_PRIOR: // PageUp - frame->editor()->command("MovePageUp").execute(); + if (kevent->shiftKey()) + frame->editor()->command("MovePageUpAndModifySelection").execute(); + else + frame->editor()->command("MovePageUp").execute(); break; case VK_NEXT: // PageDown - frame->editor()->command("MovePageDown").execute(); + if (kevent->shiftKey()) + frame->editor()->command("MovePageDownAndModifySelection").execute(); + else + frame->editor()->command("MovePageDown").execute(); break; case VK_TAB: return; diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index 8749ada..3c30ab5 100644 --- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -1,9 +1,10 @@ /* * Copyright (C) 2006 Zack Rusin <zack@kde.org> * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) * Copyright (C) 2008 Collabora Ltd. All rights reserved. * Coypright (C) 2008 Holger Hans Peter Freyther + * Coypright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in> * * All rights reserved. * @@ -53,8 +54,9 @@ #include "QNetworkReplyHandler.h" #include "ResourceHandleInternal.h" #include "ResourceHandle.h" -#include "Settings.h" +#include "ScriptController.h" #include "ScriptString.h" +#include "Settings.h" #include "QWebPageClient.h" #include "qwebpage.h" @@ -68,14 +70,10 @@ #include <QCoreApplication> #include <QDebug> -#if QT_VERSION >= 0x040400 #include <QGraphicsScene> #include <QGraphicsWidget> #include <QNetworkRequest> #include <QNetworkReply> -#else -#include "qwebnetworkinterface_p.h" -#endif #include "qwebhistory_p.h" static bool dumpFrameLoaderCallbacks = false; @@ -145,9 +143,9 @@ namespace WebCore FrameLoaderClientQt::FrameLoaderClientQt() : m_frame(0) , m_webFrame(0) + , m_firstData(false) , m_pluginView(0) , m_hasSentResponseToPlugin(false) - , m_firstData(false) , m_loadError (ResourceError()) { } @@ -176,8 +174,8 @@ void FrameLoaderClientQt::setFrame(QWebFrame* webFrame, Frame* frame) m_webFrame->page(), SIGNAL(loadFinished(bool))); connect(this, SIGNAL(loadFinished(bool)), m_webFrame, SIGNAL(loadFinished(bool))); - connect(this, SIGNAL(titleChanged(const QString&)), - m_webFrame, SIGNAL(titleChanged(const QString&))); + connect(this, SIGNAL(titleChanged(QString)), + m_webFrame, SIGNAL(titleChanged(QString))); } QWebFrame* FrameLoaderClientQt::webFrame() const @@ -307,6 +305,29 @@ void FrameLoaderClientQt::dispatchDidChangeLocationWithinPage() m_webFrame->page()->d->updateNavigationActions(); } +void FrameLoaderClientQt::dispatchDidPushStateWithinPage() +{ + if (dumpFrameLoaderCallbacks) + printf("%s - dispatchDidPushStateWithinPage\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); + + notImplemented(); +} + +void FrameLoaderClientQt::dispatchDidReplaceStateWithinPage() +{ + if (dumpFrameLoaderCallbacks) + printf("%s - dispatchDidReplaceStateWithinPage\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); + + notImplemented(); +} + +void FrameLoaderClientQt::dispatchDidPopStateWithinPage() +{ + if (dumpFrameLoaderCallbacks) + printf("%s - dispatchDidPopStateWithinPage\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); + + notImplemented(); +} void FrameLoaderClientQt::dispatchWillClose() { @@ -600,8 +621,11 @@ bool FrameLoaderClientQt::canHandleRequest(const WebCore::ResourceRequest&) cons return true; } -void FrameLoaderClientQt::windowObjectCleared() +void FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) { + if (world != mainThreadNormalWorld()) + return; + if (dumpFrameLoaderCallbacks) printf("%s - didClearWindowObjectForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame))); @@ -789,7 +813,6 @@ WTF::PassRefPtr<WebCore::DocumentLoader> FrameLoaderClientQt::createDocumentLoad void FrameLoaderClientQt::download(WebCore::ResourceHandle* handle, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&) { -#if QT_VERSION >= 0x040400 if (!m_webFrame) return; @@ -802,7 +825,6 @@ void FrameLoaderClientQt::download(WebCore::ResourceHandle* handle, const WebCor else reply->abort(); } -#endif } void FrameLoaderClientQt::assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest& request) @@ -955,11 +977,7 @@ void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction fu void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState>, const WebCore::String&) { Q_ASSERT(m_webFrame); -#if QT_VERSION < 0x040400 - QWebNetworkRequest r(request); -#else - QNetworkRequest r(request.toNetworkRequest()); -#endif + QNetworkRequest r(request.toNetworkRequest(m_webFrame)); QWebPage* page = m_webFrame->page(); if (!page->d->acceptNavigationRequest(0, r, QWebPage::NavigationType(action.type()))) { @@ -980,11 +998,7 @@ void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunc void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState>) { Q_ASSERT(m_webFrame); -#if QT_VERSION < 0x040400 - QWebNetworkRequest r(request); -#else - QNetworkRequest r(request.toNetworkRequest()); -#endif + QNetworkRequest r(request.toNetworkRequest(m_webFrame)); QWebPage*page = m_webFrame->page(); if (!page->d->acceptNavigationRequest(m_webFrame, r, QWebPage::NavigationType(action.type()))) { @@ -1009,12 +1023,10 @@ void FrameLoaderClientQt::dispatchUnableToImplementPolicy(const WebCore::Resourc void FrameLoaderClientQt::startDownload(const WebCore::ResourceRequest& request) { -#if QT_VERSION >= 0x040400 if (!m_webFrame) return; - emit m_webFrame->page()->downloadRequested(request.toNetworkRequest()); -#endif + emit m_webFrame->page()->downloadRequested(request.toNetworkRequest(m_webFrame)); } PassRefPtr<Frame> FrameLoaderClientQt::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, @@ -1131,9 +1143,25 @@ public: QRegion clipRegion = QRegion(clipRect); platformWidget()->setMask(clipRegion); + handleVisibility(); + } + + virtual void show() + { + Widget::show(); + handleVisibility(); + } + +private: + void handleVisibility() + { + if (!isVisible()) + return; + // if setMask is set with an empty QRegion, no clipping will // be performed, so in that case we hide the platformWidget - platformWidget()->setVisible(!clipRegion.isEmpty()); + QRegion mask = platformWidget()->mask(); + platformWidget()->setVisible(!mask.isEmpty()); } }; @@ -1234,23 +1262,21 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, #endif // QT_NO_STYLE_STYLESHEET } -#if QT_VERSION >= 0x040400 if (!object) { QWebPluginFactory* factory = m_webFrame->page()->pluginFactory(); if (factory) object = factory->create(mimeType, qurl, params, values); } -#endif if (object) { QWidget* widget = qobject_cast<QWidget*>(object); if (widget) { - QWidget* parentWidget; + QWidget* parentWidget = 0; if (m_webFrame->page()->d->client) parentWidget = qobject_cast<QWidget*>(m_webFrame->page()->d->client->pluginParent()); - else - parentWidget = 0; // The plug-in won't be fully functional because the QWebView doesn't exist. - widget->setParent(parentWidget); + if (parentWidget) // don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. + widget->setParent(parentWidget); + widget->hide(); RefPtr<QtPluginWidget> w = adoptRef(new QtPluginWidget()); w->setPlatformWidget(widget); // Make sure it's invisible until properly placed into the layout @@ -1260,13 +1286,12 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, #if QT_VERSION >= 0x040600 QGraphicsWidget* graphicsWidget = qobject_cast<QGraphicsWidget*>(object); if (graphicsWidget) { - QGraphicsObject* parentWidget; + QGraphicsObject* parentWidget = 0; if (m_webFrame->page()->d->client) parentWidget = qobject_cast<QGraphicsObject*>(m_webFrame->page()->d->client->pluginParent()); - else - parentWidget = 0; // The plug-in won't be fully functional because the QWebView doesn't exist. graphicsWidget->hide(); - graphicsWidget->setParentItem(parentWidget); + if (parentWidget) // don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. + graphicsWidget->setParentItem(parentWidget); RefPtr<QtPluginGraphicsWidget> w = QtPluginGraphicsWidget::create(graphicsWidget); // Make sure it's invisible until properly placed into the layout w->setFrameRect(IntRect(0, 0, 0, 0)); @@ -1276,8 +1301,23 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, // FIXME: make things work for widgetless plugins as well delete object; } else { // NPAPI Plugins + Vector<String> params = paramNames; + Vector<String> values = paramValues; + if (mimeType == "application/x-shockwave-flash") { + QWebPageClient* client = m_webFrame->page()->d->client; + if (!client || !qobject_cast<QWidget*>(client->pluginParent())) { + // inject wmode=opaque when there is no client or the client is not a QWebView + size_t wmodeIndex = params.find("wmode"); + if (wmodeIndex == -1) { + params.append("wmode"); + values.append("opaque"); + } else + values[wmodeIndex] = "opaque"; + } + } + RefPtr<PluginView> pluginView = PluginView::create(m_frame, pluginSize, element, url, - paramNames, paramValues, mimeType, loadManually); + params, values, mimeType, loadManually); return pluginView; } diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h index fe7590d..32b9caa 100644 --- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h +++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h @@ -103,6 +103,9 @@ namespace WebCore { virtual void dispatchDidCancelClientRedirect(); virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate); virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchDidPushStateWithinPage(); + virtual void dispatchDidReplaceStateWithinPage(); + virtual void dispatchDidPopStateWithinPage(); virtual void dispatchWillClose(); virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); @@ -199,7 +202,7 @@ namespace WebCore { virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType); virtual String overrideMediaType() const; - virtual void windowObjectCleared(); + virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*); virtual void documentElementAvailable(); virtual void didPerformFirstNavigation() const; diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp index 12f405c..d5683c4 100644 --- a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp @@ -50,8 +50,8 @@ namespace WebCore { static const QLatin1String settingStoragePrefix("Qt/QtWebKit/QWebInspector/"); static const QLatin1String settingStorageTypeSuffix(".type"); -static InspectorController::Setting variantToSetting(const QVariant& qvariant); -static QVariant settingToVariant(const InspectorController::Setting& icSetting); +static String variantToSetting(const QVariant& qvariant); +static QVariant settingToVariant(const String& value); class InspectorClientWebPage : public QWebPage { Q_OBJECT @@ -113,16 +113,11 @@ void InspectorClientQt::showWindow() updateWindowTitle(); m_inspectedWebPage->d->inspectorController()->setWindowVisible(true, true); - // We don't allow the inspector to ask for widget visibility itself because showWindow is - // not always called when we want. - // Inspecting an element or calling QWebInspector::show() should already have made the - // widget visible. } void InspectorClientQt::closeWindow() { - if (m_inspectedWebPage->d->inspector) - m_inspectedWebPage->d->inspector->close(); + m_inspectedWebPage->d->inspectorController()->setWindowVisible(false); } void InspectorClientQt::attachWindow() @@ -166,11 +161,10 @@ void InspectorClientQt::updateWindowTitle() if (m_inspectedWebPage->d->inspector) { QString caption = QCoreApplication::translate("QWebPage", "Web Inspector - %2").arg(m_inspectedURL); m_inspectedWebPage->d->inspector->setWindowTitle(caption); - emit m_inspectedWebPage->d->inspector->windowTitleChanged(caption); } } -void InspectorClientQt::populateSetting(const String& key, InspectorController::Setting& setting) +void InspectorClientQt::populateSetting(const String& key, String* setting) { QSettings qsettings; if (qsettings.status() == QSettings::AccessError) { @@ -184,10 +178,10 @@ void InspectorClientQt::populateSetting(const String& key, InspectorController:: QString storedValueType = qsettings.value(settingKey + settingStorageTypeSuffix).toString(); QVariant storedValue = qsettings.value(settingKey); storedValue.convert(QVariant::nameToType(storedValueType.toAscii().data())); - setting = variantToSetting(storedValue); + *setting = variantToSetting(storedValue); } -void InspectorClientQt::storeSetting(const String& key, const InspectorController::Setting& setting) +void InspectorClientQt::storeSetting(const String& key, const String& setting) { QSettings qsettings; if (qsettings.status() == QSettings::AccessError) { @@ -202,70 +196,24 @@ void InspectorClientQt::storeSetting(const String& key, const InspectorControlle qsettings.setValue(settingKey + settingStorageTypeSuffix, QVariant::typeToName(valueToStore.type())); } -void InspectorClientQt::removeSetting(const String&) +static String variantToSetting(const QVariant& qvariant) { - notImplemented(); -} - -static InspectorController::Setting variantToSetting(const QVariant& qvariant) -{ - InspectorController::Setting retVal; + String retVal; switch (qvariant.type()) { case QVariant::Bool: - retVal.set(qvariant.toBool()); - break; - case QVariant::Double: - retVal.set(qvariant.toDouble()); - break; - case QVariant::Int: - retVal.set((long)qvariant.toInt()); - break; + retVal = qvariant.toBool() ? "true" : "false"; case QVariant::String: - retVal.set(qvariant.toString()); - break; - case QVariant::StringList: { - QStringList qsList = qvariant.toStringList(); - int listCount = qsList.count(); - Vector<String> vector(listCount); - for (int i = 0; i < listCount; ++i) - vector[i] = qsList[i]; - retVal.set(vector); - break; - } + retVal = qvariant.toString(); } return retVal; } -static QVariant settingToVariant(const InspectorController::Setting& icSetting) +static QVariant settingToVariant(const String& setting) { QVariant retVal; - - switch (icSetting.type()) { - case InspectorController::Setting::StringType: - retVal.setValue(static_cast<QString>(icSetting.string())); - break; - case InspectorController::Setting::StringVectorType: { - const Vector<String>& vector = icSetting.stringVector(); - Vector<String>::const_iterator iter; - QStringList qsList; - for (iter = vector.begin(); iter != vector.end(); ++iter) - qsList << *iter; - retVal.setValue(qsList); - break; - } - case InspectorController::Setting::DoubleType: - retVal.setValue(icSetting.doubleValue()); - break; - case InspectorController::Setting::IntegerType: - retVal.setValue((int)icSetting.integerValue()); - break; - case InspectorController::Setting::BooleanType: - retVal.setValue(icSetting.booleanValue()); - break; - } - + retVal.setValue(static_cast<QString>(setting)); return retVal; } diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.h b/WebKit/qt/WebCoreSupport/InspectorClientQt.h index ccf8b69..923bab4 100644 --- a/WebKit/qt/WebCoreSupport/InspectorClientQt.h +++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.h @@ -66,9 +66,8 @@ namespace WebCore { virtual void hideHighlight(); virtual void inspectedURLChanged(const String& newURL); - virtual void populateSetting(const String& key, InspectorController::Setting&); - virtual void storeSetting(const String& key, const InspectorController::Setting&); - virtual void removeSetting(const String& key); + virtual void populateSetting(const String& key, String* value); + virtual void storeSetting(const String& key, const String& value); virtual void inspectorWindowObjectCleared(); diff --git a/WebKit/qt/docs/docs.pri b/WebKit/qt/docs/docs.pri index 4a8c165..804817b 100644 --- a/WebKit/qt/docs/docs.pri +++ b/WebKit/qt/docs/docs.pri @@ -1,9 +1,9 @@ include(../../../WebKit.pri) unix { - QDOC = SRCDIR=$$PWD/../../.. OUTPUT_DIR=$$OUTPUT_DIR $$(QTDIR)/tools/qdoc3/qdoc3 + QDOC = SRCDIR=$$PWD/../../.. OUTPUT_DIR=$$OUTPUT_DIR $$(QTDIR)/bin/qdoc3 } else { - QDOC = $$(QTDIR)\tools\qdoc3\release\qdoc3.exe + QDOC = $$(QTDIR)\bin\qdoc3.exe } unix { diff --git a/WebKit/qt/docs/qtwebkit.qdoc b/WebKit/qt/docs/qtwebkit.qdoc index 09dfae5..411762a 100644 --- a/WebKit/qt/docs/qtwebkit.qdoc +++ b/WebKit/qt/docs/qtwebkit.qdoc @@ -25,13 +25,10 @@ Qt Commercial Edition licensees that wish to distribute applications that use the QtWebKit module need to be aware of their obligations under the - GNU Lesser General Public License (LGPL). + GNU Library General Public License (LGPL). Developers using the Open Source Edition can choose to redistribute - the module under the appropriate version of the GNU LGPL; version 2.1 - for applications and libraries licensed under the GNU GPL version 2, - or version 3 for applications and libraries licensed under the GNU - GPL version 2. + the module under the appropriate version of the GNU LGPL. \legalese WebKit is licensed under the GNU Library General Public License. diff --git a/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp b/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp index 0ba1cad..a6b6620 100644 --- a/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp +++ b/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp @@ -10,7 +10,7 @@ void wrapInFunction() QWebInspector *inspector = new QWebInspector; inspector->setPage(page); - connect(page, SIGNAL(webInspectorTriggered(const QWebElement&)), inspector, SLOT(show())); + connect(page, SIGNAL(webInspectorTriggered(QWebElement)), inspector, SLOT(show())); //! [0] } diff --git a/WebKit/qt/docs/webkitsnippets/webelement/main.cpp b/WebKit/qt/docs/webkitsnippets/webelement/main.cpp index d437a6f..2707ffb 100644 --- a/WebKit/qt/docs/webkitsnippets/webelement/main.cpp +++ b/WebKit/qt/docs/webkitsnippets/webelement/main.cpp @@ -22,7 +22,6 @@ #include <qwebview.h> #include <qwebframe.h> #include <qwebelement.h> -#include <qdebug.h> static QWebFrame *frame; @@ -53,9 +52,10 @@ static void findAll() </p> */ +//! [FindAll intro] QList<QWebElement> allSpans = document.findAll("span"); QList<QWebElement> introSpans = document.findAll("p.intro span"); -//! [FindAll] +//! [FindAll intro] //! [FindAll] } int main(int argc, char *argv[]) diff --git a/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro b/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro index f9b403b..8ca4b59 100644 --- a/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro +++ b/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro @@ -1,5 +1,8 @@ TEMPLATE = app CONFIG -= app_bundle +CONFIG(QTDIR_build) { + QT += webkit +} SOURCES = main.cpp include(../../../../../WebKit.pri) QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR diff --git a/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp index 4bdb7f5..657e09f 100644 --- a/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp +++ b/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp @@ -17,36 +17,13 @@ Boston, MA 02110-1301, USA. */ +#include "../util.h" #include <QtTest/QtTest> - #include <QGraphicsView> #include <qgraphicswebview.h> #include <qwebpage.h> #include <qwebframe.h> -/** - * Starts an event loop that runs until the given signal is received. - * Optionally the event loop - * can return earlier on a timeout. - * - * \return \p true if the requested signal was received - * \p false on timeout - */ -static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) -{ - QEventLoop loop; - QObject::connect(obj, signal, &loop, SLOT(quit())); - QTimer timer; - QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); - if (timeout > 0) { - QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - timer.setSingleShot(true); - timer.start(timeout); - } - loop.exec(); - return timeoutSpy.isEmpty(); -} - class tst_QGraphicsWebView : public QObject { Q_OBJECT @@ -63,21 +40,17 @@ void tst_QGraphicsWebView::qgraphicswebview() item.title(); item.icon(); item.zoomFactor(); - item.isInteractive(); - item.progress(); - item.toHtml(); item.history(); item.settings(); - item.status(); item.page(); item.setPage(0); item.page(); item.setUrl(QUrl()); item.setZoomFactor(0); - item.setInteractive(true); item.load(QUrl()); item.setHtml(QString()); item.setContent(QByteArray()); + item.isModified(); } class WebPage : public QWebPage @@ -117,7 +90,7 @@ void tst_QGraphicsWebView::crashOnViewlessWebPages() view.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); view.resize(600, 480); webView->resize(view.geometry().size()); - QTest::qWait(200); + QCoreApplication::processEvents(); view.show(); page->mainFrame()->setHtml(QString("data:text/html," @@ -126,7 +99,7 @@ void tst_QGraphicsWebView::crashOnViewlessWebPages() "<frame src=\"data:text/html,bar\">" "</frameset>")); - QVERIFY(::waitForSignal(page, SIGNAL(loadFinished(bool)))); + QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); } QTEST_MAIN(tst_QGraphicsWebView) diff --git a/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp index cf83fe8..e9dae18 100644 --- a/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp +++ b/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp @@ -68,9 +68,12 @@ private slots: void simpleCollection(); void attributes(); void attributesNS(); + void listAttributes(); void classes(); void namespaceURI(); void iteration(); + void nonConstIterator(); + void constIterator(); void foreachManipulation(); void emptyCollection(); void appendCollection(); @@ -185,6 +188,29 @@ void tst_QWebElement::attributesNS() QCOMPARE(svg.attributeNS("http://www.w3.org/2000/svg", "foobar", "defaultblah"), QString("true")); } +void tst_QWebElement::listAttributes() +{ + QString content = "<html xmlns=\"http://www.w3.org/1999/xhtml\" " + "xmlns:svg=\"http://www.w3.org/2000/svg\">" + "<body><svg:svg foo=\"\" svg:bar=\"\">" + "</svg:svg></body></html>"; + + m_mainFrame->setContent(content.toUtf8(), "application/xhtml+xml"); + + QWebElement svg = m_mainFrame->findFirstElement("svg"); + QVERIFY(!svg.isNull()); + + QVERIFY(svg.attributeNames().contains("foo")); + QVERIFY(svg.attributeNames("http://www.w3.org/2000/svg").contains("bar")); + + svg.setAttributeNS("http://www.w3.org/2000/svg", "svg:foobar", "true"); + QVERIFY(svg.attributeNames().contains("foo")); + QStringList attributes = svg.attributeNames("http://www.w3.org/2000/svg"); + QCOMPARE(attributes.size(), 2); + QVERIFY(attributes.contains("bar")); + QVERIFY(attributes.contains("foobar")); +} + void tst_QWebElement::classes() { m_mainFrame->setHtml("<body><p class=\"a b c d a c\">Test"); @@ -305,6 +331,37 @@ void tst_QWebElement::iteration() QCOMPARE(paras.at(1), paras.last()); } +void tst_QWebElement::nonConstIterator() +{ + QString html = "<body><p>first para</p><p>second para</p></body>"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + QWebElementCollection paras = body.findAll("p"); + + QWebElementCollection::iterator it = paras.begin(); + QCOMPARE(*it, paras.at(0)); + ++it; + (*it).encloseWith("<div>"); + QCOMPARE(*it, paras.at(1)); + ++it; + QCOMPARE(it, paras.end()); +} + +void tst_QWebElement::constIterator() +{ + QString html = "<body><p>first para</p><p>second para</p></body>"; + m_mainFrame->setHtml(html); + QWebElement body = m_mainFrame->documentElement(); + const QWebElementCollection paras = body.findAll("p"); + + QWebElementCollection::const_iterator it = paras.begin(); + QCOMPARE(*it, paras.at(0)); + ++it; + QCOMPARE(*it, paras.at(1)); + ++it; + QCOMPARE(it, paras.end()); +} + void tst_QWebElement::foreachManipulation() { QString html = "<body><p>first para</p><p>second para</p></body>"; @@ -938,7 +995,10 @@ void tst_QWebElement::render() QImage testImage(resource.width(), resource.height(), QImage::Format_ARGB32); QPainter painter0(&testImage); painter0.fillRect(imageRect, Qt::white); - painter0.drawImage(0, 0, resource); + // render() uses pixmaps internally, and pixmaps might have bit depths + // other than 32, giving different pixel values due to rounding. + QPixmap pix = QPixmap::fromImage(resource); + painter0.drawPixmap(0, 0, pix); painter0.end(); QImage image1(resource.width(), resource.height(), QImage::Format_ARGB32); diff --git a/WebKit/qt/tests/qwebframe/qwebframe.pro b/WebKit/qt/tests/qwebframe/qwebframe.pro index 0e540e5..b8734cd 100644 --- a/WebKit/qt/tests/qwebframe/qwebframe.pro +++ b/WebKit/qt/tests/qwebframe/qwebframe.pro @@ -5,7 +5,7 @@ SOURCES += tst_qwebframe.cpp RESOURCES += qwebframe.qrc QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -DEFINES += SRCDIR=\\\"$$PWD/resources\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD/resources\\\" symbian { TARGET.UID3 = 0xA000E53D diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index 7cc62b0..7c13fd0 100644 --- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -38,35 +38,9 @@ #endif #include "../util.h" -//TESTED_CLASS= -//TESTED_FILES= - -// Task 160192 -/** - * Starts an event loop that runs until the given signal is received. - Optionally the event loop - * can return earlier on a timeout. - * - * \return \p true if the requested signal was received - * \p false on timeout - */ -static bool waitForSignal(QObject* obj, const char* signal, int timeout = 0) -{ - QEventLoop loop; - QObject::connect(obj, signal, &loop, SLOT(quit())); - QTimer timer; - QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); - if (timeout > 0) { - QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - timer.setSingleShot(true); - timer.start(timeout); - } - loop.exec(); - return timeoutSpy.isEmpty(); -} - -/* Mostly a test for the JavaScript related parts of QWebFrame */ - +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif struct CustomType { QString string; @@ -600,6 +574,7 @@ private slots: void render(); void scrollPosition(); void evaluateWillCauseRepaint(); + void qObjectWrapperWithSameIdentity(); private: QString evalJS(const QString&s) { @@ -2238,7 +2213,7 @@ protected: virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest& request, QIODevice* outgoingData) { QString url = request.url().toString(); - if (op == QNetworkAccessManager::GetOperation) + if (op == QNetworkAccessManager::GetOperation) { if (url == "qrc:/test1.html" || url == "http://abcdef.abcdef/") return new FakeReply(request, this); #ifndef QT_NO_OPENSSL @@ -2249,6 +2224,7 @@ protected: return reply; } #endif + } return QNetworkAccessManager::createRequest(op, request, outgoingData); } @@ -2265,19 +2241,19 @@ void tst_QWebFrame::requestedUrl() page.setNetworkAccessManager(networkManager); frame->setUrl(QUrl("qrc:/test1.html")); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.count(), 1); QCOMPARE(frame->requestedUrl(), QUrl("qrc:/test1.html")); QCOMPARE(frame->url(), QUrl("qrc:/test2.html")); frame->setUrl(QUrl("qrc:/non-existent.html")); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.count(), 2); QCOMPARE(frame->requestedUrl(), QUrl("qrc:/non-existent.html")); QCOMPARE(frame->url(), QUrl("qrc:/non-existent.html")); frame->setUrl(QUrl("http://abcdef.abcdef")); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.count(), 3); QCOMPARE(frame->requestedUrl(), QUrl("http://abcdef.abcdef/")); QCOMPARE(frame->url(), QUrl("http://abcdef.abcdef/")); @@ -2286,9 +2262,9 @@ void tst_QWebFrame::requestedUrl() qRegisterMetaType<QList<QSslError> >("QList<QSslError>"); qRegisterMetaType<QNetworkReply* >("QNetworkReply*"); - QSignalSpy spy2(page.networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&))); + QSignalSpy spy2(page.networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>))); frame->setUrl(QUrl("qrc:/fake-ssl-error.html")); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy2.count(), 1); QCOMPARE(frame->requestedUrl(), QUrl("qrc:/fake-ssl-error.html")); QCOMPARE(frame->url(), QUrl("qrc:/fake-ssl-error.html")); @@ -2346,7 +2322,7 @@ void tst_QWebFrame::setHtmlWithResource() // in few seconds, the image should be completey loaded QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); frame->setHtml(html); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.count(), 1); QCOMPARE(frame->evaluateJavaScript("document.images.length").toInt(), 1); @@ -2365,7 +2341,7 @@ void tst_QWebFrame::setHtmlWithResource() // in few seconds, the CSS should be completey loaded frame->setHtml(html2); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.size(), 2); QWebElement p = frame->documentElement().findAll("p").at(0); @@ -2383,7 +2359,7 @@ void tst_QWebFrame::setHtmlWithBaseURL() QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); frame->setHtml(html, QUrl::fromLocalFile(QDir::currentPath())); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(spy.count(), 1); QCOMPARE(frame->evaluateJavaScript("document.images.length").toInt(), 1); @@ -2494,15 +2470,15 @@ void tst_QWebFrame::popupFocus() combo->hidePopup(); QTRY_VERIFY(view.hasFocus() && !combo->view()->hasFocus()); // Focus should be back on the WebView - // triple the flashing time, should at least blink twice already - int delay = qApp->cursorFlashTime() * 3; + // double the flashing time, should at least blink once already + int delay = qApp->cursorFlashTime() * 2; // focus the lineedit and check if it blinks QTest::mouseClick(&view, Qt::LeftButton, 0, QPoint(200, 25)); m_popupTestView = &view; view.installEventFilter( this ); QTest::qWait(delay); - QVERIFY2(m_popupTestPaintCount >= 4, + QVERIFY2(m_popupTestPaintCount >= 3, "The input field should have a blinking caret"); } @@ -2646,7 +2622,7 @@ void tst_QWebFrame::hasSetFocus() QSignalSpy loadSpy(m_page, SIGNAL(loadFinished(bool))); m_page->mainFrame()->setHtml(html); - QTest::qWait(200); + waitForSignal(m_page->mainFrame(), SIGNAL(loadFinished(bool)), 200); QCOMPARE(loadSpy.size(), 1); QList<QWebFrame*> children = m_page->mainFrame()->childFrames(); @@ -2656,7 +2632,7 @@ void tst_QWebFrame::hasSetFocus() "</body></html>"); frame->setHtml(innerHtml); - QTest::qWait(200); + waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); QCOMPARE(loadSpy.size(), 2); m_page->mainFrame()->setFocus(); @@ -2743,16 +2719,51 @@ void tst_QWebFrame::evaluateWillCauseRepaint() view.setHtml(html); view.show(); - QTest::qWait(200); + QTest::qWaitForWindowShown(&view); view.page()->mainFrame()->evaluateJavaScript( "document.getElementById('junk').style.display = 'none';"); - ::waitForSignal(view.page(), SIGNAL(repaintRequested( const QRect &))); - - QTest::qWait(2000); + ::waitForSignal(view.page(), SIGNAL(repaintRequested(QRect))); } +class TestFactory : public QObject +{ + Q_OBJECT +public: + TestFactory() + : obj(0), counter(0) + {} + + Q_INVOKABLE QObject* getNewObject() + { + delete obj; + obj = new QObject(this); + obj->setObjectName(QLatin1String("test") + QString::number(++counter)); + return obj; + + } + + QObject* obj; + int counter; +}; + +void tst_QWebFrame::qObjectWrapperWithSameIdentity() +{ + m_view->setHtml("<script>function triggerBug() { document.getElementById('span1').innerText = test.getNewObject().objectName; }</script>" + "<body><span id='span1'>test</span></body>"); + + QWebFrame* mainFrame = m_view->page()->mainFrame(); + QCOMPARE(mainFrame->toPlainText(), QString("test")); + + mainFrame->addToJavaScriptWindowObject("test", new TestFactory, QScriptEngine::ScriptOwnership); + + mainFrame->evaluateJavaScript("triggerBug();"); + QCOMPARE(mainFrame->toPlainText(), QString("test1")); + + mainFrame->evaluateJavaScript("triggerBug();"); + QCOMPARE(mainFrame->toPlainText(), QString("test2")); +} QTEST_MAIN(tst_QWebFrame) #include "tst_qwebframe.moc" diff --git a/WebKit/qt/tests/qwebinspector/qwebinspector.pro b/WebKit/qt/tests/qwebinspector/qwebinspector.pro new file mode 100644 index 0000000..520887e --- /dev/null +++ b/WebKit/qt/tests/qwebinspector/qwebinspector.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = tst_qwebinspector +include(../../../../WebKit.pri) +SOURCES += tst_qwebinspector.cpp +QT += testlib network +QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR diff --git a/WebKit/qt/tests/qwebinspector/tst_qwebinspector.cpp b/WebKit/qt/tests/qwebinspector/tst_qwebinspector.cpp new file mode 100644 index 0000000..12cd630 --- /dev/null +++ b/WebKit/qt/tests/qwebinspector/tst_qwebinspector.cpp @@ -0,0 +1,68 @@ +/* + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <QtTest/QtTest> + +#include <qdir.h> +#include <qwebinspector.h> +#include <qwebpage.h> +#include <qwebsettings.h> + +class tst_QWebInspector : public QObject { + Q_OBJECT + +private slots: + void attachAndDestroy(); +}; + +void tst_QWebInspector::attachAndDestroy() +{ + { // External inspector + manual destruction of page first + QWebPage* page = new QWebPage(); + page->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); + QWebInspector* inspector = new QWebInspector(); + inspector->setPage(page); + page->updatePositionDependentActions(QPoint(0, 0)); + page->triggerAction(QWebPage::InspectElement); + + delete page; + delete inspector; + } + { // External inspector + manual destruction of inspector first + QWebPage* page = new QWebPage(); + page->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); + QWebInspector* inspector = new QWebInspector(); + inspector->setPage(page); + page->updatePositionDependentActions(QPoint(0, 0)); + page->triggerAction(QWebPage::InspectElement); + + delete inspector; + delete page; + } + { // Internal inspector + QWebPage page; + page.settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); + page.updatePositionDependentActions(QPoint(0, 0)); + page.triggerAction(QWebPage::InspectElement); + } +} + +QTEST_MAIN(tst_QWebInspector) + +#include "tst_qwebinspector.moc" diff --git a/WebKit/qt/tests/qwebpage/qwebpage.pro b/WebKit/qt/tests/qwebpage/qwebpage.pro index 6b28efd..7853b28 100644 --- a/WebKit/qt/tests/qwebpage/qwebpage.pro +++ b/WebKit/qt/tests/qwebpage/qwebpage.pro @@ -5,7 +5,7 @@ SOURCES += tst_qwebpage.cpp RESOURCES += tst_qwebpage.qrc QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -DEFINES += SRCDIR=\\\"$$PWD/\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD/\\\" symbian { TARGET.UID3 = 0xA000E53E diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 0cf85ee..2a52631 100644 --- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -21,6 +21,9 @@ #include <QtTest/QtTest> +#include <qgraphicsscene.h> +#include <qgraphicsview.h> +#include <qgraphicswebview.h> #include <qwebelement.h> #include <qwebpage.h> #include <qwidget.h> @@ -37,6 +40,10 @@ #include <QPushButton> #include <QDir> +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + // Will try to wait for the condition while allowing event processing #define QTRY_COMPARE(__expr, __expected) \ do { \ @@ -78,6 +85,22 @@ static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) return timeoutSpy.isEmpty(); } +class EventSpy : public QObject, public QList<QEvent::Type> +{ + Q_OBJECT +public: + EventSpy(QObject* objectToSpy) + { + objectToSpy->installEventFilter(this); + } + + virtual bool eventFilter(QObject* receiver, QEvent* event) + { + append(event->type()); + return false; + } +}; + class tst_QWebPage : public QObject { Q_OBJECT @@ -120,15 +143,20 @@ private slots: void testOptionalJSObjects(); void testEnablePersistentStorage(); void consoleOutput(); + void inputMethods_data(); void inputMethods(); void defaultTextEncoding(); void errorPageExtension(); + void errorPageExtensionInIFrames(); + void errorPageExtensionInFrameset(); void crashTests_LazyInitializationOfMainFrame(); void screenshot_data(); void screenshot(); + void originatingObjectInNetworkRequests(); + private: QWebView* m_view; QWebPage* m_page; @@ -234,7 +262,6 @@ void tst_QWebPage::loadFinished() { qRegisterMetaType<QWebFrame*>("QWebFrame*"); qRegisterMetaType<QNetworkRequest*>("QNetworkRequest*"); - QSignalSpy spyNetworkRequestStarted(m_page, SIGNAL(networkRequestStarted(QWebFrame*, QNetworkRequest*))); QSignalSpy spyLoadStarted(m_view, SIGNAL(loadStarted())); QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); @@ -245,7 +272,6 @@ void tst_QWebPage::loadFinished() QTest::qWait(3000); - QVERIFY(spyNetworkRequestStarted.count() > 1); QVERIFY(spyLoadStarted.count() > 1); QVERIFY(spyLoadFinished.count() > 1); @@ -346,9 +372,11 @@ public: TestNetworkManager(QObject* parent) : QNetworkAccessManager(parent) {} QList<QUrl> requestedUrls; + QList<QNetworkRequest> requests; protected: virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest &request, QIODevice* outgoingData) { + requests.append(request); requestedUrls.append(request.url()); return QNetworkAccessManager::createRequest(op, request, outgoingData); } @@ -422,7 +450,7 @@ void tst_QWebPage::modified() m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is fourth page")); QVERIFY(m_page->history()->count() == 2); m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is fifth page")); - QVERIFY(::waitForSignal(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*, QWebHistoryItem*)))); + QVERIFY(::waitForSignal(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*,QWebHistoryItem*)))); } void tst_QWebPage::contextMenuCrash() @@ -450,7 +478,6 @@ void tst_QWebPage::database() QVERIFY(QWebSettings::offlineStorageDefaultQuota() == 1024 * 1024); m_page->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); - m_page->settings()->setAttribute(QWebSettings::SessionStorageEnabled, true); m_page->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); QString dbFileName = path + "Databases.db"; @@ -459,7 +486,7 @@ void tst_QWebPage::database() QFile::remove(dbFileName); qRegisterMetaType<QWebFrame*>("QWebFrame*"); - QSignalSpy spy(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame *, QString))); + QSignalSpy spy(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString))); m_view->setHtml(QString("<html><head><script>var db; db=openDatabase('testdb', '1.0', 'test database API', 50000); </script></head><body><div></div></body></html>"), QUrl("http://www.myexample.com")); QTRY_COMPARE(spy.count(), 1); m_page->mainFrame()->evaluateJavaScript("var db2; db2=openDatabase('testdb', '1.0', 'test database API', 50000);"); @@ -637,20 +664,41 @@ class PluginCounterPage : public QWebPage { public: int m_count; QPointer<QObject> m_widget; - PluginCounterPage(QObject* parent = 0) : QWebPage(parent), m_count(0), m_widget(0) + QObject* m_pluginParent; + PluginCounterPage(QObject* parent = 0) + : QWebPage(parent) + , m_count(0) + , m_widget(0) + , m_pluginParent(0) { settings()->setAttribute(QWebSettings::PluginsEnabled, true); } + ~PluginCounterPage() + { + if (m_pluginParent) + m_pluginParent->deleteLater(); + } }; template<class T> class PluginTracerPage : public PluginCounterPage { public: - PluginTracerPage(QObject* parent = 0) : PluginCounterPage(parent) {} + PluginTracerPage(QObject* parent = 0) + : PluginCounterPage(parent) + { + // this is a dummy parent object for the created plugin + m_pluginParent = new T; + } virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) { m_count++; - return m_widget = new T(); + m_widget = new T; + // need a cast to the specific type, as QObject::setParent cannot be called, + // because it is not virtual. Instead it is necesary to call QWidget::setParent, + // 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; } }; @@ -716,6 +764,8 @@ void tst_QWebPage::createViewlessPlugin() page->mainFrame()->setHtml(content); QCOMPARE(page->m_count, 1); QVERIFY(page->m_widget); + QVERIFY(page->m_pluginParent); + QVERIFY(page->m_widget->parent() == page->m_pluginParent); delete page; } @@ -1262,28 +1312,101 @@ void tst_QWebPage::frameAt() frameAtHelper(webPage, webPage->mainFrame(), webPage->mainFrame()->pos()); } +void tst_QWebPage::inputMethods_data() +{ + QTest::addColumn<QString>("viewType"); + QTest::newRow("QWebView") << "QWebView"; +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + QTest::newRow("QGraphicsWebView") << "QGraphicsWebView"; +#endif +} + +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) +static Qt::InputMethodHints inputMethodHints(QObject* object) +{ + if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object)) + return o->inputMethodHints(); + if (QWidget* w = qobject_cast<QWidget*>(object)) + return w->inputMethodHints(); + return Qt::InputMethodHints(); +} +#endif + +static bool inputMethodEnabled(QObject* object) +{ +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object)) + return o->flags() & QGraphicsItem::ItemAcceptsInputMethod; +#endif + if (QWidget* w = qobject_cast<QWidget*>(object)) + return w->testAttribute(Qt::WA_InputMethodEnabled); + return false; +} + void tst_QWebPage::inputMethods() { - m_view->page()->mainFrame()->setHtml("<html><body>" \ + QFETCH(QString, viewType); + QWebPage* page = new QWebPage; + QObject* view = 0; + QObject* container = 0; + if (viewType == "QWebView") { + QWebView* wv = new QWebView; + wv->setPage(page); + view = wv; + container = view; + } +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + else if (viewType == "QGraphicsWebView") { + QGraphicsWebView* wv = new QGraphicsWebView; + wv->setPage(page); + view = wv; + + QGraphicsView* gv = new QGraphicsView; + QGraphicsScene* scene = new QGraphicsScene(gv); + gv->setScene(scene); + scene->addItem(wv); + wv->setGeometry(QRect(0, 0, 500, 500)); + + container = gv; + } +#endif + else + QVERIFY2(false, "Unknown view type"); + + page->mainFrame()->setHtml("<html><body>" \ "<input type='text' id='input1' style='font-family: serif' value='' maxlength='20'/><br>" \ "<input type='password'/>" \ "</body></html>"); - m_view->page()->mainFrame()->setFocus(); + page->mainFrame()->setFocus(); + + EventSpy viewEventSpy(container); - QWebElementCollection inputs = m_view->page()->mainFrame()->documentElement().findAll("input"); + QWebElementCollection inputs = page->mainFrame()->documentElement().findAll("input"); QMouseEvent evpres(QEvent::MouseButtonPress, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evpres); + page->event(&evpres); QMouseEvent evrel(QEvent::MouseButtonRelease, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evrel); + page->event(&evrel); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); +#endif + viewEventSpy.clear(); + + page->event(&evpres); + page->event(&evrel); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + QVERIFY(viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); +#endif //ImMicroFocus - QVariant variant = m_view->page()->inputMethodQuery(Qt::ImMicroFocus); + QVariant variant = page->inputMethodQuery(Qt::ImMicroFocus); QRect focusRect = variant.toRect(); QVERIFY(inputs.at(0).geometry().contains(variant.toRect().topLeft())); //ImFont - variant = m_view->page()->inputMethodQuery(Qt::ImFont); + variant = page->inputMethodQuery(Qt::ImFont); QFont font = variant.value<QFont>(); QCOMPARE(QString("-webkit-serif"), font.family()); @@ -1292,45 +1415,45 @@ void tst_QWebPage::inputMethods() //Insert text. { QInputMethodEvent eventText("QtWebKit", inputAttributes); - QSignalSpy signalSpy(m_view->page(), SIGNAL(microFocusChanged())); - m_view->page()->event(&eventText); + QSignalSpy signalSpy(page, SIGNAL(microFocusChanged())); + page->event(&eventText); QCOMPARE(signalSpy.count(), 0); } { QInputMethodEvent eventText("", inputAttributes); eventText.setCommitString(QString("QtWebKit"), 0, 0); - m_view->page()->event(&eventText); + page->event(&eventText); } #if QT_VERSION >= 0x040600 //ImMaximumTextLength - variant = m_view->page()->inputMethodQuery(Qt::ImMaximumTextLength); + variant = page->inputMethodQuery(Qt::ImMaximumTextLength); QCOMPARE(20, variant.toInt()); //Set selection inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 3, 2, QVariant()); QInputMethodEvent eventSelection("",inputAttributes); - m_view->page()->event(&eventSelection); + page->event(&eventSelection); //ImAnchorPosition - variant = m_view->page()->inputMethodQuery(Qt::ImAnchorPosition); + variant = page->inputMethodQuery(Qt::ImAnchorPosition); int anchorPosition = variant.toInt(); QCOMPARE(anchorPosition, 3); //ImCursorPosition - variant = m_view->page()->inputMethodQuery(Qt::ImCursorPosition); + variant = page->inputMethodQuery(Qt::ImCursorPosition); int cursorPosition = variant.toInt(); QCOMPARE(cursorPosition, 5); //ImCurrentSelection - variant = m_view->page()->inputMethodQuery(Qt::ImCurrentSelection); + variant = page->inputMethodQuery(Qt::ImCurrentSelection); QString selectionValue = variant.value<QString>(); QCOMPARE(selectionValue, QString("eb")); #endif //ImSurroundingText - variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText); + variant = page->inputMethodQuery(Qt::ImSurroundingText); QString value = variant.value<QString>(); QCOMPARE(value, QString("QtWebKit")); @@ -1341,29 +1464,46 @@ void tst_QWebPage::inputMethods() QInputMethodEvent::Attribute newSelection(QInputMethodEvent::Selection, 0, 0, QVariant()); attributes.append(newSelection); QInputMethodEvent event("composition", attributes); - m_view->page()->event(&event); + page->event(&event); } // A ongoing composition should not change the surrounding text before it is committed. - variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText); + variant = page->inputMethodQuery(Qt::ImSurroundingText); value = variant.value<QString>(); QCOMPARE(value, QString("QtWebKit")); #endif //ImhHiddenText QMouseEvent evpresPassword(QEvent::MouseButtonPress, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evpresPassword); + page->event(&evpresPassword); QMouseEvent evrelPassword(QEvent::MouseButtonRelease, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - m_view->page()->event(&evrelPassword); + page->event(&evrelPassword); - QVERIFY(m_view->testAttribute(Qt::WA_InputMethodEnabled)); + QVERIFY(inputMethodEnabled(view)); #if QT_VERSION >= 0x040600 - QVERIFY(m_view->inputMethodHints() & Qt::ImhHiddenText); + QVERIFY(inputMethodHints(view) & Qt::ImhHiddenText); + + page->event(&evpres); + page->event(&evrel); + QVERIFY(!(inputMethodHints(view) & Qt::ImhHiddenText)); +#endif + + page->mainFrame()->setHtml("<html><body><p>nothing to input here"); + viewEventSpy.clear(); + + QWebElement para = page->mainFrame()->findFirstElement("p"); + { + QMouseEvent evpres(QEvent::MouseButtonPress, para.geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + page->event(&evpres); + QMouseEvent evrel(QEvent::MouseButtonRelease, para.geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + page->event(&evrel); + } - m_view->page()->event(&evpres); - m_view->page()->event(&evrel); - QVERIFY(!(m_view->inputMethodHints() & Qt::ImhHiddenText)); +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); #endif + + delete container; } // import a little DRT helper function to trigger the garbage collector @@ -1394,10 +1534,17 @@ void tst_QWebPage::protectBindingsRuntimeObjectsFromCollector() void tst_QWebPage::localURLSchemes() { int i = QWebSecurityOrigin::localSchemes().size(); + QWebSecurityOrigin::removeLocalScheme("file"); QTRY_COMPARE(QWebSecurityOrigin::localSchemes().size(), i); QWebSecurityOrigin::addLocalScheme("file"); QTRY_COMPARE(QWebSecurityOrigin::localSchemes().size(), i); + + QWebSecurityOrigin::removeLocalScheme("qrc"); + QTRY_COMPARE(QWebSecurityOrigin::localSchemes().size(), i - 1); + QWebSecurityOrigin::addLocalScheme("qrc"); + QTRY_COMPARE(QWebSecurityOrigin::localSchemes().size(), i); + QString myscheme = "myscheme"; QWebSecurityOrigin::addLocalScheme(myscheme); QTRY_COMPARE(QWebSecurityOrigin::localSchemes().size(), i + 1); @@ -1438,11 +1585,6 @@ void tst_QWebPage::testOptionalJSObjects() QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", true), true); QCOMPARE(testFlag(webPage1, QWebSettings::LocalStorageEnabled, "localStorage", false), false); QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", false), true); - - QCOMPARE(testFlag(webPage1, QWebSettings::SessionStorageEnabled, "sessionStorage", false), false); - QCOMPARE(testFlag(webPage2, QWebSettings::SessionStorageEnabled, "sessionStorage", true), true); - QCOMPARE(testFlag(webPage1, QWebSettings::SessionStorageEnabled, "sessionStorage", false), false); - QCOMPARE(testFlag(webPage2, QWebSettings::SessionStorageEnabled, "sessionStorage", false), true); } void tst_QWebPage::testEnablePersistentStorage() @@ -1508,15 +1650,10 @@ public: virtual bool extension(Extension, const ExtensionOption* option, ExtensionReturn* output) { - const ErrorPageExtensionOption* info = static_cast<const ErrorPageExtensionOption*>(option); ErrorPageExtensionReturn* errorPage = static_cast<ErrorPageExtensionReturn*>(output); - if (info->frame == mainFrame()) { - errorPage->content = "data:text/html,error"; - return true; - } - - return false; + errorPage->content = "data:text/html,error"; + return true; } }; @@ -1527,11 +1664,10 @@ void tst_QWebPage::errorPageExtension() QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); - page->mainFrame()->load(QUrl("qrc:///frametest/index.html")); + m_view->setUrl(QUrl("data:text/html,foo")); QTRY_COMPARE(spyLoadFinished.count(), 1); page->mainFrame()->setUrl(QUrl("http://non.existent/url")); - QTest::qWait(2000); QTRY_COMPARE(spyLoadFinished.count(), 2); QCOMPARE(page->mainFrame()->toPlainText(), QString("data:text/html,error")); QCOMPARE(page->history()->count(), 2); @@ -1539,6 +1675,53 @@ void tst_QWebPage::errorPageExtension() QCOMPARE(page->history()->canGoBack(), true); QCOMPARE(page->history()->canGoForward(), false); + page->triggerAction(QWebPage::Back); + QTest::qWait(2000); + QCOMPARE(page->history()->canGoBack(), false); + QCOMPARE(page->history()->canGoForward(), true); + + page->triggerAction(QWebPage::Forward); + QTest::qWait(2000); + QCOMPARE(page->history()->canGoBack(), true); + QCOMPARE(page->history()->canGoForward(), false); + + page->triggerAction(QWebPage::Back); + QTest::qWait(2000); + QCOMPARE(page->history()->canGoBack(), false); + QCOMPARE(page->history()->canGoForward(), true); + QCOMPARE(page->history()->currentItem().url(), QUrl("data:text/html,foo")); + + m_view->setPage(0); +} + +void tst_QWebPage::errorPageExtensionInIFrames() +{ + ErrorPage* page = new ErrorPage; + m_view->setPage(page); + + m_view->setHtml(QString("data:text/html," + "<h1>h1</h1>" + "<iframe src='data:text/html,<p/>p'></iframe>" + "<iframe src='non-existent.html'></iframe>")); + QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); + QTRY_COMPARE(spyLoadFinished.count(), 1); + + QCOMPARE(page->mainFrame()->childFrames()[1]->toPlainText(), QString("data:text/html,error")); + + m_view->setPage(0); +} + +void tst_QWebPage::errorPageExtensionInFrameset() +{ + ErrorPage* page = new ErrorPage; + m_view->setPage(page); + + m_view->load(QUrl("qrc:///frametest/index.html")); + + QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); + QTRY_COMPARE(spyLoadFinished.count(), 1); + QCOMPARE(page->mainFrame()->childFrames()[1]->toPlainText(), QString("data:text/html,error")); + m_view->setPage(0); } @@ -1609,5 +1792,27 @@ void tst_QWebPage::screenshot() QDir::setCurrent(QApplication::applicationDirPath()); } +void tst_QWebPage::originatingObjectInNetworkRequests() +{ + TestNetworkManager* networkManager = new TestNetworkManager(m_page); + m_page->setNetworkAccessManager(networkManager); + networkManager->requests.clear(); + + m_view->setHtml(QString("data:text/html,<frameset cols=\"25%,75%\"><frame src=\"data:text/html," + "<head><meta http-equiv='refresh' content='1'></head>foo \">" + "<frame src=\"data:text/html,bar\"></frameset>"), QUrl()); + QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); + + QCOMPARE(networkManager->requests.count(), 2); + + QList<QWebFrame*> childFrames = m_page->mainFrame()->childFrames(); + QCOMPARE(childFrames.count(), 2); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + for (int i = 0; i < 2; ++i) + QVERIFY(qobject_cast<QWebFrame*>(networkManager->requests.at(i).originatingObject()) == childFrames.at(i)); +#endif +} + QTEST_MAIN(tst_QWebPage) #include "tst_qwebpage.moc" diff --git a/WebKit/qt/tests/qwebview/data/frame_a.html b/WebKit/qt/tests/qwebview/data/frame_a.html new file mode 100644 index 0000000..9ff68f1 --- /dev/null +++ b/WebKit/qt/tests/qwebview/data/frame_a.html @@ -0,0 +1,2 @@ +<a href="http://google.com" target="frame_b"><img src="" width=100 height=100 alt="Google"></a> +<a href="http://yahoo.com" target="frame_b"><img src="" width=100 height=100 alt="Yahoo"></a> diff --git a/WebKit/qt/tests/qwebview/data/index.html b/WebKit/qt/tests/qwebview/data/index.html new file mode 100644 index 0000000..c53ad09 --- /dev/null +++ b/WebKit/qt/tests/qwebview/data/index.html @@ -0,0 +1,4 @@ +<frameset cols="25%,75%"> + <frame src="frame_a.html" name="frame_a"> + <frame src="frame_b.html" name="frame_b"> +</frameset> diff --git a/WebKit/qt/tests/qwebview/qwebview.pro b/WebKit/qt/tests/qwebview/qwebview.pro index e67bb7a..735537b 100644 --- a/WebKit/qt/tests/qwebview/qwebview.pro +++ b/WebKit/qt/tests/qwebview/qwebview.pro @@ -4,6 +4,7 @@ include(../../../../WebKit.pri) SOURCES += tst_qwebview.cpp QT += testlib network QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR +RESOURCES += tst_qwebview.qrc DEFINES += SRCDIR=\\\"$$PWD/\\\" symbian { diff --git a/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/WebKit/qt/tests/qwebview/tst_qwebview.cpp index 9204223..bd2f185 100644 --- a/WebKit/qt/tests/qwebview/tst_qwebview.cpp +++ b/WebKit/qt/tests/qwebview/tst_qwebview.cpp @@ -20,6 +20,7 @@ */ #include <qtest.h> +#include "../util.h" #include <qpainter.h> #include <qwebview.h> @@ -41,12 +42,12 @@ public slots: private slots: void renderHints(); - void guessUrlFromString_data(); - void guessUrlFromString(); void getWebKitVersion(); void reusePage_data(); void reusePage(); + + void crashTests(); }; // This will be called before the first test function is executed. @@ -105,68 +106,6 @@ void tst_QWebView::renderHints() QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); } -void tst_QWebView::guessUrlFromString_data() -{ - QTest::addColumn<QString>("string"); - QTest::addColumn<QUrl>("guessUrlFromString"); - - // Null - QTest::newRow("null") << QString() << QUrl(); - - // File - QDirIterator it(QDir::homePath()); - QString fileString; - int c = 0; - while (it.hasNext()) { - it.next(); - QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.filePath() << QUrl::fromLocalFile(it.filePath()); - } - - // basic latin1 - QTest::newRow("unicode-0") << QString::fromUtf8("å.com/") << QUrl::fromEncoded(QString::fromUtf8("http://å.com/").toUtf8(), QUrl::TolerantMode); - // unicode - QTest::newRow("unicode-1") << QString::fromUtf8("λ.com/") << QUrl::fromEncoded(QString::fromUtf8("http://λ.com/").toUtf8(), QUrl::TolerantMode); - - // no scheme - QTest::newRow("add scheme-0") << "webkit.org" << QUrl("http://webkit.org"); - QTest::newRow("add scheme-1") << "www.webkit.org" << QUrl("http://www.webkit.org"); - QTest::newRow("add scheme-2") << "ftp.webkit.org" << QUrl("ftp://ftp.webkit.org"); - QTest::newRow("add scheme-3") << "webkit" << QUrl("webkit"); - - // QUrl's tolerant parser should already handle this - QTest::newRow("not-encoded-0") << "http://webkit.org/test page.html" << QUrl("http://webkit.org/test%20page.html"); - - // Make sure the :80, i.e. port doesn't screw anything up - QUrl portUrl("http://webkit.org"); - portUrl.setPort(80); - QTest::newRow("port-0") << "webkit.org:80" << portUrl; - QTest::newRow("port-1") << "http://webkit.org:80" << portUrl; - - // mailto doesn't have a ://, but is valid - QUrl mailto("ben@meyerhome.net"); - mailto.setScheme("mailto"); - QTest::newRow("mailto") << "mailto:ben@meyerhome.net" << mailto; - - // misc - QTest::newRow("localhost-0") << "localhost" << QUrl("http://localhost"); - QTest::newRow("localhost-1") << "localhost:80" << QUrl("http://localhost:80"); - QTest::newRow("spaces-0") << " http://webkit.org/test page.html " << QUrl("http://webkit.org/test%20page.html"); - - // FYI: The scheme in the resulting url user - QUrl authUrl("user:pass@domain.com"); - QTest::newRow("misc-1") << "user:pass@domain.com" << authUrl; -} - -// public static QUrl guessUrlFromString(QString const& string) -void tst_QWebView::guessUrlFromString() -{ - QFETCH(QString, string); - QFETCH(QUrl, guessUrlFromString); - - QUrl url = QWebView::guessUrlFromString(string); - QCOMPARE(url, guessUrlFromString); -} - void tst_QWebView::getWebKitVersion() { QVERIFY(qWebKitVersion().toDouble() > 0); @@ -193,18 +132,18 @@ void tst_QWebView::reusePage() mainFrame->setHtml(html, QUrl::fromLocalFile(QDir::currentPath())); if (html.contains("</embed>")) { // some reasonable time for the PluginStream to feed test.swf to flash and start painting - QTest::qWait(2000); + waitForSignal(view1, SIGNAL(loadFinished(bool)), 2000); } view1->show(); - QTest::qWait(2000); + QTest::qWaitForWindowShown(view1); delete view1; 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->show(); // in Windowless mode, you should still be able to see the plugin here - QTest::qWait(2000); + QTest::qWaitForWindowShown(view2); delete view2; delete page; // must not crash @@ -212,6 +151,46 @@ void tst_QWebView::reusePage() QDir::setCurrent(QApplication::applicationDirPath()); } +// Class used in crashTests +class WebViewCrashTest : public QObject { + Q_OBJECT + QWebView* m_view; +public: + bool m_executed; + + + WebViewCrashTest(QWebView* view) + : m_view(view) + , m_executed(false) + { + view->connect(view, SIGNAL(loadProgress(int)), this, SLOT(loading(int))); + } + +private slots: + void loading(int progress) + { + if (progress >= 20 && progress < 90) { + QVERIFY(!m_executed); + m_view->stop(); + m_executed = true; + } + } +}; + + +// Should not crash. +void tst_QWebView::crashTests() +{ + // Test if loading can be stopped in loadProgress handler without crash. + // Test page should have frames. + QWebView view; + WebViewCrashTest tester(&view); + QUrl url("qrc:///data/index.html"); + view.load(url); + QTRY_VERIFY(tester.m_executed); // If fail it means that the test wasn't executed. +} + + QTEST_MAIN(tst_QWebView) #include "tst_qwebview.moc" diff --git a/WebKit/qt/tests/qwebview/tst_qwebview.qrc b/WebKit/qt/tests/qwebview/tst_qwebview.qrc new file mode 100644 index 0000000..ede34a9 --- /dev/null +++ b/WebKit/qt/tests/qwebview/tst_qwebview.qrc @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>data/index.html</file> + <file>data/frame_a.html</file> +</qresource> +</RCC> + diff --git a/WebKit/qt/tests/tests.pro b/WebKit/qt/tests/tests.pro index 81cc8f3..b967ca9 100644 --- a/WebKit/qt/tests/tests.pro +++ b/WebKit/qt/tests/tests.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs -SUBDIRS = qwebframe qwebpage qwebelement qgraphicswebview qwebhistoryinterface qwebplugindatabase qwebview qwebhistory +SUBDIRS = qwebframe qwebpage qwebelement qgraphicswebview qwebhistoryinterface qwebview qwebhistory qwebinspector greaterThan(QT_MINOR_VERSION, 4): SUBDIRS += benchmarks/painting/tst_painting.pro benchmarks/loading/tst_loading.pro diff --git a/WebKit/qt/tests/util.h b/WebKit/qt/tests/util.h index 7f7e613..15af262 100644 --- a/WebKit/qt/tests/util.h +++ b/WebKit/qt/tests/util.h @@ -18,6 +18,33 @@ */ // Functions and macros that really need to be in QTestLib +#include <QEventLoop> +#include <QSignalSpy> +#include <QTimer> + +/** + * Starts an event loop that runs until the given signal is received. + * Optionally the event loop + * can return earlier on a timeout. + * + * \return \p true if the requested signal was received + * \p false on timeout + */ +static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) +{ + QEventLoop loop; + QObject::connect(obj, signal, &loop, SLOT(quit())); + QTimer timer; + QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); + if (timeout > 0) { + QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.setSingleShot(true); + timer.start(timeout); + } + loop.exec(); + return timeoutSpy.isEmpty(); +} + // Will try to wait for the condition while allowing event processing #define QTRY_VERIFY(__expr) \ do { \ @@ -45,4 +72,3 @@ } \ QCOMPARE(__expr, __expected); \ } while(0) - |