diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-02-10 10:19:28 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-02-10 10:19:28 +0100 |
commit | d1f4409a2b1e0143be0d4fd734f3dd83255ea35c (patch) | |
tree | 52daa990c1da2c2ce9656fe4065b73a848a57a5a /src/webengine | |
parent | 8e5ac243ac774209b77bec42eda2ec43f9c9b04a (diff) | |
parent | 776442f2117c4b2d6dac75ab56b42bd82e2ce6d0 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
tests/auto/widgets/widgets.pro
Change-Id: Id9444359ed2e35d469331db96a355c9ea2d095d5
Diffstat (limited to 'src/webengine')
-rw-r--r-- | src/webengine/api/qquickwebenginescript.cpp | 68 | ||||
-rw-r--r-- | src/webengine/doc/qtwebengine.qdocconf | 4 | ||||
-rw-r--r-- | src/webengine/doc/src/qtwebengine-platform-notes.qdoc | 10 | ||||
-rw-r--r-- | src/webengine/doc/src/webengineview.qdoc | 2 | ||||
-rw-r--r-- | src/webengine/render_widget_host_view_qt_delegate_quick.cpp | 15 |
5 files changed, 97 insertions, 2 deletions
diff --git a/src/webengine/api/qquickwebenginescript.cpp b/src/webengine/api/qquickwebenginescript.cpp index 7e5ff863f..aa32041e4 100644 --- a/src/webengine/api/qquickwebenginescript.cpp +++ b/src/webengine/api/qquickwebenginescript.cpp @@ -48,6 +48,27 @@ using QtWebEngineCore::UserScript; +/*! + \qmltype WebEngineScript + \instantiates QQuickWebEngineScript + \inqmlmodule QtWebEngine + \since QtWebEngine 1.1 + \brief Enables the programmatic injection of scripts in the JavaScript engine. + + The WebEngineScript type enables the programmatic injection of so called \e {user scripts} in + the JavaScript engine at different points, determined by injectionPoint, during the loading of + web content. + + Scripts can be executed either in the main JavaScript \e world, along with the rest of the + JavaScript coming from the web contents, or in their own isolated world. While the DOM of the + page can be accessed from any world, JavaScript variables of a function defined in one world are + not accessible from a different one. The worldId property provides some predefined IDs for this + purpose. + + Use \l{WebEngineView::userScripts}{WebEngineView.userScripts} to access a list of scripts + attached to the web view. +*/ + QQuickWebEngineScript::QQuickWebEngineScript() : d_ptr(new QQuickWebEngineScriptPrivate) { @@ -81,6 +102,12 @@ QString QQuickWebEngineScript::toString() const return ret; } +/*! + \qmlproperty QString WebEngineScript::name + + The name of the script. Can be useful to retrieve a particular script from + \l{WebEngineView::userScripts}{WebEngineView.userScripts}. +*/ QString QQuickWebEngineScript::name() const { Q_D(const QQuickWebEngineScript); @@ -93,7 +120,7 @@ QString QQuickWebEngineScript::name() const This property holds the remote source location of the user script (if any). Unlike \l sourceCode, this property allows referring to user scripts that - are not already loaded in memory, for instance, when stored on disk. + are not already loaded in memory, for instance, when stored on disk. Setting this property will change the \l sourceCode of the script. @@ -124,20 +151,57 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineScript::Deferred, UserScript::AfterLoad) ASSERT_ENUMS_MATCH(QQuickWebEngineScript::DocumentReady, UserScript::DocumentLoadFinished) ASSERT_ENUMS_MATCH(QQuickWebEngineScript::DocumentCreation, UserScript::DocumentElementCreation) +/*! + \qmlproperty enumeration WebEngineScript::injectionPoint + + The point in the loading process at which the script will be executed. + The default value is \c Deferred. + + \value DocumentCreation + The script will be executed as soon as the document is created. This is not suitable for + any DOM operation. + \value DocumentReady + The script will run as soon as the DOM is ready. This is equivalent to the + \c DOMContentLoaded event firing in JavaScript. + \value Deferred + The script will run when the page load finishes, or 500 ms after the document is ready, + whichever comes first. +*/ QQuickWebEngineScript::InjectionPoint QQuickWebEngineScript::injectionPoint() const { Q_D(const QQuickWebEngineScript); return static_cast<QQuickWebEngineScript::InjectionPoint>(d->coreScript.injectionPoint()); } - +/*! + \qmlproperty enumeration WebEngineScript::worldId + + The world ID defining which isolated world the script is executed in. + + \value MainWorld + The world used by the page's web contents. It can be useful in order to expose custom + functionality to web contents in certain scenarios. + \value ApplicationWorld + The default isolated world used for application level functionality implemented in + JavaScript. + \value UserWorld + The first isolated world to be used by scripts set by users if the application is not + making use of more worlds. As a rule of thumb, if that functionality is exposed to the + application users, each individual script should probably get its own isolated world. +*/ QQuickWebEngineScript::ScriptWorldId QQuickWebEngineScript::worldId() const { Q_D(const QQuickWebEngineScript); return static_cast<QQuickWebEngineScript::ScriptWorldId>(d->coreScript.worldId()); } +/*! + \qmlproperty int WebEngineScript::runOnSubframes + Set this property to \c true if the script is executed on every frame in the page, or \c false + if it is only ran for the main frame. + The default value is \c{false}. + */ bool QQuickWebEngineScript::runOnSubframes() const { Q_D(const QQuickWebEngineScript); diff --git a/src/webengine/doc/qtwebengine.qdocconf b/src/webengine/doc/qtwebengine.qdocconf index 02f9a9ffd..2fbdef93e 100644 --- a/src/webengine/doc/qtwebengine.qdocconf +++ b/src/webengine/doc/qtwebengine.qdocconf @@ -35,6 +35,9 @@ qhp.QtWebEngine.subprojects.examples.indexTitle = Qt WebEngine Examples qhp.QtWebEngine.subprojects.examples.selectors = doc:example qhp.QtWebEngine.subprojects.examples.sortPages = true +manifestmeta.highlighted.names += "QtWebEngine/WebEngine Markdown Editor Example" \ + "QtWebEngine/WebEngine Quick Nano Browser" + tagfile = ../../../doc/qtwebengine/qtwebengine.tags depends += qtcore \ @@ -45,6 +48,7 @@ depends += qtcore \ qtquickcontrols \ qtdoc \ qtwebchannel \ + qtwebview \ qtwidgets headerdirs += .. \ diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc index 29b8db42e..1f2d9dcf2 100644 --- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc +++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc @@ -116,4 +116,14 @@ be configured for use with several codecs, which rises licensing issues during distribution with the codec libraries. For some codecs, open source implementations, such as \l {OpenH264}, are available. + + \section1 Default QSurfaceFormat OpenGL Profile Support + + If a new default QSurfaceFormat with a modified OpenGL profile has to be set, it should be set + before the application instance is declared, to make sure that all created OpenGL contexts use + the same OpenGL profile. + + On OS X, if the default QSurfaceFormat is set after the application instance, the application + will exit with qFatal(), and print a message that the default QSurfaceFormat should be set + before the application instance. */ diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc index a242acffc..8e09d2b89 100644 --- a/src/webengine/doc/src/webengineview.qdoc +++ b/src/webengine/doc/src/webengineview.qdoc @@ -227,6 +227,8 @@ \since QtWebEngine 1.1 List of script objects attached to the view. + + \sa WebEngineScript */ /*! diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp index eebf0ceb6..1101bd483 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp +++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp @@ -44,6 +44,7 @@ #include <QGuiApplication> #include <QQuickPaintedItem> #include <QQuickWindow> +#include <QSurfaceFormat> #include <QVariant> #include <QWindow> #include <private/qquickwindow_p.h> @@ -63,6 +64,20 @@ RenderWidgetHostViewQtDelegateQuick::RenderWidgetHostViewQtDelegateQuick(RenderW return; setFocus(true); setActiveFocusOnTab(true); + +#ifdef Q_OS_OSX + // Check that the default QSurfaceFormat OpenGL profile matches the global OpenGL shared + // context profile, otherwise this could lead to a nasty crash. + QOpenGLContext *globalSharedContext = QOpenGLContext::globalShareContext(); + if (globalSharedContext) { + QSurfaceFormat sharedFormat = globalSharedContext->format(); + QSurfaceFormat defaultFormat = QSurfaceFormat::defaultFormat(); + if (defaultFormat.profile() != sharedFormat.profile()) { + qFatal("QWebEngine: Default QSurfaceFormat OpenGL profile does not match global shared context OpenGL profile. Please make sure you set a new QSurfaceFormat before the QtGui application instance is created."); + } + } +#endif + } void RenderWidgetHostViewQtDelegateQuick::initAsChild(WebContentsAdapterClient* container) |