diff options
Diffstat (limited to 'src')
25 files changed, 178 insertions, 165 deletions
diff --git a/src/3rdparty b/src/3rdparty -Subproject 0240cfc1a59deb5b612923d47ccef72f10504fe +Subproject d6e5fc10e417efdf8665d9fba57c269f0534072 diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp index 25d0bd3be..3c7fc54a1 100644 --- a/src/core/api/qtwebenginecoreglobal.cpp +++ b/src/core/api/qtwebenginecoreglobal.cpp @@ -108,7 +108,7 @@ Q_WEBENGINECORE_PRIVATE_EXPORT void initialize() QCoreApplication *app = QCoreApplication::instance(); if (!app) { - qFatal("QtWebEngine::initialize() must be called after the construction of the application object."); + qFatal("QtWebEngine::initialize() but no core application instance."); return; } diff --git a/src/core/browser_accessibility_manager_qt.cpp b/src/core/browser_accessibility_manager_qt.cpp index 7fb1386c5..8e3ee5940 100644 --- a/src/core/browser_accessibility_manager_qt.cpp +++ b/src/core/browser_accessibility_manager_qt.cpp @@ -146,6 +146,24 @@ void BrowserAccessibilityManagerQt::FireBlinkEvent(ax::mojom::Event event_type, break; } } + +void BrowserAccessibilityManagerQt::FireGeneratedEvent(ui::AXEventGenerator::Event event_type, + BrowserAccessibility* node) +{ + BrowserAccessibilityQt *iface = static_cast<BrowserAccessibilityQt*>(node); + + switch (event_type) { + case ui::AXEventGenerator::Event::VALUE_CHANGED: + if (iface->role() == QAccessible::EditableText) { + QAccessibleTextUpdateEvent event(iface, -1, QString(), QString()); + QAccessible::updateAccessibility(&event); + } + break; + default: + break; + } +} + #endif // QT_NO_ACCESSIBILITY } diff --git a/src/core/browser_accessibility_manager_qt.h b/src/core/browser_accessibility_manager_qt.h index 87c8875ba..16e2d1fe7 100644 --- a/src/core/browser_accessibility_manager_qt.h +++ b/src/core/browser_accessibility_manager_qt.h @@ -60,6 +60,8 @@ public: ~BrowserAccessibilityManagerQt() override; void FireBlinkEvent(ax::mojom::Event event_type, BrowserAccessibility* node) override; + void FireGeneratedEvent(ui::AXEventGenerator::Event event_type, + BrowserAccessibility* node) override; QAccessibleInterface *rootParentAccessible(); bool isValid() const { return m_valid; } diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 22cb5991f..f45c418fe 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -178,7 +178,7 @@ host_build { } else { gn_args += use_system_harfbuzz=false } - !qtConfig(webengine-system-glib): gn_args += use_glib=false + gn_args += use_glib=false qtConfig(webengine-pulseaudio) { gn_args += use_pulseaudio=true } else { diff --git a/src/core/configure.json b/src/core/configure.json index be686850b..cd3c5c661 100644 --- a/src/core/configure.json +++ b/src/core/configure.json @@ -334,10 +334,6 @@ "label": "thumb instruction set", "type": "hasThumbFlag" }, - "webengine-extensions-gcc-version" : { - "label": "GCC 6 or newer", - "type": "hasGcc6OrNewer" - }, "webengine-noexecstack" : { "label": "linker supports -z noexecstack", "type": "linkerSupportsFlag", @@ -566,7 +562,7 @@ "label": "Extensions", "purpose": "Enables Chromium extensions within certain limits. Currently used for enabling the pdf viewer.", "section": "WebEngine", - "condition": "features.webengine-printing-and-pdf && (tests.webengine-extensions-gcc-version || config.clang || !config.gcc)", + "condition": "features.webengine-printing-and-pdf", "autoDetect": "features.webengine-printing-and-pdf", "output": [ "publicFeature" ] }, diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 16945020b..6d1bf07a9 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -196,7 +196,7 @@ public: void* GetHandle() override { return m_handle; } // Qt currently never creates contexts using robustness attributes. - bool WasAllocatedUsingRobustnessExtension() override { return false; } + unsigned int CheckStickyGraphicsResetStatus() override { return 0 /*GL_NO_ERROR*/; } // We don't care about the rest, this context shouldn't be used except for its handle. bool Initialize(gl::GLSurface *, const gl::GLContextAttribs &) override { Q_UNREACHABLE(); return false; } @@ -235,7 +235,7 @@ void ShareGroupQtQuick::AboutToAddFirstContext() // This currently has to be setup by ::main in all applications using QQuickWebEngineView with delegated rendering. QOpenGLContext *shareContext = qt_gl_global_share_context(); if (!shareContext) { - qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function."); + qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function before QCoreApplication is created."); } m_shareContextQtQuick = new QtShareGLContext(shareContext); #endif diff --git a/src/core/core_common.pri b/src/core/core_common.pri index c92278657..e548aefd1 100644 --- a/src/core/core_common.pri +++ b/src/core/core_common.pri @@ -17,6 +17,3 @@ CONFIG -= ltcg # Chromium requires C++14 CONFIG += c++14 -#QTBUG-73216 ci has to be updated with latest yocto -boot2qt: CONFIG -= use_gold_linker - diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp index ecc46f244..29230c27b 100644 --- a/src/core/media_capture_devices_dispatcher.cpp +++ b/src/core/media_capture_devices_dispatcher.cpp @@ -87,22 +87,25 @@ const blink::MediaStreamDevice *findDeviceWithId(const blink::MediaStreamDevices return 0; } -// Based on chrome/browser/media/desktop_capture_access_handler.cc: -void getDevicesForDesktopCapture(blink::MediaStreamDevices *devices, content::DesktopMediaID mediaId, bool captureAudio) +// Based on chrome/browser/media/webrtc/desktop_capture_devices_util.cc: +void getDevicesForDesktopCapture(blink::MediaStreamDevices *devices, + content::DesktopMediaID mediaId, + bool captureAudio, + blink::MediaStreamType videoType, + blink::MediaStreamType audioType) { DCHECK_CURRENTLY_ON(BrowserThread::UI); // Add selected desktop source to the list. - devices->push_back(blink::MediaStreamDevice(blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE, mediaId.ToString(), "Screen")); + devices->push_back(blink::MediaStreamDevice(videoType, mediaId.ToString(), mediaId.ToString())); if (captureAudio) { if (mediaId.type == content::DesktopMediaID::TYPE_WEB_CONTENTS) { devices->push_back( - blink::MediaStreamDevice(blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE, - mediaId.ToString(), "Tab audio")); + blink::MediaStreamDevice(audioType, mediaId.ToString(), "Tab audio")); } else { // Use the special loopback device ID for system audio capture. devices->push_back(blink::MediaStreamDevice( - blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE, + audioType, media::AudioDeviceDescription::kLoopbackInputDeviceId, "System Audio")); } @@ -151,19 +154,27 @@ content::DesktopMediaID getDefaultScreenId() WebContentsAdapterClient::MediaRequestFlags mediaRequestFlagsForRequest(const content::MediaStreamRequest &request) { - WebContentsAdapterClient::MediaRequestFlags requestFlags = WebContentsAdapterClient::MediaNone; + if (request.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE && + request.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE) + return {WebContentsAdapterClient::MediaAudioCapture, WebContentsAdapterClient::MediaVideoCapture}; - if (request.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE) - requestFlags |= WebContentsAdapterClient::MediaAudioCapture; - else if (request.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE) - requestFlags |= WebContentsAdapterClient::MediaDesktopAudioCapture; + if (request.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE && + request.video_type == blink::MEDIA_NO_SERVICE) + return {WebContentsAdapterClient::MediaAudioCapture}; - if (request.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE) - requestFlags |= WebContentsAdapterClient::MediaVideoCapture; - else if (request.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) - requestFlags |= WebContentsAdapterClient::MediaDesktopVideoCapture; + if (request.audio_type == blink::MEDIA_NO_SERVICE && + request.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE) + return {WebContentsAdapterClient::MediaVideoCapture}; - return requestFlags; + if (request.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE && + request.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) + return {WebContentsAdapterClient::MediaDesktopAudioCapture, WebContentsAdapterClient::MediaDesktopVideoCapture}; + + if (request.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE || + request.video_type == blink::MEDIA_DISPLAY_VIDEO_CAPTURE) + return {WebContentsAdapterClient::MediaDesktopVideoCapture}; + + return {}; } } // namespace @@ -198,14 +209,13 @@ void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content: if (!securityOriginsMatch) qWarning("Security origin mismatch for media access permission: %s requested and %s provided\n", qPrintable(requestSecurityOrigin.toString()), qPrintable(securityOrigin.toString())); - bool microphoneRequested = - (request.audio_type && authorizationFlags & WebContentsAdapterClient::MediaAudioCapture); - bool webcamRequested = - (request.video_type && authorizationFlags & WebContentsAdapterClient::MediaVideoCapture); - bool desktopAudioRequested = - (request.audio_type && authorizationFlags & WebContentsAdapterClient::MediaDesktopAudioCapture); - bool desktopVideoRequested = - (request.video_type && authorizationFlags & WebContentsAdapterClient::MediaDesktopVideoCapture); + WebContentsAdapterClient::MediaRequestFlags requestFlags = mediaRequestFlagsForRequest(request); + WebContentsAdapterClient::MediaRequestFlags finalFlags = requestFlags & authorizationFlags; + + bool microphoneRequested = finalFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture); + bool webcamRequested = finalFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture); + bool desktopAudioRequested = finalFlags.testFlag(WebContentsAdapterClient::MediaDesktopAudioCapture); + bool desktopVideoRequested = finalFlags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture); if (securityOriginsMatch) { if (microphoneRequested || webcamRequested) { @@ -221,7 +231,8 @@ void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content: break; } } else if (desktopVideoRequested) { - getDevicesForDesktopCapture(&devices, getDefaultScreenId(), desktopAudioRequested); + getDevicesForDesktopCapture(&devices, getDefaultScreenId(), desktopAudioRequested, + request.video_type, request.audio_type); } } @@ -274,13 +285,13 @@ void MediaCaptureDevicesDispatcher::processMediaAccessRequest(WebContentsAdapter { DCHECK_CURRENTLY_ON(BrowserThread::UI); - // Let's not support tab capture for now. - if (request.video_type == blink::MEDIA_GUM_TAB_VIDEO_CAPTURE || request.audio_type == blink::MEDIA_GUM_TAB_AUDIO_CAPTURE) { + WebContentsAdapterClient::MediaRequestFlags flags = mediaRequestFlagsForRequest(request); + if (!flags) { std::move(callback).Run(blink::MediaStreamDevices(), blink::MEDIA_DEVICE_NOT_SUPPORTED, std::unique_ptr<content::MediaStreamUI>()); return; } - if (request.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE || request.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE) { + if (flags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture)) { const bool screenCaptureEnabled = adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::ScreenCaptureEnabled); const bool originIsSecure = content::IsOriginSecure(request.security_origin); @@ -298,18 +309,13 @@ void MediaCaptureDevicesDispatcher::processMediaAccessRequest(WebContentsAdapter enqueueMediaAccessRequest(webContents, request, std::move(callback)); // We might not require this approval for pepper requests. - adapterClient->runMediaAccessPermissionRequest(toQt(request.security_origin), mediaRequestFlagsForRequest(request)); + adapterClient->runMediaAccessPermissionRequest(toQt(request.security_origin), flags); } void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content::WebContents *webContents, const content::MediaStreamRequest &request, content::MediaResponseCallback callback) { blink::MediaStreamDevices devices; - if (request.video_type != blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE || request.requested_video_device_id.empty()) { - std::move(callback).Run(devices, blink::MEDIA_DEVICE_INVALID_STATE, std::unique_ptr<content::MediaStreamUI>()); - return; - } - content::WebContents *const web_contents_for_stream = content::WebContents::FromRenderFrameHost( content::RenderFrameHost::FromID(request.render_process_id, request.render_frame_id)); content::RenderFrameHost *const main_frame = web_contents_for_stream ? web_contents_for_stream->GetMainFrame() : NULL; @@ -334,7 +340,7 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content:: // Audio is only supported for screen capture streams. bool capture_audio = (mediaId.type == content::DesktopMediaID::TYPE_SCREEN && request.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE); - getDevicesForDesktopCapture(&devices, mediaId, capture_audio); + getDevicesForDesktopCapture(&devices, mediaId, capture_audio, request.video_type, request.audio_type); std::move(callback).Run(devices, devices.empty() ? blink::MEDIA_DEVICE_INVALID_STATE : blink::MEDIA_DEVICE_OK, std::unique_ptr<content::MediaStreamUI>()); diff --git a/src/core/net/network_delegate_qt.cpp b/src/core/net/network_delegate_qt.cpp index 7f278fd92..2cca152e6 100644 --- a/src/core/net/network_delegate_qt.cpp +++ b/src/core/net/network_delegate_qt.cpp @@ -136,11 +136,11 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet // Deprecated =begin // quick peek if deprecated - QWebEngineUrlRequestInterceptor* profileInterceptor = m_profileIOData->requestInterceptor(); - if (profileInterceptor && profileInterceptor->property("deprecated").toBool()) { - profileInterceptor = nullptr; - if (QWebEngineUrlRequestInterceptor* interceptor = m_profileIOData->acquireInterceptor()) { - interceptor->interceptRequest(requestInfo); + + if (m_profileIOData->isInterceptorDeprecated()) { + QWebEngineUrlRequestInterceptor* profileInterceptor = m_profileIOData->acquireInterceptor(); + if (profileInterceptor && m_profileIOData->isInterceptorDeprecated()) { + profileInterceptor->interceptRequest(requestInfo); m_profileIOData->releaseInterceptor(); if (requestInfo.changed()) { int result = infoPrivate->shouldBlockRequest ? net::ERR_BLOCKED_BY_CLIENT : net::OK; @@ -174,7 +174,9 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet if (!resourceInfo) return net::OK; - if (!m_profileIOData->hasPageInterceptors() && !profileInterceptor && !content::IsResourceTypeFrame(resourceType)) + // try to bail out + if (!m_profileIOData->hasPageInterceptors() && (!m_profileIOData->requestInterceptor() || m_profileIOData->isInterceptorDeprecated()) && + !content::IsResourceTypeFrame(resourceType)) return net::OK; auto webContentsGetter = resourceInfo->GetWebContentsGetterForRequest(); @@ -185,7 +187,7 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet std::move(requestInfo), webContentsGetter, std::move(callback), - profileInterceptor ? m_profileIOData->profileAdapter() : nullptr + m_profileIOData->profileAdapter() ); // We'll run the callback after we notified the UI thread. diff --git a/src/core/net/url_request_custom_job.cpp b/src/core/net/url_request_custom_job.cpp index cba9b4dc5..d8442707e 100644 --- a/src/core/net/url_request_custom_job.cpp +++ b/src/core/net/url_request_custom_job.cpp @@ -40,10 +40,12 @@ #include "url_request_custom_job.h" #include "url_request_custom_job_proxy.h" +#include "base/strings/stringprintf.h" #include "base/task/post_task.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "net/base/io_buffer.h" +#include "net/http/http_util.h" #include <QIODevice> @@ -136,6 +138,22 @@ bool URLRequestCustomJob::GetCharset(std::string* charset) return false; } +void URLRequestCustomJob::GetResponseInfo(HttpResponseInfo* info) +{ + if (m_error) + return; + + std::string headers; + if (m_redirect.is_valid()) { + headers += "HTTP/1.1 303 See Other\n"; + headers += base::StringPrintf("Location: %s\n", m_redirect.spec().c_str()); + } else { + headers += "HTTP/1.1 200 OK\n"; + } + + info->headers = new HttpResponseHeaders(HttpUtil::AssembleRawHeaders(headers.c_str(), headers.size())); +} + bool URLRequestCustomJob::IsRedirectResponse(GURL* location, int* http_status_code, bool* /*insecure_scheme_was_upgraded*/) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); diff --git a/src/core/net/url_request_custom_job.h b/src/core/net/url_request_custom_job.h index 16be76f29..c800d1595 100644 --- a/src/core/net/url_request_custom_job.h +++ b/src/core/net/url_request_custom_job.h @@ -64,6 +64,7 @@ public: int ReadRawData(net::IOBuffer *buf, int buf_size) override; bool GetMimeType(std::string *mimeType) const override; bool GetCharset(std::string *charset) override; + void GetResponseInfo(net::HttpResponseInfo* info) override; bool IsRedirectResponse(GURL* location, int* http_status_code, bool* insecure_scheme_was_upgraded) override; protected: diff --git a/src/core/net/url_request_notification.cpp b/src/core/net/url_request_notification.cpp index e37ad35bc..b59339441 100644 --- a/src/core/net/url_request_notification.cpp +++ b/src/core/net/url_request_notification.cpp @@ -49,6 +49,7 @@ #include "profile_io_data_qt.h" #include "qwebengineurlrequestinfo_p.h" #include "type_conversion.h" +#include <QVariant> namespace QtWebEngineCore { @@ -107,7 +108,7 @@ void URLRequestNotification::notify() if (webContents) { - if (m_profileAdapter) { + if (m_profileAdapter && m_profileAdapter->requestInterceptor()) { QWebEngineUrlRequestInterceptor* interceptor = m_profileAdapter->requestInterceptor(); if (!interceptor->property("deprecated").toBool()) interceptor->interceptRequest(m_requestInfo); diff --git a/src/core/printing/pdfium_document_wrapper_qt.cpp b/src/core/printing/pdfium_document_wrapper_qt.cpp index 6f415b50b..dae6ec44b 100644 --- a/src/core/printing/pdfium_document_wrapper_qt.cpp +++ b/src/core/printing/pdfium_document_wrapper_qt.cpp @@ -48,64 +48,6 @@ namespace QtWebEngineCore { int PdfiumDocumentWrapperQt::m_libraryUsers = 0; -class PdfiumPageWrapperQt { -public: - PdfiumPageWrapperQt(FPDF_DOCUMENT data, int pageIndex) - : m_pageData(FPDF_LoadPage(data, pageIndex)) - , m_width(FPDF_GetPageWidth(m_pageData)) - , m_height(FPDF_GetPageHeight(m_pageData)) - , m_image(createImage()) - { - } - - PdfiumPageWrapperQt() - : m_pageData(nullptr) - , m_width(-1) - , m_height(-1) - , m_image(QImage()) - { - } - - virtual ~PdfiumPageWrapperQt() - { - FPDF_ClosePage(m_pageData); - } - - QImage image() - { - return m_image; - } - -private: - QImage createImage() - { - Q_ASSERT(m_pageData); - - QImage image(m_width * 2, m_height * 2, QImage::Format_ARGB32); - Q_ASSERT(!image.isNull()); - image.fill(0xFFFFFFFF); - - FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(image.width(), image.height(), - FPDFBitmap_BGRA, - image.scanLine(0), image.bytesPerLine()); - Q_ASSERT(bitmap); - - FPDF_RenderPageBitmap(bitmap, m_pageData, - 0, 0, image.width(), image.height(), - 0, 0); - FPDFBitmap_Destroy(bitmap); - bitmap = nullptr; - return image; - } - -private: - FPDF_PAGE m_pageData; - int m_width; - int m_height; - QImage m_image; -}; - - PdfiumDocumentWrapperQt::PdfiumDocumentWrapperQt(const void *pdfData, size_t size, const char *password) { @@ -118,27 +60,41 @@ PdfiumDocumentWrapperQt::PdfiumDocumentWrapperQt(const void *pdfData, size_t siz m_pageCount = FPDF_GetPageCount((FPDF_DOCUMENT)m_documentHandle); } -QImage PdfiumDocumentWrapperQt::pageAsQImage(size_t index) +QImage PdfiumDocumentWrapperQt::pageAsQImage(size_t pageIndex,int width , int height) { if (!m_documentHandle || !m_pageCount) { qWarning("Failure to generate QImage from invalid or empty PDF document."); return QImage(); } - if (static_cast<int>(index) >= m_pageCount) { + if (static_cast<int>(pageIndex) >= m_pageCount) { qWarning("Failure to generate QImage from PDF data: index out of bounds."); return QImage(); } - PdfiumPageWrapperQt pageWrapper((FPDF_DOCUMENT)m_documentHandle, index); - return pageWrapper.image(); + FPDF_PAGE pageData(FPDF_LoadPage((FPDF_DOCUMENT)m_documentHandle, pageIndex)); + QImage image(width, height, QImage::Format_ARGB32); + Q_ASSERT(!image.isNull()); + image.fill(0xFFFFFFFF); + + FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(width, height, + FPDFBitmap_BGRA, + image.scanLine(0), image.bytesPerLine()); + Q_ASSERT(bitmap); + FPDF_RenderPageBitmap(bitmap, pageData, + 0, 0, width, height, + 0, 0); + FPDFBitmap_Destroy(bitmap); + bitmap = nullptr; + FPDF_ClosePage(pageData); + return image; } -bool PdfiumDocumentWrapperQt::pageIsLandscape(size_t index) +QSizeF PdfiumDocumentWrapperQt::pageSize(size_t index) { - double width = 0, height = 0; - FPDF_GetPageSizeByIndex((FPDF_DOCUMENT)m_documentHandle, index, &width, &height); - return (width > height); + QSizeF size; + FPDF_GetPageSizeByIndex((FPDF_DOCUMENT)m_documentHandle, index, &size.rwidth(), &size.rheight()); + return size; } PdfiumDocumentWrapperQt::~PdfiumDocumentWrapperQt() @@ -147,5 +103,4 @@ PdfiumDocumentWrapperQt::~PdfiumDocumentWrapperQt() if (--m_libraryUsers == 0) FPDF_DestroyLibrary(); } - } diff --git a/src/core/printing/pdfium_document_wrapper_qt.h b/src/core/printing/pdfium_document_wrapper_qt.h index 121742aa3..e0778c32b 100644 --- a/src/core/printing/pdfium_document_wrapper_qt.h +++ b/src/core/printing/pdfium_document_wrapper_qt.h @@ -56,15 +56,14 @@ #include <QtGui/qimage.h> namespace QtWebEngineCore { -class PdfiumPageWrapperQt; class Q_WEBENGINECORE_PRIVATE_EXPORT PdfiumDocumentWrapperQt { public: PdfiumDocumentWrapperQt(const void *pdfData, size_t size, const char *password = nullptr); virtual ~PdfiumDocumentWrapperQt(); - QImage pageAsQImage(size_t index); - bool pageIsLandscape(size_t index); + QImage pageAsQImage(size_t index, int width , int height); + QSizeF pageSize(size_t index); int pageCount() const { return m_pageCount; } private: diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index ebb533206..dbe76f0d1 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -179,7 +179,16 @@ void ProfileAdapter::setRequestInterceptor(QWebEngineUrlRequestInterceptor *inte { if (m_requestInterceptor == interceptor) return; + + if (m_requestInterceptor) + disconnect(m_requestInterceptor, &QObject::destroyed, this, nullptr); m_requestInterceptor = interceptor; + if (m_requestInterceptor) + connect(m_requestInterceptor, &QObject::destroyed, this, [this] () { + m_profile->m_profileIOData->updateRequestInterceptor(); + Q_ASSERT(!m_profile->m_profileIOData->requestInterceptor()); + }); + if (m_profile->m_urlRequestContextGetter.get()) m_profile->m_profileIOData->updateRequestInterceptor(); } diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index 27c97a986..a2613d3fc 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -614,7 +614,6 @@ void ProfileIODataQt::setRequestContextData(content::ProtocolHandlerMap *protoco void ProfileIODataQt::setFullConfiguration() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - m_requestInterceptor = m_profileAdapter->requestInterceptor(); m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy(); m_cookiesPath = m_profileAdapter->cookiesPath(); m_channelIdPath = m_profileAdapter->channelIdPath(); @@ -741,9 +740,18 @@ void ProfileIODataQt::updateRequestInterceptor() QMutexLocker lock(&m_mutex); m_requestInterceptor = m_profileAdapter->requestInterceptor(); m_hasPageInterceptors = m_profileAdapter->hasPageRequestInterceptor(); + if (m_requestInterceptor) + m_isInterceptorDeprecated = m_requestInterceptor->property("deprecated").toBool(); + else + m_isInterceptorDeprecated = false; // We in this case do not need to regenerate any Chromium classes. } +bool ProfileIODataQt::isInterceptorDeprecated() const +{ + return m_isInterceptorDeprecated; +} + QWebEngineUrlRequestInterceptor *ProfileIODataQt::acquireInterceptor() { m_mutex.lock(); diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h index 570365085..a1b123771 100644 --- a/src/core/profile_io_data_qt.h +++ b/src/core/profile_io_data_qt.h @@ -120,7 +120,8 @@ public: void setGlobalCertificateVerification(); // Used in NetworkDelegateQt::OnBeforeURLRequest. - QWebEngineUrlRequestInterceptor *acquireInterceptor(); + bool isInterceptorDeprecated() const; // Remove for Qt6 + QWebEngineUrlRequestInterceptor *acquireInterceptor(); // Remove for Qt6 void releaseInterceptor(); QWebEngineUrlRequestInterceptor *requestInterceptor(); @@ -191,6 +192,7 @@ private: base::WeakPtrFactory<ProfileIODataQt> m_weakPtrFactory; // this should be always the last member QString m_dataPath; bool m_pendingStorageRequestGeneration = false; + volatile bool m_isInterceptorDeprecated = false; // Remove for Qt6 DISALLOW_COPY_AND_ASSIGN(ProfileIODataQt); friend class BrowsingDataRemoverObserverQt; diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index 5977a28a8..cd8ee8110 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -272,6 +272,7 @@ net::URLRequestContextGetter *ProfileQt::CreateRequestContext( m_profileIOData->setRequestContextData(protocol_handlers, std::move(request_interceptors)); m_profileIOData->updateStorageSettings(); + m_profileIOData->updateRequestInterceptor(); m_urlRequestContextGetter = new URLRequestContextGetterQt(m_profileIOData.get()); return m_urlRequestContextGetter.get(); } diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index ca2479965..d1fe786f6 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1414,8 +1414,7 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD }); QMimeData *mimeData = mimeDataFromDropData(*m_currentDropData); - if (handleDropDataFileContents(dropData, mimeData)) - allowedActions = Qt::MoveAction; + handleDropDataFileContents(dropData, mimeData); drag->setMimeData(mimeData); if (!pixmap.isNull()) { diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index a3a5881bf..07e0d3ba8 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -362,6 +362,7 @@ ProxyAuthentication WebEngineContext::qProxyNetworkAuthentication(QString host, const static char kChromiumFlagsEnv[] = "QTWEBENGINE_CHROMIUM_FLAGS"; const static char kDisableSandboxEnv[] = "QTWEBENGINE_DISABLE_SANDBOX"; +const static char kDisableInProcGpuThread[] = "QTWEBENGINE_DISABLE_GPU_THREAD"; static void appendToFeatureList(std::string &featureList, const char *feature) { @@ -608,6 +609,7 @@ WebEngineContext::WebEngineContext() #ifndef QT_NO_OPENGL threadedGpu = QOpenGLContext::supportsThreadedOpenGL(); #endif + threadedGpu = threadedGpu && !qEnvironmentVariableIsSet(kDisableInProcGpuThread); registerMainThreadFactories(threadedGpu); SetContentClient(new ContentClientQt); diff --git a/src/webengine/api/qtwebengineglobal.cpp b/src/webengine/api/qtwebengineglobal.cpp index a11618dba..4346832c9 100644 --- a/src/webengine/api/qtwebengineglobal.cpp +++ b/src/webengine/api/qtwebengineglobal.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qtwebengineglobal.h" +#include <QCoreApplication> namespace QtWebEngineCore { @@ -62,8 +63,8 @@ namespace QtWebEngine { /*! \fn QtWebEngine::initialize() - Sets up an OpenGL Context that can be shared between threads. This has to be done after - QGuiApplication is created, but before a Qt Quick window is created. + Sets up an OpenGL Context that can be shared between threads. This has to be done before + QGuiApplication is created and before window's QPlatformOpenGLContext is created. This has the same effect as setting the Qt::AA_ShareOpenGLContexts attribute with QCoreApplication::setAttribute before constructing @@ -71,7 +72,15 @@ namespace QtWebEngine { */ void initialize() { - QtWebEngineCore::initialize(); + QCoreApplication *app = QCoreApplication::instance(); + if (app) { + qWarning("QtWebEngine::initialize() called with QCoreApplication object already created and should be call before. "\ + "This is depreciated and may fail in the future."); + QtWebEngineCore::initialize(); + return; + } + // call initialize the same way as widgets do + qAddPreRoutine(QtWebEngineCore::initialize); } } // namespace QtWebEngine diff --git a/src/webengine/doc/src/qtwebengine-features.qdoc b/src/webengine/doc/src/qtwebengine-features.qdoc index 00b9cb496..8744f312a 100644 --- a/src/webengine/doc/src/qtwebengine-features.qdoc +++ b/src/webengine/doc/src/qtwebengine-features.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -37,6 +37,7 @@ \li \l{Audio and Video Codecs} \li \l{Chromium DevTools} \li \l{Client Certificates} + \li \l{Custom Schemes} \li \l{Drag and Drop} \li \l{Fullscreen} \li \l{HTML5 DRM} diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 7b66ac876..2b18d63b1 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -2539,16 +2539,13 @@ void QContextMenuBuilder::addMenuItem(ContextMenuItem menuItem) switch (menuItem) { case ContextMenuItem::Back: - action = new QAction(QIcon::fromTheme(QStringLiteral("go-previous")), QWebEnginePage::tr("&Back"), m_menu); - QObject::connect(action, &QAction::triggered, thisRef->d_ptr->view, &QWebEngineView::back); + action = thisRef->action(QWebEnginePage::Back); break; case ContextMenuItem::Forward: - action = new QAction(QIcon::fromTheme(QStringLiteral("go-next")), QWebEnginePage::tr("&Forward"), m_menu); - QObject::connect(action, &QAction::triggered, thisRef->d_ptr->view, &QWebEngineView::forward); + action = thisRef->action(QWebEnginePage::Forward); break; case ContextMenuItem::Reload: - action = new QAction(QIcon::fromTheme(QStringLiteral("view-refresh")), QWebEnginePage::tr("&Reload"), m_menu); - QObject::connect(action, &QAction::triggered, thisRef->d_ptr->view, &QWebEngineView::reload); + action = thisRef->action(QWebEnginePage::Reload); break; case ContextMenuItem::Cut: action = thisRef->action(QWebEnginePage::Cut); diff --git a/src/webenginewidgets/printer_worker.cpp b/src/webenginewidgets/printer_worker.cpp index 94a862cda..8e1c2a985 100644 --- a/src/webenginewidgets/printer_worker.cpp +++ b/src/webenginewidgets/printer_worker.cpp @@ -94,17 +94,9 @@ void PrinterWorker::print() documentCopies = 1; } - bool isLandscape = pdfiumWrapper.pageIsLandscape(0); - QPageLayout::Orientation prevOrientation = m_printer->pageLayout().orientation(); - m_printer->setPageOrientation(isLandscape ? QPageLayout::Landscape : QPageLayout::Portrait); + qreal resolution = m_printer->resolution() / 72.0; // pdfium uses points so 1/72 inch QPainter painter; - if (!painter.begin(m_printer)) { - qWarning("Failure to print on printer %ls: Could not open printer for painting.", - qUtf16Printable(m_printer->printerName())); - Q_EMIT resultReady(false); - return; - } for (int printedDocuments = 0; printedDocuments < documentCopies; printedDocuments++) { if (printedDocuments > 0) @@ -113,11 +105,20 @@ void PrinterWorker::print() int currentPageIndex = fromPage; for (int i = 0; true; i++) { - prevOrientation = m_printer->pageLayout().orientation(); - isLandscape = pdfiumWrapper.pageIsLandscape(currentPageIndex - 1); + QSizeF documentSize = (pdfiumWrapper.pageSize(currentPageIndex - 1) * resolution); + bool isLandscape = documentSize.width() > documentSize.height(); m_printer->setPageOrientation(isLandscape ? QPageLayout::Landscape : QPageLayout::Portrait); - - QSize pageSize = m_printer->pageRect().size(); + QRectF pageRect = m_printer->pageRect(QPrinter::DevicePixel); + documentSize = documentSize.scaled(pageRect.size(), Qt::KeepAspectRatio); + + // setPageOrientation has to be called before qpainter.begin() or before qprinter.newPage() so correct metrics is used, + // therefore call begin now for only first page + if (!painter.isActive() && !painter.begin(m_printer)) { + qWarning("Failure to print on printer %ls: Could not open printer for painting.", + qUtf16Printable(m_printer->printerName())); + Q_EMIT resultReady(false); + return; + } if (i > 0) m_printer->newPage(); @@ -132,21 +133,12 @@ void PrinterWorker::print() if (printedPages > 0) m_printer->newPage(); - QImage currentImage = pdfiumWrapper.pageAsQImage(currentPageIndex - 1); + QImage currentImage = pdfiumWrapper.pageAsQImage(currentPageIndex - 1,documentSize.width(),documentSize.height()); if (currentImage.isNull()) { Q_EMIT resultReady(false); return; } - - QRect targetRect = currentImage.rect(); - // Scale down currentImage by both width and height to fit into the drawable area of the page. - float scaleFactor = (float)pageSize.width() / (float)targetRect.width(); - targetRect = QRect(0, 0, targetRect.width() * scaleFactor, targetRect.height() * scaleFactor); - scaleFactor = (float)pageSize.height() / (float)targetRect.height(); - targetRect = QRect(0, 0, targetRect.width() * scaleFactor, targetRect.height() * scaleFactor); - - // Painting operations are automatically clipped to the bounds of the drawable part of the page. - painter.drawImage(targetRect, currentImage, currentImage.rect()); + painter.drawImage(0,0, currentImage); } if (currentPageIndex == toPage) @@ -156,8 +148,6 @@ void PrinterWorker::print() currentPageIndex++; else currentPageIndex--; - - m_printer->setPageOrientation(prevOrientation); } } painter.end(); |