diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/config/linux.pri | 8 | ||||
-rw-r--r-- | src/core/delegated_frame_node.cpp | 1 | ||||
-rw-r--r-- | src/core/render_widget_host_view_qt.cpp | 18 | ||||
-rw-r--r-- | src/core/render_widget_host_view_qt.h | 2 | ||||
-rw-r--r-- | src/core/surface_factory_qt.cpp | 30 | ||||
-rw-r--r-- | src/core/web_contents_adapter.cpp | 37 | ||||
-rw-r--r-- | src/core/web_contents_adapter.h | 2 | ||||
-rw-r--r-- | src/core/web_contents_adapter_p.h | 2 | ||||
-rw-r--r-- | src/core/web_engine_context.cpp | 6 | ||||
-rw-r--r-- | src/core/web_event_factory.cpp | 2 | ||||
-rw-r--r-- | src/core/web_event_factory.h | 6 |
11 files changed, 86 insertions, 28 deletions
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 60cfa6857..28278e903 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 5d6353740..e1902a3eb 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 0c98c9e21..8d79a1869 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 cb1a5980d..311626492 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 9e72885c3..6e5e13866 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 c9b46b38a..e350aadde 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 10c65a6cb..46c8d2604 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 f24070523..94f3ca08b 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 54564718f..05750d4ba 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 7f164d6bd..0ae71114b 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 b5e465610..259795c1f 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*); }; |