diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-11-20 16:01:37 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-11-20 16:04:42 +0100 |
commit | 1f474fcc4cd47a85ce8d99f07d18b46ef2af5898 (patch) | |
tree | d4e52b5ac98343b4c2417d622164bf320d781a59 /src | |
parent | 4cc28c7c89f794d469f5e8f778ff05effe8c646f (diff) | |
parent | 1173d48149a8133b607894b67e1ec32de68e21e8 (diff) |
Merge branch '5.6' into dev
Change-Id: I05fe27b8321944cf68cc96dfa9dfcaeb54c8c8cd
Diffstat (limited to 'src')
77 files changed, 876 insertions, 324 deletions
diff --git a/src/core/api/qwebenginecallback.h b/src/core/api/qwebenginecallback.h index ddee20d06..b675438f5 100644 --- a/src/core/api/qwebenginecallback.h +++ b/src/core/api/qwebenginecallback.h @@ -81,12 +81,19 @@ public: : d(new QtWebEnginePrivate::QWebEngineCallbackPrivate<T, F>(f)) { } QWebEngineCallback() { } + void swap(QWebEngineCallback &other) Q_DECL_NOTHROW { qSwap(d, other.d); } operator bool() const { return d; } private: friend class QtWebEngineCore::CallbackDirectory; QExplicitlySharedDataPointer<QtWebEnginePrivate::QWebEngineCallbackPrivateBase<T> > d; }; +Q_DECLARE_SHARED(QWebEngineCallback<int>) +Q_DECLARE_SHARED(QWebEngineCallback<const QByteArray &>) +Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QWebEngineCallback<bool>) +Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QWebEngineCallback<const QString &>) +Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QWebEngineCallback<const QVariant &>) + QT_END_NAMESPACE #endif // QWEBENGINECALLBACK_H diff --git a/src/core/api/qwebenginecallback_p.h b/src/core/api/qwebenginecallback_p.h index f0c25fe9e..9bc9b9727 100644 --- a/src/core/api/qwebenginecallback_p.h +++ b/src/core/api/qwebenginecallback_p.h @@ -47,6 +47,7 @@ #include <QVariant> #include <type_traits> +// keep in sync with Q_DECLARE_SHARED... in qwebenginecallback.h #define FOR_EACH_TYPE(F) \ F(bool) \ F(int) \ @@ -227,6 +228,11 @@ void CallbackDirectory::CallbackSharedDataPointer<T>::invokeEmpty() parent->invokeEmptyInternal(callback); } +#define CHECK_RELOCATABLE(x) \ + Q_STATIC_ASSERT((QTypeInfoQuery<QWebEngineCallback< x > >::isRelocatable)); +FOR_EACH_TYPE(CHECK_RELOCATABLE) +#undef CHECK_RELOCATABLE + } // namespace QtWebEngineCore #endif // QWEBENGINECALLBACK_P_H diff --git a/src/core/api/qwebenginecookiestoreclient.cpp b/src/core/api/qwebenginecookiestoreclient.cpp index 167b3f68c..bd43b871d 100644 --- a/src/core/api/qwebenginecookiestoreclient.cpp +++ b/src/core/api/qwebenginecookiestoreclient.cpp @@ -181,7 +181,7 @@ bool QWebEngineCookieStoreClientPrivate::canSetCookie(const QUrl &firstPartyUrl, request.firstPartyUrl = firstPartyUrl; request.cookieLine = cookieLine; request.cookieSource = url; - callbackDirectory.invokeDirectly<const QWebEngineCookieStoreClient::FilterRequest&>(filterCallback, request); + callbackDirectory.invokeDirectly<QWebEngineCookieStoreClient::FilterRequest&>(filterCallback, request); return request.accepted; } return true; @@ -394,7 +394,7 @@ void QWebEngineCookieStoreClient::deleteAllCookies() \sa deleteAllCookiesWithCallback(), getAllCookies() */ -void QWebEngineCookieStoreClient::setCookieFilter(const QWebEngineCallback<const QWebEngineCookieStoreClient::FilterRequest&> &filter) +void QWebEngineCookieStoreClient::setCookieFilter(const QWebEngineCallback<QWebEngineCookieStoreClient::FilterRequest&> &filter) { Q_D(QWebEngineCookieStoreClient); d->filterCallback = filter; diff --git a/src/core/api/qwebenginecookiestoreclient.h b/src/core/api/qwebenginecookiestoreclient.h index 8bdb988e2..4664a8459 100644 --- a/src/core/api/qwebenginecookiestoreclient.h +++ b/src/core/api/qwebenginecookiestoreclient.h @@ -77,7 +77,7 @@ public: void deleteSessionCookiesWithCallback(const QWebEngineCallback<int> &resultCallback); void deleteAllCookiesWithCallback(const QWebEngineCallback<int> &resultCallback); void getAllCookies(const QWebEngineCallback<const QByteArray&> &resultCallback); - void setCookieFilter(const QWebEngineCallback<const FilterRequest&> &filterCallback); + void setCookieFilter(const QWebEngineCallback<FilterRequest&> &filterCallback); #endif void setCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl()); void deleteCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl()); diff --git a/src/core/api/qwebenginecookiestoreclient_p.h b/src/core/api/qwebenginecookiestoreclient_p.h index 43652fba6..54f3b9eb7 100644 --- a/src/core/api/qwebenginecookiestoreclient_p.h +++ b/src/core/api/qwebenginecookiestoreclient_p.h @@ -53,8 +53,7 @@ #include "qwebenginecallback_p.h" #include "qwebenginecookiestoreclient.h" -#include <QList> -#include <QMap> +#include <QVector> #include <QNetworkCookie> #include <QUrl> @@ -70,12 +69,12 @@ class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStoreClientPrivate { QNetworkCookie cookie; QUrl origin; }; - + friend class QTypeInfo<CookieData>; public: Q_DECLARE_PUBLIC(QWebEngineCookieStoreClient) QtWebEngineCore::CallbackDirectory callbackDirectory; - QWebEngineCallback<const QWebEngineCookieStoreClient::FilterRequest&> filterCallback; - QList<CookieData> m_pendingUserCookies; + QWebEngineCallback<QWebEngineCookieStoreClient::FilterRequest&> filterCallback; + QVector<CookieData> m_pendingUserCookies; quint64 m_nextCallbackId; bool m_deleteSessionCookiesPending; bool m_deleteAllCookiesPending; @@ -102,6 +101,8 @@ public: void onCookieChanged(const QNetworkCookie &cookie, bool removed); }; +Q_DECLARE_TYPEINFO(QWebEngineCookieStoreClientPrivate::CookieData, Q_MOVABLE_TYPE); + QT_END_NAMESPACE #endif // QWEBENGINECOOKIESTORECLIENT_P_H diff --git a/src/core/api/qwebengineurlschemehandler.cpp b/src/core/api/qwebengineurlschemehandler.cpp index f887e4e98..7f9ebaf48 100644 --- a/src/core/api/qwebengineurlschemehandler.cpp +++ b/src/core/api/qwebengineurlschemehandler.cpp @@ -75,7 +75,6 @@ QWebEngineUrlSchemeHandler::QWebEngineUrlSchemeHandler(QObject *parent) QWebEngineUrlSchemeHandler::~QWebEngineUrlSchemeHandler() { Q_EMIT destroyed(this); - delete d_ptr; } /*! diff --git a/src/core/api/qwebengineurlschemehandler.h b/src/core/api/qwebengineurlschemehandler.h index 8c1e52646..66aebe00d 100644 --- a/src/core/api/qwebengineurlschemehandler.h +++ b/src/core/api/qwebengineurlschemehandler.h @@ -48,7 +48,6 @@ class URLRequestContextGetterQt; QT_BEGIN_NAMESPACE class QWebEngineUrlRequestJob; -class QWebEngineUrlSchemeHandlerPrivate; class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandler : public QObject { Q_OBJECT @@ -63,8 +62,6 @@ Q_SIGNALS: private: Q_DISABLE_COPY(QWebEngineUrlSchemeHandler) - Q_DECLARE_PRIVATE(QWebEngineUrlSchemeHandler) - QWebEngineUrlSchemeHandlerPrivate *d_ptr; }; QT_END_NAMESPACE diff --git a/src/core/chrome_qt.gyp b/src/core/chrome_qt.gyp index 2d2abe802..6c8e0d4d6 100644 --- a/src/core/chrome_qt.gyp +++ b/src/core/chrome_qt.gyp @@ -20,13 +20,13 @@ '<(SHARED_INTERMEDIATE_DIR)/components/strings', ], 'sources': [ - '<(chromium_src_dir)/chrome/browser/media/desktop_streams_registry.cc', - '<(chromium_src_dir)/chrome/browser/media/desktop_streams_registry.h', - '<(chromium_src_dir)/chrome/browser/media/desktop_media_list.h', - '<(chromium_src_dir)/chrome/common/chrome_switches.cc', - '<(chromium_src_dir)/chrome/common/chrome_switches.h', - '<(chromium_src_dir)/chrome/common/localized_error.cc', - '<(chromium_src_dir)/chrome/common/localized_error.h', + '<(DEPTH)/chrome/browser/media/desktop_streams_registry.cc', + '<(DEPTH)/chrome/browser/media/desktop_streams_registry.h', + '<(DEPTH)/chrome/browser/media/desktop_media_list.h', + '<(DEPTH)/chrome/common/chrome_switches.cc', + '<(DEPTH)/chrome/common/chrome_switches.h', + '<(DEPTH)/chrome/common/localized_error.cc', + '<(DEPTH)/chrome/common/localized_error.h', ], }, { diff --git a/src/core/common/qt_messages.h b/src/core/common/qt_messages.h index 25a995b27..ae36a0d7f 100644 --- a/src/core/common/qt_messages.h +++ b/src/core/common/qt_messages.h @@ -25,13 +25,13 @@ IPC_STRUCT_TRAITS_END() // RenderView messages // These are messages sent from the browser to the renderer process. -IPC_MESSAGE_ROUTED1(QtRenderViewObserver_FetchDocumentMarkup, +IPC_MESSAGE_ROUTED1(RenderViewObserverQt_FetchDocumentMarkup, uint64 /* requestId */) -IPC_MESSAGE_ROUTED1(QtRenderViewObserver_FetchDocumentInnerText, +IPC_MESSAGE_ROUTED1(RenderViewObserverQt_FetchDocumentInnerText, uint64 /* requestId */) -IPC_MESSAGE_ROUTED1(QtRenderViewObserver_SetBackgroundColor, +IPC_MESSAGE_ROUTED1(RenderViewObserverQt_SetBackgroundColor, uint32 /* color */) IPC_MESSAGE_ROUTED1(WebChannelIPCTransport_Message, std::vector<char> /*binaryJSON*/) @@ -51,14 +51,14 @@ IPC_MESSAGE_CONTROL0(UserScriptController_ClearScripts) // WebContents messages // These are messages sent from the renderer back to the browser process. -IPC_MESSAGE_ROUTED2(QtRenderViewObserverHost_DidFetchDocumentMarkup, +IPC_MESSAGE_ROUTED2(RenderViewObserverHostQt_DidFetchDocumentMarkup, uint64 /* requestId */, base::string16 /* markup */) -IPC_MESSAGE_ROUTED2(QtRenderViewObserverHost_DidFetchDocumentInnerText, +IPC_MESSAGE_ROUTED2(RenderViewObserverHostQt_DidFetchDocumentInnerText, uint64 /* requestId */, base::string16 /* innerText */) -IPC_MESSAGE_ROUTED0(QtRenderViewObserverHost_DidFirstVisuallyNonEmptyLayout) +IPC_MESSAGE_ROUTED0(RenderViewObserverHostQt_DidFirstVisuallyNonEmptyLayout) IPC_MESSAGE_ROUTED1(WebChannelIPCTransportHost_SendMessage, std::vector<char> /*binaryJSON*/) diff --git a/src/core/common/user_script_data.h b/src/core/common/user_script_data.h index 3dfec0ec3..d0856e02a 100644 --- a/src/core/common/user_script_data.h +++ b/src/core/common/user_script_data.h @@ -60,4 +60,10 @@ struct UserScriptData { uint64 scriptId; }; +QT_BEGIN_NAMESPACE + +Q_DECLARE_TYPEINFO(UserScriptData, Q_MOVABLE_TYPE); + +QT_END_NAMESPACE + #endif // USER_SCRIPT_DATA_H diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 85dfe69ae..c3398757e 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -27,9 +27,9 @@ GYP_CONFIG += \ contains(QT_CONFIG, system-zlib): use?(system_minizip): GYP_CONFIG += use_system_zlib=1 contains(QT_CONFIG, system-png): GYP_CONFIG += use_system_libpng=1 contains(QT_CONFIG, system-jpeg): GYP_CONFIG += use_system_libjpeg=1 +contains(QT_CONFIG, system-harfbuzz): GYP_CONFIG += use_system_harfbuzz=1 !contains(QT_CONFIG, pulseaudio): GYP_CONFIG += use_pulseaudio=0 - -use?(system_harfbuzz): GYP_CONFIG += use_system_harfbuzz=1 +!contains(QT_CONFIG, glib): GYP_CONFIG += use_glib=0 use?(system_libevent): GYP_CONFIG += use_system_libevent=1 use?(system_libwebp): GYP_CONFIG += use_system_libwebp=1 use?(system_libsrtp): GYP_CONFIG += use_system_libsrtp=1 diff --git a/src/core/cookie_monster_delegate_qt.h b/src/core/cookie_monster_delegate_qt.h index 7592d57fa..db80bf0a1 100644 --- a/src/core/cookie_monster_delegate_qt.h +++ b/src/core/cookie_monster_delegate_qt.h @@ -47,7 +47,6 @@ QT_WARNING_DISABLE_CLANG("-Wunused-parameter") #include "net/cookies/cookie_monster.h" QT_WARNING_POP -#include <QList> #include <QNetworkCookie> #include <QPointer> diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro index 813626dc3..14b8d78e2 100644 --- a/src/core/core_gyp_generator.pro +++ b/src/core/core_gyp_generator.pro @@ -62,15 +62,15 @@ SOURCES = \ process_main.cpp \ proxy_config_service_qt.cpp \ qrc_protocol_handler_qt.cpp \ - qt_render_view_observer_host.cpp \ + render_view_observer_host_qt.cpp \ render_widget_host_view_qt.cpp \ renderer/content_renderer_client_qt.cpp \ renderer/pepper/pepper_flash_browser_host_qt.cpp \ renderer/pepper/pepper_flash_renderer_host_qt.cpp \ renderer/pepper/pepper_host_factory_qt.cpp \ renderer/pepper/pepper_renderer_host_factory_qt.cpp \ - renderer/qt_render_frame_observer.cpp \ - renderer/qt_render_view_observer.cpp \ + renderer/render_frame_observer_qt.cpp \ + renderer/render_view_observer_qt.cpp \ renderer/user_script_controller.cpp \ renderer/web_channel_ipc_transport.cpp \ resource_bundle_qt.cpp \ @@ -134,7 +134,7 @@ HEADERS = \ process_main.h \ proxy_config_service_qt.h \ qrc_protocol_handler_qt.h \ - qt_render_view_observer_host.h \ + render_view_observer_host_qt.h \ render_widget_host_view_qt.h \ render_widget_host_view_qt_delegate.h \ renderer/content_renderer_client_qt.h \ @@ -142,8 +142,8 @@ HEADERS = \ renderer/pepper/pepper_flash_renderer_host_qt.h \ renderer/pepper/pepper_host_factory_qt.h \ renderer/pepper/pepper_renderer_host_factory_qt.h \ - renderer/qt_render_frame_observer.h \ - renderer/qt_render_view_observer.h \ + renderer/render_frame_observer_qt.h \ + renderer/render_view_observer_qt.h \ renderer/user_script_controller.h \ renderer/web_channel_ipc_transport.h \ resource_context_qt.h \ diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index 724c2c9bc..a2836d5e6 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -56,6 +56,7 @@ #include "cc/output/delegated_frame_data.h" #include "cc/quads/debug_border_draw_quad.h" #include "cc/quads/draw_quad.h" +#include "cc/quads/io_surface_draw_quad.h" #include "cc/quads/render_pass_draw_quad.h" #include "cc/quads/solid_color_draw_quad.h" #include "cc/quads/stream_video_draw_quad.h" @@ -79,6 +80,10 @@ #define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull #endif +#ifndef GL_TEXTURE_RECTANGLE +#define GL_TEXTURE_RECTANGLE 0x84F5 +#endif + namespace QtWebEngineCore { class MailboxTexture : public QSGTexture, protected QOpenGLFunctions { @@ -130,7 +135,7 @@ private: QSGGeometry m_geometry; }; -static inline QSharedPointer<QSGLayer> findRenderPassLayer(const cc::RenderPassId &id, const QList<QPair<cc::RenderPassId, QSharedPointer<QSGLayer> > > &list) +static inline QSharedPointer<QSGLayer> findRenderPassLayer(const cc::RenderPassId &id, const QVector<QPair<cc::RenderPassId, QSharedPointer<QSGLayer> > > &list) { typedef QPair<cc::RenderPassId, QSharedPointer<QSGLayer> > Pair; Q_FOREACH (const Pair &pair, list) @@ -646,13 +651,29 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, MailboxTexture *texture = static_cast<MailboxTexture *>(initAndHoldTexture(resource, quad->ShouldDrawWithBlending())); texture->setTarget(GL_TEXTURE_EXTERNAL_OES); // since this is not default TEXTURE_2D type - StreamVideoNode *svideoNode = new StreamVideoNode(texture); + StreamVideoNode *svideoNode = new StreamVideoNode(texture, false, ExternalTarget); svideoNode->setRect(toQt(squad->rect)); svideoNode->setTextureMatrix(toQt(squad->matrix.matrix())); currentLayerChain->appendChildNode(svideoNode); break; #endif - } default: + } + case cc::DrawQuad::IO_SURFACE_CONTENT: { + const cc::IOSurfaceDrawQuad *ioquad = cc::IOSurfaceDrawQuad::MaterialCast(quad); + ResourceHolder *resource = findAndHoldResource(ioquad->io_surface_resource_id(), resourceCandidates); + MailboxTexture *texture = static_cast<MailboxTexture *>(initAndHoldTexture(resource, quad->ShouldDrawWithBlending())); + texture->setTarget(GL_TEXTURE_RECTANGLE); + + bool flip = ioquad->orientation != cc::IOSurfaceDrawQuad::FLIPPED; + StreamVideoNode *svideoNode = new StreamVideoNode(texture, flip, RectangleTarget); + QMatrix4x4 matrix; + matrix.scale(ioquad->io_surface_size.width(), ioquad->io_surface_size.height()); + svideoNode->setRect(toQt(ioquad->rect)); + svideoNode->setTextureMatrix(matrix); + currentLayerChain->appendChildNode(svideoNode); + break; + } + default: qWarning("Unimplemented quad material: %d", quad->material); } } diff --git a/src/core/delegated_frame_node.h b/src/core/delegated_frame_node.h index 60a1535d2..eed03fadd 100644 --- a/src/core/delegated_frame_node.h +++ b/src/core/delegated_frame_node.h @@ -90,9 +90,9 @@ private: QExplicitlySharedDataPointer<ChromiumCompositorData> m_chromiumCompositorData; struct SGObjects { - QList<QPair<cc::RenderPassId, QSharedPointer<QSGLayer> > > renderPassLayers; - QList<QSharedPointer<QSGRootNode> > renderPassRootNodes; - QList<QSharedPointer<QSGTexture> > textureStrongRefs; + QVector<QPair<cc::RenderPassId, QSharedPointer<QSGLayer> > > renderPassLayers; + QVector<QSharedPointer<QSGRootNode> > renderPassRootNodes; + QVector<QSharedPointer<QSGTexture> > textureStrongRefs; } m_sgObjects; int m_numPendingSyncPoints; QMap<uint32, gfx::TransferableFence> m_mailboxGLFences; diff --git a/src/core/gl_context_qt.cpp b/src/core/gl_context_qt.cpp index b350c3c5b..3c3b8225d 100644 --- a/src/core/gl_context_qt.cpp +++ b/src/core/gl_context_qt.cpp @@ -146,10 +146,14 @@ scoped_refptr<GLContext> GLContext::CreateGLContext(GLShareGroup* share_group, G { #if defined(OS_WIN) scoped_refptr<GLContext> context; - if (GetGLImplementation() == kGLImplementationDesktopGL) + if (GetGLImplementation() == kGLImplementationDesktopGL) { context = new GLContextWGL(share_group); - else + if (!context->Initialize(compatible_surface, gpu_preference)) + return nullptr; + return context; + } else { context = new GLContextEGL(share_group); + } #else scoped_refptr<GLContext> context = new GLContextEGL(share_group); #endif diff --git a/src/core/location_provider_qt.cpp b/src/core/location_provider_qt.cpp index e3be01b36..222d15354 100644 --- a/src/core/location_provider_qt.cpp +++ b/src/core/location_provider_qt.cpp @@ -88,12 +88,15 @@ QtPositioningHelper::~QtPositioningHelper() m_locationProvider->m_positioningHelper = 0; } +static bool isHighAccuracySource(const QGeoPositionInfoSource *source) +{ + return source->supportedPositioningMethods().testFlag( + QGeoPositionInfoSource::SatellitePositioningMethods); +} + void QtPositioningHelper::start(bool highAccuracy) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - Q_UNUSED(highAccuracy); - // FIXME: go through availableSources until one supports QGeoPositionInfoSource::SatellitePositioningMethods - // for the highAccuracy case. m_positionInfoSource = QGeoPositionInfoSource::createDefaultSource(this); if (!m_positionInfoSource) { qWarning("Failed to initialize location provider: The system either has no default " @@ -103,6 +106,23 @@ void QtPositioningHelper::start(bool highAccuracy) return; } + // Find high accuracy source if the default source is not already one. + if (highAccuracy && !isHighAccuracySource(m_positionInfoSource)) { + Q_FOREACH (const QString &name, QGeoPositionInfoSource::availableSources()) { + if (name == m_positionInfoSource->sourceName()) + continue; + QGeoPositionInfoSource *source = QGeoPositionInfoSource::createSource(name, this); + if (source && isHighAccuracySource(source)) { + delete m_positionInfoSource; + m_positionInfoSource = source; + break; + } + delete source; + } + m_positionInfoSource->setPreferredPositioningMethods( + QGeoPositionInfoSource::SatellitePositioningMethods); + } + connect(m_positionInfoSource, &QGeoPositionInfoSource::positionUpdated, this, &QtPositioningHelper::updatePosition); // disambiguate the error getter and the signal in QGeoPositionInfoSource. connect(m_positionInfoSource, static_cast<void (QGeoPositionInfoSource::*)(QGeoPositionInfoSource::Error)>(&QGeoPositionInfoSource::error) diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index d93f9c331..19204b270 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -83,8 +83,7 @@ void PermissionManagerQt::permissionRequestReply(const QUrl &origin, BrowserCont m_permissions[key] = reply; content::PermissionStatus status = reply ? content::PERMISSION_STATUS_GRANTED : content::PERMISSION_STATUS_DENIED; auto it = m_requests.begin(); - const auto end = m_requests.end(); - while (it != end) { + while (it != m_requests.end()) { if (it->origin == origin && it->type == type) { it->callback.Run(status); it = m_requests.erase(it); diff --git a/src/core/qtwebengine.gypi b/src/core/qtwebengine.gypi index a420918a0..96b48e2ca 100644 --- a/src/core/qtwebengine.gypi +++ b/src/core/qtwebengine.gypi @@ -13,6 +13,8 @@ '<(chromium_src_dir)/components/components.gyp:error_page_renderer', '<(chromium_src_dir)/components/components.gyp:visitedlink_browser', '<(chromium_src_dir)/components/components.gyp:visitedlink_renderer', + '<(chromium_src_dir)/components/components.gyp:web_cache_browser', + '<(chromium_src_dir)/components/components.gyp:web_cache_renderer', '<(chromium_src_dir)/content/content.gyp:content', '<(chromium_src_dir)/content/content.gyp:content_app_browser', '<(chromium_src_dir)/content/content.gyp:content_browser', diff --git a/src/core/qt_render_view_observer_host.cpp b/src/core/render_view_observer_host_qt.cpp index 97d001ed6..03c9d241f 100644 --- a/src/core/qt_render_view_observer_host.cpp +++ b/src/core/render_view_observer_host_qt.cpp @@ -34,7 +34,7 @@ ** ****************************************************************************/ -#include "qt_render_view_observer_host.h" +#include "render_view_observer_host_qt.h" #include "common/qt_messages.h" #include "content/public/browser/web_contents.h" @@ -44,31 +44,31 @@ namespace QtWebEngineCore { -QtRenderViewObserverHost::QtRenderViewObserverHost(content::WebContents *webContents, WebContentsAdapterClient *adapterClient) +RenderViewObserverHostQt::RenderViewObserverHostQt(content::WebContents *webContents, WebContentsAdapterClient *adapterClient) : content::WebContentsObserver(webContents) , m_adapterClient(adapterClient) { } -void QtRenderViewObserverHost::fetchDocumentMarkup(quint64 requestId) +void RenderViewObserverHostQt::fetchDocumentMarkup(quint64 requestId) { - Send(new QtRenderViewObserver_FetchDocumentMarkup(routing_id(), requestId)); + Send(new RenderViewObserverQt_FetchDocumentMarkup(routing_id(), requestId)); } -void QtRenderViewObserverHost::fetchDocumentInnerText(quint64 requestId) +void RenderViewObserverHostQt::fetchDocumentInnerText(quint64 requestId) { - Send(new QtRenderViewObserver_FetchDocumentInnerText(routing_id(), requestId)); + Send(new RenderViewObserverQt_FetchDocumentInnerText(routing_id(), requestId)); } -bool QtRenderViewObserverHost::OnMessageReceived(const IPC::Message& message) +bool RenderViewObserverHostQt::OnMessageReceived(const IPC::Message& message) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP(QtRenderViewObserverHost, message) - IPC_MESSAGE_HANDLER(QtRenderViewObserverHost_DidFetchDocumentMarkup, + IPC_BEGIN_MESSAGE_MAP(RenderViewObserverHostQt, message) + IPC_MESSAGE_HANDLER(RenderViewObserverHostQt_DidFetchDocumentMarkup, onDidFetchDocumentMarkup) - IPC_MESSAGE_HANDLER(QtRenderViewObserverHost_DidFetchDocumentInnerText, + IPC_MESSAGE_HANDLER(RenderViewObserverHostQt_DidFetchDocumentInnerText, onDidFetchDocumentInnerText) - IPC_MESSAGE_HANDLER(QtRenderViewObserverHost_DidFirstVisuallyNonEmptyLayout, + IPC_MESSAGE_HANDLER(RenderViewObserverHostQt_DidFirstVisuallyNonEmptyLayout, onDidFirstVisuallyNonEmptyLayout) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -76,17 +76,17 @@ bool QtRenderViewObserverHost::OnMessageReceived(const IPC::Message& message) } -void QtRenderViewObserverHost::onDidFetchDocumentMarkup(quint64 requestId, const base::string16& markup) +void RenderViewObserverHostQt::onDidFetchDocumentMarkup(quint64 requestId, const base::string16& markup) { m_adapterClient->didFetchDocumentMarkup(requestId, toQt(markup)); } -void QtRenderViewObserverHost::onDidFetchDocumentInnerText(quint64 requestId, const base::string16& innerText) +void RenderViewObserverHostQt::onDidFetchDocumentInnerText(quint64 requestId, const base::string16& innerText) { m_adapterClient->didFetchDocumentInnerText(requestId, toQt(innerText)); } -void QtRenderViewObserverHost::onDidFirstVisuallyNonEmptyLayout() +void RenderViewObserverHostQt::onDidFirstVisuallyNonEmptyLayout() { RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt*>(web_contents()->GetRenderWidgetHostView()); if (rwhv) diff --git a/src/core/qt_render_view_observer_host.h b/src/core/render_view_observer_host_qt.h index 148fcb9da..2683e5807 100644 --- a/src/core/qt_render_view_observer_host.h +++ b/src/core/render_view_observer_host_qt.h @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QT_RENDER_VIEW_OBSERVER_HOST_H -#define QT_RENDER_VIEW_OBSERVER_HOST_H +#ifndef RENDER_VIEW_OBSERVER_HOST_QT_H +#define RENDER_VIEW_OBSERVER_HOST_QT_H #include "content/public/browser/web_contents_observer.h" @@ -49,10 +49,10 @@ namespace QtWebEngineCore { class WebContentsAdapterClient; -class QtRenderViewObserverHost : public content::WebContentsObserver +class RenderViewObserverHostQt : public content::WebContentsObserver { public: - QtRenderViewObserverHost(content::WebContents*, WebContentsAdapterClient *adapterClient); + RenderViewObserverHostQt(content::WebContents*, WebContentsAdapterClient *adapterClient); void fetchDocumentMarkup(quint64 requestId); void fetchDocumentInnerText(quint64 requestId); @@ -67,4 +67,4 @@ private: } // namespace QtWebEngineCore -#endif // QT_RENDER_VIEW_OBSERVER_HOST_H +#endif // RENDER_VIEW_OBSERVER_HOST_QT_H diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 94b459e74..d2d292ee9 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -186,13 +186,14 @@ static inline int flagsFromModifiers(Qt::KeyboardModifiers modifiers) static uint32 s_eventId = 0; class MotionEventQt : public ui::MotionEvent { public: - MotionEventQt(const QList<QTouchEvent::TouchPoint> &touchPoints, const base::TimeTicks &eventTime, Action action, const Qt::KeyboardModifiers modifiers, int index = -1) + MotionEventQt(const QList<QTouchEvent::TouchPoint> &touchPoints, const base::TimeTicks &eventTime, Action action, const Qt::KeyboardModifiers modifiers, float dpiScale, int index = -1) : touchPoints(touchPoints) , eventTime(eventTime) , action(action) , eventId(++s_eventId) , flags(flagsFromModifiers(modifiers)) , index(index) + , dpiScale(dpiScale) { // ACTION_DOWN and ACTION_UP must be accesssed through pointer_index 0 Q_ASSERT((action != ACTION_DOWN && action != ACTION_UP) || index == 0); @@ -203,8 +204,8 @@ public: virtual int GetActionIndex() const Q_DECL_OVERRIDE { return index; } virtual size_t GetPointerCount() const Q_DECL_OVERRIDE { return touchPoints.size(); } virtual int GetPointerId(size_t pointer_index) const Q_DECL_OVERRIDE { return touchPoints.at(pointer_index).id(); } - virtual float GetX(size_t pointer_index) const Q_DECL_OVERRIDE { return touchPoints.at(pointer_index).pos().x(); } - virtual float GetY(size_t pointer_index) const Q_DECL_OVERRIDE { return touchPoints.at(pointer_index).pos().y(); } + virtual float GetX(size_t pointer_index) const Q_DECL_OVERRIDE { return touchPoints.at(pointer_index).pos().x() / dpiScale; } + virtual float GetY(size_t pointer_index) const Q_DECL_OVERRIDE { return touchPoints.at(pointer_index).pos().y() / dpiScale; } virtual float GetRawX(size_t pointer_index) const Q_DECL_OVERRIDE { return touchPoints.at(pointer_index).screenPos().x(); } virtual float GetRawY(size_t pointer_index) const Q_DECL_OVERRIDE { return touchPoints.at(pointer_index).screenPos().y(); } virtual float GetTouchMajor(size_t pointer_index) const Q_DECL_OVERRIDE @@ -240,6 +241,7 @@ private: const uint32 eventId; int flags; int index; + float dpiScale; }; RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget) @@ -413,12 +415,13 @@ gfx::Rect RenderWidgetHostViewQt::GetViewBounds() const return gfx::BoundingRect(p1, p2); } -void RenderWidgetHostViewQt::SetBackgroundColor(SkColor color) { +void RenderWidgetHostViewQt::SetBackgroundColor(SkColor color) +{ RenderWidgetHostViewBase::SetBackgroundColor(color); // Set the background of the compositor if necessary m_delegate->setClearColor(toQt(color)); // Set the background of the blink::FrameView - m_host->Send(new QtRenderViewObserver_SetBackgroundColor(m_host->GetRoutingID(), color)); + m_host->Send(new RenderViewObserverQt_SetBackgroundColor(m_host->GetRoutingID(), color)); } // Return value indicates whether the mouse is locked successfully or not. @@ -997,7 +1000,7 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) QList<QTouchEvent::TouchPoint> touchPoints = mapTouchPointIds(ev->touchPoints()); if (ev->type() == QEvent::TouchCancel) { - MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::ACTION_CANCEL, ev->modifiers()); + MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::ACTION_CANCEL, ev->modifiers(), dpiScale()); processMotionEvent(cancelEvent); return; } @@ -1030,7 +1033,7 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) continue; } - MotionEventQt motionEvent(touchPoints, eventTimestamp, action, ev->modifiers(), i); + MotionEventQt motionEvent(touchPoints, eventTimestamp, action, ev->modifiers(), dpiScale(), i); processMotionEvent(motionEvent); } } diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 0b8262c76..db50caad8 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -40,6 +40,7 @@ #include "chrome/common/localized_error.h" #include "components/error_page/common/error_page_params.h" #include "components/visitedlink/renderer/visitedlink_slave.h" +#include "components/web_cache/renderer/web_cache_render_process_observer.h" #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_view.h" @@ -53,8 +54,8 @@ #include "content/public/common/web_preferences.h" #include "renderer/web_channel_ipc_transport.h" -#include "renderer/qt_render_frame_observer.h" -#include "renderer/qt_render_view_observer.h" +#include "renderer/render_frame_observer_qt.h" +#include "renderer/render_view_observer_qt.h" #include "renderer/user_script_controller.h" #include "grit/renderer_resources.h" @@ -77,7 +78,9 @@ void ContentRendererClientQt::RenderThreadStarted() content::RenderThread *renderThread = content::RenderThread::Get(); renderThread->RegisterExtension(WebChannelIPCTransport::getV8Extension()); m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave); + m_webCacheObserver.reset(new web_cache::WebCacheRenderProcessObserver()); renderThread->AddObserver(m_visitedLinkSlave.data()); + renderThread->AddObserver(m_webCacheObserver.data()); renderThread->AddObserver(UserScriptController::instance()); // mark qrc as a secure scheme (avoids deprecation warnings) @@ -87,14 +90,14 @@ void ContentRendererClientQt::RenderThreadStarted() void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view) { // RenderViewObservers destroy themselves with their RenderView. - new QtRenderViewObserver(render_view); + new RenderViewObserverQt(render_view, m_webCacheObserver.data()); new WebChannelIPCTransport(render_view); UserScriptController::instance()->renderViewCreated(render_view); } void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_frame) { - new QtWebEngineCore::QtRenderFrameObserver(render_frame); + new QtWebEngineCore::RenderFrameObserverQt(render_frame); } bool ContentRendererClientQt::HasErrorPage(int httpStatusCode, std::string *errorDomain) diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index fab88441f..eb55156ad 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -45,6 +45,10 @@ namespace visitedlink { class VisitedLinkSlave; } +namespace web_cache { +class WebCacheRenderProcessObserver; +} + namespace QtWebEngineCore { class ContentRendererClientQt : public content::ContentRendererClient { @@ -64,6 +68,7 @@ public: private: QScopedPointer<visitedlink::VisitedLinkSlave> m_visitedLinkSlave; + QScopedPointer<web_cache::WebCacheRenderProcessObserver> m_webCacheObserver; }; } // namespace diff --git a/src/core/renderer/qt_render_frame_observer.cpp b/src/core/renderer/render_frame_observer_qt.cpp index 5f06d1e4e..8130cc53a 100644 --- a/src/core/renderer/qt_render_frame_observer.cpp +++ b/src/core/renderer/render_frame_observer_qt.cpp @@ -34,7 +34,7 @@ ** ****************************************************************************/ -#include "qt_render_frame_observer.h" +#include "render_frame_observer_qt.h" #include "content/public/renderer/renderer_ppapi_host.h" #include "ppapi/host/ppapi_host.h" @@ -44,17 +44,17 @@ namespace QtWebEngineCore { -QtRenderFrameObserver::QtRenderFrameObserver(content::RenderFrame* render_frame) +RenderFrameObserverQt::RenderFrameObserverQt(content::RenderFrame* render_frame) : RenderFrameObserver(render_frame) { } -QtRenderFrameObserver::~QtRenderFrameObserver() +RenderFrameObserverQt::~RenderFrameObserverQt() { } #if defined(ENABLE_PLUGINS) -void QtRenderFrameObserver::DidCreatePepperPlugin(content::RendererPpapiHost* host) +void RenderFrameObserverQt::DidCreatePepperPlugin(content::RendererPpapiHost* host) { host->GetPpapiHost()->AddHostFactoryFilter( scoped_ptr<ppapi::host::HostFactory>( diff --git a/src/core/renderer/qt_render_frame_observer.h b/src/core/renderer/render_frame_observer_qt.h index 42f2b7464..4835e442e 100644 --- a/src/core/renderer/qt_render_frame_observer.h +++ b/src/core/renderer/render_frame_observer_qt.h @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QT_RENDER_FRAME_OBSERVER_H -#define QT_RENDER_FRAME_OBSERVER_H +#ifndef RENDER_FRAME_OBSERVER_QT_H +#define RENDER_FRAME_OBSERVER_QT_H #include "base/basictypes.h" #include "base/compiler_specific.h" @@ -48,19 +48,19 @@ class RenderFrame; namespace QtWebEngineCore { -class QtRenderFrameObserver : public content::RenderFrameObserver { +class RenderFrameObserverQt : public content::RenderFrameObserver { public: - explicit QtRenderFrameObserver(content::RenderFrame* render_frame); - ~QtRenderFrameObserver(); + explicit RenderFrameObserverQt(content::RenderFrame* render_frame); + ~RenderFrameObserverQt(); #if defined(ENABLE_PLUGINS) void DidCreatePepperPlugin(content::RendererPpapiHost* host) override; #endif private: - DISALLOW_COPY_AND_ASSIGN(QtRenderFrameObserver); + DISALLOW_COPY_AND_ASSIGN(RenderFrameObserverQt); }; } // namespace QtWebEngineCore -#endif // QT_RENDER_FRAME_OBSERVER_H +#endif // RENDER_FRAME_OBSERVER_QT_H diff --git a/src/core/renderer/qt_render_view_observer.cpp b/src/core/renderer/render_view_observer_qt.cpp index ba91e54ae..47efd07e4 100644 --- a/src/core/renderer/qt_render_view_observer.cpp +++ b/src/core/renderer/render_view_observer_qt.cpp @@ -34,55 +34,65 @@ ** ****************************************************************************/ -#include "renderer/qt_render_view_observer.h" +#include "renderer/render_view_observer_qt.h" #include "common/qt_messages.h" +#include "components/web_cache/renderer/web_cache_render_process_observer.h" #include "content/public/renderer/render_view.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebElement.h" #include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebView.h" -QtRenderViewObserver::QtRenderViewObserver(content::RenderView* render_view) +RenderViewObserverQt::RenderViewObserverQt( + content::RenderView* render_view, + web_cache::WebCacheRenderProcessObserver* web_cache_render_process_observer) : content::RenderViewObserver(render_view) + , m_web_cache_render_process_observer(web_cache_render_process_observer) { } -void QtRenderViewObserver::onFetchDocumentMarkup(quint64 requestId) +void RenderViewObserverQt::onFetchDocumentMarkup(quint64 requestId) { - Send(new QtRenderViewObserverHost_DidFetchDocumentMarkup( + Send(new RenderViewObserverHostQt_DidFetchDocumentMarkup( routing_id(), requestId, render_view()->GetWebView()->mainFrame()->contentAsMarkup())); } -void QtRenderViewObserver::onFetchDocumentInnerText(quint64 requestId) +void RenderViewObserverQt::onFetchDocumentInnerText(quint64 requestId) { - Send(new QtRenderViewObserverHost_DidFetchDocumentInnerText( + Send(new RenderViewObserverHostQt_DidFetchDocumentInnerText( routing_id(), requestId, render_view()->GetWebView()->mainFrame()->contentAsText(std::numeric_limits<std::size_t>::max()))); } -void QtRenderViewObserver::onSetBackgroundColor(quint32 color) +void RenderViewObserverQt::onSetBackgroundColor(quint32 color) { render_view()->GetWebView()->setBaseBackgroundColor(color); } -void QtRenderViewObserver::OnFirstVisuallyNonEmptyLayout() +void RenderViewObserverQt::OnFirstVisuallyNonEmptyLayout() { - Send(new QtRenderViewObserverHost_DidFirstVisuallyNonEmptyLayout(routing_id())); + Send(new RenderViewObserverHostQt_DidFirstVisuallyNonEmptyLayout(routing_id())); } -bool QtRenderViewObserver::OnMessageReceived(const IPC::Message& message) +bool RenderViewObserverQt::OnMessageReceived(const IPC::Message& message) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP(QtRenderViewObserver, message) - IPC_MESSAGE_HANDLER(QtRenderViewObserver_FetchDocumentMarkup, onFetchDocumentMarkup) - IPC_MESSAGE_HANDLER(QtRenderViewObserver_FetchDocumentInnerText, onFetchDocumentInnerText) - IPC_MESSAGE_HANDLER(QtRenderViewObserver_SetBackgroundColor, onSetBackgroundColor) + IPC_BEGIN_MESSAGE_MAP(RenderViewObserverQt, message) + IPC_MESSAGE_HANDLER(RenderViewObserverQt_FetchDocumentMarkup, onFetchDocumentMarkup) + IPC_MESSAGE_HANDLER(RenderViewObserverQt_FetchDocumentInnerText, onFetchDocumentInnerText) + IPC_MESSAGE_HANDLER(RenderViewObserverQt_SetBackgroundColor, onSetBackgroundColor) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } + +void RenderViewObserverQt::Navigate(const GURL &) +{ + if (m_web_cache_render_process_observer) + m_web_cache_render_process_observer->ExecutePendingClearCache(); +} diff --git a/src/core/renderer/qt_render_view_observer.h b/src/core/renderer/render_view_observer_qt.h index 3f7829a92..166dcc9ea 100644 --- a/src/core/renderer/qt_render_view_observer.h +++ b/src/core/renderer/render_view_observer_qt.h @@ -33,16 +33,21 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef QT_RENDER_VIEW_OBSERVER_H -#define QT_RENDER_VIEW_OBSERVER_H +#ifndef RENDER_VIEW_OBSERVER_QT_H +#define RENDER_VIEW_OBSERVER_QT_H #include "content/public/renderer/render_view_observer.h" #include <QtGlobal> -class QtRenderViewObserver : public content::RenderViewObserver { +namespace web_cache { +class WebCacheRenderProcessObserver; +} + +class RenderViewObserverQt : public content::RenderViewObserver { public: - QtRenderViewObserver(content::RenderView* render_view); + RenderViewObserverQt(content::RenderView* render_view, + web_cache::WebCacheRenderProcessObserver* web_cache_render_process_observer); private: void onFetchDocumentMarkup(quint64 requestId); @@ -52,8 +57,11 @@ private: void OnFirstVisuallyNonEmptyLayout() Q_DECL_OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) Q_DECL_OVERRIDE; + virtual void Navigate(const GURL& url) Q_DECL_OVERRIDE; + + web_cache::WebCacheRenderProcessObserver* m_web_cache_render_process_observer; - DISALLOW_COPY_AND_ASSIGN(QtRenderViewObserver); + DISALLOW_COPY_AND_ASSIGN(RenderViewObserverQt); }; -#endif // QT_RENDER_VIEW_OBSERVER_H +#endif // RENDER_VIEW_OBSERVER_QT_H diff --git a/src/core/resources/devtools_discovery_page.html b/src/core/resources/devtools_discovery_page.html index 7aac74932..d37dbfcf4 100644 --- a/src/core/resources/devtools_discovery_page.html +++ b/src/core/resources/devtools_discovery_page.html @@ -3,44 +3,68 @@ <title>QtWebEngine Remote Debugging</title> <style> body { - background-color: rgb(245, 245, 245); + color: #222; font-family: Helvetica, Arial, sans-serif; + margin: 0; text-shadow: rgba(255, 255, 255, 0.496094) 0px 1px 0px; } #caption { - color: black; font-size: 16px; - margin-top: 30px; - margin-bottom: 0px; - margin-left: 70px; + margin-top: 15px; + margin-bottom: 10px; + margin-left: 20px; height: 20px; text-align: left; } #items { - margin-left: 60px; - margin-right: 60px; - -webkit-box-orient: horizontal; - -webkit-box-lines: multiple; + display: flex; + flex-direction: column; + margin: 10px; +} + +.item { + color: #222; + display: flex; + flex-direction: row; + text-decoration: none; + padding: 10px; + -webkit-transition-property: background-color, border-color; + -webkit-transition: background-color 0.15s, 0.15s; + -webkit-transition-delay: 0ms, 0ms; } -.frontend_ref { +.item:not(.connected):hover { + background-color: rgba(242, 242, 242, 1); + border-color: rgba(110, 116, 128, 1); color: black; - text-decoration: initial; } -.text { - background: no-repeat 0; - background-size: 16px; - font-size: 12px; - margin: 4px 0px 0px 4px; +.item.connected:hover { + border-color: rgba(184, 184, 184, 1); + color: rgb(110, 116, 128); +} + +.description { + display: flex; + flex-direction: column; +} + +.title, .subtitle { + font-size: 13px; + margin: 4px 0px 0px 6px; overflow: hidden; - padding: 2px 0px 0px 20px; - text-align: left; - text-overflow: ellipsis; - white-space: nowrap; + padding-left: 20px; } + +.title { + background-repeat: no-repeat; + background-size: 16px; + font-size: 15px; +} + + </style> <script> @@ -74,35 +98,43 @@ function overrideFrontendUrl(item) { } function appendItem(item_object) { - var frontend_ref; + var item_element; if (item_object.devtoolsFrontendUrl) { - frontend_ref = document.createElement('a'); - frontend_ref.href = overrideFrontendUrl(item_object); - frontend_ref.title = item_object.title; + item_element = document.createElement('a'); + item_element.href = overrideFrontendUrl(item_object); + item_element.title = item_object.title; } else { - frontend_ref = document.createElement('div'); - frontend_ref.title = 'The tab already has an active debug session'; + item_element = document.createElement('div'); + item_element.className = 'connected'; + item_element.title = 'The tab already has an active debug session'; } - frontend_ref.className = 'frontend_ref'; + item_element.classList.add('item'); - var text = document.createElement('div'); - text.className = 'text'; - text.innerText = item_object.description || item_object.title; - text.style.cssText = 'background-image:url(' + - item_object.faviconUrl + ')'; - frontend_ref.appendChild(text); + var description = document.createElement('div'); + description.className = 'description'; - var item = document.createElement('p'); - item.appendChild(frontend_ref); + var title = document.createElement('div'); + title.className = 'title'; + title.textContent = item_object.description || item_object.title; + title.style.cssText = 'background-image:url(' + + item_object.faviconUrl + ')'; + description.appendChild(title); - document.getElementById('items').appendChild(item); + var subtitle = document.createElement('div'); + subtitle.className = 'subtitle'; + subtitle.textContent = (item_object.url || '').substring(0, 300); + description.appendChild(subtitle); + + item_element.appendChild(description); + + document.getElementById('items').appendChild(item_element); } </script> </head> <body onload='onLoad()'> <div id='caption'>Inspectable pages</div> + <hr> <div id='items'> </div> - <hr> </body> </html> diff --git a/src/core/stream_video_node.cpp b/src/core/stream_video_node.cpp index a5a6041f3..fdae5fee2 100644 --- a/src/core/stream_video_node.cpp +++ b/src/core/stream_video_node.cpp @@ -38,9 +38,12 @@ #include <QtQuick/qsgtexture.h> +namespace QtWebEngineCore { + class StreamVideoMaterialShader : public QSGMaterialShader { public: + StreamVideoMaterialShader(TextureTarget target) : m_target(target) { } virtual void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial); virtual char const *const *attributeNames() const Q_DECL_OVERRIDE { @@ -55,7 +58,7 @@ public: protected: virtual const char *vertexShader() const Q_DECL_OVERRIDE { // Keep in sync with cc::VertexShaderVideoTransform - const char *shader = + static const char *shader = "attribute highp vec4 a_position;\n" "attribute mediump vec2 a_texCoord;\n" "uniform highp mat4 matrix;\n" @@ -70,7 +73,7 @@ protected: virtual const char *fragmentShader() const Q_DECL_OVERRIDE { // Keep in sync with cc::FragmentShaderRGBATexAlpha - static const char *shader = + static const char *shaderExternal = "#extension GL_OES_EGL_image_external : require\n" "varying mediump vec2 v_texCoord;\n" "uniform samplerExternalOES s_texture;\n" @@ -79,7 +82,19 @@ protected: " lowp vec4 texColor = texture2D(s_texture, v_texCoord);\n" " gl_FragColor = texColor * alpha;\n" "}"; - return shader; + static const char *shader2DRect = + "#extension GL_ARB_texture_rectangle : require\n" + "varying mediump vec2 v_texCoord;\n" + "uniform sampler2DRect s_texture;\n" + "uniform lowp float alpha;\n" + "void main() {\n" + " lowp vec4 texColor = texture2DRect(s_texture, v_texCoord);\n" + " gl_FragColor = texColor * alpha;\n" + "}"; + if (m_target == ExternalTarget) + return shaderExternal; + else + return shader2DRect; } virtual void initialize() { @@ -93,6 +108,7 @@ protected: int m_id_texMatrix; int m_id_sTexture; int m_id_opacity; + TextureTarget m_target; }; void StreamVideoMaterialShader::updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) @@ -113,31 +129,38 @@ void StreamVideoMaterialShader::updateState(const RenderState &state, QSGMateria program()->setUniformValue(m_id_texMatrix, mat->m_texMatrix); } -StreamVideoMaterial::StreamVideoMaterial(QSGTexture *texture) +StreamVideoMaterial::StreamVideoMaterial(QSGTexture *texture, TextureTarget target) : m_texture(texture) + , m_target(target) { } QSGMaterialShader *StreamVideoMaterial::createShader() const { - return new StreamVideoMaterialShader; + return new StreamVideoMaterialShader(m_target); } -StreamVideoNode::StreamVideoNode(QSGTexture *texture) +StreamVideoNode::StreamVideoNode(QSGTexture *texture, bool flip, TextureTarget target) : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) + , m_flip(flip) { setGeometry(&m_geometry); setFlag(QSGNode::OwnsMaterial); - m_material = new StreamVideoMaterial(texture); + m_material = new StreamVideoMaterial(texture, target); setMaterial(m_material); } void StreamVideoNode::setRect(const QRectF &rect) { - QSGGeometry::updateTexturedRectGeometry(geometry(), rect, QRectF(0, 0, 1, 1)); + if (m_flip) + QSGGeometry::updateTexturedRectGeometry(geometry(), rect, QRectF(0, 1, 1, -1)); + else + QSGGeometry::updateTexturedRectGeometry(geometry(), rect, QRectF(0, 0, 1, 1)); } void StreamVideoNode::setTextureMatrix(const QMatrix4x4 &matrix) { m_material->m_texMatrix = matrix; } + +} // namespace diff --git a/src/core/stream_video_node.h b/src/core/stream_video_node.h index f808bb609..92c640811 100644 --- a/src/core/stream_video_node.h +++ b/src/core/stream_video_node.h @@ -40,19 +40,22 @@ #include <QtQuick/qsgmaterial.h> #include <QtQuick/qsgnode.h> -QT_BEGIN_NAMESPACE -class QSGTexture; -QT_END_NAMESPACE +QT_FORWARD_DECLARE_CLASS(QSGTexture) + +namespace QtWebEngineCore { // These classes duplicate, QtQuick style, the logic of GLRenderer::DrawStreamVideoQuad. // Their behavior should stay as close as possible to GLRenderer. +enum TextureTarget { ExternalTarget, RectangleTarget }; + class StreamVideoMaterial : public QSGMaterial { public: - StreamVideoMaterial(QSGTexture *texture); + StreamVideoMaterial(QSGTexture *texture, TextureTarget target); - virtual QSGMaterialType *type() const Q_DECL_OVERRIDE{ + virtual QSGMaterialType *type() const Q_DECL_OVERRIDE + { static QSGMaterialType theType; return &theType; } @@ -61,18 +64,22 @@ public: QSGTexture *m_texture; QMatrix4x4 m_texMatrix; + TextureTarget m_target; }; class StreamVideoNode : public QSGGeometryNode { public: - StreamVideoNode(QSGTexture *texture); + StreamVideoNode(QSGTexture *texture, bool flip, TextureTarget target); void setRect(const QRectF &rect); void setTextureMatrix(const QMatrix4x4 &matrix); private: QSGGeometry m_geometry; + bool m_flip; StreamVideoMaterial *m_material; }; +} // namespace + #endif // STREAM_VIDEO_NODE_H diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 8d3345d1c..84c4e50f3 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -45,8 +45,8 @@ #include "browser_context_adapter.h" #include "browser_context_qt.h" #include "media_capture_devices_dispatcher.h" -#include "qt_render_view_observer_host.h" #include "qwebenginecallback_p.h" +#include "render_view_observer_host_qt.h" #include "type_conversion.h" #include "web_channel_ipc_transport_host.h" #include "web_contents_adapter_client.h" @@ -385,7 +385,7 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient) // Create and attach observers to the WebContents. d->webContentsDelegate.reset(new WebContentsDelegateQt(d->webContents.get(), adapterClient)); - d->renderViewObserverHost.reset(new QtRenderViewObserverHost(d->webContents.get(), adapterClient)); + d->renderViewObserverHost.reset(new RenderViewObserverHostQt(d->webContents.get(), adapterClient)); // Let the WebContent's view know about the WebContentsAdapterClient. WebContentsViewQt* contentsView = static_cast<WebContentsViewQt*>(static_cast<content::WebContentsImpl*>(d->webContents.get())->GetView()); diff --git a/src/core/web_contents_adapter_p.h b/src/core/web_contents_adapter_p.h index 9b4128749..093b9059d 100644 --- a/src/core/web_contents_adapter_p.h +++ b/src/core/web_contents_adapter_p.h @@ -60,7 +60,7 @@ QT_FORWARD_DECLARE_CLASS(QWebChannel) namespace QtWebEngineCore { class BrowserContextAdapter; -class QtRenderViewObserverHost; +class RenderViewObserverHostQt; class UserScriptControllerHost; class WebChannelIPCTransportHost; class WebContentsAdapterClient; @@ -75,7 +75,7 @@ public: QExplicitlySharedDataPointer<BrowserContextAdapter> browserContextAdapter; scoped_ptr<content::WebContents> webContents; scoped_ptr<WebContentsDelegateQt> webContentsDelegate; - scoped_ptr<QtRenderViewObserverHost> renderViewObserverHost; + scoped_ptr<RenderViewObserverHostQt> renderViewObserverHost; scoped_ptr<WebChannelIPCTransportHost> webChannelTransport; QWebChannel *webChannel; WebContentsAdapterClient *adapterClient; diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 1f789161a..1897664e3 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -51,12 +51,14 @@ #include "web_engine_settings.h" #include "web_engine_visited_links_manager.h" +#include "components/web_cache/browser/web_cache_manager.h" #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/public/browser/favicon_status.h" #include "content/public/browser/invalidate_type.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_frame_host.h" +#include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/favicon_url.h" #include "content/public/common/file_chooser_params.h" @@ -315,6 +317,11 @@ void WebContentsDelegateQt::DidNavigateAnyFrame(content::RenderFrameHost* render m_viewClient->browserContextAdapter()->visitedLinksManager()->addUrl(params.url); } +void WebContentsDelegateQt::WasShown() +{ + web_cache::WebCacheManager::GetInstance()->ObserveActivity(web_contents()->GetRenderProcessHost()->GetID()); +} + void WebContentsDelegateQt::RequestToLockMouse(content::WebContents *web_contents, bool user_gesture, bool last_unlocked_by_target) { Q_UNUSED(user_gesture); diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index abdf75fe5..d3075cfbf 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -44,6 +44,7 @@ #include "base/callback.h" #include "javascript_dialog_manager_qt.h" +#include <QtCore/qvector.h> #include <QtCore/qcompilerdetection.h> QT_FORWARD_DECLARE_CLASS(CertificateErrorController) @@ -104,6 +105,7 @@ public: virtual void DidFinishLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url) Q_DECL_OVERRIDE; virtual void DidUpdateFaviconURL(const std::vector<content::FaviconURL> &candidates) Q_DECL_OVERRIDE; virtual void DidNavigateAnyFrame(content::RenderFrameHost *render_frame_host, const content::LoadCommittedDetails &details, const content::FrameNavigateParams ¶ms) Q_DECL_OVERRIDE; + virtual void WasShown() Q_DECL_OVERRIDE; void overrideWebPreferences(content::WebContents *, content::WebPreferences*); void allowCertificateError(const QSharedPointer<CertificateErrorController> &) ; @@ -116,7 +118,7 @@ private: WebContentsAdapterClient *m_viewClient; QString m_lastSearchedString; int m_lastReceivedFindReply; - QList<int64> m_loadingErrorFrameList; + QVector<int64> m_loadingErrorFrameList; }; } // namespace QtWebEngineCore diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 5be35b348..4d1cbf3d4 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -200,7 +200,7 @@ WebEngineContext::WebEngineContext() , m_browserRunner(content::BrowserMainRunner::Create()) , m_globalQObject(new QObject()) { - QList<QByteArray> args; + QVector<QByteArray> args; Q_FOREACH (const QString& arg, QCoreApplication::arguments()) args << arg.toUtf8(); diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index c8d1cc27f..88d8a0c5c 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -46,6 +46,10 @@ namespace QtWebEngineCore { +QHash<WebEngineSettings::Attribute, bool> WebEngineSettings::m_defaultAttributes; +QHash<WebEngineSettings::FontFamily, QString> WebEngineSettings::m_defaultFontFamilies; +QHash<WebEngineSettings::FontSize, int> WebEngineSettings::m_defaultFontSizes; + static const int batchTimerTimeout = 0; class BatchTimer : public QTimer { @@ -132,9 +136,12 @@ bool WebEngineSettings::testAttribute(WebEngineSettings::Attribute attr) const void WebEngineSettings::resetAttribute(WebEngineSettings::Attribute attr) { - if (!parentSettings) // FIXME: Set initial defaults. - return; - m_attributes.remove(attr); + if (!parentSettings) { + Q_ASSERT(m_defaultAttributes.contains(attr)); + m_attributes.insert(attr, m_defaultAttributes.value(attr)); + } else { + m_attributes.remove(attr); + } scheduleApplyRecursively(); } @@ -155,9 +162,12 @@ QString WebEngineSettings::fontFamily(WebEngineSettings::FontFamily which) void WebEngineSettings::resetFontFamily(WebEngineSettings::FontFamily which) { - if (!parentSettings) // FIXME: Set initial defaults. - return; - m_fontFamilies.remove(which); + if (!parentSettings) { + Q_ASSERT(m_defaultFontFamilies.contains(which)); + m_fontFamilies.insert(which, m_defaultFontFamilies.value(which)); + } else { + m_fontFamilies.remove(which); + } scheduleApplyRecursively(); } @@ -178,9 +188,12 @@ int WebEngineSettings::fontSize(WebEngineSettings::FontSize type) const void WebEngineSettings::resetFontSize(WebEngineSettings::FontSize type) { - if (!parentSettings) // FIXME: Set initial defaults. - return; - m_fontSizes.remove(type); + if (!parentSettings) { + Q_ASSERT(m_defaultFontSizes.contains(type)); + m_fontSizes.insert(type, m_defaultFontSizes.value(type)); + } else { + m_fontSizes.remove(type); + } scheduleApplyRecursively(); } @@ -199,46 +212,55 @@ QString WebEngineSettings::defaultTextEncoding() const void WebEngineSettings::initDefaults(bool offTheRecord) { - // Initialize the default settings. - m_attributes.insert(AutoLoadImages, true); - m_attributes.insert(JavascriptEnabled, true); - m_attributes.insert(JavascriptCanOpenWindows, true); - m_attributes.insert(JavascriptCanAccessClipboard, false); - m_attributes.insert(LinksIncludedInFocusChain, true); - m_attributes.insert(LocalStorageEnabled, !offTheRecord); - m_attributes.insert(LocalContentCanAccessRemoteUrls, false); - m_attributes.insert(XSSAuditingEnabled, false); - m_attributes.insert(SpatialNavigationEnabled, false); - m_attributes.insert(LocalContentCanAccessFileUrls, true); - m_attributes.insert(HyperlinkAuditingEnabled, false); - m_attributes.insert(ScrollAnimatorEnabled, false); - m_attributes.insert(ErrorPageEnabled, true); - m_attributes.insert(PluginsEnabled, false); - m_attributes.insert(FullScreenSupportEnabled, false); - m_attributes.insert(ScreenCaptureEnabled, false); - - // Default fonts - QFont defaultFont; - defaultFont.setStyleHint(QFont::Serif); - m_fontFamilies.insert(StandardFont, defaultFont.defaultFamily()); - m_fontFamilies.insert(SerifFont, defaultFont.defaultFamily()); - - defaultFont.setStyleHint(QFont::Fantasy); - m_fontFamilies.insert(FantasyFont, defaultFont.defaultFamily()); - - defaultFont.setStyleHint(QFont::Cursive); - m_fontFamilies.insert(CursiveFont, defaultFont.defaultFamily()); - - defaultFont.setStyleHint(QFont::SansSerif); - m_fontFamilies.insert(SansSerifFont, defaultFont.defaultFamily()); - - defaultFont.setStyleHint(QFont::Monospace); - m_fontFamilies.insert(FixedFont, defaultFont.defaultFamily()); - - m_fontSizes.insert(MinimumFontSize, 0); - m_fontSizes.insert(MinimumLogicalFontSize, 6); - m_fontSizes.insert(DefaultFixedFontSize, 13); - m_fontSizes.insert(DefaultFontSize, 16); + if (m_defaultAttributes.isEmpty()) { + // Initialize the default settings. + m_defaultAttributes.insert(AutoLoadImages, true); + m_defaultAttributes.insert(JavascriptEnabled, true); + m_defaultAttributes.insert(JavascriptCanOpenWindows, true); + m_defaultAttributes.insert(JavascriptCanAccessClipboard, false); + m_defaultAttributes.insert(LinksIncludedInFocusChain, true); + m_defaultAttributes.insert(LocalStorageEnabled, !offTheRecord); + m_defaultAttributes.insert(LocalContentCanAccessRemoteUrls, false); + m_defaultAttributes.insert(XSSAuditingEnabled, false); + m_defaultAttributes.insert(SpatialNavigationEnabled, false); + m_defaultAttributes.insert(LocalContentCanAccessFileUrls, true); + m_defaultAttributes.insert(HyperlinkAuditingEnabled, false); + m_defaultAttributes.insert(ScrollAnimatorEnabled, false); + m_defaultAttributes.insert(ErrorPageEnabled, true); + m_defaultAttributes.insert(PluginsEnabled, false); + m_defaultAttributes.insert(FullScreenSupportEnabled, false); + m_defaultAttributes.insert(ScreenCaptureEnabled, false); + } + m_attributes = m_defaultAttributes; + + if (m_defaultFontFamilies.isEmpty()) { + // Default fonts + QFont defaultFont; + defaultFont.setStyleHint(QFont::Serif); + m_defaultFontFamilies.insert(StandardFont, defaultFont.defaultFamily()); + m_defaultFontFamilies.insert(SerifFont, defaultFont.defaultFamily()); + + defaultFont.setStyleHint(QFont::Fantasy); + m_defaultFontFamilies.insert(FantasyFont, defaultFont.defaultFamily()); + + defaultFont.setStyleHint(QFont::Cursive); + m_defaultFontFamilies.insert(CursiveFont, defaultFont.defaultFamily()); + + defaultFont.setStyleHint(QFont::SansSerif); + m_defaultFontFamilies.insert(SansSerifFont, defaultFont.defaultFamily()); + + defaultFont.setStyleHint(QFont::Monospace); + m_defaultFontFamilies.insert(FixedFont, defaultFont.defaultFamily()); + } + m_fontFamilies = m_defaultFontFamilies; + + if (m_defaultFontSizes.isEmpty()) { + m_defaultFontSizes.insert(MinimumFontSize, 0); + m_defaultFontSizes.insert(MinimumLogicalFontSize, 6); + m_defaultFontSizes.insert(DefaultFixedFontSize, 13); + m_defaultFontSizes.insert(DefaultFontSize, 16); + } + m_fontSizes = m_defaultFontSizes; m_defaultEncoding = QStringLiteral("ISO-8859-1"); } diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h index d850bd1ef..4104ec67c 100644 --- a/src/core/web_engine_settings.h +++ b/src/core/web_engine_settings.h @@ -137,6 +137,10 @@ private: WebEngineSettings *parentSettings; QSet<WebEngineSettings *> childSettings; + static QHash<Attribute, bool> m_defaultAttributes; + static QHash<FontFamily, QString> m_defaultFontFamilies; + static QHash<FontSize, int> m_defaultFontSizes; + friend class BatchTimer; friend class WebContentsAdapter; }; diff --git a/src/core/yuv_video_node.cpp b/src/core/yuv_video_node.cpp index 815ea7d51..7deeb5802 100644 --- a/src/core/yuv_video_node.cpp +++ b/src/core/yuv_video_node.cpp @@ -40,6 +40,8 @@ #include <QtGui/qopenglfunctions.h> #include <QtQuick/qsgtexture.h> +namespace QtWebEngineCore { + class YUVVideoMaterialShader : public QSGMaterialShader { public: @@ -369,3 +371,5 @@ void YUVVideoNode::setRect(const QRectF &rect) { QSGGeometry::updateTexturedRectGeometry(geometry(), rect, QRectF(0, 0, 1, 1)); } + +} // namespace diff --git a/src/core/yuv_video_node.h b/src/core/yuv_video_node.h index 457c2c7fe..5b13879d3 100644 --- a/src/core/yuv_video_node.h +++ b/src/core/yuv_video_node.h @@ -40,9 +40,9 @@ #include <QtQuick/qsgmaterial.h> #include <QtQuick/qsgnode.h> -QT_BEGIN_NAMESPACE -class QSGTexture; -QT_END_NAMESPACE +QT_FORWARD_DECLARE_CLASS(QSGTexture) + +namespace QtWebEngineCore { // These classes duplicate, QtQuick style, the logic of GLRenderer::DrawYUVVideoQuad. // Their behavior should stay as close as possible to GLRenderer. @@ -59,7 +59,8 @@ public: const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize, ColorSpace colorspace); - virtual QSGMaterialType *type() const Q_DECL_OVERRIDE { + virtual QSGMaterialType *type() const Q_DECL_OVERRIDE + { static QSGMaterialType theType; return &theType; } @@ -85,7 +86,8 @@ public: const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize, ColorSpace colorspace); - virtual QSGMaterialType *type() const Q_DECL_OVERRIDE{ + virtual QSGMaterialType *type() const Q_DECL_OVERRIDE + { static QSGMaterialType theType; return &theType; } @@ -109,4 +111,6 @@ private: YUVVideoMaterial *m_material; }; +} // namespace + #endif // YUV_VIDEO_NODE_H diff --git a/src/process/main.cpp b/src/process/main.cpp index 446465ef7..8328c0022 100644 --- a/src/process/main.cpp +++ b/src/process/main.cpp @@ -146,8 +146,16 @@ int stat64_proxy(const char *path, struct stat64 *buf) #endif #endif // defined(OS_LINUX) +#ifdef Q_OS_WIN +void initDpiAwareness(); +#endif // defined(Q_OS_WIN) + int main(int argc, const char **argv) { +#ifdef Q_OS_WIN + initDpiAwareness(); +#endif + // QCoreApplication needs a non-const pointer, while the // ContentMain in Chromium needs the pointer to be const. QCoreApplication qtApplication(argc, const_cast<char**>(argv)); diff --git a/src/process/process.pro b/src/process/process.pro index 7bf06a376..6174e53bf 100644 --- a/src/process/process.pro +++ b/src/process/process.pro @@ -8,8 +8,23 @@ load(qt_build_paths) contains(QT_CONFIG, qt_framework) { # Deploy the QtWebEngineProcess app bundle into the QtWebEngineCore framework. DESTDIR = $$MODULE_BASE_OUTDIR/lib/QtWebEngineCore.framework/Versions/5/Helpers - + # FIXME: remove the following workaround with proper rpath handling or + # patching of the installed QtWebEngineProcess binary. + # Since QtWebEngineCore is now built as a framework, we need to pull + # in and fixup its dependencies as well. QT += webenginecore + QMAKE_POST_LINK = \ + "xcrun install_name_tool -change " \ + "`xcrun otool -X -L $(TARGET) | grep QtWebEngineCore | cut -d ' ' -f 1` " \ + "@executable_path/../../../../QtWebEngineCore " \ + "$(TARGET); " + linked_frameworks = QtQuick QtQml QtNetwork QtCore QtGui QtWebChannel + for (current_framework, linked_frameworks) { + QMAKE_POST_LINK += "xcrun install_name_tool -change " \ + "`xcrun otool -X -L $(TARGET) | grep $${current_framework} | cut -d ' ' -f 1` " \ + "@executable_path/../../../../../../../$${current_framework}.framework/$${current_framework} " \ + "$(TARGET);" + } } else { CONFIG -= app_bundle win32: DESTDIR = $$MODULE_BASE_OUTDIR/bin @@ -24,6 +39,11 @@ INCLUDEPATH += ../core SOURCES = main.cpp +win32 { + SOURCES += \ + support_win.cpp +} + contains(QT_CONFIG, qt_framework) { target.path = $$[QT_INSTALL_LIBS]/QtWebEngineCore.framework/Versions/5/Helpers } else { diff --git a/src/process/support_win.cpp b/src/process/support_win.cpp new file mode 100644 index 000000000..4ccd51627 --- /dev/null +++ b/src/process/support_win.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qlibrary.h> +#include <qsysinfo.h> +#include <qt_windows.h> +#include <Tlhelp32.h> + +class User32DLL { +public: + User32DLL() + : setProcessDPIAware(0) + { + library.setFileName(QStringLiteral("User32")); + if (!library.load()) + return; + setProcessDPIAware = (SetProcessDPIAware)library.resolve("SetProcessDPIAware"); + } + + bool isValid() const + { + return setProcessDPIAware; + } + + typedef BOOL (WINAPI *SetProcessDPIAware)(); + + // Windows Vista onwards + SetProcessDPIAware setProcessDPIAware; + +private: + QLibrary library; +}; + +// This must match PROCESS_DPI_AWARENESS in ShellScalingApi.h +enum DpiAwareness { + PROCESS_PER_UNAWARE = 0, + PROCESS_PER_SYSTEM_DPI_AWARE = 1, + PROCESS_PER_MONITOR_DPI_AWARE = 2 +}; + +// Shell scaling library (Windows 8.1 onwards) +class ShcoreDLL { +public: + ShcoreDLL() + : getProcessDpiAwareness(0), setProcessDpiAwareness(0) + { + if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS8_1) + return; + library.setFileName(QStringLiteral("SHCore")); + if (!library.load()) + return; + getProcessDpiAwareness = (GetProcessDpiAwareness)library.resolve("GetProcessDpiAwareness"); + setProcessDpiAwareness = (SetProcessDpiAwareness)library.resolve("SetProcessDpiAwareness"); + } + + bool isValid() const + { + return getProcessDpiAwareness && setProcessDpiAwareness; + } + + typedef HRESULT (WINAPI *GetProcessDpiAwareness)(HANDLE, DpiAwareness *); + typedef HRESULT (WINAPI *SetProcessDpiAwareness)(DpiAwareness); + + GetProcessDpiAwareness getProcessDpiAwareness; + SetProcessDpiAwareness setProcessDpiAwareness; + +private: + QLibrary library; +}; + + +static DWORD getParentProcessId() +{ + HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if (hSnapshot == INVALID_HANDLE_VALUE) { + qErrnoWarning(GetLastError(), "CreateToolhelp32Snapshot failed."); + return NULL; + } + + PROCESSENTRY32 pe = {0}; + pe.dwSize = sizeof(PROCESSENTRY32); + + if (!Process32First(hSnapshot, &pe)) { + qWarning("Cannot retrieve parent process handle."); + return NULL; + } + + DWORD parentPid = NULL; + const DWORD pid = GetCurrentProcessId(); + do { + if (pe.th32ProcessID == pid) { + parentPid = pe.th32ParentProcessID; + break; + } + } while (Process32Next(hSnapshot, &pe)); + CloseHandle(hSnapshot); + return parentPid; +} + +void initDpiAwareness() +{ + ShcoreDLL shcore; + if (shcore.isValid()) { + DpiAwareness dpiAwareness = PROCESS_PER_MONITOR_DPI_AWARE; + const DWORD pid = getParentProcessId(); + if (pid) { + HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); + DpiAwareness parentDpiAwareness; + HRESULT hr = shcore.getProcessDpiAwareness(hProcess, &parentDpiAwareness); + CloseHandle(hProcess); + if (hr == S_OK) + dpiAwareness = parentDpiAwareness; + } + if (shcore.setProcessDpiAwareness(dpiAwareness) != S_OK) + qErrnoWarning(GetLastError(), "SetProcessDPIAwareness failed."); + } else { + // Fallback. Use SetProcessDPIAware unconditionally. + User32DLL user32; + if (user32.isValid()) + user32.setProcessDPIAware(); + } +} diff --git a/src/webengine/api/qquickwebenginecertificateerror_p.h b/src/webengine/api/qquickwebenginecertificateerror_p.h index 6f54528d4..7deeac932 100644 --- a/src/webengine/api/qquickwebenginecertificateerror_p.h +++ b/src/webengine/api/qquickwebenginecertificateerror_p.h @@ -62,7 +62,6 @@ class Q_WEBENGINE_EXPORT QQuickWebEngineCertificateError : public QObject { Q_PROPERTY(Error error READ error) Q_PROPERTY(QString description READ description) Q_PROPERTY(bool overridable READ overridable) - Q_ENUMS(Error) public: @@ -82,6 +81,7 @@ public: CertificateWeakKey = -211, CertificateNameConstraintViolation = -212, }; + Q_ENUM(Error) QQuickWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller, QObject *parent = 0); ~QQuickWebEngineCertificateError(); diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h index 9a30eb4ca..d0be2f99a 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p.h @@ -69,7 +69,7 @@ public: DownloadCancelled, DownloadInterrupted }; - Q_ENUMS(DownloadState) + Q_ENUM(DownloadState) Q_PROPERTY(quint32 id READ id CONSTANT FINAL) Q_PROPERTY(DownloadState state READ state NOTIFY stateChanged) diff --git a/src/webengine/api/qquickwebenginenewviewrequest.cpp b/src/webengine/api/qquickwebenginenewviewrequest.cpp index 893df7f46..6e20c0a46 100644 --- a/src/webengine/api/qquickwebenginenewviewrequest.cpp +++ b/src/webengine/api/qquickwebenginenewviewrequest.cpp @@ -69,7 +69,7 @@ QQuickWebEngineView::NewViewDestination QQuickWebEngineNewViewRequest::destinati } /*! - \qmlproperty bool WebEngineNewViewRequest::isUserInitiated + \qmlproperty bool WebEngineNewViewRequest::userInitiated Whether this window request was directly triggered as the result of a keyboard or mouse event. Use this property to block possibly unwanted \e popups. diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index b4e0d173c..1ed15aec2 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -67,8 +67,6 @@ class QWebEngineCookieStoreClient; class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineProfile : public QObject { Q_OBJECT - Q_ENUMS(HttpCacheType); - Q_ENUMS(PersistentCookiesPolicy); Q_PROPERTY(QString storageName READ storageName WRITE setStorageName NOTIFY storageNameChanged FINAL) Q_PROPERTY(bool offTheRecord READ isOffTheRecord WRITE setOffTheRecord NOTIFY offTheRecordChanged FINAL) Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY persistentStoragePathChanged FINAL) @@ -86,12 +84,14 @@ public: MemoryHttpCache, DiskHttpCache }; + Q_ENUM(HttpCacheType) enum PersistentCookiesPolicy { NoPersistentCookies, AllowPersistentCookies, ForcePersistentCookies }; + Q_ENUM(PersistentCookiesPolicy) QString storageName() const; void setStorageName(const QString &name); diff --git a/src/webengine/api/qquickwebenginescript_p.h b/src/webengine/api/qquickwebenginescript_p.h index de91134ef..c9d6f5d26 100644 --- a/src/webengine/api/qquickwebenginescript_p.h +++ b/src/webengine/api/qquickwebenginescript_p.h @@ -59,8 +59,6 @@ class QQuickWebEngineView; class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineScript : public QObject { Q_OBJECT - Q_ENUMS(InjectionPoint) - Q_ENUMS(ScriptWorldId) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QUrl sourceUrl READ sourceUrl WRITE setSourceUrl NOTIFY sourceUrlChanged) Q_PROPERTY(QString sourceCode READ sourceCode WRITE setSourceCode NOTIFY sourceCodeChanged) @@ -75,12 +73,14 @@ public: DocumentReady, DocumentCreation }; + Q_ENUM(InjectionPoint) enum ScriptWorldId { MainWorld = 0, ApplicationWorld, UserWorld }; + Q_ENUM(ScriptWorldId) QQuickWebEngineScript(); ~QQuickWebEngineScript(); diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h index e82ec6d48..c08a5d897 100644 --- a/src/webengine/api/qquickwebenginesettings_p.h +++ b/src/webengine/api/qquickwebenginesettings_p.h @@ -72,7 +72,8 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject { Q_PROPERTY(bool hyperlinkAuditingEnabled READ hyperlinkAuditingEnabled WRITE setHyperlinkAuditingEnabled NOTIFY hyperlinkAuditingEnabledChanged) Q_PROPERTY(bool errorPageEnabled READ errorPageEnabled WRITE setErrorPageEnabled NOTIFY errorPageEnabledChanged) Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled NOTIFY pluginsEnabledChanged) - Q_PROPERTY(bool fullScreenSupportEnabled READ fullScreenSupportEnabled WRITE setFullScreenSupportEnabled NOTIFY fullScreenSupportEnabledChanged REVISION 1) + // FIXME(QTBUG-40043): Mark fullScreenSupportEnabled with REVISION 1 + Q_PROPERTY(bool fullScreenSupportEnabled READ fullScreenSupportEnabled WRITE setFullScreenSupportEnabled NOTIFY fullScreenSupportEnabledChanged) // FIXME: add back REVISION when QTBUG-40043 has been fixed. Q_PROPERTY(bool screenCaptureEnabled READ screenCaptureEnabled WRITE setScreenCaptureEnabled NOTIFY screenCaptureEnabledChanged /* REVISION 2 */) Q_PROPERTY(QString defaultTextEncoding READ defaultTextEncoding WRITE setDefaultTextEncoding NOTIFY defaultTextEncodingChanged) @@ -125,7 +126,8 @@ signals: void hyperlinkAuditingEnabledChanged(); void errorPageEnabledChanged(); void pluginsEnabledChanged(); - Q_REVISION(1) void fullScreenSupportEnabledChanged(); + // FIXME(QTBUG-40043): Mark fullScreenSupportEnabledChanged with Q_REVISION(1) + void fullScreenSupportEnabledChanged(); // FIXME: add back Q_REVISION when QTBUG-40043 has been fixed. void screenCaptureEnabledChanged(); void defaultTextEncodingChanged(); diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index aa450003c..f266fdce6 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -67,6 +67,7 @@ #include <QClipboard> #include <QGuiApplication> +#include <QLoggingCategory> #include <QMimeData> #include <QQmlComponent> #include <QQmlContext> @@ -534,7 +535,29 @@ bool QQuickWebEngineViewPrivate::isFullScreenMode() const void QQuickWebEngineViewPrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) { Q_Q(QQuickWebEngineView); - Q_EMIT q->javaScriptConsoleMessage(static_cast<QQuickWebEngineView::JavaScriptConsoleMessageLevel>(level), message, lineNumber, sourceID); + if (q->receivers(SIGNAL(javaScriptConsoleMessage(JavaScriptConsoleMessageLevel,QString,int,QString))) > 0) { + Q_EMIT q->javaScriptConsoleMessage(static_cast<QQuickWebEngineView::JavaScriptConsoleMessageLevel>(level), message, lineNumber, sourceID); + return; + } + + static QLoggingCategory loggingCategory("js", QtWarningMsg); + const QByteArray file = sourceID.toUtf8(); + QMessageLogger logger(file.constData(), lineNumber, nullptr, loggingCategory.categoryName()); + + switch (level) { + case JavaScriptConsoleMessageLevel::Info: + if (loggingCategory.isInfoEnabled()) + logger.info().noquote() << message; + break; + case JavaScriptConsoleMessageLevel::Warning: + if (loggingCategory.isWarningEnabled()) + logger.warning().noquote() << message; + break; + case JavaScriptConsoleMessageLevel::Error: + if (loggingCategory.isCriticalEnabled()) + logger.critical().noquote() << message; + break; + } } void QQuickWebEngineViewPrivate::authenticationRequired(QSharedPointer<AuthenticationDialogController> controller) @@ -656,11 +679,25 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent } Q_Q(QQuickWebEngineView); + + // memorize what webChannel we had for the previous adapter + QQmlWebChannel *qmlWebChannel = NULL; + if (adapter) + qmlWebChannel = qobject_cast<QQmlWebChannel *>(adapter->webChannel()); + // This throws away the WebContentsAdapter that has been used until now. // All its states, particularly the loading URL, are replaced by the adopted WebContentsAdapter. adapter = webContents; adapter->initialize(this); + // associate the webChannel with the new adapter + if (qmlWebChannel) + adapter->setWebChannel(qmlWebChannel); + + // re-bind the userscrips to the new adapter + Q_FOREACH (QQuickWebEngineScript *script, m_userScripts) + script->d_func()->bind(browserContextAdapter()->userScriptController(), adapter.data()); + // Emit signals for values that might be different from the previous WebContentsAdapter. emit q->titleChanged(); emit q->urlChanged(); @@ -1454,5 +1491,3 @@ void QQuickWebEngineViewport::setDevicePixelRatio(qreal devicePixelRatio) QT_END_NAMESPACE -#include "moc_qquickwebengineview_p.cpp" -#include "moc_qquickwebengineview_p_p.cpp" diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index a17c7bd43..4c4192b4c 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -115,16 +115,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport FINAL) #endif - Q_ENUMS(NavigationRequestAction); - Q_ENUMS(NavigationType); - Q_ENUMS(LoadStatus); - Q_ENUMS(ErrorDomain); - Q_ENUMS(NewViewDestination); - Q_ENUMS(Feature); - Q_ENUMS(JavaScriptConsoleMessageLevel); - Q_ENUMS(RenderProcessTerminationStatus); Q_FLAGS(FindFlags); - Q_ENUMS(WebAction); public: QQuickWebEngineView(QQuickItem *parent = 0); @@ -155,6 +146,7 @@ public: // we can expose extra actions in experimental. IgnoreRequest = 0xFF }; + Q_ENUM(NavigationRequestAction) // must match WebContentsAdapterClient::NavigationType enum NavigationType { @@ -165,6 +157,7 @@ public: ReloadNavigation, OtherNavigation }; + Q_ENUM(NavigationType) enum LoadStatus { LoadStartedStatus, @@ -172,6 +165,7 @@ public: LoadSucceededStatus, LoadFailedStatus }; + Q_ENUM(LoadStatus) enum ErrorDomain { NoErrorDomain, @@ -182,6 +176,7 @@ public: FtpErrorDomain, DnsErrorDomain }; + Q_ENUM(ErrorDomain) enum NewViewDestination { NewViewInWindow, @@ -189,6 +184,7 @@ public: NewViewInDialog, NewViewInBackgroundTab }; + Q_ENUM(NewViewDestination) enum Feature { MediaAudioCapture, @@ -196,6 +192,7 @@ public: MediaAudioVideoCapture, Geolocation }; + Q_ENUM(Feature) enum WebAction { NoWebAction = - 1, @@ -239,6 +236,7 @@ public: WebActionCount }; + Q_ENUM(WebAction) // must match WebContentsAdapterClient::JavaScriptConsoleMessageLevel enum JavaScriptConsoleMessageLevel { @@ -246,6 +244,7 @@ public: WarningMessageLevel, ErrorMessageLevel }; + Q_ENUM(JavaScriptConsoleMessageLevel) // must match WebContentsAdapterClient::RenderProcessTerminationStatus enum RenderProcessTerminationStatus { @@ -254,6 +253,7 @@ public: CrashedTerminationStatus, KilledTerminationStatus }; + Q_ENUM(RenderProcessTerminationStatus) enum FindFlag { FindBackward = 1, diff --git a/src/webengine/doc/src/external-resources.qdoc b/src/webengine/doc/src/external-resources.qdoc index 34a66291e..2987f1fca 100644 --- a/src/webengine/doc/src/external-resources.qdoc +++ b/src/webengine/doc/src/external-resources.qdoc @@ -35,6 +35,11 @@ \title Chrome DevTools */ +/*! + \externalpage https://developers.google.com/web/tools/javascript/console/console-write + \title Chrome console API +*/ + /* This prevents autolinking of each occurrence of 'WebEngine' To link to the WebEngine QML type, use explicit linking: diff --git a/src/webengine/doc/src/qtwebengine-devtools.qdoc b/src/webengine/doc/src/qtwebengine-debugging.qdoc index ee87214e1..bffcd1669 100644 --- a/src/webengine/doc/src/qtwebengine-devtools.qdoc +++ b/src/webengine/doc/src/qtwebengine-debugging.qdoc @@ -26,8 +26,24 @@ ****************************************************************************/ /*! - \page qtwebengine-devtools.html - \title Qt WebEngine Web Developer Tools + \page qtwebengine-debugging.html + \title Qt WebEngine Debugging and Profiling + + \section1 Console Logging + + JavaScript executed inside Qt WebEngine can use the + \l{Chrome console API} to log information to a console. The logging messages + are forwarded to Qt's logging facilities inside a \c js + \l{QLoggingCategory}{logging category}. However, only warning and fatal + messages are printed by default. To change this, you either have to set custom + rules for the \c js category, or provide custom message handlers + by reimplementing \l{QWebEnginePage::javaScriptConsoleMessage()}, or + connecting to \l{WebEngineView::javaScriptConsoleMessage()}. + + All messages can also be accessed through the Qt WebEngine developer + tools. + + \section1 Qt WebEngine Developer Tools The Qt WebEngine module provides web developer tools that make it easy to inspect and debug layout and performance issues of any web content. diff --git a/src/webengine/doc/src/qtwebengine-index.qdoc b/src/webengine/doc/src/qtwebengine-index.qdoc index e67bd43fd..671425e75 100644 --- a/src/webengine/doc/src/qtwebengine-index.qdoc +++ b/src/webengine/doc/src/qtwebengine-index.qdoc @@ -70,7 +70,7 @@ \list \li \l{Qt WebEngine Overview} \li \l{Qt WebEngine Platform Notes} - \li \l{Qt WebEngine Web Developer Tools} + \li \l{Qt WebEngine Debugging and Profiling} \li \l{Porting from Qt WebKit to Qt WebEngine} \endlist diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc index 7ab29e324..cfe731c01 100644 --- a/src/webengine/doc/src/qtwebengine-overview.qdoc +++ b/src/webengine/doc/src/qtwebengine-overview.qdoc @@ -67,6 +67,12 @@ specification than Qt WebKit. However, Qt WebEngine is thus heavier than Qt WebKit and does not provide direct access to the network stack and the HTML document through C++ APIs. + Please note that Qt WebEngine is based on Chromium, but does not contain or use any services + or add-ons that might be part of the Chrome browser that is built and delivered by Google. + You can find more detailed information about the differences between Chromium and Chrome in this + \l{https://chromium.googlesource.com/chromium/src/+/master/docs/chromium_browser_vs_google_chrome.md}{overview} + that is part of the documentation in the \l {Chromium Project} upstream source tree. + Chromium is tightly integrated to the \l{Qt Quick Scene Graph}{Qt Quick scene graph}, which is based on OpenGL ES 2.0 or OpenGL 2.0 for its rendering. This provides you with one-pass compositing of web content and all the Qt Quick UI. The integration to Chromium is transparent diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc index f230ba261..d1b4e722b 100644 --- a/src/webengine/doc/src/webengineview.qdoc +++ b/src/webengine/doc/src/webengineview.qdoc @@ -434,7 +434,10 @@ \a level indicates the severity of the event that triggered the message, that is, whether it was triggered by an error or a less severe event. - The corresponding handler is \c onJavaScriptConsoleMessage. + The corresponding handler is \c onJavaScriptConsoleMessage. If no handler is specified, + the view will log the messages into a \c js \l{QLoggingCategory}{logging category}. + + \sa{Console Logging} */ /*! diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp index 2025ce588..c59dfb450 100644 --- a/src/webengine/plugin/plugin.cpp +++ b/src/webengine/plugin/plugin.cpp @@ -79,7 +79,7 @@ public: tr("Cannot create a separate instance of WebEngineDownloadItem")); qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", tr("Cannot create separate instance of WebEngineNewViewRequest")); qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); - qmlRegisterUncreatableType<QQuickWebEngineSettings, 1>(uri, 1, 2, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); + // FIXME(QTBUG-40043): qmlRegisterUncreatableType<QQuickWebEngineSettings, 1>(uri, 1, 2, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); qmlRegisterSingletonType<QQuickWebEngineSingleton>(uri, 1, 1, "WebEngine", webEngineSingletonProvider); qmlRegisterUncreatableType<QQuickWebEngineHistory>(uri, 1, 1, "NavigationHistory", tr("Cannot create a separate instance of NavigationHistory")); diff --git a/src/webengine/plugin/plugins.qmltypes b/src/webengine/plugin/plugins.qmltypes index 1e577bf51..7a310d268 100644 --- a/src/webengine/plugin/plugins.qmltypes +++ b/src/webengine/plugin/plugins.qmltypes @@ -488,8 +488,10 @@ Module { exports: ["QtWebEngine/FullScreenRequest 1.1"] isCreatable: false exportMetaObjectRevisions: [0] + Property { name: "origin"; type: "QUrl"; isReadonly: true } Property { name: "toggleOn"; type: "bool"; isReadonly: true } Method { name: "accept" } + Method { name: "reject" } } Component { name: "QQuickWebEngineHistory" @@ -609,11 +611,7 @@ Module { name: "downloadFinished" Parameter { name: "download"; type: "QQuickWebEngineDownloadItem"; isPointer: true } } - Method { - name: "setCookieStoreClient" - revision: 1 - Parameter { name: "client"; type: "QWebEngineCookieStoreClient"; isPointer: true } - } + Method { name: "cookieStoreClient"; revision: 1; type: "QWebEngineCookieStoreClient*" } } Component { name: "QQuickWebEngineScript" @@ -832,7 +830,8 @@ Module { "DownloadMediaToDisk": 25, "InspectElement": 26, "ExitFullScreen": 27, - "WebActionCount": 28 + "RequestClose": 28, + "WebActionCount": 29 } } Enum { @@ -953,6 +952,7 @@ Module { Parameter { name: "terminationStatus"; type: "RenderProcessTerminationStatus" } Parameter { name: "exitCode"; type: "int" } } + Signal { name: "windowCloseRequested"; revision: 2 } Method { name: "runJavaScript" Parameter { type: "string" } diff --git a/src/webengine/ui/AuthenticationDialog.qml b/src/webengine/ui/AuthenticationDialog.qml index 46e2e3151..441235980 100644 --- a/src/webengine/ui/AuthenticationDialog.qml +++ b/src/webengine/ui/AuthenticationDialog.qml @@ -35,71 +35,88 @@ ****************************************************************************/ // FIXME: authentication missing in Qt Quick Dialogs atm. Make our own for now. +import QtQuick 2.5 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.0 -import QtQuick 2.5 +import QtQuick.Window 2.2 -ApplicationWindow { +Window { signal accepted(string user, string password); signal rejected; - property alias text: message.text; + property alias text: message.text - width: 350 - height: 100 + title: qsTr("Authentication Required") flags: Qt.Dialog + modality: Qt.WindowModal - title: "Authentication Required" + width: minimumWidth + height: minimumHeight + minimumWidth: rootLayout.implicitWidth + rootLayout.doubleMargins + minimumHeight: rootLayout.implicitHeight + rootLayout.doubleMargins + + SystemPalette { id: palette; colorGroup: SystemPalette.Active } + color: palette.window function open() { show(); } + function acceptDialog() { + accepted(userField.text, passwordField.text); + close(); + } + ColumnLayout { - anchors.fill: parent; - anchors.margins: 4; + id: rootLayout + anchors.fill: parent + anchors.margins: 4 + property int doubleMargins: anchors.margins * 2 Text { id: message; - Layout.fillWidth: true; + color: palette.windowText } - RowLayout { + GridLayout { + columns: 2 Label { - text: "Username:" + text: qsTr("Username:") + color: palette.windowText } TextField { - id: userField; - Layout.fillWidth: true; + id: userField + focus: true + Layout.fillWidth: true + onAccepted: acceptDialog() } - } - RowLayout { Label { - text: "Password:" + text: qsTr("Password:") + color: palette.windowText } TextField { - id: passwordField; - Layout.fillWidth: true; - echoMode: TextInput.Password; + id: passwordField + Layout.fillWidth: true + echoMode: TextInput.Password + onAccepted: acceptDialog() } } + Item { + Layout.fillHeight: true + } RowLayout { Layout.alignment: Qt.AlignRight - spacing: 8; + spacing: 8 Button { - text: "Log In" + id: cancelButton + text: qsTr("&Cancel") onClicked: { - accepted(userField.text, passwordField.text); + rejected(); close(); - destroy(); } } Button { - text: "Cancel" - onClicked: { - rejected(); - close(); - destroy(); - } + text: qsTr("&Log In") + isDefault: true + onClicked: acceptDialog() } } } - } diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp index f60cfb1a7..2e686b1b1 100644 --- a/src/webengine/ui_delegates_manager.cpp +++ b/src/webengine/ui_delegates_manager.cpp @@ -245,19 +245,19 @@ void UIDelegatesManager::showDialog(QSharedPointer<JavaScriptDialogController> d switch (dialogController->type()) { case WebContentsAdapterClient::AlertDialog: dialogComponentType = AlertDialog; - title = QCoreApplication::translate("UIDelegatesManager", "Javascript Alert - %1").arg(m_view->url().toString()); + title = tr("Javascript Alert - %1").arg(m_view->url().toString()); break; case WebContentsAdapterClient::ConfirmDialog: dialogComponentType = ConfirmDialog; - title = QCoreApplication::translate("UIDelegatesManager", "Javascript Confirm - %1").arg(m_view->url().toString()); + title = tr("Javascript Confirm - %1").arg(m_view->url().toString()); break; case WebContentsAdapterClient::PromptDialog: dialogComponentType = PromptDialog; - title = QCoreApplication::translate("UIDelegatesManager", "Javascript Prompt - %1").arg(m_view->url().toString()); + title = tr("Javascript Prompt - %1").arg(m_view->url().toString()); break; case WebContentsAdapterClient::UnloadDialog: dialogComponentType = ConfirmDialog; - title = QCoreApplication::translate("UIDelegatesManager", "Are you sure you want to leave this page?"); + title = tr("Are you sure you want to leave this page?"); break; case WebContentsAdapterClient::InternalAuthorizationDialog: dialogComponentType = ConfirmDialog; @@ -335,10 +335,10 @@ void UIDelegatesManager::showDialog(QSharedPointer<AuthenticationDialogControlle QString introMessage; if (dialogController->isProxy()) { - introMessage = QObject::tr("Connect to proxy \"%1\" using:"); + introMessage = tr("Connect to proxy \"%1\" using:"); introMessage = introMessage.arg(dialogController->host().toHtmlEscaped()); } else { - introMessage = QObject::tr("Enter username and password for \"%1\" at %2"); + introMessage = tr("Enter username and password for \"%1\" at %2"); introMessage = introMessage.arg(dialogController->realm()).arg(dialogController->url().toString().toHtmlEscaped()); } QQmlProperty textProp(authenticationDialog, QStringLiteral("text")); diff --git a/src/webengine/ui_delegates_manager.h b/src/webengine/ui_delegates_manager.h index fb262aac1..7a87c1eee 100644 --- a/src/webengine/ui_delegates_manager.h +++ b/src/webengine/ui_delegates_manager.h @@ -37,7 +37,12 @@ #ifndef UI_DELEGATES_MANAGER_H #define UI_DELEGATES_MANAGER_H -#include <QObject> +#include "qglobal.h" +#include "web_contents_adapter.h" +#include "web_contents_adapter_client.h" + +#include <QCoreApplication> +#include <QExplicitlySharedDataPointer> #include <QPoint> #include <QSharedPointer> @@ -82,8 +87,9 @@ Q_SIGNALS: void triggered(); }; -class UIDelegatesManager { - +class UIDelegatesManager +{ + Q_DECLARE_TR_FUNCTIONS(UIDelegatesManager) public: enum ComponentType { Invalid = -1, diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h index 05e0f8765..38b9a4ad8 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem.h @@ -59,7 +59,7 @@ public: DownloadCancelled, DownloadInterrupted }; - Q_ENUMS(DownloadState) + Q_ENUM(DownloadState) quint32 id() const; DownloadState state() const; diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp b/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp index 6223c070d..7db86e6f2 100644 --- a/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp +++ b/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp @@ -39,21 +39,31 @@ QT_BEGIN_NAMESPACE -QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(QWebEnginePagePrivate *pagePrivate, const QUrl &origin, bool fullscreen) - : m_pagePrivate(pagePrivate) +QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(QWebEnginePage *page, const QUrl &origin, bool fullscreen) + : m_page(page) , m_origin(origin) , m_toggleOn(fullscreen) { } -void QWebEngineFullScreenRequest::reject() const +void QWebEngineFullScreenRequest::reject() { - m_pagePrivate->setFullScreenMode(!m_toggleOn); + if (!m_page) { + qWarning("Cannot reject QWebEngineFullScreenRequest: Originating page is already deleted"); + return; + } + + m_page->d_func()->setFullScreenMode(!m_toggleOn); } -void QWebEngineFullScreenRequest::accept() const +void QWebEngineFullScreenRequest::accept() { - m_pagePrivate->setFullScreenMode(m_toggleOn); + if (!m_page) { + qWarning("Cannot accept QWebEngineFullScreenRequest: Originating page is already deleted"); + return; + } + + m_page->d_func()->setFullScreenMode(m_toggleOn); } QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.h b/src/webenginewidgets/api/qwebenginefullscreenrequest.h index c6768f4d6..26f7247e0 100644 --- a/src/webenginewidgets/api/qwebenginefullscreenrequest.h +++ b/src/webenginewidgets/api/qwebenginefullscreenrequest.h @@ -38,26 +38,25 @@ #define QWEBENGINEFULLSCREENREQUEST_H #include <qtwebenginewidgetsglobal.h> -#include <qwebenginepage.h> -#include <QtCore/qurl.h> +#include <qurl.h> +#include <qpointer.h> QT_BEGIN_NAMESPACE -class QWebEnginePagePrivate; +class QWebEnginePage; class QWEBENGINEWIDGETS_EXPORT QWebEngineFullScreenRequest { Q_GADGET Q_PROPERTY(bool toggleOn READ toggleOn) Q_PROPERTY(QUrl origin READ origin) public: - Q_INVOKABLE void reject() const; - Q_INVOKABLE void accept() const; + Q_INVOKABLE void reject(); + Q_INVOKABLE void accept(); bool toggleOn() const { return m_toggleOn; } const QUrl &origin() const { return m_origin; } private: - Q_DISABLE_COPY(QWebEngineFullScreenRequest) - QWebEngineFullScreenRequest(QWebEnginePagePrivate *pagePrivate, const QUrl &origin, bool toggleOn); - QWebEnginePagePrivate *m_pagePrivate; + QWebEngineFullScreenRequest(QWebEnginePage *page, const QUrl &origin, bool toggleOn); + QPointer<QWebEnginePage> m_page; const QUrl m_origin; const bool m_toggleOn; friend class QWebEnginePagePrivate; diff --git a/src/webenginewidgets/api/qwebenginehistory.h b/src/webenginewidgets/api/qwebenginehistory.h index 0471e28e6..3dcea9469 100644 --- a/src/webenginewidgets/api/qwebenginehistory.h +++ b/src/webenginewidgets/api/qwebenginehistory.h @@ -65,6 +65,9 @@ public: QUrl iconUrl() const; bool isValid() const; + + void swap(QWebEngineHistoryItem &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + private: QWebEngineHistoryItem(QWebEngineHistoryItemPrivate *priv); Q_DECLARE_PRIVATE_D(d.data(), QWebEngineHistoryItem) @@ -73,6 +76,7 @@ private: friend class QWebEngineHistoryPrivate; }; +Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QWebEngineHistoryItem) class QWebEngineHistoryPrivate; class QWEBENGINEWIDGETS_EXPORT QWebEngineHistory { diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index dd71db6a0..e85021832 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -55,6 +55,7 @@ #include <QIcon> #include <QInputDialog> #include <QLayout> +#include <QLoggingCategory> #include <QMenu> #include <QMessageBox> #include <QMimeData> @@ -431,7 +432,7 @@ QWebEnginePage::QWebEnginePage(QObject* parent) */ /*! - \fn QWebEnginePage::fullScreenRequested(const QWebEngineFullScreenRequest &request) + \fn QWebEnginePage::fullScreenRequested(QWebEngineFullScreenRequest request) This signal is emitted when the web page issues the request to enter fullscreen mode for a web-element, usually a video element. @@ -877,9 +878,19 @@ bool QWebEnginePage::event(QEvent *e) return QObject::event(e); } +void QWebEnginePagePrivate::wasShown() +{ + adapter->wasShown(); +} + +void QWebEnginePagePrivate::wasHidden() +{ + adapter->wasHidden(); +} + bool QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData &data) { - if (!view) + if (!view || !view->d_func()->m_pendingContextMenuEvent) return false; m_menuData = WebEngineContextMenuData(); @@ -905,7 +916,6 @@ bool QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData return false; break; } - Q_ASSERT(view->d_func()->m_pendingContextMenuEvent); view->d_func()->m_pendingContextMenuEvent = false; return true; } @@ -920,7 +930,7 @@ void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl & void QWebEnginePagePrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen) { Q_Q(QWebEnginePage); - QWebEngineFullScreenRequest request(this, origin, fullscreen); + QWebEngineFullScreenRequest request(q, origin, fullscreen); Q_EMIT q->fullScreenRequested(request); } @@ -1230,8 +1240,12 @@ void QWebEnginePage::runJavaScript(const QString& scriptSource, const QWebEngine } /*! - Returns the script collection used by this page. - \sa QWebEngineScriptCollection + Returns the collection of scripts that are injected into the page. + + In addition, a page might also execute scripts + added through QWebEngineProfile::scripts(). + + \sa QWebEngineScriptCollection, QWebEngineScript */ QWebEngineScriptCollection &QWebEnginePage::scripts() @@ -1309,10 +1323,24 @@ bool QWebEnginePage::javaScriptPrompt(const QUrl &securityOrigin, const QString void QWebEnginePage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) { - Q_UNUSED(level); - Q_UNUSED(message); - Q_UNUSED(lineNumber); - Q_UNUSED(sourceID); + static QLoggingCategory loggingCategory("js", QtWarningMsg); + static QByteArray file = sourceID.toUtf8(); + QMessageLogger logger(file.constData(), lineNumber, nullptr, loggingCategory.categoryName()); + + switch (level) { + case JavaScriptConsoleMessageLevel::InfoMessageLevel: + if (loggingCategory.isInfoEnabled()) + logger.info().noquote() << message; + break; + case JavaScriptConsoleMessageLevel::WarningMessageLevel: + if (loggingCategory.isWarningEnabled()) + logger.warning().noquote() << message; + break; + case JavaScriptConsoleMessageLevel::ErrorMessageLevel: + if (loggingCategory.isCriticalEnabled()) + logger.critical().noquote() << message; + break; + } } bool QWebEnginePage::certificateError(const QWebEngineCertificateError &) diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index 9740c89c9..69f8822b1 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -258,7 +258,7 @@ Q_SIGNALS: void featurePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature); void featurePermissionRequestCanceled(const QUrl &securityOrigin, QWebEnginePage::Feature feature); - void fullScreenRequested(const QWebEngineFullScreenRequest &fullScreenRequest); + void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest); void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator); void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost); @@ -292,6 +292,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_webActionTriggered(bool checked)) #endif + friend class QWebEngineFullScreenRequest; friend class QWebEngineView; friend class QWebEngineViewPrivate; #ifndef QT_NO_ACCESSIBILITY diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 66a2cf35b..dd43b08c8 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -131,6 +131,9 @@ public: void updateNavigationActions(); void _q_webActionTriggered(bool checked); + void wasShown(); + void wasHidden(); + QtWebEngineCore::WebContentsAdapter *webContents() { return adapter.data(); } void recreateFromSerializedHistory(QDataStream &input); diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 2edebdfeb..5fbc4d63c 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -199,7 +199,7 @@ void QWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info) */ QWebEngineProfile::QWebEngineProfile(QObject *parent) : QObject(parent) - , d_ptr(new QWebEngineProfilePrivate(new BrowserContextAdapter(false))) + , d_ptr(new QWebEngineProfilePrivate(new BrowserContextAdapter(true))) { d_ptr->q_ptr = this; } @@ -490,8 +490,10 @@ bool QWebEngineProfile::visitedLinksContainsUrl(const QUrl &url) const } /*! - Returns the script collection used by this profile. - \sa QWebEngineScriptCollection + Returns the collection of scripts that are injected into all pages that share + this profile. + + \sa QWebEngineScriptCollection, QWebEngineScript, QWebEnginePage::scripts() */ QWebEngineScriptCollection *QWebEngineProfile::scripts() const { diff --git a/src/webenginewidgets/api/qwebenginescript.cpp b/src/webenginewidgets/api/qwebenginescript.cpp index 1bd56604d..058f58475 100644 --- a/src/webenginewidgets/api/qwebenginescript.cpp +++ b/src/webenginewidgets/api/qwebenginescript.cpp @@ -58,6 +58,9 @@ using QtWebEngineCore::UserScript; not accessible from a different one. ScriptWorldId provides some predefined IDs for this purpose. + Use QWebEnginePage::scripts() and QWebEngineProfile::scripts() to access + the collection of scripts associated with a single page or a + number of pages sharing the same profile. */ /*! \enum QWebEngineScript::InjectionPoint diff --git a/src/webenginewidgets/api/qwebenginescript.h b/src/webenginewidgets/api/qwebenginescript.h index 4cff2631d..29126b110 100644 --- a/src/webenginewidgets/api/qwebenginescript.h +++ b/src/webenginewidgets/api/qwebenginescript.h @@ -99,7 +99,7 @@ private: QSharedDataPointer<QtWebEngineCore::UserScript> d; }; -Q_DECLARE_SHARED(QWebEngineScript) +Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QWebEngineScript) #ifndef QT_NO_DEBUG_STREAM QWEBENGINEWIDGETS_EXPORT QDebug operator<<(QDebug, const QWebEngineScript &); diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/webenginewidgets/api/qwebenginescriptcollection.cpp index 80a7f9b6e..9967cde85 100644 --- a/src/webenginewidgets/api/qwebenginescriptcollection.cpp +++ b/src/webenginewidgets/api/qwebenginescriptcollection.cpp @@ -47,6 +47,11 @@ using QtWebEngineCore::UserScript; \since 5.5 \brief The QWebEngineScriptCollection class represents a collection of user scripts. + QWebEngineScriptCollection manages a set of user scripts. + + Use QWebEnginePage::scripts() and QWebEngineProfile::scripts() to access + the collection of scripts associated with a single page or a + number of pages sharing the same profile. */ /*! diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp index 9baa8e34a..362849732 100644 --- a/src/webenginewidgets/api/qwebengineview.cpp +++ b/src/webenginewidgets/api/qwebengineview.cpp @@ -294,6 +294,24 @@ void QWebEngineView::contextMenuEvent(QContextMenuEvent *event) menu->popup(event->globalPos()); } +/*! + * \reimp + */ +void QWebEngineView::showEvent(QShowEvent *event) +{ + QWidget::showEvent(event); + page()->d_ptr->wasShown(); +} + +/*! + * \reimp + */ +void QWebEngineView::hideEvent(QHideEvent *event) +{ + QWidget::hideEvent(event); + page()->d_ptr->wasHidden(); +} + #ifndef QT_NO_ACCESSIBILITY int QWebEngineViewAccessible::childCount() const { diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h index ae38e6c5c..e16bbf4af 100644 --- a/src/webenginewidgets/api/qwebengineview.h +++ b/src/webenginewidgets/api/qwebengineview.h @@ -120,6 +120,8 @@ protected: virtual QWebEngineView *createWindow(QWebEnginePage::WebWindowType type); virtual void contextMenuEvent(QContextMenuEvent*) Q_DECL_OVERRIDE; virtual bool event(QEvent*) Q_DECL_OVERRIDE; + virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + virtual void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QWebEngineView) diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc index b7b3bf022..17dd15630 100644 --- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc @@ -262,7 +262,10 @@ \a level indicates the severity of the event that triggered the message. That is, whether it was triggered by an error or a less severe event. - The default implementation prints nothing. + Since Qt 5.6, the default implementation logs the messages in a \c js + \l{QLoggingCategory}{logging category}. + + \sa{Console Logging} */ /*! diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp index 76ca8d354..57631c4cc 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -139,14 +139,12 @@ void RenderWidgetHostViewQtDelegateWidget::show() // want to show anything else than popups as top-level. if (parent() || m_isPopup) { QOpenGLWidget::show(); - m_client->notifyShown(); } } void RenderWidgetHostViewQtDelegateWidget::hide() { QOpenGLWidget::hide(); - m_client->notifyHidden(); } bool RenderWidgetHostViewQtDelegateWidget::isVisible() const @@ -257,6 +255,13 @@ void RenderWidgetHostViewQtDelegateWidget::showEvent(QShowEvent *event) m_windowConnections.append(connect(w, SIGNAL(yChanged(int)), SLOT(onWindowPosChanged()))); } m_client->windowChanged(); + m_client->notifyShown(); +} + +void RenderWidgetHostViewQtDelegateWidget::hideEvent(QHideEvent *event) +{ + QOpenGLWidget::hideEvent(event); + m_client->notifyHidden(); } bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event) diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h index d228bd487..fddc79c2f 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h @@ -84,6 +84,7 @@ protected: bool event(QEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE; void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; void initializeGL() Q_DECL_OVERRIDE; void paintGL() Q_DECL_OVERRIDE; |