diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-03 12:59:23 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-05 11:38:23 +0200 |
commit | 8f160af577e4d979954a63ab56f56e4d0c8ad0f8 (patch) | |
tree | 0c6cf366f3309c96e43e532527aff362320b7e94 /src | |
parent | 601003362c75283e9164e997e3835e7c36c6db00 (diff) | |
parent | fcdde728f0c4b4af5159b993e44eb6089d70aa90 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: Ida702fd5fa05a32d6cd7fc737aa061da74b675a0
Diffstat (limited to 'src')
30 files changed, 147 insertions, 157 deletions
diff --git a/src/3rdparty b/src/3rdparty -Subproject 4a23e0462a610f421d22fba38b0f9ba72120ae1 +Subproject 0e828760a46a39f26c7d9fd86654c363f4218be diff --git a/src/buildtools/configure_host.pro b/src/buildtools/configure_host.pro index fd27643ec..f1b3d47b0 100644 --- a/src/buildtools/configure_host.pro +++ b/src/buildtools/configure_host.pro @@ -4,8 +4,9 @@ TEMPLATE = aux # Pick up the host toolchain option(host_build) -GN_HOST_CPU = $$gnArch($$QMAKE_HOST.arch) -GN_TARGET_CPU = $$gnArch($$WEBENGINE_ARCH) +GN_HOST_CPU = $$gnArch($$QT_ARCH) +!isEmpty(QT_TARGET_ARCH): GN_TARGET_CPU = $$gnArch($$QT_TARGET_ARCH) +else: GN_TARGET_CPU = $$GN_HOST_CPU GN_OS = $$gnOS() clang: GN_CLANG = true @@ -15,11 +16,11 @@ use_gold_linker: GN_USE_GOLD=true else: GN_USE_GOLD=false GN_V8_HOST_CPU = $$GN_HOST_CPU -contains(GN_TARGET_CPU, "arm")|contains(GN_TARGET_CPU, "mips")|contains(GN_TARGET_CPU, "x86") { +contains(GN_TARGET_CPU, "arm")|contains(GN_TARGET_CPU, "mipsel")|contains(GN_TARGET_CPU, "x86") { # The v8 snapshot need a host that matches bitwidth, so we build makesnapshot to 32-bit variants of host. contains(GN_V8_HOST_CPU, x64): GN_V8_HOST_CPU = "x86" else: contains(GN_V8_HOST_CPU, arm64): GN_V8_HOST_CPU = "arm" - else: contains(GN_V8_HOST_CPU, mips64): GN_V8_HOST_CPU = "mips" + else: contains(GN_V8_HOST_CPU, mips64el): GN_V8_HOST_CPU = "mipsel" } # We always use the gcc_toolchain, because clang_toolchain is just diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro index 22c165e2a..d3d47e03a 100644 --- a/src/core/api/core_api.pro +++ b/src/core/api/core_api.pro @@ -53,11 +53,3 @@ SOURCES = \ unix:!isEmpty(QMAKE_LFLAGS_VERSION_SCRIPT):!static { SOURCES += qtbug-60565.cpp } - -msvc { - # Create a list of object files that can be used as response file for the linker. - # This is done to simulate -whole-archive on MSVC. - QMAKE_POST_LINK = \ - "if exist $(DESTDIR_TARGET).objects del $(DESTDIR_TARGET).objects$$escape_expand(\\n\\t)" \ - "for %%a in ($(OBJECTS)) do echo $$shell_quote($$shell_path($$OUT_PWD))\\%%a >> $(DESTDIR_TARGET).objects" -} diff --git a/src/core/api/qtbug-60565.cpp b/src/core/api/qtbug-60565.cpp index 21b545cca..be601b7e4 100644 --- a/src/core/api/qtbug-60565.cpp +++ b/src/core/api/qtbug-60565.cpp @@ -47,6 +47,7 @@ #endif #define SHIM_ALIAS_SYMBOL(fn) __attribute__((weak, alias(#fn))) +#define SHIM_HIDDEN __attribute__ ((visibility ("hidden"))) extern "C" { @@ -87,19 +88,19 @@ static void* __shimCppNewArray(size_t size); static void __shimCppDelete(void *address); static void __shimCppDeleteArray(void *address); -static void* ShimCppNew(size_t size) { +SHIM_HIDDEN void* ShimCppNew(size_t size) { return __shimCppNew(size); } -static void* ShimCppNewArray(size_t size) { +SHIM_HIDDEN void* ShimCppNewArray(size_t size) { return __shimCppNewArray(size); } -static void ShimCppDelete(void* address) { +SHIM_HIDDEN void ShimCppDelete(void* address) { __shimCppDelete(address); } -static void ShimCppDeleteArray(void* address) { +SHIM_HIDDEN void ShimCppDeleteArray(void* address) { __shimCppDeleteArray(address); } } // extern "C" diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp index 133006d70..ffee001ff 100644 --- a/src/core/browser_context_qt.cpp +++ b/src/core/browser_context_qt.cpp @@ -63,8 +63,9 @@ #include "components/prefs/pref_registry_simple.h" #include "components/user_prefs/user_prefs.h" #if BUILDFLAG(ENABLE_SPELLCHECK) -#include "chrome/common/pref_names.h" #include "chrome/browser/spellchecker/spellcheck_service.h" +#include "chrome/common/pref_names.h" +#include "components/spellcheck/browser/pref_names.h" #endif namespace QtWebEngineCore { @@ -80,12 +81,11 @@ BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter) #if BUILDFLAG(ENABLE_SPELLCHECK) // Initial spellcheck settings - registry->RegisterListPref(prefs::kSpellCheckDictionaries, new base::ListValue()); registry->RegisterStringPref(prefs::kAcceptLanguages, std::string()); - registry->RegisterStringPref(prefs::kSpellCheckDictionary, std::string()); - registry->RegisterBooleanPref(prefs::kSpellCheckUseSpellingService, false); - registry->RegisterBooleanPref(prefs::kEnableContinuousSpellcheck, false); - registry->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect, false); + registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries, new base::ListValue()); + registry->RegisterStringPref(spellcheck::prefs::kSpellCheckDictionary, std::string()); + registry->RegisterBooleanPref(spellcheck::prefs::kEnableSpellcheck, false); + registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckUseSpellingService, false); #endif //ENABLE_SPELLCHECK m_prefService = factory.Create(std::move(registry.get())); user_prefs::UserPrefs::Set(this, m_prefService.get()); @@ -216,7 +216,7 @@ void BrowserContextQt::failedToLoadDictionary(const std::string &language) void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages) { StringListPrefMember dictionaries_pref; - dictionaries_pref.Init(prefs::kSpellCheckDictionaries, m_prefService.get()); + dictionaries_pref.Init(spellcheck::prefs::kSpellCheckDictionaries, m_prefService.get()); std::vector<std::string> dictionaries; dictionaries.reserve(languages.size()); for (const auto &language : languages) @@ -227,7 +227,7 @@ void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages) QStringList BrowserContextQt::spellCheckLanguages() const { QStringList spellcheck_dictionaries; - for (const auto &value : *m_prefService->GetList(prefs::kSpellCheckDictionaries)) { + for (const auto &value : *m_prefService->GetList(spellcheck::prefs::kSpellCheckDictionaries)) { std::string dictionary; if (value->GetAsString(&dictionary)) spellcheck_dictionaries.append(QString::fromStdString(dictionary)); @@ -238,12 +238,12 @@ QStringList BrowserContextQt::spellCheckLanguages() const void BrowserContextQt::setSpellCheckEnabled(bool enabled) { - m_prefService->SetBoolean(prefs::kEnableContinuousSpellcheck, enabled); + m_prefService->SetBoolean(spellcheck::prefs::kEnableSpellcheck, enabled); } bool BrowserContextQt::isSpellCheckEnabled() const { - return m_prefService->GetBoolean(prefs::kEnableContinuousSpellcheck); + return m_prefService->GetBoolean(spellcheck::prefs::kEnableSpellcheck); } #endif //ENABLE_SPELLCHECK } // namespace QtWebEngineCore diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 24951cd07..60cfa6857 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -98,17 +98,18 @@ contains(QT_ARCH, "mips"):!host_build { host_build { gn_args += custom_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:host\" + GN_HOST_CPU = $$gnArch($$QT_ARCH) + gn_args += host_cpu=\"$$GN_HOST_CPU\" # Don't bother trying to use system libraries in this case gn_args += use_glib=false gn_args += use_system_libffi=false } else { gn_args += custom_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:target\" + gn_args += host_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:host\" cross_compile { - gn_args += host_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:host\" gn_args += v8_snapshot_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:v8_snapshot\" - GN_HOST_CPU = $$gnArch($$QMAKE_HOST.arch) GN_TARGET_CPU = $$gnArch($$QT_ARCH) - gn_args += host_cpu=\"$$GN_HOST_CPU\" target_cpu=\"$$GN_TARGET_CPU\" + gn_args += target_cpu=\"$$GN_TARGET_CPU\" } !contains(QT_CONFIG, no-pkg-config) { # Strip '>2 /dev/null' from $$pkgConfigExecutable() diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri index 49c725475..f5dd4a9d3 100644 --- a/src/core/config/windows.pri +++ b/src/core/config/windows.pri @@ -36,10 +36,8 @@ defineTest(usingMSVC32BitCrossCompiler) { msvc:contains(QT_ARCH, "i386"):!usingMSVC32BitCrossCompiler() { # The 32 bit MSVC linker runs out of memory if we do not remove all debug information. - gn_args += symbol_level=0 -} else { - # Chromium builds with debug info in release by default but Qt doesn't - CONFIG(release, debug|release):!force_debug_info: gn_args += symbol_level=1 + force_debug_info: gn_args -= symbol_level=1 + gn_args *= symbol_level=0 } msvc { @@ -55,10 +53,11 @@ msvc { SDK_PATH = $$(WINDOWSSDKDIR) VS_PATH= $$(VSINSTALLDIR) - gn_args += visual_studio_path=$$shell_quote($$VS_PATH) - gn_args += windows_sdk_path=$$shell_quote($$SDK_PATH) + gn_args += visual_studio_path=\"$$clean_path($$VS_PATH)\" + gn_args += windows_sdk_path=\"$$clean_path($$SDK_PATH)\" - contains(QT_ARCH, "i386"): gn_args += target_cpu=\"x86\" + GN_TARGET_CPU = $$gnArch($$QT_ARCH) + gn_args += target_cpu=\"$$GN_TARGET_CPU\" } else { fatal("Qt WebEngine for Windows can only be built with the Microsoft Visual Studio C++ compiler") diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index 38f66d641..8284029a0 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -139,10 +139,15 @@ content::ContentRendererClient *ContentMainDelegateQt::CreateContentRendererClie { #if defined(OS_LINUX) base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess(); - - if (parsedCommandLine->HasSwitch(switches::kLang)) { - const std::string &locale = parsedCommandLine->GetSwitchValueASCII(switches::kLang); - ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources(locale); + std::string process_type = parsedCommandLine->GetSwitchValueASCII(switches::kProcessType); + bool no_sandbox = parsedCommandLine->HasSwitch(switches::kNoSandbox); + + // Reload locale if the renderer process is sandboxed + if (process_type == switches::kRendererProcess && !no_sandbox) { + if (parsedCommandLine->HasSwitch(switches::kLang)) { + const std::string &locale = parsedCommandLine->GetSwitchValueASCII(switches::kLang); + ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources(locale); + } } #endif diff --git a/src/core/core.pro b/src/core/core.pro index 6cc8080e0..9709e62c3 100644 --- a/src/core/core.pro +++ b/src/core/core.pro @@ -17,23 +17,6 @@ core_generator.depends = core_headers # core_gn_generator.pro is a dummy .pro file that is used by qmake # to generate our main BUILD.gn file -core_icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat -core_icu.path = $$[QT_INSTALL_DATA]/resources -core_icu.CONFIG += no_check_exist - -core_locales.files = $$OUT_PWD/$$getConfigDir()/qtwebengine_locales/*.pak -core_locales.path = $$[QT_INSTALL_TRANSLATIONS]/qtwebengine_locales -core_locales.CONFIG += no_check_exist - -core_resources.files = \ - $$OUT_PWD/$$getConfigDir()/qtwebengine_resources.pak \ - $$OUT_PWD/$$getConfigDir()/qtwebengine_resources_100p.pak \ - $$OUT_PWD/$$getConfigDir()/qtwebengine_resources_200p.pak \ - $$OUT_PWD/$$getConfigDir()/qtwebengine_devtools_resources.pak -core_resources.path = $$[QT_INSTALL_DATA]/resources -core_resources.CONFIG += no_check_exist -INSTALLS += core_resources core_locales core_icu - gn_run.file = gn_run.pro gn_run.depends = core_generator diff --git a/src/core/core_module.pro b/src/core/core_module.pro index 44e8ac613..3785ddc46 100644 --- a/src/core/core_module.pro +++ b/src/core/core_module.pro @@ -47,10 +47,8 @@ CONFIG *= no_smart_library_merge osx { LIBS_PRIVATE += -Wl,-force_load,$${api_library_path}$${QMAKE_DIR_SEP}lib$${api_library_name}.a } else:msvc { - # Simulate -whole-archive by passing the list of object files that belong to the public - # API library as response file to the linker. QMAKE_LFLAGS += /OPT:REF - QMAKE_LFLAGS += @$${api_library_path}$${QMAKE_DIR_SEP}$${api_library_name}.lib.objects + QMAKE_LFLAGS += /WHOLEARCHIVE:$${api_library_path}$${QMAKE_DIR_SEP}$${api_library_name}.lib } else { LIBS_PRIVATE += -Wl,-whole-archive -l$$api_library_name -Wl,-no-whole-archive } diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp index b3c42aa08..8bdbaadd2 100644 --- a/src/core/media_capture_devices_dispatcher.cpp +++ b/src/core/media_capture_devices_dispatcher.cpp @@ -62,8 +62,14 @@ #include "content/public/common/media_stream_request.h" #include "media/audio/audio_device_description.h" #include "media/audio/audio_manager_base.h" +#include "media/media_features.h" #include "ui/base/l10n/l10n_util.h" +#if BUILDFLAG(ENABLE_WEBRTC) +#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" +#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" +#endif + #include <QtCore/qcoreapplication.h> namespace QtWebEngineCore { @@ -330,10 +336,38 @@ void MediaCaptureDevicesDispatcher::handleScreenCaptureAccessRequest(content::We { content::MediaStreamDevices devices; std::unique_ptr<content::MediaStreamUI> ui; +#if BUILDFLAG(ENABLE_WEBRTC) if (userAccepted) { - content::DesktopMediaID screenId = content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN, 0); + // Source id patterns are different across platforms. + // On Linux, the hardcoded value "0" is used. + // On Windows, the screens are enumerated consecutively in increasing order from 0. + // On macOS the source ids are randomish numbers assigned by the OS. + webrtc::DesktopCapturer::SourceId id = 0; + + // In order to provide a correct screen id, we query for the available screen ids, and + // select the first one as the main display id. + // The code is based on the file + // src/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc. + webrtc::DesktopCaptureOptions options = + webrtc::DesktopCaptureOptions::CreateDefault(); + options.set_disable_effects(false); + std::unique_ptr<webrtc::DesktopCapturer> screen_capturer( + webrtc::DesktopCapturer::CreateScreenCapturer(options)); + + if (screen_capturer) { + webrtc::DesktopCapturer::SourceList screens; + if (screen_capturer->GetSourceList(&screens)) { + if (screens.size() > 0) { + id = screens[0].id; + } + } + } + + content::DesktopMediaID screenId = content::DesktopMediaID( + content::DesktopMediaID::TYPE_SCREEN, id); ui = getDevicesForDesktopCapture(&devices, screenId, false/*capture_audio*/, false/*display_notification*/, getContentsUrl(webContents)); } +#endif std::map<content::WebContents*, RequestsQueue>::iterator it = m_pendingRequests.find(webContents); if (it == m_pendingRequests.end()) { diff --git a/src/core/qtwebengine.gni b/src/core/qtwebengine.gni index de1fa1836..c9f766a36 100644 --- a/src/core/qtwebengine.gni +++ b/src/core/qtwebengine.gni @@ -1,3 +1,4 @@ +import("//media/media_options.gni") import("//third_party/widevine/cdm/widevine.gni") chromium_version = exec_script("//build/util/version.py", [ "-f", rebase_path("//chrome/VERSION"), @@ -18,10 +19,12 @@ deps = [ "//components/visitedlink/renderer", "//components/web_cache/browser", "//components/web_cache/renderer", + "//components/spellcheck:build_features", "//content/public/app:browser", "//content/public/browser", "//content/public/common", "//content/public/renderer", + "//media:media_features", "//net:net_browser_services", "//net:net_with_v8", "//skia", @@ -36,6 +39,10 @@ if (enable_widevine) { deps += [ "//components/cdm/renderer"] } +if (enable_webrtc) { + deps += [ "//third_party/webrtc/base:base" ] +} + if (is_linux && !is_desktop_linux) { deps += [ "//ui/events/ozone:events_ozone_evdev"] } diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 3d51d4108..4e98a1016 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -942,10 +942,17 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) case Qt::ImFont: // TODO: Implement this return QVariant(); - case Qt::ImCursorRectangle: - if (!text_input_manager_ || !text_input_manager_->GetActiveWidget()) - return QVariant(); - return toQt(text_input_manager_->GetSelectionRegion()->caret_rect); + case Qt::ImCursorRectangle: { + if (text_input_manager_) { + if (auto *region = text_input_manager_->GetSelectionRegion()) { + gfx::Rect caretRect = gfx::RectBetweenSelectionBounds(region->anchor, region->focus); + if (caretRect.width() == 0) + caretRect.set_width(1); // IME API on Windows expects a width > 0 + return toQt(caretRect); + } + } + return QVariant(); + } case Qt::ImCursorPosition: return m_cursorPosition; case Qt::ImAnchorPosition: @@ -1253,7 +1260,6 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev) // to the same focused object, and cancelling the composition on the next event loop tick. if (!m_receivedEmptyImeText && m_imeInProgress && !hasSelection) { m_receivedEmptyImeText = true; - m_imeInProgress = false; QInputMethodEvent *eventCopy = new QInputMethodEvent(*ev); QGuiApplication::postEvent(qApp->focusObject(), eventCopy); } else { diff --git a/src/core/resource_bundle_qt.cpp b/src/core/resource_bundle_qt.cpp index 52355e996..c37854ea6 100644 --- a/src/core/resource_bundle_qt.cpp +++ b/src/core/resource_bundle_qt.cpp @@ -75,7 +75,8 @@ bool ResourceBundle::LocaleDataPakExists(const std::string& locale) #if defined(OS_LINUX) base::CommandLine *parsed_command_line = base::CommandLine::ForCurrentProcess(); std::string process_type = parsed_command_line->GetSwitchValueASCII(switches::kProcessType); - if (process_type == switches::kRendererProcess) { + bool no_sandbox = parsed_command_line->HasSwitch(switches::kNoSandbox); + if (process_type == switches::kRendererProcess && !no_sandbox) { // The Renderer Process is sandboxed thus only one locale is available in it. // The particular one is passed by the --lang command line option. if (!parsed_command_line->HasSwitch(switches::kLang) || parsed_command_line->GetSwitchValueASCII(switches::kLang) != locale) diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index 9fc8add01..fe1758655 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -340,8 +340,7 @@ void URLRequestContextGetterQt::generateCookieStore() cookieMonster->SetCookieableSchemes(cookieableSchemes); m_cookieDelegate->setCookieMonster(cookieMonster); - if (!m_updateAllStorage) { - Q_ASSERT(m_updateHttpCache); + if (!m_updateAllStorage && m_updateHttpCache) { // HttpCache needs to be regenerated when we generate a new channel id service generateHttpCache(); } @@ -469,6 +468,9 @@ void URLRequestContextGetterQt::generateHttpCache() QMutexLocker lock(&m_mutex); m_updateHttpCache = false; + if (m_updateCookieStore) + generateCookieStore(); + net::HttpCache::DefaultBackend* main_backend = 0; switch (m_httpCacheType) { case BrowserContextAdapter::MemoryHttpCache: diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 270096553..399c036a4 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -402,6 +402,7 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient) // We keep a reference to browserContextAdapter to keep it alive as long as we use it. // This is needed in case the QML WebEngineProfile is garbage collected before the WebEnginePage. d->browserContextAdapter = adapterClient->browserContextAdapter(); + Q_ASSERT(d->browserContextAdapter); // Create our own if a WebContents wasn't provided at construction. if (!d->webContents) @@ -1228,7 +1229,7 @@ static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeDat return; if (mimeData->hasHtml()) dropData->html = toNullableString16(mimeData->html()); - else if (mimeData->hasText()) + if (mimeData->hasText()) dropData->text = toNullableString16(mimeData->text()); } diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index ee7dbe1ce..8d75f24b7 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -339,7 +339,7 @@ public: virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) = 0; virtual void focusContainer() = 0; virtual void unhandledKeyEvent(QKeyEvent *event) = 0; - virtual void adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect & initialGeometry) = 0; + virtual void adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect & initialGeometry, const QUrl &targetUrl) = 0; virtual bool isBeingAdopted() = 0; virtual void close() = 0; virtual void windowCloseRejected() = 0; @@ -359,9 +359,7 @@ public: virtual void passOnFocus(bool reverse) = 0; // returns the last QObject (QWidget/QQuickItem) based object in the accessibility // hierarchy before going into the BrowserAccessibility tree -#ifndef QT_NO_ACCESSIBILITY virtual QObject *accessibilityParentObject() = 0; -#endif // QT_NO_ACCESSIBILITY virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) = 0; virtual void authenticationRequired(QSharedPointer<AuthenticationDialogController>) = 0; virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) = 0; diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 5bcb83c6b..a6e1fb438 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -306,6 +306,11 @@ void WebContentsDelegateQt::DidUpdateFaviconURL(const std::vector<content::Favic m_faviconManager->update(faviconCandidates); } +void WebContentsDelegateQt::WebContentsCreated(content::WebContents* /*source_contents*/, int /*opener_render_process_id*/, int /*opener_render_frame_id*/, const std::string& /*frame_name*/, const GURL& target_url, content::WebContents* new_contents) +{ + this->m_initialTargetUrl = toQt(target_url); +} + content::ColorChooser *WebContentsDelegateQt::OpenColorChooser(content::WebContents *source, SkColor color, const std::vector<content::ColorSuggestion> &suggestion) { Q_UNUSED(suggestion); @@ -445,7 +450,7 @@ QWeakPointer<WebContentsAdapter> WebContentsDelegateQt::createWindow(content::We { QSharedPointer<WebContentsAdapter> newAdapter = QSharedPointer<WebContentsAdapter>::create(new_contents); - m_viewClient->adoptNewWindow(newAdapter, static_cast<WebContentsAdapterClient::WindowOpenDisposition>(disposition), user_gesture, toQt(initial_pos)); + m_viewClient->adoptNewWindow(newAdapter, static_cast<WebContentsAdapterClient::WindowOpenDisposition>(disposition), user_gesture, toQt(initial_pos), m_initialTargetUrl); // If the client didn't reference the adapter, it will be deleted now, and the weak pointer zeroed. return newAdapter; diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 5ae442bbc..84799c2cd 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -104,6 +104,7 @@ public: void LoadProgressChanged(content::WebContents* source, double progress) override; void HandleKeyboardEvent(content::WebContents *source, const content::NativeWebKeyboardEvent &event) override; content::ColorChooser *OpenColorChooser(content::WebContents *source, SkColor color, const std::vector<content::ColorSuggestion> &suggestion) override; + void WebContentsCreated(content::WebContents* source_contents, int opener_render_process_id, int opener_render_frame_id, const std::string& frame_name, const GURL& target_url, content::WebContents* new_contents) override; content::JavaScriptDialogManager *GetJavaScriptDialogManager(content::WebContents *source) override; void EnterFullscreenModeForTab(content::WebContents* web_contents, const GURL& origin) override; void ExitFullscreenModeForTab(content::WebContents*) override; @@ -156,6 +157,7 @@ private: QScopedPointer<FaviconManager> m_faviconManager; SavePageInfo m_savePageInfo; QSharedPointer<FilePickerController> m_filePickerController; + QUrl m_initialTargetUrl; }; } // namespace QtWebEngineCore diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index bf3ea955c..1fceb4366 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -591,7 +591,7 @@ void QQuickWebEngineViewPrivate::unhandledKeyEvent(QKeyEvent *event) q->window()->sendEvent(q->parentItem(), event); } -void QQuickWebEngineViewPrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) +void QQuickWebEngineViewPrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &, const QUrl &targetUrl) { Q_Q(QQuickWebEngineView); QQuickWebEngineNewViewRequest request; @@ -599,8 +599,7 @@ void QQuickWebEngineViewPrivate::adoptNewWindow(QSharedPointer<WebContentsAdapte // to start loading it and possibly return it to its parent page window.open(). request.m_adapter = newWebContents; request.m_isUserInitiated = userGesture; - if (newWebContents) - request.m_requestedUrl = newWebContents->requestedUrl(); + request.m_requestedUrl = targetUrl; switch (disposition) { case WebContentsAdapterClient::NewForegroundTabDisposition: @@ -716,13 +715,11 @@ void QQuickWebEngineViewPrivate::runMouseLockPermissionRequest(const QUrl &secur adapter->grantMouseLockPermission(false); } -#ifndef QT_NO_ACCESSIBILITY QObject *QQuickWebEngineViewPrivate::accessibilityParentObject() { Q_Q(QQuickWebEngineView); return q; } -#endif // QT_NO_ACCESSIBILITY QSharedPointer<BrowserContextAdapter> QQuickWebEngineViewPrivate::browserContextAdapter() { @@ -1102,9 +1099,10 @@ void QQuickWebEngineViewPrivate::didFindText(quint64 requestId, int matchCount) void QQuickWebEngineViewPrivate::didPrintPage(quint64 requestId, const QByteArray &result) { + Q_Q(QQuickWebEngineView); QJSValue callback = m_callbacks.take(requestId); QJSValueList args; - args.append(QJSValue(result.data())); + args.append(qmlEngine(q)->toScriptValue(result)); callback.call(args); } diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 2ecd70d78..19ecf5e1f 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -107,7 +107,7 @@ public: virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE; virtual void focusContainer() Q_DECL_OVERRIDE; virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - virtual void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE; + virtual void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &, const QUrl &targetUrl) Q_DECL_OVERRIDE; virtual bool isBeingAdopted() Q_DECL_OVERRIDE; virtual void close() Q_DECL_OVERRIDE; virtual void windowCloseRejected() Q_DECL_OVERRIDE; @@ -129,9 +129,7 @@ public: virtual void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) Q_DECL_OVERRIDE; virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE; virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE; -#ifndef QT_NO_ACCESSIBILITY virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE; -#endif // QT_NO_ACCESSIBILITY virtual QtWebEngineCore::WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) Q_DECL_OVERRIDE; virtual void runGeolocationPermissionRequest(QUrl const&) Q_DECL_OVERRIDE; diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc index 2eeda6e8a..ec678672c 100644 --- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc +++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc @@ -69,7 +69,7 @@ \section2 Windows - On Windows, Visual Studio 2015 and Windows 10 SDK are required. + On Windows, Visual Studio 2015 or 2017 and Windows 10 SDK are required. \section2 Linux diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp index 86f3aaa64..a0ed00918 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp +++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp @@ -241,14 +241,8 @@ void RenderWidgetHostViewQtDelegateQuick::inputMethodStateChanged(bool editorVis bool RenderWidgetHostViewQtDelegateQuick::event(QEvent *event) { - if (event->type() == QEvent::ShortcutOverride) { - QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); - if (m_client->handleShortcutOverrideEvent(keyEvent)) - return true; - if (editorActionForKeyEvent(keyEvent) != QQuickWebEngineView::NoWebAction) - event->accept(); - return true; - } + if (event->type() == QEvent::ShortcutOverride) + return m_client->handleShortcutOverrideEvent(static_cast<QKeyEvent *>(event)); if (event->type() == QEvent::NativeGesture) return m_client->forwardEvent(event); diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index ea0117b95..d0305f81a 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -81,11 +81,9 @@ #include <QMenu> #include <QMessageBox> #include <QMimeData> -#if defined(QT_PRINTSUPPORT_LIB) -#ifndef QT_NO_PRINTER +#ifdef ENABLE_PRINTING #include <QPrinter> -#endif //QT_NO_PRINTER -#endif //QT_PRINTSUPPORT_LIB +#endif #include <QStandardPaths> #include <QStyle> #include <QTimer> @@ -403,10 +401,11 @@ void QWebEnginePagePrivate::unhandledKeyEvent(QKeyEvent *event) QGuiApplication::sendEvent(view->parentWidget(), event); } -void QWebEnginePagePrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry) +void QWebEnginePagePrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl) { Q_Q(QWebEnginePage); Q_UNUSED(userGesture); + Q_UNUSED(targetUrl); QWebEnginePage *newPage = q->createWindow(toWindowType(disposition)); if (!newPage) @@ -585,12 +584,10 @@ void QWebEnginePagePrivate::runMouseLockPermissionRequest(const QUrl &securityOr Q_EMIT q->featurePermissionRequested(securityOrigin, QWebEnginePage::MouseLock); } -#ifndef QT_NO_ACCESSIBILITY QObject *QWebEnginePagePrivate::accessibilityParentObject() { return view; } -#endif // QT_NO_ACCESSIBILITY void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const { @@ -1969,7 +1966,7 @@ QStringList QWebEnginePage::chooseFiles(FileSelectionMode mode, const QStringLis break; // Chromium extension, not exposed as part of the public API for now. case FilePickerController::UploadFolder: - str = QFileDialog::getExistingDirectory(view(), tr("Select folder to upload")) + QLatin1Char('/'); + str = QFileDialog::getExistingDirectory(view(), tr("Select folder to upload")); if (!str.isNull()) ret << str; break; @@ -2126,8 +2123,6 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res #endif // if defined(ENABLE_PDF) } -#if defined(QT_PRINTSUPPORT_LIB) -#ifndef QT_NO_PRINTER /*! \fn void QWebEnginePage::print(QPrinter *printer, FunctorOrLambda resultCallback) Renders the current content of the page into a temporary PDF document, then prints it using \a printer. @@ -2164,8 +2159,6 @@ void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &re d->m_callbacks.invokeDirectly(resultCallback, false); #endif // if defined(ENABLE_PDF) } -#endif // if defined(QT_NO_PRINTER) -#endif // if defined(QT_PRINTSUPPORT_LIB) /*! \since 5.7 diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index 37a59e88c..74ebd0a35 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -55,11 +55,7 @@ QT_BEGIN_NAMESPACE class QMenu; -#if defined(QT_PRINTSUPPORT_LIB) -#ifndef QT_NO_PRINTER class QPrinter; -#endif // QT_NO_PRINTER -#endif // QT_PRINTSUPPORT_LIB class QWebChannel; class QWebEngineContextMenuData; @@ -310,15 +306,11 @@ public: void printToPdf(const QWebEngineCallback<const QByteArray&> &resultCallback, const QPageLayout &layout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF())); #endif -#if defined(QT_PRINTSUPPORT_LIB) -#ifndef QT_NO_PRINTER #ifdef Q_QDOC void print(QPrinter *printer, FunctorOrLambda resultCallback); #else void print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback); #endif // QDOC -#endif // QT_NO_PRINTER -#endif // QT_PRINTSUPPORT_LIB const QWebEngineContextMenuData &contextMenuData() const; diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index c7b805c45..ec84f05e1 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -100,7 +100,7 @@ public: virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE; virtual void focusContainer() Q_DECL_OVERRIDE; virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - virtual void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry) Q_DECL_OVERRIDE; + virtual void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl) Q_DECL_OVERRIDE; void adoptNewWindowImpl(QWebEnginePage *newPage, const QSharedPointer<QtWebEngineCore::WebContentsAdapter> &newWebContents, const QRect &initialGeometry); @@ -126,9 +126,7 @@ public: virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE; virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE; virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE; -#ifndef QT_NO_ACCESSIBILITY virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE; -#endif // QT_NO_ACCESSIBILITY virtual QtWebEngineCore::WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &controller) Q_DECL_OVERRIDE; virtual void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) Q_DECL_OVERRIDE; diff --git a/src/webenginewidgets/api/qwebenginesettings.cpp b/src/webenginewidgets/api/qwebenginesettings.cpp index 4c8c4be33..6e24b4b51 100644 --- a/src/webenginewidgets/api/qwebenginesettings.cpp +++ b/src/webenginewidgets/api/qwebenginesettings.cpp @@ -124,9 +124,9 @@ QWebEngineSettings *QWebEngineSettings::globalSettings() #endif /*! - Returns the default settings for the web engine page. - - \sa globalSettings() + Returns the settings for a web engine page that belongs to the default + profile. All web pages not specifically created with another profile belong + to the default profile. */ QWebEngineSettings *QWebEngineSettings::defaultSettings() { diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc index bc841849e..26f3964da 100644 --- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc @@ -24,12 +24,9 @@ /*! \fn static QWebEngineSettings *QWebEngineSettings::globalSettings() - Returns the global settings object. + \obsolete - Any setting changed on the default object is automatically applied to all - QWebEnginePage instances where the particular setting is not overridden already. - - \sa defaultSettings() + Use defaultSettings() instead. */ /*! @@ -40,16 +37,15 @@ \inmodule QtWebEngineWidgets - Each QWebEnginePage object has its own QWebEngineSettings object, which configures the - settings for that page. If a setting is not configured, then it is looked - up in the global settings object, which can be accessed using - globalSettings(). - QWebEngineSettings allows configuration of browser properties, such as font sizes and families, the location of a custom style sheet, and generic attributes, such as JavaScript support. Individual attributes are set using the setAttribute() function. The \l{QWebEngineSettings::WebAttribute}{WebAttribute} enum further describes each attribute. + Each QWebEnginePage object has its own QWebEngineSettings object, which configures the + settings for that page. If a setting is not configured for a web engine + page, it is looked up in the settings of the profile the page belongs to. + \sa QWebEnginePage::settings(), QWebEngineView::settings() */ @@ -184,10 +180,8 @@ /*! \fn void QWebEngineSettings::resetFontSize(FontSize type) - Resets the font size for \a type to the size specified in the global - settings object. - - This function has no effect on the global QWebEngineSettings instance. + Resets the font size for \a type to the size specified in the profile that + the page belongs to. */ /*! @@ -222,10 +216,8 @@ /*! \fn void QWebEngineSettings::resetFontFamily(FontFamily which) - Resets the actual font family specified by \a which to the one set - in the global QWebEngineSettings instance. - - This function has no effect on the global QWebEngineSettings instance. + Resets the actual font family specified by \a which to the one specified + in the profile that the page belongs to. */ /*! @@ -245,9 +237,5 @@ \fn void QWebEngineSettings::resetAttribute(WebAttribute attribute) Resets the setting of \a attribute to the value specified in the - global QWebEngineSettings instance. - - This function has no effect on the global QWebEngineSettings instance. - - \sa globalSettings() + profile that the page belongs to. */ diff --git a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc index 3b27ca146..e54c5d507 100644 --- a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc @@ -141,6 +141,12 @@ \warning This function works only for HTML. For other MIME types (such as XHTML or SVG), setContent() should be used instead. + \note Content larger than 2 MB cannot be displayed, because setHtml() + converts the provided HTML to percent-encoding and places \c data: in front + of it to create the URL that it navigates to. Thereby, the provided code + becomes a URL that exceeds the 2 MB limit set by Chromium. If the content is + too large, the loadFinished() signal is triggered with \c success=false. + \sa load(), setContent(), QWebEnginePage::toHtml(), QWebEnginePage::setContent() */ 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 c608ba2aa..d02191b23 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -59,15 +59,6 @@ namespace QtWebEngineCore { -static bool handleShortcutOverrideEvent(RenderWidgetHostViewQtDelegateClient *client, QKeyEvent *ke) -{ - if (client->handleShortcutOverrideEvent(ke)) - return true; - if (editorActionForKeyEvent(ke) != QWebEnginePage::NoWebAction) - ke->accept(); - return true; -} - class RenderWidgetHostViewQuickItem : public QQuickItem { public: RenderWidgetHostViewQuickItem(RenderWidgetHostViewQtDelegateClient *client) : m_client(client) @@ -79,10 +70,8 @@ public: protected: bool event(QEvent *event) override { - if (event->type() == QEvent::ShortcutOverride) { - handleShortcutOverrideEvent(m_client, static_cast<QKeyEvent *>(event)); - return true; - } + if (event->type() == QEvent::ShortcutOverride) + return m_client->handleShortcutOverrideEvent(static_cast<QKeyEvent *>(event)); return QQuickItem::event(event); } void focusInEvent(QFocusEvent *event) override @@ -454,10 +443,8 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event) // We forward focus events later, once they have made it to the m_rootItem. return QQuickWidget::event(event); case QEvent::ShortcutOverride: - if (event->type() == QEvent::ShortcutOverride) { - handleShortcutOverrideEvent(m_client, static_cast<QKeyEvent *>(event)); + if (m_client->handleShortcutOverrideEvent(static_cast<QKeyEvent *>(event))) return true; - } break; case QEvent::DragEnter: case QEvent::DragLeave: |