diff --git a/config.tests/srtp/srtp.cpp b/config.tests/re2/re2.cpp
similarity index 90%
rename from config.tests/srtp/srtp.cpp
rename to config.tests/re2/re2.cpp
index 7dfcc832ad3a128395a273dc5785d570cfe3fac9..f2c0b01702c11dc7e6b2c61630b9bb11d542a04f 100644
--- a/config.tests/srtp/srtp.cpp
+++ b/config.tests/re2/re2.cpp
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
 ** Contact: https://www.qt.io/licensing/
 **
 ** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -26,10 +26,10 @@
 **
 ****************************************************************************/
 
-#include <srtp/srtp.h>
+#include <re2/re2.h>
 
 int main(int, char **)
 {
-    err_status_t status = srtp_init();
-    return status == err_status_ok;
+    RE2 re2("dummytest");
+    return 0;
 }
diff --git a/config.tests/re2/re2.pro b/config.tests/re2/re2.pro
new file mode 100644
index 0000000000000000000000000000000000000000..b1a26d918079e55e3fff562f0091fd39ff4690d0
--- /dev/null
+++ b/config.tests/re2/re2.pro
@@ -0,0 +1,3 @@
+SOURCES += re2.cpp
+LIBS += -lre2
+CONFIG -= qt
diff --git a/config.tests/srtp/srtp.pro b/config.tests/srtp/srtp.pro
deleted file mode 100644
index 2151d64aa08cfd4011be877fe4f5b2bef442fcc3..0000000000000000000000000000000000000000
--- a/config.tests/srtp/srtp.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-linux:SOURCES += srtp.cpp
-LIBS += -lsrtp
-CONFIG -= qt
diff --git a/config_help.txt b/config_help.txt
new file mode 100644
index 0000000000000000000000000000000000000000..6ff24f8c8c6456e18dc4d82384f93d1918e3c65d
--- /dev/null
+++ b/config_help.txt
@@ -0,0 +1,13 @@
+Webengine options:
+
+  -alsa ................ Enable ALSA support [auto] (Linux only)
+  -webengine-icu ....... Select used ICU libraries [system/qt] (Linux only)
+  -ffmpeg .............. Select used FFmpeg libraries [system/qt] (Linux only)
+  -opus ................ Select used Opus libraries [system/qt] (Linux only)
+  -webp ................ Select used WebP libraries [system/qt] (Linux only)
+  -pepper-plugins ...... Enable use of Pepper Flash and Widevine plugins [auto]
+  -printing-and-pdf .... Enable use of printing and output to PDF [auto]
+  -proprietary-codecs .. Enable support for proprietary codecs [no]
+  -pulseaudio .......... Enable PulseAudio support [auto] (Linux only)
+  -spellchecker ........ Enable support for spellchecker [yes]
+  -webrtc .............. Enable support for WebRTC [auto]
diff --git a/configure.json b/configure.json
index 19a32a17c2e692e8fc9da7c7d992bd31057c5363..a176b845bb90c17ce9a504195d039dfdcd6d9b74 100644
--- a/configure.json
+++ b/configure.json
@@ -97,6 +97,11 @@
             "label": "embedded",
             "type": "embedded"
         },
+        "re2": {
+            "label": "re2",
+            "test": "re2",
+            "type": "compile"
+        },
         "glibc": {
             "label": "glibc > 2.16",
             "type": "detectGlibc"
@@ -210,6 +215,12 @@
             "condition": "libs.icu",
             "output": [ "privateFeature" ]
         },
