From 84882c173529352870966f97459ffb17c5a51eb4 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 18 Jun 2010 10:12:23 +0200 Subject: Updated WebKit to c6f08f4c13f88491a5d1ae1794c72166af0c26ba Integrated: || || [Qt] Upstream the WebKit QML integration plugin || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/ChangeLog | 11 + src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebKit.pro | 3 + src/3rdparty/webkit/WebKit/qt/ChangeLog | 149 +++ .../webkit/WebKit/qt/declarative/declarative.pro | 74 ++ .../webkit/WebKit/qt/declarative/plugin.cpp | 43 + .../WebKit/qt/declarative/qdeclarativewebview.cpp | 1020 ++++++++++++++++++++ .../WebKit/qt/declarative/qdeclarativewebview_p.h | 367 +++++++ src/3rdparty/webkit/WebKit/qt/declarative/qmldir | 1 + .../webkit/WebKit/qt/docs/qtwebkit.qdocconf | 4 +- 11 files changed, 1672 insertions(+), 4 deletions(-) create mode 100644 src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro create mode 100644 src/3rdparty/webkit/WebKit/qt/declarative/plugin.cpp create mode 100644 src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp create mode 100644 src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h create mode 100644 src/3rdparty/webkit/WebKit/qt/declarative/qmldir diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index f5b6af3..2a95aee 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -6623b5da196390748dc619461739f9cb84524736 +c6f08f4c13f88491a5d1ae1794c72166af0c26ba diff --git a/src/3rdparty/webkit/ChangeLog b/src/3rdparty/webkit/ChangeLog index 51d08a0..1f067bf 100644 --- a/src/3rdparty/webkit/ChangeLog +++ b/src/3rdparty/webkit/ChangeLog @@ -1,3 +1,14 @@ +2010-06-17 Alexis Menard + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Upstream the WebKit QML integration plugin + https://bugs.webkit.org/show_bug.cgi?id=40050 + + Add to the build the QML WebKit integration plugin. + + * WebKit.pro: + 2010-06-17 Mark Brand Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 1e7351f..2134b58 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 6623b5da196390748dc619461739f9cb84524736 + c6f08f4c13f88491a5d1ae1794c72166af0c26ba diff --git a/src/3rdparty/webkit/WebKit.pro b/src/3rdparty/webkit/WebKit.pro index 84fcb56..5a33bf7 100644 --- a/src/3rdparty/webkit/WebKit.pro +++ b/src/3rdparty/webkit/WebKit.pro @@ -9,6 +9,9 @@ SUBDIRS += \ # If the source exists, built it exists($$PWD/WebKitTools/QtTestBrowser): SUBDIRS += WebKitTools/QtTestBrowser +greaterThan(QT_MINOR_VERSION, 6) { + exists($$PWD/WebKit/qt/declarative): SUBDIRS += WebKit/qt/declarative +} exists($$PWD/JavaScriptCore/jsc.pro): SUBDIRS += JavaScriptCore/jsc.pro exists($$PWD/WebKit/qt/tests): SUBDIRS += WebKit/qt/tests exists($$PWD/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro): SUBDIRS += WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 475d22d..113202b 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,152 @@ +2010-06-17 Alexis Menard + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Upstream the WebKit QML integration plugin + https://bugs.webkit.org/show_bug.cgi?id=40050 + + Add to the Qt port the QML WebKit integration plugin. + QDeclarativeWebView is creating the item and expose + properties. The C++ API is not public, only the + properties are. + + * declarative/declarative.pro: Added. + * declarative/plugin.cpp: Added. + (WebKitQmlPlugin::registerTypes): + * declarative/qdeclarativewebview.cpp: Added. + (QDeclarativeWebViewPrivate::QDeclarativeWebViewPrivate): + (QDeclarativeWebViewPrivate::): + (QDeclarativeWebViewPrivate::windowObjectsAppend): + (GraphicsWebView::GraphicsWebView): + (GraphicsWebView::mousePressEvent): + (GraphicsWebView::mouseReleaseEvent): + (GraphicsWebView::mouseDoubleClickEvent): + (GraphicsWebView::timerEvent): + (GraphicsWebView::mouseMoveEvent): + (QDeclarativeWebView::QDeclarativeWebView): + (QDeclarativeWebView::~QDeclarativeWebView): + (QDeclarativeWebView::init): + (QDeclarativeWebView::componentComplete): + (QDeclarativeWebView::status): + (QDeclarativeWebView::progress): + (QDeclarativeWebView::doLoadStarted): + (QDeclarativeWebView::doLoadProgress): + (QDeclarativeWebView::pageUrlChanged): + (QDeclarativeWebView::doLoadFinished): + (QDeclarativeWebView::url): + (QDeclarativeWebView::setUrl): + (QDeclarativeWebView::preferredWidth): + (QDeclarativeWebView::setPreferredWidth): + (QDeclarativeWebView::preferredHeight): + (QDeclarativeWebView::setPreferredHeight): + (QDeclarativeWebView::evaluateJavaScript): + (QDeclarativeWebView::updateDeclarativeWebViewSize): + (QDeclarativeWebView::initialLayout): + (QDeclarativeWebView::updateContentsSize): + (QDeclarativeWebView::geometryChanged): + (QDeclarativeWebView::javaScriptWindowObjects): + (QDeclarativeWebView::qmlAttachedProperties): + (QDeclarativeWebViewPrivate::updateWindowObjects): + (QDeclarativeWebView::renderingEnabled): + (QDeclarativeWebView::setRenderingEnabled): + (QDeclarativeWebView::heuristicZoom): + (QDeclarativeWebView::pressGrabTime): + (QDeclarativeWebView::setPressGrabTime): + (QDeclarativeWebView::backAction): + (QDeclarativeWebView::forwardAction): + (QDeclarativeWebView::reloadAction): + (QDeclarativeWebView::stopAction): + (QDeclarativeWebView::title): + (QDeclarativeWebView::icon): + (QDeclarativeWebView::setStatusText): + (QDeclarativeWebView::windowObjectCleared): + (QDeclarativeWebView::statusText): + (QDeclarativeWebView::page): + (QDeclarativeWebView::settingsObject): + (QDeclarativeWebView::setPage): + (QDeclarativeWebView::load): + (QDeclarativeWebView::html): + (QDeclarativeWebView::setHtml): + (QDeclarativeWebView::setContent): + (QDeclarativeWebView::history): + (QDeclarativeWebView::settings): + (QDeclarativeWebView::createWindow): + (QDeclarativeWebView::newWindowComponent): + (QDeclarativeWebView::setNewWindowComponent): + (QDeclarativeWebView::newWindowParent): + (QDeclarativeWebView::setNewWindowParent): + (QDeclarativeWebView::contentsSize): + (QDeclarativeWebView::contentsScale): + (QDeclarativeWebView::setContentsScale): + (QDeclarativeWebView::elementAreaAt): + (QDeclarativeWebPage::QDeclarativeWebPage): + (QDeclarativeWebPage::~QDeclarativeWebPage): + (QDeclarativeWebPage::chooseFile): + (QDeclarativeWebPage::javaScriptAlert): + (QDeclarativeWebPage::javaScriptConfirm): + (QDeclarativeWebPage::javaScriptPrompt): + (QDeclarativeWebPage::viewItem): + (QDeclarativeWebPage::createWindow): + * declarative/qdeclarativewebview_p.h: Added. + (QDeclarativeWebView::): + (QDeclarativeWebView::isComponentCompletePublic): + (QDeclarativeWebViewAttached::QDeclarativeWebViewAttached): + (QDeclarativeWebViewAttached::windowObjectName): + (QDeclarativeWebViewAttached::setWindowObjectName): + (QDeclarativeWebSettings::QDeclarativeWebSettings): + (QDeclarativeWebSettings::standardFontFamily): + (QDeclarativeWebSettings::setStandardFontFamily): + (QDeclarativeWebSettings::fixedFontFamily): + (QDeclarativeWebSettings::setFixedFontFamily): + (QDeclarativeWebSettings::serifFontFamily): + (QDeclarativeWebSettings::setSerifFontFamily): + (QDeclarativeWebSettings::sansSerifFontFamily): + (QDeclarativeWebSettings::setSansSerifFontFamily): + (QDeclarativeWebSettings::cursiveFontFamily): + (QDeclarativeWebSettings::setCursiveFontFamily): + (QDeclarativeWebSettings::fantasyFontFamily): + (QDeclarativeWebSettings::setFantasyFontFamily): + (QDeclarativeWebSettings::minimumFontSize): + (QDeclarativeWebSettings::setMinimumFontSize): + (QDeclarativeWebSettings::minimumLogicalFontSize): + (QDeclarativeWebSettings::setMinimumLogicalFontSize): + (QDeclarativeWebSettings::defaultFontSize): + (QDeclarativeWebSettings::setDefaultFontSize): + (QDeclarativeWebSettings::defaultFixedFontSize): + (QDeclarativeWebSettings::setDefaultFixedFontSize): + (QDeclarativeWebSettings::autoLoadImages): + (QDeclarativeWebSettings::setAutoLoadImages): + (QDeclarativeWebSettings::javascriptEnabled): + (QDeclarativeWebSettings::setJavascriptEnabled): + (QDeclarativeWebSettings::javaEnabled): + (QDeclarativeWebSettings::setJavaEnabled): + (QDeclarativeWebSettings::pluginsEnabled): + (QDeclarativeWebSettings::setPluginsEnabled): + (QDeclarativeWebSettings::privateBrowsingEnabled): + (QDeclarativeWebSettings::setPrivateBrowsingEnabled): + (QDeclarativeWebSettings::javascriptCanOpenWindows): + (QDeclarativeWebSettings::setJavascriptCanOpenWindows): + (QDeclarativeWebSettings::javascriptCanAccessClipboard): + (QDeclarativeWebSettings::setJavascriptCanAccessClipboard): + (QDeclarativeWebSettings::developerExtrasEnabled): + (QDeclarativeWebSettings::setDeveloperExtrasEnabled): + (QDeclarativeWebSettings::linksIncludedInFocusChain): + (QDeclarativeWebSettings::setLinksIncludedInFocusChain): + (QDeclarativeWebSettings::zoomTextOnly): + (QDeclarativeWebSettings::setZoomTextOnly): + (QDeclarativeWebSettings::printElementBackgrounds): + (QDeclarativeWebSettings::setPrintElementBackgrounds): + (QDeclarativeWebSettings::offlineStorageDatabaseEnabled): + (QDeclarativeWebSettings::setOfflineStorageDatabaseEnabled): + (QDeclarativeWebSettings::offlineWebApplicationCacheEnabled): + (QDeclarativeWebSettings::setOfflineWebApplicationCacheEnabled): + (QDeclarativeWebSettings::localStorageDatabaseEnabled): + (QDeclarativeWebSettings::setLocalStorageDatabaseEnabled): + (QDeclarativeWebSettings::localContentCanAccessRemoteUrls): + (QDeclarativeWebSettings::setLocalContentCanAccessRemoteUrls): + * declarative/qmldir: Added. + * docs/qtwebkit.qdocconf: + 2010-06-17 Mark Brand Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro new file mode 100644 index 0000000..9c15529 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro @@ -0,0 +1,74 @@ +TARGET = qmlwebkitplugin +TARGETPATH = org/webkit + +TEMPLATE = lib +CONFIG += qt plugin + +win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release + +QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir +copy2build.input = QMLDIRFILE +CONFIG(QTDIR_build) { + copy2build.output = $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir +} else { + copy2build.output = $$OUTPUT_DIR/imports/$$TARGETPATH/qmldir +} +!contains(TEMPLATE_PREFIX, vc):copy2build.variable_out = PRE_TARGETDEPS +copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy2build.name = COPY ${QMAKE_FILE_IN} +copy2build.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += copy2build + +TARGET = $$qtLibraryTarget($$TARGET) +contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols + +wince*:LIBS += $$QMAKE_LIBS_GUI + +symbian: { + TARGET.EPOCALLOWDLLDATA=1 + TARGET.CAPABILITY = All -Tcb + load(armcc_warnings) +} + +include(../../../WebKit.pri) + +QT += declarative + +linux-* { + # From Creator's src/rpath.pri: + # Do the rpath by hand since it's not possible to use ORIGIN in QMAKE_RPATHDIR + # this expands to $ORIGIN (after qmake and make), it does NOT read a qmake var. + QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR + MY_RPATH = $$join(QMAKE_RPATHDIR, ":") + + QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${MY_RPATH}\' + QMAKE_RPATHDIR = +} else { + QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR +} + +SOURCES += qdeclarativewebview.cpp plugin.cpp +HEADERS += qdeclarativewebview_p.h + +CONFIG(QTDIR_build) { + DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH +} else { + DESTDIR = $$OUTPUT_DIR/imports/$$TARGETPATH +} +target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH + + +qmldir.files += $$PWD/qmldir +qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH + +symbian:{ + load(data_caging_paths) + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + importFiles.sources = qmlwebkitplugin.dll qmldir + importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH + + DEPLOYMENT = importFiles +} + +INSTALLS += target qmldir diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/plugin.cpp b/src/3rdparty/webkit/WebKit/qt/declarative/plugin.cpp new file mode 100644 index 0000000..f1f165e --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/declarative/plugin.cpp @@ -0,0 +1,43 @@ +/* + Copyright (C) 2009 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 "qdeclarativewebview_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +class WebKitQmlPlugin : public QDeclarativeExtensionPlugin { + Q_OBJECT +public: + virtual void registerTypes(const char* uri) + { + Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebKit")); + qmlRegisterType(); + qmlRegisterType(uri, 1, 0, "WebView"); + } +}; + +QT_END_NAMESPACE + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(qmlwebkitplugin, QT_PREPEND_NAMESPACE(WebKitQmlPlugin)); + diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp new file mode 100644 index 0000000..f8e1767 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -0,0 +1,1020 @@ +/* + Copyright (C) 2009 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 "qdeclarativewebview_p.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QDeclarativeWebViewPrivate { +public: + QDeclarativeWebViewPrivate(QDeclarativeWebView* qq) + : q(qq) + , preferredwidth(0) + , preferredheight(0) + , progress(1.0) + , status(QDeclarativeWebView::Null) + , pending(PendingNone) + , newWindowComponent(0) + , newWindowParent(0) + , rendering(true) + { + } + + QDeclarativeWebView* q; + + QUrl url; // page url might be different if it has not loaded yet + GraphicsWebView* view; + + int preferredwidth, preferredheight; + qreal progress; + QDeclarativeWebView::Status status; + QString statusText; + enum { PendingNone, PendingUrl, PendingHtml, PendingContent } pending; + QUrl pendingUrl; + QString pendingString; + QByteArray pendingData; + mutable QDeclarativeWebSettings settings; + QDeclarativeComponent* newWindowComponent; + QDeclarativeItem* newWindowParent; + + static void windowObjectsAppend(QDeclarativeListProperty* prop, QObject* o) + { + static_cast(prop->data)->windowObjects.append(o); + static_cast(prop->data)->updateWindowObjects(); + } + + void updateWindowObjects(); + QObjectList windowObjects; + + bool rendering; +}; + +GraphicsWebView::GraphicsWebView(QDeclarativeWebView* parent) + : QGraphicsWebView(parent) + , parent(parent) + , pressTime(400) +{ +} + +void GraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* event) +{ + setFocus(); + pressPoint = event->pos(); + if (pressTime) { + pressTimer.start(pressTime, this); + parent->setKeepMouseGrab(false); + } else { + grabMouse(); + parent->setKeepMouseGrab(true); + } + QGraphicsWebView::mousePressEvent(event); +} + +void GraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) +{ + QGraphicsWebView::mouseReleaseEvent(event); + pressTimer.stop(); + parent->setKeepMouseGrab(false); + ungrabMouse(); +} + +void GraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) +{ + QMouseEvent* me = new QMouseEvent(QEvent::MouseButtonDblClick, (event->pos() / parent->contentsScale()).toPoint(), event->button(), event->buttons(), 0); + emit doubleClick(event->pos().x(), event->pos().y()); + delete me; +} + +void GraphicsWebView::timerEvent(QTimerEvent* event) +{ + if (event->timerId() == pressTimer.timerId()) { + pressTimer.stop(); + grabMouse(); + parent->setKeepMouseGrab(true); + } +} + +void GraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) +{ + if (pressTimer.isActive()) { + if ((event->pos() - pressPoint).manhattanLength() > QApplication::startDragDistance()) + pressTimer.stop(); + } + if (parent->keepMouseGrab()) + QGraphicsWebView::mouseMoveEvent(event); +} + +/*! + \qmlclass WebView QDeclarativeWebView + \since 4.7 + \brief The WebView item allows you to add web content to a canvas. + \inherits Item + + A WebView renders web content based on a URL. + + This type is made available by importing the \c org.webkit module: + + \bold{import org.webkit 1.0} + + 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 for typical online web pages. + + If the width or height is explictly set, the rendered website + will be clipped, not scaled, to fit into the set dimensions. + + If the preferredWidth is set, the width will be this amount or larger, + usually laying out the web content to fit the preferredWidth. + + \qml + import org.webkit 1.0 + + WebView { + url: "http://www.nokia.com" + preferredWidth: 490 + preferredHeight: 400 + scale: 0.5 + smooth: false + smoothCache: true + } + \endqml + + \image webview.png + + The item includes no scrolling, scaling, + toolbars, etc., those must be implemented around WebView. See the WebBrowser example + for a demonstration of this. + + When this item has keyboard focus, all keyboard input will be sent directly to the + web page within. +*/ + +/*! + \internal + \class QDeclarativeWebView + \brief The QDeclarativeWebView class allows you to add web content to a QDeclarativeView. + + A WebView renders web content base on a URL. + + \image webview.png + + The item includes no scrolling, scaling, + toolbars, etc., those must be implemented around WebView. See the WebBrowser example + for a demonstration of this. + + A QDeclarativeWebView object can be instantiated in Qml using the tag \l WebView. +*/ + +QDeclarativeWebView::QDeclarativeWebView(QDeclarativeItem *parent) : QDeclarativeItem(parent) +{ + init(); +} + +QDeclarativeWebView::~QDeclarativeWebView() +{ + delete d; +} + +void QDeclarativeWebView::init() +{ + d = new QDeclarativeWebViewPrivate(this); + + QWebSettings::enablePersistentStorage(); + + setAcceptedMouseButtons(Qt::LeftButton); + setFlag(QGraphicsItem::ItemHasNoContents, true); + setClip(true); + + d->view = new GraphicsWebView(this); + d->view->setResizesToContents(true); + QWebPage* wp = new QDeclarativeWebPage(this); + setPage(wp); + connect(d->view, SIGNAL(geometryChanged()), this, SLOT(updateDeclarativeWebViewSize())); + connect(d->view, SIGNAL(doubleClick(int, int)), this, SIGNAL(doubleClick(int, int))); + connect(d->view, SIGNAL(scaleChanged()), this, SIGNAL(contentsScaleChanged())); +} + +void QDeclarativeWebView::componentComplete() +{ + QDeclarativeItem::componentComplete(); + page()->setNetworkAccessManager(qmlEngine(this)->networkAccessManager()); + + switch (d->pending) { + case QDeclarativeWebViewPrivate::PendingUrl: + setUrl(d->pendingUrl); + break; + case QDeclarativeWebViewPrivate::PendingHtml: + setHtml(d->pendingString, d->pendingUrl); + break; + case QDeclarativeWebViewPrivate::PendingContent: + setContent(d->pendingData, d->pendingString, d->pendingUrl); + break; + default: + break; + } + d->pending = QDeclarativeWebViewPrivate::PendingNone; + d->updateWindowObjects(); +} + +QDeclarativeWebView::Status QDeclarativeWebView::status() const +{ + return d->status; +} + + +/*! + \qmlproperty real WebView::progress + This property holds the progress of loading the current URL, from 0 to 1. + + If you just want to know when progress gets to 1, use + WebView::onLoadFinished() or WebView::onLoadFailed() instead. +*/ +qreal QDeclarativeWebView::progress() const +{ + return d->progress; +} + +void QDeclarativeWebView::doLoadStarted() +{ + if (!d->url.isEmpty()) { + d->status = Loading; + emit statusChanged(d->status); + } + emit loadStarted(); +} + +void QDeclarativeWebView::doLoadProgress(int p) +{ + if (d->progress == p / 100.0) + return; + d->progress = p / 100.0; + emit progressChanged(); +} + +void QDeclarativeWebView::pageUrlChanged() +{ + updateContentsSize(); + + if ((d->url.isEmpty() && page()->mainFrame()->url() != QUrl(QLatin1String("about:blank"))) + || (d->url != page()->mainFrame()->url() && !page()->mainFrame()->url().isEmpty())) + { + d->url = page()->mainFrame()->url(); + if (d->url == QUrl(QLatin1String("about:blank"))) + d->url = QUrl(); + emit urlChanged(); + } +} + +void QDeclarativeWebView::doLoadFinished(bool ok) +{ + if (ok) { + d->status = d->url.isEmpty() ? Null : Ready; + emit loadFinished(); + } else { + d->status = Error; + emit loadFailed(); + } + emit statusChanged(d->status); +} + +/*! + \qmlproperty url WebView::url + This property holds the URL to the page displayed in this item. It can be set, + but also can change spontaneously (eg. because of network redirection). + + If the url is empty, the page is blank. + + The url is always absolute (QML will resolve relative URL strings in the context + of the containing QML document). +*/ +QUrl QDeclarativeWebView::url() const +{ + return d->url; +} + +void QDeclarativeWebView::setUrl(const QUrl& url) +{ + if (url == d->url) + return; + + if (isComponentComplete()) { + d->url = url; + updateContentsSize(); + QUrl seturl = url; + if (seturl.isEmpty()) + seturl = QUrl(QLatin1String("about:blank")); + + Q_ASSERT(!seturl.isRelative()); + + page()->mainFrame()->load(seturl); + + emit urlChanged(); + } else { + d->pending = d->PendingUrl; + d->pendingUrl = url; + } +} + +/*! + \qmlproperty int WebView::preferredWidth + This property holds the ideal width for displaying the current URL. +*/ +int QDeclarativeWebView::preferredWidth() const +{ + return d->preferredwidth; +} + +void QDeclarativeWebView::setPreferredWidth(int width) +{ + if (d->preferredwidth == width) + return; + d->preferredwidth = width; + updateContentsSize(); + emit preferredWidthChanged(); +} + +/*! + \qmlproperty int WebView::preferredHeight + This property holds the ideal height for displaying the current URL. + This only affects the area zoomed by heuristicZoom(). +*/ +int QDeclarativeWebView::preferredHeight() const +{ + return d->preferredheight; +} + +void QDeclarativeWebView::setPreferredHeight(int height) +{ + if (d->preferredheight == height) + return; + d->preferredheight = height; + updateContentsSize(); + emit preferredHeightChanged(); +} + +/*! + \qmlmethod bool WebView::evaluateJavaScript(string) + + Evaluates the \a scriptSource JavaScript inside the context of the + main web frame, and returns the result of the last executed statement. + + Note that this JavaScript does \e not have any access to QML objects + except as made available as windowObjects. +*/ +QVariant QDeclarativeWebView::evaluateJavaScript(const QString& scriptSource) +{ + return this->page()->mainFrame()->evaluateJavaScript(scriptSource); +} + +void QDeclarativeWebView::updateDeclarativeWebViewSize() +{ + QSizeF size = d->view->geometry().size() * contentsScale(); + setImplicitWidth(size.width()); + setImplicitHeight(size.height()); +} + +void QDeclarativeWebView::initialLayout() +{ + // nothing useful to do at this point +} + +void QDeclarativeWebView::updateContentsSize() +{ + if (page()) { + page()->setPreferredContentsSize(QSize( + d->preferredwidth>0 ? d->preferredwidth : width(), + d->preferredheight>0 ? d->preferredheight : height())); + } +} + +void QDeclarativeWebView::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) +{ + QWebPage* webPage = page(); + if (newGeometry.size() != oldGeometry.size() && webPage) { + QSize contentSize = webPage->preferredContentsSize(); + if (widthValid()) + contentSize.setWidth(width()); + if (heightValid()) + contentSize.setHeight(height()); + if (contentSize != webPage->preferredContentsSize()) + webPage->setPreferredContentsSize(contentSize); + } + QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); +} + +/*! + \qmlproperty list WebView::javaScriptWindowObjects + + A list of QML objects to expose to the web page. + + Each object will be added as a property of the web frame's window object. The + property name is controlled by the value of \c WebView.windowObjectName + attached property. + + Exposing QML objects to a web page allows JavaScript executing in the web + page itself to communicate with QML, by reading and writing properties and + by calling methods of the exposed QML objects. + + This example shows how to call into a QML method using a window object. + + \qml + WebView { + javaScriptWindowObjects: QtObject { + WebView.windowObjectName: "qml" + + function qmlCall() { + console.log("This call is in QML!"); + } + } + + html: "" + } + \endqml + + The output of the example will be: + \code + This is in WebKit! + This call is in QML! + \endcode + + If Javascript is not enabled for the page, then this property does nothing. +*/ +QDeclarativeListProperty QDeclarativeWebView::javaScriptWindowObjects() +{ + return QDeclarativeListProperty(this, d, &QDeclarativeWebViewPrivate::windowObjectsAppend); +} + +QDeclarativeWebViewAttached* QDeclarativeWebView::qmlAttachedProperties(QObject* o) +{ + return new QDeclarativeWebViewAttached(o); +} + +void QDeclarativeWebViewPrivate::updateWindowObjects() +{ + if (!q->isComponentCompletePublic() || !q->page()) + return; + + for (int i = 0; i < windowObjects.count(); ++i) { + QObject* object = windowObjects.at(i); + QDeclarativeWebViewAttached* attached = static_cast(qmlAttachedPropertiesObject(object)); + if (attached && !attached->windowObjectName().isEmpty()) + q->page()->mainFrame()->addToJavaScriptWindowObject(attached->windowObjectName(), object); + } +} + +bool QDeclarativeWebView::renderingEnabled() const +{ + return d->rendering; +} + +void QDeclarativeWebView::setRenderingEnabled(bool enabled) +{ + if (d->rendering == enabled) + return; + d->rendering = enabled; + emit renderingEnabledChanged(); + d->view->setTiledBackingStoreFrozen(!enabled); +} + +/*! + \qmlsignal WebView::onDoubleClick(clickx, clicky) + + The WebView does not pass double-click events to the web engine, but rather + emits this signals. +*/ + +/*! + \qmlmethod bool WebView::heuristicZoom(clickX,clickY,maxzoom) + + Finds a zoom that: + \list + \i shows a whole item + \i includes (\a clickX, \a clickY) + \i fits into the preferredWidth and preferredHeight + \i zooms by no more than \a maxZoom + \i is more than 10% above the current zoom + \endlist + + If such a zoom exists, emits zoomTo(zoom,centerX,centerY) and returns true; otherwise, + no signal is emitted and returns false. +*/ +bool QDeclarativeWebView::heuristicZoom(int clickX, int clickY, qreal maxZoom) +{ + if (contentsScale() >= maxZoom / scale()) + return false; + qreal ozf = contentsScale(); + QRect showArea = elementAreaAt(clickX, clickY, d->preferredwidth / maxZoom, d->preferredheight / maxZoom); + qreal z = qMin(qreal(d->preferredwidth) / showArea.width(), qreal(d->preferredheight) / showArea.height()); + if (z > maxZoom / scale()) + z = maxZoom / scale(); + if (z / ozf > 1.2) { + QRectF r(showArea.left() * z, showArea.top() * z, showArea.width() * z, showArea.height() * z); + emit zoomTo(z, r.x() + r.width() / 2, r.y() + r.height() / 2); + return true; + } + return false; +} + +/*! + \qmlproperty int WebView::pressGrabTime + + The number of milliseconds the user must press before the WebView + starts passing move events through to the web engine (rather than + letting other QML elements such as a Flickable take them). + + Defaults to 400ms. Set to 0 to always grab and pass move events to + the web engine. +*/ +int QDeclarativeWebView::pressGrabTime() const +{ + return d->view->pressTime; +} + +void QDeclarativeWebView::setPressGrabTime(int millis) +{ + if (d->view->pressTime == millis) + return; + d->view->pressTime = millis; + emit pressGrabTimeChanged(); +} + +/*! + \qmlproperty action WebView::back + This property holds the action for causing the previous URL in the history to be displayed. +*/ +QAction* QDeclarativeWebView::backAction() const +{ + return page()->action(QWebPage::Back); +} + +/*! + \qmlproperty action WebView::forward + This property holds the action for causing the next URL in the history to be displayed. +*/ +QAction* QDeclarativeWebView::forwardAction() const +{ + return page()->action(QWebPage::Forward); +} + +/*! + \qmlproperty action WebView::reload + This property holds the action for reloading with the current URL +*/ +QAction* QDeclarativeWebView::reloadAction() const +{ + return page()->action(QWebPage::Reload); +} + +/*! + \qmlproperty action WebView::stop + This property holds the action for stopping loading with the current URL +*/ +QAction* QDeclarativeWebView::stopAction() const +{ + return page()->action(QWebPage::Stop); +} + +/*! + \qmlproperty real WebView::title + This property holds the title of the web page currently viewed + + By default, this property contains an empty string. +*/ +QString QDeclarativeWebView::title() const +{ + return page()->mainFrame()->title(); +} + +/*! + \qmlproperty pixmap WebView::icon + This property holds the icon associated with the web page currently viewed +*/ +QPixmap QDeclarativeWebView::icon() const +{ + return page()->mainFrame()->icon().pixmap(QSize(256, 256)); +} + +/*! + \qmlproperty string WebView::statusText + + This property is the current status suggested by the current web page. In a web browser, + such status is often shown in some kind of status bar. +*/ +void QDeclarativeWebView::setStatusText(const QString& text) +{ + d->statusText = text; + emit statusTextChanged(); +} + +void QDeclarativeWebView::windowObjectCleared() +{ + d->updateWindowObjects(); +} + +QString QDeclarativeWebView::statusText() const +{ + return d->statusText; +} + +QWebPage* QDeclarativeWebView::page() const +{ + return d->view->page(); +} + +// The QObject interface to settings(). +/*! + \qmlproperty string WebView::settings.standardFontFamily + \qmlproperty string WebView::settings.fixedFontFamily + \qmlproperty string WebView::settings.serifFontFamily + \qmlproperty string WebView::settings.sansSerifFontFamily + \qmlproperty string WebView::settings.cursiveFontFamily + \qmlproperty string WebView::settings.fantasyFontFamily + + \qmlproperty int WebView::settings.minimumFontSize + \qmlproperty int WebView::settings.minimumLogicalFontSize + \qmlproperty int WebView::settings.defaultFontSize + \qmlproperty int WebView::settings.defaultFixedFontSize + + \qmlproperty bool WebView::settings.autoLoadImages + \qmlproperty bool WebView::settings.javascriptEnabled + \qmlproperty bool WebView::settings.javaEnabled + \qmlproperty bool WebView::settings.pluginsEnabled + \qmlproperty bool WebView::settings.privateBrowsingEnabled + \qmlproperty bool WebView::settings.javascriptCanOpenWindows + \qmlproperty bool WebView::settings.javascriptCanAccessClipboard + \qmlproperty bool WebView::settings.developerExtrasEnabled + \qmlproperty bool WebView::settings.linksIncludedInFocusChain + \qmlproperty bool WebView::settings.zoomTextOnly + \qmlproperty bool WebView::settings.printElementBackgrounds + \qmlproperty bool WebView::settings.offlineStorageDatabaseEnabled + \qmlproperty bool WebView::settings.offlineWebApplicationCacheEnabled + \qmlproperty bool WebView::settings.localStorageDatabaseEnabled + \qmlproperty bool WebView::settings.localContentCanAccessRemoteUrls + + These properties give access to the settings controlling the web view. + + See QWebSettings for details of these properties. + + \qml + WebView { + settings.pluginsEnabled: true + settings.standardFontFamily: "Arial" + ... + } + \endqml +*/ +QDeclarativeWebSettings* QDeclarativeWebView::settingsObject() const +{ + d->settings.s = page()->settings(); + return &d->settings; +} + +void QDeclarativeWebView::setPage(QWebPage* page) +{ + if (d->view->page() == page) + return; + + d->view->setPage(page); + updateContentsSize(); + page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); + connect(page->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(pageUrlChanged())); + connect(page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); + connect(page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(iconChanged())); + connect(page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); + connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout())); + connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SIGNAL(contentsSizeChanged(QSize))); + + connect(page, SIGNAL(loadStarted()), this, SLOT(doLoadStarted())); + connect(page, SIGNAL(loadProgress(int)), this, SLOT(doLoadProgress(int))); + connect(page, SIGNAL(loadFinished(bool)), this, SLOT(doLoadFinished(bool))); + connect(page, SIGNAL(statusBarMessage(QString)), this, SLOT(setStatusText(QString))); + + connect(page->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(windowObjectCleared())); + + page->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); + +} + +/*! + \qmlsignal WebView::onLoadStarted() + + This handler is called when the web engine begins loading + a page. Later, WebView::onLoadFinished() or WebView::onLoadFailed() + will be emitted. +*/ + +/*! + \qmlsignal WebView::onLoadFinished() + + This handler is called when the web engine \e successfully + finishes loading a page, including any component content + (WebView::onLoadFailed() will be emitted otherwise). + + \sa progress +*/ + +/*! + \qmlsignal WebView::onLoadFailed() + + This handler is called when the web engine fails loading + a page or any component content + (WebView::onLoadFinished() will be emitted on success). +*/ + +void QDeclarativeWebView::load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation, const QByteArray& body) +{ + page()->mainFrame()->load(request, operation, body); +} + +QString QDeclarativeWebView::html() const +{ + return page()->mainFrame()->toHtml(); +} + +/*! + \qmlproperty string WebView::html + This property holds HTML text set directly + + The html property can be set as a string. + + \qml + WebView { + html: "

This is HTML." + } + \endqml +*/ +void QDeclarativeWebView::setHtml(const QString& html, const QUrl& baseUrl) +{ + updateContentsSize(); + if (isComponentComplete()) + page()->mainFrame()->setHtml(html, baseUrl); + else { + d->pending = d->PendingHtml; + d->pendingUrl = baseUrl; + d->pendingString = html; + } + emit htmlChanged(); +} + +void QDeclarativeWebView::setContent(const QByteArray& data, const QString& mimeType, const QUrl& baseUrl) +{ + updateContentsSize(); + + if (isComponentComplete()) + page()->mainFrame()->setContent(data, mimeType, qmlContext(this)->resolvedUrl(baseUrl)); + else { + d->pending = d->PendingContent; + d->pendingUrl = baseUrl; + d->pendingString = mimeType; + d->pendingData = data; + } +} + +QWebHistory* QDeclarativeWebView::history() const +{ + return page()->history(); +} + +QWebSettings* QDeclarativeWebView::settings() const +{ + return page()->settings(); +} + +QDeclarativeWebView* QDeclarativeWebView::createWindow(QWebPage::WebWindowType type) +{ + switch (type) { + case QWebPage::WebBrowserWindow: { + if (!d->newWindowComponent && d->newWindowParent) + qWarning("WebView::newWindowComponent not set - WebView::newWindowParent ignored"); + else if (d->newWindowComponent && !d->newWindowParent) + qWarning("WebView::newWindowParent not set - WebView::newWindowComponent ignored"); + else if (d->newWindowComponent && d->newWindowParent) { + QDeclarativeWebView* webview = 0; + QDeclarativeContext* windowContext = new QDeclarativeContext(qmlContext(this)); + + QObject* newObject = d->newWindowComponent->create(windowContext); + if (newObject) { + windowContext->setParent(newObject); + QDeclarativeItem* item = qobject_cast(newObject); + if (!item) + delete newObject; + else { + webview = item->findChild(); + if (!webview) + delete item; + else { + newObject->setParent(d->newWindowParent); + static_cast(item)->setParentItem(d->newWindowParent); + } + } + } else + delete windowContext; + + return webview; + } + } + break; + case QWebPage::WebModalDialog: { + // Not supported + } + } + return 0; +} + +/*! + \qmlproperty component WebView::newWindowComponent + + This property holds the component to use for new windows. + The component must have a WebView somewhere in its structure. + + When the web engine requests a new window, it will be an instance of + this component. + + The parent of the new window is set by newWindowParent. It must be set. +*/ +QDeclarativeComponent* QDeclarativeWebView::newWindowComponent() const +{ + return d->newWindowComponent; +} + +void QDeclarativeWebView::setNewWindowComponent(QDeclarativeComponent* newWindow) +{ + if (newWindow == d->newWindowComponent) + return; + d->newWindowComponent = newWindow; + emit newWindowComponentChanged(); +} + + +/*! + \qmlproperty item WebView::newWindowParent + + The parent item for new windows. + + \sa newWindowComponent +*/ +QDeclarativeItem* QDeclarativeWebView::newWindowParent() const +{ + return d->newWindowParent; +} + +void QDeclarativeWebView::setNewWindowParent(QDeclarativeItem* parent) +{ + if (parent == d->newWindowParent) + return; + if (d->newWindowParent && parent) { + QList children = d->newWindowParent->childItems(); + for (int i = 0; i < children.count(); ++i) + children.at(i)->setParentItem(parent); + } + d->newWindowParent = parent; + emit newWindowParentChanged(); +} + +QSize QDeclarativeWebView::contentsSize() const +{ + return page()->mainFrame()->contentsSize() * contentsScale(); +} + +qreal QDeclarativeWebView::contentsScale() const +{ + return d->view->scale(); +} + +void QDeclarativeWebView::setContentsScale(qreal scale) +{ + if (scale == d->view->scale()) + return; + d->view->setScale(scale); + updateDeclarativeWebViewSize(); + emit contentsScaleChanged(); +} + +/*! + Returns the area of the largest element at position (\a x,\a y) that is no larger + than \a maxWidth by \a maxHeight pixels. + + May return an area larger in the case when no smaller element is at the position. +*/ +QRect QDeclarativeWebView::elementAreaAt(int x, int y, int maxWidth, int maxHeight) const +{ + QWebHitTestResult hit = page()->mainFrame()->hitTestContent(QPoint(x, y)); + QRect hitRect = hit.boundingRect(); + QWebElement element = hit.enclosingBlockElement(); + if (maxWidth <= 0) + maxWidth = INT_MAX; + if (maxHeight <= 0) + maxHeight = INT_MAX; + while (!element.parent().isNull() && element.geometry().width() <= maxWidth && element.geometry().height() <= maxHeight) { + hitRect = element.geometry(); + element = element.parent(); + } + return hitRect; +} + +/*! + \internal + \class QDeclarativeWebPage + \brief The QDeclarativeWebPage class is a QWebPage that can create QML plugins. + + \sa QDeclarativeWebView +*/ +QDeclarativeWebPage::QDeclarativeWebPage(QDeclarativeWebView* parent) : + QWebPage(parent) +{ +} + +QDeclarativeWebPage::~QDeclarativeWebPage() +{ +} + +QString QDeclarativeWebPage::chooseFile(QWebFrame* originatingFrame, const QString& oldFile) +{ + // Not supported (it's modal) + Q_UNUSED(originatingFrame) + Q_UNUSED(oldFile) + return oldFile; +} + +/*! + \qmlsignal WebView::alert(message) + + This signal is emitted when the web engine sends a JavaScript alert. The \a message is the text + to be displayed in the alert to the user. +*/ + + +void QDeclarativeWebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString& msg) +{ + Q_UNUSED(originatingFrame) + emit viewItem()->alert(msg); +} + +bool QDeclarativeWebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString& msg) +{ + // Not supported (it's modal) + Q_UNUSED(originatingFrame) + Q_UNUSED(msg) + return false; +} + +bool QDeclarativeWebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString& msg, const QString& defaultValue, QString* result) +{ + // Not supported (it's modal) + Q_UNUSED(originatingFrame) + Q_UNUSED(msg) + Q_UNUSED(defaultValue) + Q_UNUSED(result) + return false; +} + + +QDeclarativeWebView* QDeclarativeWebPage::viewItem() +{ + return static_cast(parent()); +} + +QWebPage* QDeclarativeWebPage::createWindow(WebWindowType type) +{ + QDeclarativeWebView* newView = viewItem()->createWindow(type); + if (newView) + return newView->page(); + return 0; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h new file mode 100644 index 0000000..1dca96d --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h @@ -0,0 +1,367 @@ +/* + Copyright (C) 2009 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 qdeclarativewebview_p_h +#define qdeclarativewebview_p_h + +#include +#include +#include +#include +#include +#include +#include + + +QT_BEGIN_HEADER + +class QWebHistory; +class QWebSettings; + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) +class QDeclarativeWebSettings; +class QDeclarativeWebViewPrivate; +class QNetworkRequest; +class QDeclarativeWebView; +class QDeclarativeWebViewPrivate; + +class QDeclarativeWebPage : public QWebPage { + Q_OBJECT +public: + explicit QDeclarativeWebPage(QDeclarativeWebView *parent); + ~QDeclarativeWebPage(); +protected: + QWebPage *createWindow(WebWindowType type); + QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile); + void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg); + bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg); + bool javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result); + +private: + QDeclarativeWebView *viewItem(); +}; + +class GraphicsWebView : public QGraphicsWebView { + Q_OBJECT +public: + GraphicsWebView(QDeclarativeWebView* parent = 0); +protected: + void mousePressEvent(QGraphicsSceneMouseEvent* event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); + void mouseMoveEvent(QGraphicsSceneMouseEvent* event); + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); + void timerEvent(QTimerEvent* event); +Q_SIGNALS: + void doubleClick(int clickX, int clickY); +private: + QDeclarativeWebView *parent; + QPointF pressPoint; + QBasicTimer pressTimer; + int pressTime; // milliseconds before the touch event becomes a "tap and hold" + friend class QDeclarativeWebView; +}; + +class QDeclarativeWebViewAttached; + +// TODO: browser plugins + +class QDeclarativeWebView : public QDeclarativeItem { + Q_OBJECT + + Q_ENUMS(Status SelectionMode) + + Q_PROPERTY(QString title READ title NOTIFY titleChanged) + Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged) + Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged) + + Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged) + + Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime NOTIFY pressGrabTimeChanged) + + Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged) + Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged) + Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) + Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + + Q_PROPERTY(QAction* reload READ reloadAction CONSTANT) + Q_PROPERTY(QAction* back READ backAction CONSTANT) + Q_PROPERTY(QAction* forward READ forwardAction CONSTANT) + Q_PROPERTY(QAction* stop READ stopAction CONSTANT) + + Q_PROPERTY(QDeclarativeWebSettings* settings READ settingsObject CONSTANT) + + Q_PROPERTY(QDeclarativeListProperty javaScriptWindowObjects READ javaScriptWindowObjects CONSTANT) + + Q_PROPERTY(QDeclarativeComponent* newWindowComponent READ newWindowComponent WRITE setNewWindowComponent NOTIFY newWindowComponentChanged) + Q_PROPERTY(QDeclarativeItem* newWindowParent READ newWindowParent WRITE setNewWindowParent NOTIFY newWindowParentChanged) + + Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged) + + Q_PROPERTY(QSize contentsSize READ contentsSize NOTIFY contentsSizeChanged) + Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged) + +public: + QDeclarativeWebView(QDeclarativeItem *parent = 0); + ~QDeclarativeWebView(); + + QUrl url() const; + void setUrl(const QUrl &); + + QString title() const; + + QPixmap icon() const; + + Q_INVOKABLE bool heuristicZoom(int clickX, int clickY, qreal maxzoom); + QRect elementAreaAt(int x, int y, int minwidth, int minheight) const; + + int pressGrabTime() const; + void setPressGrabTime(int); + + int preferredWidth() const; + void setPreferredWidth(int); + int preferredHeight() const; + void setPreferredHeight(int); + + enum Status { Null, Ready, Loading, Error }; + Status status() const; + qreal progress() const; + QString statusText() const; + + QAction *reloadAction() const; + QAction *backAction() const; + QAction *forwardAction() const; + QAction *stopAction() const; + + QWebPage *page() const; + void setPage(QWebPage *page); + + void load(const QNetworkRequest &request, + QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, + const QByteArray &body = QByteArray()); + + QString html() const; + + void setHtml(const QString &html, const QUrl &baseUrl = QUrl()); + void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl()); + + QWebHistory* history() const; + QWebSettings* settings() const; + QDeclarativeWebSettings *settingsObject() const; + + bool renderingEnabled() const; + void setRenderingEnabled(bool); + + QDeclarativeListProperty javaScriptWindowObjects(); + + static QDeclarativeWebViewAttached* qmlAttachedProperties(QObject*); + + QDeclarativeComponent *newWindowComponent() const; + void setNewWindowComponent(QDeclarativeComponent *newWindow); + QDeclarativeItem* newWindowParent() const; + void setNewWindowParent(QDeclarativeItem* newWindow); + + bool isComponentCompletePublic() const { return isComponentComplete(); } + + QSize contentsSize() const; + + void setContentsScale(qreal scale); + qreal contentsScale() const; + +Q_SIGNALS: + void preferredWidthChanged(); + void preferredHeightChanged(); + void urlChanged(); + void progressChanged(); + void statusChanged(Status); + void titleChanged(const QString&); + void iconChanged(); + void statusTextChanged(); + void htmlChanged(); + void pressGrabTimeChanged(); + void newWindowComponentChanged(); + void newWindowParentChanged(); + void renderingEnabledChanged(); + void contentsSizeChanged(const QSize&); + void contentsScaleChanged(); + + void loadStarted(); + void loadFinished(); + void loadFailed(); + + void doubleClick(int clickX, int clickY); + + void zoomTo(qreal zoom, int centerX, int centerY); + + void alert(const QString& message); + +public Q_SLOTS: + QVariant evaluateJavaScript(const QString&); + +private Q_SLOTS: + void doLoadStarted(); + void doLoadProgress(int p); + void doLoadFinished(bool ok); + void setStatusText(const QString&); + void windowObjectCleared(); + void pageUrlChanged(); + void initialLayout(); + + void updateDeclarativeWebViewSize(); + + virtual void geometryChanged(const QRectF &newGeometry, + const QRectF &oldGeometry); + QDeclarativeWebView* createWindow(QWebPage::WebWindowType type); + +private: + void updateContentsSize(); + void init(); + virtual void componentComplete(); + Q_DISABLE_COPY(QDeclarativeWebView) + QDeclarativeWebViewPrivate* d; + QMouseEvent* sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent*); + QMouseEvent* sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent*); + friend class QDeclarativeWebPage; +}; + +class QDeclarativeWebViewAttached : public QObject { + Q_OBJECT + Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName) +public: + QDeclarativeWebViewAttached(QObject* parent) + : QObject(parent) + { + } + + QString windowObjectName() const + { + return m_windowObjectName; + } + + void setWindowObjectName(const QString &n) + { + m_windowObjectName = n; + } + +private: + QString m_windowObjectName; +}; + +class QDeclarativeWebSettings : public QObject { + Q_OBJECT + + Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily) + Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily) + Q_PROPERTY(QString serifFontFamily READ serifFontFamily WRITE setSerifFontFamily) + Q_PROPERTY(QString sansSerifFontFamily READ sansSerifFontFamily WRITE setSansSerifFontFamily) + Q_PROPERTY(QString cursiveFontFamily READ cursiveFontFamily WRITE setCursiveFontFamily) + Q_PROPERTY(QString fantasyFontFamily READ fantasyFontFamily WRITE setFantasyFontFamily) + + Q_PROPERTY(int minimumFontSize READ minimumFontSize WRITE setMinimumFontSize) + Q_PROPERTY(int minimumLogicalFontSize READ minimumLogicalFontSize WRITE setMinimumLogicalFontSize) + Q_PROPERTY(int defaultFontSize READ defaultFontSize WRITE setDefaultFontSize) + Q_PROPERTY(int defaultFixedFontSize READ defaultFixedFontSize WRITE setDefaultFixedFontSize) + + Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages) + Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled) + Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled) + Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled) + Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled) + Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows) + Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard) + Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled) + Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain) + Q_PROPERTY(bool zoomTextOnly READ zoomTextOnly WRITE setZoomTextOnly) + Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds) + Q_PROPERTY(bool offlineStorageDatabaseEnabled READ offlineStorageDatabaseEnabled WRITE setOfflineStorageDatabaseEnabled) + Q_PROPERTY(bool offlineWebApplicationCacheEnabled READ offlineWebApplicationCacheEnabled WRITE setOfflineWebApplicationCacheEnabled) + Q_PROPERTY(bool localStorageDatabaseEnabled READ localStorageDatabaseEnabled WRITE setLocalStorageDatabaseEnabled) + Q_PROPERTY(bool localContentCanAccessRemoteUrls READ localContentCanAccessRemoteUrls WRITE setLocalContentCanAccessRemoteUrls) + +public: + QDeclarativeWebSettings() {} + + QString standardFontFamily() const { return s->fontFamily(QWebSettings::StandardFont); } + void setStandardFontFamily(const QString& f) { s->setFontFamily(QWebSettings::StandardFont, f); } + QString fixedFontFamily() const { return s->fontFamily(QWebSettings::FixedFont); } + void setFixedFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FixedFont, f); } + QString serifFontFamily() const { return s->fontFamily(QWebSettings::SerifFont); } + void setSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SerifFont, f); } + QString sansSerifFontFamily() const { return s->fontFamily(QWebSettings::SansSerifFont); } + void setSansSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SansSerifFont, f); } + QString cursiveFontFamily() const { return s->fontFamily(QWebSettings::CursiveFont); } + void setCursiveFontFamily(const QString& f) { s->setFontFamily(QWebSettings::CursiveFont, f); } + QString fantasyFontFamily() const { return s->fontFamily(QWebSettings::FantasyFont); } + void setFantasyFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FantasyFont, f); } + + int minimumFontSize() const { return s->fontSize(QWebSettings::MinimumFontSize); } + void setMinimumFontSize(int size) { s->setFontSize(QWebSettings::MinimumFontSize, size); } + int minimumLogicalFontSize() const { return s->fontSize(QWebSettings::MinimumLogicalFontSize); } + void setMinimumLogicalFontSize(int size) { s->setFontSize(QWebSettings::MinimumLogicalFontSize, size); } + int defaultFontSize() const { return s->fontSize(QWebSettings::DefaultFontSize); } + void setDefaultFontSize(int size) { s->setFontSize(QWebSettings::DefaultFontSize, size); } + int defaultFixedFontSize() const { return s->fontSize(QWebSettings::DefaultFixedFontSize); } + void setDefaultFixedFontSize(int size) { s->setFontSize(QWebSettings::DefaultFixedFontSize, size); } + + bool autoLoadImages() const { return s->testAttribute(QWebSettings::AutoLoadImages); } + void setAutoLoadImages(bool on) { s->setAttribute(QWebSettings::AutoLoadImages, on); } + bool javascriptEnabled() const { return s->testAttribute(QWebSettings::JavascriptEnabled); } + void setJavascriptEnabled(bool on) { s->setAttribute(QWebSettings::JavascriptEnabled, on); } + bool javaEnabled() const { return s->testAttribute(QWebSettings::JavaEnabled); } + void setJavaEnabled(bool on) { s->setAttribute(QWebSettings::JavaEnabled, on); } + bool pluginsEnabled() const { return s->testAttribute(QWebSettings::PluginsEnabled); } + void setPluginsEnabled(bool on) { s->setAttribute(QWebSettings::PluginsEnabled, on); } + bool privateBrowsingEnabled() const { return s->testAttribute(QWebSettings::PrivateBrowsingEnabled); } + void setPrivateBrowsingEnabled(bool on) { s->setAttribute(QWebSettings::PrivateBrowsingEnabled, on); } + bool javascriptCanOpenWindows() const { return s->testAttribute(QWebSettings::JavascriptCanOpenWindows); } + void setJavascriptCanOpenWindows(bool on) { s->setAttribute(QWebSettings::JavascriptCanOpenWindows, on); } + bool javascriptCanAccessClipboard() const { return s->testAttribute(QWebSettings::JavascriptCanAccessClipboard); } + void setJavascriptCanAccessClipboard(bool on) { s->setAttribute(QWebSettings::JavascriptCanAccessClipboard, on); } + bool developerExtrasEnabled() const { return s->testAttribute(QWebSettings::DeveloperExtrasEnabled); } + void setDeveloperExtrasEnabled(bool on) { s->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); } + bool linksIncludedInFocusChain() const { return s->testAttribute(QWebSettings::LinksIncludedInFocusChain); } + void setLinksIncludedInFocusChain(bool on) { s->setAttribute(QWebSettings::LinksIncludedInFocusChain, on); } + bool zoomTextOnly() const { return s->testAttribute(QWebSettings::ZoomTextOnly); } + void setZoomTextOnly(bool on) { s->setAttribute(QWebSettings::ZoomTextOnly, on); } + bool printElementBackgrounds() const { return s->testAttribute(QWebSettings::PrintElementBackgrounds); } + void setPrintElementBackgrounds(bool on) { s->setAttribute(QWebSettings::PrintElementBackgrounds, on); } + bool offlineStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::OfflineStorageDatabaseEnabled); } + void setOfflineStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, on); } + bool offlineWebApplicationCacheEnabled() const { return s->testAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); } + void setOfflineWebApplicationCacheEnabled(bool on) { s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, on); } + bool localStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::LocalStorageDatabaseEnabled); } + void setLocalStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, on); } + bool localContentCanAccessRemoteUrls() const { return s->testAttribute(QWebSettings::LocalContentCanAccessRemoteUrls); } + void setLocalContentCanAccessRemoteUrls(bool on) { s->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, on); } + + QWebSettings *s; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarativeWebView) +QML_DECLARE_TYPE(QDeclarativeWebSettings) +QML_DECLARE_TYPEINFO(QDeclarativeWebView, QML_HAS_ATTACHED_PROPERTIES) + +QT_END_HEADER + +#endif diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qmldir b/src/3rdparty/webkit/WebKit/qt/declarative/qmldir new file mode 100644 index 0000000..dcfdd06 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qmldir @@ -0,0 +1 @@ +plugin qmlwebkitplugin diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdocconf b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdocconf index 292c124..5f877c2 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdocconf +++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdocconf @@ -3,8 +3,8 @@ project = qtwebkit description = "Qt WebKit API Documentation" -headerdirs = $SRCDIR/WebKit/qt/Api -sourcedirs = $SRCDIR/WebKit/qt/Api $SRCDIR/WebKit/qt/docs $SRCDIR/JavaScriptCore/qt/api +headerdirs = $SRCDIR/WebKit/qt/Api $SRCDIR/WebKit/qt/declarative +sourcedirs = $SRCDIR/WebKit/qt/Api $SRCDIR/WebKit/qt/docs $SRCDIR/JavaScriptCore/qt/api $SRCDIR/WebKit/qt/declarative outputdir = $OUTPUT_DIR/doc/html outputformats = HTML sources.fileextensions = "*.cpp *.doc *.qdoc *.h" -- cgit v0.12 From 0ce072e74aea546852b6bb4b7f0c0fe0e2678aa5 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 18 Jun 2010 11:23:44 +0200 Subject: Updated WebKit to d7a095a2a9514e1f132b779b99279585820b46f5 * Build fixes from the trunk --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebKit.pro | 2 +- src/3rdparty/webkit/WebKit/ChangeLog | 8 ++++++++ src/3rdparty/webkit/WebKit/qt/ChangeLog | 20 ++++++++++++++++++++ .../webkit/WebKit/qt/declarative/declarative.pro | 2 +- .../WebKit/qt/declarative/qdeclarativewebview.cpp | 8 ++++---- .../WebKit/qt/declarative/qdeclarativewebview_p.h | 4 ++-- 8 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 2a95aee..c7b77a6 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -c6f08f4c13f88491a5d1ae1794c72166af0c26ba +d7a095a2a9514e1f132b779b99279585820b46f5 diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 2134b58..dc50465 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - c6f08f4c13f88491a5d1ae1794c72166af0c26ba + d7a095a2a9514e1f132b779b99279585820b46f5 diff --git a/src/3rdparty/webkit/WebKit.pro b/src/3rdparty/webkit/WebKit.pro index 5a33bf7..c7df391 100644 --- a/src/3rdparty/webkit/WebKit.pro +++ b/src/3rdparty/webkit/WebKit.pro @@ -9,7 +9,7 @@ SUBDIRS += \ # If the source exists, built it exists($$PWD/WebKitTools/QtTestBrowser): SUBDIRS += WebKitTools/QtTestBrowser -greaterThan(QT_MINOR_VERSION, 6) { +contains(QT_CONFIG, declarative) { exists($$PWD/WebKit/qt/declarative): SUBDIRS += WebKit/qt/declarative } exists($$PWD/JavaScriptCore/jsc.pro): SUBDIRS += JavaScriptCore/jsc.pro diff --git a/src/3rdparty/webkit/WebKit/ChangeLog b/src/3rdparty/webkit/WebKit/ChangeLog index bee3298..0bf9bed 100644 --- a/src/3rdparty/webkit/WebKit/ChangeLog +++ b/src/3rdparty/webkit/WebKit/ChangeLog @@ -1,3 +1,11 @@ +2010-06-18 Alexis Menard + + Reviewed by Simon Hausmann. + + [qt] Better check for the declarative plugin inclusion. + + * WebKit.pro: + 2010-03-22 Kevin Decker Reviewed by Simon Fraser. diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 113202b..987dc12 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,23 @@ +2010-06-18 Alexis Menard + + Reviewed by Simon Hausmann. + + [Qt] Change the target path to QtWebKit. + + * declarative/declarative.pro: + +2010-06-17 Robert Hogan + + [Qt] Build fix + + Unreviewed. + + Remove includes in qdeclarativewebview*.* that rely on an installation + of QtWebKit. + + * declarative/qdeclarativewebview.cpp: + * declarative/qdeclarativewebview_p.h: + 2010-06-17 Alexis Menard Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro index 9c15529..924329a 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro +++ b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro @@ -1,5 +1,5 @@ TARGET = qmlwebkitplugin -TARGETPATH = org/webkit +TARGETPATH = QtWebKit TEMPLATE = lib CONFIG += qt plugin diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp index f8e1767..0d2800f 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -31,10 +31,10 @@ #include #include #include -#include -#include -#include -#include +#include "qwebelement.h" +#include "qwebframe.h" +#include "qwebpage.h" +#include "qwebsettings.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h index 1dca96d..3c3f889 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h @@ -26,8 +26,8 @@ #include #include #include -#include -#include +#include "qgraphicswebview.h" +#include "qwebpage.h" QT_BEGIN_HEADER -- cgit v0.12 From 8f1def139d6eaf99c22b43536d056964e0d41245 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Fri, 18 Jun 2010 14:22:13 +0200 Subject: Remove the old WebView element in src/import. The new one is in src/3rdparty/webkit Also change a bit the demo due to a little API change. The module is not org.webkit but QtWebKit now. Reviewed-by:simon hausmann --- .../webbrowser/content/FlickableWebView.qml | 5 +- demos/declarative/webbrowser/webbrowser.qml | 2 +- src/imports/imports.pro | 2 - src/imports/webkit/plugin.cpp | 67 -- src/imports/webkit/qdeclarativewebview.cpp | 1212 -------------------- src/imports/webkit/qdeclarativewebview_p.h | 300 ----- src/imports/webkit/qdeclarativewebview_p_p.h | 151 --- src/imports/webkit/qmldir | 1 - src/imports/webkit/webkit.pro | 27 - src/src.pro | 4 + 10 files changed, 7 insertions(+), 1764 deletions(-) delete mode 100644 src/imports/webkit/plugin.cpp delete mode 100644 src/imports/webkit/qdeclarativewebview.cpp delete mode 100644 src/imports/webkit/qdeclarativewebview_p.h delete mode 100644 src/imports/webkit/qdeclarativewebview_p_p.h delete mode 100644 src/imports/webkit/qmldir delete mode 100644 src/imports/webkit/webkit.pro diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 62da2ea..fb479d2 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -40,7 +40,7 @@ ****************************************************************************/ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 Flickable { property alias title: webView.title @@ -90,7 +90,6 @@ Flickable { url: fixUrl(webBrowser.urlString) smooth: false // We don't want smooth scaling, since we only scale during (fast) transitions focus: true - zoomFactor: 1 onAlert: console.log(message) @@ -114,7 +113,7 @@ Flickable { preferredWidth: flickable.width preferredHeight: flickable.height - contentsScale: 1/zoomFactor + contentsScale: 1 onContentsSizeChanged: { // zoom out contentsScale = Math.min(1,flickable.width / contentsSize.width) diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 53ba6da..3bff0fe 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -40,7 +40,7 @@ ****************************************************************************/ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 import "content" diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 7f9331a..5e50b08 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -2,5 +2,3 @@ TEMPLATE = subdirs SUBDIRS += folderlistmodel particles gestures -contains(QT_CONFIG, webkit): SUBDIRS += webkit - diff --git a/src/imports/webkit/plugin.cpp b/src/imports/webkit/plugin.cpp deleted file mode 100644 index c8e56ba..0000000 --- a/src/imports/webkit/plugin.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "qdeclarativewebview_p.h" -#include "qdeclarativewebview_p_p.h" - -QT_BEGIN_NAMESPACE - -class WebKitQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("org.webkit")); - qmlRegisterType(); - qmlRegisterType(uri,1,0,"WebView"); - } -}; - -QT_END_NAMESPACE - -#include "plugin.moc" - -Q_EXPORT_PLUGIN2(qmlwebkitplugin, QT_PREPEND_NAMESPACE(WebKitQmlPlugin)); - diff --git a/src/imports/webkit/qdeclarativewebview.cpp b/src/imports/webkit/qdeclarativewebview.cpp deleted file mode 100644 index 383f1ce..0000000 --- a/src/imports/webkit/qdeclarativewebview.cpp +++ /dev/null @@ -1,1212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativewebview_p.h" -#include "qdeclarativewebview_p_p.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system - -class QDeclarativeWebViewPrivate -{ -public: - QDeclarativeWebViewPrivate(QDeclarativeWebView* qq) - : q(qq), page(0), preferredwidth(0), preferredheight(0), - progress(1.0), status(QDeclarativeWebView::Null), pending(PendingNone), - newWindowComponent(0), newWindowParent(0), - pressTime(400), - rendering(true) - { - QObject::connect(q, SIGNAL(focusChanged(bool)), q, SLOT(propagateFocusToWebPage(bool))); - } - - QDeclarativeWebView *q; - - QUrl url; // page url might be different if it has not loaded yet - QWebPage *page; - QGraphicsWebView* view; - - int preferredwidth, preferredheight; - qreal progress; - QDeclarativeWebView::Status status; - QString statusText; - enum { PendingNone, PendingUrl, PendingHtml, PendingContent } pending; - QUrl pending_url; - QString pending_string; - QByteArray pending_data; - mutable QDeclarativeWebSettings settings; - QDeclarativeComponent *newWindowComponent; - QDeclarativeItem *newWindowParent; - - QBasicTimer pressTimer; - QPoint pressPoint; - int pressTime; // milliseconds before it's a "hold" - - static void windowObjects_append(QDeclarativeListProperty *prop, QObject *o) { - static_cast(prop->data)->windowObjects.append(o); - static_cast(prop->data)->updateWindowObjects(); - } - - void updateWindowObjects(); - QObjectList windowObjects; - - bool rendering; -}; - -/*! - \qmlclass WebView QDeclarativeWebView - \since 4.7 - \brief The WebView item allows you to add web content to a canvas. - \inherits Item - - A WebView renders web content based on a URL. - - This type is made available by importing the \c org.webkit module: - - \bold{import org.webkit 1.0} - - 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 for typical online web pages. - - If the width or height is explictly set, the rendered website - will be clipped, not scaled, to fit into the set dimensions. - - If the preferredWidth is set, the width will be this amount or larger, - usually laying out the web content to fit the preferredWidth. - - \qml - import org.webkit 1.0 - - WebView { - url: "http://www.nokia.com" - preferredWidth: 490 - preferredHeight: 400 - scale: 0.5 - smooth: false - smoothCache: true - } - \endqml - - \image webview.png - - The item includes no scrolling, scaling, - toolbars, etc., those must be implemented around WebView. See the WebBrowser example - for a demonstration of this. - - When this item has keyboard focus, all keyboard input will be sent directly to the - web page within. -*/ - -/*! - \internal - \class QDeclarativeWebView - \brief The QDeclarativeWebView class allows you to add web content to a QDeclarativeView. - - A WebView renders web content base on a URL. - - \image webview.png - - The item includes no scrolling, scaling, - toolbars, etc., those must be implemented around WebView. See the WebBrowser example - for a demonstration of this. - - A QDeclarativeWebView object can be instantiated in Qml using the tag \l WebView. -*/ - -QDeclarativeWebView::QDeclarativeWebView(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ - init(); -} - -QDeclarativeWebView::~QDeclarativeWebView() -{ - delete d->page; - delete d; -} - -void QDeclarativeWebView::init() -{ - d = new QDeclarativeWebViewPrivate(this); - - QWebSettings::enablePersistentStorage(); - - setAcceptHoverEvents(true); - setAcceptedMouseButtons(Qt::LeftButton); - setFlag(QGraphicsItem::ItemHasNoContents, true); - setClip(true); - - d->page = 0; - d->view = new QGraphicsWebView(this); - d->view->setResizesToContents(true); - d->view->setFlag(QGraphicsItem::ItemStacksBehindParent, true); - connect(d->view, SIGNAL(geometryChanged()), this, SLOT(updateDeclarativeWebViewSize())); - connect(d->view, SIGNAL(scaleChanged()), this, SIGNAL(contentsScaleChanged())); -} - -void QDeclarativeWebView::componentComplete() -{ - QDeclarativeItem::componentComplete(); - switch (d->pending) { - case QDeclarativeWebViewPrivate::PendingUrl: - setUrl(d->pending_url); - break; - case QDeclarativeWebViewPrivate::PendingHtml: - setHtml(d->pending_string, d->pending_url); - break; - case QDeclarativeWebViewPrivate::PendingContent: - setContent(d->pending_data, d->pending_string, d->pending_url); - break; - default: - break; - } - d->pending = QDeclarativeWebViewPrivate::PendingNone; - d->updateWindowObjects(); -} - -QDeclarativeWebView::Status QDeclarativeWebView::status() const -{ - return d->status; -} - - -/*! - \qmlproperty real WebView::progress - This property holds the progress of loading the current URL, from 0 to 1. - - If you just want to know when progress gets to 1, use - WebView::onLoadFinished() or WebView::onLoadFailed() instead. -*/ -qreal QDeclarativeWebView::progress() const -{ - return d->progress; -} - -void QDeclarativeWebView::doLoadStarted() -{ - - if (!d->url.isEmpty()) { - d->status = Loading; - emit statusChanged(d->status); - } - emit loadStarted(); -} - -void QDeclarativeWebView::doLoadProgress(int p) -{ - if (d->progress == p/100.0) - return; - d->progress = p/100.0; - emit progressChanged(); -} - -void QDeclarativeWebView::pageUrlChanged() -{ - updateContentsSize(); - - if ((d->url.isEmpty() && page()->mainFrame()->url() != QUrl(QLatin1String("about:blank"))) - || (d->url != page()->mainFrame()->url() && !page()->mainFrame()->url().isEmpty())) - { - d->url = page()->mainFrame()->url(); - if (d->url == QUrl(QLatin1String("about:blank"))) - d->url = QUrl(); - emit urlChanged(); - } -} - -void QDeclarativeWebView::doLoadFinished(bool ok) -{ - - if (title().isEmpty()) - pageUrlChanged(); // XXX bug 232556 - pages with no title never get urlChanged() - - if (ok) { - d->status = d->url.isEmpty() ? Null : Ready; - emit loadFinished(); - } else { - d->status = Error; - emit loadFailed(); - } - emit statusChanged(d->status); -} - -/*! - \qmlproperty url WebView::url - This property holds the URL to the page displayed in this item. It can be set, - but also can change spontaneously (eg. because of network redirection). - - If the url is empty, the page is blank. - - The url is always absolute (QML will resolve relative URL strings in the context - of the containing QML document). -*/ -QUrl QDeclarativeWebView::url() const -{ - return d->url; -} - -void QDeclarativeWebView::setUrl(const QUrl &url) -{ - if (url == d->url) - return; - - if (isComponentComplete()) { - d->url = url; - updateContentsSize(); - QUrl seturl = url; - if (seturl.isEmpty()) - seturl = QUrl(QLatin1String("about:blank")); - - Q_ASSERT(!seturl.isRelative()); - - page()->mainFrame()->load(seturl); - - emit urlChanged(); - } else { - d->pending = d->PendingUrl; - d->pending_url = url; - } -} - -/*! - \qmlproperty int WebView::preferredWidth - This property holds the ideal width for displaying the current URL. -*/ -int QDeclarativeWebView::preferredWidth() const -{ - return d->preferredwidth; -} - -void QDeclarativeWebView::setPreferredWidth(int iw) -{ - if (d->preferredwidth == iw) return; - d->preferredwidth = iw; - updateContentsSize(); - emit preferredWidthChanged(); -} - -/*! - \qmlproperty int WebView::preferredHeight - This property holds the ideal height for displaying the current URL. - This only affects the area zoomed by heuristicZoom(). -*/ -int QDeclarativeWebView::preferredHeight() const -{ - return d->preferredheight; -} - -void QDeclarativeWebView::setPreferredHeight(int ih) -{ - if (d->preferredheight == ih) return; - d->preferredheight = ih; - updateContentsSize(); - emit preferredHeightChanged(); -} - -/*! - \qmlmethod bool WebView::evaluateJavaScript(string) - - Evaluates the \a scriptSource JavaScript inside the context of the - main web frame, and returns the result of the last executed statement. - - Note that this JavaScript does \e not have any access to QML objects - except as made available as windowObjects. -*/ -QVariant QDeclarativeWebView::evaluateJavaScript(const QString &scriptSource) -{ - return this->page()->mainFrame()->evaluateJavaScript(scriptSource); -} - -void QDeclarativeWebView::propagateFocusToWebPage(bool hasFocus) -{ - QFocusEvent e(hasFocus ? QEvent::FocusIn : QEvent::FocusOut); - page()->event(&e); -} - -void QDeclarativeWebView::updateDeclarativeWebViewSize() -{ - QSizeF size = d->view->geometry().size() * contentsScale(); - setImplicitWidth(size.width()); - setImplicitHeight(size.height()); -} - -void QDeclarativeWebView::initialLayout() -{ - // nothing useful to do at this point -} - -void QDeclarativeWebView::updateContentsSize() -{ - if (d->page) - d->page->setPreferredContentsSize(QSize( - d->preferredwidth>0 ? d->preferredwidth : width(), - d->preferredheight>0 ? d->preferredheight : height())); -} - -void QDeclarativeWebView::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) -{ - if (newGeometry.size() != oldGeometry.size() && d->page) { - QSize cs = d->page->preferredContentsSize(); - if (widthValid()) - cs.setWidth(width()); - if (heightValid()) - cs.setHeight(height()); - if (cs != d->page->preferredContentsSize()) - d->page->setPreferredContentsSize(cs); - } - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); -} - -/*! - \qmlproperty list WebView::javaScriptWindowObjects - - A list of QML objects to expose to the web page. - - Each object will be added as a property of the web frame's window object. The - property name is controlled by the value of \c WebView.windowObjectName - attached property. - - Exposing QML objects to a web page allows JavaScript executing in the web - page itself to communicate with QML, by reading and writing properties and - by calling methods of the exposed QML objects. - - This example shows how to call into a QML method using a window object. - - \qml - WebView { - javaScriptWindowObjects: QtObject { - WebView.windowObjectName: "qml" - - function qmlCall() { - console.log("This call is in QML!"); - } - } - - html: "" - } - \endqml - - The output of the example will be: - \code - This is in WebKit! - This call is in QML! - \endcode - - If Javascript is not enabled for the page, then this property does nothing. -*/ -QDeclarativeListProperty QDeclarativeWebView::javaScriptWindowObjects() -{ - return QDeclarativeListProperty(this, d, &QDeclarativeWebViewPrivate::windowObjects_append); -} - -QDeclarativeWebViewAttached *QDeclarativeWebView::qmlAttachedProperties(QObject *o) -{ - return new QDeclarativeWebViewAttached(o); -} - -void QDeclarativeWebViewPrivate::updateWindowObjects() -{ - if (!q->isComponentCompletePublic() || !page) - return; - - for (int ii = 0; ii < windowObjects.count(); ++ii) { - QObject *object = windowObjects.at(ii); - QDeclarativeWebViewAttached *attached = static_cast(qmlAttachedPropertiesObject(object)); - if (attached && !attached->windowObjectName().isEmpty()) { - page->mainFrame()->addToJavaScriptWindowObject(attached->windowObjectName(), object); - } - } -} - -bool QDeclarativeWebView::renderingEnabled() const -{ - return d->rendering; -} - -void QDeclarativeWebView::setRenderingEnabled(bool enabled) -{ - if (d->rendering == enabled) - return; - d->rendering = enabled; - emit renderingEnabledChanged(); - - d->view->setTiledBackingStoreFrozen(!enabled); -} - -QMouseEvent *QDeclarativeWebView::sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e) -{ - QEvent::Type t; - switch(e->type()) { - default: - case QEvent::GraphicsSceneMousePress: - t = QEvent::MouseButtonPress; - break; - case QEvent::GraphicsSceneMouseRelease: - t = QEvent::MouseButtonRelease; - break; - case QEvent::GraphicsSceneMouseMove: - t = QEvent::MouseMove; - break; - case QGraphicsSceneEvent::GraphicsSceneMouseDoubleClick: - t = QEvent::MouseButtonDblClick; - break; - } - - QMouseEvent *me = new QMouseEvent(t, (e->pos()/contentsScale()).toPoint(), e->button(), e->buttons(), 0); - return me; -} - -QMouseEvent *QDeclarativeWebView::sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *e) -{ - QEvent::Type t = QEvent::MouseMove; - - QMouseEvent *me = new QMouseEvent(t, (e->pos()/contentsScale()).toPoint(), Qt::NoButton, Qt::NoButton, 0); - - return me; -} - -/*! - \qmlsignal WebView::onDoubleClick(clickx,clicky) - - The WebView does not pass double-click events to the web engine, but rather - emits this signals. -*/ - -void QDeclarativeWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -{ - QMouseEvent *me = sceneMouseEventToMouseEvent(event); - emit doubleClick(me->x(),me->y()); - delete me; -} - -/*! - \qmlmethod bool WebView::heuristicZoom(clickX,clickY,maxzoom) - - Finds a zoom that: - \list - \i shows a whole item - \i includes (\a clickX, \a clickY) - \i fits into the preferredWidth and preferredHeight - \i zooms by no more than \a maxzoom - \i is more than 10% above the current zoom - \endlist - - If such a zoom exists, emits zoomTo(zoom,centerX,centerY) and returns true; otherwise, - no signal is emitted and returns false. -*/ -bool QDeclarativeWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom) -{ - if (contentsScale() >= maxzoom/zoomFactor()) - return false; - qreal ozf = contentsScale(); - QRect showarea = elementAreaAt(clickX, clickY, d->preferredwidth/maxzoom, d->preferredheight/maxzoom); - qreal z = qMin(qreal(d->preferredwidth)/showarea.width(),qreal(d->preferredheight)/showarea.height()); - if (z > maxzoom/zoomFactor()) - z = maxzoom/zoomFactor(); - if (z/ozf > 1.2) { - QRectF r(showarea.left()*z, showarea.top()*z, showarea.width()*z, showarea.height()*z); - emit zoomTo(z,r.x()+r.width()/2, r.y()+r.height()/2); - return true; - } else { - return false; - } -} - -/*! - \qmlproperty int WebView::pressGrabTime - - The number of milliseconds the user must press before the WebView - starts passing move events through to the web engine (rather than - letting other QML elements such as a Flickable take them). - - Defaults to 400ms. Set to 0 to always grab and pass move events to - the web engine. -*/ -int QDeclarativeWebView::pressGrabTime() const -{ - return d->pressTime; -} - -void QDeclarativeWebView::setPressGrabTime(int ms) -{ - if (d->pressTime == ms) - return; - d->pressTime = ms; - emit pressGrabTimeChanged(); -} - -void QDeclarativeWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - setFocus (true); - QMouseEvent *me = sceneMouseEventToMouseEvent(event); - - d->pressPoint = me->pos(); - if (d->pressTime) { - d->pressTimer.start(d->pressTime,this); - setKeepMouseGrab(false); - } else { - grabMouse(); - setKeepMouseGrab(true); - } - - page()->event(me); - event->setAccepted( -/* - It is not correct to send the press event upwards, if it is not accepted by WebKit - e.g. push button does not work, if done so as QGraphicsScene will not send the release event at all to WebKit - Might be a bug in WebKit, though - */ -#if 1 //QT_VERSION <= 0x040500 // XXX see bug 230835 - true -#else - me->isAccepted() -#endif - ); - delete me; - if (!event->isAccepted()) { - QDeclarativeItem::mousePressEvent(event); - } -} - -void QDeclarativeWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - QMouseEvent *me = sceneMouseEventToMouseEvent(event); - page()->event(me); - d->pressTimer.stop(); - event->setAccepted( -/* - It is not correct to send the press event upwards, if it is not accepted by WebKit - e.g. push button does not work, if done so as QGraphicsScene will not send all the events to WebKit - */ -#if 1 //QT_VERSION <= 0x040500 // XXX see bug 230835 - true -#else - me->isAccepted() -#endif - ); - delete me; - if (!event->isAccepted()) { - QDeclarativeItem::mouseReleaseEvent(event); - } - setKeepMouseGrab(false); - ungrabMouse(); -} - -void QDeclarativeWebView::timerEvent(QTimerEvent *event) -{ - if (event->timerId() == d->pressTimer.timerId()) { - d->pressTimer.stop(); - grabMouse(); - setKeepMouseGrab(true); - } -} - -void QDeclarativeWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - QMouseEvent *me = sceneMouseEventToMouseEvent(event); - if (d->pressTimer.isActive()) { - if ((me->pos() - d->pressPoint).manhattanLength() > QApplication::startDragDistance()) { - d->pressTimer.stop(); - } - } - if (keepMouseGrab()) { - page()->event(me); - event->setAccepted( -/* - It is not correct to send the press event upwards, if it is not accepted by WebKit - e.g. push button does not work, if done so as QGraphicsScene will not send the release event at all to WebKit - Might be a bug in WebKit, though - */ -#if 1 // QT_VERSION <= 0x040500 // XXX see bug 230835 - true -#else - me->isAccepted() -#endif - ); - } - delete me; - if (!event->isAccepted()) - QDeclarativeItem::mouseMoveEvent(event); -} - -void QDeclarativeWebView::hoverMoveEvent (QGraphicsSceneHoverEvent * event) -{ - QMouseEvent *me = sceneHoverMoveEventToMouseEvent(event); - page()->event(me); - event->setAccepted( -#if QT_VERSION <= 0x040500 // XXX see bug 230835 - true -#else - me->isAccepted() -#endif - ); - delete me; - if (!event->isAccepted()) - QDeclarativeItem::hoverMoveEvent(event); -} - -bool QDeclarativeWebView::sceneEvent(QEvent *event) -{ - if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease)//Key events go to the page - return page()->event(event); - return QDeclarativeItem::sceneEvent(event); -} - -#ifndef QT_NO_ACTION -/*! - \qmlproperty action WebView::back - This property holds the action for causing the previous URL in the history to be displayed. -*/ -QAction *QDeclarativeWebView::backAction() const -{ - return page()->action(QWebPage::Back); -} - -/*! - \qmlproperty action WebView::forward - This property holds the action for causing the next URL in the history to be displayed. -*/ -QAction *QDeclarativeWebView::forwardAction() const -{ - return page()->action(QWebPage::Forward); -} - -/*! - \qmlproperty action WebView::reload - This property holds the action for reloading with the current URL -*/ -QAction *QDeclarativeWebView::reloadAction() const -{ - return page()->action(QWebPage::Reload); -} - -/*! - \qmlproperty action WebView::stop - This property holds the action for stopping loading with the current URL -*/ -QAction *QDeclarativeWebView::stopAction() const -{ - return page()->action(QWebPage::Stop); -} -#endif // QT_NO_ACTION - -/*! - \qmlproperty real WebView::title - This property holds the title of the web page currently viewed - - By default, this property contains an empty string. -*/ -QString QDeclarativeWebView::title() const -{ - return page()->mainFrame()->title(); -} - - - -/*! - \qmlproperty pixmap WebView::icon - This property holds the icon associated with the web page currently viewed -*/ -QPixmap QDeclarativeWebView::icon() const -{ - return page()->mainFrame()->icon().pixmap(QSize(256,256)); -} - - -/*! - \qmlproperty real WebView::zoomFactor - This property holds the multiplier used to scale the contents of a Web page. -*/ -void QDeclarativeWebView::setZoomFactor(qreal factor) -{ - if (factor == page()->mainFrame()->zoomFactor()) - return; - - page()->mainFrame()->setZoomFactor(factor); - updateContentsSize(); - - emit zoomFactorChanged(); -} - -qreal QDeclarativeWebView::zoomFactor() const -{ - return page()->mainFrame()->zoomFactor(); -} - -/*! - \qmlproperty string WebView::statusText - - This property is the current status suggested by the current web page. In a web browser, - such status is often shown in some kind of status bar. -*/ -void QDeclarativeWebView::setStatusText(const QString& s) -{ - d->statusText = s; - emit statusTextChanged(); -} - -void QDeclarativeWebView::windowObjectCleared() -{ - d->updateWindowObjects(); -} - -QString QDeclarativeWebView::statusText() const -{ - return d->statusText; -} - -QWebPage *QDeclarativeWebView::page() const -{ - - if (!d->page) { - QDeclarativeWebView *self = const_cast(this); - QWebPage *wp = new QDeclarativeWebPage(self); - - wp->setNetworkAccessManager(qmlEngine(this)->networkAccessManager()); - - self->setPage(wp); - - return wp; - } - - return d->page; -} - - -// The QObject interface to settings(). -/*! - \qmlproperty string WebView::settings.standardFontFamily - \qmlproperty string WebView::settings.fixedFontFamily - \qmlproperty string WebView::settings.serifFontFamily - \qmlproperty string WebView::settings.sansSerifFontFamily - \qmlproperty string WebView::settings.cursiveFontFamily - \qmlproperty string WebView::settings.fantasyFontFamily - - \qmlproperty int WebView::settings.minimumFontSize - \qmlproperty int WebView::settings.minimumLogicalFontSize - \qmlproperty int WebView::settings.defaultFontSize - \qmlproperty int WebView::settings.defaultFixedFontSize - - \qmlproperty bool WebView::settings.autoLoadImages - \qmlproperty bool WebView::settings.javascriptEnabled - \qmlproperty bool WebView::settings.javaEnabled - \qmlproperty bool WebView::settings.pluginsEnabled - \qmlproperty bool WebView::settings.privateBrowsingEnabled - \qmlproperty bool WebView::settings.javascriptCanOpenWindows - \qmlproperty bool WebView::settings.javascriptCanAccessClipboard - \qmlproperty bool WebView::settings.developerExtrasEnabled - \qmlproperty bool WebView::settings.linksIncludedInFocusChain - \qmlproperty bool WebView::settings.zoomTextOnly - \qmlproperty bool WebView::settings.printElementBackgrounds - \qmlproperty bool WebView::settings.offlineStorageDatabaseEnabled - \qmlproperty bool WebView::settings.offlineWebApplicationCacheEnabled - \qmlproperty bool WebView::settings.localStorageDatabaseEnabled - \qmlproperty bool WebView::settings.localContentCanAccessRemoteUrls - - These properties give access to the settings controlling the web view. - - See QWebSettings for details of these properties. - - \qml - WebView { - settings.pluginsEnabled: true - settings.standardFontFamily: "Arial" - ... - } - \endqml -*/ -QDeclarativeWebSettings *QDeclarativeWebView::settingsObject() const -{ - d->settings.s = page()->settings(); - return &d->settings; -} - -void QDeclarativeWebView::setPage(QWebPage *page) -{ - if (d->page == page) - return; - if (d->page) { - if (d->page->parent() == this) { - delete d->page; - } else { - d->page->disconnect(this); - } - } - d->page = page; - updateContentsSize(); - d->page->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff); - d->page->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff); - connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SLOT(pageUrlChanged())); - connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); - connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(iconChanged())); - connect(d->page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); - connect(d->page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout())); - connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SIGNAL(contentsSizeChanged(QSize))); - - connect(d->page,SIGNAL(loadStarted()),this,SLOT(doLoadStarted())); - connect(d->page,SIGNAL(loadProgress(int)),this,SLOT(doLoadProgress(int))); - connect(d->page,SIGNAL(loadFinished(bool)),this,SLOT(doLoadFinished(bool))); - connect(d->page,SIGNAL(statusBarMessage(QString)),this,SLOT(setStatusText(QString))); - - connect(d->page->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(windowObjectCleared())); - - d->page->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); - - d->view->setPage(page); -} - -/*! - \qmlsignal WebView::onLoadStarted() - - This handler is called when the web engine begins loading - a page. Later, WebView::onLoadFinished() or WebView::onLoadFailed() - will be emitted. -*/ - -/*! - \qmlsignal WebView::onLoadFinished() - - This handler is called when the web engine \e successfully - finishes loading a page, including any component content - (WebView::onLoadFailed() will be emitted otherwise). - - \sa progress -*/ - -/*! - \qmlsignal WebView::onLoadFailed() - - This handler is called when the web engine fails loading - a page or any component content - (WebView::onLoadFinished() will be emitted on success). -*/ - -void QDeclarativeWebView::load(const QNetworkRequest &request, - QNetworkAccessManager::Operation operation, - const QByteArray &body) -{ - page()->mainFrame()->load(request, operation, body); -} - -QString QDeclarativeWebView::html() const -{ - return page()->mainFrame()->toHtml(); -} - -/*! - \qmlproperty string WebView::html - This property holds HTML text set directly - - The html property can be set as a string. - - \qml - WebView { - html: "

This is HTML." - } - \endqml -*/ -void QDeclarativeWebView::setHtml(const QString &html, const QUrl &baseUrl) -{ - updateContentsSize(); - if (isComponentComplete()) - page()->mainFrame()->setHtml(html, baseUrl); - else { - d->pending = d->PendingHtml; - d->pending_url = baseUrl; - d->pending_string = html; - } - emit htmlChanged(); -} - -void QDeclarativeWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl) -{ - updateContentsSize(); - - if (isComponentComplete()) - page()->mainFrame()->setContent(data,mimeType,qmlContext(this)->resolvedUrl(baseUrl)); - else { - d->pending = d->PendingContent; - d->pending_url = baseUrl; - d->pending_string = mimeType; - d->pending_data = data; - } -} - -QWebHistory *QDeclarativeWebView::history() const -{ - return page()->history(); -} - -QWebSettings *QDeclarativeWebView::settings() const -{ - return page()->settings(); -} - -QDeclarativeWebView *QDeclarativeWebView::createWindow(QWebPage::WebWindowType type) -{ - switch (type) { - case QWebPage::WebBrowserWindow: { - if (!d->newWindowComponent && d->newWindowParent) - qWarning("WebView::newWindowComponent not set - WebView::newWindowParent ignored"); - else if (d->newWindowComponent && !d->newWindowParent) - qWarning("WebView::newWindowParent not set - WebView::newWindowComponent ignored"); - else if (d->newWindowComponent && d->newWindowParent) { - QDeclarativeWebView *webview = 0; - QDeclarativeContext *windowContext = new QDeclarativeContext(qmlContext(this)); - - QObject *nobj = d->newWindowComponent->create(windowContext); - if (nobj) { - windowContext->setParent(nobj); - QDeclarativeItem *item = qobject_cast(nobj); - if (!item) { - delete nobj; - } else { - webview = item->findChild(); - if (!webview) { - delete item; - } else { - nobj->setParent(d->newWindowParent); - static_cast(item)->setParentItem(d->newWindowParent); - } - } - } else { - delete windowContext; - } - - return webview; - } - } - break; - case QWebPage::WebModalDialog: { - // Not supported - } - } - return 0; -} - -/*! - \qmlproperty component WebView::newWindowComponent - - This property holds the component to use for new windows. - The component must have a WebView somewhere in its structure. - - When the web engine requests a new window, it will be an instance of - this component. - - The parent of the new window is set by newWindowParent. It must be set. -*/ -QDeclarativeComponent *QDeclarativeWebView::newWindowComponent() const -{ - return d->newWindowComponent; -} - -void QDeclarativeWebView::setNewWindowComponent(QDeclarativeComponent *newWindow) -{ - if (newWindow == d->newWindowComponent) - return; - d->newWindowComponent = newWindow; - emit newWindowComponentChanged(); -} - - -/*! - \qmlproperty item WebView::newWindowParent - - The parent item for new windows. - - \sa newWindowComponent -*/ -QDeclarativeItem *QDeclarativeWebView::newWindowParent() const -{ - return d->newWindowParent; -} - -void QDeclarativeWebView::setNewWindowParent(QDeclarativeItem *parent) -{ - if (parent == d->newWindowParent) - return; - if (d->newWindowParent && parent) { - QList children = d->newWindowParent->childItems(); - for (int i = 0; i < children.count(); ++i) { - children.at(i)->setParentItem(parent); - } - } - d->newWindowParent = parent; - emit newWindowParentChanged(); -} - -QSize QDeclarativeWebView::contentsSize() const -{ - return d->page->mainFrame()->contentsSize() * contentsScale(); -} - -qreal QDeclarativeWebView::contentsScale() const -{ - return d->view->scale(); -} - -void QDeclarativeWebView::setContentsScale(qreal scale) -{ - if (scale == d->view->scale()) - return; - d->view->setScale(scale); - updateDeclarativeWebViewSize(); - emit contentsScaleChanged(); -} - -/*! - Returns the area of the largest element at position (\a x,\a y) that is no larger - than \a maxwidth by \a maxheight pixels. - - May return an area larger in the case when no smaller element is at the position. -*/ -QRect QDeclarativeWebView::elementAreaAt(int x, int y, int maxwidth, int maxheight) const -{ - QWebHitTestResult hit = page()->mainFrame()->hitTestContent(QPoint(x,y)); - QRect rv = hit.boundingRect(); - QWebElement element = hit.enclosingBlockElement(); - if (maxwidth<=0) maxwidth = INT_MAX; - if (maxheight<=0) maxheight = INT_MAX; - while (!element.parent().isNull() && element.geometry().width() <= maxwidth && element.geometry().height() <= maxheight) { - rv = element.geometry(); - element = element.parent(); - } - return rv; -} - -/*! - \internal - \class QDeclarativeWebPage - \brief The QDeclarativeWebPage class is a QWebPage that can create QML plugins. - - \sa QDeclarativeWebView -*/ -QDeclarativeWebPage::QDeclarativeWebPage(QDeclarativeWebView *parent) : - QWebPage(parent) -{ -} - -QDeclarativeWebPage::~QDeclarativeWebPage() -{ -} - -void QDeclarativeWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) -{ - qWarning() << sourceID << ':' << lineNumber << ':' << message; -} - -QString QDeclarativeWebPage::chooseFile(QWebFrame *originatingFrame, const QString& oldFile) -{ - // Not supported (it's modal) - Q_UNUSED(originatingFrame) - Q_UNUSED(oldFile) - return oldFile; -} - -/*! - \qmlsignal WebView::onAlert(message) - - This handler is called when the web engine sends a JavaScript alert. The \a message is the text - to be displayed in the alert to the user. -*/ - - -void QDeclarativeWebPage::javaScriptAlert(QWebFrame *originatingFrame, const QString& msg) -{ - Q_UNUSED(originatingFrame) - emit viewItem()->alert(msg); -} - -bool QDeclarativeWebPage::javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg) -{ - // Not supported (it's modal) - Q_UNUSED(originatingFrame) - Q_UNUSED(msg) - return false; -} - -bool QDeclarativeWebPage::javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result) -{ - // Not supported (it's modal) - Q_UNUSED(originatingFrame) - Q_UNUSED(msg) - Q_UNUSED(defaultValue) - Q_UNUSED(result) - return false; -} - - -QDeclarativeWebView *QDeclarativeWebPage::viewItem() -{ - return static_cast(parent()); -} - -QWebPage *QDeclarativeWebPage::createWindow(WebWindowType type) -{ - QDeclarativeWebView *newView = viewItem()->createWindow(type); - if (newView) - return newView->page(); - return 0; -} - -QT_END_NAMESPACE - diff --git a/src/imports/webkit/qdeclarativewebview_p.h b/src/imports/webkit/qdeclarativewebview_p.h deleted file mode 100644 index 042237e..0000000 --- a/src/imports/webkit/qdeclarativewebview_p.h +++ /dev/null @@ -1,300 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEWEBVIEW_H -#define QDECLARATIVEWEBVIEW_H - -#include - -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -class QWebHistory; -class QWebSettings; - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QDeclarativeWebSettings; -class QDeclarativeWebViewPrivate; -class QNetworkRequest; -class QDeclarativeWebView; -class QDeclarativeWebViewPrivate; - -class QDeclarativeWebPage : public QWebPage -{ - Q_OBJECT -public: - explicit QDeclarativeWebPage(QDeclarativeWebView *parent); - ~QDeclarativeWebPage(); -protected: - QWebPage *createWindow(WebWindowType type); - void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID); - QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile); - void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg); - bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg); - bool javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result); - -private: - QDeclarativeWebView *viewItem(); -}; - - -class QDeclarativeWebViewAttached; - -//### TODO: browser plugins - -class QDeclarativeWebView : public QDeclarativeItem -{ - Q_OBJECT - - Q_ENUMS(Status SelectionMode) - - Q_PROPERTY(QString title READ title NOTIFY titleChanged) - Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged) - Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) - Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged) - - Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged) - - Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime NOTIFY pressGrabTimeChanged) - - Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged) - Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged) - Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) - Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - -#ifndef QT_NO_ACTION - Q_PROPERTY(QAction* reload READ reloadAction CONSTANT) - Q_PROPERTY(QAction* back READ backAction CONSTANT) - Q_PROPERTY(QAction* forward READ forwardAction CONSTANT) - Q_PROPERTY(QAction* stop READ stopAction CONSTANT) -#endif - - Q_PROPERTY(QDeclarativeWebSettings* settings READ settingsObject CONSTANT) - - Q_PROPERTY(QDeclarativeListProperty javaScriptWindowObjects READ javaScriptWindowObjects CONSTANT) - - Q_PROPERTY(QDeclarativeComponent* newWindowComponent READ newWindowComponent WRITE setNewWindowComponent NOTIFY newWindowComponentChanged) - Q_PROPERTY(QDeclarativeItem* newWindowParent READ newWindowParent WRITE setNewWindowParent NOTIFY newWindowParentChanged) - - Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged) - - Q_PROPERTY(QSize contentsSize READ contentsSize NOTIFY contentsSizeChanged) - Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged) - -public: - QDeclarativeWebView(QDeclarativeItem *parent=0); - ~QDeclarativeWebView(); - - QUrl url() const; - void setUrl(const QUrl &); - - QString title() const; - - QPixmap icon() const; - - qreal zoomFactor() const; - void setZoomFactor(qreal); - Q_INVOKABLE bool heuristicZoom(int clickX, int clickY, qreal maxzoom); - QRect elementAreaAt(int x, int y, int minwidth, int minheight) const; - - int pressGrabTime() const; - void setPressGrabTime(int); - - int preferredWidth() const; - void setPreferredWidth(int); - int preferredHeight() const; - void setPreferredHeight(int); - - enum Status { Null, Ready, Loading, Error }; - Status status() const; - qreal progress() const; - QString statusText() const; - -#ifndef QT_NO_ACTION - QAction *reloadAction() const; - QAction *backAction() const; - QAction *forwardAction() const; - QAction *stopAction() const; -#endif - - QWebPage *page() const; - void setPage(QWebPage *page); - - void load(const QNetworkRequest &request, - QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, - const QByteArray &body = QByteArray()); - - QString html() const; - - void setHtml(const QString &html, const QUrl &baseUrl = QUrl()); - void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl()); - - QWebHistory *history() const; - QWebSettings *settings() const; - QDeclarativeWebSettings *settingsObject() const; - - bool renderingEnabled() const; - void setRenderingEnabled(bool); - - QDeclarativeListProperty javaScriptWindowObjects(); - - static QDeclarativeWebViewAttached *qmlAttachedProperties(QObject *); - - QDeclarativeComponent *newWindowComponent() const; - void setNewWindowComponent(QDeclarativeComponent *newWindow); - QDeclarativeItem *newWindowParent() const; - void setNewWindowParent(QDeclarativeItem *newWindow); - - bool isComponentCompletePublic() const { return isComponentComplete(); } - - QSize contentsSize() const; - - void setContentsScale(qreal scale); - qreal contentsScale() const; - -Q_SIGNALS: - void preferredWidthChanged(); - void preferredHeightChanged(); - void urlChanged(); - void progressChanged(); - void statusChanged(Status); - void titleChanged(const QString&); - void iconChanged(); - void statusTextChanged(); - void htmlChanged(); - void pressGrabTimeChanged(); - void zoomFactorChanged(); - void newWindowComponentChanged(); - void newWindowParentChanged(); - void renderingEnabledChanged(); - void contentsSizeChanged(const QSize&); - void contentsScaleChanged(); - - void loadStarted(); - void loadFinished(); - void loadFailed(); - - void doubleClick(int clickX, int clickY); - - void zoomTo(qreal zoom, int centerX, int centerY); - - void alert(const QString& message); - -public Q_SLOTS: - QVariant evaluateJavaScript(const QString&); - -private Q_SLOTS: - void doLoadStarted(); - void doLoadProgress(int p); - void doLoadFinished(bool ok); - void setStatusText(const QString&); - void windowObjectCleared(); - void pageUrlChanged(); - void initialLayout(); - - void propagateFocusToWebPage(bool); - - void updateDeclarativeWebViewSize(); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); - void timerEvent(QTimerEvent *event); - void hoverMoveEvent (QGraphicsSceneHoverEvent * event); - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - virtual bool sceneEvent(QEvent *event); - QDeclarativeWebView *createWindow(QWebPage::WebWindowType type); - -private: - void updateContentsSize(); - void init(); - virtual void componentComplete(); - Q_DISABLE_COPY(QDeclarativeWebView) - QDeclarativeWebViewPrivate* d; - QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *); - QMouseEvent *sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *); - friend class QDeclarativeWebPage; -}; - -class QDeclarativeWebViewAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName) -public: - QDeclarativeWebViewAttached(QObject *parent) - : QObject(parent) - { - } - - QString windowObjectName() const - { - return m_windowObjectName; - } - - void setWindowObjectName(const QString &n) - { - m_windowObjectName = n; - } - -private: - QString m_windowObjectName; -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeWebView) -QML_DECLARE_TYPEINFO(QDeclarativeWebView, QML_HAS_ATTACHED_PROPERTIES) - -QT_END_HEADER - -#endif diff --git a/src/imports/webkit/qdeclarativewebview_p_p.h b/src/imports/webkit/qdeclarativewebview_p_p.h deleted file mode 100644 index 258b472..0000000 --- a/src/imports/webkit/qdeclarativewebview_p_p.h +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEWEBVIEW_P_H -#define QDECLARATIVEWEBVIEW_P_H - -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeWebSettings : public QObject { - Q_OBJECT - - Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily) - Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily) - Q_PROPERTY(QString serifFontFamily READ serifFontFamily WRITE setSerifFontFamily) - Q_PROPERTY(QString sansSerifFontFamily READ sansSerifFontFamily WRITE setSansSerifFontFamily) - Q_PROPERTY(QString cursiveFontFamily READ cursiveFontFamily WRITE setCursiveFontFamily) - Q_PROPERTY(QString fantasyFontFamily READ fantasyFontFamily WRITE setFantasyFontFamily) - - Q_PROPERTY(int minimumFontSize READ minimumFontSize WRITE setMinimumFontSize) - Q_PROPERTY(int minimumLogicalFontSize READ minimumLogicalFontSize WRITE setMinimumLogicalFontSize) - Q_PROPERTY(int defaultFontSize READ defaultFontSize WRITE setDefaultFontSize) - Q_PROPERTY(int defaultFixedFontSize READ defaultFixedFontSize WRITE setDefaultFixedFontSize) - - Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages) - Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled) - Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled) - Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled) - Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled) - Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows) - Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard) - Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled) - Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain) - Q_PROPERTY(bool zoomTextOnly READ zoomTextOnly WRITE setZoomTextOnly) - Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds) - Q_PROPERTY(bool offlineStorageDatabaseEnabled READ offlineStorageDatabaseEnabled WRITE setOfflineStorageDatabaseEnabled) - Q_PROPERTY(bool offlineWebApplicationCacheEnabled READ offlineWebApplicationCacheEnabled WRITE setOfflineWebApplicationCacheEnabled) - Q_PROPERTY(bool localStorageDatabaseEnabled READ localStorageDatabaseEnabled WRITE setLocalStorageDatabaseEnabled) - Q_PROPERTY(bool localContentCanAccessRemoteUrls READ localContentCanAccessRemoteUrls WRITE setLocalContentCanAccessRemoteUrls) - -public: - QDeclarativeWebSettings() {} - - QString standardFontFamily() const { return s->fontFamily(QWebSettings::StandardFont); } - void setStandardFontFamily(const QString& f) { s->setFontFamily(QWebSettings::StandardFont,f); } - QString fixedFontFamily() const { return s->fontFamily(QWebSettings::FixedFont); } - void setFixedFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FixedFont,f); } - QString serifFontFamily() const { return s->fontFamily(QWebSettings::SerifFont); } - void setSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SerifFont,f); } - QString sansSerifFontFamily() const { return s->fontFamily(QWebSettings::SansSerifFont); } - void setSansSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SansSerifFont,f); } - QString cursiveFontFamily() const { return s->fontFamily(QWebSettings::CursiveFont); } - void setCursiveFontFamily(const QString& f) { s->setFontFamily(QWebSettings::CursiveFont,f); } - QString fantasyFontFamily() const { return s->fontFamily(QWebSettings::FantasyFont); } - void setFantasyFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FantasyFont,f); } - - int minimumFontSize() const { return s->fontSize(QWebSettings::MinimumFontSize); } - void setMinimumFontSize(int size) { s->setFontSize(QWebSettings::MinimumFontSize,size); } - int minimumLogicalFontSize() const { return s->fontSize(QWebSettings::MinimumLogicalFontSize); } - void setMinimumLogicalFontSize(int size) { s->setFontSize(QWebSettings::MinimumLogicalFontSize,size); } - int defaultFontSize() const { return s->fontSize(QWebSettings::DefaultFontSize); } - void setDefaultFontSize(int size) { s->setFontSize(QWebSettings::DefaultFontSize,size); } - int defaultFixedFontSize() const { return s->fontSize(QWebSettings::DefaultFixedFontSize); } - void setDefaultFixedFontSize(int size) { s->setFontSize(QWebSettings::DefaultFixedFontSize,size); } - - bool autoLoadImages() const { return s->testAttribute(QWebSettings::AutoLoadImages); } - void setAutoLoadImages(bool on) { s->setAttribute(QWebSettings::AutoLoadImages, on); } - bool javascriptEnabled() const { return s->testAttribute(QWebSettings::JavascriptEnabled); } - void setJavascriptEnabled(bool on) { s->setAttribute(QWebSettings::JavascriptEnabled, on); } - bool javaEnabled() const { return s->testAttribute(QWebSettings::JavaEnabled); } - void setJavaEnabled(bool on) { s->setAttribute(QWebSettings::JavaEnabled, on); } - bool pluginsEnabled() const { return s->testAttribute(QWebSettings::PluginsEnabled); } - void setPluginsEnabled(bool on) { s->setAttribute(QWebSettings::PluginsEnabled, on); } - bool privateBrowsingEnabled() const { return s->testAttribute(QWebSettings::PrivateBrowsingEnabled); } - void setPrivateBrowsingEnabled(bool on) { s->setAttribute(QWebSettings::PrivateBrowsingEnabled, on); } - bool javascriptCanOpenWindows() const { return s->testAttribute(QWebSettings::JavascriptCanOpenWindows); } - void setJavascriptCanOpenWindows(bool on) { s->setAttribute(QWebSettings::JavascriptCanOpenWindows, on); } - bool javascriptCanAccessClipboard() const { return s->testAttribute(QWebSettings::JavascriptCanAccessClipboard); } - void setJavascriptCanAccessClipboard(bool on) { s->setAttribute(QWebSettings::JavascriptCanAccessClipboard, on); } - bool developerExtrasEnabled() const { return s->testAttribute(QWebSettings::DeveloperExtrasEnabled); } - void setDeveloperExtrasEnabled(bool on) { s->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); } - bool linksIncludedInFocusChain() const { return s->testAttribute(QWebSettings::LinksIncludedInFocusChain); } - void setLinksIncludedInFocusChain(bool on) { s->setAttribute(QWebSettings::LinksIncludedInFocusChain, on); } - bool zoomTextOnly() const { return s->testAttribute(QWebSettings::ZoomTextOnly); } - void setZoomTextOnly(bool on) { s->setAttribute(QWebSettings::ZoomTextOnly, on); } - bool printElementBackgrounds() const { return s->testAttribute(QWebSettings::PrintElementBackgrounds); } - void setPrintElementBackgrounds(bool on) { s->setAttribute(QWebSettings::PrintElementBackgrounds, on); } - bool offlineStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::OfflineStorageDatabaseEnabled); } - void setOfflineStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, on); } - bool offlineWebApplicationCacheEnabled() const { return s->testAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); } - void setOfflineWebApplicationCacheEnabled(bool on) { s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, on); } - bool localStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::LocalStorageDatabaseEnabled); } - void setLocalStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, on); } - bool localContentCanAccessRemoteUrls() const { return s->testAttribute(QWebSettings::LocalContentCanAccessRemoteUrls); } - void setLocalContentCanAccessRemoteUrls(bool on) { s->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, on); } - - QWebSettings *s; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeWebSettings) - -QT_END_HEADER - -#endif diff --git a/src/imports/webkit/qmldir b/src/imports/webkit/qmldir deleted file mode 100644 index dcfdd06..0000000 --- a/src/imports/webkit/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmlwebkitplugin diff --git a/src/imports/webkit/webkit.pro b/src/imports/webkit/webkit.pro deleted file mode 100644 index 7b2ac66..0000000 --- a/src/imports/webkit/webkit.pro +++ /dev/null @@ -1,27 +0,0 @@ -TARGET = qmlwebkitplugin -TARGETPATH = org/webkit -include(../qimportbase.pri) - -QT += webkit declarative - -SOURCES += qdeclarativewebview.cpp plugin.cpp -HEADERS += qdeclarativewebview_p.h \ - qdeclarativewebview_p_p.h - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -symbian:{ - load(data_caging_paths) - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - - importFiles.sources = qmlwebkitplugin.dll qmldir - importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH - - DEPLOYMENT = importFiles -} - -INSTALLS += target qmldir diff --git a/src/src.pro b/src/src.pro index 3ac69be..0d7404d 100644 --- a/src/src.pro +++ b/src/src.pro @@ -27,6 +27,7 @@ contains(QT_CONFIG, script): SRC_SUBDIRS += src_script contains(QT_CONFIG, declarative): SRC_SUBDIRS += src_declarative SRC_SUBDIRS += src_plugins contains(QT_CONFIG, declarative): SRC_SUBDIRS += src_imports +contains(QT_CONFIG, declarative):contains(QT_CONFIG, webkit): SRC_SUBDIRS += src_webkit_declarative # s60installs need to be at the end, because projects.pro does an ordered build, # and s60installs depends on all the others. @@ -82,6 +83,8 @@ src_webkit.subdir = $$QT_SOURCE_TREE/src/3rdparty/webkit/WebCore src_webkit.target = sub-webkit src_declarative.subdir = $$QT_SOURCE_TREE/src/declarative src_declarative.target = sub-declarative +src_webkit_declarative.subdir = $$QT_SOURCE_TREE/src/3rdparty/webkit/WebKit/qt/declarative +src_webkit_declarative.target = sub-webkitdeclarative #CONFIG += ordered !wince*:!ordered:!symbian-abld:!symbian-sbsv2 { @@ -133,6 +136,7 @@ src_declarative.target = sub-declarative contains(QT_CONFIG, svg) { src_declarative.depends += src_svg } + contains(QT_CONFIG, webkit) : contains(QT_CONFIG, declarative): src_webkit_declarative.depends = src_declarative src_webkit } -- cgit v0.12 From 52590f355b2a17f65eea74b604bf921647704561 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 18 Jun 2010 14:41:37 +0200 Subject: Updated WebKit to a99218d1984be36e00966f988123fa7e2b18eec5 Doc and build fixes: http://trac.webkit.org/changeset/61400 --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 10 ++++++++++ .../webkit/WebKit/qt/declarative/qdeclarativewebview.cpp | 6 ++++-- .../webkit/WebKit/qt/declarative/qdeclarativewebview_p.h | 4 ++++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index c7b77a6..c139c28 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -d7a095a2a9514e1f132b779b99279585820b46f5 +a99218d1984be36e00966f988123fa7e2b18eec5 diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index dc50465..da5c1dc 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - d7a095a2a9514e1f132b779b99279585820b46f5 + a99218d1984be36e00966f988123fa7e2b18eec5 diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 987dc12..2057c7e 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -2,6 +2,16 @@ Reviewed by Simon Hausmann. + Fix documentation issue on the onAlert handler. + Fix compilation issue with QT_NO_ACTION. + + * declarative/qdeclarativewebview.cpp: + * declarative/qdeclarativewebview_p.h: + +2010-06-18 Alexis Menard + + Reviewed by Simon Hausmann. + [Qt] Change the target path to QtWebKit. * declarative/declarative.pro: diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp index 0d2800f..263b42a 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -571,6 +571,7 @@ void QDeclarativeWebView::setPressGrabTime(int millis) emit pressGrabTimeChanged(); } +#ifndef QT_NO_ACTION /*! \qmlproperty action WebView::back This property holds the action for causing the previous URL in the history to be displayed. @@ -606,6 +607,7 @@ QAction* QDeclarativeWebView::stopAction() const { return page()->action(QWebPage::Stop); } +#endif // QT_NO_ACTION /*! \qmlproperty real WebView::title @@ -971,9 +973,9 @@ QString QDeclarativeWebPage::chooseFile(QWebFrame* originatingFrame, const QStri } /*! - \qmlsignal WebView::alert(message) + \qmlsignal WebView::onAlert(message) - This signal is emitted when the web engine sends a JavaScript alert. The \a message is the text + The handler is called when the web engine sends a JavaScript alert. The \a message is the text to be displayed in the alert to the user. */ diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h index 3c3f889..b2055bf 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview_p.h @@ -103,10 +103,12 @@ class QDeclarativeWebView : public QDeclarativeItem { Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) +#ifndef QT_NO_ACTION Q_PROPERTY(QAction* reload READ reloadAction CONSTANT) Q_PROPERTY(QAction* back READ backAction CONSTANT) Q_PROPERTY(QAction* forward READ forwardAction CONSTANT) Q_PROPERTY(QAction* stop READ stopAction CONSTANT) +#endif Q_PROPERTY(QDeclarativeWebSettings* settings READ settingsObject CONSTANT) @@ -147,10 +149,12 @@ public: qreal progress() const; QString statusText() const; +#ifndef QT_NO_ACTION QAction *reloadAction() const; QAction *backAction() const; QAction *forwardAction() const; QAction *stopAction() const; +#endif QWebPage *page() const; void setPage(QWebPage *page); -- cgit v0.12 From a78d53f430cac6d1624446e5bc0f90081f513fb6 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 18 Jun 2010 15:06:31 +0200 Subject: Updated WebKit to e32cb21d4f1787147bcb681883b96a95f867749a Integrated changes: || || Impossible to set input method hints based HTML5 input types || || || WebCore EventHandler needs to take account of onLoad events fired before layout() complete || || || REGRESSION(r60958) [Qt] qwebpage::inputMethods auto-test fails || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 35 ++++++++++ .../webkit/WebCore/html/HTMLInputElement.h | 4 ++ src/3rdparty/webkit/WebCore/page/EventHandler.cpp | 3 + src/3rdparty/webkit/WebKit/qt/ChangeLog | 40 ++++++++++++ .../WebKit/qt/WebCoreSupport/EditorClientQt.cpp | 33 ++++++---- .../qgraphicswebview/resources/input_types.html | 8 +++ .../qgraphicswebview/tst_qgraphicswebview.cpp | 76 ++++++++++++++++++++++ .../qgraphicswebview/tst_qgraphicswebview.qrc | 6 ++ .../qt/tests/qwebview/resources/input_types.html | 8 +++ .../WebKit/qt/tests/qwebview/tst_qwebview.cpp | 63 +++++++++++++++++- .../WebKit/qt/tests/qwebview/tst_qwebview.qrc | 1 + 13 files changed, 265 insertions(+), 16 deletions(-) create mode 100644 src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/resources/input_types.html create mode 100644 src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc create mode 100644 src/3rdparty/webkit/WebKit/qt/tests/qwebview/resources/input_types.html diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index c139c28..17ba8d7 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -a99218d1984be36e00966f988123fa7e2b18eec5 +e32cb21d4f1787147bcb681883b96a95f867749a diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index da5c1dc..6ba3221 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - a99218d1984be36e00966f988123fa7e2b18eec5 + e32cb21d4f1787147bcb681883b96a95f867749a diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index c17a8aa..3113efe 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,38 @@ +2010-06-13 Robert Hogan + + Reviewed by Kenneth Rohde Christiansen. + + WebCore EventHandler needs to take account of onLoad events + fired before layout() complete + + https://bugs.webkit.org/show_bug.cgi?id=40102 + + WebCore 'cheats' by firing onLoad events before the frame's layout + has been performed. This can result in event listeners performing + operations that depend on the document's final layout, such as + scrolling operations. + + When scrolling a frameview in eventhandler ensure the layout is complete. + + * page/EventHandler.cpp: + (WebCore::EventHandler::scrollRecursively): + +2010-06-10 Raine Makelainen + + Reviewed by Kenneth Rohde Christiansen. + + Impossible to set input method hints based HTML5 input types + https://bugs.webkit.org/show_bug.cgi?id=40107 + + Helper methods for checking "tel", "number", "email", + and "url" input element types. + + * html/HTMLInputElement.h: + (WebCore::HTMLInputElement::isTelephoneField): + (WebCore::HTMLInputElement::isNumberField): + (WebCore::HTMLInputElement::isEmailField): + (WebCore::HTMLInputElement::isUrlField): + 2010-06-17 Mark Brand Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h index c3b0a73..087cffa 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h +++ b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h @@ -128,6 +128,10 @@ public: virtual bool isSearchField() const { return m_type == SEARCH; } virtual bool isInputTypeHidden() const { return m_type == HIDDEN; } virtual bool isPasswordField() const { return m_type == PASSWORD; } + bool isTelephoneField() const { return m_type == TELEPHONE; } + bool isNumberField() const { return m_type == NUMBER; } + bool isEmailField() const { return m_type == EMAIL; } + bool isUrlField() const { return m_type == URL; } bool checked() const { return m_checked; } void setChecked(bool, bool sendChangeEvent = false); diff --git a/src/3rdparty/webkit/WebCore/page/EventHandler.cpp b/src/3rdparty/webkit/WebCore/page/EventHandler.cpp index c40299c..1654257 100644 --- a/src/3rdparty/webkit/WebCore/page/EventHandler.cpp +++ b/src/3rdparty/webkit/WebCore/page/EventHandler.cpp @@ -952,6 +952,9 @@ bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity g bool EventHandler::scrollRecursively(ScrollDirection direction, ScrollGranularity granularity, Node* startingNode) { + // The layout needs to be up to date to determine if we can scroll. We may be + // here because of an onLoad event, in which case the final layout hasn't been performed yet. + m_frame->document()->updateLayoutIgnorePendingStylesheets(); bool handled = scrollOverflow(direction, granularity, startingNode); if (!handled) { Frame* frame = m_frame; diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 2057c7e..d77267b 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,43 @@ +2010-06-18 Simon Hausmann + + Reviewed by Antti Koivisto. + + REGRESSION(r60958) [Qt] qwebpage::inputMethods auto-test fails + https://bugs.webkit.org/show_bug.cgi?id=40830 + + When activating a regular input method field, always set or unset the ImhHiddenText + input method hint. + + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::setInputMethodState): + +2010-06-10 Raine Makelainen + + Reviewed by Kenneth Rohde Christiansen. + + Impossible to set input method hints based HTML5 input types + https://bugs.webkit.org/show_bug.cgi?id=40107 + + EditorClientQt to set input method hints for "number", "tel", + "email", and "url" HTML input elements. + + Tests for HTML input elements and input method hints added for + QGraphicsWebView and QWebView. + + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::setInputMethodState): + * tests/qgraphicswebview/resources/input_types.html: Added. + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (GraphicsWebView::GraphicsWebView): + (GraphicsWebView::fireMouseClick): + (tst_QGraphicsWebView::focusInputTypes): + * tests/qgraphicswebview/tst_qgraphicswebview.qrc: Added. + * tests/qwebview/resources/input_types.html: Added. + * tests/qwebview/tst_qwebview.cpp: + (WebView::fireMouseClick): + (tst_QWebView::focusInputTypes): + * tests/qwebview/tst_qwebview.qrc: + 2010-06-18 Alexis Menard Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/EditorClientQt.cpp index 0ce6383..1cebef7 100644 --- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/EditorClientQt.cpp +++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/EditorClientQt.cpp @@ -599,20 +599,29 @@ void EditorClientQt::setInputMethodState(bool active) QWebPageClient* webPageClient = m_page->d->client; if (webPageClient) { #if QT_VERSION >= 0x040600 - bool isPasswordField = false; - if (!active) { - // Setting the Qt::WA_InputMethodEnabled attribute true and Qt::ImhHiddenText flag - // for password fields. The Qt platform is responsible for determining which widget - // will receive input method events for password fields. - Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame(); - if (frame && frame->document() && frame->document()->focusedNode()) { - if (frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag)) { - HTMLInputElement* inputElement = static_cast(frame->document()->focusedNode()); - active = isPasswordField = inputElement->isPasswordField(); - } + HTMLInputElement* inputElement = 0; + Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame(); + if (frame && frame->document() && frame->document()->focusedNode()) + if (frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag)) + inputElement = static_cast(frame->document()->focusedNode()); + + if (inputElement) { + if (!active) { + // Setting the Qt::WA_InputMethodEnabled attribute true and Qt::ImhHiddenText flag + // for password fields. The Qt platform is responsible for determining which widget + // will receive input method events for password fields. + active = inputElement->isPasswordField(); + webPageClient->setInputMethodHint(Qt::ImhHiddenText, active); + } else { + // Set input method hints for "number", "tel", "email", and "url" input elements. + webPageClient->setInputMethodHint(Qt::ImhDialableCharactersOnly, inputElement->isTelephoneField()); + webPageClient->setInputMethodHint(Qt::ImhDigitsOnly, inputElement->isNumberField()); + webPageClient->setInputMethodHint(Qt::ImhEmailCharactersOnly, inputElement->isEmailField()); + webPageClient->setInputMethodHint(Qt::ImhUrlCharactersOnly, inputElement->isUrlField()); + webPageClient->setInputMethodHint(Qt::ImhHiddenText, inputElement->isPasswordField()); } } - webPageClient->setInputMethodHint(Qt::ImhHiddenText, isPasswordField); + #if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) // disables auto-uppercase and predictive text for mobile devices webPageClient->setInputMethodHint(Qt::ImhNoAutoUppercase, true); diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/resources/input_types.html b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/resources/input_types.html new file mode 100644 index 0000000..18ab314 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/resources/input_types.html @@ -0,0 +1,8 @@ + +
+
+
+
+
+
" + \ No newline at end of file diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp index ebe847d..e06524d 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp @@ -19,6 +19,7 @@ #include "../util.h" #include +#include #include #include #include @@ -32,6 +33,7 @@ private slots: void qgraphicswebview(); void crashOnViewlessWebPages(); void microFocusCoordinates(); + void focusInputTypes(); }; void tst_QGraphicsWebView::qgraphicswebview() @@ -75,6 +77,29 @@ private slots: } }; +class GraphicsWebView : public QGraphicsWebView +{ + Q_OBJECT + +public: + GraphicsWebView(QGraphicsItem* parent = 0): QGraphicsWebView(parent) + { + } + + void fireMouseClick(QPointF point) { + QGraphicsSceneMouseEvent presEv(QEvent::GraphicsSceneMousePress); + presEv.setPos(point); + presEv.setButton(Qt::LeftButton); + presEv.setButtons(Qt::LeftButton); + QGraphicsSceneMouseEvent relEv(QEvent::GraphicsSceneMouseRelease); + relEv.setPos(point); + relEv.setButton(Qt::LeftButton); + relEv.setButtons(Qt::LeftButton); + QGraphicsWebView::sceneEvent(&presEv); + QGraphicsWebView::sceneEvent(&relEv); + } +}; + void tst_QGraphicsWebView::crashOnViewlessWebPages() { QGraphicsScene scene; @@ -140,6 +165,57 @@ void tst_QGraphicsWebView::microFocusCoordinates() delete view; } +void tst_QGraphicsWebView::focusInputTypes() +{ + QWebPage* page = new QWebPage; + GraphicsWebView* webView = new GraphicsWebView; + webView->setPage( page ); + QGraphicsView* view = new QGraphicsView; + QGraphicsScene* scene = new QGraphicsScene(view); + view->setScene(scene); + scene->addItem(webView); + view->setGeometry(QRect(0,0,500,500)); + QCoreApplication::processEvents(); + QUrl url("qrc:///resources/input_types.html"); + page->mainFrame()->load(url); + page->mainFrame()->setFocus(); + + QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); + + // 'text' type + webView->fireMouseClick(QPointF(20.0, 10.0)); +#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) + QVERIFY(webView->inputMethodHints() & Qt::ImhNoAutoUppercase); + QVERIFY(webView->inputMethodHints() & Qt::ImhNoPredictiveText); +#else + QVERIFY(webView->inputMethodHints() == Qt::ImhNone); +#endif + + // 'password' field + webView->fireMouseClick(QPointF(20.0, 60.0)); + QVERIFY(webView->inputMethodHints() & Qt::ImhHiddenText); + + // 'tel' field + webView->fireMouseClick(QPointF(20.0, 110.0)); + QVERIFY(webView->inputMethodHints() & Qt::ImhDialableCharactersOnly); + + // 'number' field + webView->fireMouseClick(QPointF(20.0, 160.0)); + QVERIFY(webView->inputMethodHints() & Qt::ImhDigitsOnly); + + // 'email' field + webView->fireMouseClick(QPointF(20.0, 210.0)); + QVERIFY(webView->inputMethodHints() & Qt::ImhEmailCharactersOnly); + + // 'url' field + webView->fireMouseClick(QPointF(20.0, 260.0)); + QVERIFY(webView->inputMethodHints() & Qt::ImhUrlCharactersOnly); + + delete webView; + delete view; +} + + QTEST_MAIN(tst_QGraphicsWebView) diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc new file mode 100644 index 0000000..c91bb9c --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc @@ -0,0 +1,6 @@ + + + resources/input_types.html + + + diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/resources/input_types.html b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/resources/input_types.html new file mode 100644 index 0000000..18ab314 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/resources/input_types.html @@ -0,0 +1,8 @@ + +
+
+
+
+
+
" + \ No newline at end of file diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp index 100399e..835ad82 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp @@ -30,8 +30,6 @@ #include #include -#include - class tst_QWebView : public QObject { Q_OBJECT @@ -49,10 +47,25 @@ private slots: void reusePage_data(); void reusePage(); void microFocusCoordinates(); + void focusInputTypes(); void crashTests(); }; +class WebView : public QWebView +{ + Q_OBJECT + +public: + void fireMouseClick(QPoint point) { + QMouseEvent presEv(QEvent::MouseButtonPress, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QMouseEvent relEv(QEvent::MouseButtonRelease, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QWebView::mousePressEvent(&presEv); + QWebView::mousePressEvent(&relEv); + } + +}; + // This will be called before the first test function is executed. // It is only called once. void tst_QWebView::initTestCase() @@ -230,6 +243,52 @@ void tst_QWebView::microFocusCoordinates() QCOMPARE(initialMicroFocus.toRect().translated(QPoint(0,-50)), currentMicroFocus.toRect()); } +void tst_QWebView::focusInputTypes() +{ + QWebPage* page = new QWebPage; + WebView* webView = new WebView; + webView->setPage( page ); + + QCoreApplication::processEvents(); + QUrl url("qrc:///resources/input_types.html"); + page->mainFrame()->load(url); + page->mainFrame()->setFocus(); + + QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); + + // 'text' type + webView->fireMouseClick(QPoint(20, 10)); +#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) + QVERIFY(webView->inputMethodHints() & Qt::ImhNoAutoUppercase); + QVERIFY(webView->inputMethodHints() & Qt::ImhNoPredictiveText); +#else + QVERIFY(webView->inputMethodHints() == Qt::ImhNone); +#endif + + // 'password' field + webView->fireMouseClick(QPoint(20, 60)); + QVERIFY(webView->inputMethodHints() & Qt::ImhHiddenText); + + // 'tel' field + webView->fireMouseClick(QPoint(20, 110)); + QVERIFY(webView->inputMethodHints() & Qt::ImhDialableCharactersOnly); + + // 'number' field + webView->fireMouseClick(QPoint(20, 160)); + QVERIFY(webView->inputMethodHints() & Qt::ImhDigitsOnly); + + // 'email' field + webView->fireMouseClick(QPoint(20, 210)); + QVERIFY(webView->inputMethodHints() & Qt::ImhEmailCharactersOnly); + + // 'url' field + webView->fireMouseClick(QPoint(20, 260)); + QVERIFY(webView->inputMethodHints() & Qt::ImhUrlCharactersOnly); + + delete webView; + +} + QTEST_MAIN(tst_QWebView) #include "tst_qwebview.moc" diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.qrc b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.qrc index 5abc64c..8710a9a 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.qrc +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.qrc @@ -2,6 +2,7 @@ resources/index.html resources/frame_a.html + resources/input_types.html -- cgit v0.12 From 35d4b2558f79d971d49ed3b86e6e48a349f948a1 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Fri, 18 Jun 2010 15:19:52 +0200 Subject: Update qmlchanges from import org.webkit to QtWebKit Reviewed-by:TrustMe --- src/declarative/QmlChanges.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 8b6b83f..432b5d6 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -50,7 +50,7 @@ Removed Qt.playSound (replaced by SoundEffect element) Removed Qt.closestAngle (use RotationAnimation instead) Removed NumberFormatter Removed DateTimeFormatter (use Qt.formatDateTime() instead) -Using WebView now requires "import org.webkit 1.0" +Using WebView now requires "import QtWebKit 1.0" Using Particles now requires "import Qt.labs.particles 1.0" AnchorAnimation must now be used to animate anchor changes (and not NumberAnimation) Removed ParentAction (use ParentAnimation instead) -- cgit v0.12 From d0b68442682382414527024b3e86f87dc8597c9c Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Fri, 18 Jun 2010 15:33:48 +0200 Subject: Update S60 stuff after renaming the webkit component. The new name is QtWebKit not org.webkit. Reviewed-by:jbarron --- src/s60installs/qt.iby | 4 ++-- src/s60installs/s60installs.pro | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/s60installs/qt.iby b/src/s60installs/qt.iby index f43f344..935bdc5 100644 --- a/src/s60installs/qt.iby +++ b/src/s60installs/qt.iby @@ -80,12 +80,12 @@ file=ABI_DIR\BUILD_DIR\qmlfolderlistmodelplugin.dll SHARED_LIB_DIR\qmlfolde file=ABI_DIR\BUILD_DIR\qmlgesturesplugin.dll SHARED_LIB_DIR\qmlgesturesplugin.dll file=ABI_DIR\BUILD_DIR\qmlparticlesplugin.dll SHARED_LIB_DIR\qmlparticlesplugin.dll -data=\epoc32\data\z\resource\qt\imports\org\webkit\qmlwebkitplugin.qtplugin resource\qt\imports\org\webkit\qmlwebkitplugin.qtplugin +data=\epoc32\data\z\resource\qt\imports\QtWebKit\qmlwebkitplugin.qtplugin resource\qt\imports\QtWebKit\qmlwebkitplugin.qtplugin data=\epoc32\data\z\resource\qt\imports\Qt\labs\folderlistmodel\qmlfolderlistmodelplugin.qtplugin resource\qt\imports\Qt\labs\folderlistmodel\qmlfolderlistmodelplugin.qtplugin data=\epoc32\data\z\resource\qt\imports\Qt\labs\gestures\qmlgesturesplugin.qtplugin resource\qt\imports\Qt\labs\gestures\qmlgesturesplugin.qtplugin data=\epoc32\data\z\resource\qt\imports\Qt\labs\particles\qmlparticlesplugin.qtplugin resource\qt\imports\Qt\labs\particles\qmlparticlesplugin.qtplugin -data=\epoc32\data\z\resource\qt\imports\org\webkit\qmldir resource\qt\imports\org\webkit\qmldir +data=\epoc32\data\z\resource\qt\imports\QtWebKit\qmldir resource\qt\imports\QtWebKit\qmldir data=\epoc32\data\z\resource\qt\imports\Qt\labs\folderlistmodel\qmldir resource\qt\imports\Qt\labs\folderlistmodel\qmldir data=\epoc32\data\z\resource\qt\imports\Qt\labs\gestures\qmldir resource\qt\imports\Qt\labs\gestures\qmldir data=\epoc32\data\z\resource\qt\imports\Qt\labs\particles\qmldir resource\qt\imports\Qt\labs\particles\qmldir diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 6d8513e..485471b 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -177,9 +177,9 @@ symbian: { DEPLOYMENT += folderlistmodelImport gesturesImport particlesImport contains(QT_CONFIG, webkit): { - webkitImport.sources = $$QT_BUILD_TREE/imports/org/webkit/qmlwebkitplugin$${QT_LIBINFIX}.dll - webkitImport.sources += $$QT_SOURCE_TREE/src/imports/webkit/qmldir - webkitImport.path = c:$$QT_IMPORTS_BASE_DIR/org/webkit + webkitImport.sources = $$QT_BUILD_TREE/imports/QtWebKit/qmlwebkitplugin$${QT_LIBINFIX}.dll + webkitImport.sources += $$QT_SOURCE_TREE/src/3rdparty/webkit/WebKit/qt/declarative/qmldir + webkitImport.path = c:$$QT_IMPORTS_BASE_DIR/QtWebKit DEPLOYMENT += webkitImport } } -- cgit v0.12 From 26bf653b5d3bb68900ddde05819cf476e918b3e9 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 18 Jun 2010 15:41:05 +0200 Subject: Updated WebKit to 515aae71494436816cd0250cdc52caa4f2566aef Doc fixes from Alexis :) --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 8 ++++++++ src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp | 6 +++--- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 17ba8d7..4c476d0 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -e32cb21d4f1787147bcb681883b96a95f867749a +515aae71494436816cd0250cdc52caa4f2566aef diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 6ba3221..4cf9463 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - e32cb21d4f1787147bcb681883b96a95f867749a + 515aae71494436816cd0250cdc52caa4f2566aef diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index d77267b..3df2970 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,11 @@ +2010-06-18 Alexis Menard + + Reviewed by Simon Hausmann. + + [Qt] Fix documentation for the declarative module import. + + * declarative/qdeclarativewebview.cpp: + 2010-06-18 Simon Hausmann Reviewed by Antti Koivisto. diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp index 263b42a..a349bec 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -145,9 +145,9 @@ void GraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) A WebView renders web content based on a URL. - This type is made available by importing the \c org.webkit module: + This type is made available by importing the \c QtWebKit module: - \bold{import org.webkit 1.0} + \bold{import QtWebKit 1.0} If the width and height of the item is not set, they will dynamically adjust to a size appropriate for the content. @@ -160,7 +160,7 @@ void GraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) usually laying out the web content to fit the preferredWidth. \qml - import org.webkit 1.0 + import QtWebKit 1.0 WebView { url: "http://www.nokia.com" -- cgit v0.12 From 6d10cf218b22052e380fff18255953241b821ff3 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sat, 19 Jun 2010 10:02:25 +0200 Subject: Updated WebKit to 19de3d2848b715f937eb375a078672cc8e9b8185 || || [Qt] The new Qt's documentation text layout is messed up with QtWebKit. || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 14 ++++++++++++++ .../webkit/WebCore/platform/graphics/qt/FontQt.cpp | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 4c476d0..98460a0 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -515aae71494436816cd0250cdc52caa4f2566aef +19de3d2848b715f937eb375a078672cc8e9b8185 diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 4cf9463..c2daf34 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 515aae71494436816cd0250cdc52caa4f2566aef + 19de3d2848b715f937eb375a078672cc8e9b8185 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 3113efe..ddd04c1 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,17 @@ +2010-06-18 Ananth Jasty + + Reviewed by Simon Hausmann. + + [Qt] Text spacing miscalculation when using wordSpacing. + https://bugs.webkit.org/show_bug.cgi?id=40483 + + Removed wordSpacing compensation in FontQt whitespace width + calculation. The QFontMetrics::width() overload that takes + a character does not take QFont's word spacing into account. + + * platform/graphics/qt/FontQt.cpp: + (WebCore::Font::floatWidthForComplexText): + 2010-06-13 Robert Hogan Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp index ae1033e..d75f156 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp @@ -182,7 +182,7 @@ float Font::floatWidthForComplexText(const TextRun& run, HashSet Date: Sun, 20 Jun 2010 23:48:08 +0200 Subject: Updated WebKit to 19de3d2848b715f937eb375a078672cc8e9b8185 * Don't include QtScript Phoenix here until it's ready for release :) --- .../webkit/JavaScriptCore/qt/api/QtScript.pro | 46 - .../JavaScriptCore/qt/api/qscriptconverter_p.h | 132 -- .../webkit/JavaScriptCore/qt/api/qscriptengine.cpp | 145 -- .../webkit/JavaScriptCore/qt/api/qscriptengine.h | 56 - .../JavaScriptCore/qt/api/qscriptengine_p.cpp | 71 - .../webkit/JavaScriptCore/qt/api/qscriptengine_p.h | 121 -- .../JavaScriptCore/qt/api/qscriptprogram.cpp | 136 -- .../webkit/JavaScriptCore/qt/api/qscriptprogram.h | 53 - .../JavaScriptCore/qt/api/qscriptprogram_p.h | 129 -- .../webkit/JavaScriptCore/qt/api/qscriptstring.cpp | 131 -- .../webkit/JavaScriptCore/qt/api/qscriptstring.h | 58 - .../webkit/JavaScriptCore/qt/api/qscriptstring_p.h | 112 -- .../qt/api/qscriptsyntaxcheckresult.cpp | 142 -- .../qt/api/qscriptsyntaxcheckresult.h | 50 - .../qt/api/qscriptsyntaxcheckresult_p.h | 73 - .../webkit/JavaScriptCore/qt/api/qscriptvalue.cpp | 556 ------ .../webkit/JavaScriptCore/qt/api/qscriptvalue.h | 99 - .../webkit/JavaScriptCore/qt/api/qscriptvalue_p.h | 754 -------- .../webkit/JavaScriptCore/qt/api/qtscriptglobal.h | 44 - .../qt/tests/qscriptengine/qscriptengine.pro | 8 - .../qt/tests/qscriptengine/tst_qscriptengine.cpp | 275 --- .../qt/tests/qscriptstring/qscriptstring.pro | 7 - .../qt/tests/qscriptstring/tst_qscriptstring.cpp | 175 -- .../qt/tests/qscriptvalue/qscriptvalue.pro | 12 - .../qt/tests/qscriptvalue/tst_qscriptvalue.cpp | 435 ----- .../qt/tests/qscriptvalue/tst_qscriptvalue.h | 196 -- .../qscriptvalue/tst_qscriptvalue_generated.cpp | 1922 -------------------- .../webkit/JavaScriptCore/qt/tests/tests.pri | 19 - .../webkit/JavaScriptCore/qt/tests/tests.pro | 4 - 29 files changed, 5961 deletions(-) delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptconverter_p.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine.cpp delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine_p.cpp delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine_p.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram.cpp delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram_p.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring.cpp delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring_p.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult.cpp delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult_p.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue.cpp delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue_p.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/api/qtscriptglobal.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptengine/qscriptengine.pro delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptengine/tst_qscriptengine.cpp delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptstring/qscriptstring.pro delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptstring/tst_qscriptstring.cpp delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/tests/tests.pri delete mode 100644 src/3rdparty/webkit/JavaScriptCore/qt/tests/tests.pro diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro b/src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro deleted file mode 100644 index 3c2691e..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro +++ /dev/null @@ -1,46 +0,0 @@ -TARGET = QtScript -TEMPLATE = lib -QT = core - -INCLUDEPATH += $$PWD - -CONFIG += building-libs - -isEmpty(JSC_GENERATED_SOURCES_DIR):JSC_GENERATED_SOURCES_DIR = ../../generated -!CONFIG(release, debug|release) { - OBJECTS_DIR = obj/debug -} else { # Release - OBJECTS_DIR = obj/release -} - -isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../.. -include($$PWD/../../../WebKit.pri) - -include($$PWD/../../JavaScriptCore.pri) -addJavaScriptCoreLib(../..) - -INCLUDEPATH += $$PWD/../../API - -SOURCES += $$PWD/qscriptengine.cpp \ - $$PWD/qscriptengine_p.cpp \ - $$PWD/qscriptvalue.cpp \ - $$PWD/qscriptstring.cpp \ - $$PWD/qscriptprogram.cpp \ - $$PWD/qscriptsyntaxcheckresult.cpp \ - -HEADERS += $$PWD/qtscriptglobal.h \ - $$PWD/qscriptengine.h \ - $$PWD/qscriptengine_p.h \ - $$PWD/qscriptvalue.h \ - $$PWD/qscriptvalue_p.h \ - $$PWD/qscriptconverter_p.h \ - $$PWD/qscriptstring.h \ - $$PWD/qscriptstring_p.h \ - $$PWD/qscriptprogram.h \ - $$PWD/qscriptprogram_p.h \ - $$PWD/qscriptsyntaxcheckresult.h \ - - -!static: DEFINES += QT_MAKEDLL - -DESTDIR = $$OUTPUT_DIR/lib diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptconverter_p.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptconverter_p.h deleted file mode 100644 index cd86e20..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptconverter_p.h +++ /dev/null @@ -1,132 +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 qscriptconverter_p_h -#define qscriptconverter_p_h - -#include -#include -#include -#include - -extern char *qdtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **digits_str); - -/* - \internal - \class QScriptConverter - QScriptValue and QScriptEngine helper class. This class's responsibility is to convert values - between JS values and Qt/C++ values. - - This is a nice way to inline these functions in both QScriptValue and QScriptEngine. -*/ -class QScriptConverter { -public: - static quint32 toArrayIndex(const JSStringRef jsstring) - { - // FIXME this function should be exported by JSC C API. - QString qstring = toString(jsstring); - - bool ok; - quint32 idx = qstring.toUInt(&ok); - if (!ok || toString(idx) != qstring) - idx = 0xffffffff; - - return idx; - } - - static QString toString(const JSStringRef str) - { - return QString(reinterpret_cast(JSStringGetCharactersPtr(str)), JSStringGetLength(str)); - } - static JSStringRef toString(const QString& str) - { - return JSStringCreateWithUTF8CString(str.toUtf8().constData()); - } - static JSStringRef toString(const char* str) - { - return JSStringCreateWithUTF8CString(str); - } - static QString toString(double value) - { - // FIXME this should be easier. The ideal fix is to create - // a new function in JSC C API which could cover the functionality. - - if (qIsNaN(value)) - return QString::fromLatin1("NaN"); - if (qIsInf(value)) - return QString::fromLatin1(value < 0 ? "-Infinity" : "Infinity"); - if (!value) - return QString::fromLatin1("0"); - - QVarLengthArray buf; - int decpt; - int sign; - char* result = 0; - char* endresult; - (void)qdtoa(value, 0, 0, &decpt, &sign, &endresult, &result); - - if (!result) - return QString(); - - int resultLen = endresult - result; - if (decpt <= 0 && decpt > -6) { - buf.resize(-decpt + 2 + sign); - qMemSet(buf.data(), '0', -decpt + 2 + sign); - if (sign) // fix the sign. - buf[0] = '-'; - buf[sign + 1] = '.'; - buf.append(result, resultLen); - } else { - if (sign) - buf.append('-'); - int length = buf.size() - sign + resultLen; - if (decpt <= 21 && decpt > 0) { - if (length <= decpt) { - const char* zeros = "0000000000000000000000000"; - buf.append(result, resultLen); - buf.append(zeros, decpt - length); - } else { - buf.append(result, decpt); - buf.append('.'); - buf.append(result + decpt, resultLen - decpt); - } - } else if (result[0] >= '0' && result[0] <= '9') { - if (length > 1) { - buf.append(result, 1); - buf.append('.'); - buf.append(result + 1, resultLen - 1); - } else - buf.append(result, resultLen); - buf.append('e'); - buf.append(decpt >= 0 ? '+' : '-'); - int e = qAbs(decpt - 1); - if (e >= 100) - buf.append('0' + e / 100); - if (e >= 10) - buf.append('0' + (e % 100) / 10); - buf.append('0' + e % 10); - } - } - free(result); - buf.append(0); - return QString::fromLatin1(buf.constData()); - } -}; - -#endif // qscriptconverter_p_h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine.cpp b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine.cpp deleted file mode 100644 index 6a3edc1..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - Copyright (C) 2009 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 "config.h" - -#include "qscriptengine.h" - -#include "qscriptengine_p.h" -#include "qscriptprogram_p.h" -#include "qscriptsyntaxcheckresult_p.h" -#include "qscriptvalue_p.h" - -/*! - Constructs a QScriptEngine object. - - The globalObject() is initialized to have properties as described in ECMA-262, Section 15.1. -*/ -QScriptEngine::QScriptEngine() - : d_ptr(new QScriptEnginePrivate(this)) -{ -} - -/*! - Destroys this QScriptEngine. -*/ -QScriptEngine::~QScriptEngine() -{ -} - -/*! - Checks the syntax of the given \a program. Returns a - QScriptSyntaxCheckResult object that contains the result of the check. -*/ -QScriptSyntaxCheckResult QScriptEngine::checkSyntax(const QString &program) -{ - // FIXME This is not optimal. - // The JSC C API needs a context to perform a syntax check, it means that a QScriptEnginePrivate - // had to be created. This function is static so we have to create QScriptEnginePrivate for each - // call. We can't remove the "static" for compatibility reason, at least up to Qt5. - // QScriptSyntaxCheckResultPrivate takes ownership of newly created engine. The engine will be - // kept as long as it is needed for lazy evaluation of properties of - // the QScriptSyntaxCheckResultPrivate. - QScriptEnginePrivate* engine = new QScriptEnginePrivate(/* q_ptr */ 0); - return QScriptSyntaxCheckResultPrivate::get(engine->checkSyntax(program)); -} - -/*! - Evaluates \a program, using \a lineNumber as the base line number, - and returns the result of the evaluation. - - The script code will be evaluated in the current context. - - The evaluation of \a program can cause an exception in the - engine; in this case the return value will be the exception - that was thrown (typically an \c{Error} object). You can call - hasUncaughtException() to determine if an exception occurred in - the last call to evaluate(). - - \a lineNumber is used to specify a starting line number for \a - program; line number information reported by the engine that pertain - to this evaluation (e.g. uncaughtExceptionLineNumber()) will be - based on this argument. For example, if \a program consists of two - lines of code, and the statement on the second line causes a script - exception, uncaughtExceptionLineNumber() would return the given \a - lineNumber plus one. When no starting line number is specified, line - numbers will be 1-based. - - \a fileName is used for error reporting. For example in error objects - the file name is accessible through the "fileName" property if it's - provided with this function. -*/ -QScriptValue QScriptEngine::evaluate(const QString& program, const QString& fileName, int lineNumber) -{ - return QScriptValuePrivate::get(d_ptr->evaluate(program, fileName, lineNumber)); -} - -QScriptValue QScriptEngine::evaluate(const QScriptProgram& program) -{ - return QScriptValuePrivate::get(d_ptr->evaluate(QScriptProgramPrivate::get(program))); -} - -/*! - Runs the garbage collector. - - The garbage collector will attempt to reclaim memory by locating and disposing of objects that are - no longer reachable in the script environment. - - Normally you don't need to call this function; the garbage collector will automatically be invoked - when the QScriptEngine decides that it's wise to do so (i.e. when a certain number of new objects - have been created). However, you can call this function to explicitly request that garbage - collection should be performed as soon as possible. -*/ -void QScriptEngine::collectGarbage() -{ - d_ptr->collectGarbage(); -} - -/*! - Returns a handle that represents the given string, \a str. - - QScriptString can be used to quickly look up properties, and - compare property names, of script objects. - - \sa QScriptValue::property() -*/ -QScriptString QScriptEngine::toStringHandle(const QString& str) -{ - return QScriptStringPrivate::get(d_ptr->toStringHandle(str)); -} - -/*! - Returns a QScriptValue of the primitive type Null. - - \sa undefinedValue() -*/ -QScriptValue QScriptEngine::nullValue() -{ - return QScriptValue(this, QScriptValue::NullValue); -} - -/*! - Returns a QScriptValue of the primitive type Undefined. - - \sa nullValue() -*/ -QScriptValue QScriptEngine::undefinedValue() -{ - return QScriptValue(this, QScriptValue::UndefinedValue); -} diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine.h deleted file mode 100644 index ee066c9..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2009 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 qscriptengine_h -#define qscriptengine_h - -#include "qscriptprogram.h" -#include "qscriptstring.h" -#include "qscriptsyntaxcheckresult.h" -#include -#include -#include - -class QScriptValue; -class QScriptEnginePrivate; - -// Internal typedef -typedef QExplicitlySharedDataPointer QScriptEnginePtr; - -class QScriptEngine : public QObject { -public: - QScriptEngine(); - ~QScriptEngine(); - - static QScriptSyntaxCheckResult checkSyntax(const QString& program); - QScriptValue evaluate(const QString& program, const QString& fileName = QString(), int lineNumber = 1); - QScriptValue evaluate(const QScriptProgram& program); - void collectGarbage(); - - QScriptString toStringHandle(const QString& str); - - QScriptValue nullValue(); - QScriptValue undefinedValue(); -private: - friend class QScriptEnginePrivate; - - QScriptEnginePtr d_ptr; -}; - -#endif diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine_p.cpp b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine_p.cpp deleted file mode 100644 index 32551b0..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine_p.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2009 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 "config.h" - -#include "qscriptengine_p.h" - -#include "qscriptprogram_p.h" -#include "qscriptvalue_p.h" - -/*! - Constructs a default QScriptEnginePrivate object, a new global context will be created. - \internal -*/ -QScriptEnginePrivate::QScriptEnginePrivate(const QScriptEngine* engine) - : q_ptr(const_cast(engine)) - , m_context(JSGlobalContextCreate(0)) -{ -} - -QScriptEnginePrivate::~QScriptEnginePrivate() -{ - JSGlobalContextRelease(m_context); -} - -QScriptSyntaxCheckResultPrivate* QScriptEnginePrivate::checkSyntax(const QString& program) -{ - JSValueRef exception; - if (JSCheckScriptSyntax(m_context, QScriptConverter::toString(program), /* url */ 0, /* starting line */ 1, &exception)) - return new QScriptSyntaxCheckResultPrivate(this); - JSValueProtect(m_context, exception); - return new QScriptSyntaxCheckResultPrivate(this, const_cast(exception)); -} - -/*! - Evaluates program and returns the result of the evaluation. - \internal -*/ -QScriptValuePrivate* QScriptEnginePrivate::evaluate(const QString& program, const QString& fileName, int lineNumber) -{ - JSStringRef script = QScriptConverter::toString(program); - JSStringRef file = QScriptConverter::toString(fileName); - return new QScriptValuePrivate(this, evaluate(script, file, lineNumber)); -} - -/*! - Evaluates program and returns the result of the evaluation. - \internal -*/ -QScriptValuePrivate* QScriptEnginePrivate::evaluate(const QScriptProgramPrivate* program) -{ - if (program->isNull()) - return new QScriptValuePrivate; - return new QScriptValuePrivate(this, evaluate(program->program(), program->file(), program->line())); -} diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine_p.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine_p.h deleted file mode 100644 index bf958ba..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptengine_p.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - Copyright (C) 2009 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 qscriptengine_p_h -#define qscriptengine_p_h - -#include "qscriptconverter_p.h" -#include "qscriptengine.h" -#include "qscriptstring_p.h" -#include "qscriptsyntaxcheckresult_p.h" -#include "qscriptvalue.h" -#include -#include -#include - -class QScriptEngine; -class QScriptSyntaxCheckResultPrivate; - -class QScriptEnginePrivate : public QSharedData { -public: - static QScriptEnginePtr get(const QScriptEngine* q) { Q_ASSERT(q); return q->d_ptr; } - static QScriptEngine* get(const QScriptEnginePrivate* d) { Q_ASSERT(d); return d->q_ptr; } - - QScriptEnginePrivate(const QScriptEngine*); - ~QScriptEnginePrivate(); - - QScriptSyntaxCheckResultPrivate* checkSyntax(const QString& program); - QScriptValuePrivate* evaluate(const QString& program, const QString& fileName, int lineNumber); - QScriptValuePrivate* evaluate(const QScriptProgramPrivate* program); - inline JSValueRef evaluate(JSStringRef program, JSStringRef fileName, int lineNumber); - inline void collectGarbage(); - - inline JSValueRef makeJSValue(double number) const; - inline JSValueRef makeJSValue(int number) const; - inline JSValueRef makeJSValue(uint number) const; - inline JSValueRef makeJSValue(const QString& string) const; - inline JSValueRef makeJSValue(bool number) const; - inline JSValueRef makeJSValue(QScriptValue::SpecialValue value) const; - - inline QScriptStringPrivate* toStringHandle(const QString& str) const; - - inline JSGlobalContextRef context() const; -private: - QScriptEngine* q_ptr; - JSGlobalContextRef m_context; -}; - - -JSValueRef QScriptEnginePrivate::evaluate(JSStringRef program, JSStringRef fileName, int lineNumber) -{ - JSValueRef exception; - JSValueRef result = JSEvaluateScript(m_context, program, /* Global Object */ 0, fileName, lineNumber, &exception); - if (!result) - return exception; // returns an exception - return result; -} - -void QScriptEnginePrivate::collectGarbage() -{ - JSGarbageCollect(m_context); -} - -JSValueRef QScriptEnginePrivate::makeJSValue(double number) const -{ - return JSValueMakeNumber(m_context, number); -} - -JSValueRef QScriptEnginePrivate::makeJSValue(int number) const -{ - return JSValueMakeNumber(m_context, number); -} - -JSValueRef QScriptEnginePrivate::makeJSValue(uint number) const -{ - return JSValueMakeNumber(m_context, number); -} - -JSValueRef QScriptEnginePrivate::makeJSValue(const QString& string) const -{ - return JSValueMakeString(m_context, QScriptConverter::toString(string)); -} - -JSValueRef QScriptEnginePrivate::makeJSValue(bool value) const -{ - return JSValueMakeBoolean(m_context, value); -} - -JSValueRef QScriptEnginePrivate::makeJSValue(QScriptValue::SpecialValue value) const -{ - if (value == QScriptValue::NullValue) - return JSValueMakeNull(m_context); - return JSValueMakeUndefined(m_context); -} - -QScriptStringPrivate* QScriptEnginePrivate::toStringHandle(const QString& str) const -{ - return new QScriptStringPrivate(str); -} - -JSGlobalContextRef QScriptEnginePrivate::context() const -{ - return m_context; -} - -#endif diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram.cpp b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram.cpp deleted file mode 100644 index d7d4948..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - Copyright (C) 2010 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 "config.h" - -#include "qscriptprogram.h" - -#include "qscriptprogram_p.h" - -/*! - \internal - - \class QScriptProgram - - \brief The QScriptProgram class encapsulates a Qt Script program. - - \ingroup script - - QScriptProgram retains the compiled representation of the script if - possible. Thus, QScriptProgram can be used to evaluate the same - script multiple times more efficiently. - - \code - QScriptEngine engine; - QScriptProgram program("1 + 2"); - QScriptValue result = engine.evaluate(program); - \endcode -*/ - -/*! - Constructs a null QScriptProgram. -*/ -QScriptProgram::QScriptProgram() - : d_ptr(new QScriptProgramPrivate) -{} - -/*! - Constructs a new QScriptProgram with the given \a sourceCode, \a - fileName and \a firstLineNumber. -*/ -QScriptProgram::QScriptProgram(const QString& sourceCode, - const QString fileName, - int firstLineNumber) - : d_ptr(new QScriptProgramPrivate(sourceCode, fileName, firstLineNumber)) -{} - -/*! - Destroys this QScriptProgram. -*/ -QScriptProgram::~QScriptProgram() -{} - -/*! - Constructs a new QScriptProgram that is a copy of \a other. -*/ -QScriptProgram::QScriptProgram(const QScriptProgram& other) -{ - d_ptr = other.d_ptr; -} - -/*! - Assigns the \a other value to this QScriptProgram. -*/ -QScriptProgram& QScriptProgram::operator=(const QScriptProgram& other) -{ - d_ptr = other.d_ptr; - return *this; -} - -/*! - Returns true if this QScriptProgram is null; otherwise - returns false. -*/ -bool QScriptProgram::isNull() const -{ - return d_ptr->isNull(); -} - -/*! - Returns the source code of this program. -*/ -QString QScriptProgram::sourceCode() const -{ - return d_ptr->sourceCode(); -} - -/*! - Returns the filename associated with this program. -*/ -QString QScriptProgram::fileName() const -{ - return d_ptr->fileName(); -} - -/*! - Returns the line number associated with this program. -*/ -int QScriptProgram::firstLineNumber() const -{ - return d_ptr->firstLineNumber(); -} - -/*! - Returns true if this QScriptProgram is equal to \a other; - otherwise returns false. -*/ -bool QScriptProgram::operator==(const QScriptProgram& other) const -{ - return d_ptr == other.d_ptr || *d_ptr == *other.d_ptr; -} - -/*! - Returns true if this QScriptProgram is not equal to \a other; - otherwise returns false. -*/ -bool QScriptProgram::operator!=(const QScriptProgram& other) const -{ - return d_ptr != other.d_ptr && *d_ptr != *other.d_ptr; -} - diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram.h deleted file mode 100644 index 93c8a3c..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 2010 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 qscriptprogram_h -#define qscriptprogram_h - -#include "qtscriptglobal.h" -#include -#include - -class QScriptProgramPrivate; -class Q_JAVASCRIPT_EXPORT QScriptProgram { -public: - QScriptProgram(); - QScriptProgram(const QString& sourceCode, - const QString fileName = QString(), - int firstLineNumber = 1); - QScriptProgram(const QScriptProgram& other); - ~QScriptProgram(); - - QScriptProgram& operator=(const QScriptProgram& other); - - bool isNull() const; - - QString sourceCode() const; - QString fileName() const; - int firstLineNumber() const; - - bool operator==(const QScriptProgram& other) const; - bool operator!=(const QScriptProgram& other) const; - -private: - QExplicitlySharedDataPointer d_ptr; - Q_DECLARE_PRIVATE(QScriptProgram) -}; - -#endif // qscriptprogram_h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram_p.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram_p.h deleted file mode 100644 index 6e80e85..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptprogram_p.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - Copyright (C) 2010 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 qscriptprogram_p_h -#define qscriptprogram_p_h - -#include "qscriptconverter_p.h" -#include "qscriptprogram.h" -#include -#include -#include - -/* - FIXME The QScriptProgramPrivate potentially could be much faster. In current implementation we - gain CPU time only by avoiding QString -> JSStringRef conversion. In the ideal world we should - have a function inside the JSC C API that could provide us "parse once, execute multiple times" - functionality. -*/ - -class QScriptProgramPrivate : public QSharedData { -public: - inline static QScriptProgramPrivate* get(const QScriptProgram& program); - inline QScriptProgramPrivate(); - inline QScriptProgramPrivate(const QString& sourceCode, - const QString fileName, - int firstLineNumber); - - inline ~QScriptProgramPrivate(); - - inline bool isNull() const; - - inline QString sourceCode() const; - inline QString fileName() const; - inline int firstLineNumber() const; - - inline bool operator==(const QScriptProgramPrivate& other) const; - inline bool operator!=(const QScriptProgramPrivate& other) const; - - inline JSStringRef program() const; - inline JSStringRef file() const; - inline int line() const; -private: - JSStringRef m_program; - JSStringRef m_fileName; - int m_line; -}; - -QScriptProgramPrivate* QScriptProgramPrivate::get(const QScriptProgram& program) -{ - return const_cast(program.d_ptr.constData()); -} - -QScriptProgramPrivate::QScriptProgramPrivate() - : m_program(0) - , m_fileName(0) - , m_line(-1) -{} - -QScriptProgramPrivate::QScriptProgramPrivate(const QString& sourceCode, - const QString fileName, - int firstLineNumber) - : m_program(QScriptConverter::toString(sourceCode)) - , m_fileName(QScriptConverter::toString(fileName)) - , m_line(firstLineNumber) -{} - -QScriptProgramPrivate::~QScriptProgramPrivate() -{ - if (!isNull()) { - JSStringRelease(m_program); - JSStringRelease(m_fileName); - } -} - -bool QScriptProgramPrivate::isNull() const -{ - return !m_program; -} - -QString QScriptProgramPrivate::sourceCode() const -{ - return QScriptConverter::toString(m_program); -} - -QString QScriptProgramPrivate::fileName() const -{ - return QScriptConverter::toString(m_fileName); -} - -int QScriptProgramPrivate::firstLineNumber() const -{ - return m_line; -} - -bool QScriptProgramPrivate::operator==(const QScriptProgramPrivate& other) const -{ - return m_line == other.m_line - && JSStringIsEqual(m_fileName, other.m_fileName) - && JSStringIsEqual(m_program, other.m_program); -} - -bool QScriptProgramPrivate::operator!=(const QScriptProgramPrivate& other) const -{ - return m_line != other.m_line - || !JSStringIsEqual(m_fileName, other.m_fileName) - || !JSStringIsEqual(m_program, other.m_program); -} - -JSStringRef QScriptProgramPrivate::program() const { return m_program; } -JSStringRef QScriptProgramPrivate::file() const {return m_fileName; } -int QScriptProgramPrivate::line() const { return m_line; } - -#endif // qscriptprogram_p_h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring.cpp b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring.cpp deleted file mode 100644 index 83c03c5..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - Copyright (C) 2009 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 "config.h" - -#include "qscriptstring.h" - -#include "qscriptstring_p.h" -#include - -/*! - Constructs an invalid QScriptString. -*/ -QScriptString::QScriptString() - : d_ptr(new QScriptStringPrivate()) -{ -} -/*! - Constructs an QScriptString from internal representation - \internal -*/ -QScriptString::QScriptString(QScriptStringPrivate* d) - : d_ptr(d) -{ -} - -/*! - Constructs a new QScriptString that is a copy of \a other. -*/ -QScriptString::QScriptString(const QScriptString& other) -{ - d_ptr = other.d_ptr; -} - -/*! - Destroys this QScriptString. -*/ -QScriptString::~QScriptString() -{ -} - -/*! - Assigns the \a other value to this QScriptString. -*/ -QScriptString& QScriptString::operator=(const QScriptString& other) -{ - d_ptr = other.d_ptr; - return *this; -} - -/*! - Returns true if this QScriptString is valid; otherwise - returns false. -*/ -bool QScriptString::isValid() const -{ - return d_ptr->isValid(); -} - -/*! - Returns true if this QScriptString is equal to \a other; - otherwise returns false. -*/ -bool QScriptString::operator==(const QScriptString& other) const -{ - return d_ptr == other.d_ptr || *d_ptr == *(other.d_ptr); -} - -/*! - Returns true if this QScriptString is not equal to \a other; - otherwise returns false. -*/ -bool QScriptString::operator!=(const QScriptString& other) const -{ - return d_ptr != other.d_ptr || *d_ptr != *(other.d_ptr); -} - -/*! - Attempts to convert this QScriptString to a QtScript array index, - and returns the result. - - If a conversion error occurs, *\a{ok} is set to false; otherwise - *\a{ok} is set to true. -*/ -quint32 QScriptString::toArrayIndex(bool* ok) const -{ - return d_ptr->toArrayIndex(ok); -} - -/*! - Returns the string that this QScriptString represents, or a - null string if this QScriptString is not valid. - - \sa isValid() -*/ -QString QScriptString::toString() const -{ - return d_ptr->toString(); -} - -/*! - Returns the string that this QScriptString represents, or a - null string if this QScriptString is not valid. - - \sa toString() -*/ -QScriptString::operator QString() const -{ - return d_ptr->toString(); -} - -uint qHash(const QScriptString& key) -{ - return qHash(QScriptStringPrivate::get(key)->id()); -} diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring.h deleted file mode 100644 index 16593bc..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2010 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 qscriptstring_h -#define qscriptstring_h - -#include "qtscriptglobal.h" -#include -#include - -class QScriptStringPrivate; -typedef QExplicitlySharedDataPointer QScriptStringPtr; - -class Q_JAVASCRIPT_EXPORT QScriptString { -public: - QScriptString(); - QScriptString(const QScriptString& other); - ~QScriptString(); - - QScriptString& operator=(const QScriptString& other); - - bool isValid() const; - - bool operator==(const QScriptString& other) const; - bool operator!=(const QScriptString& other) const; - - quint32 toArrayIndex(bool* ok = 0) const; - - QString toString() const; - operator QString() const; - -private: - QScriptString(QScriptStringPrivate* d); - - QScriptStringPtr d_ptr; - - friend class QScriptStringPrivate; -}; - -uint qHash(const QScriptString& key); - -#endif // qscriptstring_h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring_p.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring_p.h deleted file mode 100644 index f4fd117..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptstring_p.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright (C) 2010 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 qscriptstring_p_h -#define qscriptstring_p_h - -#include "qscriptconverter_p.h" -#include "qscriptstring.h" -#include -#include -#include - -class QScriptStringPrivate : public QSharedData { -public: - inline QScriptStringPrivate(); - inline QScriptStringPrivate(const QString& qtstring); - inline ~QScriptStringPrivate(); - - static inline QScriptString get(QScriptStringPrivate* d); - static inline QScriptStringPtr get(const QScriptString& p); - - inline bool isValid() const; - - inline bool operator==(const QScriptStringPrivate& other) const; - inline bool operator!=(const QScriptStringPrivate& other) const; - - inline quint32 toArrayIndex(bool* ok = 0) const; - - inline QString toString() const; - - inline quint64 id() const; - -private: - JSStringRef m_string; -}; - - -QScriptStringPrivate::QScriptStringPrivate() - : m_string(0) -{} - -QScriptStringPrivate::QScriptStringPrivate(const QString& qtstring) - : m_string(JSStringRetain(QScriptConverter::toString(qtstring))) -{} - -QScriptStringPrivate::~QScriptStringPrivate() -{ - if (isValid()) - JSStringRelease(m_string); -} - -QScriptString QScriptStringPrivate::get(QScriptStringPrivate* d) -{ - Q_ASSERT(d); - return QScriptString(d); -} - -QScriptStringPtr QScriptStringPrivate::get(const QScriptString& p) -{ - return p.d_ptr; -} - -bool QScriptStringPrivate::isValid() const -{ - return m_string; -} - -bool QScriptStringPrivate::operator==(const QScriptStringPrivate& other) const -{ - return isValid() && other.isValid() && JSStringIsEqual(m_string, other.m_string); -} - -bool QScriptStringPrivate::operator!=(const QScriptStringPrivate& other) const -{ - return isValid() && other.isValid() && !JSStringIsEqual(m_string, other.m_string); -} - -quint32 QScriptStringPrivate::toArrayIndex(bool* ok) const -{ - quint32 idx = QScriptConverter::toArrayIndex(m_string); - if (ok) - *ok = (idx != 0xffffffff); - return idx; -} - -QString QScriptStringPrivate::toString() const -{ - return QScriptConverter::toString(m_string); -} - -quint64 QScriptStringPrivate::id() const -{ - return reinterpret_cast(m_string); -} - -#endif // qscriptstring_p_h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult.cpp b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult.cpp deleted file mode 100644 index 2085f5b..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - Copyright (C) 2010 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 "config.h" - -#include "qscriptsyntaxcheckresult.h" -#include "qscriptsyntaxcheckresult_p.h" - -/*! - \class QScriptSyntaxCheckResult - - \brief The QScriptSyntaxCheckResult class provides the result of a script syntax check. - - \ingroup script - \mainclass - - QScriptSyntaxCheckResult is returned by QScriptEngine::checkSyntax() to - provide information about the syntactical (in)correctness of a script. -*/ - -/*! - \enum QScriptSyntaxCheckResult::State - - This enum specifies the state of a syntax check. - - \value Error The program contains a syntax error. - \value Intermediate The program is incomplete. - \value Valid The program is a syntactically correct Qt Script program. -*/ - -/*! - Constructs a new QScriptSyntaxCheckResult from the \a other result. -*/ -QScriptSyntaxCheckResult::QScriptSyntaxCheckResult(const QScriptSyntaxCheckResult& other) - : d_ptr(other.d_ptr) -{} - -/*! - Constructs a new QScriptSyntaxCheckResult from an internal representation. - \internal -*/ -QScriptSyntaxCheckResult::QScriptSyntaxCheckResult(QScriptSyntaxCheckResultPrivate* d) - : d_ptr(d) -{} - -/*! - Destroys this QScriptSyntaxCheckResult. -*/ -QScriptSyntaxCheckResult::~QScriptSyntaxCheckResult() -{} - -/*! - Assigns the \a other result to this QScriptSyntaxCheckResult, and returns a - reference to this QScriptSyntaxCheckResult. -*/ -QScriptSyntaxCheckResult& QScriptSyntaxCheckResult::operator=(const QScriptSyntaxCheckResult& other) -{ - d_ptr = other.d_ptr; - return *this; -} - -/*! - Returns the state of this QScriptSyntaxCheckResult. -*/ -QScriptSyntaxCheckResult::State QScriptSyntaxCheckResult::state() const -{ - return d_ptr->state(); -} - -/*! - Returns the error line number of this QScriptSyntaxCheckResult, or -1 if - there is no error. - - \sa state(), errorMessage() -*/ -int QScriptSyntaxCheckResult::errorLineNumber() const -{ - return d_ptr->errorLineNumber(); -} - -/*! - Returns the error column number of this QScriptSyntaxCheckResult, or -1 if - there is no error. - - \sa state(), errorLineNumber() -*/ -int QScriptSyntaxCheckResult::errorColumnNumber() const -{ - return d_ptr->errorColumnNumber(); -} - -/*! - Returns the error message of this QScriptSyntaxCheckResult, or an empty - string if there is no error. - - \sa state(), errorLineNumber() -*/ -QString QScriptSyntaxCheckResult::errorMessage() const -{ - return d_ptr->errorMessage(); -} - -QScriptSyntaxCheckResultPrivate::~QScriptSyntaxCheckResultPrivate() -{ - if (m_exception) - JSValueUnprotect(m_engine->context(), m_exception); -} - -QString QScriptSyntaxCheckResultPrivate::errorMessage() const -{ - if (m_exception) - return QScriptConverter::toString(JSValueToStringCopy(m_engine->context(), m_exception, /* exception */ 0)); - return QString(); -} - -int QScriptSyntaxCheckResultPrivate::errorLineNumber() const -{ - if (!m_exception) - return -1; - // m_exception is an instance of the Exception so it has "line" attribute. - JSValueRef line = JSObjectGetProperty(m_engine->context(), - m_exception, - QScriptConverter::toString("line"), - /* exceptions */0); - return JSValueToNumber(m_engine->context(), line, /* exceptions */0); -} diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult.h deleted file mode 100644 index aa57744..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2010 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 qscriptsyntaxcheckresult_h -#define qscriptsyntaxcheckresult_h - -#include "qtscriptglobal.h" -#include - -class QScriptSyntaxCheckResultPrivate; -class Q_JAVASCRIPT_EXPORT QScriptSyntaxCheckResult { -public: - enum State { - Error, - Intermediate, - Valid - }; - - QScriptSyntaxCheckResult(const QScriptSyntaxCheckResult& other); - ~QScriptSyntaxCheckResult(); - QScriptSyntaxCheckResult& operator=(const QScriptSyntaxCheckResult& other); - - State state() const; - int errorLineNumber() const; - int errorColumnNumber() const; - QString errorMessage() const; - -private: - QScriptSyntaxCheckResult(QScriptSyntaxCheckResultPrivate* d); - QExplicitlySharedDataPointer d_ptr; - - friend class QScriptSyntaxCheckResultPrivate; -}; -#endif // qscriptsyntaxcheckresult_h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult_p.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult_p.h deleted file mode 100644 index 6e1a131..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptsyntaxcheckresult_p.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2010 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 qscriptsyntaxcheckresult_p_h -#define qscriptsyntaxcheckresult_p_h - -#include "qscriptconverter_p.h" -#include "qscriptengine_p.h" -#include "qscriptsyntaxcheckresult.h" -#include -#include - -class QScriptSyntaxCheckResultPrivate : public QSharedData { -public: - static inline QScriptSyntaxCheckResult get(QScriptSyntaxCheckResultPrivate* p); - inline QScriptSyntaxCheckResultPrivate(const QScriptEnginePrivate* engine); - inline QScriptSyntaxCheckResultPrivate(const QScriptEnginePrivate* engine, JSObjectRef value); - ~QScriptSyntaxCheckResultPrivate(); - - inline QScriptSyntaxCheckResult::State state() const; - int errorLineNumber() const; - inline int errorColumnNumber() const; - QString errorMessage() const; -private: - JSObjectRef m_exception; - QScriptEnginePtr m_engine; -}; - -QScriptSyntaxCheckResult QScriptSyntaxCheckResultPrivate::get(QScriptSyntaxCheckResultPrivate* p) -{ - return QScriptSyntaxCheckResult(p); -} - -QScriptSyntaxCheckResultPrivate::QScriptSyntaxCheckResultPrivate(const QScriptEnginePrivate* engine) - : m_exception(0) - , m_engine(const_cast(engine)) -{} - -QScriptSyntaxCheckResultPrivate::QScriptSyntaxCheckResultPrivate(const QScriptEnginePrivate* engine, JSObjectRef value) - : m_exception(value) - , m_engine(const_cast(engine)) -{} - -QScriptSyntaxCheckResult::State QScriptSyntaxCheckResultPrivate::state() const -{ - // FIXME This function doesn't return QScriptSyntaxCheckResult::Intermediate - return m_exception ? QScriptSyntaxCheckResult::Error : QScriptSyntaxCheckResult::Valid; -} - -int QScriptSyntaxCheckResultPrivate::errorColumnNumber() const -{ - // FIXME JSC C API doesn't expose the error column number. - return m_exception ? 1 : -1; -} - - -#endif // qscriptsyntaxcheckresult_p_h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue.cpp b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue.cpp deleted file mode 100644 index 127fe04..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue.cpp +++ /dev/null @@ -1,556 +0,0 @@ -/* - Copyright (C) 2009 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 "config.h" - -#include "qscriptvalue.h" - -#include "qscriptengine.h" -#include "qscriptengine_p.h" -#include "qscriptvalue_p.h" -#include - -/*! - Constructs an invalid value. -*/ -QScriptValue::QScriptValue() - : d_ptr(new QScriptValuePrivate()) -{ -} - -/*! - Constructs a new QScriptValue with a boolean \a value. -*/ -QScriptValue::QScriptValue(bool value) - : d_ptr(new QScriptValuePrivate(value)) -{ -} - -/*! - Constructs a new QScriptValue with a number \a value. -*/ -QScriptValue::QScriptValue(int value) - : d_ptr(new QScriptValuePrivate(value)) -{ -} - -/*! - Constructs a new QScriptValue with a number \a value. -*/ -QScriptValue::QScriptValue(uint value) - : d_ptr(new QScriptValuePrivate(value)) -{ -} - -/*! - Constructs a new QScriptValue with a number \a value. -*/ -QScriptValue::QScriptValue(qsreal value) - : d_ptr(new QScriptValuePrivate(value)) -{ -} - -/*! - Constructs a new QScriptValue with a string \a value. -*/ -QScriptValue::QScriptValue(const QString& value) - : d_ptr(new QScriptValuePrivate(value)) -{ -} - -/*! - Constructs a new QScriptValue with a special \a value. -*/ -QScriptValue::QScriptValue(SpecialValue value) - : d_ptr(new QScriptValuePrivate(value)) -{ -} - -/*! - Constructs a new QScriptValue with a string \a value. -*/ -QScriptValue::QScriptValue(const char* value) - : d_ptr(new QScriptValuePrivate(QString::fromUtf8(value))) -{ -} - -/*! - Block automatic convertion to bool - \internal -*/ -QScriptValue::QScriptValue(void* d) -{ - Q_ASSERT(false); -} - -/*! - Constructs a new QScriptValue from private - \internal -*/ -QScriptValue::QScriptValue(QScriptValuePrivate* d) - : d_ptr(d) -{ -} - -/*! - \obsolete - - Constructs a new QScriptValue with the boolean \a value and - registers it with the script \a engine. -*/ -QScriptValue::QScriptValue(QScriptEngine* engine, bool value) - : d_ptr(new QScriptValuePrivate(engine, value)) -{ -} - -/*! - \obsolete - - Constructs a new QScriptValue with the integer \a value and - registers it with the script \a engine. -*/ -QScriptValue::QScriptValue(QScriptEngine* engine, int value) - : d_ptr(new QScriptValuePrivate(engine, value)) -{ -} - -/*! - \obsolete - - Constructs a new QScriptValue with the unsigned integer \a value and - registers it with the script \a engine. - */ -QScriptValue::QScriptValue(QScriptEngine* engine, uint value) - : d_ptr(new QScriptValuePrivate(engine, value)) -{ -} - -/*! - \obsolete - - Constructs a new QScriptValue with the qsreal \a value and - registers it with the script \a engine. -*/ -QScriptValue::QScriptValue(QScriptEngine* engine, qsreal value) - : d_ptr(new QScriptValuePrivate(engine, value)) -{ -} - -/*! - \obsolete - - Constructs a new QScriptValue with the string \a value and - registers it with the script \a engine. -*/ -QScriptValue::QScriptValue(QScriptEngine* engine, const QString& value) - : d_ptr(new QScriptValuePrivate(engine, value)) -{ -} - -/*! - \obsolete - - Constructs a new QScriptValue with the string \a value and - registers it with the script \a engine. -*/ -QScriptValue::QScriptValue(QScriptEngine* engine, const char* value) - : d_ptr(new QScriptValuePrivate(engine, QString::fromUtf8(value))) -{ -} - -/*! - \obsolete - - Constructs a new QScriptValue with the special \a value and - registers it with the script \a engine. -*/ -QScriptValue::QScriptValue(QScriptEngine* engine, SpecialValue value) - : d_ptr(new QScriptValuePrivate(engine, value)) -{ -} - -/*! - Constructs a new QScriptValue that is a copy of \a other. - - Note that if \a other is an object (i.e., isObject() would return - true), then only a reference to the underlying object is copied into - the new script value (i.e., the object itself is not copied). -*/ -QScriptValue::QScriptValue(const QScriptValue& other) - : d_ptr(other.d_ptr) -{ -} - -/*! - Destroys this QScriptValue. -*/ -QScriptValue::~QScriptValue() -{ -} - -/*! - Returns true if this QScriptValue is valid; otherwise returns - false. -*/ -bool QScriptValue::isValid() const -{ - return d_ptr->isValid(); -} - -/*! - Returns true if this QScriptValue is of the primitive type Boolean; - otherwise returns false. - - \sa toBool() -*/ -bool QScriptValue::isBool() const -{ - return d_ptr->isBool(); -} - -/*! - \obsolete - - Use isBool() instead. - Returns true if this QScriptValue is of the primitive type Boolean; - otherwise returns false. -*/ -bool QScriptValue::isBoolean() const -{ - return d_ptr->isBool(); -} - -/*! - Returns true if this QScriptValue is of the primitive type Number; - otherwise returns false. - - \sa toNumber() -*/ -bool QScriptValue::isNumber() const -{ - return d_ptr->isNumber(); -} - -/*! - Returns true if this QScriptValue is of the primitive type Null; - otherwise returns false. - - \sa QScriptEngine::nullValue() -*/ -bool QScriptValue::isNull() const -{ - return d_ptr->isNull(); -} - -/*! - Returns true if this QScriptValue is of the primitive type String; - otherwise returns false. - - \sa toString() -*/ -bool QScriptValue::isString() const -{ - return d_ptr->isString(); -} - -/*! - Returns true if this QScriptValue is of the primitive type Undefined; - otherwise returns false. - - \sa QScriptEngine::undefinedValue() -*/ -bool QScriptValue::isUndefined() const -{ - return d_ptr->isUndefined(); -} - -/*! - Returns true if this QScriptValue is an object of the Error class; - otherwise returns false. - - \sa QScriptContext::throwError() -*/ -bool QScriptValue::isError() const -{ - return d_ptr->isError(); -} - -/*! - Returns true if this QScriptValue is of the Object type; otherwise - returns false. - - Note that function values, variant values, and QObject values are - objects, so this function returns true for such values. - - \sa toObject(), QScriptEngine::newObject() -*/ -bool QScriptValue::isObject() const -{ - return d_ptr->isObject(); -} - -/*! - Returns true if this QScriptValue is a function; otherwise returns - false. - - \sa call() -*/ -bool QScriptValue::isFunction() const -{ - return d_ptr->isFunction(); -} - -/*! - Returns the string value of this QScriptValue, as defined in - \l{ECMA-262} section 9.8, "ToString". - - Note that if this QScriptValue is an object, calling this function - has side effects on the script engine, since the engine will call - the object's toString() function (and possibly valueOf()) in an - attempt to convert the object to a primitive value (possibly - resulting in an uncaught script exception). - - \sa isString() -*/ -QString QScriptValue::toString() const -{ - return d_ptr->toString(); -} - -/*! - Returns the number value of this QScriptValue, as defined in - \l{ECMA-262} section 9.3, "ToNumber". - - Note that if this QScriptValue is an object, calling this function - has side effects on the script engine, since the engine will call - the object's valueOf() function (and possibly toString()) in an - attempt to convert the object to a primitive value (possibly - resulting in an uncaught script exception). - - \sa isNumber(), toInteger(), toInt32(), toUInt32(), toUInt16() -*/ -qsreal QScriptValue::toNumber() const -{ - return d_ptr->toNumber(); -} - -/*! - Returns the boolean value of this QScriptValue, using the conversion - rules described in \l{ECMA-262} section 9.2, "ToBoolean". - - Note that if this QScriptValue is an object, calling this function - has side effects on the script engine, since the engine will call - the object's valueOf() function (and possibly toString()) in an - attempt to convert the object to a primitive value (possibly - resulting in an uncaught script exception). - - \sa isBool() -*/ -bool QScriptValue::toBool() const -{ - return d_ptr->toBool(); -} - -/*! - \obsolete - - Use toBool() instead. -*/ -bool QScriptValue::toBoolean() const -{ - return d_ptr->toBool(); -} - -/*! - Returns the integer value of this QScriptValue, using the conversion - rules described in \l{ECMA-262} section 9.4, "ToInteger". - - Note that if this QScriptValue is an object, calling this function - has side effects on the script engine, since the engine will call - the object's valueOf() function (and possibly toString()) in an - attempt to convert the object to a primitive value (possibly - resulting in an uncaught script exception). - - \sa toNumber() -*/ -qsreal QScriptValue::toInteger() const -{ - return d_ptr->toInteger(); -} - -/*! - Returns the signed 32-bit integer value of this QScriptValue, using - the conversion rules described in \l{ECMA-262} section 9.5, "ToInt32". - - Note that if this QScriptValue is an object, calling this function - has side effects on the script engine, since the engine will call - the object's valueOf() function (and possibly toString()) in an - attempt to convert the object to a primitive value (possibly - resulting in an uncaught script exception). - - \sa toNumber(), toUInt32() -*/ -qint32 QScriptValue::toInt32() const -{ - return d_ptr->toInt32(); -} - -/*! - Returns the unsigned 32-bit integer value of this QScriptValue, using - the conversion rules described in \l{ECMA-262} section 9.6, "ToUint32". - - Note that if this QScriptValue is an object, calling this function - has side effects on the script engine, since the engine will call - the object's valueOf() function (and possibly toString()) in an - attempt to convert the object to a primitive value (possibly - resulting in an uncaught script exception). - - \sa toNumber(), toInt32() -*/ -quint32 QScriptValue::toUInt32() const -{ - return d_ptr->toUInt32(); -} - -/*! - Returns the unsigned 16-bit integer value of this QScriptValue, using - the conversion rules described in \l{ECMA-262} section 9.7, "ToUint16". - - Note that if this QScriptValue is an object, calling this function - has side effects on the script engine, since the engine will call - the object's valueOf() function (and possibly toString()) in an - attempt to convert the object to a primitive value (possibly - resulting in an uncaught script exception). - - \sa toNumber() -*/ -quint16 QScriptValue::toUInt16() const -{ - return d_ptr->toUInt16(); -} - -/*! - Calls this QScriptValue as a function, using \a thisObject as - the `this' object in the function call, and passing \a args - as arguments to the function. Returns the value returned from - the function. - - If this QScriptValue is not a function, call() does nothing - and returns an invalid QScriptValue. - - Note that if \a thisObject is not an object, the global object - (see \l{QScriptEngine::globalObject()}) will be used as the - `this' object. - - Calling call() can cause an exception to occur in the script engine; - in that case, call() returns the value that was thrown (typically an - \c{Error} object). You can call - QScriptEngine::hasUncaughtException() to determine if an exception - occurred. - - \snippet doc/src/snippets/code/src_script_qscriptvalue.cpp 2 - - \sa construct() -*/ -QScriptValue QScriptValue::call(const QScriptValue& thisObject, const QScriptValueList& args) -{ - return d_ptr->call(thisObject.d_ptr.data(), args); -} - -/*! - Returns the QScriptEngine that created this QScriptValue, - or 0 if this QScriptValue is invalid or the value is not - associated with a particular engine. -*/ -QScriptEngine* QScriptValue::engine() const -{ - QScriptEnginePrivate* engine = d_ptr->engine(); - if (engine) - return QScriptEnginePrivate::get(engine); - return 0; -} - -/*! - Assigns the \a other value to this QScriptValue. - - Note that if \a other is an object (isObject() returns true), - only a reference to the underlying object will be assigned; - the object itself will not be copied. -*/ -QScriptValue& QScriptValue::operator=(const QScriptValue& other) -{ - d_ptr = other.d_ptr; - return *this; -} - -/*! - Returns true if this QScriptValue is equal to \a other, otherwise - returns false. The comparison follows the behavior described in - \l{ECMA-262} section 11.9.3, "The Abstract Equality Comparison - Algorithm". - - This function can return true even if the type of this QScriptValue - is different from the type of the \a other value; i.e. the - comparison is not strict. For example, comparing the number 9 to - the string "9" returns true; comparing an undefined value to a null - value returns true; comparing a \c{Number} object whose primitive - value is 6 to a \c{String} object whose primitive value is "6" - returns true; and comparing the number 1 to the boolean value - \c{true} returns true. If you want to perform a comparison - without such implicit value conversion, use strictlyEquals(). - - Note that if this QScriptValue or the \a other value are objects, - calling this function has side effects on the script engine, since - the engine will call the object's valueOf() function (and possibly - toString()) in an attempt to convert the object to a primitive value - (possibly resulting in an uncaught script exception). - - \sa strictlyEquals(), lessThan() -*/ -bool QScriptValue::equals(const QScriptValue& other) const -{ - return d_ptr == other.d_ptr || d_ptr->equals(QScriptValuePrivate::get(other)); -} - -/*! - Returns true if this QScriptValue is equal to \a other using strict - comparison (no conversion), otherwise returns false. The comparison - follows the behavior described in \l{ECMA-262} section 11.9.6, "The - Strict Equality Comparison Algorithm". - - If the type of this QScriptValue is different from the type of the - \a other value, this function returns false. If the types are equal, - the result depends on the type, as shown in the following table: - - \table - \header \o Type \o Result - \row \o Undefined \o true - \row \o Null \o true - \row \o Boolean \o true if both values are true, false otherwise - \row \o Number \o false if either value is NaN (Not-a-Number); true if values are equal, false otherwise - \row \o String \o true if both values are exactly the same sequence of characters, false otherwise - \row \o Object \o true if both values refer to the same object, false otherwise - \endtable - - \sa equals() -*/ -bool QScriptValue::strictlyEquals(const QScriptValue& other) const -{ - return d_ptr == other.d_ptr || d_ptr->strictlyEquals(QScriptValuePrivate::get(other)); -} diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue.h deleted file mode 100644 index d45aed3..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright (C) 2009 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 qscriptvalue_h -#define qscriptvalue_h - -#include -#include - -class QScriptEngine; -class QScriptValuePrivate; - -class QScriptValue; -typedef QList QScriptValueList; - -typedef double qsreal; - -class QScriptValue { -public: - enum SpecialValue { - NullValue, - UndefinedValue - }; - - QScriptValue(); - QScriptValue(bool value); - QScriptValue(int value); - QScriptValue(uint value); - QScriptValue(qsreal value); - QScriptValue(const QString& value); - QScriptValue(const char* value); - QScriptValue(SpecialValue value); - QScriptValue(const QScriptValue& other); - - QScriptValue(QScriptEngine* engine, bool value); - QScriptValue(QScriptEngine* engine, int value); - QScriptValue(QScriptEngine* engine, uint value); - QScriptValue(QScriptEngine* engine, qsreal value); - QScriptValue(QScriptEngine* engine, const QString& value); - QScriptValue(QScriptEngine* engine, const char* value); - QScriptValue(QScriptEngine* engine, SpecialValue value); - - ~QScriptValue(); - - QScriptValue& operator=(const QScriptValue& other); - bool equals(const QScriptValue& other) const; - bool strictlyEquals(const QScriptValue& other) const; - - QScriptEngine* engine() const; - - bool isValid() const; - bool isBool() const; - bool isBoolean() const; - bool isNumber() const; - bool isFunction() const; - bool isNull() const; - bool isString() const; - bool isUndefined() const; - bool isObject() const; - bool isError() const; - - QString toString() const; - qsreal toNumber() const; - bool toBool() const; - bool toBoolean() const; - qsreal toInteger() const; - qint32 toInt32() const; - quint32 toUInt32() const; - quint16 toUInt16() const; - - QScriptValue call(const QScriptValue& thisObject = QScriptValue(), - const QScriptValueList& args = QScriptValueList()); - -private: - QScriptValue(void*); - QScriptValue(QScriptValuePrivate*); - - QExplicitlySharedDataPointer d_ptr; - - friend class QScriptValuePrivate; -}; - -#endif // qscriptvalue_h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue_p.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue_p.h deleted file mode 100644 index e5c2a82..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qscriptvalue_p.h +++ /dev/null @@ -1,754 +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 qscriptvalue_p_h -#define qscriptvalue_p_h - -#include "qscriptconverter_p.h" -#include "qscriptengine_p.h" -#include "qscriptvalue.h" -#include -#include -#include -#include -#include - -class QScriptEngine; -class QScriptValue; - -/* - \internal - \class QScriptValuePrivate - - Implementation of QScriptValue. - The implementation is based on a state machine. The states names are included in - QScriptValuePrivate::State. Each method should check for the current state and then perform a - correct action. - - State: - Invalid -> QSVP is invalid, no assumptions should be made about class members (apart from m_value). - CString -> QSVP is created from QString or const char* and no JSC engine has been associated yet. - Current value is kept in m_string, - CNumber -> QSVP is created from int, uint, double... and no JSC engine has been bind yet. Current - value is kept in m_number - CBool -> QSVP is created from bool and no JSC engine has been associated yet. Current value is kept - in m_number - CSpecial -> QSVP is Undefined or Null, but a JSC engine hasn't been associated yet, current value - is kept in m_number (cast of QScriptValue::SpecialValue) - JSValue -> QSVP is associated with engine, but there is no information about real type, the state - have really short live cycle. Normally it is created as a function call result. - JSPrimitive -> QSVP is associated with engine, and it is sure that it isn't a JavaScript object. - JSObject -> QSVP is associated with engine, and it is sure that it is a JavaScript object. - - Each state keep all necessary information to invoke all methods, if not it should be changed to - a proper state. Changed state shouldn't be reverted. -*/ - -class QScriptValuePrivate : public QSharedData { -public: - inline static QScriptValuePrivate* get(const QScriptValue& q); - inline static QScriptValue get(const QScriptValuePrivate* d); - inline static QScriptValue get(QScriptValuePrivate* d); - - inline ~QScriptValuePrivate(); - - inline QScriptValuePrivate(); - inline QScriptValuePrivate(const QString& string); - inline QScriptValuePrivate(bool value); - inline QScriptValuePrivate(int number); - inline QScriptValuePrivate(uint number); - inline QScriptValuePrivate(qsreal number); - inline QScriptValuePrivate(QScriptValue::SpecialValue value); - - inline QScriptValuePrivate(const QScriptEngine* engine, bool value); - inline QScriptValuePrivate(const QScriptEngine* engine, int value); - inline QScriptValuePrivate(const QScriptEngine* engine, uint value); - inline QScriptValuePrivate(const QScriptEngine* engine, qsreal value); - inline QScriptValuePrivate(const QScriptEngine* engine, const QString& value); - inline QScriptValuePrivate(const QScriptEngine* engine, QScriptValue::SpecialValue value); - - inline QScriptValuePrivate(const QScriptEnginePrivate* engine, JSValueRef value); - inline QScriptValuePrivate(const QScriptEnginePrivate* engine, JSValueRef value, JSObjectRef object); - - inline bool isValid() const; - inline bool isBool(); - inline bool isNumber(); - inline bool isNull(); - inline bool isString(); - inline bool isUndefined(); - inline bool isError(); - inline bool isObject(); - inline bool isFunction(); - - inline QString toString() const; - inline qsreal toNumber() const; - inline bool toBool() const; - inline qsreal toInteger() const; - inline qint32 toInt32() const; - inline quint32 toUInt32() const; - inline quint16 toUInt16() const; - - inline bool equals(QScriptValuePrivate* other); - inline bool strictlyEquals(const QScriptValuePrivate* other) const; - inline bool assignEngine(QScriptEnginePrivate* engine); - - inline QScriptValuePrivate* call(const QScriptValuePrivate* , const QScriptValueList& args); - - inline JSGlobalContextRef context() const; - inline JSValueRef value() const; - inline JSObjectRef object() const; - inline QScriptEnginePrivate* engine() const; - -private: - // Please, update class documentation when you change the enum. - enum State { - Invalid = 0, - CString = 0x1000, - CNumber, - CBool, - CSpecial, - JSValue = 0x2000, // JS values are equal or higher then this value. - JSPrimitive, - JSObject - } m_state; - QScriptEnginePtr m_engine; - QString m_string; - qsreal m_number; - JSValueRef m_value; - JSObjectRef m_object; - - inline void setValue(JSValueRef); - - inline bool inherits(const char*); - inline State refinedJSValue(); - - inline bool isJSBased() const; - inline bool isNumberBased() const; - inline bool isStringBased() const; -}; - -QScriptValuePrivate* QScriptValuePrivate::get(const QScriptValue& q) { return q.d_ptr.data(); } - -QScriptValue QScriptValuePrivate::get(const QScriptValuePrivate* d) -{ - return QScriptValue(const_cast(d)); -} - -QScriptValue QScriptValuePrivate::get(QScriptValuePrivate* d) -{ - return QScriptValue(d); -} - -QScriptValuePrivate::~QScriptValuePrivate() -{ - if (m_value) - JSValueUnprotect(context(), m_value); -} - -QScriptValuePrivate::QScriptValuePrivate() - : m_state(Invalid) - , m_value(0) -{ -} - -QScriptValuePrivate::QScriptValuePrivate(const QString& string) - : m_state(CString) - , m_string(string) - , m_value(0) -{ -} - -QScriptValuePrivate::QScriptValuePrivate(bool value) - : m_state(CBool) - , m_number(value) - , m_value(0) -{ -} - -QScriptValuePrivate::QScriptValuePrivate(int number) - : m_state(CNumber) - , m_number(number) - , m_value(0) -{ -} - -QScriptValuePrivate::QScriptValuePrivate(uint number) - : m_state(CNumber) - , m_number(number) - , m_value(0) -{ -} - -QScriptValuePrivate::QScriptValuePrivate(qsreal number) - : m_state(CNumber) - , m_number(number) - , m_value(0) -{ -} - -QScriptValuePrivate::QScriptValuePrivate(QScriptValue::SpecialValue value) - : m_state(CSpecial) - , m_number(value) - , m_value(0) -{ -} - -QScriptValuePrivate::QScriptValuePrivate(const QScriptEngine* engine, bool value) - : m_state(JSPrimitive) -{ - if (!engine) { - // slower path reinitialization - m_state = CBool; - m_number = value; - m_value = 0; - } else { - m_engine = QScriptEnginePrivate::get(engine); - m_value = m_engine->makeJSValue(value); - JSValueProtect(context(), m_value); - } -} - -QScriptValuePrivate::QScriptValuePrivate(const QScriptEngine* engine, int value) - : m_state(JSPrimitive) -{ - if (!engine) { - // slower path reinitialization - m_state = CNumber; - m_number = value; - m_value = 0; - } else { - m_engine = QScriptEnginePrivate::get(engine); - m_value = m_engine->makeJSValue(value); - JSValueProtect(context(), m_value); - } -} - -QScriptValuePrivate::QScriptValuePrivate(const QScriptEngine* engine, uint value) - : m_state(JSPrimitive) -{ - if (!engine) { - // slower path reinitialization - m_state = CNumber; - m_number = value; - m_value = 0; - } else { - m_engine = QScriptEnginePrivate::get(engine); - m_value = m_engine->makeJSValue(value); - JSValueProtect(context(), m_value); - } -} - -QScriptValuePrivate::QScriptValuePrivate(const QScriptEngine* engine, qsreal value) - : m_state(JSPrimitive) -{ - if (!engine) { - // slower path reinitialization - m_state = CNumber; - m_number = value; - m_value = 0; - } else { - m_engine = QScriptEnginePrivate::get(engine); - m_value = m_engine->makeJSValue(value); - JSValueProtect(context(), m_value); - } -} - -QScriptValuePrivate::QScriptValuePrivate(const QScriptEngine* engine, const QString& value) - : m_state(JSPrimitive) -{ - if (!engine) { - // slower path reinitialization - m_state = CString; - m_string = value; - m_value = 0; - } else { - m_engine = QScriptEnginePrivate::get(engine); - m_value = m_engine->makeJSValue(value); - JSValueProtect(context(), m_value); - } -} - -QScriptValuePrivate::QScriptValuePrivate(const QScriptEngine* engine, QScriptValue::SpecialValue value) - : m_state(JSPrimitive) -{ - if (!engine) { - // slower path reinitialization - m_state = CSpecial; - m_number = value; - m_value = 0; - } else { - m_engine = QScriptEnginePrivate::get(engine); - m_value = m_engine->makeJSValue(value); - JSValueProtect(context(), m_value); - } -} - -QScriptValuePrivate::QScriptValuePrivate(const QScriptEnginePrivate* engine, JSValueRef value) - : m_state(JSValue) - , m_engine(const_cast(engine)) - , m_value(value) -{ - Q_ASSERT(engine); - JSValueProtect(context(), m_value); -} - -QScriptValuePrivate::QScriptValuePrivate(const QScriptEnginePrivate* engine, JSValueRef value, JSObjectRef object) - : m_state(JSObject) - , m_engine(const_cast(engine)) - , m_value(value) - , m_object(object) -{ - Q_ASSERT(engine); - JSValueProtect(context(), m_value); -} - -bool QScriptValuePrivate::isValid() const { return m_state != Invalid; } - -bool QScriptValuePrivate::isBool() -{ - switch (m_state) { - case CBool: - return true; - case JSValue: - if (refinedJSValue() != JSPrimitive) - return false; - // Fall-through. - case JSPrimitive: - return JSValueIsBoolean(context(), value()); - default: - return false; - } -} - -bool QScriptValuePrivate::isNumber() -{ - switch (m_state) { - case CNumber: - return true; - case JSValue: - if (refinedJSValue() != JSPrimitive) - return false; - // Fall-through. - case JSPrimitive: - return JSValueIsNumber(context(), value()); - default: - return false; - } -} - -bool QScriptValuePrivate::isNull() -{ - switch (m_state) { - case CSpecial: - return m_number == static_cast(QScriptValue::NullValue); - case JSValue: - if (refinedJSValue() != JSPrimitive) - return false; - // Fall-through. - case JSPrimitive: - return JSValueIsNull(context(), value()); - default: - return false; - } -} - -bool QScriptValuePrivate::isString() -{ - switch (m_state) { - case CString: - return true; - case JSValue: - if (refinedJSValue() != JSPrimitive) - return false; - // Fall-through. - case JSPrimitive: - return JSValueIsString(context(), value()); - default: - return false; - } -} - -bool QScriptValuePrivate::isUndefined() -{ - switch (m_state) { - case CSpecial: - return m_number == static_cast(QScriptValue::UndefinedValue); - case JSValue: - if (refinedJSValue() != JSPrimitive) - return false; - // Fall-through. - case JSPrimitive: - return JSValueIsUndefined(context(), value()); - default: - return false; - } -} - -bool QScriptValuePrivate::isError() -{ - switch (m_state) { - case JSValue: - if (refinedJSValue() != JSObject) - return false; - // Fall-through. - case JSObject: - return inherits("Error"); - default: - return false; - } -} - -bool QScriptValuePrivate::isObject() -{ - switch (m_state) { - case JSValue: - return refinedJSValue() == JSObject; - case JSObject: - return true; - - default: - return false; - } -} - -bool QScriptValuePrivate::isFunction() -{ - switch (m_state) { - case JSValue: - if (refinedJSValue() != JSObject) - return false; - // Fall-through. - case JSObject: - return JSObjectIsFunction(context(), object()); - default: - return false; - } -} - -QString QScriptValuePrivate::toString() const -{ - switch (m_state) { - case Invalid: - return QString(); - case CBool: - return m_number ? QString::fromLatin1("true") : QString::fromLatin1("false"); - case CString: - return m_string; - case CNumber: - return QScriptConverter::toString(m_number); - case CSpecial: - return m_number == QScriptValue::NullValue ? QString::fromLatin1("null") : QString::fromLatin1("undefined"); - case JSValue: - case JSPrimitive: - case JSObject: - return QScriptConverter::toString(JSValueToStringCopy(context(), value(), /* exception */ 0)); - } - - Q_ASSERT_X(false, "toString()", "Not all states are included in the previous switch statement."); - return QString(); // Avoid compiler warning. -} - -qsreal QScriptValuePrivate::toNumber() const -{ - switch (m_state) { - case JSValue: - case JSPrimitive: - case JSObject: - return JSValueToNumber(context(), value(), /* exception */ 0); - case CNumber: - return m_number; - case CBool: - return m_number ? 1 : 0; - case Invalid: - return 0; - case CSpecial: - return m_number == QScriptValue::NullValue ? 0 : qQNaN(); - case CString: - bool ok; - qsreal result = m_string.toDouble(&ok); - if (ok) - return result; - result = m_string.toInt(&ok, 0); // Try other bases. - if (ok) - return result; - if (m_string == "Infinity" || m_string == "-Infinity") - return qInf(); - return m_string.length() ? qQNaN() : 0; - } - - Q_ASSERT_X(false, "toNumber()", "Not all states are included in the previous switch statement."); - return 0; // Avoid compiler warning. -} - -bool QScriptValuePrivate::toBool() const -{ - switch (m_state) { - case JSValue: - case JSPrimitive: - return JSValueToBoolean(context(), value()); - case JSObject: - return true; - case CNumber: - return !(qIsNaN(m_number) || !m_number); - case CBool: - return m_number; - case Invalid: - case CSpecial: - return false; - case CString: - return m_string.length(); - } - - Q_ASSERT_X(false, "toBool()", "Not all states are included in the previous switch statement."); - return false; // Avoid compiler warning. -} - -qsreal QScriptValuePrivate::toInteger() const -{ - qsreal result = toNumber(); - if (qIsNaN(result)) - return 0; - if (qIsInf(result)) - return result; - return (result > 0) ? qFloor(result) : -1 * qFloor(-result); -} - -qint32 QScriptValuePrivate::toInt32() const -{ - qsreal result = toInteger(); - // Orginaly it should look like that (result == 0 || qIsInf(result) || qIsNaN(result)), but - // some of these operation are invoked in toInteger subcall. - if (qIsInf(result)) - return 0; - return result; -} - -quint32 QScriptValuePrivate::toUInt32() const -{ - qsreal result = toInteger(); - // Orginaly it should look like that (result == 0 || qIsInf(result) || qIsNaN(result)), but - // some of these operation are invoked in toInteger subcall. - if (qIsInf(result)) - return 0; - return result; -} - -quint16 QScriptValuePrivate::toUInt16() const -{ - return toInt32(); -} - - -bool QScriptValuePrivate::equals(QScriptValuePrivate* other) -{ - if (!isValid() || !other->isValid()) - return false; - - if ((m_state == other->m_state) && !isJSBased()) { - if (isNumberBased()) - return m_number == other->m_number; - return m_string == other->m_string; - } - - if (isJSBased() && !other->isJSBased()) { - if (!other->assignEngine(engine())) { - qWarning("equals(): Cannot compare to a value created in a different engine"); - return false; - } - } else if (!isJSBased() && other->isJSBased()) { - if (!other->assignEngine(other->engine())) { - qWarning("equals(): Cannot compare to a value created in a different engine"); - return false; - } - } - - return JSValueIsEqual(context(), value(), other->value(), /* exception */ 0); -} - -bool QScriptValuePrivate::strictlyEquals(const QScriptValuePrivate* other) const -{ - if (m_state != other->m_state) - return false; - if (isJSBased()) { - if (other->engine() != engine()) { - qWarning("strictlyEquals(): Cannot compare to a value created in a different engine"); - return false; - } - return JSValueIsStrictEqual(context(), value(), other->value()); - } - if (isStringBased()) - return m_string == other->m_string; - if (isNumberBased()) - return m_number == other->m_number; - - return false; // Invalid state. -} - -/*! - Tries to assign \a engine to this value. Returns true on success; otherwise returns false. -*/ -bool QScriptValuePrivate::assignEngine(QScriptEnginePrivate* engine) -{ - JSValueRef value; - switch (m_state) { - case CBool: - value = engine->makeJSValue(static_cast(m_number)); - break; - case CString: - value = engine->makeJSValue(m_string); - break; - case CNumber: - value = engine->makeJSValue(m_number); - break; - case CSpecial: - value = engine->makeJSValue(static_cast(m_number)); - break; - default: - if (!isJSBased()) - Q_ASSERT_X(!isJSBased(), "assignEngine()", "Not all states are included in the previous switch statement."); - else - qWarning("JSValue can't be rassigned to an another engine."); - return false; - } - m_engine = engine; - m_state = JSPrimitive; - setValue(value); - return true; -} - -QScriptValuePrivate* QScriptValuePrivate::call(const QScriptValuePrivate*, const QScriptValueList& args) -{ - switch (m_state) { - case JSValue: - if (refinedJSValue() != JSObject) - return new QScriptValuePrivate; - // Fall-through. - case JSObject: - { - // Convert all arguments and bind to the engine. - int argc = args.size(); - QVarLengthArray argv(argc); - QScriptValueList::const_iterator i = args.constBegin(); - for (int j = 0; i != args.constEnd(); j++, i++) { - QScriptValuePrivate* value = QScriptValuePrivate::get(*i); - if (!value->assignEngine(engine())) { - qWarning("QScriptValue::call() failed: cannot call function with values created in a different engine"); - return new QScriptValuePrivate; - } - argv[j] = value->value(); - } - - // Make the call - JSValueRef exception = 0; - JSValueRef result = JSObjectCallAsFunction(context(), object(), /* thisObject */ 0, argc, argv.constData(), &exception); - if (!result && exception) - return new QScriptValuePrivate(engine(), exception); - if (result && !exception) - return new QScriptValuePrivate(engine(), result); - } - // this QSV is not a function <-- !result && !exception. Fall-through. - default: - return new QScriptValuePrivate; - } -} - -QScriptEnginePrivate* QScriptValuePrivate::engine() const -{ - // As long as m_engine is an autoinitializated pointer we can safely return it without - // checking current state. - return m_engine.data(); -} - -JSGlobalContextRef QScriptValuePrivate::context() const -{ - Q_ASSERT(isJSBased()); - return m_engine->context(); -} - -JSValueRef QScriptValuePrivate::value() const -{ - Q_ASSERT(isJSBased()); - return m_value; -} - -JSObjectRef QScriptValuePrivate::object() const -{ - Q_ASSERT(m_state == JSObject); - return m_object; -} - -void QScriptValuePrivate::setValue(JSValueRef value) -{ - if (m_value) - JSValueUnprotect(context(), m_value); - if (value) - JSValueProtect(context(), value); - m_value = value; -} - -/*! - \internal - Returns true if QSV is created from constructor with the given \a name, it has to be a - built-in type. -*/ -bool QScriptValuePrivate::inherits(const char* name) -{ - Q_ASSERT(isJSBased()); - JSObjectRef globalObject = JSContextGetGlobalObject(context()); - JSValueRef error = JSObjectGetProperty(context(), globalObject, QScriptConverter::toString(name), 0); - return JSValueIsInstanceOfConstructor(context(), value(), JSValueToObject(context(), error, /* exception */ 0), /* exception */ 0); -} - -/*! - \internal - Refines the state of this QScriptValuePrivate. Returns the new state. -*/ -QScriptValuePrivate::State QScriptValuePrivate::refinedJSValue() -{ - Q_ASSERT(m_state == JSValue); - if (!JSValueIsObject(context(), value())) { - m_state = JSPrimitive; - } else { - m_state = JSObject; - // We are sure that value is an JSObject, so we can const_cast safely without - // calling JSC C API (JSValueToObject(context(), value(), /* exceptions */ 0)). - m_object = const_cast(m_value); - } - return m_state; -} - -/*! - \internal - Returns true if QSV have an engine associated. -*/ -bool QScriptValuePrivate::isJSBased() const { return m_state >= JSValue; } - -/*! - \internal - Returns true if current value of QSV is placed in m_number. -*/ -bool QScriptValuePrivate::isNumberBased() const { return !isJSBased() && !isStringBased() && m_state != Invalid; } - -/*! - \internal - Returns true if current value of QSV is placed in m_string. -*/ -bool QScriptValuePrivate::isStringBased() const { return m_state == CString; } - -#endif // qscriptvalue_p_h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/qtscriptglobal.h b/src/3rdparty/webkit/JavaScriptCore/qt/api/qtscriptglobal.h deleted file mode 100644 index 29749c0..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/qtscriptglobal.h +++ /dev/null @@ -1,44 +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 qtscriptglobal_h -#define qtscriptglobal_h - -#include - -#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) -# if defined(QT_NODLL) -# elif defined(QT_MAKEDLL) /* create a Qt DLL library */ -# if defined(QT_BUILD_JAVASCRIPT_LIB) -# define Q_JAVASCRIPT_EXPORT Q_DECL_EXPORT -# else -# define Q_JAVASCRIPT_EXPORT Q_DECL_IMPORT -# endif -# elif defined(QT_DLL) /* use a Qt DLL library */ -# define Q_JAVASCRIPT_EXPORT -# endif -#endif - -#if defined(QT_SHARED) -# define Q_JAVASCRIPT_EXPORT Q_DECL_EXPORT -#else -# define Q_JAVASCRIPT_EXPORT -#endif - -#endif diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptengine/qscriptengine.pro b/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptengine/qscriptengine.pro deleted file mode 100644 index d521dd8..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptengine/qscriptengine.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = app -TARGET = tst_qscriptengine -QT += testlib -isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../../.. -include(../tests.pri) - -SOURCES += tst_qscriptengine.cpp - diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptengine/tst_qscriptengine.cpp b/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptengine/tst_qscriptengine.cpp deleted file mode 100644 index 2632796..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptengine/tst_qscriptengine.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/* - Copyright (C) 2009 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 "qscriptengine.h" -#include "qscriptprogram.h" -#include "qscriptsyntaxcheckresult.h" -#include "qscriptvalue.h" -#include - -class tst_QScriptEngine : public QObject { - Q_OBJECT - -public: - tst_QScriptEngine() {} - virtual ~tst_QScriptEngine() {} - -public slots: - void init() {} - void cleanup() {} - -private slots: - void evaluate(); - void collectGarbage(); - void nullValue(); - void undefinedValue(); - void evaluateProgram(); - void checkSyntax_data(); - void checkSyntax(); -}; - -/* Evaluating a script that throw an unhandled exception should return an invalid value. */ -void tst_QScriptEngine::evaluate() -{ - QScriptEngine engine; - QVERIFY2(engine.evaluate("1+1").isValid(), "the expression should be evaluated and an valid result should be returned"); - QVERIFY2(engine.evaluate("ping").isValid(), "Script throwing an unhandled exception should return an exception value"); -} - -/* Test garbage collection, at least try to not crash. */ -void tst_QScriptEngine::collectGarbage() -{ - QScriptEngine engine; - QScriptValue foo = engine.evaluate("( function foo() {return 'pong';} )"); - QVERIFY(foo.isFunction()); - engine.collectGarbage(); - QCOMPARE(foo.call().toString(), QString::fromAscii("pong")); -} - -void tst_QScriptEngine::nullValue() -{ - QScriptEngine engine; - QScriptValue value = engine.nullValue(); - QVERIFY(value.isValid()); - QVERIFY(value.isNull()); -} - -void tst_QScriptEngine::undefinedValue() -{ - QScriptEngine engine; - QScriptValue value = engine.undefinedValue(); - QVERIFY(value.isValid()); - QVERIFY(value.isUndefined()); -} - -void tst_QScriptEngine::evaluateProgram() -{ - QScriptEngine eng; - { - QString code("1 + 2"); - QString fileName("hello.js"); - int lineNumber = 123; - QScriptProgram program(code, fileName, lineNumber); - QVERIFY(!program.isNull()); - QCOMPARE(program.sourceCode(), code); - QCOMPARE(program.fileName(), fileName); - QCOMPARE(program.firstLineNumber(), lineNumber); - - QScriptValue expected = eng.evaluate(code); - for (int x = 0; x < 10; ++x) { - QScriptValue ret = eng.evaluate(program); - QVERIFY(ret.equals(expected)); - } - - // operator= - QScriptProgram sameProgram = program; - QVERIFY(sameProgram == program); - QVERIFY(eng.evaluate(sameProgram).equals(expected)); - - // copy constructor - QScriptProgram sameProgram2(program); - QVERIFY(sameProgram2 == program); - QVERIFY(eng.evaluate(sameProgram2).equals(expected)); - - QScriptProgram differentProgram("2 + 3"); - QVERIFY(differentProgram != program); - QVERIFY(!eng.evaluate(differentProgram).equals(expected)); - } - - // Program that accesses variable in the scope - { - QScriptProgram program("a"); - QVERIFY(!program.isNull()); - { - QScriptValue ret = eng.evaluate(program); - QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: Can't find variable: a")); - } - { - QScriptValue ret = eng.evaluate(program); - QVERIFY(ret.isError()); - } - eng.evaluate("a = 456"); - { - QScriptValue ret = eng.evaluate(program); - QVERIFY(!ret.isError()); - QCOMPARE(ret.toNumber(), 456.0); - } - } - - // Program that creates closure - { - QScriptProgram program("(function() { var count = 0; return function() { return count++; }; })"); - QVERIFY(!program.isNull()); - QScriptValue createCounter = eng.evaluate(program); - QVERIFY(createCounter.isFunction()); - QScriptValue counter = createCounter.call(); - QVERIFY(counter.isFunction()); - { - QScriptValue ret = counter.call(); - QVERIFY(ret.isNumber()); - } - QScriptValue counter2 = createCounter.call(); - QVERIFY(counter2.isFunction()); - QVERIFY(!counter2.equals(counter)); - { - QScriptValue ret = counter2.call(); - QVERIFY(ret.isNumber()); - } - } - - // Same program run in different engines - { - QString code("1 + 2"); - QScriptProgram program(code); - QVERIFY(!program.isNull()); - double expected = eng.evaluate(program).toNumber(); - for (int x = 0; x < 2; ++x) { - QScriptEngine eng2; - for (int y = 0; y < 2; ++y) { - double ret = eng2.evaluate(program).toNumber(); - QCOMPARE(ret, expected); - } - } - } - - // No program - { - QScriptProgram program; - QVERIFY(program.isNull()); - QScriptValue ret = eng.evaluate(program); - QVERIFY(!ret.isValid()); - } -} - -void tst_QScriptEngine::checkSyntax_data() -{ - QTest::addColumn("code"); - QTest::addColumn("expectedState"); - QTest::addColumn("errorLineNumber"); - QTest::addColumn("errorColumnNumber"); - QTest::addColumn("errorMessage"); - - QTest::newRow("0") - << QString("0") << int(QScriptSyntaxCheckResult::Valid) - << -1 << -1 << ""; - QTest::newRow("if (") - << QString("if (\n") << int(QScriptSyntaxCheckResult::Intermediate) - << 1 << 4 << ""; - QTest::newRow("if else") - << QString("\nif else") << int(QScriptSyntaxCheckResult::Error) - << 2 << 4 << "SyntaxError: Parse error"; - QTest::newRow("{if}") - << QString("{\n{\nif\n}\n") << int(QScriptSyntaxCheckResult::Error) - << 4 << 1 << "SyntaxError: Parse error"; - QTest::newRow("foo[") - << QString("foo[") << int(QScriptSyntaxCheckResult::Error) - << 1 << 4 << "SyntaxError: Parse error"; - QTest::newRow("foo['bar']") - << QString("foo['bar']") << int(QScriptSyntaxCheckResult::Valid) - << -1 << -1 << ""; - - QTest::newRow("/*") - << QString("/*") << int(QScriptSyntaxCheckResult::Intermediate) - << 1 << 1 << "Unclosed comment at end of file"; - QTest::newRow("/*\nMy comment") - << QString("/*\nMy comment") << int(QScriptSyntaxCheckResult::Intermediate) - << 1 << 1 << "Unclosed comment at end of file"; - QTest::newRow("/*\nMy comment */\nfoo = 10") - << QString("/*\nMy comment */\nfoo = 10") << int(QScriptSyntaxCheckResult::Valid) - << -1 << -1 << ""; - QTest::newRow("foo = 10 /*") - << QString("foo = 10 /*") << int(QScriptSyntaxCheckResult::Intermediate) - << -1 << -1 << ""; - QTest::newRow("foo = 10; /*") - << QString("foo = 10; /*") << int(QScriptSyntaxCheckResult::Intermediate) - << 1 << 11 << "Expected `end of file'"; - QTest::newRow("foo = 10 /* My comment */") - << QString("foo = 10 /* My comment */") << int(QScriptSyntaxCheckResult::Valid) - << -1 << -1 << ""; - - QTest::newRow("/=/") - << QString("/=/") << int(QScriptSyntaxCheckResult::Valid) << -1 << -1 << ""; - QTest::newRow("/=/g") - << QString("/=/g") << int(QScriptSyntaxCheckResult::Valid) << -1 << -1 << ""; - QTest::newRow("/a/") - << QString("/a/") << int(QScriptSyntaxCheckResult::Valid) << -1 << -1 << ""; - QTest::newRow("/a/g") - << QString("/a/g") << int(QScriptSyntaxCheckResult::Valid) << -1 << -1 << ""; -} - -void tst_QScriptEngine::checkSyntax() -{ - QFETCH(QString, code); - QFETCH(int, expectedState); - QFETCH(int, errorLineNumber); - QFETCH(int, errorColumnNumber); - QFETCH(QString, errorMessage); - - QScriptSyntaxCheckResult result = QScriptEngine::checkSyntax(code); - - // assignment - { - QScriptSyntaxCheckResult copy = result; - QCOMPARE(copy.state(), result.state()); - QCOMPARE(copy.errorLineNumber(), result.errorLineNumber()); - QCOMPARE(copy.errorColumnNumber(), result.errorColumnNumber()); - QCOMPARE(copy.errorMessage(), result.errorMessage()); - } - { - QScriptSyntaxCheckResult copy(result); - QCOMPARE(copy.state(), result.state()); - QCOMPARE(copy.errorLineNumber(), result.errorLineNumber()); - QCOMPARE(copy.errorColumnNumber(), result.errorColumnNumber()); - QCOMPARE(copy.errorMessage(), result.errorMessage()); - } - - if (expectedState == QScriptSyntaxCheckResult::Intermediate) - QEXPECT_FAIL("", "QScriptSyntaxCheckResult::state() doesn't return the Intermediate state", Abort); - QCOMPARE(result.state(), QScriptSyntaxCheckResult::State(expectedState)); - QCOMPARE(result.errorLineNumber(), errorLineNumber); - if (expectedState != QScriptSyntaxCheckResult::Valid && errorColumnNumber != 1) - QEXPECT_FAIL("", "QScriptSyntaxCheckResult::errorColumnNumber() doesn't return correct value", Continue); - QCOMPARE(result.errorColumnNumber(), errorColumnNumber); - QCOMPARE(result.errorMessage(), errorMessage); -} - - -QTEST_MAIN(tst_QScriptEngine) -#include "tst_qscriptengine.moc" diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptstring/qscriptstring.pro b/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptstring/qscriptstring.pro deleted file mode 100644 index 5ad9b7c..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptstring/qscriptstring.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = app -TARGET = tst_qscriptstring -QT += testlib -include(../tests.pri) - -SOURCES += tst_qscriptstring.cpp - diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptstring/tst_qscriptstring.cpp b/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptstring/tst_qscriptstring.cpp deleted file mode 100644 index ff31835..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptstring/tst_qscriptstring.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - Copyright (C) 2010 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 tst_qscriptstring_h -#define tst_qscriptstring_h - -#include "qscriptengine.h" -#include "qscriptstring.h" -#include -#include - -class tst_QScriptString : public QObject { - Q_OBJECT - -public: - tst_QScriptString(); - virtual ~tst_QScriptString(); - -private slots: - void test(); - void hash(); - void toArrayIndex_data(); - void toArrayIndex(); -}; - -tst_QScriptString::tst_QScriptString() -{ -} - -tst_QScriptString::~tst_QScriptString() -{ -} - -void tst_QScriptString::test() -{ - QScriptEngine eng; - { - QScriptString str; - QVERIFY(!str.isValid()); - QVERIFY(str == str); - QVERIFY(!(str != str)); - QVERIFY(str.toString().isNull()); - - QScriptString str1(str); - QVERIFY(!str1.isValid()); - - QScriptString str2 = str; - QVERIFY(!str2.isValid()); - - QCOMPARE(str.toArrayIndex(), quint32(0xffffffff)); - } - for (int x = 0; x < 2; ++x) { - QString ciao = QString::fromLatin1("ciao"); - QScriptString str = eng.toStringHandle(ciao); - QVERIFY(str.isValid()); - QVERIFY(str == str); - QVERIFY(!(str != str)); - QCOMPARE(str.toString(), ciao); - - QScriptString str1(str); - QCOMPARE(str, str1); - - QScriptString str2 = str; - QCOMPARE(str, str2); - - QScriptString str3 = eng.toStringHandle(ciao); - QVERIFY(str3.isValid()); - QCOMPARE(str, str3); - - eng.collectGarbage(); - - QVERIFY(str.isValid()); - QCOMPARE(str.toString(), ciao); - QVERIFY(str1.isValid()); - QCOMPARE(str1.toString(), ciao); - QVERIFY(str2.isValid()); - QCOMPARE(str2.toString(), ciao); - QVERIFY(str3.isValid()); - QCOMPARE(str3.toString(), ciao); - } - { - QScriptEngine* eng2 = new QScriptEngine; - QString one = QString::fromLatin1("one"); - QString two = QString::fromLatin1("two"); - QScriptString oneInterned = eng2->toStringHandle(one); - QCOMPARE(oneInterned.toString(), one); - QScriptString twoInterned = eng2->toStringHandle(two); - QCOMPARE(twoInterned.toString(), two); - QVERIFY(oneInterned != twoInterned); - QVERIFY(!(oneInterned == twoInterned)); - - delete eng2; - } -} - -void tst_QScriptString::hash() -{ - QScriptEngine engine; - QHash stringToInt; - QScriptString foo = engine.toStringHandle("foo"); - - QScriptString bar = engine.toStringHandle("bar"); - QVERIFY(!stringToInt.contains(foo)); - for (int i = 0; i < 1000000; ++i) - stringToInt.insert(foo, 123); - QCOMPARE(stringToInt.value(foo), 123); - QVERIFY(!stringToInt.contains(bar)); - stringToInt.insert(bar, 456); - QCOMPARE(stringToInt.value(bar), 456); - QCOMPARE(stringToInt.value(foo), 123); -} - -void tst_QScriptString::toArrayIndex_data() -{ - QTest::addColumn("input"); - QTest::addColumn("expectSuccess"); - QTest::addColumn("expectedIndex"); - QTest::newRow("foo") << QString::fromLatin1("foo") << false << quint32(0xffffffff); - QTest::newRow("empty") << QString::fromLatin1("") << false << quint32(0xffffffff); - QTest::newRow("0") << QString::fromLatin1("0") << true << quint32(0); - QTest::newRow("00") << QString::fromLatin1("00") << false << quint32(0xffffffff); - QTest::newRow("1") << QString::fromLatin1("1") << true << quint32(1); - QTest::newRow("123") << QString::fromLatin1("123") << true << quint32(123); - QTest::newRow("-1") << QString::fromLatin1("-1") << false << quint32(0xffffffff); - QTest::newRow("0a") << QString::fromLatin1("0a") << false << quint32(0xffffffff); - QTest::newRow("0x1") << QString::fromLatin1("0x1") << false << quint32(0xffffffff); - QTest::newRow("01") << QString::fromLatin1("01") << false << quint32(0xffffffff); - QTest::newRow("101a") << QString::fromLatin1("101a") << false << quint32(0xffffffff); - QTest::newRow("4294967294") << QString::fromLatin1("4294967294") << true << quint32(0xfffffffe); - QTest::newRow("4294967295") << QString::fromLatin1("4294967295") << false << quint32(0xffffffff); - QTest::newRow("11111111111") << QString::fromLatin1("11111111111") << false << quint32(0xffffffff); - QTest::newRow("0.0") << QString::fromLatin1("0.0") << false << quint32(0xffffffff); - QTest::newRow("1.0") << QString::fromLatin1("1.0") << false << quint32(0xffffffff); - QTest::newRow("1.5") << QString::fromLatin1("1.5") << false << quint32(0xffffffff); - QTest::newRow("1.") << QString::fromLatin1("1.") << false << quint32(0xffffffff); - QTest::newRow(".1") << QString::fromLatin1(".1") << false << quint32(0xffffffff); - QTest::newRow("1e0") << QString::fromLatin1("1e0") << false << quint32(0xffffffff); -} - -void tst_QScriptString::toArrayIndex() -{ - QFETCH(QString, input); - QFETCH(bool, expectSuccess); - QFETCH(quint32, expectedIndex); - QScriptEngine engine; - for (int x = 0; x < 2; ++x) { - bool isArrayIndex; - bool* ptr = (!x) ? &isArrayIndex : (bool*)0; - quint32 result = engine.toStringHandle(input).toArrayIndex(ptr); - if (!x) - QCOMPARE(isArrayIndex, expectSuccess); - QCOMPARE(result, expectedIndex); - } -} - -QTEST_MAIN(tst_QScriptString) -#include "tst_qscriptstring.moc" - -#endif // tst_qscriptstring_h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro b/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro deleted file mode 100644 index 35cc17d..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = app -TARGET = tst_qscriptvalue -QT += testlib -isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../../.. -include(../tests.pri) - -SOURCES += \ - tst_qscriptvalue.cpp \ - tst_qscriptvalue_generated.cpp - -HEADERS += \ - tst_qscriptvalue.h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp b/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp deleted file mode 100644 index 82f0901..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp +++ /dev/null @@ -1,435 +0,0 @@ -/* - Copyright (C) 2009 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 "tst_qscriptvalue.h" -#include - -tst_QScriptValue::tst_QScriptValue() - : engine(0) -{ -} - -tst_QScriptValue::~tst_QScriptValue() -{ - delete engine; -} - -void tst_QScriptValue::dataHelper(InitDataFunction init, DefineDataFunction define) -{ - QTest::addColumn("__expression__"); - (this->*init)(); - QHash::const_iterator it; - for (it = m_values.constBegin(); it != m_values.constEnd(); ++it) { - m_currentExpression = it.key(); - (this->*define)(it.key().toLatin1()); - } - m_currentExpression = QString(); -} - -QTestData& tst_QScriptValue::newRow(const char* tag) -{ - return QTest::newRow(tag) << m_currentExpression; -} - -void tst_QScriptValue::testHelper(TestFunction fun) -{ - QFETCH(QString, __expression__); - QScriptValue value = m_values.value(__expression__); - (this->*fun)(__expression__.toLatin1(), value); -} - - -void tst_QScriptValue::ctor() -{ - QScriptEngine eng; - { - QScriptValue v; - QCOMPARE(v.isValid(), false); - QCOMPARE(v.engine(), (QScriptEngine*)0); - } - { - QScriptValue v(&eng, QScriptValue::UndefinedValue); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isUndefined(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), &eng); - } - { - QScriptValue v(&eng, QScriptValue::NullValue); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isNull(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), &eng); - } - { - QScriptValue v(&eng, false); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isBoolean(), true); - QCOMPARE(v.isBool(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toBoolean(), false); - QCOMPARE(v.engine(), &eng); - } - { - QScriptValue v(&eng, int(1)); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), &eng); - } - { - QScriptValue v(int(0x43211234)); - QVERIFY(v.isNumber()); - QCOMPARE(v.toInt32(), 0x43211234); - } - { - QScriptValue v(&eng, uint(1)); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), &eng); - } - { - QScriptValue v(uint(0x43211234)); - QVERIFY(v.isNumber()); - QCOMPARE(v.toUInt32(), uint(0x43211234)); - } - { - QScriptValue v(&eng, 1.0); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), &eng); - } - { - QScriptValue v(12345678910.5); - QVERIFY(v.isNumber()); - QCOMPARE(v.toNumber(), 12345678910.5); - } - { - QScriptValue v(&eng, "ciao"); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isString(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toString(), QLatin1String("ciao")); - QCOMPARE(v.engine(), &eng); - } - { - QScriptValue v(&eng, QString("ciao")); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isString(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toString(), QLatin1String("ciao")); - QCOMPARE(v.engine(), &eng); - } - // copy constructor, operator= - { - QScriptValue v(&eng, 1.0); - QScriptValue v2(v); - QCOMPARE(v2.strictlyEquals(v), true); - QCOMPARE(v2.engine(), &eng); - - QScriptValue v3(v); - QCOMPARE(v3.strictlyEquals(v), true); - QCOMPARE(v3.strictlyEquals(v2), true); - QCOMPARE(v3.engine(), &eng); - - QScriptValue v4(&eng, 2.0); - QCOMPARE(v4.strictlyEquals(v), false); - v3 = v4; - QCOMPARE(v3.strictlyEquals(v), false); - QCOMPARE(v3.strictlyEquals(v4), true); - - v2 = QScriptValue(); - QCOMPARE(v2.strictlyEquals(v), false); - QCOMPARE(v.toNumber(), 1.0); - - QScriptValue v5(v); - QCOMPARE(v5.strictlyEquals(v), true); - v = QScriptValue(); - QCOMPARE(v5.strictlyEquals(v), false); - QCOMPARE(v5.toNumber(), 1.0); - } - - // constructors that take no engine argument - { - QScriptValue v(QScriptValue::UndefinedValue); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isUndefined(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), (QScriptEngine*)0); - } - { - QScriptValue v(QScriptValue::NullValue); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isNull(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), (QScriptEngine*)0); - } - { - QScriptValue v(false); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isBoolean(), true); - QCOMPARE(v.isBool(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toBoolean(), false); - QCOMPARE(v.engine(), (QScriptEngine*)0); - } - { - QScriptValue v(int(1)); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QScriptEngine*)0); - } - { - QScriptValue v(uint(1)); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QScriptEngine*)0); - } - { - QScriptValue v(1.0); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QScriptEngine*)0); - } - { - QScriptValue v("ciao"); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isString(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toString(), QLatin1String("ciao")); - QCOMPARE(v.engine(), (QScriptEngine*)0); - } - { - QScriptValue v(QString("ciao")); - QCOMPARE(v.isValid(), true); - QCOMPARE(v.isString(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toString(), QLatin1String("ciao")); - QCOMPARE(v.engine(), (QScriptEngine*)0); - } - // copy constructor, operator= - { - QScriptValue v(1.0); - QScriptValue v2(v); - QCOMPARE(v2.strictlyEquals(v), true); - QCOMPARE(v2.engine(), (QScriptEngine*)0); - - QScriptValue v3(v); - QCOMPARE(v3.strictlyEquals(v), true); - QCOMPARE(v3.strictlyEquals(v2), true); - QCOMPARE(v3.engine(), (QScriptEngine*)0); - - QScriptValue v4(2.0); - QCOMPARE(v4.strictlyEquals(v), false); - v3 = v4; - QCOMPARE(v3.strictlyEquals(v), false); - QCOMPARE(v3.strictlyEquals(v4), true); - - v2 = QScriptValue(); - QCOMPARE(v2.strictlyEquals(v), false); - QCOMPARE(v.toNumber(), 1.0); - - QScriptValue v5(v); - QCOMPARE(v5.strictlyEquals(v), true); - v = QScriptValue(); - QCOMPARE(v5.strictlyEquals(v), false); - QCOMPARE(v5.toNumber(), 1.0); - } - - // 0 engine - QVERIFY(QScriptValue(0, QScriptValue::UndefinedValue).isUndefined()); - QVERIFY(QScriptValue(0, QScriptValue::NullValue).isNull()); - QVERIFY(QScriptValue(0, false).isBool()); - QVERIFY(QScriptValue(0, int(1)).isNumber()); - QVERIFY(QScriptValue(0, uint(1)).isNumber()); - QVERIFY(QScriptValue(0, 1.0).isNumber()); - QVERIFY(QScriptValue(0, "ciao").isString()); - QVERIFY(QScriptValue(0, QString("ciao")).isString()); -} - -void tst_QScriptValue::toStringSimple_data() -{ - QTest::addColumn("code"); - QTest::addColumn("result"); - - QTest::newRow("string") << QString::fromAscii("'hello'") << QString::fromAscii("hello"); - QTest::newRow("string utf") << QString::fromUtf8("'ąśćżźółńę'") << QString::fromUtf8("ąśćżźółńę"); - QTest::newRow("expression") << QString::fromAscii("1 + 4") << QString::fromAscii("5"); - QTest::newRow("null") << QString::fromAscii("null") << QString::fromAscii("null"); - QTest::newRow("boolean") << QString::fromAscii("false") << QString::fromAscii("false"); - QTest::newRow("undefined") << QString::fromAscii("undefined") << QString::fromAscii("undefined"); - QTest::newRow("object") << QString::fromAscii("new Object") << QString::fromAscii("[object Object]"); -} - -/* Test conversion to string from different JSC types */ -void tst_QScriptValue::toStringSimple() -{ - QFETCH(QString, code); - QFETCH(QString, result); - - QScriptEngine engine; - QCOMPARE(engine.evaluate(code).toString(), result); -} - -void tst_QScriptValue::copyConstructor_data() -{ - QScriptEngine engine; - QScriptValue nnumber(123); - QScriptValue nstring("ping"); - QScriptValue number(engine.evaluate("1")); - QScriptValue string(engine.evaluate("'foo'")); - QScriptValue object(engine.evaluate("new Object")); - QScriptValue undefined(engine.evaluate("undefined")); - QScriptValue null(engine.evaluate("null")); - - QTest::addColumn("value"); - QTest::addColumn("result"); - - QTest::newRow("native number") << nnumber << QString::number(123); - QTest::newRow("native string") << nstring << QString("ping"); - QTest::newRow("number") << number << QString::fromAscii("1"); - QTest::newRow("string") << string << QString::fromAscii("foo"); - QTest::newRow("object") << object << QString::fromAscii("[object Object]"); - QTest::newRow("undefined") << undefined << QString::fromAscii("undefined"); - QTest::newRow("null") << null << QString::fromAscii("null"); -} - -void tst_QScriptValue::copyConstructor() -{ - QFETCH(QScriptValue, value); - QFETCH(QString, result); - - QVERIFY(value.isValid()); - QScriptValue tmp(value); - QVERIFY(tmp.isValid()); - QCOMPARE(tmp.toString(), result); -} - -void tst_QScriptValue::assignOperator_data() -{ - copyConstructor_data(); -} - -void tst_QScriptValue::assignOperator() -{ - QFETCH(QScriptValue, value); - QFETCH(QString, result); - - QScriptValue tmp; - tmp = value; - QVERIFY(tmp.isValid()); - QCOMPARE(tmp.toString(), result); -} - -/* Test internal data sharing between a diffrenet QScriptValue. */ -void tst_QScriptValue::dataSharing() -{ - QScriptEngine engine; - QScriptValue v1; - QScriptValue v2(v1); - - v1 = engine.evaluate("1"); // v1 == 1 ; v2 invalid. - QVERIFY(v1.isValid()); - QVERIFY(!v2.isValid()); - - v2 = v1; // v1 == 1; v2 == 1. - QVERIFY(v1.isValid()); - QVERIFY(v2.isValid()); - - v1 = engine.evaluate("obj = new Date"); // v1 == [object Date] ; v2 == 1. - QVERIFY(v1.isValid()); - QVERIFY(v2.isValid()); - QVERIFY(v2.toString() != v1.toString()); - - // TODO add object manipulation (v1 and v2 point to the same object). -} - -void tst_QScriptValue::constructors_data() -{ - QScriptEngine engine; - - QTest::addColumn("value"); - QTest::addColumn("string"); - QTest::addColumn("valid"); - QTest::addColumn("object"); - - QTest::newRow("invalid") << QScriptValue() << QString() << false << false; - QTest::newRow("number") << QScriptValue(-21) << QString::number(-21) << true << false; - QTest::newRow("bool") << QScriptValue(true) << QString::fromAscii("true") << true << false; - QTest::newRow("double") << QScriptValue(21.12) << QString::number(21.12) << true << false; - QTest::newRow("string") << QScriptValue("AlaMaKota") << QString::fromAscii("AlaMaKota") << true << false; - QTest::newRow("object") << engine.evaluate("new Object") << QString::fromAscii("[object Object]") << true << true; - QTest::newRow("null") << QScriptValue(QScriptValue::NullValue)<< QString::fromAscii("null") << true << false; - QTest::newRow("undef") << QScriptValue(QScriptValue::UndefinedValue)<< QString::fromAscii("undefined") << true << false; -} - -void tst_QScriptValue::constructors() -{ - QFETCH(QScriptValue, value); - QFETCH(QString, string); - QFETCH(bool, valid); - QFETCH(bool, object); - - QCOMPARE(value.isValid(), valid); - QCOMPARE(value.toString(), string); - QCOMPARE(value.isObject(), object); -} - -void tst_QScriptValue::call() -{ - QScriptEngine engine; - QScriptValue ping = engine.evaluate("( function() {return 'ping';} )"); - QScriptValue incr = engine.evaluate("( function(i) {return i + 1;} )"); - QScriptValue one(1); - QScriptValue five(5); - QScriptValue result; - - QVERIFY(one.isValid()); - QVERIFY(five.isValid()); - - QVERIFY(ping.isValid()); - QVERIFY(ping.isFunction()); - result = ping.call(); - QVERIFY(result.isValid()); - QCOMPARE(result.toString(), QString::fromUtf8("ping")); - - QVERIFY(incr.isValid()); - QVERIFY(incr.isFunction()); - result = incr.call(QScriptValue(), QScriptValueList() << one); - QVERIFY(result.isValid()); - QCOMPARE(result.toString(), QString("2")); - - QCOMPARE(incr.call(QScriptValue(), QScriptValueList() << five).toString(), QString::fromAscii("6")); - - QVERIFY(incr.call().isValid()); // Exception. -} - - -QTEST_MAIN(tst_QScriptValue) diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h b/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h deleted file mode 100644 index 28154a9..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - Copyright (C) 2010 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 tst_qscriptvalue_h -#define tst_qscriptvalue_h - -#include "qscriptengine.h" -#include "qscriptvalue.h" -#include -#include - -Q_DECLARE_METATYPE(QScriptValue*); -Q_DECLARE_METATYPE(QScriptValue); - -class tst_QScriptValue : public QObject { - Q_OBJECT - -public: - tst_QScriptValue(); - virtual ~tst_QScriptValue(); - -private slots: - void toStringSimple_data(); - void toStringSimple(); - void copyConstructor_data(); - void copyConstructor(); - void assignOperator_data(); - void assignOperator(); - void dataSharing(); - void constructors_data(); - void constructors(); - void call(); - void ctor(); - - // Generated test functions. - void isBool_data(); - void isBool(); - - void isBoolean_data(); - void isBoolean(); - - void isNumber_data(); - void isNumber(); - - void isFunction_data(); - void isFunction(); - - void isNull_data(); - void isNull(); - - void isObject_data(); - void isObject(); - - void isString_data(); - void isString(); - - void isUndefined_data(); - void isUndefined(); - - void isValid_data(); - void isValid(); - - void toString_data(); - void toString(); - - void toNumber_data(); - void toNumber(); - - void toBool_data(); - void toBool(); - - void toBoolean_data(); - void toBoolean(); - - void toInteger_data(); - void toInteger(); - - void toInt32_data(); - void toInt32(); - - void toUInt32_data(); - void toUInt32(); - - void toUInt16_data(); - void toUInt16(); - -private: - typedef void (tst_QScriptValue::*InitDataFunction)(); - typedef void (tst_QScriptValue::*DefineDataFunction)(const char*); - void dataHelper(InitDataFunction init, DefineDataFunction define); - QTestData& newRow(const char* tag); - - typedef void (tst_QScriptValue::*TestFunction)(const char*, const QScriptValue&); - void testHelper(TestFunction fun); - - // Generated functions - - void initScriptValues(); - - void isBool_initData(); - void isBool_makeData(const char* expr); - void isBool_test(const char* expr, const QScriptValue& value); - - void isBoolean_initData(); - void isBoolean_makeData(const char* expr); - void isBoolean_test(const char* expr, const QScriptValue& value); - - void isNumber_initData(); - void isNumber_makeData(const char* expr); - void isNumber_test(const char* expr, const QScriptValue&); - - void isFunction_initData(); - void isFunction_makeData(const char* expr); - void isFunction_test(const char* expr, const QScriptValue& value); - - void isNull_initData(); - void isNull_makeData(const char* expr); - void isNull_test(const char* expr, const QScriptValue& value); - - void isObject_initData(); - void isObject_makeData(const char* expr); - void isObject_test(const char* expr, const QScriptValue& value); - - void isString_initData(); - void isString_makeData(const char* expr); - void isString_test(const char* expr, const QScriptValue& value); - - void isUndefined_initData(); - void isUndefined_makeData(const char* expr); - void isUndefined_test(const char* expr, const QScriptValue& value); - - void isValid_initData(); - void isValid_makeData(const char* expr); - void isValid_test(const char* expr, const QScriptValue& value); - - void toString_initData(); - void toString_makeData(const char*); - void toString_test(const char*, const QScriptValue&); - - void toNumber_initData(); - void toNumber_makeData(const char*); - void toNumber_test(const char*, const QScriptValue&); - - void toBool_initData(); - void toBool_makeData(const char*); - void toBool_test(const char*, const QScriptValue&); - - void toBoolean_initData(); - void toBoolean_makeData(const char*); - void toBoolean_test(const char*, const QScriptValue&); - - void toInteger_initData(); - void toInteger_makeData(const char*); - void toInteger_test(const char*, const QScriptValue&); - - void toInt32_initData(); - void toInt32_makeData(const char*); - void toInt32_test(const char*, const QScriptValue&); - - void toUInt32_initData(); - void toUInt32_makeData(const char*); - void toUInt32_test(const char*, const QScriptValue&); - - void toUInt16_initData(); - void toUInt16_makeData(const char*); - void toUInt16_test(const char*, const QScriptValue&); - -private: - QScriptEngine* engine; - QHash m_values; - QString m_currentExpression; -}; - -#define DEFINE_TEST_FUNCTION(name) \ -void tst_QScriptValue::name##_data() { dataHelper(&tst_QScriptValue::name##_initData, &tst_QScriptValue::name##_makeData); } \ -void tst_QScriptValue::name() { testHelper(&tst_QScriptValue::name##_test); } - - - -#endif // tst_qscriptvalue_h diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp b/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp deleted file mode 100644 index 970c960..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp +++ /dev/null @@ -1,1922 +0,0 @@ -/* - Copyright (C) 2010 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 "tst_qscriptvalue.h" - -#define DEFINE_TEST_VALUE(expr) m_values.insert(QString::fromLatin1(#expr), expr) - -void tst_QScriptValue::initScriptValues() -{ - m_values.clear(); - if (engine) - delete engine; - engine = new QScriptEngine; - DEFINE_TEST_VALUE(QScriptValue()); - DEFINE_TEST_VALUE(QScriptValue(QScriptValue::UndefinedValue)); - DEFINE_TEST_VALUE(QScriptValue(QScriptValue::NullValue)); - DEFINE_TEST_VALUE(QScriptValue(true)); - DEFINE_TEST_VALUE(QScriptValue(false)); - DEFINE_TEST_VALUE(QScriptValue(int(122))); - DEFINE_TEST_VALUE(QScriptValue(uint(124))); - DEFINE_TEST_VALUE(QScriptValue(0)); - DEFINE_TEST_VALUE(QScriptValue(0.0)); - DEFINE_TEST_VALUE(QScriptValue(123.0)); - DEFINE_TEST_VALUE(QScriptValue(6.37e-8)); - DEFINE_TEST_VALUE(QScriptValue(-6.37e-8)); - DEFINE_TEST_VALUE(QScriptValue(0x43211234)); - DEFINE_TEST_VALUE(QScriptValue(0x10000)); - DEFINE_TEST_VALUE(QScriptValue(0x10001)); - DEFINE_TEST_VALUE(QScriptValue(qSNaN())); - DEFINE_TEST_VALUE(QScriptValue(qQNaN())); - DEFINE_TEST_VALUE(QScriptValue(qInf())); - DEFINE_TEST_VALUE(QScriptValue(-qInf())); - DEFINE_TEST_VALUE(QScriptValue("NaN")); - DEFINE_TEST_VALUE(QScriptValue("Infinity")); - DEFINE_TEST_VALUE(QScriptValue("-Infinity")); - DEFINE_TEST_VALUE(QScriptValue("ciao")); - DEFINE_TEST_VALUE(QScriptValue(QString::fromLatin1("ciao"))); - DEFINE_TEST_VALUE(QScriptValue(QString(""))); - DEFINE_TEST_VALUE(QScriptValue(QString())); - DEFINE_TEST_VALUE(QScriptValue(QString("0"))); - DEFINE_TEST_VALUE(QScriptValue(QString("123"))); - DEFINE_TEST_VALUE(QScriptValue(QString("12.4"))); - DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::UndefinedValue)); - DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::NullValue)); - DEFINE_TEST_VALUE(QScriptValue(0, true)); - DEFINE_TEST_VALUE(QScriptValue(0, false)); - DEFINE_TEST_VALUE(QScriptValue(0, int(122))); - DEFINE_TEST_VALUE(QScriptValue(0, uint(124))); - DEFINE_TEST_VALUE(QScriptValue(0, 0)); - DEFINE_TEST_VALUE(QScriptValue(0, 0.0)); - DEFINE_TEST_VALUE(QScriptValue(0, 123.0)); - DEFINE_TEST_VALUE(QScriptValue(0, 6.37e-8)); - DEFINE_TEST_VALUE(QScriptValue(0, -6.37e-8)); - DEFINE_TEST_VALUE(QScriptValue(0, 0x43211234)); - DEFINE_TEST_VALUE(QScriptValue(0, 0x10000)); - DEFINE_TEST_VALUE(QScriptValue(0, 0x10001)); - DEFINE_TEST_VALUE(QScriptValue(0, qSNaN())); - DEFINE_TEST_VALUE(QScriptValue(0, qQNaN())); - DEFINE_TEST_VALUE(QScriptValue(0, qInf())); - DEFINE_TEST_VALUE(QScriptValue(0, -qInf())); - DEFINE_TEST_VALUE(QScriptValue(0, "NaN")); - DEFINE_TEST_VALUE(QScriptValue(0, "Infinity")); - DEFINE_TEST_VALUE(QScriptValue(0, "-Infinity")); - DEFINE_TEST_VALUE(QScriptValue(0, "ciao")); - DEFINE_TEST_VALUE(QScriptValue(0, QString::fromLatin1("ciao"))); - DEFINE_TEST_VALUE(QScriptValue(0, QString(""))); - DEFINE_TEST_VALUE(QScriptValue(0, QString())); - DEFINE_TEST_VALUE(QScriptValue(0, QString("0"))); - DEFINE_TEST_VALUE(QScriptValue(0, QString("123"))); - DEFINE_TEST_VALUE(QScriptValue(0, QString("12.3"))); - DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::UndefinedValue)); - DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::NullValue)); - DEFINE_TEST_VALUE(QScriptValue(engine, true)); - DEFINE_TEST_VALUE(QScriptValue(engine, false)); - DEFINE_TEST_VALUE(QScriptValue(engine, int(122))); - DEFINE_TEST_VALUE(QScriptValue(engine, uint(124))); - DEFINE_TEST_VALUE(QScriptValue(engine, 0)); - DEFINE_TEST_VALUE(QScriptValue(engine, 0.0)); - DEFINE_TEST_VALUE(QScriptValue(engine, 123.0)); - DEFINE_TEST_VALUE(QScriptValue(engine, 6.37e-8)); - DEFINE_TEST_VALUE(QScriptValue(engine, -6.37e-8)); - DEFINE_TEST_VALUE(QScriptValue(engine, 0x43211234)); - DEFINE_TEST_VALUE(QScriptValue(engine, 0x10000)); - DEFINE_TEST_VALUE(QScriptValue(engine, 0x10001)); - DEFINE_TEST_VALUE(QScriptValue(engine, qSNaN())); - DEFINE_TEST_VALUE(QScriptValue(engine, qQNaN())); - DEFINE_TEST_VALUE(QScriptValue(engine, qInf())); - DEFINE_TEST_VALUE(QScriptValue(engine, -qInf())); - DEFINE_TEST_VALUE(QScriptValue(engine, "NaN")); - DEFINE_TEST_VALUE(QScriptValue(engine, "Infinity")); - DEFINE_TEST_VALUE(QScriptValue(engine, "-Infinity")); - DEFINE_TEST_VALUE(QScriptValue(engine, "ciao")); - DEFINE_TEST_VALUE(QScriptValue(engine, QString::fromLatin1("ciao"))); - DEFINE_TEST_VALUE(QScriptValue(engine, QString(""))); - DEFINE_TEST_VALUE(QScriptValue(engine, QString())); - DEFINE_TEST_VALUE(QScriptValue(engine, QString("0"))); - DEFINE_TEST_VALUE(QScriptValue(engine, QString("123"))); - DEFINE_TEST_VALUE(QScriptValue(engine, QString("1.23"))); - DEFINE_TEST_VALUE(engine->evaluate("[]")); - DEFINE_TEST_VALUE(engine->evaluate("{}")); - DEFINE_TEST_VALUE(engine->evaluate("Object.prototype")); - DEFINE_TEST_VALUE(engine->evaluate("Date.prototype")); - DEFINE_TEST_VALUE(engine->evaluate("Array.prototype")); - DEFINE_TEST_VALUE(engine->evaluate("Function.prototype")); - DEFINE_TEST_VALUE(engine->evaluate("Error.prototype")); - DEFINE_TEST_VALUE(engine->evaluate("Object")); - DEFINE_TEST_VALUE(engine->evaluate("Array")); - DEFINE_TEST_VALUE(engine->evaluate("Number")); - DEFINE_TEST_VALUE(engine->evaluate("Function")); - DEFINE_TEST_VALUE(engine->evaluate("(function() { return 1; })")); - DEFINE_TEST_VALUE(engine->evaluate("(function() { return 'ciao'; })")); - DEFINE_TEST_VALUE(engine->evaluate("(function() { throw new Error('foo'); })")); - DEFINE_TEST_VALUE(engine->evaluate("/foo/")); - DEFINE_TEST_VALUE(engine->evaluate("new Object()")); - DEFINE_TEST_VALUE(engine->evaluate("new Array()")); - DEFINE_TEST_VALUE(engine->evaluate("new Error()")); - DEFINE_TEST_VALUE(engine->evaluate("a = new Object(); a.foo = 22; a.foo")); - DEFINE_TEST_VALUE(engine->evaluate("Undefined")); - DEFINE_TEST_VALUE(engine->evaluate("Null")); - DEFINE_TEST_VALUE(engine->evaluate("True")); - DEFINE_TEST_VALUE(engine->evaluate("False")); - DEFINE_TEST_VALUE(engine->evaluate("undefined")); - DEFINE_TEST_VALUE(engine->evaluate("null")); - DEFINE_TEST_VALUE(engine->evaluate("true")); - DEFINE_TEST_VALUE(engine->evaluate("false")); - DEFINE_TEST_VALUE(engine->evaluate("122")); - DEFINE_TEST_VALUE(engine->evaluate("124")); - DEFINE_TEST_VALUE(engine->evaluate("0")); - DEFINE_TEST_VALUE(engine->evaluate("0.0")); - DEFINE_TEST_VALUE(engine->evaluate("123.0")); - DEFINE_TEST_VALUE(engine->evaluate("6.37e-8")); - DEFINE_TEST_VALUE(engine->evaluate("-6.37e-8")); - DEFINE_TEST_VALUE(engine->evaluate("0x43211234")); - DEFINE_TEST_VALUE(engine->evaluate("0x10000")); - DEFINE_TEST_VALUE(engine->evaluate("0x10001")); - DEFINE_TEST_VALUE(engine->evaluate("NaN")); - DEFINE_TEST_VALUE(engine->evaluate("Infinity")); - DEFINE_TEST_VALUE(engine->evaluate("-Infinity")); - DEFINE_TEST_VALUE(engine->evaluate("'ciao'")); - DEFINE_TEST_VALUE(engine->evaluate("''")); - DEFINE_TEST_VALUE(engine->evaluate("'0'")); - DEFINE_TEST_VALUE(engine->evaluate("'123'")); - DEFINE_TEST_VALUE(engine->evaluate("'12.4'")); - DEFINE_TEST_VALUE(engine->nullValue()); - DEFINE_TEST_VALUE(engine->undefinedValue()); -} - - -void tst_QScriptValue::isValid_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::isValid_makeData(const char* expr) -{ - static QSet isValid; - if (isValid.isEmpty()) { - isValid << "QScriptValue(QScriptValue::UndefinedValue)" - << "QScriptValue(QScriptValue::NullValue)" - << "QScriptValue(true)" - << "QScriptValue(false)" - << "QScriptValue(int(122))" - << "QScriptValue(uint(124))" - << "QScriptValue(0)" - << "QScriptValue(0.0)" - << "QScriptValue(123.0)" - << "QScriptValue(6.37e-8)" - << "QScriptValue(-6.37e-8)" - << "QScriptValue(0x43211234)" - << "QScriptValue(0x10000)" - << "QScriptValue(0x10001)" - << "QScriptValue(qSNaN())" - << "QScriptValue(qQNaN())" - << "QScriptValue(qInf())" - << "QScriptValue(-qInf())" - << "QScriptValue(\"NaN\")" - << "QScriptValue(\"Infinity\")" - << "QScriptValue(\"-Infinity\")" - << "QScriptValue(\"ciao\")" - << "QScriptValue(QString::fromLatin1(\"ciao\"))" - << "QScriptValue(QString(\"\"))" - << "QScriptValue(QString())" - << "QScriptValue(QString(\"0\"))" - << "QScriptValue(QString(\"123\"))" - << "QScriptValue(QString(\"12.4\"))" - << "QScriptValue(0, QScriptValue::UndefinedValue)" - << "QScriptValue(0, QScriptValue::NullValue)" - << "QScriptValue(0, true)" - << "QScriptValue(0, false)" - << "QScriptValue(0, int(122))" - << "QScriptValue(0, uint(124))" - << "QScriptValue(0, 0)" - << "QScriptValue(0, 0.0)" - << "QScriptValue(0, 123.0)" - << "QScriptValue(0, 6.37e-8)" - << "QScriptValue(0, -6.37e-8)" - << "QScriptValue(0, 0x43211234)" - << "QScriptValue(0, 0x10000)" - << "QScriptValue(0, 0x10001)" - << "QScriptValue(0, qSNaN())" - << "QScriptValue(0, qQNaN())" - << "QScriptValue(0, qInf())" - << "QScriptValue(0, -qInf())" - << "QScriptValue(0, \"NaN\")" - << "QScriptValue(0, \"Infinity\")" - << "QScriptValue(0, \"-Infinity\")" - << "QScriptValue(0, \"ciao\")" - << "QScriptValue(0, QString::fromLatin1(\"ciao\"))" - << "QScriptValue(0, QString(\"\"))" - << "QScriptValue(0, QString())" - << "QScriptValue(0, QString(\"0\"))" - << "QScriptValue(0, QString(\"123\"))" - << "QScriptValue(0, QString(\"12.3\"))" - << "QScriptValue(engine, QScriptValue::UndefinedValue)" - << "QScriptValue(engine, QScriptValue::NullValue)" - << "QScriptValue(engine, true)" - << "QScriptValue(engine, false)" - << "QScriptValue(engine, int(122))" - << "QScriptValue(engine, uint(124))" - << "QScriptValue(engine, 0)" - << "QScriptValue(engine, 0.0)" - << "QScriptValue(engine, 123.0)" - << "QScriptValue(engine, 6.37e-8)" - << "QScriptValue(engine, -6.37e-8)" - << "QScriptValue(engine, 0x43211234)" - << "QScriptValue(engine, 0x10000)" - << "QScriptValue(engine, 0x10001)" - << "QScriptValue(engine, qSNaN())" - << "QScriptValue(engine, qQNaN())" - << "QScriptValue(engine, qInf())" - << "QScriptValue(engine, -qInf())" - << "QScriptValue(engine, \"NaN\")" - << "QScriptValue(engine, \"Infinity\")" - << "QScriptValue(engine, \"-Infinity\")" - << "QScriptValue(engine, \"ciao\")" - << "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" - << "QScriptValue(engine, QString(\"\"))" - << "QScriptValue(engine, QString())" - << "QScriptValue(engine, QString(\"0\"))" - << "QScriptValue(engine, QString(\"123\"))" - << "QScriptValue(engine, QString(\"1.23\"))" - << "engine->evaluate(\"[]\")" - << "engine->evaluate(\"{}\")" - << "engine->evaluate(\"Object.prototype\")" - << "engine->evaluate(\"Date.prototype\")" - << "engine->evaluate(\"Array.prototype\")" - << "engine->evaluate(\"Function.prototype\")" - << "engine->evaluate(\"Error.prototype\")" - << "engine->evaluate(\"Object\")" - << "engine->evaluate(\"Array\")" - << "engine->evaluate(\"Number\")" - << "engine->evaluate(\"Function\")" - << "engine->evaluate(\"(function() { return 1; })\")" - << "engine->evaluate(\"(function() { return 'ciao'; })\")" - << "engine->evaluate(\"(function() { throw new Error('foo'); })\")" - << "engine->evaluate(\"/foo/\")" - << "engine->evaluate(\"new Object()\")" - << "engine->evaluate(\"new Array()\")" - << "engine->evaluate(\"new Error()\")" - << "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")" - << "engine->evaluate(\"Undefined\")" - << "engine->evaluate(\"Null\")" - << "engine->evaluate(\"True\")" - << "engine->evaluate(\"False\")" - << "engine->evaluate(\"undefined\")" - << "engine->evaluate(\"null\")" - << "engine->evaluate(\"true\")" - << "engine->evaluate(\"false\")" - << "engine->evaluate(\"122\")" - << "engine->evaluate(\"124\")" - << "engine->evaluate(\"0\")" - << "engine->evaluate(\"0.0\")" - << "engine->evaluate(\"123.0\")" - << "engine->evaluate(\"6.37e-8\")" - << "engine->evaluate(\"-6.37e-8\")" - << "engine->evaluate(\"0x43211234\")" - << "engine->evaluate(\"0x10000\")" - << "engine->evaluate(\"0x10001\")" - << "engine->evaluate(\"NaN\")" - << "engine->evaluate(\"Infinity\")" - << "engine->evaluate(\"-Infinity\")" - << "engine->evaluate(\"'ciao'\")" - << "engine->evaluate(\"''\")" - << "engine->evaluate(\"'0'\")" - << "engine->evaluate(\"'123'\")" - << "engine->evaluate(\"'12.4'\")" - << "engine->nullValue()" - << "engine->undefinedValue()"; - } - newRow(expr) << isValid.contains(expr); -} - -void tst_QScriptValue::isValid_test(const char*, const QScriptValue& value) -{ - QFETCH(bool, expected); - QCOMPARE(value.isValid(), expected); - QCOMPARE(value.isValid(), expected); -} - -DEFINE_TEST_FUNCTION(isValid) - - -void tst_QScriptValue::isBool_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::isBool_makeData(const char* expr) -{ - static QSet isBool; - if (isBool.isEmpty()) { - isBool << "QScriptValue(true)" - << "QScriptValue(false)" - << "QScriptValue(0, true)" - << "QScriptValue(0, false)" - << "QScriptValue(engine, true)" - << "QScriptValue(engine, false)" - << "engine->evaluate(\"true\")" - << "engine->evaluate(\"false\")"; - } - newRow(expr) << isBool.contains(expr); -} - -void tst_QScriptValue::isBool_test(const char*, const QScriptValue& value) -{ - QFETCH(bool, expected); - QCOMPARE(value.isBool(), expected); - QCOMPARE(value.isBool(), expected); -} - -DEFINE_TEST_FUNCTION(isBool) - - -void tst_QScriptValue::isBoolean_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::isBoolean_makeData(const char* expr) -{ - static QSet isBoolean; - if (isBoolean.isEmpty()) { - isBoolean << "QScriptValue(true)" - << "QScriptValue(false)" - << "QScriptValue(0, true)" - << "QScriptValue(0, false)" - << "QScriptValue(engine, true)" - << "QScriptValue(engine, false)" - << "engine->evaluate(\"true\")" - << "engine->evaluate(\"false\")"; - } - newRow(expr) << isBoolean.contains(expr); -} - -void tst_QScriptValue::isBoolean_test(const char*, const QScriptValue& value) -{ - QFETCH(bool, expected); - QCOMPARE(value.isBoolean(), expected); - QCOMPARE(value.isBoolean(), expected); -} - -DEFINE_TEST_FUNCTION(isBoolean) - - -void tst_QScriptValue::isNumber_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::isNumber_makeData(const char* expr) -{ - static QSet isNumber; - if (isNumber.isEmpty()) { - isNumber << "QScriptValue(int(122))" - << "QScriptValue(uint(124))" - << "QScriptValue(0)" - << "QScriptValue(0.0)" - << "QScriptValue(123.0)" - << "QScriptValue(6.37e-8)" - << "QScriptValue(-6.37e-8)" - << "QScriptValue(0x43211234)" - << "QScriptValue(0x10000)" - << "QScriptValue(0x10001)" - << "QScriptValue(qSNaN())" - << "QScriptValue(qQNaN())" - << "QScriptValue(qInf())" - << "QScriptValue(-qInf())" - << "QScriptValue(0, int(122))" - << "QScriptValue(0, uint(124))" - << "QScriptValue(0, 0)" - << "QScriptValue(0, 0.0)" - << "QScriptValue(0, 123.0)" - << "QScriptValue(0, 6.37e-8)" - << "QScriptValue(0, -6.37e-8)" - << "QScriptValue(0, 0x43211234)" - << "QScriptValue(0, 0x10000)" - << "QScriptValue(0, 0x10001)" - << "QScriptValue(0, qSNaN())" - << "QScriptValue(0, qQNaN())" - << "QScriptValue(0, qInf())" - << "QScriptValue(0, -qInf())" - << "QScriptValue(engine, int(122))" - << "QScriptValue(engine, uint(124))" - << "QScriptValue(engine, 0)" - << "QScriptValue(engine, 0.0)" - << "QScriptValue(engine, 123.0)" - << "QScriptValue(engine, 6.37e-8)" - << "QScriptValue(engine, -6.37e-8)" - << "QScriptValue(engine, 0x43211234)" - << "QScriptValue(engine, 0x10000)" - << "QScriptValue(engine, 0x10001)" - << "QScriptValue(engine, qSNaN())" - << "QScriptValue(engine, qQNaN())" - << "QScriptValue(engine, qInf())" - << "QScriptValue(engine, -qInf())" - << "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")" - << "engine->evaluate(\"122\")" - << "engine->evaluate(\"124\")" - << "engine->evaluate(\"0\")" - << "engine->evaluate(\"0.0\")" - << "engine->evaluate(\"123.0\")" - << "engine->evaluate(\"6.37e-8\")" - << "engine->evaluate(\"-6.37e-8\")" - << "engine->evaluate(\"0x43211234\")" - << "engine->evaluate(\"0x10000\")" - << "engine->evaluate(\"0x10001\")" - << "engine->evaluate(\"NaN\")" - << "engine->evaluate(\"Infinity\")" - << "engine->evaluate(\"-Infinity\")"; - } - newRow(expr) << isNumber.contains(expr); -} - -void tst_QScriptValue::isNumber_test(const char*, const QScriptValue& value) -{ - QFETCH(bool, expected); - QCOMPARE(value.isNumber(), expected); - QCOMPARE(value.isNumber(), expected); -} - -DEFINE_TEST_FUNCTION(isNumber) - - -void tst_QScriptValue::isFunction_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::isFunction_makeData(const char* expr) -{ - static QSet isFunction; - if (isFunction.isEmpty()) { - isFunction << "engine->evaluate(\"Function.prototype\")" - << "engine->evaluate(\"Object\")" - << "engine->evaluate(\"Array\")" - << "engine->evaluate(\"Number\")" - << "engine->evaluate(\"Function\")" - << "engine->evaluate(\"(function() { return 1; })\")" - << "engine->evaluate(\"(function() { return 'ciao'; })\")" - << "engine->evaluate(\"(function() { throw new Error('foo'); })\")" - << "engine->evaluate(\"/foo/\")"; - } - newRow(expr) << isFunction.contains(expr); -} - -void tst_QScriptValue::isFunction_test(const char*, const QScriptValue& value) -{ - QFETCH(bool, expected); - QCOMPARE(value.isFunction(), expected); - QCOMPARE(value.isFunction(), expected); -} - -DEFINE_TEST_FUNCTION(isFunction) - - -void tst_QScriptValue::isNull_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::isNull_makeData(const char* expr) -{ - static QSet isNull; - if (isNull.isEmpty()) { - isNull << "QScriptValue(QScriptValue::NullValue)" - << "QScriptValue(0, QScriptValue::NullValue)" - << "QScriptValue(engine, QScriptValue::NullValue)" - << "engine->evaluate(\"null\")" - << "engine->nullValue()"; - } - newRow(expr) << isNull.contains(expr); -} - -void tst_QScriptValue::isNull_test(const char*, const QScriptValue& value) -{ - QFETCH(bool, expected); - QCOMPARE(value.isNull(), expected); - QCOMPARE(value.isNull(), expected); -} - -DEFINE_TEST_FUNCTION(isNull) - - -void tst_QScriptValue::isString_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::isString_makeData(const char* expr) -{ - static QSet isString; - if (isString.isEmpty()) { - isString << "QScriptValue(\"NaN\")" - << "QScriptValue(\"Infinity\")" - << "QScriptValue(\"-Infinity\")" - << "QScriptValue(\"ciao\")" - << "QScriptValue(QString::fromLatin1(\"ciao\"))" - << "QScriptValue(QString(\"\"))" - << "QScriptValue(QString())" - << "QScriptValue(QString(\"0\"))" - << "QScriptValue(QString(\"123\"))" - << "QScriptValue(QString(\"12.4\"))" - << "QScriptValue(0, \"NaN\")" - << "QScriptValue(0, \"Infinity\")" - << "QScriptValue(0, \"-Infinity\")" - << "QScriptValue(0, \"ciao\")" - << "QScriptValue(0, QString::fromLatin1(\"ciao\"))" - << "QScriptValue(0, QString(\"\"))" - << "QScriptValue(0, QString())" - << "QScriptValue(0, QString(\"0\"))" - << "QScriptValue(0, QString(\"123\"))" - << "QScriptValue(0, QString(\"12.3\"))" - << "QScriptValue(engine, \"NaN\")" - << "QScriptValue(engine, \"Infinity\")" - << "QScriptValue(engine, \"-Infinity\")" - << "QScriptValue(engine, \"ciao\")" - << "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" - << "QScriptValue(engine, QString(\"\"))" - << "QScriptValue(engine, QString())" - << "QScriptValue(engine, QString(\"0\"))" - << "QScriptValue(engine, QString(\"123\"))" - << "QScriptValue(engine, QString(\"1.23\"))" - << "engine->evaluate(\"'ciao'\")" - << "engine->evaluate(\"''\")" - << "engine->evaluate(\"'0'\")" - << "engine->evaluate(\"'123'\")" - << "engine->evaluate(\"'12.4'\")"; - } - newRow(expr) << isString.contains(expr); -} - -void tst_QScriptValue::isString_test(const char*, const QScriptValue& value) -{ - QFETCH(bool, expected); - QCOMPARE(value.isString(), expected); - QCOMPARE(value.isString(), expected); -} - -DEFINE_TEST_FUNCTION(isString) - - -void tst_QScriptValue::isUndefined_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::isUndefined_makeData(const char* expr) -{ - static QSet isUndefined; - if (isUndefined.isEmpty()) { - isUndefined << "QScriptValue(QScriptValue::UndefinedValue)" - << "QScriptValue(0, QScriptValue::UndefinedValue)" - << "QScriptValue(engine, QScriptValue::UndefinedValue)" - << "engine->evaluate(\"{}\")" - << "engine->evaluate(\"undefined\")" - << "engine->undefinedValue()"; - } - newRow(expr) << isUndefined.contains(expr); -} - -void tst_QScriptValue::isUndefined_test(const char*, const QScriptValue& value) -{ - QFETCH(bool, expected); - QCOMPARE(value.isUndefined(), expected); - QCOMPARE(value.isUndefined(), expected); -} - -DEFINE_TEST_FUNCTION(isUndefined) - - - - - -void tst_QScriptValue::isObject_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::isObject_makeData(const char* expr) -{ - static QSet isObject; - if (isObject.isEmpty()) { - isObject << "engine->evaluate(\"[]\")" - << "engine->evaluate(\"Object.prototype\")" - << "engine->evaluate(\"Date.prototype\")" - << "engine->evaluate(\"Array.prototype\")" - << "engine->evaluate(\"Function.prototype\")" - << "engine->evaluate(\"Error.prototype\")" - << "engine->evaluate(\"Object\")" - << "engine->evaluate(\"Array\")" - << "engine->evaluate(\"Number\")" - << "engine->evaluate(\"Function\")" - << "engine->evaluate(\"(function() { return 1; })\")" - << "engine->evaluate(\"(function() { return 'ciao'; })\")" - << "engine->evaluate(\"(function() { throw new Error('foo'); })\")" - << "engine->evaluate(\"/foo/\")" - << "engine->evaluate(\"new Object()\")" - << "engine->evaluate(\"new Array()\")" - << "engine->evaluate(\"new Error()\")" - << "engine->evaluate(\"Undefined\")" - << "engine->evaluate(\"Null\")" - << "engine->evaluate(\"True\")" - << "engine->evaluate(\"False\")"; - } - newRow(expr) << isObject.contains(expr); -} - -void tst_QScriptValue::isObject_test(const char*, const QScriptValue& value) -{ - QFETCH(bool, expected); - QCOMPARE(value.isObject(), expected); - QCOMPARE(value.isObject(), expected); -} - -DEFINE_TEST_FUNCTION(isObject) - - -void tst_QScriptValue::toString_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::toString_makeData(const char* expr) -{ - static QHash toString; - if (toString.isEmpty()) { - toString.insert("QScriptValue()", ""); - toString.insert("QScriptValue(QScriptValue::UndefinedValue)", "undefined"); - toString.insert("QScriptValue(QScriptValue::NullValue)", "null"); - toString.insert("QScriptValue(true)", "true"); - toString.insert("QScriptValue(false)", "false"); - toString.insert("QScriptValue(int(122))", "122"); - toString.insert("QScriptValue(uint(124))", "124"); - toString.insert("QScriptValue(0)", "0"); - toString.insert("QScriptValue(0.0)", "0"); - toString.insert("QScriptValue(123.0)", "123"); - toString.insert("QScriptValue(6.37e-8)", "6.37e-8"); - toString.insert("QScriptValue(-6.37e-8)", "-6.37e-8"); - toString.insert("QScriptValue(0x43211234)", "1126240820"); - toString.insert("QScriptValue(0x10000)", "65536"); - toString.insert("QScriptValue(0x10001)", "65537"); - toString.insert("QScriptValue(qSNaN())", "NaN"); - toString.insert("QScriptValue(qQNaN())", "NaN"); - toString.insert("QScriptValue(qInf())", "Infinity"); - toString.insert("QScriptValue(-qInf())", "-Infinity"); - toString.insert("QScriptValue(\"NaN\")", "NaN"); - toString.insert("QScriptValue(\"Infinity\")", "Infinity"); - toString.insert("QScriptValue(\"-Infinity\")", "-Infinity"); - toString.insert("QScriptValue(\"ciao\")", "ciao"); - toString.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", "ciao"); - toString.insert("QScriptValue(QString(\"\"))", ""); - toString.insert("QScriptValue(QString())", ""); - toString.insert("QScriptValue(QString(\"0\"))", "0"); - toString.insert("QScriptValue(QString(\"123\"))", "123"); - toString.insert("QScriptValue(QString(\"12.4\"))", "12.4"); - toString.insert("QScriptValue(0, QScriptValue::UndefinedValue)", "undefined"); - toString.insert("QScriptValue(0, QScriptValue::NullValue)", "null"); - toString.insert("QScriptValue(0, true)", "true"); - toString.insert("QScriptValue(0, false)", "false"); - toString.insert("QScriptValue(0, int(122))", "122"); - toString.insert("QScriptValue(0, uint(124))", "124"); - toString.insert("QScriptValue(0, 0)", "0"); - toString.insert("QScriptValue(0, 0.0)", "0"); - toString.insert("QScriptValue(0, 123.0)", "123"); - toString.insert("QScriptValue(0, 6.37e-8)", "6.37e-8"); - toString.insert("QScriptValue(0, -6.37e-8)", "-6.37e-8"); - toString.insert("QScriptValue(0, 0x43211234)", "1126240820"); - toString.insert("QScriptValue(0, 0x10000)", "65536"); - toString.insert("QScriptValue(0, 0x10001)", "65537"); - toString.insert("QScriptValue(0, qSNaN())", "NaN"); - toString.insert("QScriptValue(0, qQNaN())", "NaN"); - toString.insert("QScriptValue(0, qInf())", "Infinity"); - toString.insert("QScriptValue(0, -qInf())", "-Infinity"); - toString.insert("QScriptValue(0, \"NaN\")", "NaN"); - toString.insert("QScriptValue(0, \"Infinity\")", "Infinity"); - toString.insert("QScriptValue(0, \"-Infinity\")", "-Infinity"); - toString.insert("QScriptValue(0, \"ciao\")", "ciao"); - toString.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", "ciao"); - toString.insert("QScriptValue(0, QString(\"\"))", ""); - toString.insert("QScriptValue(0, QString())", ""); - toString.insert("QScriptValue(0, QString(\"0\"))", "0"); - toString.insert("QScriptValue(0, QString(\"123\"))", "123"); - toString.insert("QScriptValue(0, QString(\"12.3\"))", "12.3"); - toString.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", "undefined"); - toString.insert("QScriptValue(engine, QScriptValue::NullValue)", "null"); - toString.insert("QScriptValue(engine, true)", "true"); - toString.insert("QScriptValue(engine, false)", "false"); - toString.insert("QScriptValue(engine, int(122))", "122"); - toString.insert("QScriptValue(engine, uint(124))", "124"); - toString.insert("QScriptValue(engine, 0)", "0"); - toString.insert("QScriptValue(engine, 0.0)", "0"); - toString.insert("QScriptValue(engine, 123.0)", "123"); - toString.insert("QScriptValue(engine, 6.37e-8)", "6.37e-8"); - toString.insert("QScriptValue(engine, -6.37e-8)", "-6.37e-8"); - toString.insert("QScriptValue(engine, 0x43211234)", "1126240820"); - toString.insert("QScriptValue(engine, 0x10000)", "65536"); - toString.insert("QScriptValue(engine, 0x10001)", "65537"); - toString.insert("QScriptValue(engine, qSNaN())", "NaN"); - toString.insert("QScriptValue(engine, qQNaN())", "NaN"); - toString.insert("QScriptValue(engine, qInf())", "Infinity"); - toString.insert("QScriptValue(engine, -qInf())", "-Infinity"); - toString.insert("QScriptValue(engine, \"NaN\")", "NaN"); - toString.insert("QScriptValue(engine, \"Infinity\")", "Infinity"); - toString.insert("QScriptValue(engine, \"-Infinity\")", "-Infinity"); - toString.insert("QScriptValue(engine, \"ciao\")", "ciao"); - toString.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", "ciao"); - toString.insert("QScriptValue(engine, QString(\"\"))", ""); - toString.insert("QScriptValue(engine, QString())", ""); - toString.insert("QScriptValue(engine, QString(\"0\"))", "0"); - toString.insert("QScriptValue(engine, QString(\"123\"))", "123"); - toString.insert("QScriptValue(engine, QString(\"1.23\"))", "1.23"); - toString.insert("engine->evaluate(\"[]\")", ""); - toString.insert("engine->evaluate(\"{}\")", "undefined"); - toString.insert("engine->evaluate(\"Object.prototype\")", "[object Object]"); - toString.insert("engine->evaluate(\"Date.prototype\")", "Invalid Date"); - toString.insert("engine->evaluate(\"Array.prototype\")", ""); - toString.insert("engine->evaluate(\"Function.prototype\")", "function () {\n [native code]\n}"); - toString.insert("engine->evaluate(\"Error.prototype\")", "Error: Unknown error"); - toString.insert("engine->evaluate(\"Object\")", "function Object() {\n [native code]\n}"); - toString.insert("engine->evaluate(\"Array\")", "function Array() {\n [native code]\n}"); - toString.insert("engine->evaluate(\"Number\")", "function Number() {\n [native code]\n}"); - toString.insert("engine->evaluate(\"Function\")", "function Function() {\n [native code]\n}"); - toString.insert("engine->evaluate(\"(function() { return 1; })\")", "function () { return 1; }"); - toString.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", "function () { return 'ciao'; }"); - toString.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", "function () { throw new Error('foo'); }"); - toString.insert("engine->evaluate(\"/foo/\")", "/foo/"); - toString.insert("engine->evaluate(\"new Object()\")", "[object Object]"); - toString.insert("engine->evaluate(\"new Array()\")", ""); - toString.insert("engine->evaluate(\"new Error()\")", "Error: Unknown error"); - toString.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", "22"); - toString.insert("engine->evaluate(\"Undefined\")", "ReferenceError: Can't find variable: Undefined"); - toString.insert("engine->evaluate(\"Null\")", "ReferenceError: Can't find variable: Null"); - toString.insert("engine->evaluate(\"True\")", "ReferenceError: Can't find variable: True"); - toString.insert("engine->evaluate(\"False\")", "ReferenceError: Can't find variable: False"); - toString.insert("engine->evaluate(\"undefined\")", "undefined"); - toString.insert("engine->evaluate(\"null\")", "null"); - toString.insert("engine->evaluate(\"true\")", "true"); - toString.insert("engine->evaluate(\"false\")", "false"); - toString.insert("engine->evaluate(\"122\")", "122"); - toString.insert("engine->evaluate(\"124\")", "124"); - toString.insert("engine->evaluate(\"0\")", "0"); - toString.insert("engine->evaluate(\"0.0\")", "0"); - toString.insert("engine->evaluate(\"123.0\")", "123"); - toString.insert("engine->evaluate(\"6.37e-8\")", "6.37e-8"); - toString.insert("engine->evaluate(\"-6.37e-8\")", "-6.37e-8"); - toString.insert("engine->evaluate(\"0x43211234\")", "1126240820"); - toString.insert("engine->evaluate(\"0x10000\")", "65536"); - toString.insert("engine->evaluate(\"0x10001\")", "65537"); - toString.insert("engine->evaluate(\"NaN\")", "NaN"); - toString.insert("engine->evaluate(\"Infinity\")", "Infinity"); - toString.insert("engine->evaluate(\"-Infinity\")", "-Infinity"); - toString.insert("engine->evaluate(\"'ciao'\")", "ciao"); - toString.insert("engine->evaluate(\"''\")", ""); - toString.insert("engine->evaluate(\"'0'\")", "0"); - toString.insert("engine->evaluate(\"'123'\")", "123"); - toString.insert("engine->evaluate(\"'12.4'\")", "12.4"); - toString.insert("engine->nullValue()", "null"); - toString.insert("engine->undefinedValue()", "undefined"); - } - newRow(expr) << toString.value(expr); -} - -void tst_QScriptValue::toString_test(const char*, const QScriptValue& value) -{ - QFETCH(QString, expected); - QCOMPARE(value.toString(), expected); - QCOMPARE(value.toString(), expected); -} - -DEFINE_TEST_FUNCTION(toString) - - -void tst_QScriptValue::toNumber_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::toNumber_makeData(const char* expr) -{ - static QHash toNumber; - if (toNumber.isEmpty()) { - toNumber.insert("QScriptValue()", 0); - toNumber.insert("QScriptValue(QScriptValue::UndefinedValue)", qQNaN()); - toNumber.insert("QScriptValue(QScriptValue::NullValue)", 0); - toNumber.insert("QScriptValue(true)", 1); - toNumber.insert("QScriptValue(false)", 0); - toNumber.insert("QScriptValue(int(122))", 122); - toNumber.insert("QScriptValue(uint(124))", 124); - toNumber.insert("QScriptValue(0)", 0); - toNumber.insert("QScriptValue(0.0)", 0); - toNumber.insert("QScriptValue(123.0)", 123); - toNumber.insert("QScriptValue(6.37e-8)", 6.369999999999999e-08); - toNumber.insert("QScriptValue(-6.37e-8)", -6.369999999999999e-08); - toNumber.insert("QScriptValue(0x43211234)", 1126240820); - toNumber.insert("QScriptValue(0x10000)", 65536); - toNumber.insert("QScriptValue(0x10001)", 65537); - toNumber.insert("QScriptValue(qSNaN())", qQNaN()); - toNumber.insert("QScriptValue(qQNaN())", qQNaN()); - toNumber.insert("QScriptValue(qInf())", qInf()); - toNumber.insert("QScriptValue(-qInf())", qInf()); - toNumber.insert("QScriptValue(\"NaN\")", qQNaN()); - toNumber.insert("QScriptValue(\"Infinity\")", qInf()); - toNumber.insert("QScriptValue(\"-Infinity\")", qInf()); - toNumber.insert("QScriptValue(\"ciao\")", qQNaN()); - toNumber.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", qQNaN()); - toNumber.insert("QScriptValue(QString(\"\"))", 0); - toNumber.insert("QScriptValue(QString())", 0); - toNumber.insert("QScriptValue(QString(\"0\"))", 0); - toNumber.insert("QScriptValue(QString(\"123\"))", 123); - toNumber.insert("QScriptValue(QString(\"12.4\"))", 12.4); - toNumber.insert("QScriptValue(0, QScriptValue::UndefinedValue)", qQNaN()); - toNumber.insert("QScriptValue(0, QScriptValue::NullValue)", 0); - toNumber.insert("QScriptValue(0, true)", 1); - toNumber.insert("QScriptValue(0, false)", 0); - toNumber.insert("QScriptValue(0, int(122))", 122); - toNumber.insert("QScriptValue(0, uint(124))", 124); - toNumber.insert("QScriptValue(0, 0)", 0); - toNumber.insert("QScriptValue(0, 0.0)", 0); - toNumber.insert("QScriptValue(0, 123.0)", 123); - toNumber.insert("QScriptValue(0, 6.37e-8)", 6.369999999999999e-08); - toNumber.insert("QScriptValue(0, -6.37e-8)", -6.369999999999999e-08); - toNumber.insert("QScriptValue(0, 0x43211234)", 1126240820); - toNumber.insert("QScriptValue(0, 0x10000)", 65536); - toNumber.insert("QScriptValue(0, 0x10001)", 65537); - toNumber.insert("QScriptValue(0, qSNaN())", qQNaN()); - toNumber.insert("QScriptValue(0, qQNaN())", qQNaN()); - toNumber.insert("QScriptValue(0, qInf())", qInf()); - toNumber.insert("QScriptValue(0, -qInf())", qInf()); - toNumber.insert("QScriptValue(0, \"NaN\")", qQNaN()); - toNumber.insert("QScriptValue(0, \"Infinity\")", qInf()); - toNumber.insert("QScriptValue(0, \"-Infinity\")", qInf()); - toNumber.insert("QScriptValue(0, \"ciao\")", qQNaN()); - toNumber.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", qQNaN()); - toNumber.insert("QScriptValue(0, QString(\"\"))", 0); - toNumber.insert("QScriptValue(0, QString())", 0); - toNumber.insert("QScriptValue(0, QString(\"0\"))", 0); - toNumber.insert("QScriptValue(0, QString(\"123\"))", 123); - toNumber.insert("QScriptValue(0, QString(\"12.3\"))", 12.3); - toNumber.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", qQNaN()); - toNumber.insert("QScriptValue(engine, QScriptValue::NullValue)", 0); - toNumber.insert("QScriptValue(engine, true)", 1); - toNumber.insert("QScriptValue(engine, false)", 0); - toNumber.insert("QScriptValue(engine, int(122))", 122); - toNumber.insert("QScriptValue(engine, uint(124))", 124); - toNumber.insert("QScriptValue(engine, 0)", 0); - toNumber.insert("QScriptValue(engine, 0.0)", 0); - toNumber.insert("QScriptValue(engine, 123.0)", 123); - toNumber.insert("QScriptValue(engine, 6.37e-8)", 6.369999999999999e-08); - toNumber.insert("QScriptValue(engine, -6.37e-8)", -6.369999999999999e-08); - toNumber.insert("QScriptValue(engine, 0x43211234)", 1126240820); - toNumber.insert("QScriptValue(engine, 0x10000)", 65536); - toNumber.insert("QScriptValue(engine, 0x10001)", 65537); - toNumber.insert("QScriptValue(engine, qSNaN())", qQNaN()); - toNumber.insert("QScriptValue(engine, qQNaN())", qQNaN()); - toNumber.insert("QScriptValue(engine, qInf())", qInf()); - toNumber.insert("QScriptValue(engine, -qInf())", qInf()); - toNumber.insert("QScriptValue(engine, \"NaN\")", qQNaN()); - toNumber.insert("QScriptValue(engine, \"Infinity\")", qInf()); - toNumber.insert("QScriptValue(engine, \"-Infinity\")", qInf()); - toNumber.insert("QScriptValue(engine, \"ciao\")", qQNaN()); - toNumber.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", qQNaN()); - toNumber.insert("QScriptValue(engine, QString(\"\"))", 0); - toNumber.insert("QScriptValue(engine, QString())", 0); - toNumber.insert("QScriptValue(engine, QString(\"0\"))", 0); - toNumber.insert("QScriptValue(engine, QString(\"123\"))", 123); - toNumber.insert("QScriptValue(engine, QString(\"1.23\"))", 1.23); - toNumber.insert("engine->evaluate(\"[]\")", 0); - toNumber.insert("engine->evaluate(\"{}\")", qQNaN()); - toNumber.insert("engine->evaluate(\"Object.prototype\")", qQNaN()); - toNumber.insert("engine->evaluate(\"Date.prototype\")", qQNaN()); - toNumber.insert("engine->evaluate(\"Array.prototype\")", 0); - toNumber.insert("engine->evaluate(\"Function.prototype\")", qQNaN()); - toNumber.insert("engine->evaluate(\"Error.prototype\")", qQNaN()); - toNumber.insert("engine->evaluate(\"Object\")", qQNaN()); - toNumber.insert("engine->evaluate(\"Array\")", qQNaN()); - toNumber.insert("engine->evaluate(\"Number\")", qQNaN()); - toNumber.insert("engine->evaluate(\"Function\")", qQNaN()); - toNumber.insert("engine->evaluate(\"(function() { return 1; })\")", qQNaN()); - toNumber.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", qQNaN()); - toNumber.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", qQNaN()); - toNumber.insert("engine->evaluate(\"/foo/\")", qQNaN()); - toNumber.insert("engine->evaluate(\"new Object()\")", qQNaN()); - toNumber.insert("engine->evaluate(\"new Array()\")", 0); - toNumber.insert("engine->evaluate(\"new Error()\")", qQNaN()); - toNumber.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22); - toNumber.insert("engine->evaluate(\"Undefined\")", qQNaN()); - toNumber.insert("engine->evaluate(\"Null\")", qQNaN()); - toNumber.insert("engine->evaluate(\"True\")", qQNaN()); - toNumber.insert("engine->evaluate(\"False\")", qQNaN()); - toNumber.insert("engine->evaluate(\"undefined\")", qQNaN()); - toNumber.insert("engine->evaluate(\"null\")", 0); - toNumber.insert("engine->evaluate(\"true\")", 1); - toNumber.insert("engine->evaluate(\"false\")", 0); - toNumber.insert("engine->evaluate(\"122\")", 122); - toNumber.insert("engine->evaluate(\"124\")", 124); - toNumber.insert("engine->evaluate(\"0\")", 0); - toNumber.insert("engine->evaluate(\"0.0\")", 0); - toNumber.insert("engine->evaluate(\"123.0\")", 123); - toNumber.insert("engine->evaluate(\"6.37e-8\")", 6.369999999999999e-08); - toNumber.insert("engine->evaluate(\"-6.37e-8\")", -6.369999999999999e-08); - toNumber.insert("engine->evaluate(\"0x43211234\")", 1126240820); - toNumber.insert("engine->evaluate(\"0x10000\")", 65536); - toNumber.insert("engine->evaluate(\"0x10001\")", 65537); - toNumber.insert("engine->evaluate(\"NaN\")", qQNaN()); - toNumber.insert("engine->evaluate(\"Infinity\")", qInf()); - toNumber.insert("engine->evaluate(\"-Infinity\")", qInf()); - toNumber.insert("engine->evaluate(\"'ciao'\")", qQNaN()); - toNumber.insert("engine->evaluate(\"''\")", 0); - toNumber.insert("engine->evaluate(\"'0'\")", 0); - toNumber.insert("engine->evaluate(\"'123'\")", 123); - toNumber.insert("engine->evaluate(\"'12.4'\")", 12.4); - toNumber.insert("engine->nullValue()", 0); - toNumber.insert("engine->undefinedValue()", qQNaN()); - } - newRow(expr) << toNumber.value(expr); -} - -void tst_QScriptValue::toNumber_test(const char*, const QScriptValue& value) -{ - QFETCH(qsreal, expected); - if (qIsNaN(expected)) { - QVERIFY(qIsNaN(value.toNumber())); - return; - } - if (qIsInf(expected)) { - QVERIFY(qIsInf(value.toNumber())); - QVERIFY(qIsInf(value.toNumber())); - return; - } - QCOMPARE(value.toNumber(), expected); - QCOMPARE(value.toNumber(), expected); -} - -DEFINE_TEST_FUNCTION(toNumber) - - -void tst_QScriptValue::toBool_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::toBool_makeData(const char* expr) -{ - static QHash toBool; - if (toBool.isEmpty()) { - toBool.insert("QScriptValue()", false); - toBool.insert("QScriptValue(QScriptValue::UndefinedValue)", false); - toBool.insert("QScriptValue(QScriptValue::NullValue)", false); - toBool.insert("QScriptValue(true)", true); - toBool.insert("QScriptValue(false)", false); - toBool.insert("QScriptValue(int(122))", true); - toBool.insert("QScriptValue(uint(124))", true); - toBool.insert("QScriptValue(0)", false); - toBool.insert("QScriptValue(0.0)", false); - toBool.insert("QScriptValue(123.0)", true); - toBool.insert("QScriptValue(6.37e-8)", true); - toBool.insert("QScriptValue(-6.37e-8)", true); - toBool.insert("QScriptValue(0x43211234)", true); - toBool.insert("QScriptValue(0x10000)", true); - toBool.insert("QScriptValue(0x10001)", true); - toBool.insert("QScriptValue(qSNaN())", false); - toBool.insert("QScriptValue(qQNaN())", false); - toBool.insert("QScriptValue(qInf())", true); - toBool.insert("QScriptValue(-qInf())", true); - toBool.insert("QScriptValue(\"NaN\")", true); - toBool.insert("QScriptValue(\"Infinity\")", true); - toBool.insert("QScriptValue(\"-Infinity\")", true); - toBool.insert("QScriptValue(\"ciao\")", true); - toBool.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", true); - toBool.insert("QScriptValue(QString(\"\"))", false); - toBool.insert("QScriptValue(QString())", false); - toBool.insert("QScriptValue(QString(\"0\"))", true); - toBool.insert("QScriptValue(QString(\"123\"))", true); - toBool.insert("QScriptValue(QString(\"12.4\"))", true); - toBool.insert("QScriptValue(0, QScriptValue::UndefinedValue)", false); - toBool.insert("QScriptValue(0, QScriptValue::NullValue)", false); - toBool.insert("QScriptValue(0, true)", true); - toBool.insert("QScriptValue(0, false)", false); - toBool.insert("QScriptValue(0, int(122))", true); - toBool.insert("QScriptValue(0, uint(124))", true); - toBool.insert("QScriptValue(0, 0)", false); - toBool.insert("QScriptValue(0, 0.0)", false); - toBool.insert("QScriptValue(0, 123.0)", true); - toBool.insert("QScriptValue(0, 6.37e-8)", true); - toBool.insert("QScriptValue(0, -6.37e-8)", true); - toBool.insert("QScriptValue(0, 0x43211234)", true); - toBool.insert("QScriptValue(0, 0x10000)", true); - toBool.insert("QScriptValue(0, 0x10001)", true); - toBool.insert("QScriptValue(0, qSNaN())", false); - toBool.insert("QScriptValue(0, qQNaN())", false); - toBool.insert("QScriptValue(0, qInf())", true); - toBool.insert("QScriptValue(0, -qInf())", true); - toBool.insert("QScriptValue(0, \"NaN\")", true); - toBool.insert("QScriptValue(0, \"Infinity\")", true); - toBool.insert("QScriptValue(0, \"-Infinity\")", true); - toBool.insert("QScriptValue(0, \"ciao\")", true); - toBool.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", true); - toBool.insert("QScriptValue(0, QString(\"\"))", false); - toBool.insert("QScriptValue(0, QString())", false); - toBool.insert("QScriptValue(0, QString(\"0\"))", true); - toBool.insert("QScriptValue(0, QString(\"123\"))", true); - toBool.insert("QScriptValue(0, QString(\"12.3\"))", true); - toBool.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", false); - toBool.insert("QScriptValue(engine, QScriptValue::NullValue)", false); - toBool.insert("QScriptValue(engine, true)", true); - toBool.insert("QScriptValue(engine, false)", false); - toBool.insert("QScriptValue(engine, int(122))", true); - toBool.insert("QScriptValue(engine, uint(124))", true); - toBool.insert("QScriptValue(engine, 0)", false); - toBool.insert("QScriptValue(engine, 0.0)", false); - toBool.insert("QScriptValue(engine, 123.0)", true); - toBool.insert("QScriptValue(engine, 6.37e-8)", true); - toBool.insert("QScriptValue(engine, -6.37e-8)", true); - toBool.insert("QScriptValue(engine, 0x43211234)", true); - toBool.insert("QScriptValue(engine, 0x10000)", true); - toBool.insert("QScriptValue(engine, 0x10001)", true); - toBool.insert("QScriptValue(engine, qSNaN())", false); - toBool.insert("QScriptValue(engine, qQNaN())", false); - toBool.insert("QScriptValue(engine, qInf())", true); - toBool.insert("QScriptValue(engine, -qInf())", true); - toBool.insert("QScriptValue(engine, \"NaN\")", true); - toBool.insert("QScriptValue(engine, \"Infinity\")", true); - toBool.insert("QScriptValue(engine, \"-Infinity\")", true); - toBool.insert("QScriptValue(engine, \"ciao\")", true); - toBool.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", true); - toBool.insert("QScriptValue(engine, QString(\"\"))", false); - toBool.insert("QScriptValue(engine, QString())", false); - toBool.insert("QScriptValue(engine, QString(\"0\"))", true); - toBool.insert("QScriptValue(engine, QString(\"123\"))", true); - toBool.insert("QScriptValue(engine, QString(\"1.23\"))", true); - toBool.insert("engine->evaluate(\"[]\")", true); - toBool.insert("engine->evaluate(\"{}\")", false); - toBool.insert("engine->evaluate(\"Object.prototype\")", true); - toBool.insert("engine->evaluate(\"Date.prototype\")", true); - toBool.insert("engine->evaluate(\"Array.prototype\")", true); - toBool.insert("engine->evaluate(\"Function.prototype\")", true); - toBool.insert("engine->evaluate(\"Error.prototype\")", true); - toBool.insert("engine->evaluate(\"Object\")", true); - toBool.insert("engine->evaluate(\"Array\")", true); - toBool.insert("engine->evaluate(\"Number\")", true); - toBool.insert("engine->evaluate(\"Function\")", true); - toBool.insert("engine->evaluate(\"(function() { return 1; })\")", true); - toBool.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", true); - toBool.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", true); - toBool.insert("engine->evaluate(\"/foo/\")", true); - toBool.insert("engine->evaluate(\"new Object()\")", true); - toBool.insert("engine->evaluate(\"new Array()\")", true); - toBool.insert("engine->evaluate(\"new Error()\")", true); - toBool.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", true); - toBool.insert("engine->evaluate(\"Undefined\")", true); - toBool.insert("engine->evaluate(\"Null\")", true); - toBool.insert("engine->evaluate(\"True\")", true); - toBool.insert("engine->evaluate(\"False\")", true); - toBool.insert("engine->evaluate(\"undefined\")", false); - toBool.insert("engine->evaluate(\"null\")", false); - toBool.insert("engine->evaluate(\"true\")", true); - toBool.insert("engine->evaluate(\"false\")", false); - toBool.insert("engine->evaluate(\"122\")", true); - toBool.insert("engine->evaluate(\"124\")", true); - toBool.insert("engine->evaluate(\"0\")", false); - toBool.insert("engine->evaluate(\"0.0\")", false); - toBool.insert("engine->evaluate(\"123.0\")", true); - toBool.insert("engine->evaluate(\"6.37e-8\")", true); - toBool.insert("engine->evaluate(\"-6.37e-8\")", true); - toBool.insert("engine->evaluate(\"0x43211234\")", true); - toBool.insert("engine->evaluate(\"0x10000\")", true); - toBool.insert("engine->evaluate(\"0x10001\")", true); - toBool.insert("engine->evaluate(\"NaN\")", false); - toBool.insert("engine->evaluate(\"Infinity\")", true); - toBool.insert("engine->evaluate(\"-Infinity\")", true); - toBool.insert("engine->evaluate(\"'ciao'\")", true); - toBool.insert("engine->evaluate(\"''\")", false); - toBool.insert("engine->evaluate(\"'0'\")", true); - toBool.insert("engine->evaluate(\"'123'\")", true); - toBool.insert("engine->evaluate(\"'12.4'\")", true); - toBool.insert("engine->nullValue()", false); - toBool.insert("engine->undefinedValue()", false); - } - newRow(expr) << toBool.value(expr); -} - -void tst_QScriptValue::toBool_test(const char*, const QScriptValue& value) -{ - QFETCH(bool, expected); - QCOMPARE(value.toBool(), expected); - QCOMPARE(value.toBool(), expected); -} - -DEFINE_TEST_FUNCTION(toBool) - - -void tst_QScriptValue::toBoolean_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::toBoolean_makeData(const char* expr) -{ - static QHash toBoolean; - if (toBoolean.isEmpty()) { - toBoolean.insert("QScriptValue()", false); - toBoolean.insert("QScriptValue(QScriptValue::UndefinedValue)", false); - toBoolean.insert("QScriptValue(QScriptValue::NullValue)", false); - toBoolean.insert("QScriptValue(true)", true); - toBoolean.insert("QScriptValue(false)", false); - toBoolean.insert("QScriptValue(int(122))", true); - toBoolean.insert("QScriptValue(uint(124))", true); - toBoolean.insert("QScriptValue(0)", false); - toBoolean.insert("QScriptValue(0.0)", false); - toBoolean.insert("QScriptValue(123.0)", true); - toBoolean.insert("QScriptValue(6.37e-8)", true); - toBoolean.insert("QScriptValue(-6.37e-8)", true); - toBoolean.insert("QScriptValue(0x43211234)", true); - toBoolean.insert("QScriptValue(0x10000)", true); - toBoolean.insert("QScriptValue(0x10001)", true); - toBoolean.insert("QScriptValue(qSNaN())", false); - toBoolean.insert("QScriptValue(qQNaN())", false); - toBoolean.insert("QScriptValue(qInf())", true); - toBoolean.insert("QScriptValue(-qInf())", true); - toBoolean.insert("QScriptValue(\"NaN\")", true); - toBoolean.insert("QScriptValue(\"Infinity\")", true); - toBoolean.insert("QScriptValue(\"-Infinity\")", true); - toBoolean.insert("QScriptValue(\"ciao\")", true); - toBoolean.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", true); - toBoolean.insert("QScriptValue(QString(\"\"))", false); - toBoolean.insert("QScriptValue(QString())", false); - toBoolean.insert("QScriptValue(QString(\"0\"))", true); - toBoolean.insert("QScriptValue(QString(\"123\"))", true); - toBoolean.insert("QScriptValue(QString(\"12.4\"))", true); - toBoolean.insert("QScriptValue(0, QScriptValue::UndefinedValue)", false); - toBoolean.insert("QScriptValue(0, QScriptValue::NullValue)", false); - toBoolean.insert("QScriptValue(0, true)", true); - toBoolean.insert("QScriptValue(0, false)", false); - toBoolean.insert("QScriptValue(0, int(122))", true); - toBoolean.insert("QScriptValue(0, uint(124))", true); - toBoolean.insert("QScriptValue(0, 0)", false); - toBoolean.insert("QScriptValue(0, 0.0)", false); - toBoolean.insert("QScriptValue(0, 123.0)", true); - toBoolean.insert("QScriptValue(0, 6.37e-8)", true); - toBoolean.insert("QScriptValue(0, -6.37e-8)", true); - toBoolean.insert("QScriptValue(0, 0x43211234)", true); - toBoolean.insert("QScriptValue(0, 0x10000)", true); - toBoolean.insert("QScriptValue(0, 0x10001)", true); - toBoolean.insert("QScriptValue(0, qSNaN())", false); - toBoolean.insert("QScriptValue(0, qQNaN())", false); - toBoolean.insert("QScriptValue(0, qInf())", true); - toBoolean.insert("QScriptValue(0, -qInf())", true); - toBoolean.insert("QScriptValue(0, \"NaN\")", true); - toBoolean.insert("QScriptValue(0, \"Infinity\")", true); - toBoolean.insert("QScriptValue(0, \"-Infinity\")", true); - toBoolean.insert("QScriptValue(0, \"ciao\")", true); - toBoolean.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", true); - toBoolean.insert("QScriptValue(0, QString(\"\"))", false); - toBoolean.insert("QScriptValue(0, QString())", false); - toBoolean.insert("QScriptValue(0, QString(\"0\"))", true); - toBoolean.insert("QScriptValue(0, QString(\"123\"))", true); - toBoolean.insert("QScriptValue(0, QString(\"12.3\"))", true); - toBoolean.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", false); - toBoolean.insert("QScriptValue(engine, QScriptValue::NullValue)", false); - toBoolean.insert("QScriptValue(engine, true)", true); - toBoolean.insert("QScriptValue(engine, false)", false); - toBoolean.insert("QScriptValue(engine, int(122))", true); - toBoolean.insert("QScriptValue(engine, uint(124))", true); - toBoolean.insert("QScriptValue(engine, 0)", false); - toBoolean.insert("QScriptValue(engine, 0.0)", false); - toBoolean.insert("QScriptValue(engine, 123.0)", true); - toBoolean.insert("QScriptValue(engine, 6.37e-8)", true); - toBoolean.insert("QScriptValue(engine, -6.37e-8)", true); - toBoolean.insert("QScriptValue(engine, 0x43211234)", true); - toBoolean.insert("QScriptValue(engine, 0x10000)", true); - toBoolean.insert("QScriptValue(engine, 0x10001)", true); - toBoolean.insert("QScriptValue(engine, qSNaN())", false); - toBoolean.insert("QScriptValue(engine, qQNaN())", false); - toBoolean.insert("QScriptValue(engine, qInf())", true); - toBoolean.insert("QScriptValue(engine, -qInf())", true); - toBoolean.insert("QScriptValue(engine, \"NaN\")", true); - toBoolean.insert("QScriptValue(engine, \"Infinity\")", true); - toBoolean.insert("QScriptValue(engine, \"-Infinity\")", true); - toBoolean.insert("QScriptValue(engine, \"ciao\")", true); - toBoolean.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", true); - toBoolean.insert("QScriptValue(engine, QString(\"\"))", false); - toBoolean.insert("QScriptValue(engine, QString())", false); - toBoolean.insert("QScriptValue(engine, QString(\"0\"))", true); - toBoolean.insert("QScriptValue(engine, QString(\"123\"))", true); - toBoolean.insert("QScriptValue(engine, QString(\"1.23\"))", true); - toBoolean.insert("engine->evaluate(\"[]\")", true); - toBoolean.insert("engine->evaluate(\"{}\")", false); - toBoolean.insert("engine->evaluate(\"Object.prototype\")", true); - toBoolean.insert("engine->evaluate(\"Date.prototype\")", true); - toBoolean.insert("engine->evaluate(\"Array.prototype\")", true); - toBoolean.insert("engine->evaluate(\"Function.prototype\")", true); - toBoolean.insert("engine->evaluate(\"Error.prototype\")", true); - toBoolean.insert("engine->evaluate(\"Object\")", true); - toBoolean.insert("engine->evaluate(\"Array\")", true); - toBoolean.insert("engine->evaluate(\"Number\")", true); - toBoolean.insert("engine->evaluate(\"Function\")", true); - toBoolean.insert("engine->evaluate(\"(function() { return 1; })\")", true); - toBoolean.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", true); - toBoolean.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", true); - toBoolean.insert("engine->evaluate(\"/foo/\")", true); - toBoolean.insert("engine->evaluate(\"new Object()\")", true); - toBoolean.insert("engine->evaluate(\"new Array()\")", true); - toBoolean.insert("engine->evaluate(\"new Error()\")", true); - toBoolean.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", true); - toBoolean.insert("engine->evaluate(\"Undefined\")", true); - toBoolean.insert("engine->evaluate(\"Null\")", true); - toBoolean.insert("engine->evaluate(\"True\")", true); - toBoolean.insert("engine->evaluate(\"False\")", true); - toBoolean.insert("engine->evaluate(\"undefined\")", false); - toBoolean.insert("engine->evaluate(\"null\")", false); - toBoolean.insert("engine->evaluate(\"true\")", true); - toBoolean.insert("engine->evaluate(\"false\")", false); - toBoolean.insert("engine->evaluate(\"122\")", true); - toBoolean.insert("engine->evaluate(\"124\")", true); - toBoolean.insert("engine->evaluate(\"0\")", false); - toBoolean.insert("engine->evaluate(\"0.0\")", false); - toBoolean.insert("engine->evaluate(\"123.0\")", true); - toBoolean.insert("engine->evaluate(\"6.37e-8\")", true); - toBoolean.insert("engine->evaluate(\"-6.37e-8\")", true); - toBoolean.insert("engine->evaluate(\"0x43211234\")", true); - toBoolean.insert("engine->evaluate(\"0x10000\")", true); - toBoolean.insert("engine->evaluate(\"0x10001\")", true); - toBoolean.insert("engine->evaluate(\"NaN\")", false); - toBoolean.insert("engine->evaluate(\"Infinity\")", true); - toBoolean.insert("engine->evaluate(\"-Infinity\")", true); - toBoolean.insert("engine->evaluate(\"'ciao'\")", true); - toBoolean.insert("engine->evaluate(\"''\")", false); - toBoolean.insert("engine->evaluate(\"'0'\")", true); - toBoolean.insert("engine->evaluate(\"'123'\")", true); - toBoolean.insert("engine->evaluate(\"'12.4'\")", true); - toBoolean.insert("engine->nullValue()", false); - toBoolean.insert("engine->undefinedValue()", false); - } - newRow(expr) << toBoolean.value(expr); -} - -void tst_QScriptValue::toBoolean_test(const char*, const QScriptValue& value) -{ - QFETCH(bool, expected); - QCOMPARE(value.toBoolean(), expected); - QCOMPARE(value.toBoolean(), expected); -} - -DEFINE_TEST_FUNCTION(toBoolean) - - -void tst_QScriptValue::toInteger_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::toInteger_makeData(const char* expr) -{ - static QHash toInteger; - if (toInteger.isEmpty()) { - toInteger.insert("QScriptValue()", 0); - toInteger.insert("QScriptValue(QScriptValue::UndefinedValue)", 0); - toInteger.insert("QScriptValue(QScriptValue::NullValue)", 0); - toInteger.insert("QScriptValue(true)", 1); - toInteger.insert("QScriptValue(false)", 0); - toInteger.insert("QScriptValue(int(122))", 122); - toInteger.insert("QScriptValue(uint(124))", 124); - toInteger.insert("QScriptValue(0)", 0); - toInteger.insert("QScriptValue(0.0)", 0); - toInteger.insert("QScriptValue(123.0)", 123); - toInteger.insert("QScriptValue(6.37e-8)", 0); - toInteger.insert("QScriptValue(-6.37e-8)", 0); - toInteger.insert("QScriptValue(0x43211234)", 1126240820); - toInteger.insert("QScriptValue(0x10000)", 65536); - toInteger.insert("QScriptValue(0x10001)", 65537); - toInteger.insert("QScriptValue(qSNaN())", 0); - toInteger.insert("QScriptValue(qQNaN())", 0); - toInteger.insert("QScriptValue(qInf())", qInf()); - toInteger.insert("QScriptValue(-qInf())", qInf()); - toInteger.insert("QScriptValue(\"NaN\")", 0); - toInteger.insert("QScriptValue(\"Infinity\")", qInf()); - toInteger.insert("QScriptValue(\"-Infinity\")", qInf()); - toInteger.insert("QScriptValue(\"ciao\")", 0); - toInteger.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", 0); - toInteger.insert("QScriptValue(QString(\"\"))", 0); - toInteger.insert("QScriptValue(QString())", 0); - toInteger.insert("QScriptValue(QString(\"0\"))", 0); - toInteger.insert("QScriptValue(QString(\"123\"))", 123); - toInteger.insert("QScriptValue(QString(\"12.4\"))", 12); - toInteger.insert("QScriptValue(0, QScriptValue::UndefinedValue)", 0); - toInteger.insert("QScriptValue(0, QScriptValue::NullValue)", 0); - toInteger.insert("QScriptValue(0, true)", 1); - toInteger.insert("QScriptValue(0, false)", 0); - toInteger.insert("QScriptValue(0, int(122))", 122); - toInteger.insert("QScriptValue(0, uint(124))", 124); - toInteger.insert("QScriptValue(0, 0)", 0); - toInteger.insert("QScriptValue(0, 0.0)", 0); - toInteger.insert("QScriptValue(0, 123.0)", 123); - toInteger.insert("QScriptValue(0, 6.37e-8)", 0); - toInteger.insert("QScriptValue(0, -6.37e-8)", 0); - toInteger.insert("QScriptValue(0, 0x43211234)", 1126240820); - toInteger.insert("QScriptValue(0, 0x10000)", 65536); - toInteger.insert("QScriptValue(0, 0x10001)", 65537); - toInteger.insert("QScriptValue(0, qSNaN())", 0); - toInteger.insert("QScriptValue(0, qQNaN())", 0); - toInteger.insert("QScriptValue(0, qInf())", qInf()); - toInteger.insert("QScriptValue(0, -qInf())", qInf()); - toInteger.insert("QScriptValue(0, \"NaN\")", 0); - toInteger.insert("QScriptValue(0, \"Infinity\")", qInf()); - toInteger.insert("QScriptValue(0, \"-Infinity\")", qInf()); - toInteger.insert("QScriptValue(0, \"ciao\")", 0); - toInteger.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", 0); - toInteger.insert("QScriptValue(0, QString(\"\"))", 0); - toInteger.insert("QScriptValue(0, QString())", 0); - toInteger.insert("QScriptValue(0, QString(\"0\"))", 0); - toInteger.insert("QScriptValue(0, QString(\"123\"))", 123); - toInteger.insert("QScriptValue(0, QString(\"12.3\"))", 12); - toInteger.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", 0); - toInteger.insert("QScriptValue(engine, QScriptValue::NullValue)", 0); - toInteger.insert("QScriptValue(engine, true)", 1); - toInteger.insert("QScriptValue(engine, false)", 0); - toInteger.insert("QScriptValue(engine, int(122))", 122); - toInteger.insert("QScriptValue(engine, uint(124))", 124); - toInteger.insert("QScriptValue(engine, 0)", 0); - toInteger.insert("QScriptValue(engine, 0.0)", 0); - toInteger.insert("QScriptValue(engine, 123.0)", 123); - toInteger.insert("QScriptValue(engine, 6.37e-8)", 0); - toInteger.insert("QScriptValue(engine, -6.37e-8)", 0); - toInteger.insert("QScriptValue(engine, 0x43211234)", 1126240820); - toInteger.insert("QScriptValue(engine, 0x10000)", 65536); - toInteger.insert("QScriptValue(engine, 0x10001)", 65537); - toInteger.insert("QScriptValue(engine, qSNaN())", 0); - toInteger.insert("QScriptValue(engine, qQNaN())", 0); - toInteger.insert("QScriptValue(engine, qInf())", qInf()); - toInteger.insert("QScriptValue(engine, -qInf())", qInf()); - toInteger.insert("QScriptValue(engine, \"NaN\")", 0); - toInteger.insert("QScriptValue(engine, \"Infinity\")", qInf()); - toInteger.insert("QScriptValue(engine, \"-Infinity\")", qInf()); - toInteger.insert("QScriptValue(engine, \"ciao\")", 0); - toInteger.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", 0); - toInteger.insert("QScriptValue(engine, QString(\"\"))", 0); - toInteger.insert("QScriptValue(engine, QString())", 0); - toInteger.insert("QScriptValue(engine, QString(\"0\"))", 0); - toInteger.insert("QScriptValue(engine, QString(\"123\"))", 123); - toInteger.insert("QScriptValue(engine, QString(\"1.23\"))", 1); - toInteger.insert("engine->evaluate(\"[]\")", 0); - toInteger.insert("engine->evaluate(\"{}\")", 0); - toInteger.insert("engine->evaluate(\"Object.prototype\")", 0); - toInteger.insert("engine->evaluate(\"Date.prototype\")", 0); - toInteger.insert("engine->evaluate(\"Array.prototype\")", 0); - toInteger.insert("engine->evaluate(\"Function.prototype\")", 0); - toInteger.insert("engine->evaluate(\"Error.prototype\")", 0); - toInteger.insert("engine->evaluate(\"Object\")", 0); - toInteger.insert("engine->evaluate(\"Array\")", 0); - toInteger.insert("engine->evaluate(\"Number\")", 0); - toInteger.insert("engine->evaluate(\"Function\")", 0); - toInteger.insert("engine->evaluate(\"(function() { return 1; })\")", 0); - toInteger.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", 0); - toInteger.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", 0); - toInteger.insert("engine->evaluate(\"/foo/\")", 0); - toInteger.insert("engine->evaluate(\"new Object()\")", 0); - toInteger.insert("engine->evaluate(\"new Array()\")", 0); - toInteger.insert("engine->evaluate(\"new Error()\")", 0); - toInteger.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22); - toInteger.insert("engine->evaluate(\"Undefined\")", 0); - toInteger.insert("engine->evaluate(\"Null\")", 0); - toInteger.insert("engine->evaluate(\"True\")", 0); - toInteger.insert("engine->evaluate(\"False\")", 0); - toInteger.insert("engine->evaluate(\"undefined\")", 0); - toInteger.insert("engine->evaluate(\"null\")", 0); - toInteger.insert("engine->evaluate(\"true\")", 1); - toInteger.insert("engine->evaluate(\"false\")", 0); - toInteger.insert("engine->evaluate(\"122\")", 122); - toInteger.insert("engine->evaluate(\"124\")", 124); - toInteger.insert("engine->evaluate(\"0\")", 0); - toInteger.insert("engine->evaluate(\"0.0\")", 0); - toInteger.insert("engine->evaluate(\"123.0\")", 123); - toInteger.insert("engine->evaluate(\"6.37e-8\")", 0); - toInteger.insert("engine->evaluate(\"-6.37e-8\")", 0); - toInteger.insert("engine->evaluate(\"0x43211234\")", 1126240820); - toInteger.insert("engine->evaluate(\"0x10000\")", 65536); - toInteger.insert("engine->evaluate(\"0x10001\")", 65537); - toInteger.insert("engine->evaluate(\"NaN\")", 0); - toInteger.insert("engine->evaluate(\"Infinity\")", qInf()); - toInteger.insert("engine->evaluate(\"-Infinity\")", qInf()); - toInteger.insert("engine->evaluate(\"'ciao'\")", 0); - toInteger.insert("engine->evaluate(\"''\")", 0); - toInteger.insert("engine->evaluate(\"'0'\")", 0); - toInteger.insert("engine->evaluate(\"'123'\")", 123); - toInteger.insert("engine->evaluate(\"'12.4'\")", 12); - toInteger.insert("engine->nullValue()", 0); - toInteger.insert("engine->undefinedValue()", 0); - } - newRow(expr) << toInteger.value(expr); -} - -void tst_QScriptValue::toInteger_test(const char*, const QScriptValue& value) -{ - QFETCH(qsreal, expected); - if (qIsInf(expected)) { - QVERIFY(qIsInf(value.toInteger())); - QVERIFY(qIsInf(value.toInteger())); - return; - } - QCOMPARE(value.toInteger(), expected); - QCOMPARE(value.toInteger(), expected); -} - -DEFINE_TEST_FUNCTION(toInteger) - - -void tst_QScriptValue::toInt32_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::toInt32_makeData(const char* expr) -{ - static QHash toInt32; - if (toInt32.isEmpty()) { - toInt32.insert("QScriptValue()", 0); - toInt32.insert("QScriptValue(QScriptValue::UndefinedValue)", 0); - toInt32.insert("QScriptValue(QScriptValue::NullValue)", 0); - toInt32.insert("QScriptValue(true)", 1); - toInt32.insert("QScriptValue(false)", 0); - toInt32.insert("QScriptValue(int(122))", 122); - toInt32.insert("QScriptValue(uint(124))", 124); - toInt32.insert("QScriptValue(0)", 0); - toInt32.insert("QScriptValue(0.0)", 0); - toInt32.insert("QScriptValue(123.0)", 123); - toInt32.insert("QScriptValue(6.37e-8)", 0); - toInt32.insert("QScriptValue(-6.37e-8)", 0); - toInt32.insert("QScriptValue(0x43211234)", 1126240820); - toInt32.insert("QScriptValue(0x10000)", 65536); - toInt32.insert("QScriptValue(0x10001)", 65537); - toInt32.insert("QScriptValue(qSNaN())", 0); - toInt32.insert("QScriptValue(qQNaN())", 0); - toInt32.insert("QScriptValue(qInf())", 0); - toInt32.insert("QScriptValue(-qInf())", 0); - toInt32.insert("QScriptValue(\"NaN\")", 0); - toInt32.insert("QScriptValue(\"Infinity\")", 0); - toInt32.insert("QScriptValue(\"-Infinity\")", 0); - toInt32.insert("QScriptValue(\"ciao\")", 0); - toInt32.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", 0); - toInt32.insert("QScriptValue(QString(\"\"))", 0); - toInt32.insert("QScriptValue(QString())", 0); - toInt32.insert("QScriptValue(QString(\"0\"))", 0); - toInt32.insert("QScriptValue(QString(\"123\"))", 123); - toInt32.insert("QScriptValue(QString(\"12.4\"))", 12); - toInt32.insert("QScriptValue(0, QScriptValue::UndefinedValue)", 0); - toInt32.insert("QScriptValue(0, QScriptValue::NullValue)", 0); - toInt32.insert("QScriptValue(0, true)", 1); - toInt32.insert("QScriptValue(0, false)", 0); - toInt32.insert("QScriptValue(0, int(122))", 122); - toInt32.insert("QScriptValue(0, uint(124))", 124); - toInt32.insert("QScriptValue(0, 0)", 0); - toInt32.insert("QScriptValue(0, 0.0)", 0); - toInt32.insert("QScriptValue(0, 123.0)", 123); - toInt32.insert("QScriptValue(0, 6.37e-8)", 0); - toInt32.insert("QScriptValue(0, -6.37e-8)", 0); - toInt32.insert("QScriptValue(0, 0x43211234)", 1126240820); - toInt32.insert("QScriptValue(0, 0x10000)", 65536); - toInt32.insert("QScriptValue(0, 0x10001)", 65537); - toInt32.insert("QScriptValue(0, qSNaN())", 0); - toInt32.insert("QScriptValue(0, qQNaN())", 0); - toInt32.insert("QScriptValue(0, qInf())", 0); - toInt32.insert("QScriptValue(0, -qInf())", 0); - toInt32.insert("QScriptValue(0, \"NaN\")", 0); - toInt32.insert("QScriptValue(0, \"Infinity\")", 0); - toInt32.insert("QScriptValue(0, \"-Infinity\")", 0); - toInt32.insert("QScriptValue(0, \"ciao\")", 0); - toInt32.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", 0); - toInt32.insert("QScriptValue(0, QString(\"\"))", 0); - toInt32.insert("QScriptValue(0, QString())", 0); - toInt32.insert("QScriptValue(0, QString(\"0\"))", 0); - toInt32.insert("QScriptValue(0, QString(\"123\"))", 123); - toInt32.insert("QScriptValue(0, QString(\"12.3\"))", 12); - toInt32.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", 0); - toInt32.insert("QScriptValue(engine, QScriptValue::NullValue)", 0); - toInt32.insert("QScriptValue(engine, true)", 1); - toInt32.insert("QScriptValue(engine, false)", 0); - toInt32.insert("QScriptValue(engine, int(122))", 122); - toInt32.insert("QScriptValue(engine, uint(124))", 124); - toInt32.insert("QScriptValue(engine, 0)", 0); - toInt32.insert("QScriptValue(engine, 0.0)", 0); - toInt32.insert("QScriptValue(engine, 123.0)", 123); - toInt32.insert("QScriptValue(engine, 6.37e-8)", 0); - toInt32.insert("QScriptValue(engine, -6.37e-8)", 0); - toInt32.insert("QScriptValue(engine, 0x43211234)", 1126240820); - toInt32.insert("QScriptValue(engine, 0x10000)", 65536); - toInt32.insert("QScriptValue(engine, 0x10001)", 65537); - toInt32.insert("QScriptValue(engine, qSNaN())", 0); - toInt32.insert("QScriptValue(engine, qQNaN())", 0); - toInt32.insert("QScriptValue(engine, qInf())", 0); - toInt32.insert("QScriptValue(engine, -qInf())", 0); - toInt32.insert("QScriptValue(engine, \"NaN\")", 0); - toInt32.insert("QScriptValue(engine, \"Infinity\")", 0); - toInt32.insert("QScriptValue(engine, \"-Infinity\")", 0); - toInt32.insert("QScriptValue(engine, \"ciao\")", 0); - toInt32.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", 0); - toInt32.insert("QScriptValue(engine, QString(\"\"))", 0); - toInt32.insert("QScriptValue(engine, QString())", 0); - toInt32.insert("QScriptValue(engine, QString(\"0\"))", 0); - toInt32.insert("QScriptValue(engine, QString(\"123\"))", 123); - toInt32.insert("QScriptValue(engine, QString(\"1.23\"))", 1); - toInt32.insert("engine->evaluate(\"[]\")", 0); - toInt32.insert("engine->evaluate(\"{}\")", 0); - toInt32.insert("engine->evaluate(\"Object.prototype\")", 0); - toInt32.insert("engine->evaluate(\"Date.prototype\")", 0); - toInt32.insert("engine->evaluate(\"Array.prototype\")", 0); - toInt32.insert("engine->evaluate(\"Function.prototype\")", 0); - toInt32.insert("engine->evaluate(\"Error.prototype\")", 0); - toInt32.insert("engine->evaluate(\"Object\")", 0); - toInt32.insert("engine->evaluate(\"Array\")", 0); - toInt32.insert("engine->evaluate(\"Number\")", 0); - toInt32.insert("engine->evaluate(\"Function\")", 0); - toInt32.insert("engine->evaluate(\"(function() { return 1; })\")", 0); - toInt32.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", 0); - toInt32.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", 0); - toInt32.insert("engine->evaluate(\"/foo/\")", 0); - toInt32.insert("engine->evaluate(\"new Object()\")", 0); - toInt32.insert("engine->evaluate(\"new Array()\")", 0); - toInt32.insert("engine->evaluate(\"new Error()\")", 0); - toInt32.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22); - toInt32.insert("engine->evaluate(\"Undefined\")", 0); - toInt32.insert("engine->evaluate(\"Null\")", 0); - toInt32.insert("engine->evaluate(\"True\")", 0); - toInt32.insert("engine->evaluate(\"False\")", 0); - toInt32.insert("engine->evaluate(\"undefined\")", 0); - toInt32.insert("engine->evaluate(\"null\")", 0); - toInt32.insert("engine->evaluate(\"true\")", 1); - toInt32.insert("engine->evaluate(\"false\")", 0); - toInt32.insert("engine->evaluate(\"122\")", 122); - toInt32.insert("engine->evaluate(\"124\")", 124); - toInt32.insert("engine->evaluate(\"0\")", 0); - toInt32.insert("engine->evaluate(\"0.0\")", 0); - toInt32.insert("engine->evaluate(\"123.0\")", 123); - toInt32.insert("engine->evaluate(\"6.37e-8\")", 0); - toInt32.insert("engine->evaluate(\"-6.37e-8\")", 0); - toInt32.insert("engine->evaluate(\"0x43211234\")", 1126240820); - toInt32.insert("engine->evaluate(\"0x10000\")", 65536); - toInt32.insert("engine->evaluate(\"0x10001\")", 65537); - toInt32.insert("engine->evaluate(\"NaN\")", 0); - toInt32.insert("engine->evaluate(\"Infinity\")", 0); - toInt32.insert("engine->evaluate(\"-Infinity\")", 0); - toInt32.insert("engine->evaluate(\"'ciao'\")", 0); - toInt32.insert("engine->evaluate(\"''\")", 0); - toInt32.insert("engine->evaluate(\"'0'\")", 0); - toInt32.insert("engine->evaluate(\"'123'\")", 123); - toInt32.insert("engine->evaluate(\"'12.4'\")", 12); - toInt32.insert("engine->nullValue()", 0); - toInt32.insert("engine->undefinedValue()", 0); - } - newRow(expr) << toInt32.value(expr); -} - -void tst_QScriptValue::toInt32_test(const char*, const QScriptValue& value) -{ - QFETCH(qint32, expected); - QCOMPARE(value.toInt32(), expected); - QCOMPARE(value.toInt32(), expected); -} - -DEFINE_TEST_FUNCTION(toInt32) - - -void tst_QScriptValue::toUInt32_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::toUInt32_makeData(const char* expr) -{ - static QHash toUInt32; - if (toUInt32.isEmpty()) { - toUInt32.insert("QScriptValue()", 0); - toUInt32.insert("QScriptValue(QScriptValue::UndefinedValue)", 0); - toUInt32.insert("QScriptValue(QScriptValue::NullValue)", 0); - toUInt32.insert("QScriptValue(true)", 1); - toUInt32.insert("QScriptValue(false)", 0); - toUInt32.insert("QScriptValue(int(122))", 122); - toUInt32.insert("QScriptValue(uint(124))", 124); - toUInt32.insert("QScriptValue(0)", 0); - toUInt32.insert("QScriptValue(0.0)", 0); - toUInt32.insert("QScriptValue(123.0)", 123); - toUInt32.insert("QScriptValue(6.37e-8)", 0); - toUInt32.insert("QScriptValue(-6.37e-8)", 0); - toUInt32.insert("QScriptValue(0x43211234)", 1126240820); - toUInt32.insert("QScriptValue(0x10000)", 65536); - toUInt32.insert("QScriptValue(0x10001)", 65537); - toUInt32.insert("QScriptValue(qSNaN())", 0); - toUInt32.insert("QScriptValue(qQNaN())", 0); - toUInt32.insert("QScriptValue(qInf())", 0); - toUInt32.insert("QScriptValue(-qInf())", 0); - toUInt32.insert("QScriptValue(\"NaN\")", 0); - toUInt32.insert("QScriptValue(\"Infinity\")", 0); - toUInt32.insert("QScriptValue(\"-Infinity\")", 0); - toUInt32.insert("QScriptValue(\"ciao\")", 0); - toUInt32.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", 0); - toUInt32.insert("QScriptValue(QString(\"\"))", 0); - toUInt32.insert("QScriptValue(QString())", 0); - toUInt32.insert("QScriptValue(QString(\"0\"))", 0); - toUInt32.insert("QScriptValue(QString(\"123\"))", 123); - toUInt32.insert("QScriptValue(QString(\"12.4\"))", 12); - toUInt32.insert("QScriptValue(0, QScriptValue::UndefinedValue)", 0); - toUInt32.insert("QScriptValue(0, QScriptValue::NullValue)", 0); - toUInt32.insert("QScriptValue(0, true)", 1); - toUInt32.insert("QScriptValue(0, false)", 0); - toUInt32.insert("QScriptValue(0, int(122))", 122); - toUInt32.insert("QScriptValue(0, uint(124))", 124); - toUInt32.insert("QScriptValue(0, 0)", 0); - toUInt32.insert("QScriptValue(0, 0.0)", 0); - toUInt32.insert("QScriptValue(0, 123.0)", 123); - toUInt32.insert("QScriptValue(0, 6.37e-8)", 0); - toUInt32.insert("QScriptValue(0, -6.37e-8)", 0); - toUInt32.insert("QScriptValue(0, 0x43211234)", 1126240820); - toUInt32.insert("QScriptValue(0, 0x10000)", 65536); - toUInt32.insert("QScriptValue(0, 0x10001)", 65537); - toUInt32.insert("QScriptValue(0, qSNaN())", 0); - toUInt32.insert("QScriptValue(0, qQNaN())", 0); - toUInt32.insert("QScriptValue(0, qInf())", 0); - toUInt32.insert("QScriptValue(0, -qInf())", 0); - toUInt32.insert("QScriptValue(0, \"NaN\")", 0); - toUInt32.insert("QScriptValue(0, \"Infinity\")", 0); - toUInt32.insert("QScriptValue(0, \"-Infinity\")", 0); - toUInt32.insert("QScriptValue(0, \"ciao\")", 0); - toUInt32.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", 0); - toUInt32.insert("QScriptValue(0, QString(\"\"))", 0); - toUInt32.insert("QScriptValue(0, QString())", 0); - toUInt32.insert("QScriptValue(0, QString(\"0\"))", 0); - toUInt32.insert("QScriptValue(0, QString(\"123\"))", 123); - toUInt32.insert("QScriptValue(0, QString(\"12.3\"))", 12); - toUInt32.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", 0); - toUInt32.insert("QScriptValue(engine, QScriptValue::NullValue)", 0); - toUInt32.insert("QScriptValue(engine, true)", 1); - toUInt32.insert("QScriptValue(engine, false)", 0); - toUInt32.insert("QScriptValue(engine, int(122))", 122); - toUInt32.insert("QScriptValue(engine, uint(124))", 124); - toUInt32.insert("QScriptValue(engine, 0)", 0); - toUInt32.insert("QScriptValue(engine, 0.0)", 0); - toUInt32.insert("QScriptValue(engine, 123.0)", 123); - toUInt32.insert("QScriptValue(engine, 6.37e-8)", 0); - toUInt32.insert("QScriptValue(engine, -6.37e-8)", 0); - toUInt32.insert("QScriptValue(engine, 0x43211234)", 1126240820); - toUInt32.insert("QScriptValue(engine, 0x10000)", 65536); - toUInt32.insert("QScriptValue(engine, 0x10001)", 65537); - toUInt32.insert("QScriptValue(engine, qSNaN())", 0); - toUInt32.insert("QScriptValue(engine, qQNaN())", 0); - toUInt32.insert("QScriptValue(engine, qInf())", 0); - toUInt32.insert("QScriptValue(engine, -qInf())", 0); - toUInt32.insert("QScriptValue(engine, \"NaN\")", 0); - toUInt32.insert("QScriptValue(engine, \"Infinity\")", 0); - toUInt32.insert("QScriptValue(engine, \"-Infinity\")", 0); - toUInt32.insert("QScriptValue(engine, \"ciao\")", 0); - toUInt32.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", 0); - toUInt32.insert("QScriptValue(engine, QString(\"\"))", 0); - toUInt32.insert("QScriptValue(engine, QString())", 0); - toUInt32.insert("QScriptValue(engine, QString(\"0\"))", 0); - toUInt32.insert("QScriptValue(engine, QString(\"123\"))", 123); - toUInt32.insert("QScriptValue(engine, QString(\"1.23\"))", 1); - toUInt32.insert("engine->evaluate(\"[]\")", 0); - toUInt32.insert("engine->evaluate(\"{}\")", 0); - toUInt32.insert("engine->evaluate(\"Object.prototype\")", 0); - toUInt32.insert("engine->evaluate(\"Date.prototype\")", 0); - toUInt32.insert("engine->evaluate(\"Array.prototype\")", 0); - toUInt32.insert("engine->evaluate(\"Function.prototype\")", 0); - toUInt32.insert("engine->evaluate(\"Error.prototype\")", 0); - toUInt32.insert("engine->evaluate(\"Object\")", 0); - toUInt32.insert("engine->evaluate(\"Array\")", 0); - toUInt32.insert("engine->evaluate(\"Number\")", 0); - toUInt32.insert("engine->evaluate(\"Function\")", 0); - toUInt32.insert("engine->evaluate(\"(function() { return 1; })\")", 0); - toUInt32.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", 0); - toUInt32.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", 0); - toUInt32.insert("engine->evaluate(\"/foo/\")", 0); - toUInt32.insert("engine->evaluate(\"new Object()\")", 0); - toUInt32.insert("engine->evaluate(\"new Array()\")", 0); - toUInt32.insert("engine->evaluate(\"new Error()\")", 0); - toUInt32.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22); - toUInt32.insert("engine->evaluate(\"Undefined\")", 0); - toUInt32.insert("engine->evaluate(\"Null\")", 0); - toUInt32.insert("engine->evaluate(\"True\")", 0); - toUInt32.insert("engine->evaluate(\"False\")", 0); - toUInt32.insert("engine->evaluate(\"undefined\")", 0); - toUInt32.insert("engine->evaluate(\"null\")", 0); - toUInt32.insert("engine->evaluate(\"true\")", 1); - toUInt32.insert("engine->evaluate(\"false\")", 0); - toUInt32.insert("engine->evaluate(\"122\")", 122); - toUInt32.insert("engine->evaluate(\"124\")", 124); - toUInt32.insert("engine->evaluate(\"0\")", 0); - toUInt32.insert("engine->evaluate(\"0.0\")", 0); - toUInt32.insert("engine->evaluate(\"123.0\")", 123); - toUInt32.insert("engine->evaluate(\"6.37e-8\")", 0); - toUInt32.insert("engine->evaluate(\"-6.37e-8\")", 0); - toUInt32.insert("engine->evaluate(\"0x43211234\")", 1126240820); - toUInt32.insert("engine->evaluate(\"0x10000\")", 65536); - toUInt32.insert("engine->evaluate(\"0x10001\")", 65537); - toUInt32.insert("engine->evaluate(\"NaN\")", 0); - toUInt32.insert("engine->evaluate(\"Infinity\")", 0); - toUInt32.insert("engine->evaluate(\"-Infinity\")", 0); - toUInt32.insert("engine->evaluate(\"'ciao'\")", 0); - toUInt32.insert("engine->evaluate(\"''\")", 0); - toUInt32.insert("engine->evaluate(\"'0'\")", 0); - toUInt32.insert("engine->evaluate(\"'123'\")", 123); - toUInt32.insert("engine->evaluate(\"'12.4'\")", 12); - toUInt32.insert("engine->nullValue()", 0); - toUInt32.insert("engine->undefinedValue()", 0); - } - newRow(expr) << toUInt32.value(expr); -} - -void tst_QScriptValue::toUInt32_test(const char*, const QScriptValue& value) -{ - QFETCH(quint32, expected); - QCOMPARE(value.toUInt32(), expected); - QCOMPARE(value.toUInt32(), expected); -} - -DEFINE_TEST_FUNCTION(toUInt32) - - -void tst_QScriptValue::toUInt16_initData() -{ - QTest::addColumn("expected"); - initScriptValues(); -} - -void tst_QScriptValue::toUInt16_makeData(const char* expr) -{ - static QHash toUInt16; - if (toUInt16.isEmpty()) { - toUInt16.insert("QScriptValue()", 0); - toUInt16.insert("QScriptValue(QScriptValue::UndefinedValue)", 0); - toUInt16.insert("QScriptValue(QScriptValue::NullValue)", 0); - toUInt16.insert("QScriptValue(true)", 1); - toUInt16.insert("QScriptValue(false)", 0); - toUInt16.insert("QScriptValue(int(122))", 122); - toUInt16.insert("QScriptValue(uint(124))", 124); - toUInt16.insert("QScriptValue(0)", 0); - toUInt16.insert("QScriptValue(0.0)", 0); - toUInt16.insert("QScriptValue(123.0)", 123); - toUInt16.insert("QScriptValue(6.37e-8)", 0); - toUInt16.insert("QScriptValue(-6.37e-8)", 0); - toUInt16.insert("QScriptValue(0x43211234)", 4660); - toUInt16.insert("QScriptValue(0x10000)", 0); - toUInt16.insert("QScriptValue(0x10001)", 1); - toUInt16.insert("QScriptValue(qSNaN())", 0); - toUInt16.insert("QScriptValue(qQNaN())", 0); - toUInt16.insert("QScriptValue(qInf())", 0); - toUInt16.insert("QScriptValue(-qInf())", 0); - toUInt16.insert("QScriptValue(\"NaN\")", 0); - toUInt16.insert("QScriptValue(\"Infinity\")", 0); - toUInt16.insert("QScriptValue(\"-Infinity\")", 0); - toUInt16.insert("QScriptValue(\"ciao\")", 0); - toUInt16.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", 0); - toUInt16.insert("QScriptValue(QString(\"\"))", 0); - toUInt16.insert("QScriptValue(QString())", 0); - toUInt16.insert("QScriptValue(QString(\"0\"))", 0); - toUInt16.insert("QScriptValue(QString(\"123\"))", 123); - toUInt16.insert("QScriptValue(QString(\"12.4\"))", 12); - toUInt16.insert("QScriptValue(0, QScriptValue::UndefinedValue)", 0); - toUInt16.insert("QScriptValue(0, QScriptValue::NullValue)", 0); - toUInt16.insert("QScriptValue(0, true)", 1); - toUInt16.insert("QScriptValue(0, false)", 0); - toUInt16.insert("QScriptValue(0, int(122))", 122); - toUInt16.insert("QScriptValue(0, uint(124))", 124); - toUInt16.insert("QScriptValue(0, 0)", 0); - toUInt16.insert("QScriptValue(0, 0.0)", 0); - toUInt16.insert("QScriptValue(0, 123.0)", 123); - toUInt16.insert("QScriptValue(0, 6.37e-8)", 0); - toUInt16.insert("QScriptValue(0, -6.37e-8)", 0); - toUInt16.insert("QScriptValue(0, 0x43211234)", 4660); - toUInt16.insert("QScriptValue(0, 0x10000)", 0); - toUInt16.insert("QScriptValue(0, 0x10001)", 1); - toUInt16.insert("QScriptValue(0, qSNaN())", 0); - toUInt16.insert("QScriptValue(0, qQNaN())", 0); - toUInt16.insert("QScriptValue(0, qInf())", 0); - toUInt16.insert("QScriptValue(0, -qInf())", 0); - toUInt16.insert("QScriptValue(0, \"NaN\")", 0); - toUInt16.insert("QScriptValue(0, \"Infinity\")", 0); - toUInt16.insert("QScriptValue(0, \"-Infinity\")", 0); - toUInt16.insert("QScriptValue(0, \"ciao\")", 0); - toUInt16.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", 0); - toUInt16.insert("QScriptValue(0, QString(\"\"))", 0); - toUInt16.insert("QScriptValue(0, QString())", 0); - toUInt16.insert("QScriptValue(0, QString(\"0\"))", 0); - toUInt16.insert("QScriptValue(0, QString(\"123\"))", 123); - toUInt16.insert("QScriptValue(0, QString(\"12.3\"))", 12); - toUInt16.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", 0); - toUInt16.insert("QScriptValue(engine, QScriptValue::NullValue)", 0); - toUInt16.insert("QScriptValue(engine, true)", 1); - toUInt16.insert("QScriptValue(engine, false)", 0); - toUInt16.insert("QScriptValue(engine, int(122))", 122); - toUInt16.insert("QScriptValue(engine, uint(124))", 124); - toUInt16.insert("QScriptValue(engine, 0)", 0); - toUInt16.insert("QScriptValue(engine, 0.0)", 0); - toUInt16.insert("QScriptValue(engine, 123.0)", 123); - toUInt16.insert("QScriptValue(engine, 6.37e-8)", 0); - toUInt16.insert("QScriptValue(engine, -6.37e-8)", 0); - toUInt16.insert("QScriptValue(engine, 0x43211234)", 4660); - toUInt16.insert("QScriptValue(engine, 0x10000)", 0); - toUInt16.insert("QScriptValue(engine, 0x10001)", 1); - toUInt16.insert("QScriptValue(engine, qSNaN())", 0); - toUInt16.insert("QScriptValue(engine, qQNaN())", 0); - toUInt16.insert("QScriptValue(engine, qInf())", 0); - toUInt16.insert("QScriptValue(engine, -qInf())", 0); - toUInt16.insert("QScriptValue(engine, \"NaN\")", 0); - toUInt16.insert("QScriptValue(engine, \"Infinity\")", 0); - toUInt16.insert("QScriptValue(engine, \"-Infinity\")", 0); - toUInt16.insert("QScriptValue(engine, \"ciao\")", 0); - toUInt16.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", 0); - toUInt16.insert("QScriptValue(engine, QString(\"\"))", 0); - toUInt16.insert("QScriptValue(engine, QString())", 0); - toUInt16.insert("QScriptValue(engine, QString(\"0\"))", 0); - toUInt16.insert("QScriptValue(engine, QString(\"123\"))", 123); - toUInt16.insert("QScriptValue(engine, QString(\"1.23\"))", 1); - toUInt16.insert("engine->evaluate(\"[]\")", 0); - toUInt16.insert("engine->evaluate(\"{}\")", 0); - toUInt16.insert("engine->evaluate(\"Object.prototype\")", 0); - toUInt16.insert("engine->evaluate(\"Date.prototype\")", 0); - toUInt16.insert("engine->evaluate(\"Array.prototype\")", 0); - toUInt16.insert("engine->evaluate(\"Function.prototype\")", 0); - toUInt16.insert("engine->evaluate(\"Error.prototype\")", 0); - toUInt16.insert("engine->evaluate(\"Object\")", 0); - toUInt16.insert("engine->evaluate(\"Array\")", 0); - toUInt16.insert("engine->evaluate(\"Number\")", 0); - toUInt16.insert("engine->evaluate(\"Function\")", 0); - toUInt16.insert("engine->evaluate(\"(function() { return 1; })\")", 0); - toUInt16.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", 0); - toUInt16.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", 0); - toUInt16.insert("engine->evaluate(\"/foo/\")", 0); - toUInt16.insert("engine->evaluate(\"new Object()\")", 0); - toUInt16.insert("engine->evaluate(\"new Array()\")", 0); - toUInt16.insert("engine->evaluate(\"new Error()\")", 0); - toUInt16.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22); - toUInt16.insert("engine->evaluate(\"Undefined\")", 0); - toUInt16.insert("engine->evaluate(\"Null\")", 0); - toUInt16.insert("engine->evaluate(\"True\")", 0); - toUInt16.insert("engine->evaluate(\"False\")", 0); - toUInt16.insert("engine->evaluate(\"undefined\")", 0); - toUInt16.insert("engine->evaluate(\"null\")", 0); - toUInt16.insert("engine->evaluate(\"true\")", 1); - toUInt16.insert("engine->evaluate(\"false\")", 0); - toUInt16.insert("engine->evaluate(\"122\")", 122); - toUInt16.insert("engine->evaluate(\"124\")", 124); - toUInt16.insert("engine->evaluate(\"0\")", 0); - toUInt16.insert("engine->evaluate(\"0.0\")", 0); - toUInt16.insert("engine->evaluate(\"123.0\")", 123); - toUInt16.insert("engine->evaluate(\"6.37e-8\")", 0); - toUInt16.insert("engine->evaluate(\"-6.37e-8\")", 0); - toUInt16.insert("engine->evaluate(\"0x43211234\")", 4660); - toUInt16.insert("engine->evaluate(\"0x10000\")", 0); - toUInt16.insert("engine->evaluate(\"0x10001\")", 1); - toUInt16.insert("engine->evaluate(\"NaN\")", 0); - toUInt16.insert("engine->evaluate(\"Infinity\")", 0); - toUInt16.insert("engine->evaluate(\"-Infinity\")", 0); - toUInt16.insert("engine->evaluate(\"'ciao'\")", 0); - toUInt16.insert("engine->evaluate(\"''\")", 0); - toUInt16.insert("engine->evaluate(\"'0'\")", 0); - toUInt16.insert("engine->evaluate(\"'123'\")", 123); - toUInt16.insert("engine->evaluate(\"'12.4'\")", 12); - toUInt16.insert("engine->nullValue()", 0); - toUInt16.insert("engine->undefinedValue()", 0); - } - newRow(expr) << toUInt16.value(expr); -} - -void tst_QScriptValue::toUInt16_test(const char*, const QScriptValue& value) -{ - QFETCH(quint16, expected); - QCOMPARE(value.toUInt16(), expected); - QCOMPARE(value.toUInt16(), expected); -} - -DEFINE_TEST_FUNCTION(toUInt16) diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/tests/tests.pri b/src/3rdparty/webkit/JavaScriptCore/qt/tests/tests.pri deleted file mode 100644 index 5af3383..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/tests/tests.pri +++ /dev/null @@ -1,19 +0,0 @@ -QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -QMAKE_LIBDIR = $$OUTPUT_DIR/lib $$QMAKE_LIBDIR -mac:!static:contains(QT_CONFIG, qt_framework):!CONFIG(webkit_no_framework) { - LIBS += -framework QtScript - QMAKE_FRAMEWORKPATH = $$OUTPUT_DIR/lib $$QMAKE_FRAMEWORKPATH -} else { - win32-*|wince* { - LIBS += -lQtScript$${QT_MAJOR_VERSION} - } else { - LIBS += -lQtScript - } -} - -CONFIG(release, debug|release) { - DEFINES += NDEBUG -} - -INCLUDEPATH += $$PWD/../api - diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/tests/tests.pro b/src/3rdparty/webkit/JavaScriptCore/qt/tests/tests.pro deleted file mode 100644 index 7c3f590..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/qt/tests/tests.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = qscriptengine \ - qscriptvalue \ - qscriptstring -- cgit v0.12 From 4bc894400ffb4ad07babe9b45ed53ceb2d986418 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 21 Jun 2010 14:56:26 +0200 Subject: Updated WebKit to 4ad38c43081bedb69c7e26a9ca0fb2c50456066d Integrated changes: || || [Qt] Compilation in QWebPagePrivate::timerEvent with clang || || || [Qt] Bridge documentation: some snippets have the wrong indentation || || || [Qt] Avoid truncation of zoom factor in QWebFrame's print function. || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp | 4 +- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 2 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 60 ++++++++++++++++++++++ .../webkit/WebKit/qt/declarative/declarative.pro | 24 +++++---- .../webkitsnippets/qtwebkit_bridge_snippets.cpp | 43 ++++++++-------- 7 files changed, 98 insertions(+), 39 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 98460a0..3ebd2c1 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -19de3d2848b715f937eb375a078672cc8e9b8185 +4ad38c43081bedb69c7e26a9ca0fb2c50456066d diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index c2daf34..86d1838 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 19de3d2848b715f937eb375a078672cc8e9b8185 + 4ad38c43081bedb69c7e26a9ca0fb2c50456066d diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp index 721aaa6..cc7b11c 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp @@ -1431,8 +1431,8 @@ void QWebFrame::print(QPrinter *printer) const if (!painter.begin(printer)) return; - const qreal zoomFactorX = printer->logicalDpiX() / qt_defaultDpi(); - const qreal zoomFactorY = printer->logicalDpiY() / qt_defaultDpi(); + const qreal zoomFactorX = (qreal)printer->logicalDpiX() / qt_defaultDpi(); + const qreal zoomFactorY = (qreal)printer->logicalDpiY() / qt_defaultDpi(); PrintContext printContext(d->frame); float pageHeight = 0; diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index 4460ad3..3141f66 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -766,7 +766,7 @@ void QWebPagePrivate::timerEvent(QTimerEvent *ev) if (timerId == tripleClickTimer.timerId()) tripleClickTimer.stop(); else - q->QObject::timerEvent(ev); + q->timerEvent(ev); } void QWebPagePrivate::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 3df2970..2785421 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,63 @@ +2010-06-21 Simon Hausmann + + Unreviewed build fix. + + [Qt] Fix package builds + + Don't use rpath unless we're building inside the trunk. + + * declarative/declarative.pro: + +2010-06-19 Mirko Damiani + + Reviewed by Simon Hausmann. + + [Qt] Avoid truncation of zoom factor in QWebFrame's print function. + https://bugs.webkit.org/show_bug.cgi?id=40662 + + The zoom factor is a qreal number but its value is truncated to an + integer. So a cast to qreal is needed to avoid this issue. + + * Api/qwebframe.cpp: + (QWebFrame::print): + +2010-06-19 No'am Rosenthal + + Reviewed by Simon Hausmann. + + Bridge documentation: some snippets have the wrong indentation + https://bugs.webkit.org/show_bug.cgi?id=40717 + + Fixed code snippets + + * docs/webkitsnippets/qtwebkit_bridge_snippets.cpp: + (wrapInFunction): + +2010-06-19 Olivier Goffart + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Compilation in QWebPagePrivate::timerEvent with clang + https://bugs.webkit.org/show_bug.cgi?id=40714 + + QObject::timerEvent is protected and cannot be accessed by QWebPagePrivate + with clang + + QWebPagePrivate is a friend of QWebPage and then should have access to + all protected members of parents of QWebPage, including QObject. + But the clang team do not want to conform to this aspect of the specification + because "It is either a drafting error or a horrible mistake." + See http://llvm.org/bugs/show_bug.cgi?id=6840 + + This change is better because QWebPage does not reimplement the timerEvent + (QWebPagePrivate::timerEvent is called from QWebPage::event) + So customers that would reimplement their own timerEvent + for their own timer now get a chance to catch them. + + + * Api/qwebpage.cpp: + (QWebPagePrivate::timerEvent): + 2010-06-18 Alexis Menard Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro index 924329a..122d90a 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro +++ b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro @@ -34,17 +34,19 @@ include(../../../WebKit.pri) QT += declarative -linux-* { - # From Creator's src/rpath.pri: - # Do the rpath by hand since it's not possible to use ORIGIN in QMAKE_RPATHDIR - # this expands to $ORIGIN (after qmake and make), it does NOT read a qmake var. - QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR - MY_RPATH = $$join(QMAKE_RPATHDIR, ":") - - QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${MY_RPATH}\' - QMAKE_RPATHDIR = -} else { - QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR +!CONFIG(standalone_package) { + linux-* { + # From Creator's src/rpath.pri: + # Do the rpath by hand since it's not possible to use ORIGIN in QMAKE_RPATHDIR + # this expands to $ORIGIN (after qmake and make), it does NOT read a qmake var. + QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR + MY_RPATH = $$join(QMAKE_RPATHDIR, ":") + + QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${MY_RPATH}\' + QMAKE_RPATHDIR = + } else { + QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR + } } SOURCES += qdeclarativewebview.cpp plugin.cpp diff --git a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp index 62eeeca..6a517c2 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp +++ b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp @@ -12,10 +12,10 @@ void wrapInFunction() //! [1] { width: ..., - height: ..., - toDataURL: function() { ... }, - assignToHTMLImageElement: function(element) { ... } - } + height: ..., + toDataURL: function() { ... }, + assignToHTMLImageElement: function(element) { ... } + } //! [1] #endif //! [2] @@ -24,7 +24,7 @@ void wrapInFunction() Q_PROPERTY(QPixmap myPixmap READ getPixmap) public: - QPixmap getPixmap() const; + QPixmap getPixmap() const; }; /* ... */ @@ -36,21 +36,22 @@ void wrapInFunction() #if 0 //! [3] - + - - - - - - //! [3] + function loadImage() + { + myObject.myPixmap.assignToHTMLImageElement(document.getElementById("imageElement")); + } + + + + + + +//! [3] #endif - //! [4] - class MyObject : QObject { +//! [4] +class MyObject : QObject { Q_OBJECT public slots: @@ -161,11 +162,7 @@ void wrapInFunction() myQObject.enabled = !myQObject.enabled; //! [24] //! [25] - myQObject.enabled = true; - - ... - - myQObject.enabled = !myQObject.enabled; + myDialog.okButton //! [25] //! [26] myDialog.okButton -- cgit v0.12 From 33ccc95da472e2932514e3df43ffc1df33855ded Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 21 Jun 2010 16:25:39 +0200 Subject: Updated WebKit to 45d1c9149ef8940081fa8dd35854d2b95ebaf3cd Integrated changes: || || text repainting does not account for glyphs which draw outside the typographic bounds of the font || || || [Qt] Symbian builds in release sometimes try to link with the debug JavaScriptCore static lib. || || || [Qt] Get rid of the the unused imageSize of ImageDecoderQt::internalHandleCurrentImage() || || || http://trac.webkit.org/changeset/57215 caused perf regressions || || || [Qt] Implement the simple font code path. || || || [Qt] Avoid unnecessary image conversion in RGBA32Buffer::zeroFill() || || || [Qt] Decode images directly to QPixmap || || || [chromium] use integral glyph widths || --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/JavaScriptCore/ChangeLog | 40 +++ .../webkit/JavaScriptCore/JavaScriptCore.pri | 18 +- src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h | 4 - src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 301 +++++++++++++++++++++ src/3rdparty/webkit/WebCore/WebCore.gypi | 4 +- .../webkit/WebCore/platform/graphics/Font.cpp | 104 +++++-- .../webkit/WebCore/platform/graphics/Font.h | 32 ++- .../WebCore/platform/graphics/FontFastPath.cpp | 88 +----- .../WebCore/platform/graphics/GlyphMetricsMap.cpp | 62 +++++ .../WebCore/platform/graphics/GlyphMetricsMap.h | 104 +++++++ .../WebCore/platform/graphics/GlyphWidthMap.cpp | 58 ---- .../WebCore/platform/graphics/GlyphWidthMap.h | 89 ------ .../WebCore/platform/graphics/SimpleFontData.cpp | 8 +- .../WebCore/platform/graphics/SimpleFontData.h | 31 ++- .../WebCore/platform/graphics/WidthIterator.cpp | 21 +- .../WebCore/platform/graphics/WidthIterator.h | 13 +- .../webkit/WebCore/platform/graphics/qt/FontQt.cpp | 188 ++++++++++--- .../platform/graphics/qt/ImageDecoderQt.cpp | 24 +- .../WebCore/platform/graphics/win/FontWin.cpp | 10 +- .../platform/graphics/win/SimpleFontDataCGWin.cpp | 18 +- .../platform/graphics/win/SimpleFontDataWin.cpp | 17 +- .../platform/graphics/win/UniscribeController.cpp | 34 ++- .../platform/graphics/win/UniscribeController.h | 10 + .../WebCore/platform/image-decoders/ImageDecoder.h | 7 +- .../platform/image-decoders/qt/RGBA32BufferQt.cpp | 31 ++- .../webkit/WebCore/rendering/InlineFlowBox.cpp | 44 +-- .../webkit/WebCore/rendering/InlineTextBox.cpp | 50 ++-- .../webkit/WebCore/rendering/InlineTextBox.h | 14 +- .../WebCore/rendering/RenderBlockLineLayout.cpp | 12 +- .../webkit/WebCore/rendering/RenderText.cpp | 58 ++-- src/3rdparty/webkit/WebCore/rendering/RenderText.h | 10 +- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 3 + src/3rdparty/webkit/WebKit/qt/ChangeLog | 41 +++ 35 files changed, 1113 insertions(+), 439 deletions(-) create mode 100644 src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.cpp create mode 100644 src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.h delete mode 100644 src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.cpp delete mode 100644 src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.h diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 3ebd2c1..1eb0d78 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -4ad38c43081bedb69c7e26a9ca0fb2c50456066d +45d1c9149ef8940081fa8dd35854d2b95ebaf3cd diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index adaf390..676ed23 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,43 @@ +2010-06-18 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] Work around a build problem with libjscore on Symbian. + https://bugs.webkit.org/show_bug.cgi?id=40840 + + Sbsv2 sometimes have problems with debug/release configuration + determination causing QtWebKit in release to try linking with the debug + JavaScriptCore static library. This patch limit the jscore/jscored + r58306 fix necessary for mac builds only to the mac platform to prevent the + different name problem. + + The real fix would be to fix qmake or the toolchain, this patch might + help meanwhile. + + * JavaScriptCore.pri: + +2010-05-31 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] Implement the simple text code path. + https://bugs.webkit.org/show_bug.cgi?id=40077 + + Remove the FONT_FAST_PATH macro and use the Qt's + fast text implementation instead of the one of WebKit. + + The Qt::TextBypassShaping flag is used to tell Qt to + only use the glyph advances. + + Qt 4.7 is needed to get this flag thus the complex path is always + used if QtWebKit is compiled against an earlier version. + + Contrary to the WebKit's implementation, the complex code path + is taken if the text is RightToLeft, justified or is formatted + with non-zero letter or word spacing. + + * wtf/Platform.h: + 2010-06-17 Mark Brand Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri index cc4a1b3..fe9e8cd 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri @@ -1,14 +1,14 @@ # JavaScriptCore - Qt4 build info VPATH += $$PWD -!CONFIG(release, debug|release) { - # Output in JavaScriptCore/ - JAVASCRIPTCORE_DESTDIR = debug - # Use a config-specific target to prevent parallel builds file clashes on Mac - JAVASCRIPTCORE_TARGET = jscored -} else { - JAVASCRIPTCORE_DESTDIR = release - JAVASCRIPTCORE_TARGET = jscore -} + +# Use a config-specific target to prevent parallel builds file clashes on Mac +mac: CONFIG(debug, debug|release): JAVASCRIPTCORE_TARGET = jscored +else: JAVASCRIPTCORE_TARGET = jscore + +# Output in JavaScriptCore/ +CONFIG(debug, debug|release) : JAVASCRIPTCORE_DESTDIR = debug +else: JAVASCRIPTCORE_DESTDIR = release + CONFIG(standalone_package) { isEmpty(JSC_GENERATED_SOURCES_DIR):JSC_GENERATED_SOURCES_DIR = $$PWD/generated } else { diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h index 876e60e..84b6153 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h @@ -1043,10 +1043,6 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ #define WTF_USE_QXMLQUERY 1 #endif -#if !PLATFORM(QT) -#define WTF_USE_FONT_FAST_PATH 1 -#endif - /* Accelerated compositing */ #if PLATFORM(MAC) #if !defined(BUILDING_ON_TIGER) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 86d1838..1a343eb 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 4ad38c43081bedb69c7e26a9ca0fb2c50456066d + 45d1c9149ef8940081fa8dd35854d2b95ebaf3cd diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index ddd04c1..fd259e0 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,304 @@ +2010-06-21 Balazs Kelemen + + Reviewed by Simon Hausmann. + + [Qt] Avoid unnecessary image conversion in RGBA32Buffer::zeroFill() + https://bugs.webkit.org/show_bug.cgi?id=40910 + + * platform/image-decoders/qt/RGBA32BufferQt.cpp: + (WebCore::RGBA32Buffer::zeroFill): + +2010-05-31 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] Implement the simple text code path. + https://bugs.webkit.org/show_bug.cgi?id=40077 + + Remove the FONT_FAST_PATH macro and use the Qt's + fast text implementation instead of the one of WebKit. + + The Qt::TextBypassShaping flag is used to tell Qt to + only use the glyph advances. + + Qt 4.7 is needed to get this flag thus the complex path is always + used if QtWebKit is compiled against an earlier version. + + Contrary to the WebKit's implementation, the complex code path + is taken if the text is RightToLeft, justified or is formatted + with non-zero letter or word spacing. + + * platform/graphics/Font.cpp: + (WebCore::Font::drawText): + (WebCore::Font::floatWidth): + (WebCore::Font::selectionRectForText): + (WebCore::Font::offsetForPosition): + * platform/graphics/Font.h: + (WebCore::Font::isRoundingHackCharacter): + * platform/graphics/qt/FontQt.cpp: + (WebCore::fromRawDataWithoutRef): + (WebCore::needComplexCodePath): + (WebCore::setupPlatformContext): + (WebCore::Font::canReturnFallbackFontsForComplexText): + (WebCore::Font::drawSimpleText): + (WebCore::Font::drawComplexText): + (WebCore::Font::floatWidthForSimpleText): + (WebCore::Font::offsetForPositionForSimpleText): + (WebCore::Font::selectionRectForSimpleText): + +2010-06-03 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + Move the text code path detection code from FontFastPath.cpp to Font.cpp. + https://bugs.webkit.org/show_bug.cgi?id=40077 + + This is a patch preliminary to the implementation of the + simple font code path for the Qt port. + + * platform/graphics/Font.cpp: + (WebCore::Font::setCodePath): + (WebCore::Font::codePath): + * platform/graphics/Font.h: + * platform/graphics/FontFastPath.cpp: + +2010-04-30 Dan Bernstein + + Reviewed by Adele Peterson. + + Part of Text repainting does not account for glyphs which draw outside the typographic bounds of the font + https://bugs.webkit.org/show_bug.cgi?id=6274 + + Account for glyph overflow of characters in the range U+1E00..U+2000, but without sending them + through the complex text code path. Instead, introduce a variant of the fast path that tracks + glyph overflow. + + * platform/graphics/Font.cpp: + (WebCore::Font::drawText): Use codePath(). + (WebCore::Font::floatWidth): Use codePath(). Pass the GlyphOverflow pointer through to + floatWidthForSimpleText() if the code path is SimpleWithGlyphOverflow. + (WebCore::Font::selectionRectForText): Use codePath(). + (WebCore::Font::offsetForPosition): Ditto. + * platform/graphics/Font.h: Replaced canUseGlyphCache() with codePath(). Added a GlyphOverflow + parameter to floatWidthForSimpleText(). + * platform/graphics/FontFastPath.cpp: + Removed ROMAN_AND_GREEK_DIACRITICS_CAN_USE_GLYPH_CACHE. + (WebCore::Font::codePath): Renamed canUseGlyphCache() to this. Where it used to return false, + it now returns Complex. Where it used to return true, it now returns Simple, except for + the range U+1E00..U+2000, where it now returns SimpleWithGlyphOverflow. + (WebCore::Font::floatWidthForSimpleText): Added a GlyphOverflow parameter. If not 0, have the + width iterator account for glyph bounds, then update the GlyphOverflow accordingly. + * platform/graphics/WidthIterator.cpp: + (WebCore::WidthIterator::WidthIterator): Added boolean parameter telling the width iterator + whether to account for glyph bounds. Initialize m_accountForGlyphBounds accordingly. Initialize + m_maxGlyphBoundingBoxY, m_minGlyphBoundingBoxY, m_firstGlyphOverflow and m_lastGlyphOverflow. + (WebCore::WidthIterator::advance): If accounting for glyph bounds, update the above member variables. + * platform/graphics/WidthIterator.h: + (WebCore::WidthIterator::maxGlyphBoundingBoxY): Added this accessor. + (WebCore::WidthIterator::minGlyphBoundingBoxY): Ditto. + (WebCore::WidthIterator::firstGlyphOverflow): Ditto. + (WebCore::WidthIterator::lastGlyphOverflow): Ditto. + +2010-04-21 Ojan Vafai + + Reviewed by Adele Peterson. + + http://trac.webkit.org/changeset/57215 caused perf/memory regressions + https://bugs.webkit.org/show_bug.cgi?id=37292 + + #if out the canUseGlyphCache Changes from r57215 as they caused a + 8% perf regression on Chromium's international page load tests so that + the perf regression can be fixed properly without being left in the tree. + + * platform/graphics/FontFastPath.cpp: + (WebCore::Font::canUseGlyphCache): + +2010-04-07 Enrica Casucci + + Reviewed by Dave Hyatt. + + Text repainting does not account for glyphs which draw outside the typographic bounds of the font (6274). + + + + In order to be able to handle successfully this case, it is necessary to change the glyph width cache to store + the bounding box for the glyph instead of the simply caching the glyph width. + Retrieving the bounding box for the glyph is expensive, therefore we do it only + when we are rendering text using the complex text path to minimize the performance impact. + To support characters with stacked diacritics, the method canUseGlyphCache has been modified to + return false for the range of characters with stacked diacritics. + The glyph cache has been also updated to allow storing the glyph bounding box together with the + horizontal width. The bounding box is populated only for complex text. + + The original version of this patch has been written by Dan Bernstein. + + Test: fast/repaint/stacked-diacritics.html + + * Android.mk: File name change. + * GNUmakefile.am: File name change. + * WebCore.base.exp: Added parameter in exported function. + * WebCore.gypi: File name change. + * WebCore.vcproj/WebCore.vcproj: File name change. + * WebCore.xcodeproj/project.pbxproj: File name change. + * platform/graphics/Font.cpp: + (WebCore::Font::floatWidth): Added glyphOverflow parameter. + * platform/graphics/Font.h: + (WebCore::GlyphOverflow::GlyphOverflow): Added. + (WebCore::Font::width): Added glyphOverflow parameter. + * platform/graphics/FontFastPath.cpp: + (WebCore::Font::canUseGlyphCache): Modified to render characters with stacked diacritics with complex text path. + * platform/graphics/GlyphMetricsMap.cpp: Copied from WebCore/platform/graphics/GlyphWidthMap.cpp. + (WebCore::GlyphMetricsMap::locatePageSlowCase): Class name changed to reflect new semantics. + * platform/graphics/GlyphMetricsMap.h: Copied from WebCore/platform/graphics/GlyphWidthMap.h. + (WebCore::GlyphMetricsMap::GlyphMetricsMap): + (WebCore::GlyphMetricsMap::~GlyphMetricsMap): + (WebCore::GlyphMetricsMap::metricsForGlyph): + (WebCore::GlyphMetricsMap::widthForGlyph): + (WebCore::GlyphMetricsMap::setMetricsForGlyph): + (WebCore::GlyphMetricsMap::GlyphMetricsPage::metricsForGlyph): + (WebCore::GlyphMetricsMap::GlyphMetricsPage::setMetricsForGlyph): + (WebCore::GlyphMetricsMap::GlyphMetricsPage::setMetricsForIndex): + (WebCore::GlyphMetricsMap::locatePage): + * platform/graphics/GlyphWidthMap.cpp: Removed. + * platform/graphics/GlyphWidthMap.h: Removed. + * platform/graphics/SimpleFontData.cpp: + (WebCore::SimpleFontData::platformGlyphInit): + * platform/graphics/SimpleFontData.h: + (WebCore::): + (WebCore::SimpleFontData::widthForGlyph): + (WebCore::SimpleFontData::metricsForGlyph): + * platform/graphics/cairo/SimpleFontDataCairo.cpp: + (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change. + * platform/graphics/chromium/FontChromiumWin.cpp: + (WebCore::Font::floatWidthForComplexText): Added parameter. + * platform/graphics/chromium/FontLinux.cpp: + (WebCore::Font::floatWidthForComplexText): Added parameter. + * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp: + (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change. + * platform/graphics/chromium/SimpleFontDataLinux.cpp: + (WebCore::SimpleFontData::platformWidthForGlyph): Name and signature vachange + * platform/graphics/efl/FontEfl.cpp: + (WebCore::Font::floatWidthForComplexText): Name and signature change. + * platform/graphics/gtk/SimpleFontDataPango.cpp: + (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change. + * platform/graphics/haiku/FontHaiku.cpp: + (WebCore::Font::floatWidthForComplexText): Added parameter. + * platform/graphics/haiku/SimpleFontDataHaiku.cpp: + (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change. + * platform/graphics/mac/ComplexTextController.cpp: + (WebCore::ComplexTextController::ComplexTextController): + (WebCore::ComplexTextController::adjustGlyphsAndAdvances): + * platform/graphics/mac/ComplexTextController.h: + (WebCore::ComplexTextController::minGlyphBoundingBoxX): + (WebCore::ComplexTextController::maxGlyphBoundingBoxX): + (WebCore::ComplexTextController::minGlyphBoundingBoxY): + (WebCore::ComplexTextController::maxGlyphBoundingBoxY): + * platform/graphics/mac/FontComplexTextMac.cpp: + (WebCore::Font::floatWidthForComplexText): Added paramter. + * platform/graphics/mac/SimpleFontDataMac.mm: + (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change. + * platform/graphics/qt/FontQt.cpp: + (WebCore::Font::floatWidthForComplexText): Added paramter. + * platform/graphics/win/FontWin.cpp: + (WebCore::Font::floatWidthForComplexText): Added parameter. + * platform/graphics/win/SimpleFontDataCGWin.cpp: + (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change. + * platform/graphics/win/SimpleFontDataWin.cpp: + (WebCore::SimpleFontData::metricsForGDIGlyph): + * platform/graphics/win/UniscribeController.cpp: + (WebCore::UniscribeController::UniscribeController): + (WebCore::UniscribeController::shapeAndPlaceItem): + * platform/graphics/win/UniscribeController.h: + (WebCore::UniscribeController::minGlyphBoundingBoxX): + (WebCore::UniscribeController::maxGlyphBoundingBoxX): + (WebCore::UniscribeController::minGlyphBoundingBoxY): + (WebCore::UniscribeController::maxGlyphBoundingBoxY): + * platform/graphics/wince/FontWince.cpp: + (WebCore::Font::floatWidthForComplexText): Added parameter. + * platform/graphics/wx/FontWx.cpp: + (WebCore::Font::floatWidthForComplexText): Added parameter. + * platform/graphics/wx/SimpleFontDataWx.cpp: + (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change. + * rendering/InlineFlowBox.cpp: + (WebCore::InlineFlowBox::placeBoxesHorizontally): + (WebCore::InlineFlowBox::computeLogicalBoxHeights): + (WebCore::InlineFlowBox::computeVerticalOverflow): + * rendering/InlineTextBox.cpp: + (WebCore::InlineTextBox::setFallbackFonts): + (WebCore::InlineTextBox::fallbackFonts): + (WebCore::InlineTextBox::setGlyphOverflow): + (WebCore::InlineTextBox::glyphOverflow): + * rendering/InlineTextBox.h: + (WebCore::InlineTextBox::clearGlyphOverflowAndFallbackFontMap): Added. + * rendering/RenderBlockLineLayout.cpp: + (WebCore::RenderBlock::computeHorizontalPositionsForLine): + (WebCore::RenderBlock::layoutInlineChildren): + * rendering/RenderText.cpp: + (WebCore::RenderText::RenderText): + (WebCore::RenderText::styleDidChange): + (WebCore::RenderText::widthFromCache): + (WebCore::RenderText::trimmedPrefWidths): + (WebCore::RenderText::calcPrefWidths): + (WebCore::RenderText::setText): + (WebCore::RenderText::width): + * rendering/RenderText.h: + +2010-03-23 Evan Martin + + Reviewed by Dmitry Titov. + + [chromium] use integral glyph widths + https://bugs.webkit.org/show_bug.cgi?id=36510 + + Despite WebKit (and Skia, to an extent) supporting non-integral + glyph widths, the font code path we hit in Skia only supports + integral glyph positions. This means that we would accumulate + offsets when drawing a sequence up non-integer-width glyphs + which would cause gaps when snapped to the pixel grid when drawing. + + * platform/graphics/chromium/SimpleFontDataLinux.cpp: + (WebCore::SimpleFontData::platformWidthForGlyph): + round glyph widths to integers. + +2010-06-21 Benjamin Poulain + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Decode images directly to QPixmap + https://bugs.webkit.org/show_bug.cgi?id=40797 + + Decode images to QPixmap directly instead of QImage when possible. + RGBA32Buffer transforms the pixmap back to image if + necessary. + + This improve the performance with certain graphic system, and + can reduce memory usage. + + * platform/graphics/qt/ImageDecoderQt.cpp: + (WebCore::ImageDecoderQt::setData): + (WebCore::ImageDecoderQt::internalHandleCurrentImage): + * platform/image-decoders/ImageDecoder.h: + (WebCore::RGBA32Buffer::getAddr): + * platform/image-decoders/qt/RGBA32BufferQt.cpp: + (WebCore::RGBA32Buffer::clear): + (WebCore::RGBA32Buffer::zeroFill): + (WebCore::RGBA32Buffer::copyBitmapData): + (WebCore::RGBA32Buffer::setSize): + (WebCore::RGBA32Buffer::asNewNativeImage): + (WebCore::RGBA32Buffer::setPixmap): + +2010-06-17 Benjamin Poulain + + Reviewed by Simon Hausmann. + + [Qt] Get rid of the the unused imageSize of ImageDecoderQt::internalHandleCurrentImage() + https://bugs.webkit.org/show_bug.cgi?id=40620 + + Remove an unused variable. + + * platform/graphics/qt/ImageDecoderQt.cpp: + (WebCore::ImageDecoderQt::internalHandleCurrentImage): + 2010-06-18 Ananth Jasty Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/WebCore.gypi b/src/3rdparty/webkit/WebCore/WebCore.gypi index 94a6052..27b9085 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.gypi +++ b/src/3rdparty/webkit/WebCore/WebCore.gypi @@ -2320,8 +2320,8 @@ 'platform/graphics/GlyphBuffer.h', 'platform/graphics/GlyphPageTreeNode.cpp', 'platform/graphics/GlyphPageTreeNode.h', - 'platform/graphics/GlyphWidthMap.cpp', - 'platform/graphics/GlyphWidthMap.h', + 'platform/graphics/GlyphMetricsMap.cpp', + 'platform/graphics/GlyphMetricsMap.h', 'platform/graphics/Gradient.cpp', 'platform/graphics/Gradient.h', 'platform/graphics/GraphicsContext.cpp', diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/Font.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/Font.cpp index 3d3ffe3..8e132e1 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/Font.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/Font.cpp @@ -38,7 +38,6 @@ using namespace Unicode; namespace WebCore { -#if USE(FONT_FAST_PATH) const uint8_t Font::gRoundingHackCharacterTable[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*\t*/, 1 /*\n*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*space*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*-*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*?*/, @@ -51,7 +50,6 @@ const uint8_t Font::gRoundingHackCharacterTable[256] = { }; Font::CodePath Font::s_codePath = Auto; -#endif // ============================================================================================ // Font Implementation (Cross-Platform Portion) @@ -174,31 +172,28 @@ void Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoi } #endif -#if USE(FONT_FAST_PATH) - if (canUseGlyphCache(run)) + if (codePath(run) != Complex) return drawSimpleText(context, run, point, from, to); -#endif return drawComplexText(context, run, point, from, to); } -float Font::floatWidth(const TextRun& run, HashSet* fallbackFonts) const +float Font::floatWidth(const TextRun& run, HashSet* fallbackFonts, GlyphOverflow* glyphOverflow) const { #if ENABLE(SVG_FONTS) if (primaryFont()->isSVGFont()) return floatWidthUsingSVGFont(run); #endif -#if USE(FONT_FAST_PATH) - if (canUseGlyphCache(run)) { + CodePath codePathToUse = codePath(run); + if (codePathToUse != Complex) { // If the complex text implementation cannot return fallback fonts, avoid // returning them for simple text as well. static bool returnFallbackFonts = canReturnFallbackFontsForComplexText(); - return floatWidthForSimpleText(run, 0, returnFallbackFonts ? fallbackFonts : 0); + return floatWidthForSimpleText(run, 0, returnFallbackFonts ? fallbackFonts : 0, codePathToUse == SimpleWithGlyphOverflow ? glyphOverflow : 0); } -#endif - return floatWidthForComplexText(run, fallbackFonts); + return floatWidthForComplexText(run, fallbackFonts, glyphOverflow); } float Font::floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const @@ -213,10 +208,8 @@ float Font::floatWidth(const TextRun& run, int extraCharsAvailable, int& charsCo charsConsumed = run.length(); glyphName = ""; -#if USE(FONT_FAST_PATH) - if (canUseGlyphCache(run)) + if (codePath(run) != Complex) return floatWidthForSimpleText(run, 0); -#endif return floatWidthForComplexText(run); } @@ -230,10 +223,8 @@ FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& point, to = (to == -1 ? run.length() : to); -#if USE(FONT_FAST_PATH) - if (canUseGlyphCache(run)) + if (codePath(run) != Complex) return selectionRectForSimpleText(run, point, h, from, to); -#endif return selectionRectForComplexText(run, point, h, from, to); } @@ -245,10 +236,8 @@ int Font::offsetForPosition(const TextRun& run, int x, bool includePartialGlyphs return offsetForPositionForTextUsingSVGFont(run, x, includePartialGlyphs); #endif -#if USE(FONT_FAST_PATH) - if (canUseGlyphCache(run)) + if (codePath(run) != Complex) return offsetForPositionForSimpleText(run, x, includePartialGlyphs); -#endif return offsetForPositionForComplexText(run, x, includePartialGlyphs); } @@ -295,4 +284,79 @@ bool Font::shouldUseSmoothing() return shouldUseFontSmoothing; } +void Font::setCodePath(CodePath p) +{ + s_codePath = p; +} + +Font::CodePath Font::codePath() +{ + return s_codePath; +} + +Font::CodePath Font::codePath(const TextRun& run) const +{ + if (s_codePath != Auto) + return s_codePath; + +#if PLATFORM(QT) + if (run.padding() || run.rtl() || isSmallCaps() || wordSpacing() || letterSpacing()) + return Complex; +#endif + + // Start from 0 since drawing and highlighting also measure the characters before run->from + for (int i = 0; i < run.length(); i++) { + const UChar c = run[i]; + if (c < 0x300) // U+0300 through U+036F Combining diacritical marks + continue; + if (c <= 0x36F) + return Complex; + + if (c < 0x0591 || c == 0x05BE) // U+0591 through U+05CF excluding U+05BE Hebrew combining marks, Hebrew punctuation Paseq, Sof Pasuq and Nun Hafukha + continue; + if (c <= 0x05CF) + return Complex; + + if (c < 0x0600) // U+0600 through U+1059 Arabic, Syriac, Thaana, Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Sinhala, Thai, Lao, Tibetan, Myanmar + continue; + if (c <= 0x1059) + return Complex; + + if (c < 0x1100) // U+1100 through U+11FF Hangul Jamo (only Ancient Korean should be left here if you precompose; Modern Korean will be precomposed as a result of step A) + continue; + if (c <= 0x11FF) + return Complex; + + if (c < 0x1780) // U+1780 through U+18AF Khmer, Mongolian + continue; + if (c <= 0x18AF) + return Complex; + + if (c < 0x1900) // U+1900 through U+194F Limbu (Unicode 4.0) + continue; + if (c <= 0x194F) + return Complex; + + if (c < 0x1E00) // U+1E00 through U+2000 characters with diacritics and stacked diacritics + continue; + if (c <= 0x2000) + return SimpleWithGlyphOverflow; + + if (c < 0x20D0) // U+20D0 through U+20FF Combining marks for symbols + continue; + if (c <= 0x20FF) + return Complex; + + if (c < 0xFE20) // U+FE20 through U+FE2F Combining half marks + continue; + if (c <= 0xFE2F) + return Complex; + } + + if (typesettingFeatures()) + return Complex; + + return Simple; +} + } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/Font.h b/src/3rdparty/webkit/WebCore/platform/graphics/Font.h index 3c07be7..772ad93 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/Font.h +++ b/src/3rdparty/webkit/WebCore/platform/graphics/Font.h @@ -56,6 +56,21 @@ struct GlyphData; const unsigned defaultUnitsPerEm = 1000; +struct GlyphOverflow { + GlyphOverflow() + : left(0) + , right(0) + , top(0) + , bottom(0) + { + } + + int left; + int right; + int top; + int bottom; +}; + class Font { public: Font(); @@ -81,8 +96,8 @@ public: void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const; - int width(const TextRun& run, HashSet* fallbackFonts = 0) const { return lroundf(floatWidth(run, fallbackFonts)); } - float floatWidth(const TextRun&, HashSet* fallbackFonts = 0) const; + int width(const TextRun& run, HashSet* fallbackFonts = 0, GlyphOverflow* glyphOverflow = 0) const { return lroundf(floatWidth(run, fallbackFonts, glyphOverflow)); } + float floatWidth(const TextRun&, HashSet* fallbackFonts = 0, GlyphOverflow* glyphOverflow = 0) const; float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const; @@ -137,6 +152,8 @@ public: static void setShouldUseSmoothing(bool); static bool shouldUseSmoothing(); + enum CodePath { Auto, Simple, Complex, SimpleWithGlyphOverflow }; + private: #if ENABLE(SVG_FONTS) void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; @@ -146,20 +163,18 @@ private: int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const; #endif -#if USE(FONT_FAST_PATH) - bool canUseGlyphCache(const TextRun&) const; void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const; void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FloatPoint&) const; - float floatWidthForSimpleText(const TextRun&, GlyphBuffer*, HashSet* fallbackFonts = 0) const; + float floatWidthForSimpleText(const TextRun&, GlyphBuffer*, HashSet* fallbackFonts = 0, GlyphOverflow* = 0) const; int offsetForPositionForSimpleText(const TextRun&, int position, bool includePartialGlyphs) const; FloatRect selectionRectForSimpleText(const TextRun&, const IntPoint&, int h, int from, int to) const; static bool canReturnFallbackFontsForComplexText(); -#endif + CodePath codePath(const TextRun&) const; void drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; - float floatWidthForComplexText(const TextRun&, HashSet* fallbackFonts = 0) const; + float floatWidthForComplexText(const TextRun&, HashSet* fallbackFonts = 0, GlyphOverflow* = 0) const; int offsetForPositionForComplexText(const TextRun&, int position, bool includePartialGlyphs) const; FloatRect selectionRectForComplexText(const TextRun&, const IntPoint&, int h, int from, int to) const; @@ -167,8 +182,6 @@ private: public: // Useful for debugging the different font rendering code paths. -#if USE(FONT_FAST_PATH) - enum CodePath { Auto, Simple, Complex }; static void setCodePath(CodePath); static CodePath codePath(); static CodePath s_codePath; @@ -178,7 +191,6 @@ public: { return (((c & ~0xFF) == 0 && gRoundingHackCharacterTable[c])); } -#endif FontSelector* fontSelector() const; static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == 0x00A0; } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/FontFastPath.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/FontFastPath.cpp index 428e85e..b863e83 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/FontFastPath.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/FontFastPath.cpp @@ -24,17 +24,17 @@ #include "Font.h" #include "CharacterNames.h" +#include "FloatRect.h" #include "FontCache.h" #include "FontFallbackList.h" -#include "FloatRect.h" #include "GlyphBuffer.h" #include "GlyphPageTreeNode.h" #include "IntPoint.h" #include "SimpleFontData.h" #include "WidthIterator.h" -#include #include +#include using namespace WTF; using namespace Unicode; @@ -180,78 +180,6 @@ GlyphData Font::glyphDataForCharacter(UChar32 c, bool mirror, bool forceSmallCap return data; } -void Font::setCodePath(CodePath p) -{ - s_codePath = p; -} - -Font::CodePath Font::codePath() -{ - return s_codePath; -} - -bool Font::canUseGlyphCache(const TextRun& run) const -{ - switch (s_codePath) { - case Auto: - break; - case Simple: - return true; - case Complex: - return false; - } - - // Start from 0 since drawing and highlighting also measure the characters before run->from - for (int i = 0; i < run.length(); i++) { - const UChar c = run[i]; - if (c < 0x300) // U+0300 through U+036F Combining diacritical marks - continue; - if (c <= 0x36F) - return false; - - if (c < 0x0591 || c == 0x05BE) // U+0591 through U+05CF excluding U+05BE Hebrew combining marks, Hebrew punctuation Paseq, Sof Pasuq and Nun Hafukha - continue; - if (c <= 0x05CF) - return false; - - if (c < 0x0600) // U+0600 through U+1059 Arabic, Syriac, Thaana, Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Sinhala, Thai, Lao, Tibetan, Myanmar - continue; - if (c <= 0x1059) - return false; - - if (c < 0x1100) // U+1100 through U+11FF Hangul Jamo (only Ancient Korean should be left here if you precompose; Modern Korean will be precomposed as a result of step A) - continue; - if (c <= 0x11FF) - return false; - - if (c < 0x1780) // U+1780 through U+18AF Khmer, Mongolian - continue; - if (c <= 0x18AF) - return false; - - if (c < 0x1900) // U+1900 through U+194F Limbu (Unicode 4.0) - continue; - if (c <= 0x194F) - return false; - - if (c < 0x20D0) // U+20D0 through U+20FF Combining marks for symbols - continue; - if (c <= 0x20FF) - return false; - - if (c < 0xFE20) // U+FE20 through U+FE2F Combining half marks - continue; - if (c <= 0xFE2F) - return false; - } - - if (typesettingFeatures()) - return false; - - return true; - -} - void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const { // This glyph buffer holds our glyphs+advances+font data for each glyph. @@ -314,10 +242,18 @@ void Font::drawGlyphBuffer(GraphicsContext* context, const GlyphBuffer& glyphBuf drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); } -float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer, HashSet* fallbackFonts) const +float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer, HashSet* fallbackFonts, GlyphOverflow* glyphOverflow) const { - WidthIterator it(this, run, fallbackFonts); + WidthIterator it(this, run, fallbackFonts, glyphOverflow); it.advance(run.length(), glyphBuffer); + + if (glyphOverflow) { + glyphOverflow->top = max(glyphOverflow->top, ceilf(-it.minGlyphBoundingBoxY()) - ascent()); + glyphOverflow->bottom = max(glyphOverflow->bottom, ceilf(it.maxGlyphBoundingBoxY()) - descent()); + glyphOverflow->left = ceilf(it.firstGlyphOverflow()); + glyphOverflow->right = ceilf(it.lastGlyphOverflow()); + } + return it.m_runWidthSoFar; } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.cpp new file mode 100644 index 0000000..d3c3180 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "GlyphMetricsMap.h" + +namespace WebCore { + +GlyphMetricsMap::GlyphMetricsPage* GlyphMetricsMap::locatePageSlowCase(unsigned pageNumber) +{ + GlyphMetricsPage* page; + if (!pageNumber) { + ASSERT(!m_filledPrimaryPage); + page = &m_primaryPage; + m_filledPrimaryPage = true; + } else { + if (m_pages) { + if ((page = m_pages->get(pageNumber))) + return page; + } else + m_pages.set(new HashMap); + page = new GlyphMetricsPage; + m_pages->set(pageNumber, page); + } + + GlyphMetrics unknownMetrics; + unknownMetrics.horizontalAdvance = cGlyphSizeUnknown; + unknownMetrics.boundingBox.setWidth(cGlyphSizeUnknown); + unknownMetrics.boundingBox.setHeight(cGlyphSizeUnknown); + // Fill in the whole page with the unknown glyph information. + for (unsigned i = 0; i < GlyphMetricsPage::size; i++) + page->setMetricsForIndex(i, unknownMetrics); + + return page; +} + +} diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.h b/src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.h new file mode 100644 index 0000000..49854be --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GlyphMetricsMap_h +#define GlyphMetricsMap_h + +#include "FloatRect.h" +#include +#include +#include + +namespace WebCore { + +typedef unsigned short Glyph; + +const float cGlyphSizeUnknown = -1; + +struct GlyphMetrics { + float horizontalAdvance; + FloatRect boundingBox; +}; + +class GlyphMetricsMap : public Noncopyable { +public: + GlyphMetricsMap() : m_filledPrimaryPage(false) { } + ~GlyphMetricsMap() + { + if (m_pages) + deleteAllValues(*m_pages); + } + + GlyphMetrics metricsForGlyph(Glyph glyph) + { + return locatePage(glyph / GlyphMetricsPage::size)->metricsForGlyph(glyph); + } + + float widthForGlyph(Glyph glyph) + { + return locatePage(glyph / GlyphMetricsPage::size)->metricsForGlyph(glyph).horizontalAdvance; + } + + void setMetricsForGlyph(Glyph glyph, const GlyphMetrics& metrics) + { + locatePage(glyph / GlyphMetricsPage::size)->setMetricsForGlyph(glyph, metrics); + } + +private: + struct GlyphMetricsPage { + static const size_t size = 256; // Usually covers Latin-1 in a single page. + GlyphMetrics m_metrics[size]; + + GlyphMetrics metricsForGlyph(Glyph glyph) const { return m_metrics[glyph % size]; } + void setMetricsForGlyph(Glyph glyph, const GlyphMetrics& metrics) + { + setMetricsForIndex(glyph % size, metrics); + } + void setMetricsForIndex(unsigned index, const GlyphMetrics& metrics) + { + m_metrics[index] = metrics; + } + }; + + GlyphMetricsPage* locatePage(unsigned pageNumber) + { + if (!pageNumber && m_filledPrimaryPage) + return &m_primaryPage; + return locatePageSlowCase(pageNumber); + } + + GlyphMetricsPage* locatePageSlowCase(unsigned pageNumber); + + bool m_filledPrimaryPage; + GlyphMetricsPage m_primaryPage; // We optimize for the page that contains glyph indices 0-255. + OwnPtr > m_pages; +}; + +} // namespace WebCore + +#endif diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.cpp deleted file mode 100644 index 43cab65..0000000 --- a/src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "GlyphWidthMap.h" - -namespace WebCore { - -GlyphWidthMap::GlyphWidthPage* GlyphWidthMap::locatePageSlowCase(unsigned pageNumber) -{ - GlyphWidthPage* page; - if (pageNumber == 0) { - ASSERT(!m_filledPrimaryPage); - page = &m_primaryPage; - m_filledPrimaryPage = true; - } else { - if (m_pages) { - if ((page = m_pages->get(pageNumber))) - return page; - } else - m_pages.set(new HashMap); - page = new GlyphWidthPage; - m_pages->set(pageNumber, page); - } - - // Fill in the whole page with the unknown glyph width value. - for (unsigned i = 0; i < GlyphWidthPage::size; i++) - page->setWidthForIndex(i, cGlyphWidthUnknown); - - return page; -} - -} diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.h b/src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.h deleted file mode 100644 index 66dea1f..0000000 --- a/src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GlyphWidthMap_h -#define GlyphWidthMap_h - -#include -#include -#include - -namespace WebCore { - -typedef unsigned short Glyph; - -const float cGlyphWidthUnknown = -1; - -class GlyphWidthMap : public Noncopyable { -public: - GlyphWidthMap() : m_filledPrimaryPage(false) { } - ~GlyphWidthMap() { if (m_pages) { deleteAllValues(*m_pages); } } - - float widthForGlyph(Glyph glyph) - { - return locatePage(glyph / GlyphWidthPage::size)->widthForGlyph(glyph); - } - - void setWidthForGlyph(Glyph glyph, float width) - { - locatePage(glyph / GlyphWidthPage::size)->setWidthForGlyph(glyph, width); - } - -private: - struct GlyphWidthPage { - static const size_t size = 256; // Usually covers Latin-1 in a single page. - float m_widths[size]; - - float widthForGlyph(Glyph glyph) const { return m_widths[glyph % size]; } - void setWidthForGlyph(Glyph glyph, float width) - { - setWidthForIndex(glyph % size, width); - } - void setWidthForIndex(unsigned index, float width) - { - m_widths[index] = width; - } - }; - - GlyphWidthPage* locatePage(unsigned pageNumber) - { - if (!pageNumber && m_filledPrimaryPage) - return &m_primaryPage; - return locatePageSlowCase(pageNumber); - } - - GlyphWidthPage* locatePageSlowCase(unsigned pageNumber); - - bool m_filledPrimaryPage; - GlyphWidthPage m_primaryPage; // We optimize for the page that contains glyph indices 0-255. - OwnPtr > m_pages; -}; - -} - -#endif diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.cpp index 2ec8abb..04b6ab1 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.cpp @@ -157,9 +157,11 @@ void SimpleFontData::platformGlyphInit() // are mapped to the ZERO WIDTH SPACE glyph. Glyph zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph; if (zeroWidthSpaceGlyph) { - if (zeroWidthSpaceGlyph != m_spaceGlyph) - m_glyphToWidthMap.setWidthForGlyph(zeroWidthSpaceGlyph, 0); - else + if (zeroWidthSpaceGlyph != m_spaceGlyph) { + GlyphMetrics metrics; + metrics.horizontalAdvance = 0; + m_glyphToMetricsMap.setMetricsForGlyph(zeroWidthSpaceGlyph, metrics); + } else LOG_ERROR("Font maps SPACE and ZERO WIDTH SPACE to the same glyph. Glyph width not overridden."); } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.h b/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.h index 0366e3b..efdbba4 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.h +++ b/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.h @@ -26,8 +26,8 @@ #include "FontData.h" #include "FontPlatformData.h" +#include "GlyphMetricsMap.h" #include "GlyphPageTreeNode.h" -#include "GlyphWidthMap.h" #include "TypesettingFeatures.h" #include @@ -58,9 +58,9 @@ class FontDescription; class FontPlatformData; class SharedBuffer; class SVGFontData; -class WidthMap; enum Pitch { UnknownPitch, FixedPitch, VariablePitch }; +enum GlyphMetricsMode { GlyphBoundingBox, GlyphWidthOnly }; class SimpleFontData : public FontData { public: @@ -81,8 +81,9 @@ public: float xHeight() const { return m_xHeight; } unsigned unitsPerEm() const { return m_unitsPerEm; } - float widthForGlyph(Glyph) const; - float platformWidthForGlyph(Glyph) const; + float widthForGlyph(Glyph glyph) const { return metricsForGlyph(glyph, GlyphWidthOnly).horizontalAdvance; } + GlyphMetrics metricsForGlyph(Glyph, GlyphMetricsMode = GlyphBoundingBox) const; + GlyphMetrics platformMetricsForGlyph(Glyph, GlyphMetricsMode) const; float spaceWidth() const { return m_spaceWidth; } float adjustedSpaceWidth() const { return m_adjustedSpaceWidth; } @@ -167,7 +168,7 @@ private: || (OS(WINDOWS) && PLATFORM(WX)) void initGDIFont(); void platformCommonDestroy(); - float widthForGDIGlyph(Glyph glyph) const; + GlyphMetrics metricsForGDIGlyph(Glyph glyph) const; #endif int m_ascent; @@ -181,7 +182,7 @@ private: FontPlatformData m_platformData; - mutable GlyphWidthMap m_glyphToWidthMap; + mutable GlyphMetricsMap m_glyphToMetricsMap; bool m_treatAsFixedPitch; @@ -237,16 +238,16 @@ private: #if !PLATFORM(QT) -ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const +ALWAYS_INLINE GlyphMetrics SimpleFontData::metricsForGlyph(Glyph glyph, GlyphMetricsMode metricsMode) const { - float width = m_glyphToWidthMap.widthForGlyph(glyph); - if (width != cGlyphWidthUnknown) - return width; - - width = platformWidthForGlyph(glyph); - m_glyphToWidthMap.setWidthForGlyph(glyph, width); - - return width; + GlyphMetrics metrics = m_glyphToMetricsMap.metricsForGlyph(glyph); + if ((metricsMode == GlyphWidthOnly && metrics.horizontalAdvance != cGlyphSizeUnknown) || (metricsMode == GlyphBoundingBox && metrics.boundingBox.width() != cGlyphSizeUnknown)) + return metrics; + + metrics = platformMetricsForGlyph(glyph, metricsMode); + m_glyphToMetricsMap.setMetricsForGlyph(glyph, metrics); + + return metrics; } #endif diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.cpp index 9157310..996ce40 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.cpp @@ -33,13 +33,14 @@ using namespace WTF; using namespace Unicode; +using namespace std; namespace WebCore { // According to http://www.unicode.org/Public/UNIDATA/UCD.html#Canonical_Combining_Class_Values static const uint8_t hiraganaKatakanaVoicingMarksCombiningClass = 8; -WidthIterator::WidthIterator(const Font* font, const TextRun& run, HashSet* fallbackFonts) +WidthIterator::WidthIterator(const Font* font, const TextRun& run, HashSet* fallbackFonts, bool accountForGlyphBounds) : m_font(font) , m_run(run) , m_end(run.length()) @@ -47,6 +48,11 @@ WidthIterator::WidthIterator(const Font* font, const TextRun& run, HashSet::min()) + , m_minGlyphBoundingBoxY(numeric_limits::max()) + , m_firstGlyphOverflow(0) + , m_lastGlyphOverflow(0) { // If the padding is non-zero, count the number of spaces in the run // and divide that by the padding for per space addition. @@ -79,6 +85,7 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) float runWidthSoFar = m_runWidthSoFar; float lastRoundingWidth = m_finalRoundingWidth; + FloatRect bounds; const SimpleFontData* primaryFont = m_font->primaryFont(); const SimpleFontData* lastFontData = primaryFont; @@ -175,6 +182,12 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) } } + if (m_accountForGlyphBounds) { + bounds = fontData->boundsForGlyph(glyph); + if (!currentCharacter) + m_firstGlyphOverflow = max(0, -bounds.x()); + } + // Advance past the character we just dealt with. cp += clusterLength; currentCharacter += clusterLength; @@ -205,6 +218,12 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) glyphBuffer->add(glyph, fontData, (rtl ? oldWidth + lastRoundingWidth : width)); lastRoundingWidth = width - oldWidth; + + if (m_accountForGlyphBounds) { + m_maxGlyphBoundingBoxY = max(m_maxGlyphBoundingBoxY, bounds.bottom()); + m_minGlyphBoundingBoxY = min(m_minGlyphBoundingBoxY, bounds.y()); + m_lastGlyphOverflow = max(0, bounds.right() - width); + } } m_currentCharacter = currentCharacter; diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.h b/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.h index 7ca4198..d42a0c5 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.h +++ b/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.h @@ -33,11 +33,16 @@ class SimpleFontData; class TextRun; struct WidthIterator { - WidthIterator(const Font*, const TextRun&, HashSet* fallbackFonts = 0); + WidthIterator(const Font*, const TextRun&, HashSet* fallbackFonts = 0, bool accountForGlyphBounds = false); void advance(int to, GlyphBuffer* = 0); bool advanceOneCharacter(float& width, GlyphBuffer* = 0); + float maxGlyphBoundingBoxY() const { ASSERT(m_accountForGlyphBounds); return m_maxGlyphBoundingBoxY; } + float minGlyphBoundingBoxY() const { ASSERT(m_accountForGlyphBounds); return m_minGlyphBoundingBoxY; } + float firstGlyphOverflow() const { ASSERT(m_accountForGlyphBounds); return m_firstGlyphOverflow; } + float lastGlyphOverflow() const { ASSERT(m_accountForGlyphBounds); return m_lastGlyphOverflow; } + const Font* m_font; const TextRun& m_run; @@ -51,7 +56,13 @@ struct WidthIterator { private: UChar32 normalizeVoicingMarks(int currentCharacter); + HashSet* m_fallbackFonts; + bool m_accountForGlyphBounds; + float m_maxGlyphBoundingBoxY; + float m_minGlyphBoundingBoxY; + float m_firstGlyphOverflow; + float m_lastGlyphOverflow; }; } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp index d75f156..06885ba 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp @@ -44,11 +44,15 @@ namespace WebCore { -static const QString fromRawDataWithoutRef(const String& string) +static const QString fromRawDataWithoutRef(const String& string, int start = 0, int len = -1) { + if (len < 0) + len = string.length() - start; + Q_ASSERT(start + len <= string.length()); + // We don't detach. This assumes the WebCore string data will stay valid for the // lifetime of the QString we pass back, since we don't ref the WebCore string. - return QString::fromRawData(reinterpret_cast(string.characters()), string.length()); + return QString::fromRawData(reinterpret_cast(string.characters() + start), len); } static QTextLine setupLayout(QTextLayout* layout, const TextRun& style) @@ -66,7 +70,7 @@ static QTextLine setupLayout(QTextLayout* layout, const TextRun& style) return line; } -void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const +static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to, const QFont& font, bool isComplexText) { if (to < 0) to = run.length(); @@ -102,6 +106,7 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float String sanitized = Font::normalizeSpaces(String(run.characters(), run.length())); QString string = fromRawDataWithoutRef(sanitized); + QPointF pt(point.x(), point.y()); // text shadow IntSize shadowSize; @@ -110,52 +115,63 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float bool hasShadow = ctx->textDrawingMode() == cTextFill && ctx->getShadow(shadowSize, shadowBlur, shadowColor); if (from > 0 || to < run.length()) { - QTextLayout layout(string, font()); - QTextLine line = setupLayout(&layout, run); - float x1 = line.cursorToX(from); - float x2 = line.cursorToX(to); - if (x2 < x1) - qSwap(x1, x2); - - QFontMetrics fm(font()); - int ascent = fm.ascent(); - QRectF clip(point.x() + x1, point.y() - ascent, x2 - x1, fm.height()); - - if (hasShadow) { - // TODO: when blur support is added, the clip will need to account - // for the blur radius - qreal dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; - if (shadowSize.width() > 0) - dx2 = shadowSize.width(); - else - dx1 = -shadowSize.width(); - if (shadowSize.height() > 0) - dy2 = shadowSize.height(); - else - dy1 = -shadowSize.height(); - // expand the clip rect to include the text shadow as well - clip.adjust(dx1, dx2, dy1, dy2); - } - p->save(); - p->setClipRect(clip.toRect(), Qt::IntersectClip); - QPointF pt(point.x(), point.y() - ascent); - if (hasShadow) { + if (isComplexText) { + QTextLayout layout(string, font); + QTextLine line = setupLayout(&layout, run); + float x1 = line.cursorToX(from); + float x2 = line.cursorToX(to); + if (x2 < x1) + qSwap(x1, x2); + + QFontMetrics fm(font); + int ascent = fm.ascent(); + QRectF clip(point.x() + x1, point.y() - ascent, x2 - x1, fm.height()); + + if (hasShadow) { + // TODO: when blur support is added, the clip will need to account + // for the blur radius + qreal dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; + if (shadowSize.width() > 0) + dx2 = shadowSize.width(); + else + dx1 = -shadowSize.width(); + if (shadowSize.height() > 0) + dy2 = shadowSize.height(); + else + dy1 = -shadowSize.height(); + // expand the clip rect to include the text shadow as well + clip.adjust(dx1, dx2, dy1, dy2); + } p->save(); - p->setPen(QColor(shadowColor)); - p->translate(shadowSize.width(), shadowSize.height()); + p->setClipRect(clip.toRect(), Qt::IntersectClip); + pt.setY(pt.y() - ascent); + if (hasShadow) { + p->save(); + p->setPen(QColor(shadowColor)); + p->translate(shadowSize.width(), shadowSize.height()); + line.draw(p, pt); + p->restore(); + } + p->setPen(textFillPen); line.draw(p, pt); p->restore(); + return; } - p->setPen(textFillPen); - line.draw(p, pt); - p->restore(); - return; +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + int skipWidth = QFontMetrics(font).width(string, from, Qt::TextBypassShaping); + pt.setX(pt.x() + skipWidth); + string = fromRawDataWithoutRef(sanitized, from, to - from); +#endif } - p->setFont(font()); + p->setFont(font); - QPointF pt(point.x(), point.y()); int flags = run.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight; +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + // See QWebPagePrivate::QWebPagePrivate() where the default path is set to Complex for Qt 4.6 and earlier. + if (!isComplexText) + flags |= Qt::TextBypassShaping; +#endif if (hasShadow) { // TODO: text shadow blur support p->save(); @@ -166,7 +182,7 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float } if (ctx->textDrawingMode() & cTextStroke) { QPainterPath path; - path.addText(pt, font(), string); + path.addText(pt, font, string); p->setPen(textStrokePen); p->strokePath(path, p->pen()); } @@ -176,7 +192,43 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float } } -float Font::floatWidthForComplexText(const TextRun& run, HashSet*) const +void Font::drawSimpleText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const +{ +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + drawTextCommon(ctx, run, point, from, to, font(), /* isComplexText = */false); +#else + Q_ASSERT(false); +#endif +} + +void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const +{ + drawTextCommon(ctx, run, point, from, to, font(), /* isComplexText = */true); +} + +float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer, HashSet* fallbackFonts, GlyphOverflow* glyphOverflow) const +{ +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + if (!run.length()) + return 0; + + String sanitized = Font::normalizeSpaces(String(run.characters(), run.length())); + QString string = fromRawDataWithoutRef(sanitized); + + int w = QFontMetrics(font()).width(string, -1, Qt::TextBypassShaping); + + // WebKit expects us to ignore word spacing on the first character (as opposed to what Qt does) + if (treatAsSpace(run[0])) + w -= m_wordSpacing; + + return w + run.padding(); +#else + Q_ASSERT(false); + return 0.0f; +#endif +} + +float Font::floatWidthForComplexText(const TextRun& run, HashSet*, GlyphOverflow*) const { if (!run.length()) return 0; @@ -195,6 +247,34 @@ float Font::floatWidthForComplexText(const TextRun& run, HashSet= QT_VERSION_CHECK(4, 7, 0) + String sanitized = Font::normalizeSpaces(String(run.characters(), run.length())); + QString string = fromRawDataWithoutRef(sanitized); + + QFontMetrics fm(font()); + float delta = (float)position; + int curPos = 0; + do { + float charWidth = fm.width(string[curPos]); + delta -= charWidth; + if (includePartialGlyphs) { + if (delta + charWidth / 2 <= 0) + break; + } else { + if (delta + charWidth <= 0) + break; + } + } while (++curPos < string.size()); + + return curPos; +#else + Q_ASSERT(false); + return 0; +#endif +} + int Font::offsetForPositionForComplexText(const TextRun& run, int position, bool) const { String sanitized = Font::normalizeSpaces(String(run.characters(), run.length())); @@ -205,6 +285,23 @@ int Font::offsetForPositionForComplexText(const TextRun& run, int position, bool return line.xToCursor(position); } +FloatRect Font::selectionRectForSimpleText(const TextRun& run, const IntPoint& pt, int h, int from, int to) const +{ +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + String sanitized = Font::normalizeSpaces(String(run.characters(), run.length())); + QString wholeText = fromRawDataWithoutRef(sanitized); + QString selectedText = fromRawDataWithoutRef(sanitized, from, to - from); + + int startX = QFontMetrics(font()).width(wholeText, from, Qt::TextBypassShaping); + int width = QFontMetrics(font()).width(selectedText, -1, Qt::TextBypassShaping); + + return FloatRect(pt.x() + startX, pt.y(), width, h); +#else + Q_ASSERT(false); + return FloatRect(); +#endif +} + FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& pt, int h, int from, int to) const { String sanitized = Font::normalizeSpaces(String(run.characters(), run.length())); @@ -221,6 +318,11 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& return FloatRect(pt.x() + x1, pt.y(), x2 - x1, h); } +bool Font::canReturnFallbackFontsForComplexText() +{ + return false; +} + QFont Font::font() const { QFont f = primaryFont()->getQtFont(); diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp index cc707da..fb3d621 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp @@ -78,9 +78,6 @@ void ImageDecoderQt::setData(SharedBuffer* data, bool allDataReceived) m_buffer->open(QIODevice::ReadOnly | QIODevice::Unbuffered); m_reader.set(new QImageReader(m_buffer.get(), m_format)); - // This will force the JPEG decoder to use JDCT_IFAST - m_reader->setQuality(49); - // QImageReader only allows retrieving the format before reading the image m_format = m_reader->format(); } @@ -188,9 +185,21 @@ void ImageDecoderQt::internalReadImage(size_t frameIndex) bool ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex) { - // Now get the QImage from Qt and place it in the RGBA32Buffer - QImage img; - if (!m_reader->read(&img)) { + QPixmap pixmap; + bool pixmapLoaded; + const int imageCount = m_reader->imageCount(); + if (imageCount == 0 || imageCount == 1) + pixmapLoaded = pixmap.loadFromData((const uchar*)(m_data->data()), m_data->size(), m_format); + else { + QImage img; + const bool imageLoaded = m_reader->read(&img); + if (imageLoaded) { + pixmap = QPixmap::fromImage(img); + pixmapLoaded = true; + } + } + + if (!pixmapLoaded) { frameCount(); repetitionCount(); clearPointers(); @@ -198,12 +207,11 @@ bool ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex) } // now into the RGBA32Buffer - even if the image is not - QSize imageSize = img.size(); RGBA32Buffer* const buffer = &m_frameBufferCache[frameIndex]; buffer->setRect(m_reader->currentImageRect()); buffer->setStatus(RGBA32Buffer::FrameComplete); buffer->setDuration(m_reader->nextImageDelay()); - buffer->setDecodedImage(img); + buffer->setPixmap(pixmap); return true; } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/win/FontWin.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/win/FontWin.cpp index 27d8dee..717171f 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/win/FontWin.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/win/FontWin.cpp @@ -34,6 +34,8 @@ #include "UniscribeController.h" #include +using namespace std; + namespace WebCore { bool Font::canReturnFallbackFontsForComplexText() @@ -89,10 +91,16 @@ void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const F drawGlyphBuffer(context, glyphBuffer, run, startPoint); } -float Font::floatWidthForComplexText(const TextRun& run, HashSet* fallbackFonts) const +float Font::floatWidthForComplexText(const TextRun& run, HashSet* fallbackFonts, GlyphOverflow* glyphOverflow) const { UniscribeController controller(this, run, fallbackFonts); controller.advance(run.length()); + if (glyphOverflow) { + glyphOverflow->top = max(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - ascent()); + glyphOverflow->bottom = max(glyphOverflow->bottom, ceilf(controller.maxGlyphBoundingBoxY()) - descent()); + glyphOverflow->left = max(0, ceilf(-controller.minGlyphBoundingBoxX())); + glyphOverflow->right = max(0, ceilf(controller.maxGlyphBoundingBoxX() - controller.runWidthSoFar())); + } return controller.runWidthSoFar(); } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp index 6b3a96e..ee3a980 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp @@ -126,10 +126,10 @@ void SimpleFontData::platformCharWidthInit() } } -float SimpleFontData::platformWidthForGlyph(Glyph glyph) const +GlyphMetrics SimpleFontData::platformMetricsForGlyph(Glyph glyph, GlyphMetricsMode metricsMode) const { if (m_platformData.useGDI()) - return widthForGDIGlyph(glyph); + return metricsForGDIGlyph(glyph); CGFontRef font = m_platformData.cgFont(); float pointSize = m_platformData.size(); @@ -139,8 +139,18 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const // FIXME: Need to add real support for printer fonts. bool isPrinterFont = false; wkGetGlyphAdvances(font, m, m_isSystemFont, isPrinterFont, glyph, advance); - - return advance.width + m_syntheticBoldOffset; + GlyphMetrics metrics; + metrics.horizontalAdvance = advance.width + m_syntheticBoldOffset; + + if (metricsMode == GlyphBoundingBox) { + CGRect boundingBox; + CGFontGetGlyphBBoxes(font, &glyph, 1, &boundingBox); + CGFloat scale = pointSize / unitsPerEm(); + metrics.boundingBox = CGRectApplyAffineTransform(boundingBox, CGAffineTransformMakeScale(scale, -scale)); + if (m_syntheticBoldOffset) + metrics.boundingBox.setWidth(metrics.boundingBox.width() + m_syntheticBoldOffset); + } + return metrics; } } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataWin.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataWin.cpp index 5a3244c..f85f9ba 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataWin.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataWin.cpp @@ -179,16 +179,25 @@ void SimpleFontData::determinePitch() ReleaseDC(0, dc); } -float SimpleFontData::widthForGDIGlyph(Glyph glyph) const +GlyphMetrics SimpleFontData::metricsForGDIGlyph(Glyph glyph) const { HDC hdc = GetDC(0); SetGraphicsMode(hdc, GM_ADVANCED); HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont()); - int width; - GetCharWidthI(hdc, glyph, 1, 0, &width); + + GLYPHMETRICS gdiMetrics; + static const MAT2 identity = { 0, 1, 0, 0, 0, 0, 0, 1 }; + GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity); + SelectObject(hdc, oldFont); ReleaseDC(0, hdc); - return width + m_syntheticBoldOffset; + + GlyphMetrics glyphMetrics; + glyphMetrics.horizontalAdvance = gdiMetrics.gmCellIncX + m_syntheticBoldOffset; + glyphMetrics.boundingBox = FloatRect(gdiMetrics.gmptGlyphOrigin.x, -gdiMetrics.gmptGlyphOrigin.y, + gdiMetrics.gmBlackBoxX + m_syntheticBoldOffset, gdiMetrics.gmBlackBoxY); + + return glyphMetrics; } SCRIPT_FONTPROPERTIES* SimpleFontData::scriptFontProperties() const diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.cpp index f382857..cfa15a2 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.cpp @@ -32,6 +32,8 @@ #include "SimpleFontData.h" #include +using namespace std; + namespace WebCore { // FIXME: Rearchitect this to be more like WidthIterator in Font.cpp. Have an advance() method @@ -39,16 +41,20 @@ namespace WebCore { // take the GlyphBuffer as an arg so that we don't have to populate the glyph buffer when // measuring. UniscribeController::UniscribeController(const Font* font, const TextRun& run, HashSet* fallbackFonts) -: m_font(*font) -, m_run(run) -, m_fallbackFonts(fallbackFonts) -, m_end(run.length()) -, m_currentCharacter(0) -, m_runWidthSoFar(0) -, m_computingOffsetPosition(false) -, m_includePartialGlyphs(false) -, m_offsetX(0) -, m_offsetPosition(0) + : m_font(*font) + , m_run(run) + , m_fallbackFonts(fallbackFonts) + , m_minGlyphBoundingBoxX(numeric_limits::max()) + , m_maxGlyphBoundingBoxX(numeric_limits::min()) + , m_minGlyphBoundingBoxY(numeric_limits::max()) + , m_maxGlyphBoundingBoxY(numeric_limits::min()) + , m_end(run.length()) + , m_currentCharacter(0) + , m_runWidthSoFar(0) + , m_computingOffsetPosition(false) + , m_includePartialGlyphs(false) + , m_offsetX(0) + , m_offsetPosition(0) { m_padding = m_run.padding(); if (!m_padding) @@ -374,6 +380,14 @@ bool UniscribeController::shapeAndPlaceItem(const UChar* cp, unsigned i, const S glyphBuffer->add(glyph, fontData, advance, &size); } + GlyphMetrics glyphMetrics = fontData->metricsForGlyph(glyph); + glyphMetrics.boundingBox.move(m_glyphOrigin.x(), m_glyphOrigin.y()); + m_minGlyphBoundingBoxX = min(m_minGlyphBoundingBoxX, glyphMetrics.boundingBox.x()); + m_maxGlyphBoundingBoxX = max(m_maxGlyphBoundingBoxX, glyphMetrics.boundingBox.right()); + m_minGlyphBoundingBoxY = min(m_minGlyphBoundingBoxY, glyphMetrics.boundingBox.y()); + m_maxGlyphBoundingBoxY = max(m_maxGlyphBoundingBoxY, glyphMetrics.boundingBox.bottom()); + m_glyphOrigin.move(advance + offsetX, -offsetY); + // Mutate the glyph array to contain our altered advances. if (m_computingOffsetPosition) advances[k] = advance; diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.h b/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.h index 23b8108..09203b5 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.h +++ b/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.h @@ -49,6 +49,11 @@ public: // Returns the width of everything we've consumed so far. float runWidthSoFar() const { return m_runWidthSoFar; } + float minGlyphBoundingBoxX() const { return m_minGlyphBoundingBoxX; } + float maxGlyphBoundingBoxX() const { return m_maxGlyphBoundingBoxX; } + float minGlyphBoundingBoxY() const { return m_minGlyphBoundingBoxY; } + float maxGlyphBoundingBoxY() const { return m_maxGlyphBoundingBoxY; } + private: void resetControlAndState(); @@ -61,6 +66,11 @@ private: const Font& m_font; const TextRun& m_run; HashSet* m_fallbackFonts; + FloatPoint m_glyphOrigin; + float m_minGlyphBoundingBoxX; + float m_maxGlyphBoundingBoxX; + float m_minGlyphBoundingBoxY; + float m_maxGlyphBoundingBoxY; SCRIPT_CONTROL m_control; SCRIPT_STATE m_state; diff --git a/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h b/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h index d526e5e..1074753 100644 --- a/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h +++ b/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h @@ -40,6 +40,7 @@ #if PLATFORM(SKIA) #include "NativeImageSkia.h" #elif PLATFORM(QT) +#include #include #endif @@ -130,8 +131,7 @@ namespace WebCore { } #if PLATFORM(QT) - void setDecodedImage(const QImage& image); - QImage decodedImage() const { return m_image; } + void setPixmap(const QPixmap& pixmap); #endif private: @@ -143,6 +143,8 @@ namespace WebCore { #if PLATFORM(SKIA) return m_bitmap.getAddr32(x, y); #elif PLATFORM(QT) + m_image = m_pixmap.toImage(); + m_pixmap = QPixmap(); return reinterpret_cast(m_image.scanLine(y)) + x; #else return m_bytes.data() + (y * width()) + x; @@ -168,6 +170,7 @@ namespace WebCore { #if PLATFORM(SKIA) NativeImageSkia m_bitmap; #elif PLATFORM(QT) + mutable QPixmap m_pixmap; mutable QImage m_image; bool m_hasAlpha; IntSize m_size; diff --git a/src/3rdparty/webkit/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp b/src/3rdparty/webkit/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp index b2e5e17..044515a 100644 --- a/src/3rdparty/webkit/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp @@ -57,6 +57,7 @@ RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other) void RGBA32Buffer::clear() { + m_pixmap = QPixmap(); m_image = QImage(); m_status = FrameEmpty; // NOTE: Do not reset other members here; clearFrameBufferCache() @@ -67,7 +68,11 @@ void RGBA32Buffer::clear() void RGBA32Buffer::zeroFill() { - m_image.fill(0); + if (m_pixmap.isNull() && !m_image.isNull()) { + m_pixmap = QPixmap(m_image.width(), m_image.height()); + m_image = QImage(); + } + m_pixmap.fill(QColor(0, 0, 0, 0)); } void RGBA32Buffer::copyBitmapData(const RGBA32Buffer& other) @@ -76,6 +81,7 @@ void RGBA32Buffer::copyBitmapData(const RGBA32Buffer& other) return; m_image = other.m_image; + m_pixmap = other.m_pixmap; m_size = other.m_size; m_hasAlpha = other.m_hasAlpha; } @@ -87,8 +93,9 @@ bool RGBA32Buffer::setSize(int newWidth, int newHeight) ASSERT(width() == 0 && height() == 0); m_size = IntSize(newWidth, newHeight); - m_image = QImage(newWidth, newHeight, QImage::Format_ARGB32_Premultiplied); - if (m_image.isNull()) + m_image = QImage(); + m_pixmap = QPixmap(newWidth, newHeight); + if (m_pixmap.isNull()) return false; // Zero the image. @@ -99,10 +106,11 @@ bool RGBA32Buffer::setSize(int newWidth, int newHeight) QPixmap* RGBA32Buffer::asNewNativeImage() const { - QPixmap pix = QPixmap::fromImage(m_image); - m_image = QImage(); - - return new QPixmap(pix); + if (m_pixmap.isNull() && !m_image.isNull()) { + m_pixmap = QPixmap::fromImage(m_image); + m_image = QImage(); + } + return new QPixmap(m_pixmap); } bool RGBA32Buffer::hasAlpha() const @@ -121,11 +129,12 @@ void RGBA32Buffer::setStatus(FrameStatus status) } // The image must not have format 8888 pre multiplied... -void RGBA32Buffer::setDecodedImage(const QImage& image) +void RGBA32Buffer::setPixmap(const QPixmap& pixmap) { - m_image = image; - m_size = image.size(); - m_hasAlpha = image.hasAlphaChannel(); + m_pixmap = pixmap; + m_image = QImage(); + m_size = pixmap.size(); + m_hasAlpha = pixmap.hasAlphaChannel(); } int RGBA32Buffer::width() const diff --git a/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp b/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp index 23dc4e7..f83ebc6 100644 --- a/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp @@ -288,8 +288,10 @@ int InlineFlowBox::placeBoxesHorizontally(int xPos, bool& needsWordSpacing) int letterSpacing = min(0, (int)rt->style(m_firstLine)->font().letterSpacing()); rightLayoutOverflow = max(xPos + text->width() - letterSpacing, rightLayoutOverflow); - int leftGlyphOverflow = -strokeOverflow; - int rightGlyphOverflow = strokeOverflow - letterSpacing; + GlyphOverflow* glyphOverflow = static_cast(curr)->glyphOverflow(); + + int leftGlyphOverflow = -strokeOverflow - (glyphOverflow ? glyphOverflow->left : 0); + int rightGlyphOverflow = strokeOverflow - letterSpacing + (glyphOverflow ? glyphOverflow->right : 0); int childOverflowLeft = leftGlyphOverflow; int childOverflowRight = rightGlyphOverflow; @@ -412,35 +414,35 @@ void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositi int lineHeight; int baseline; - Vector usedFonts; + Vector* usedFonts = 0; if (curr->isInlineTextBox()) - static_cast(curr)->takeFallbackFonts(usedFonts); + usedFonts = static_cast(curr)->fallbackFonts(); - if (!usedFonts.isEmpty()) { - usedFonts.append(curr->renderer()->style(m_firstLine)->font().primaryFont()); + if (usedFonts) { + usedFonts->append(curr->renderer()->style(m_firstLine)->font().primaryFont()); Length parentLineHeight = curr->renderer()->parent()->style()->lineHeight(); if (parentLineHeight.isNegative()) { int baselineToBottom = 0; baseline = 0; - for (size_t i = 0; i < usedFonts.size(); ++i) { - int halfLeading = (usedFonts[i]->lineSpacing() - usedFonts[i]->ascent() - usedFonts[i]->descent()) / 2; - baseline = max(baseline, halfLeading + usedFonts[i]->ascent()); - baselineToBottom = max(baselineToBottom, usedFonts[i]->lineSpacing() - usedFonts[i]->ascent() - usedFonts[i]->descent() - halfLeading); + for (size_t i = 0; i < usedFonts->size(); ++i) { + int halfLeading = (usedFonts->at(i)->lineSpacing() - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent()) / 2; + baseline = max(baseline, halfLeading + usedFonts->at(i)->ascent()); + baselineToBottom = max(baselineToBottom, usedFonts->at(i)->lineSpacing() - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent() - halfLeading); } lineHeight = baseline + baselineToBottom; } else if (parentLineHeight.isPercent()) { lineHeight = parentLineHeight.calcMinValue(curr->renderer()->style()->fontSize()); baseline = 0; - for (size_t i = 0; i < usedFonts.size(); ++i) { - int halfLeading = (lineHeight - usedFonts[i]->ascent() - usedFonts[i]->descent()) / 2; - baseline = max(baseline, halfLeading + usedFonts[i]->ascent()); + for (size_t i = 0; i < usedFonts->size(); ++i) { + int halfLeading = (lineHeight - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent()) / 2; + baseline = max(baseline, halfLeading + usedFonts->at(i)->ascent()); } } else { lineHeight = parentLineHeight.value(); baseline = 0; - for (size_t i = 0; i < usedFonts.size(); ++i) { - int halfLeading = (lineHeight - usedFonts[i]->ascent() - usedFonts[i]->descent()) / 2; - baseline = max(baseline, halfLeading + usedFonts[i]->ascent()); + for (size_t i = 0; i < usedFonts->size(); ++i) { + int halfLeading = (lineHeight - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent()) / 2; + baseline = max(baseline, halfLeading + usedFonts->at(i)->ascent()); } } } else { @@ -562,10 +564,12 @@ void InlineFlowBox::computeVerticalOverflow(int lineTop, int lineBottom, bool st continue; int strokeOverflow = static_cast(ceilf(rt->style()->textStrokeWidth() / 2.0f)); - - int topGlyphOverflow = -strokeOverflow; - int bottomGlyphOverflow = strokeOverflow; - + + GlyphOverflow* glyphOverflow = static_cast(curr)->glyphOverflow(); + + int topGlyphOverflow = -strokeOverflow - (glyphOverflow ? glyphOverflow->top : 0); + int bottomGlyphOverflow = strokeOverflow + (glyphOverflow ? glyphOverflow->bottom : 0); + int childOverflowTop = topGlyphOverflow; int childOverflowBottom = bottomGlyphOverflow; for (ShadowData* shadow = rt->style()->textShadow(); shadow; shadow = shadow->next) { diff --git a/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.cpp b/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.cpp index 9f17b0c..3c0d13b 100644 --- a/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.cpp @@ -1029,30 +1029,48 @@ bool InlineTextBox::containsCaretOffset(int offset) const return true; } -typedef HashMap > FallbackFontsMap; -static FallbackFontsMap* gFallbackFontsMap; - void InlineTextBox::setFallbackFonts(const HashSet& fallbackFonts) { - if (!gFallbackFontsMap) - gFallbackFontsMap = new FallbackFontsMap; + if (!s_glyphOverflowAndFallbackFontsMap) + s_glyphOverflowAndFallbackFontsMap = new GlyphOverflowAndFallbackFontsMap; - FallbackFontsMap::iterator it = gFallbackFontsMap->set(this, Vector()).first; - ASSERT(it->second.isEmpty()); - copyToVector(fallbackFonts, it->second); + GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->add(this, make_pair(Vector(), GlyphOverflow())).first; + ASSERT(it->second.first.isEmpty()); + copyToVector(fallbackFonts, it->second.first); } -void InlineTextBox::takeFallbackFonts(Vector& fallbackFonts) +Vector* InlineTextBox::fallbackFonts() const { - if (!gFallbackFontsMap) - return; + if (!s_glyphOverflowAndFallbackFontsMap) + return 0; - FallbackFontsMap::iterator it = gFallbackFontsMap->find(this); - if (it == gFallbackFontsMap->end()) - return; + GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->find(this); + if (it == s_glyphOverflowAndFallbackFontsMap->end()) + return 0; + + return &it->second.first; +} + +InlineTextBox::GlyphOverflowAndFallbackFontsMap* InlineTextBox::s_glyphOverflowAndFallbackFontsMap = 0; + +void InlineTextBox::setGlyphOverflow(const GlyphOverflow& glyphOverflow) +{ + if (!s_glyphOverflowAndFallbackFontsMap) + s_glyphOverflowAndFallbackFontsMap = new GlyphOverflowAndFallbackFontsMap; + + GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->add(this, make_pair(Vector(), GlyphOverflow())).first; + it->second.second = glyphOverflow; +} + +GlyphOverflow* InlineTextBox::glyphOverflow() const +{ + if (!s_glyphOverflowAndFallbackFontsMap) + return 0; + GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->find(this); + if (it == s_glyphOverflowAndFallbackFontsMap->end()) + return 0; - fallbackFonts.swap(it->second); - gFallbackFontsMap->remove(it); + return &it->second.second; } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.h b/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.h index 96ca4c3..7a4432e 100644 --- a/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.h +++ b/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.h @@ -64,7 +64,16 @@ public: void offsetRun(int d) { m_start += d; } void setFallbackFonts(const HashSet&); - void takeFallbackFonts(Vector&); + Vector* fallbackFonts() const; + + void setGlyphOverflow(const GlyphOverflow&); + GlyphOverflow* glyphOverflow() const; + + static void clearGlyphOverflowAndFallbackFontMap() + { + if (s_glyphOverflowAndFallbackFontsMap) + s_glyphOverflowAndFallbackFontsMap->clear(); + } unsigned short truncation() { return m_truncation; } @@ -129,6 +138,9 @@ private: unsigned short m_truncation; // Where to truncate when text overflow is applied. We use special constants to // denote no truncation (the whole run paints) and full truncation (nothing paints at all). + typedef HashMap, GlyphOverflow> > GlyphOverflowAndFallbackFontsMap; + static GlyphOverflowAndFallbackFontsMap* s_glyphOverflowAndFallbackFontsMap; + protected: void paintCompositionBackground(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&, int startPos, int endPos); void paintDocumentMarkers(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&, bool background); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBlockLineLayout.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderBlockLineLayout.cpp index 6e89060..9ef6a23 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderBlockLineLayout.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderBlockLineLayout.cpp @@ -342,7 +342,8 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool needsWordSpacing = !isSpaceOrNewline(rt->characters()[r->m_stop - 1]) && r->m_stop == length; } HashSet fallbackFonts; - r->m_box->setWidth(rt->width(r->m_start, r->m_stop - r->m_start, totWidth, firstLine, &fallbackFonts)); + GlyphOverflow glyphOverflow; + r->m_box->setWidth(rt->width(r->m_start, r->m_stop - r->m_start, totWidth, firstLine, &fallbackFonts, &glyphOverflow)); if (!fallbackFonts.isEmpty() #if ENABLE(SVG) && !isSVGText() @@ -351,6 +352,14 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool ASSERT(r->m_box->isText()); static_cast(r->m_box)->setFallbackFonts(fallbackFonts); } + if ((glyphOverflow.top || glyphOverflow.bottom || glyphOverflow.left || glyphOverflow.right) +#if ENABLE(SVG) + && !isSVGText() +#endif + ) { + ASSERT(r->m_box->isText()); + static_cast(r->m_box)->setGlyphOverflow(glyphOverflow); + } } else if (!r->m_object->isRenderInline()) { RenderBox* renderBox = toRenderBox(r->m_object); renderBox->calcWidth(); @@ -734,6 +743,7 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i // Now position our text runs vertically. computeVerticalPositionsForLine(lineBox, resolver.firstRun()); + InlineTextBox::clearGlyphOverflowAndFallbackFontMap(); #if ENABLE(SVG) // Special SVG text layout code diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderText.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderText.cpp index aa919e0..307db64 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderText.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderText.cpp @@ -61,7 +61,7 @@ RenderText::RenderText(Node* node, PassRefPtr str) , m_linesDirty(false) , m_containsReversedText(false) , m_isAllASCII(m_text.containsOnlyASCII()) - , m_knownNotToUseFallbackFonts(false) + , m_knownToHaveNoOverflowAndNoFallbackFonts(false) { ASSERT(m_text); @@ -106,7 +106,7 @@ void RenderText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl // need to relayout. if (diff == StyleDifferenceLayout) { setNeedsLayoutAndPrefWidthsRecalc(); - m_knownNotToUseFallbackFonts = false; + m_knownToHaveNoOverflowAndNoFallbackFonts = false; } ETextTransform oldTransform = oldStyle ? oldStyle->textTransform() : TTNONE; @@ -428,7 +428,7 @@ IntRect RenderText::localCaretRect(InlineBox* inlineBox, int caretOffset, int* e return IntRect(left, top, caretWidth, height); } -ALWAYS_INLINE int RenderText::widthFromCache(const Font& f, int start, int len, int xPos, HashSet* fallbackFonts) const +ALWAYS_INLINE int RenderText::widthFromCache(const Font& f, int start, int len, int xPos, HashSet* fallbackFonts, GlyphOverflow* glyphOverflow) const { if (f.isFixedPitch() && !f.isSmallCaps() && m_isAllASCII) { int monospaceCharacterWidth = f.spaceWidth(); @@ -460,7 +460,7 @@ ALWAYS_INLINE int RenderText::widthFromCache(const Font& f, int start, int len, return w; } - return f.width(TextRun(text()->characters() + start, len, allowTabs(), xPos), fallbackFonts); + return f.width(TextRun(text()->characters() + start, len, allowTabs(), xPos), fallbackFonts, glyphOverflow); } void RenderText::trimmedPrefWidths(int leadWidth, @@ -531,7 +531,7 @@ void RenderText::trimmedPrefWidths(int leadWidth, linelen++; if (linelen) { - endMaxW = widthFromCache(f, i, linelen, leadWidth + endMaxW, 0); + endMaxW = widthFromCache(f, i, linelen, leadWidth + endMaxW, 0, 0); if (firstLine) { firstLine = false; leadWidth = 0; @@ -576,14 +576,15 @@ int RenderText::maxPrefWidth() const void RenderText::calcPrefWidths(int leadWidth) { HashSet fallbackFonts; - calcPrefWidths(leadWidth, fallbackFonts); - if (fallbackFonts.isEmpty()) - m_knownNotToUseFallbackFonts = true; + GlyphOverflow glyphOverflow; + calcPrefWidths(leadWidth, fallbackFonts, glyphOverflow); + if (fallbackFonts.isEmpty() && !glyphOverflow.left && !glyphOverflow.right && !glyphOverflow.top && !glyphOverflow.bottom) + m_knownToHaveNoOverflowAndNoFallbackFonts = true; } -void RenderText::calcPrefWidths(int leadWidth, HashSet& fallbackFonts) +void RenderText::calcPrefWidths(int leadWidth, HashSet& fallbackFonts, GlyphOverflow& glyphOverflow) { - ASSERT(m_hasTab || prefWidthsDirty() || !m_knownNotToUseFallbackFonts); + ASSERT(m_hasTab || prefWidthsDirty() || !m_knownToHaveNoOverflowAndNoFallbackFonts); m_minWidth = 0; m_beginMinWidth = 0; @@ -613,6 +614,8 @@ void RenderText::calcPrefWidths(int leadWidth, HashSet& f int nextBreakable = -1; int lastWordBoundary = 0; + int firstGlyphLeftOverflow = -1; + bool breakNBSP = style()->autoWrap() && style()->nbspMode() == SPACE; bool breakAll = (style()->wordBreak() == BreakAllWordBreak || style()->wordBreak() == BreakWordBreak) && style()->autoWrap(); @@ -655,7 +658,9 @@ void RenderText::calcPrefWidths(int leadWidth, HashSet& f lastWordBoundary++; continue; } else if (c == softHyphen) { - currMaxWidth += widthFromCache(f, lastWordBoundary, i - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts); + currMaxWidth += widthFromCache(f, lastWordBoundary, i - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow); + if (firstGlyphLeftOverflow < 0) + firstGlyphLeftOverflow = glyphOverflow.left; lastWordBoundary = i + 1; continue; } @@ -678,13 +683,15 @@ void RenderText::calcPrefWidths(int leadWidth, HashSet& f int wordLen = j - i; if (wordLen) { - int w = widthFromCache(f, i, wordLen, leadWidth + currMaxWidth, &fallbackFonts); + int w = widthFromCache(f, i, wordLen, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow); + if (firstGlyphLeftOverflow < 0) + firstGlyphLeftOverflow = glyphOverflow.left; currMinWidth += w; if (betweenWords) { if (lastWordBoundary == i) currMaxWidth += w; else - currMaxWidth += widthFromCache(f, lastWordBoundary, j - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts); + currMaxWidth += widthFromCache(f, lastWordBoundary, j - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow); lastWordBoundary = j; } @@ -737,6 +744,7 @@ void RenderText::calcPrefWidths(int leadWidth, HashSet& f currMaxWidth = 0; } else { currMaxWidth += f.width(TextRun(txt + i, 1, allowTabs(), leadWidth + currMaxWidth)); + glyphOverflow.right = 0; needsWordSpacing = isSpace && !previousCharacterIsSpace && i == len - 1; } ASSERT(lastWordBoundary == i); @@ -744,6 +752,9 @@ void RenderText::calcPrefWidths(int leadWidth, HashSet& f } } + if (firstGlyphLeftOverflow > 0) + glyphOverflow.left = firstGlyphLeftOverflow; + if ((needsWordSpacing && len > 1) || (ignoringSpaces && !firstWord)) currMaxWidth += wordSpacing; @@ -1019,7 +1030,7 @@ void RenderText::setText(PassRefPtr text, bool force) setTextInternal(text); setNeedsLayoutAndPrefWidthsRecalc(); - m_knownNotToUseFallbackFonts = false; + m_knownToHaveNoOverflowAndNoFallbackFonts = false; AXObjectCache* axObjectCache = document()->axObjectCache(); if (axObjectCache->accessibilityEnabled()) @@ -1085,7 +1096,7 @@ void RenderText::positionLineBox(InlineBox* box) m_containsReversedText |= s->direction() == RTL; } -unsigned RenderText::width(unsigned from, unsigned len, int xPos, bool firstLine, HashSet* fallbackFonts) const +unsigned RenderText::width(unsigned from, unsigned len, int xPos, bool firstLine, HashSet* fallbackFonts, GlyphOverflow* glyphOverflow) const { if (from >= textLength()) return 0; @@ -1093,10 +1104,10 @@ unsigned RenderText::width(unsigned from, unsigned len, int xPos, bool firstLine if (from + len > textLength()) len = textLength() - from; - return width(from, len, style(firstLine)->font(), xPos, fallbackFonts); + return width(from, len, style(firstLine)->font(), xPos, fallbackFonts, glyphOverflow); } -unsigned RenderText::width(unsigned from, unsigned len, const Font& f, int xPos, HashSet* fallbackFonts) const +unsigned RenderText::width(unsigned from, unsigned len, const Font& f, int xPos, HashSet* fallbackFonts, GlyphOverflow* glyphOverflow) const { ASSERT(from + len <= textLength()); if (!characters()) @@ -1106,18 +1117,19 @@ unsigned RenderText::width(unsigned from, unsigned len, const Font& f, int xPos, if (&f == &style()->font()) { if (!style()->preserveNewline() && !from && len == textLength()) { if (fallbackFonts) { - if (prefWidthsDirty() || !m_knownNotToUseFallbackFonts) { - const_cast(this)->calcPrefWidths(0, *fallbackFonts); - if (fallbackFonts->isEmpty()) - m_knownNotToUseFallbackFonts = true; + ASSERT(glyphOverflow); + if (prefWidthsDirty() || !m_knownToHaveNoOverflowAndNoFallbackFonts) { + const_cast(this)->calcPrefWidths(0, *fallbackFonts, *glyphOverflow); + if (fallbackFonts->isEmpty() && !glyphOverflow->left && !glyphOverflow->right && !glyphOverflow->top && !glyphOverflow->bottom) + m_knownToHaveNoOverflowAndNoFallbackFonts = true; } w = m_maxWidth; } else w = maxPrefWidth(); } else - w = widthFromCache(f, from, len, xPos, fallbackFonts); + w = widthFromCache(f, from, len, xPos, fallbackFonts, glyphOverflow); } else - w = f.width(TextRun(text()->characters() + from, len, allowTabs(), xPos), fallbackFonts); + w = f.width(TextRun(text()->characters() + from, len, allowTabs(), xPos), fallbackFonts, glyphOverflow); return w; } diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderText.h b/src/3rdparty/webkit/WebCore/rendering/RenderText.h index e9ed147..9b1467d 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderText.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderText.h @@ -67,8 +67,8 @@ public: unsigned textLength() const { return m_text.length(); } // non virtual implementation of length() void positionLineBox(InlineBox*); - virtual unsigned width(unsigned from, unsigned len, const Font&, int xPos, HashSet* fallbackFonts = 0) const; - virtual unsigned width(unsigned from, unsigned len, int xPos, bool firstLine = false, HashSet* fallbackFonts = 0) const; + virtual unsigned width(unsigned from, unsigned len, const Font&, int xPos, HashSet* fallbackFonts = 0, GlyphOverflow* = 0) const; + virtual unsigned width(unsigned from, unsigned len, int xPos, bool firstLine = false, HashSet* fallbackFonts = 0, GlyphOverflow* = 0) const; virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const; @@ -133,7 +133,7 @@ protected: virtual InlineTextBox* createTextBox(); // Subclassed by SVG. private: - void calcPrefWidths(int leadWidth, HashSet& fallbackFonts); + void calcPrefWidths(int leadWidth, HashSet& fallbackFonts, GlyphOverflow&); // Make length() private so that callers that have a RenderText* // will use the more efficient textLength() instead, while @@ -146,7 +146,7 @@ private: void deleteTextBoxes(); bool containsOnlyWhitespace(unsigned from, unsigned len) const; - int widthFromCache(const Font&, int start, int len, int xPos, HashSet* fallbackFonts) const; + int widthFromCache(const Font&, int start, int len, int xPos, HashSet* fallbackFonts, GlyphOverflow*) const; bool isAllASCII() const { return m_isAllASCII; } int m_minWidth; // here to minimize padding in 64-bit. @@ -171,7 +171,7 @@ private: // or removed). bool m_containsReversedText : 1; bool m_isAllASCII : 1; - mutable bool m_knownNotToUseFallbackFonts : 1; + mutable bool m_knownToHaveNoOverflowAndNoFallbackFonts : 1; }; inline RenderText* toRenderText(RenderObject* object) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index 3141f66..9a4e9b2 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -453,6 +453,9 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) WebCore::InitializeLoggingChannelsIfNecessary(); JSC::initializeThreading(); WebCore::SecurityOrigin::setLocalLoadPolicy(WebCore::SecurityOrigin::AllowLocalLoadsForLocalAndSubstituteData); +#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) + WebCore::Font::setCodePath(WebCore::Font::Complex); +#endif chromeClient = new ChromeClientQt(q); contextMenuClient = new ContextMenuClientQt(); diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 2785421..0e73680 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,44 @@ +2010-06-11 Jocelyn Turcotte + + Reviewed by nobody, build fix. + + [Qt] Second fix attempt for the build break introduced by r61002. + + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): + +2010-06-11 Jocelyn Turcotte + + Reviewed by nobody, build fix. + + [Qt] Fix build break introduced by r61002. + + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): + +2010-05-31 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] Implement the simple text code path. + https://bugs.webkit.org/show_bug.cgi?id=40077 + + Remove the FONT_FAST_PATH macro and use the Qt's + fast text implementation instead of the one of WebKit. + + The Qt::TextBypassShaping flag is used to tell Qt to + only use the glyph advances. + + Qt 4.7 is needed to get this flag thus the complex path is always + used if QtWebKit is compiled against an earlier version. + + Contrary to the WebKit's implementation, the complex code path + is taken if the text is RightToLeft, justified or is formatted + with non-zero letter or word spacing. + + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): + 2010-06-21 Simon Hausmann Unreviewed build fix. -- cgit v0.12 From a090a9f42c0db1bbcce30db6165d5edbaa2c4456 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 21 Jun 2010 16:57:49 +0200 Subject: Fix examples Import QtWebKit instead of org.webkit Reviewed-by: Trust me --- examples/declarative/modelviews/webview/alerts.qml | 2 +- examples/declarative/modelviews/webview/autosize.qml | 2 +- examples/declarative/modelviews/webview/googleMaps.qml | 2 +- examples/declarative/modelviews/webview/inline-html.qml | 2 +- examples/declarative/modelviews/webview/newwindows.qml | 2 +- examples/declarative/modelviews/webview/transparent.qml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/declarative/modelviews/webview/alerts.qml b/examples/declarative/modelviews/webview/alerts.qml index 7303450..cfeaa11 100644 --- a/examples/declarative/modelviews/webview/alerts.qml +++ b/examples/declarative/modelviews/webview/alerts.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 WebView { id: webView diff --git a/examples/declarative/modelviews/webview/autosize.qml b/examples/declarative/modelviews/webview/autosize.qml index 556b429..e037848 100644 --- a/examples/declarative/modelviews/webview/autosize.qml +++ b/examples/declarative/modelviews/webview/autosize.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 // The WebView size is determined by the width, height, // preferredWidth, and preferredHeight properties. diff --git a/examples/declarative/modelviews/webview/googleMaps.qml b/examples/declarative/modelviews/webview/googleMaps.qml index 1c99940..361b40c 100644 --- a/examples/declarative/modelviews/webview/googleMaps.qml +++ b/examples/declarative/modelviews/webview/googleMaps.qml @@ -46,7 +46,7 @@ // order to create a Map. import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 import "content/Mapping" Map { diff --git a/examples/declarative/modelviews/webview/inline-html.qml b/examples/declarative/modelviews/webview/inline-html.qml index 875c903..969cda0 100644 --- a/examples/declarative/modelviews/webview/inline-html.qml +++ b/examples/declarative/modelviews/webview/inline-html.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 // Inline HTML with loose formatting can be // set on the html property. diff --git a/examples/declarative/modelviews/webview/newwindows.qml b/examples/declarative/modelviews/webview/newwindows.qml index 4ea3e68..c09b2a9 100644 --- a/examples/declarative/modelviews/webview/newwindows.qml +++ b/examples/declarative/modelviews/webview/newwindows.qml @@ -44,7 +44,7 @@ // allow it on WebView with settings.javascriptCanOpenWindows: true import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 Grid { columns: 3 diff --git a/examples/declarative/modelviews/webview/transparent.qml b/examples/declarative/modelviews/webview/transparent.qml index 92c1578..d21a88e 100644 --- a/examples/declarative/modelviews/webview/transparent.qml +++ b/examples/declarative/modelviews/webview/transparent.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 // The WebView background is transparent // if the HTML does not specify a background -- cgit v0.12