diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-04-29 17:03:43 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-16 21:31:07 +0000 |
commit | 3ba5bdc86731ddc1736b01f8f24b21371361d658 (patch) | |
tree | d1956cd100c50b2afcd6ab881d44f07412fed20a /src/core/web_engine_context.cpp | |
parent | 0e5359669640f85d582339d44aeb0c3cfd19d316 (diff) |
Avoid setting feature switches multiple times
We were setting and overriding switch each time it was changed, this
led to needlessly long command line.
Change-Id: Icdfc9fb5769820330ad918da19da2c886dc02e80
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Diffstat (limited to 'src/core/web_engine_context.cpp')
-rw-r--r-- | src/core/web_engine_context.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 33cc723f5..a3a5881bf 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -363,7 +363,15 @@ ProxyAuthentication WebEngineContext::qProxyNetworkAuthentication(QString host, const static char kChromiumFlagsEnv[] = "QTWEBENGINE_CHROMIUM_FLAGS"; const static char kDisableSandboxEnv[] = "QTWEBENGINE_DISABLE_SANDBOX"; -static void appendToFeatureSwitch(base::CommandLine *commandLine, const char *featureSwitch, const char *feature) +static void appendToFeatureList(std::string &featureList, const char *feature) +{ + if (featureList.empty()) + featureList = feature; + else + featureList = featureList + "," + feature; +} + +static void appendToFeatureSwitch(base::CommandLine *commandLine, const char *featureSwitch, std::string feature) { if (!commandLine->HasSwitch(featureSwitch)) { commandLine->AppendSwitchASCII(featureSwitch, feature); @@ -475,35 +483,41 @@ WebEngineContext::WebEngineContext() if (isDesktopGLOrSoftware || isGLES2Context) parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext); #endif + + std::string disableFeatures; + std::string enableFeatures; // Needed to allow navigations within pages that were set using setHtml(). One example is // tst_QWebEnginePage::acceptNavigationRequest. // This is deprecated behavior, and will be removed in a future Chromium version, as per // upstream Chromium commit ba52f56207a4b9d70b34880fbff2352e71a06422. - appendToFeatureSwitch(parsedCommandLine, switches::kEnableFeatures, features::kAllowContentInitiatedDataUrlNavigations.name); + appendToFeatureList(enableFeatures, features::kAllowContentInitiatedDataUrlNavigations.name); // Surface synchronization breaks our current graphics integration (since 65) - appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, features::kEnableSurfaceSynchronization.name); + appendToFeatureList(disableFeatures, features::kEnableSurfaceSynchronization.name); // Viz Display Compositor is enabled by default since 73. Doesn't work for us (also implies SurfaceSynchronization) - appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, features::kVizDisplayCompositor.name); + appendToFeatureList(disableFeatures, features::kVizDisplayCompositor.name); // The video-capture service is not functioning at this moment (since 69) - appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, features::kMojoVideoCapture.name); + appendToFeatureList(disableFeatures, features::kMojoVideoCapture.name); // Breaks WebEngineNewViewRequest.userInitiated API (since 73) - appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, features::kUserActivationV2.name); + appendToFeatureList(disableFeatures, features::kUserActivationV2.name); - appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, features::kBackgroundFetch.name); + appendToFeatureList(disableFeatures, features::kBackgroundFetch.name); #if QT_CONFIG(webengine_printing_and_pdf) - appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, printing::features::kUsePdfCompositorServiceForPrint.name); + appendToFeatureList(disableFeatures, printing::features::kUsePdfCompositorServiceForPrint.name); #endif if (useEmbeddedSwitches) { // embedded switches are based on the switches for Android, see content/browser/android/content_startup_flags.cc - appendToFeatureSwitch(parsedCommandLine, switches::kEnableFeatures, features::kOverlayScrollbar.name); + appendToFeatureList(enableFeatures, features::kOverlayScrollbar.name); if (!parsedCommandLine->HasSwitch(switches::kDisablePinch)) parsedCommandLine->AppendSwitch(switches::kEnablePinch); parsedCommandLine->AppendSwitch(switches::kEnableViewport); parsedCommandLine->AppendSwitch(switches::kMainFrameResizesAreOrientationChanges); parsedCommandLine->AppendSwitch(cc::switches::kDisableCompositedAntialiasing); } + + appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, disableFeatures); + appendToFeatureSwitch(parsedCommandLine, switches::kEnableFeatures, enableFeatures); base::FeatureList::InitializeInstance( parsedCommandLine->GetSwitchValueASCII(switches::kEnableFeatures), parsedCommandLine->GetSwitchValueASCII(switches::kDisableFeatures)); |