+        "system-re2": {
+            "label": "re2",
+            "autoDetect": "config.unix",
+            "condition": "tests.re2",
+            "output": [ "privateFeature" ]
+        },
         "system-ninja": {
             "label": "Using system ninja",
             "condition": "tests.ninja",
@@ -276,6 +287,7 @@
                    "section": "System libraries",
                    "condition": "config.unix",
                    "entries": [
+                        "system-re2",
                         "system-icu",
                         "system-webp",
                         "system-opus",
diff --git a/configure.pri b/configure.pri
index 0030ce3bba78501125772b2b0fee1eb3dc0daf5d..f8ecd3db693eede88c66c24a88aab81412062881 100644
--- a/configure.pri
+++ b/configure.pri
@@ -18,9 +18,9 @@ defineTest(isPythonVersionSupported) {
 }
 
 defineTest(qtConfTest_detectPython2) {
-    python = $$qtConfFindInPath("python2")
+    python = $$qtConfFindInPath("python2$$EXE_SUFFIX")
     isEmpty(python) {
-        qtLog("'python2' not found in PATH. Checking for 'python'.")
+        qtLog("'python2$$EXE_SUFFIX' not found in PATH. Checking for 'python$$EXE_SUFFIX'.")
         python = $$qtConfFindInPath("python$$EXE_SUFFIX")
     }
     isEmpty(python) {
diff --git a/dist/changes-5.6.3 b/dist/changes-5.6.3
new file mode 100644
index 0000000000000000000000000000000000000000..88af64f80a3005caa9d27a01cc4260ce70da5c38
--- /dev/null
+++ b/dist/changes-5.6.3
@@ -0,0 +1,73 @@
+Qt 5.6.3 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.6.0.
+
+Qt WebEngine 5.6.3 contains a merge from Qt WebEngine 5.7.1 and all
+bug-fixes in Qt 5.7.1 are also in Qt 5.6.3. These are listed both here
+and in changes-5.7.1.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+  http://doc.qt.io/qt-5/index.html
+
+The Qt version 5.6 series is binary compatible with the 5.5.x series.
+Applications compiled for 5.5 will continue to run with 5.6.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+  https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+*                             General                                      *
+****************************************************************************
+
+ - Chromium Snapshot:
+   * Updated the Chromium version to 49.0.2623.111.
+   * Backported security fixes from Chromium up to version 59.0.3071.104.
+    Including: CVE-2016-5133, CVE-2016-5147, CVE-2016-5153, CVE-2016-5155,
+      CVE-2016-5161, CVE-2016-5166, CVE-2016-5170, CVE-2016-5171,
+      CVE-2016-5172, CVE-2016-5181, CVE-2016-5185, CVE-2016-5186,
+      CVE-2016-5187, CVE-2016-5188, CVE-2016-5192, CVE-2016-5198.
+      CVE-2016-5205, CVE-2016-5207, CVE-2016-5208, CVE-2016-5214,
+      CVE-2016-5215, CVE-2016-5221, CVE-2016-5222, CVE-2016-5224,
+      CVE-2016-5225, CVE-2016-9650, CVE-2016-9651, CVE-2016-9652,
+      CVE-2017-5006, CVE-2017-5007, CVE-2017-5008, CVE-2017-5009,
+      CVE-2017-5010, CVE-2017-5012, CVE-2017-5015, CVE-2017-5016,
+      CVE-2017-5017, CVE-2017-5019, CVE-2017-5023, CVE-2017-5024,
+      CVE-2017-5025, CVE-2017-5026, CVE-2017-5027, CVE-2017-5029,
+      CVE-2017-5033, CVE-2017-5037, CVE-2017-5044, CVE-2017-5046,
+      CVE-2017-5047, CVE-2017-5048, CVE-2017-5049, CVE-2017-5050,
+      CVE-2017-5051, CVE-2017-5052, CVE-2017-5054, CVE-2017-5059,
+      CVE-2017-5061, CVE-2017-5062, CVE-2017-5065, CVE-2017-5067,
+      CVE-2017-5069, CVE-2017-5070, CVE-2017-5071, CVE-2017-5075,
+      CVE-2017-5076, CVE-2017-5078, CVE-2017-5083 and CVE-2017-5089
+   * Added support for macOS 10.12 Sierra.
+   * Backported various crash and assertion fixes.
+
+ - QtWebEngineCore:
+   * [QTBUG-51244, QTBUG-54795] Fixed select control issues.
+   * Fixed several focus issues.
+   * Fixed regression with fine-grained wheel events.
+   * [QTBUG-54221] Fixed editing short-cuts in plugins.
+   * [QTBUG-54222] Fixed potential infinite loop on history load.
+   * Fixed Flash plugin clipboard access.
+
+****************************************************************************
+*                      Platform Specific Changes                           *
+****************************************************************************
+
+ - Linux:
+   * [QTBUG-55367] Fixed reading timezone when running sandboxed.
+   * Fixed crash when using Wayland QPA.
+   * Improved OpenGL check, so EGL/GLES2 mode can be used with Desktop
+     OpenGL if the driver has the ARB_ES2_compatibility extension.
+
+ - Windows:
+   * It is no longer possible to build on a 32-bit Windows host, but
+   32-bit binaries can still be built on a 64-bit host.
+   * [QTBUG-52201, QTBUG-55501, QTBUG-56020] Fixed crashes and asserts
+     upon initialization of the global shared OpenGL context.
diff --git a/mkspecs/features/configure.prf b/mkspecs/features/configure.prf
index 37128bf9312e9ca75c8bc87027ebf5551fc2a139..2264ba7042edbe1acad5488c7013a02f5d1ab940 100644
--- a/mkspecs/features/configure.prf
+++ b/mkspecs/features/configure.prf
@@ -50,6 +50,7 @@ defineTest(runConfigure) {
     qtConfig(system-opus): WEBENGINE_CONFIG += use_system_opus
     qtConfig(system-ffmpeg): WEBENGINE_CONFIG += use_system_ffmpeg
     qtConfig(system-icu): WEBENGINE_CONFIG += use_system_icu
+    qtConfig(system-re2): WEBENGINE_CONFIG += use_system_re2
 
     !contains(WEBENGINE_CONFIG, use_system_libwebp): WEBENGINE_CONFIG += use_bundled_libwebp
     !contains(WEBENGINE_CONFIG, use_system_opus): WEBENGINE_CONFIG += use_bundled_opus
@@ -122,11 +123,6 @@ defineTest(runConfigure) {
             log("Compatible system libvpx not found. Using Chromium's copy.$${EOL}")
             WEBENGINE_CONFIG += use_bundled_libvpx
         }
-        config_srtp: WEBENGINE_CONFIG += use_system_libsrtp
-        else {
-            log("System libsrtp not found. Using Chromium's copy.$${EOL}")
-            WEBENGINE_CONFIG += use_bundled_srtp
-        }
         config_snappy: WEBENGINE_CONFIG += use_system_snappy
         else {
             log("System snappy not found. Using Chromium's copy.$${EOL}")
@@ -162,11 +158,6 @@ defineTest(runConfigure) {
         !isEmpty(use_bundled): log("  Optional bundled libraries used .... $$use_bundled$${EOL}")
     }
     log("Configurable features:$${EOL}")
-    use?(proprietary_codecs) {
-        log("  Proprietary codecs (H264, MP3) ..... Enabled$${EOL}")
-    } else {
-        log("  Proprietary codecs (H264, MP3) ..... Not enabled         (Default, enable with -proprietary-codecs)$${EOL}")
-    }
     qtHaveModule(positioning): {
         log("  Geolocation ........................ Enabled$${EOL}")
     } else {
diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf
index 56894e58a8fdf3c7cba3f019306d384a71723b56..b78d2a11238cc18b9243dac02f61c50d83934cff 100644
--- a/mkspecs/features/functions.prf
+++ b/mkspecs/features/functions.prf
@@ -81,9 +81,10 @@ defineTest(isPlatformSupported) {
 defineTest(isArchSupported) {
     contains(QT_ARCH, "i386")|contains(QT_ARCH, "x86_64"): return(true)
     contains(QT_ARCH, "arm")|contains(QT_ARCH, "arm64"): return(true)
-    contains(QT_ARCH, "mips")|contains(QT_ARCH, "mips64"): return(true)
+    contains(QT_ARCH, "mips"): return(true)
+#     contains(QT_ARCH, "mips64"): return(true)
 
-    skipBuild("QtWebEngine can only be built for x86, x86-64, ARM, Aarch64, MIPSel, and MIPS64 architectures.")
+    skipBuild("QtWebEngine can only be built for x86, x86-64, ARM, Aarch64, and MIPSel architectures.")
     return(false)
 }
 
diff --git a/qtwebengine.pro b/qtwebengine.pro
index 034e946c42cda3844513da47b99166568ca1720c..1375bc5401700d7a670fbb248627f94d99844577 100644
--- a/qtwebengine.pro
+++ b/qtwebengine.pro
@@ -25,5 +25,5 @@ OTHER_FILES = \
     config.tests/libcap/* \
     config.tests/libvpx/* \
     config.tests/snappy/* \
-    config.tests/srtp/* \
+    config.tests/re2/* \
     mkspecs/features/*
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri
index 60cfa6857dbbedb936de203a1b52e48a0192f089..28278e9039adddb065c4df7a2100ee396bf805d3 100644
--- a/src/core/config/linux.pri
+++ b/src/core/config/linux.pri
@@ -106,10 +106,14 @@ host_build {
 } else {
     gn_args += custom_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:target\"
     gn_args += host_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:host\"
+    GN_TARGET_CPU = $$gnArch($$QT_ARCH)
     cross_compile {
         gn_args += v8_snapshot_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:v8_snapshot\"
-        GN_TARGET_CPU = $$gnArch($$QT_ARCH)
+        # FIXME: we should set host_cpu in case host-toolchain doesn't match os arch,
+        # but currently we don't it available at this point
         gn_args += target_cpu=\"$$GN_TARGET_CPU\"
+    } else {
+        gn_args += host_cpu=\"$$GN_TARGET_CPU\"
     }
     !contains(QT_CONFIG, no-pkg-config) {
         # Strip '>2 /dev/null' from $$pkgConfigExecutable()
@@ -139,7 +143,6 @@ host_build {
 
     use?(system_libevent): gn_args += use_system_libevent=true
     use?(system_libwebp):  gn_args += use_system_libwebp=true
-    #use?(system_libsrtp):  gn_args += use_system_libsrtp=true
     use?(system_libxslt):  gn_args += use_system_libxml=true use_system_libxslt=true
     #use?(system_jsoncpp):  gn_args += use_system_jsoncpp=true
     use?(system_opus):     gn_args += use_system_opus=true
@@ -147,5 +150,6 @@ host_build {
     use?(system_vpx):      gn_args += use_system_libvpx=true
     use?(system_icu):      gn_args += use_system_icu=true icu_use_data_file=false
     use?(system_ffmpeg):   gn_args += use_system_ffmpeg=true
+    use?(system_re2):      gn_args += use_system_re2=true
     #use?(system_protobuf): gn_args += use_system_protobuf=true
 }
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index 5d635374045fd64e76240f6d181a2f88bb693d71..e1902a3ebf2b284cba8a51c95e714d766f10f31e 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -923,6 +923,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
             rpLayer->setRect(toQt(pass->output_rect));
             rpLayer->setSize(toQt(pass->output_rect.size()));
             rpLayer->setFormat(pass->has_transparent_background ? GL_RGBA : GL_RGB);
+            rpLayer->setMirrorVertical(true);
         } else
             renderPassParent = this;
 
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 0c98c9e21fe0ba504370c44562984cc434da5cb2..8d79a18693db99c72846e5ad5fca805d816ee0c3 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -80,6 +80,7 @@
 #include <QFocusEvent>
 #include <QGuiApplication>
 #include <QInputMethodEvent>
+#include <QLoggingCategory>
 #include <QTextFormat>
 #include <QKeyEvent>
 #include <QMouseEvent>
@@ -919,11 +920,11 @@ bool RenderWidgetHostViewQt::forwardEvent(QEvent *event)
     case QEvent::TouchCancel:
         handleTouchEvent(static_cast<QTouchEvent*>(event));
         break;
+#ifndef QT_NO_GESTURES
     case QEvent::NativeGesture:
         handleGestureEvent(static_cast<QNativeGestureEvent *>(event));
         break;
-    case QEvent::HoverEnter:
-    case QEvent::HoverLeave:
+#endif // QT_NO_GESTURES
     case QEvent::HoverMove:
         handleHoverEvent(static_cast<QHoverEvent*>(event));
         break;
@@ -1316,6 +1317,7 @@ void RenderWidgetHostViewQt::clearPreviousTouchMotionState()
     m_touchMotionStarted = false;
 }
 
+#ifndef QT_NO_GESTURES
 void RenderWidgetHostViewQt::handleGestureEvent(QNativeGestureEvent *ev)
 {
     const Qt::NativeGestureType type = ev->gestureType();
@@ -1326,12 +1328,22 @@ void RenderWidgetHostViewQt::handleGestureEvent(QNativeGestureEvent *ev)
                                         static_cast<double>(dpiScale())));
     }
 }
+#endif
+
+Q_DECLARE_LOGGING_CATEGORY(QWEBENGINE_TOUCH_HANDLING);
+Q_LOGGING_CATEGORY(QWEBENGINE_TOUCH_HANDLING, "qt.webengine.touch");
 
 void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev)
 {
     // On macOS instead of handling touch events, we use the OS provided QNativeGestureEvents.
 #ifdef Q_OS_MACOS
-    return;
+    if (ev->spontaneous()) {
+        return;
+    } else {
+        qCWarning(QWEBENGINE_TOUCH_HANDLING)
+            << "Sending simulated touch events to Chromium does not work properly on macOS. "
+               "Consider using QNativeGestureEvents or QMouseEvents.";
+    }
 #endif
 
     // Chromium expects the touch event timestamps to be comparable to base::TimeTicks::Now().
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index cb1a5980d844f5e7ddfbb9eddc49189a74ab57ac..31162649225f066015f6df7d1b0a81d12599b110 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -183,7 +183,9 @@ public:
     void handleKeyEvent(QKeyEvent*);
     void handleWheelEvent(QWheelEvent*);
     void handleTouchEvent(QTouchEvent*);
+#ifndef QT_NO_GESTURES
     void handleGestureEvent(QNativeGestureEvent *);
+#endif
     void handleHoverEvent(QHoverEvent*);
     void handleFocusEvent(QFocusEvent*);
     void handleInputMethodEvent(QInputMethodEvent*);
diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp
index 9e72885c3c7316b1475d674b0f35fc443e72f8c0..6e5e13866debf8f39a8ebf7ef422e07debe5c8a4 100644
--- a/src/core/surface_factory_qt.cpp
+++ b/src/core/surface_factory_qt.cpp
@@ -56,13 +56,7 @@
 #if defined(USE_OZONE)
 
 #include <EGL/egl.h>
-
-#ifndef QT_LIBDIR_EGL
-#define QT_LIBDIR_EGL "/usr/lib"
-#endif
-#ifndef QT_LIBDIR_GLES2
-#define QT_LIBDIR_GLES2 QT_LIBDIR_EGL
-#endif
+#include <dlfcn.h>
 
 namespace QtWebEngineCore {
 
@@ -99,29 +93,21 @@ base::NativeLibrary LoadLibrary(const base::FilePath& filename) {
 
 bool GLOzoneQt::LoadGLES2Bindings()
 {
-    base::FilePath libEGLPath = QtWebEngineCore::toFilePath(QT_LIBDIR_EGL);
-    libEGLPath = libEGLPath.Append("libEGL.so.1");
-    base::NativeLibrary eglLibrary = LoadLibrary(libEGLPath);
-    if (!eglLibrary)
-        return false;
-
-    base::FilePath libGLES2Path = QtWebEngineCore::toFilePath(QT_LIBDIR_GLES2);
-    libGLES2Path = libGLES2Path.Append("libGLESv2.so.2");
-    base::NativeLibrary gles2Library = LoadLibrary(libGLES2Path);
-    if (!gles2Library)
+    base::NativeLibrary eglgles2Library = dlopen(NULL, RTLD_LAZY);
+    if (!eglgles2Library) {
+        LOG(ERROR) << "Failed to open EGL/GLES2 context " << dlerror();
         return false;
+    }
 
-    gl::GLGetProcAddressProc get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglLibrary, "eglGetProcAddress"));
+    gl::GLGetProcAddressProc get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglgles2Library, "eglGetProcAddress"));
     if (!get_proc_address) {
         LOG(ERROR) << "eglGetProcAddress not found.";
-        base::UnloadNativeLibrary(eglLibrary);
-        base::UnloadNativeLibrary(gles2Library);
+        base::UnloadNativeLibrary(eglgles2Library);
         return false;
     }
 
     gl::SetGLGetProcAddressProc(get_proc_address);
-    gl::AddGLNativeLibrary(eglLibrary);
-    gl::AddGLNativeLibrary(gles2Library);
+    gl::AddGLNativeLibrary(eglgles2Library);
     return true;
 }
 
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index c9b46b38aaa680c7fc94060a44ef4a5fa44ed6e5..e350aadded36e3585918f011eecdf15b04bcafd4 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -92,6 +92,7 @@
 #include <QVariant>
 #include <QtCore/qelapsedtimer.h>
 #include <QtCore/qmimedata.h>
+#include <QtCore/qtemporarydir.h>
 #include <QtGui/qaccessible.h>
 #include <QtGui/qdrag.h>
 #include <QtGui/qpixmap.h>
@@ -1203,7 +1204,11 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD
         QDrag::cancel();
     });
 
-    drag->setMimeData(mimeDataFromDropData(*d->currentDropData));
+    QMimeData *mimeData = mimeDataFromDropData(*d->currentDropData);
+    if (handleDropDataFileContents(dropData, mimeData))
+        allowedActions = Qt::MoveAction;
+
+    drag->setMimeData(mimeData);
     if (!pixmap.isNull()) {
         drag->setPixmap(pixmap);
         drag->setHotSpot(offset);
@@ -1229,6 +1234,36 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD
     }
 }
 
+bool WebContentsAdapter::handleDropDataFileContents(const content::DropData &dropData,
+                                                    QMimeData *mimeData)
+{
+    if (dropData.file_contents.empty())
+        return false;
+
+    Q_D(WebContentsAdapter);
+    if (!d->dndTmpDir) {
+        d->dndTmpDir.reset(new QTemporaryDir);
+        if (!d->dndTmpDir->isValid()) {
+            d->dndTmpDir.reset();
+            return false;
+        }
+    }
+
+    const auto maybeFilename = dropData.GetSafeFilenameForImageFileContents();
+    const QString fileName = maybeFilename ? toQt(maybeFilename->AsUTF16Unsafe()) : QString();
+    const QString &filePath = d->dndTmpDir->filePath(fileName);
+    QFile file(filePath);
+    if (!file.open(QIODevice::WriteOnly)) {
+        qWarning("Cannot write temporary file %s.", qUtf8Printable(filePath));
+        return false;
+    }
+    file.write(QByteArray::fromStdString(dropData.file_contents));
+
+    const QUrl &targetUrl = QUrl::fromLocalFile(filePath);
+    mimeData->setUrls(QList<QUrl>{targetUrl});
+    return true;
+}
+
 static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeData *mimeData)
 {
     Q_ASSERT(dropData->filenames.empty());
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index 10c65a6cb04c44cdd91d86c6945556f8a21e9647..46c8d2604c9399bc77128eec892ec14c42c04202 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE
 class QAccessibleInterface;
 class QDragEnterEvent;
 class QDragMoveEvent;
+class QMimeData;
 class QPageLayout;
 class QString;
 class QWebChannel;
@@ -187,6 +188,7 @@ private:
     Q_DISABLE_COPY(WebContentsAdapter)
     Q_DECLARE_PRIVATE(WebContentsAdapter)
     void waitForUpdateDragActionCalled();
+    bool handleDropDataFileContents(const content::DropData &dropData, QMimeData *mimeData);
 
     QScopedPointer<WebContentsAdapterPrivate> d_ptr;
 };
diff --git a/src/core/web_contents_adapter_p.h b/src/core/web_contents_adapter_p.h
index f2407052372701a87b9e725d5e8f5997108da798..94f3ca08b7a6e53a106006ba587f5bc06ca5f987 100644
--- a/src/core/web_contents_adapter_p.h
+++ b/src/core/web_contents_adapter_p.h
@@ -61,6 +61,7 @@
 #include <QScopedPointer>
 #include <QSharedPointer>
 
+QT_FORWARD_DECLARE_CLASS(QTemporaryDir)
 QT_FORWARD_DECLARE_CLASS(QWebChannel)
 
 class WebEngineContext;
@@ -98,6 +99,7 @@ public:
     bool updateDragActionCalled;
     gfx::Point lastDragClientPos;
     gfx::Point lastDragScreenPos;
+    std::unique_ptr<QTemporaryDir> dndTmpDir;
 };
 
 } // namespace QtWebEngineCore
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 54564718fc7fd20aa91eec86e061411eb89c14ca..05750d4baf239f396d7a23589106e52a139182e4 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -67,6 +67,7 @@
 #include "content/renderer/in_process_renderer_thread.h"
 #include "content/utility/in_process_utility_thread.h"
 #include "gpu/command_buffer/service/gpu_switches.h"
+#include "net/base/port_util.h"
 #include "ppapi/features/features.h"
 #include "ui/events/event_switches.h"
 #include "ui/native_theme/native_theme_switches.h"
@@ -460,6 +461,11 @@ WebEngineContext::WebEngineContext()
 
     base::ThreadRestrictions::SetIOAllowed(true);
 
+    if (parsedCommandLine->HasSwitch(switches::kExplicitlyAllowedPorts)) {
+        std::string allowedPorts = parsedCommandLine->GetSwitchValueASCII(switches::kExplicitlyAllowedPorts);
+        net::SetExplicitlyAllowedPorts(allowedPorts);
+    }
+
 #if BUILDFLAG(ENABLE_PLUGINS)
     // Creating pepper plugins from the page (which calls PluginService::GetPluginInfoArray)
     // might fail unless the page queried the list of available plugins at least once
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index 7f164d6bd73fe4d37d9fe245a4c7e4650c2d7214..0ae71114b85fbecdf8a8ce020b1b0689d57df560 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -1213,6 +1213,7 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QHoverEvent *ev, double dpiScale)
     return webKitEvent;
 }
 
+#ifndef QT_NO_GESTURES
 WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev, double dpiScale)
 {
     WebGestureEvent webKitEvent;
@@ -1249,6 +1250,7 @@ WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev, doub
 
     return webKitEvent;
 }
+#endif
 
 blink::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev, double dpiScale)
 {
diff --git a/src/core/web_event_factory.h b/src/core/web_event_factory.h
index b5e46561051fadb367e73b873d8fd0a70812b06e..259795c1f5d4abb8aea847a61f9c6f826fe1c1b1 100644
--- a/src/core/web_event_factory.h
+++ b/src/core/web_event_factory.h
@@ -41,7 +41,9 @@
 #define WEB_EVENT_FACTORY_H
 
 #include "content/public/browser/native_web_keyboard_event.h"
+#ifndef QT_NO_GESTURES
 #include "third_party/WebKit/public/platform/WebGestureEvent.h"
+#endif
 #include "third_party/WebKit/public/platform/WebMouseEvent.h"
 #include "third_party/WebKit/public/platform/WebMouseWheelEvent.h"
 
@@ -52,7 +54,9 @@ class QHoverEvent;
 class QKeyEvent;
 class QMouseEvent;
 class QWheelEvent;
+#ifndef QT_NO_GESTURES
 class QNativeGestureEvent;
+#endif
 QT_END_NAMESPACE
 
 class WebEventFactory {
@@ -60,7 +64,9 @@ class WebEventFactory {
 public:
     static blink::WebMouseEvent toWebMouseEvent(QMouseEvent*, double dpiScale);
     static blink::WebMouseEvent toWebMouseEvent(QHoverEvent*, double dpiScale);
+#ifndef QT_NO_GESTURES
     static blink::WebGestureEvent toWebGestureEvent(QNativeGestureEvent *, double dpiScale);
+#endif
     static blink::WebMouseWheelEvent toWebWheelEvent(QWheelEvent*, double dpiScale);
     static content::NativeWebKeyboardEvent toWebKeyboardEvent(QKeyEvent*);
 };
diff --git a/src/webengine/doc/src/qtwebengine-features.qdoc b/src/webengine/doc/src/qtwebengine-features.qdoc
index 7850ff35de641f7f0d9f8d06627b3b1b50a8112c..545d230efb33794866a6941c68e2e25f0018fd56 100644
--- a/src/webengine/doc/src/qtwebengine-features.qdoc
+++ b/src/webengine/doc/src/qtwebengine-features.qdoc
@@ -55,10 +55,10 @@
     Qt WebEngine supports the MPEG-4 Part 14 (MP4) file format only if the
     required proprietary audio and video codecs, such as H.264 and MPEG layer-3
     (MP3), have been enabled. Proprietary codecs can be enabled by passing the
-    following option to qmake when building Qt WebEngine:
+    following option when configuring Qt:
 
     \code
-    qmake WEBENGINE_CONFIG+=use_proprietary_codecs
+    -proprietary-codecs
     \endcode
 
     \warning When distributing proprietary codec libraries, you must acquire
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 650a40988bd2736ece70ff1b24a8429ad6a70572..04773725444ffd0971997106e2bac7c494750499 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
@@ -226,8 +226,10 @@ bool RenderWidgetHostViewQtDelegateQuick::event(QEvent *event)
     if (event->type() == QEvent::ShortcutOverride)
         return m_client->handleShortcutOverrideEvent(static_cast<QKeyEvent *>(event));
 
+#ifndef QT_NO_GESTURES
     if (event->type() == QEvent::NativeGesture)
         return m_client->forwardEvent(event);
+#endif
 
     return QQuickItem::event(event);
 }
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 a504506a05cf115f40284a5c8aa177d72c2d6445..55b6001d12cda5709cd751b7d9aba7e4f9d00305 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -162,7 +162,14 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
 
 void RenderWidgetHostViewQtDelegateWidget::removeParentBeforeParentDelete()
 {
+    // Unset the parent, because parent is being destroyed, but the owner of this
+    // RenderWidgetHostViewQtDelegateWidget is actually a RenderWidgetHostViewQt instance.
     setParent(Q_NULLPTR);
+
+    // If this widget represents a popup window, make sure to close it, so that if the popup was the
+    // last visible top level window, the application event loop can quit if it deems it necessarry.
+    if (m_isPopup)
+        close();
 }
 
 void RenderWidgetHostViewQtDelegateWidget::initAsChild(WebContentsAdapterClient* container)
@@ -430,6 +437,9 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
     case QEvent::DragLeave:
     case QEvent::DragMove:
     case QEvent::Drop:
+    case QEvent::HoverEnter:
+    case QEvent::HoverLeave:
+    case QEvent::HoverMove:
         // Let the parent handle these events.
         return false;
     default: