summaryrefslogtreecommitdiffstats
path: root/src/core/web_engine_settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/web_engine_settings.cpp')
-rw-r--r--src/core/web_engine_settings.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
index fe40298bb..31d120899 100644
--- a/src/core/web_engine_settings.cpp
+++ b/src/core/web_engine_settings.cpp
@@ -48,6 +48,7 @@
#include "content/browser/gpu/gpu_process_host.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/web_preferences.h"
+#include "ui/events/event_switches.h"
#include <QFont>
#include <QTimer>
@@ -97,6 +98,29 @@ static inline bool isTouchScreenAvailable() {
return touchScreenAvailable;
}
+static inline bool isTouchEventsAPIEnabled() {
+ static bool initialized = false;
+ static bool touchEventsAPIEnabled = false;
+ if (!initialized) {
+ base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess();
+
+ // By default the Touch Events API support (presence of 'ontouchstart' in 'window' object)
+ // will be determined based on the availability of touch screen devices.
+ const std::string touchEventsSwitchValue =
+ parsedCommandLine->HasSwitch(switches::kTouchEventFeatureDetection) ?
+ parsedCommandLine->GetSwitchValueASCII(switches::kTouchEventFeatureDetection) :
+ switches::kTouchEventFeatureDetectionAuto;
+
+ if (touchEventsSwitchValue == switches::kTouchEventFeatureDetectionEnabled)
+ touchEventsAPIEnabled = true;
+ else if (touchEventsSwitchValue == switches::kTouchEventFeatureDetectionAuto)
+ touchEventsAPIEnabled = isTouchScreenAvailable();
+
+ initialized = true;
+ }
+ return touchEventsAPIEnabled;
+}
+
WebEngineSettings::WebEngineSettings(WebEngineSettings *_parentSettings)
: m_adapter(0)
@@ -298,6 +322,7 @@ void WebEngineSettings::doApply()
void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *prefs)
{
// Override for now
+ prefs->touch_event_feature_detection_enabled = isTouchEventsAPIEnabled();
prefs->device_supports_touch = isTouchScreenAvailable();
if (prefs->viewport_enabled) {
// We should enable viewport and viewport-meta together, but since 5.7 we