From 82499104972d24027044acaff1136ea7d758efe2 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 13 Jul 2017 14:05:52 +0200 Subject: Adaptations for Chromium 59 Change-Id: I472053e316bfa782d0a6fb8903f4901be12247ae Reviewed-by: Allan Sandfeld Jensen --- src/core/browser_accessibility_qt.cpp | 6 +- src/core/browser_context_qt.cpp | 4 +- src/core/config/common.pri | 3 +- src/core/delegated_frame_node.cpp | 4 +- src/core/desktop_screen_qt.cpp | 2 +- src/core/desktop_screen_qt.h | 2 +- src/core/download_manager_delegate_qt.cpp | 11 +- src/core/gl_surface_qt.cpp | 10 ++ src/core/ozone_platform_qt.cpp | 16 +- src/core/qtwebengine_sources.gni | 1 + src/core/render_widget_host_view_qt.cpp | 160 ++++++++++-------- src/core/render_widget_host_view_qt.h | 8 +- src/core/renderer/content_renderer_client_qt.cpp | 15 +- .../pepper/pepper_flash_renderer_host_qt.cpp | 4 +- src/core/renderer/render_view_observer_qt.cpp | 16 +- src/core/renderer/user_resource_controller.cpp | 16 +- src/core/renderer/web_channel_ipc_transport.cpp | 24 +-- src/core/web_contents_adapter.cpp | 49 +++--- src/core/web_contents_delegate_qt.cpp | 1 - src/core/web_contents_view_qt.cpp | 44 ++--- src/core/web_engine_context.cpp | 8 +- src/core/web_engine_settings.cpp | 18 +- src/core/web_event_factory.cpp | 181 ++++++++++----------- 23 files changed, 313 insertions(+), 290 deletions(-) (limited to 'src') diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp index 7dad00f65..ffc510bf2 100644 --- a/src/core/browser_accessibility_qt.cpp +++ b/src/core/browser_accessibility_qt.cpp @@ -127,7 +127,7 @@ void *BrowserAccessibilityQt::interface_cast(QAccessible::InterfaceType type) QAccessibleInterface *BrowserAccessibilityQt::parent() const { - BrowserAccessibility *p = GetParent(); + BrowserAccessibility *p = PlatformGetParent(); if (p) return static_cast(p); return static_cast(manager())->rootParentAccessible(); @@ -830,9 +830,9 @@ bool BrowserAccessibilityQt::isSelected() const QAccessibleInterface *BrowserAccessibilityQt::table() const { - BrowserAccessibility* find_table = GetParent(); + BrowserAccessibility* find_table = PlatformGetParent(); while (find_table && find_table->GetRole() != ui::AX_ROLE_TABLE) - find_table = find_table->GetParent(); + find_table = find_table->PlatformGetParent(); if (!find_table) return 0; return static_cast(find_table); diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp index ffee001ff..6fa91688b 100644 --- a/src/core/browser_context_qt.cpp +++ b/src/core/browser_context_qt.cpp @@ -82,7 +82,7 @@ BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter) #if BUILDFLAG(ENABLE_SPELLCHECK) // Initial spellcheck settings registry->RegisterStringPref(prefs::kAcceptLanguages, std::string()); - registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries, new base::ListValue()); + registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries, base::MakeUnique()); registry->RegisterStringPref(spellcheck::prefs::kSpellCheckDictionary, std::string()); registry->RegisterBooleanPref(spellcheck::prefs::kEnableSpellcheck, false); registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckUseSpellingService, false); @@ -229,7 +229,7 @@ QStringList BrowserContextQt::spellCheckLanguages() const QStringList spellcheck_dictionaries; for (const auto &value : *m_prefService->GetList(spellcheck::prefs::kSpellCheckDictionaries)) { std::string dictionary; - if (value->GetAsString(&dictionary)) + if (value.GetAsString(&dictionary)) spellcheck_dictionaries.append(QString::fromStdString(dictionary)); } diff --git a/src/core/config/common.pri b/src/core/config/common.pri index b0723e333..8c06b9b35 100644 --- a/src/core/config/common.pri +++ b/src/core/config/common.pri @@ -11,7 +11,8 @@ gn_args += \ use_experimental_allocator_shim=false \ use_allocator=\"none\" \ v8_use_external_startup_data=false \ - treat_warnings_as_errors=false + treat_warnings_as_errors=false \ + enable_swiftshader=false use?(printing) { gn_args += enable_basic_printing=true enable_print_preview=true diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index e1902a3eb..0384d1ce4 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -69,7 +69,7 @@ #include "cc/quads/yuv_video_draw_quad.h" #include "cc/resources/returned_resource.h" #include "cc/resources/transferable_resource.h" -#include "content/common/host_shared_bitmap_manager.h" +#include "components/display_compositor/host_shared_bitmap_manager.h" #include "gpu/command_buffer/service/mailbox_manager.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_fence.h" @@ -652,7 +652,7 @@ QSharedPointer ResourceHolder::initTexture(bool quadNeedsBlending, R if (!texture) { if (m_resource.is_software) { Q_ASSERT(apiDelegate); - std::unique_ptr sharedBitmap = content::HostSharedBitmapManager::current()->GetSharedBitmapFromId(m_resource.size, m_resource.mailbox_holder.mailbox); + std::unique_ptr sharedBitmap = display_compositor::HostSharedBitmapManager::current()->GetSharedBitmapFromId(m_resource.size, m_resource.mailbox_holder.mailbox); // QSG interprets QImage::hasAlphaChannel meaning that a node should enable blending // to draw it but Chromium keeps this information in the quads. // The input format is currently always Format_ARGB32_Premultiplied, so assume that all diff --git a/src/core/desktop_screen_qt.cpp b/src/core/desktop_screen_qt.cpp index ec7b6ce98..380a876e4 100644 --- a/src/core/desktop_screen_qt.cpp +++ b/src/core/desktop_screen_qt.cpp @@ -77,7 +77,7 @@ std::vector& DesktopScreenQt::GetAllDisplays() const return empty; } -display::Display DesktopScreenQt::GetDisplayNearestWindow(gfx::NativeView window) const +display::Display DesktopScreenQt::GetDisplayNearestWindow(gfx::NativeWindow window) const { // RenderViewHostImpl::OnStartDragging uses this to determine // the scale factor for the view. diff --git a/src/core/desktop_screen_qt.h b/src/core/desktop_screen_qt.h index b91cb6aab..0c52c615a 100644 --- a/src/core/desktop_screen_qt.h +++ b/src/core/desktop_screen_qt.h @@ -52,7 +52,7 @@ public: gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; int GetNumDisplays() const override; std::vector& GetAllDisplays() const override; - display::Display GetDisplayNearestWindow(gfx::NativeView window) const override; + display::Display GetDisplayNearestWindow(gfx::NativeWindow window) const override; display::Display GetDisplayNearestPoint(const gfx::Point& point) const override; display::Display GetDisplayMatching(const gfx::Rect& match_rect) const override; display::Display GetPrimaryDisplay() const override; diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index 67c809032..5eb97c5ea 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -81,7 +81,7 @@ void DownloadManagerDelegateQt::GetNextId(const content::DownloadIdCallback& cal void DownloadManagerDelegateQt::cancelDownload(const content::DownloadTargetCallback& callback) { - callback.Run(base::FilePath(), content::DownloadItem::TARGET_DISPOSITION_PROMPT, content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT, base::FilePath()); + callback.Run(base::FilePath(), content::DownloadItem::TARGET_DISPOSITION_PROMPT, content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT, base::FilePath(), content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); } void DownloadManagerDelegateQt::cancelDownload(quint32 downloadId) @@ -116,7 +116,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i // store downloads and other special downloads, so they might never end up here anyway. if (!item->GetForcedFilePath().empty()) { callback.Run(item->GetForcedFilePath(), content::DownloadItem::TARGET_DISPOSITION_PROMPT, - content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, item->GetForcedFilePath()); + content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, item->GetForcedFilePath(), content::DOWNLOAD_INTERRUPT_REASON_NONE); return true; } @@ -196,8 +196,11 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i } base::FilePath filePathForCallback(toFilePathString(suggestedFile.absoluteFilePath())); - callback.Run(filePathForCallback, content::DownloadItem::TARGET_DISPOSITION_OVERWRITE, - content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT, filePathForCallback.AddExtension(toFilePathString("download"))); + callback.Run(filePathForCallback, + content::DownloadItem::TARGET_DISPOSITION_OVERWRITE, + content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT, + filePathForCallback.AddExtension(toFilePathString("download")), + content::DOWNLOAD_INTERRUPT_REASON_NONE); } else cancelDownload(callback); diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index e0672f14f..e54e959c3 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -179,6 +179,16 @@ bool GLSurfaceGLX::IsCreateContextRobustnessSupported() return false; // ExtensionsContain(g_extensions, "GLX_ARB_create_context_robustness"); } +bool GLSurfaceGLX::IsEXTSwapControlSupported() +{ + return HasGLXExtension("GLX_EXT_swap_control"); +} + +bool GLSurfaceGLX::IsMESASwapControlSupported() +{ + return HasGLXExtension("GLX_MESA_swap_control"); +} + bool GLSurfaceGLX::IsCreateContextProfileSupported() { return false; // ExtensionsContain(g_extensions, "GLX_ARB_create_context_profile"); diff --git a/src/core/ozone_platform_qt.cpp b/src/core/ozone_platform_qt.cpp index 20c1f43c8..e165239bd 100644 --- a/src/core/ozone_platform_qt.cpp +++ b/src/core/ozone_platform_qt.cpp @@ -99,6 +99,7 @@ public: // PlatformEventDispatcher: bool CanDispatchEvent(const PlatformEvent& event) override; uint32_t DispatchEvent(const PlatformEvent& event) override; + void PrepareForShutdown() override; private: PlatformWindowDelegate* delegate_; @@ -134,6 +135,11 @@ uint32_t PlatformWindowQt::DispatchEvent(const ui::PlatformEvent& native_event) return ui::POST_DISPATCH_STOP_PROPAGATION; } +void PlatformWindowQt::PrepareForShutdown() +{ +} + + class OzonePlatformQt : public OzonePlatform { public: OzonePlatformQt(); @@ -149,8 +155,8 @@ public: ui::OverlayManagerOzone* GetOverlayManager() override; private: - void InitializeUI() override; - void InitializeGPU() override; + void InitializeUI(const ui::OzonePlatform::InitParams &) override; + void InitializeGPU(const ui::OzonePlatform::InitParams &) override; std::unique_ptr surface_factory_ozone_; std::unique_ptr cursor_factory_ozone_; @@ -208,7 +214,7 @@ std::unique_ptr OzonePlatformQt::CreateNativeDis return nullptr; } -void OzonePlatformQt::InitializeUI() +void OzonePlatformQt::InitializeUI(const ui::OzonePlatform::InitParams &) { overlay_manager_.reset(new StubOverlayManager()); cursor_factory_ozone_.reset(new CursorFactoryOzone()); @@ -216,7 +222,7 @@ void OzonePlatformQt::InitializeUI() input_controller_ = CreateStubInputController(); } -void OzonePlatformQt::InitializeGPU() +void OzonePlatformQt::InitializeGPU(const ui::OzonePlatform::InitParams &) { surface_factory_ozone_.reset(new QtWebEngineCore::SurfaceFactoryQt()); } @@ -226,7 +232,7 @@ void OzonePlatformQt::InitializeGPU() OzonePlatform* CreateOzonePlatformQt() { return new OzonePlatformQt; } -ClientNativePixmapFactory* CreateClientNativePixmapFactoryQt() +gfx::ClientNativePixmapFactory* CreateClientNativePixmapFactoryQt() { return CreateStubClientNativePixmapFactory(); } diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni index 785c252cb..d766bde38 100644 --- a/src/core/qtwebengine_sources.gni +++ b/src/core/qtwebengine_sources.gni @@ -21,6 +21,7 @@ source_set("qtwebengine_spellcheck_sources") { deps = [ "//components/spellcheck/browser", "//components/spellcheck/renderer", + "//third_party/boringssl", "//third_party/WebKit/public:blink", "//third_party/hunspell", ] diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 8d79a1869..bf96b1d9b 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -105,9 +105,9 @@ enum ImStateFlags { static inline ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& event) { ui::LatencyInfo latency_info; // The latency number should only be added if the timestamp is valid. - if (event.timeStampSeconds()) { + if (event.TimeStampSeconds()) { const int64_t time_micros = static_cast( - event.timeStampSeconds() * base::Time::kMicrosecondsPerSecond); + event.TimeStampSeconds() * base::Time::kMicrosecondsPerSecond); latency_info.AddLatencyNumberWithTimestamp( ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, @@ -261,12 +261,14 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget , m_needsDelegatedFrameAck(false) , m_loadVisuallyCommittedState(NotCommitted) , m_adapterClient(0) + , m_rendererCompositorFrameSink(0) , m_imeInProgress(false) , m_receivedEmptyImeText(false) , m_initPending(false) , m_beginFrameSource(nullptr) , m_needsBeginFrames(false) , m_addedFrameObserver(false) + , m_backgroundColor(SK_ColorWHITE) , m_imState(0) , m_anchorPositionWithinSelection(-1) , m_cursorPositionWithinSelection(-1) @@ -444,12 +446,20 @@ gfx::Rect RenderWidgetHostViewQt::GetViewBounds() const return gfx::BoundingRect(p1, p2); } +SkColor RenderWidgetHostViewQt::background_color() const +{ + return m_backgroundColor; +} + void RenderWidgetHostViewQt::SetBackgroundColor(SkColor color) { - RenderWidgetHostViewBase::SetBackgroundColor(color); + if (m_backgroundColor == color) + return; + m_backgroundColor = color; // Set the background of the compositor if necessary m_delegate->setClearColor(toQt(color)); // Set the background of the blink::FrameView + m_host->SetBackgroundOpaque(SkColorGetA(color) == SK_AlphaOPAQUE); m_host->Send(new RenderViewObserverQt_SetBackgroundColor(m_host->GetRoutingID(), color)); } @@ -473,119 +483,119 @@ void RenderWidgetHostViewQt::UnlockMouse() void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor) { - content::WebCursor::CursorInfo cursorInfo; + content::CursorInfo cursorInfo; webCursor.GetCursorInfo(&cursorInfo); Qt::CursorShape shape = Qt::ArrowCursor; #if defined(USE_AURA) int auraType = -1; #endif switch (cursorInfo.type) { - case blink::WebCursorInfo::TypePointer: + case blink::WebCursorInfo::kTypePointer: shape = Qt::ArrowCursor; break; - case blink::WebCursorInfo::TypeCross: + case blink::WebCursorInfo::kTypeCross: shape = Qt::CrossCursor; break; - case blink::WebCursorInfo::TypeHand: + case blink::WebCursorInfo::kTypeHand: shape = Qt::PointingHandCursor; break; - case blink::WebCursorInfo::TypeIBeam: + case blink::WebCursorInfo::kTypeIBeam: shape = Qt::IBeamCursor; break; - case blink::WebCursorInfo::TypeWait: + case blink::WebCursorInfo::kTypeWait: shape = Qt::WaitCursor; break; - case blink::WebCursorInfo::TypeHelp: + case blink::WebCursorInfo::kTypeHelp: shape = Qt::WhatsThisCursor; break; - case blink::WebCursorInfo::TypeEastResize: - case blink::WebCursorInfo::TypeWestResize: - case blink::WebCursorInfo::TypeEastWestResize: - case blink::WebCursorInfo::TypeEastPanning: - case blink::WebCursorInfo::TypeWestPanning: + case blink::WebCursorInfo::kTypeEastResize: + case blink::WebCursorInfo::kTypeWestResize: + case blink::WebCursorInfo::kTypeEastWestResize: + case blink::WebCursorInfo::kTypeEastPanning: + case blink::WebCursorInfo::kTypeWestPanning: shape = Qt::SizeHorCursor; break; - case blink::WebCursorInfo::TypeNorthResize: - case blink::WebCursorInfo::TypeSouthResize: - case blink::WebCursorInfo::TypeNorthSouthResize: - case blink::WebCursorInfo::TypeNorthPanning: - case blink::WebCursorInfo::TypeSouthPanning: + case blink::WebCursorInfo::kTypeNorthResize: + case blink::WebCursorInfo::kTypeSouthResize: + case blink::WebCursorInfo::kTypeNorthSouthResize: + case blink::WebCursorInfo::kTypeNorthPanning: + case blink::WebCursorInfo::kTypeSouthPanning: shape = Qt::SizeVerCursor; break; - case blink::WebCursorInfo::TypeNorthEastResize: - case blink::WebCursorInfo::TypeSouthWestResize: - case blink::WebCursorInfo::TypeNorthEastSouthWestResize: - case blink::WebCursorInfo::TypeNorthEastPanning: - case blink::WebCursorInfo::TypeSouthWestPanning: + case blink::WebCursorInfo::kTypeNorthEastResize: + case blink::WebCursorInfo::kTypeSouthWestResize: + case blink::WebCursorInfo::kTypeNorthEastSouthWestResize: + case blink::WebCursorInfo::kTypeNorthEastPanning: + case blink::WebCursorInfo::kTypeSouthWestPanning: shape = Qt::SizeBDiagCursor; break; - case blink::WebCursorInfo::TypeNorthWestResize: - case blink::WebCursorInfo::TypeSouthEastResize: - case blink::WebCursorInfo::TypeNorthWestSouthEastResize: - case blink::WebCursorInfo::TypeNorthWestPanning: - case blink::WebCursorInfo::TypeSouthEastPanning: + case blink::WebCursorInfo::kTypeNorthWestResize: + case blink::WebCursorInfo::kTypeSouthEastResize: + case blink::WebCursorInfo::kTypeNorthWestSouthEastResize: + case blink::WebCursorInfo::kTypeNorthWestPanning: + case blink::WebCursorInfo::kTypeSouthEastPanning: shape = Qt::SizeFDiagCursor; break; - case blink::WebCursorInfo::TypeColumnResize: + case blink::WebCursorInfo::kTypeColumnResize: shape = Qt::SplitHCursor; break; - case blink::WebCursorInfo::TypeRowResize: + case blink::WebCursorInfo::kTypeRowResize: shape = Qt::SplitVCursor; break; - case blink::WebCursorInfo::TypeMiddlePanning: - case blink::WebCursorInfo::TypeMove: + case blink::WebCursorInfo::kTypeMiddlePanning: + case blink::WebCursorInfo::kTypeMove: shape = Qt::SizeAllCursor; break; - case blink::WebCursorInfo::TypeProgress: + case blink::WebCursorInfo::kTypeProgress: shape = Qt::BusyCursor; break; #if defined(USE_AURA) - case blink::WebCursorInfo::TypeVerticalText: + case blink::WebCursorInfo::kTypeVerticalText: auraType = ui::kCursorVerticalText; break; - case blink::WebCursorInfo::TypeCell: + case blink::WebCursorInfo::kTypeCell: auraType = ui::kCursorCell; break; - case blink::WebCursorInfo::TypeContextMenu: + case blink::WebCursorInfo::kTypeContextMenu: auraType = ui::kCursorContextMenu; break; - case blink::WebCursorInfo::TypeAlias: + case blink::WebCursorInfo::kTypeAlias: auraType = ui::kCursorAlias; break; - case blink::WebCursorInfo::TypeCopy: + case blink::WebCursorInfo::kTypeCopy: auraType = ui::kCursorCopy; break; - case blink::WebCursorInfo::TypeZoomIn: + case blink::WebCursorInfo::kTypeZoomIn: auraType = ui::kCursorZoomIn; break; - case blink::WebCursorInfo::TypeZoomOut: + case blink::WebCursorInfo::kTypeZoomOut: auraType = ui::kCursorZoomOut; break; #else - case blink::WebCursorInfo::TypeVerticalText: - case blink::WebCursorInfo::TypeCell: - case blink::WebCursorInfo::TypeContextMenu: - case blink::WebCursorInfo::TypeAlias: - case blink::WebCursorInfo::TypeCopy: - case blink::WebCursorInfo::TypeZoomIn: - case blink::WebCursorInfo::TypeZoomOut: + case blink::WebCursorInfo::kTypeVerticalText: + case blink::WebCursorInfo::kTypeCell: + case blink::WebCursorInfo::kTypeContextMenu: + case blink::WebCursorInfo::kTypeAlias: + case blink::WebCursorInfo::kTypeCopy: + case blink::WebCursorInfo::kTypeZoomIn: + case blink::WebCursorInfo::kTypeZoomOut: // FIXME: Support on OS X break; #endif - case blink::WebCursorInfo::TypeNoDrop: - case blink::WebCursorInfo::TypeNotAllowed: + case blink::WebCursorInfo::kTypeNoDrop: + case blink::WebCursorInfo::kTypeNotAllowed: shape = Qt::ForbiddenCursor; break; - case blink::WebCursorInfo::TypeNone: + case blink::WebCursorInfo::kTypeNone: shape = Qt::BlankCursor; break; - case blink::WebCursorInfo::TypeGrab: + case blink::WebCursorInfo::kTypeGrab: shape = Qt::OpenHandCursor; break; - case blink::WebCursorInfo::TypeGrabbing: + case blink::WebCursorInfo::kTypeGrabbing: shape = Qt::ClosedHandCursor; break; - case blink::WebCursorInfo::TypeCustom: + case blink::WebCursorInfo::kTypeCustom: if (cursorInfo.custom_image.colorType() == SkColorType::kN32_SkColorType) { QImage cursor = toQImage(cursorInfo.custom_image, QImage::Format_ARGB32); m_delegate->updateCursor(QCursor(QPixmap::fromImage(cursor), cursorInfo.hotspot.x(), cursorInfo.hotspot.y())); @@ -645,15 +655,28 @@ bool RenderWidgetHostViewQt::HasAcceleratedSurface(const gfx::Size&) return false; } -void RenderWidgetHostViewQt::OnSwapCompositorFrame(uint32_t output_surface_id, cc::CompositorFrame frame) +void RenderWidgetHostViewQt::DidCreateNewRendererCompositorFrameSink(cc::mojom::MojoCompositorFrameSinkClient *frameSink) +{ + // Accumulated resources belong to the old RendererCompositorFrameSink and + // should not be returned. + m_resourcesToRelease.clear(); + m_rendererCompositorFrameSink = frameSink; +} + +void RenderWidgetHostViewQt::SubmitCompositorFrame(const cc::LocalSurfaceId &local_surface_id, cc::CompositorFrame frame) { bool scrollOffsetChanged = (m_lastScrollOffset != frame.metadata.root_scroll_offset); bool contentsSizeChanged = (m_lastContentsSize != frame.metadata.root_layer_size); m_lastScrollOffset = frame.metadata.root_scroll_offset; m_lastContentsSize = frame.metadata.root_layer_size; + m_backgroundColor = frame.metadata.root_background_color; + if (m_localSurfaceId != local_surface_id) { + m_localSurfaceId = local_surface_id; + // FIXME: update frame_size and device_scale_factor? + // FIXME: showPrimarySurface()? + } Q_ASSERT(!m_needsDelegatedFrameAck); m_needsDelegatedFrameAck = true; - m_pendingOutputSurfaceId = output_surface_id; m_chromiumCompositorData->previousFrameData = std::move(m_chromiumCompositorData->frameData); m_chromiumCompositorData->frameDevicePixelRatio = frame.metadata.device_scale_factor; m_chromiumCompositorData->frameData = std::move(frame); @@ -984,7 +1007,7 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) void RenderWidgetHostViewQt::ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) { Q_UNUSED(touch); const bool eventConsumed = ack_result == content::INPUT_EVENT_ACK_STATE_CONSUMED; - m_gestureProvider.OnTouchEventAck(touch.event.uniqueTouchEventId, eventConsumed); + m_gestureProvider.OnTouchEventAck(touch.event.unique_touch_event_id, eventConsumed); } void RenderWidgetHostViewQt::sendDelegatedFrameAck() @@ -993,9 +1016,8 @@ void RenderWidgetHostViewQt::sendDelegatedFrameAck() m_beginFrameSource->DidFinishFrame(this, ack); cc::ReturnedResourceArray resources; m_resourcesToRelease.swap(resources); - content::RenderWidgetHostImpl::SendReclaimCompositorResources( - m_host->GetRoutingID(), m_pendingOutputSurfaceId, - m_host->GetProcess()->GetID(), true, resources); + if (m_rendererCompositorFrameSink) + m_rendererCompositorFrameSink->DidReceiveCompositorFrameAck(resources); } void RenderWidgetHostViewQt::processMotionEvent(const ui::MotionEvent &motionEvent) @@ -1035,7 +1057,7 @@ float RenderWidgetHostViewQt::dpiScale() const bool RenderWidgetHostViewQt::IsPopup() const { - return popup_type_ != blink::WebPopupTypeNone; + return popup_type_ != blink::kWebPopupTypeNone; } void RenderWidgetHostViewQt::handleMouseEvent(QMouseEvent* event) @@ -1048,8 +1070,8 @@ void RenderWidgetHostViewQt::handleMouseEvent(QMouseEvent* event) return; blink::WebMouseEvent webEvent = WebEventFactory::toWebMouseEvent(event, dpiScale()); - if ((webEvent.type() == blink::WebInputEvent::MouseDown || webEvent.type() == blink::WebInputEvent::MouseUp) - && webEvent.button == blink::WebMouseEvent::Button::NoButton) { + if ((webEvent.GetType() == blink::WebInputEvent::kMouseDown || webEvent.GetType() == blink::WebInputEvent::kMouseUp) + && webEvent.button == blink::WebMouseEvent::Button::kNoButton) { // Blink can only handle the 3 main mouse-buttons and may assert when processing mouse-down for no button. return; } @@ -1062,13 +1084,13 @@ void RenderWidgetHostViewQt::handleMouseEvent(QMouseEvent* event) m_clickHelper.clickCounter = 0; m_clickHelper.lastPressTimestamp = event->timestamp(); - webEvent.clickCount = ++m_clickHelper.clickCounter; + webEvent.click_count = ++m_clickHelper.clickCounter; m_clickHelper.lastPressButton = event->button(); m_clickHelper.lastPressPosition = QPointF(event->pos()).toPoint(); } - webEvent.movementX = event->globalX() - m_previousMousePosition.x(); - webEvent.movementY = event->globalY() - m_previousMousePosition.y(); + webEvent.movement_x = event->globalX() - m_previousMousePosition.x(); + webEvent.movement_y = event->globalY() - m_previousMousePosition.y(); if (IsMouseLocked()) QCursor::setPos(m_previousMousePosition); @@ -1119,7 +1141,7 @@ void RenderWidgetHostViewQt::handleKeyEvent(QKeyEvent *ev) } content::NativeWebKeyboardEvent webEvent = WebEventFactory::toWebKeyboardEvent(ev); - bool keyDownTextInsertion = webEvent.type() == blink::WebInputEvent::RawKeyDown && webEvent.text[0]; + bool keyDownTextInsertion = webEvent.GetType() == blink::WebInputEvent::kRawKeyDown && webEvent.text[0]; webEvent.skip_in_browser = keyDownTextInsertion; m_host->ForwardKeyboardEvent(webEvent); @@ -1128,7 +1150,7 @@ void RenderWidgetHostViewQt::handleKeyEvent(QKeyEvent *ev) // The RawKeyDown is skipped on the way back (see above). // The same os_event will be set on both NativeWebKeyboardEvents. webEvent.skip_in_browser = false; - webEvent.setType(blink::WebInputEvent::Char); + webEvent.SetType(blink::WebInputEvent::kChar); m_host->ForwardKeyboardEvent(webEvent); } } diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index 311626492..7fc29adb1 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -138,6 +138,7 @@ public: void Hide() override; bool IsShowing() override; gfx::Rect GetViewBounds() const override; + SkColor background_color() const override; void SetBackgroundColor(SkColor color) override; bool LockMouse() override; void UnlockMouse() override; @@ -149,7 +150,8 @@ public: void Destroy() override; void SetTooltipText(const base::string16 &tooltip_text) override; bool HasAcceleratedSurface(const gfx::Size&) override; - void OnSwapCompositorFrame(uint32_t output_surface_id, cc::CompositorFrame frame) override; + void DidCreateNewRendererCompositorFrameSink(cc::mojom::MojoCompositorFrameSinkClient*) override; + void SubmitCompositorFrame(const cc::LocalSurfaceId&, cc::CompositorFrame) override; void GetScreenInfo(content::ScreenInfo* results); gfx::Rect GetBoundsInRootWindow() override; @@ -239,11 +241,11 @@ private: cc::ReturnedResourceArray m_resourcesToRelease; bool m_needsDelegatedFrameAck; LoadVisuallyCommittedState m_loadVisuallyCommittedState; - uint32_t m_pendingOutputSurfaceId; QMetaObject::Connection m_adapterClientDestroyedConnection; WebContentsAdapterClient *m_adapterClient; MultipleMouseClickHelper m_clickHelper; + cc::mojom::MojoCompositorFrameSinkClient *m_rendererCompositorFrameSink; bool m_imeInProgress; bool m_receivedEmptyImeText; @@ -257,6 +259,8 @@ private: gfx::Vector2dF m_lastScrollOffset; gfx::SizeF m_lastContentsSize; + SkColor m_backgroundColor; + cc::LocalSurfaceId m_localSurfaceId; uint m_imState; int m_anchorPositionWithinSelection; diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index f09aa48f0..a3b0fece8 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -114,15 +114,14 @@ void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view new RenderViewObserverQt(render_view, m_webCacheImpl.data()); new WebChannelIPCTransport(render_view); UserResourceController::instance()->renderViewCreated(render_view); -#if BUILDFLAG(ENABLE_SPELLCHECK) - new SpellCheckProvider(render_view, m_spellCheck.data()); -#endif - } void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_frame) { new QtWebEngineCore::RenderFrameObserverQt(render_frame); +#if BUILDFLAG(ENABLE_SPELLCHECK) + new SpellCheckProvider(render_frame, m_spellCheck.data()); +#endif #if BUILDFLAG(ENABLE_BASIC_PRINTING) new printing::PrintWebViewHelper( render_frame, @@ -173,7 +172,7 @@ bool ContentRendererClientQt::ShouldSuppressErrorPage(content::RenderFrame *fram // To tap into the chromium localized strings. Ripped from the chrome layer (highly simplified). void ContentRendererClientQt::GetNavigationErrorStrings(content::RenderFrame* renderFrame, const blink::WebURLRequest &failedRequest, const blink::WebURLError &error, std::string *errorHtml, base::string16 *errorDescription) { - const bool isPost = QByteArray::fromStdString(failedRequest.httpMethod().utf8()) == QByteArrayLiteral("POST"); + const bool isPost = QByteArray::fromStdString(failedRequest.HttpMethod().Utf8()) == QByteArrayLiteral("POST"); if (errorHtml) { // Use a local error page. @@ -184,8 +183,8 @@ void ContentRendererClientQt::GetNavigationErrorStrings(content::RenderFrame* re // TODO(elproxy): We could potentially get better diagnostics here by first calling // NetErrorHelper::GetErrorStringsForDnsProbe, but that one is harder to untangle. - error_page::LocalizedError::GetStrings(error.reason, error.domain.utf8(), error.unreachableURL, isPost - , error.staleCopyInCache && !isPost, false, false, locale + error_page::LocalizedError::GetStrings(error.reason, error.domain.Utf8(), error.unreachable_url, isPost + , error.stale_copy_in_cache && !isPost, false, false, locale , std::unique_ptr(), &errorStrings); resourceId = IDR_NET_ERROR_HTML; @@ -198,7 +197,7 @@ void ContentRendererClientQt::GetNavigationErrorStrings(content::RenderFrame* re } if (errorDescription) - *errorDescription = error_page::LocalizedError::GetErrorDetails(error.domain.utf8(), error.reason, isPost); + *errorDescription = error_page::LocalizedError::GetErrorDetails(error.domain.Utf8(), error.reason, isPost); } unsigned long long ContentRendererClientQt::VisitedLinkHash(const char *canonicalUrl, size_t length) diff --git a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp index 3a34d5f93..5111a3129 100644 --- a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp +++ b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp @@ -138,8 +138,8 @@ enum FlashNavigateUsage { FLASH_NAVIGATE_USAGE_ENUM_COUNT }; -static base::LazyInstance > -g_rejected_headers = LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance>:: + DestructorAtExit g_rejected_headers = LAZY_INSTANCE_INITIALIZER; bool IsSimpleHeader(const std::string& lower_case_header_name, const std::string& header_value) diff --git a/src/core/renderer/render_view_observer_qt.cpp b/src/core/renderer/render_view_observer_qt.cpp index 54aed8b59..676210688 100644 --- a/src/core/renderer/render_view_observer_qt.cpp +++ b/src/core/renderer/render_view_observer_qt.cpp @@ -62,25 +62,25 @@ RenderViewObserverQt::RenderViewObserverQt( void RenderViewObserverQt::onFetchDocumentMarkup(quint64 requestId) { blink::WebString markup; - if (render_view()->GetWebView()->mainFrame()->isWebLocalFrame()) - markup = blink::WebFrameContentDumper::dumpAsMarkup( - static_cast(render_view()->GetWebView()->mainFrame())); - Send(new RenderViewObserverHostQt_DidFetchDocumentMarkup(routing_id(), requestId, markup.utf16())); + if (render_view()->GetWebView()->MainFrame()->IsWebLocalFrame()) + markup = blink::WebFrameContentDumper::DumpAsMarkup( + static_cast(render_view()->GetWebView()->MainFrame())); + Send(new RenderViewObserverHostQt_DidFetchDocumentMarkup(routing_id(), requestId, markup.Utf16())); } void RenderViewObserverQt::onFetchDocumentInnerText(quint64 requestId) { blink::WebString text; - if (render_view()->GetWebView()->mainFrame()->isWebLocalFrame()) - text = blink::WebFrameContentDumper::dumpWebViewAsText( + if (render_view()->GetWebView()->MainFrame()->IsWebLocalFrame()) + text = blink::WebFrameContentDumper::DumpWebViewAsText( render_view()->GetWebView(), std::numeric_limits::max()); - Send(new RenderViewObserverHostQt_DidFetchDocumentInnerText(routing_id(), requestId, text.utf16())); + Send(new RenderViewObserverHostQt_DidFetchDocumentInnerText(routing_id(), requestId, text.Utf16())); } void RenderViewObserverQt::onSetBackgroundColor(quint32 color) { - render_view()->GetWebFrameWidget()->setBaseBackgroundColor(color); + render_view()->GetWebFrameWidget()->SetBaseBackgroundColor(color); } bool RenderViewObserverQt::OnMessageReceived(const IPC::Message& message) diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp index b172c762b..d2e70a226 100644 --- a/src/core/renderer/user_resource_controller.cpp +++ b/src/core/renderer/user_resource_controller.cpp @@ -128,8 +128,8 @@ void UserResourceController::RenderViewObserverHelper::runScripts(UserScriptData void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink::WebLocalFrame *frame) { - content::RenderView *renderView = content::RenderView::FromWebView(frame->view()); - const bool isMainFrame = (frame == renderView->GetWebView()->mainFrame()); + content::RenderView *renderView = content::RenderView::FromWebView(frame->View()); + const bool isMainFrame = (frame == renderView->GetWebView()->MainFrame()); QList scriptsToRun = m_viewUserScriptMap.value(globalScriptsIndex).toList(); scriptsToRun.append(m_viewUserScriptMap.value(renderView).toList()); @@ -139,13 +139,13 @@ void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink: if (script.injectionPoint != p || (!script.injectForSubframes && !isMainFrame)) continue; - if (!scriptMatchesURL(script, frame->document().url())) + if (!scriptMatchesURL(script, frame->GetDocument().Url())) continue; - blink::WebScriptSource source(blink::WebString::fromUTF8(script.source), script.url); + blink::WebScriptSource source(blink::WebString::FromUTF8(script.source), script.url); if (script.worldId) - frame->executeScriptInIsolatedWorld(script.worldId, &source, /*numSources = */1, /*contentScriptExtentsionGroup = */ 0); + frame->ExecuteScriptInIsolatedWorld(script.worldId, &source, /*numSources = */1, /*contentScriptExtentsionGroup = */ 0); else - frame->executeScript(source); + frame->ExecuteScript(source); } } @@ -186,8 +186,8 @@ void UserResourceController::RenderViewObserverHelper::DidStartProvisionalLoad(b void UserResourceController::RenderViewObserverHelper::FrameDetached(blink::WebFrame *frame) { - if (frame->isWebLocalFrame()) - m_pendingFrames.remove(frame->toWebLocalFrame()); + if (frame->IsWebLocalFrame()) + m_pendingFrames.remove(frame->ToWebLocalFrame()); } void UserResourceController::RenderViewObserverHelper::OnDestruct() diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp index f34e1310b..c685cd465 100644 --- a/src/core/renderer/web_channel_ipc_transport.cpp +++ b/src/core/renderer/web_channel_ipc_transport.cpp @@ -105,9 +105,9 @@ void WebChannelTransport::Install(blink::WebFrame *frame, uint worldId) v8::HandleScope handleScope(isolate); v8::Handle context; if (worldId == 0) - context = frame->mainWorldScriptContext(); + context = frame->MainWorldScriptContext(); else - context = frame->toWebLocalFrame()->isolatedWorldScriptContext(worldId); + context = frame->ToWebLocalFrame()->IsolatedWorldScriptContext(worldId); v8::Context::Scope contextScope(context); gin::Handle transport = gin::CreateHandle(isolate, new WebChannelTransport); @@ -126,9 +126,9 @@ void WebChannelTransport::Uninstall(blink::WebFrame *frame, uint worldId) v8::HandleScope handleScope(isolate); v8::Handle context; if (worldId == 0) - context = frame->mainWorldScriptContext(); + context = frame->MainWorldScriptContext(); else - context = frame->toWebLocalFrame()->isolatedWorldScriptContext(worldId); + context = frame->ToWebLocalFrame()->IsolatedWorldScriptContext(worldId); v8::Context::Scope contextScope(context); v8::Handle global(context->Global()); @@ -145,12 +145,12 @@ gin::ObjectTemplateBuilder WebChannelTransport::GetObjectTemplateBuilder(v8::Iso content::RenderView *WebChannelTransport::GetRenderView(v8::Isolate *isolate) { - blink::WebLocalFrame *webframe = blink::WebLocalFrame::frameForContext(isolate->GetCurrentContext()); + blink::WebLocalFrame *webframe = blink::WebLocalFrame::FrameForContext(isolate->GetCurrentContext()); DCHECK(webframe) << "There should be an active frame since we just got a native function called."; if (!webframe) return 0; - blink::WebView *webview = webframe->view(); + blink::WebView *webview = webframe->View(); if (!webview) return 0; // can happen during closing @@ -179,7 +179,7 @@ void WebChannelIPCTransport::installWebChannel(uint worldId) blink::WebView *webView = render_view()->GetWebView(); if (!webView) return; - WebChannelTransport::Install(webView->mainFrame(), worldId); + WebChannelTransport::Install(webView->MainFrame(), worldId); m_installed = true; m_installedWorldId = worldId; } @@ -190,7 +190,7 @@ void WebChannelIPCTransport::uninstallWebChannel(uint worldId) blink::WebView *webView = render_view()->GetWebView(); if (!webView) return; - WebChannelTransport::Uninstall(webView->mainFrame(), worldId); + WebChannelTransport::Uninstall(webView->MainFrame(), worldId); m_installed = false; } @@ -206,12 +206,12 @@ void WebChannelIPCTransport::dispatchWebChannelMessage(const std::vector & v8::Isolate *isolate = v8::Isolate::GetCurrent(); v8::HandleScope handleScope(isolate); - blink::WebFrame *frame = webView->mainFrame(); + blink::WebFrame *frame = webView->MainFrame(); v8::Handle context; if (worldId == 0) - context = frame->mainWorldScriptContext(); + context = frame->MainWorldScriptContext(); else - context = frame->toWebLocalFrame()->isolatedWorldScriptContext(worldId); + context = frame->ToWebLocalFrame()->IsolatedWorldScriptContext(worldId); v8::Context::Scope contextScope(context); v8::Handle global(context->Global()); @@ -239,7 +239,7 @@ void WebChannelIPCTransport::dispatchWebChannelMessage(const std::vector & const int argc = 1; v8::Handle argv[argc]; argv[0] = messageObject; - frame->callFunctionEvenIfScriptDisabled(callback, webChannelObjectValue->ToObject(), argc, argv); + frame->CallFunctionEvenIfScriptDisabled(callback, webChannelObjectValue->ToObject(), argc, argv); } bool WebChannelIPCTransport::OnMessageReceived(const IPC::Message &message) diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index e350aadde..e4e902bc5 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -169,8 +169,7 @@ static QVariant fromJSValue(const base::Value *result) } case base::Value::Type::BINARY: { - const base::BinaryValue *out = static_cast(result); - QByteArray data(out->GetBuffer(), out->GetSize()); + QByteArray data(result->GetBuffer(), result->GetSize()); ret.setValue(data); break; } @@ -349,7 +348,7 @@ WebContentsAdapterPrivate::WebContentsAdapterPrivate() , adapterClient(0) , nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd) , lastFindRequestId(0) - , currentDropAction(blink::WebDragOperationNone) + , currentDropAction(blink::kWebDragOperationNone) { } @@ -899,8 +898,8 @@ quint64 WebContentsAdapter::findText(const QString &subString, bool caseSensitiv blink::WebFindOptions options; options.forward = !findBackward; - options.matchCase = caseSensitively; - options.findNext = subString == d->webContentsDelegate->lastSearchedString(); + options.match_case = caseSensitively; + options.find_next = subString == d->webContentsDelegate->lastSearchedString(); d->webContentsDelegate->setLastSearchedString(subString); // Find already allows a request ID as input, but only as an int. @@ -970,11 +969,11 @@ void WebContentsAdapter::copyImageAt(const QPoint &location) d->webContents->GetRenderViewHost()->GetMainFrame()->CopyImageAt(location.x(), location.y()); } -ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerNoAction, blink::WebMediaPlayerAction::Unknown) -ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerPlay, blink::WebMediaPlayerAction::Play) -ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerMute, blink::WebMediaPlayerAction::Mute) -ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerLoop, blink::WebMediaPlayerAction::Loop) -ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerControls, blink::WebMediaPlayerAction::Controls) +ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerNoAction, blink::WebMediaPlayerAction::kUnknown) +ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerPlay, blink::WebMediaPlayerAction::kPlay) +ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerMute, blink::WebMediaPlayerAction::kMute) +ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerLoop, blink::WebMediaPlayerAction::kLoop) +ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerControls, blink::WebMediaPlayerAction::kControls) void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, MediaPlayerAction action, bool enable) { @@ -1170,13 +1169,13 @@ static QMimeData *mimeDataFromDropData(const content::DropData &dropData) static blink::WebDragOperationsMask toWeb(const Qt::DropActions action) { - int result = blink::WebDragOperationNone; + int result = blink::kWebDragOperationNone; if (action & Qt::CopyAction) - result |= blink::WebDragOperationCopy; + result |= blink::kWebDragOperationCopy; if (action & Qt::LinkAction) - result |= blink::WebDragOperationLink; + result |= blink::kWebDragOperationLink; if (action & Qt::MoveAction) - result |= blink::WebDragOperationMove; + result |= blink::kWebDragOperationMove; return static_cast(result); } @@ -1196,7 +1195,7 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD d->currentDropData->file_contents.clear(); d->currentDropData->file_contents_content_disposition.clear(); - d->currentDropAction = blink::WebDragOperationNone; + d->currentDropAction = blink::kWebDragOperationNone; QDrag *drag = new QDrag(dragSource); // will be deleted by Qt's DnD implementation bool dValid = true; QMetaObject::Connection onDestroyed = QObject::connect(dragSource, &QObject::destroyed, [&dValid](){ @@ -1301,11 +1300,11 @@ void WebContentsAdapter::enterDrag(QDragEnterEvent *e, const QPoint &screenPos) Qt::DropAction toQt(blink::WebDragOperation op) { - if (op & blink::WebDragOperationCopy) + if (op & blink::kWebDragOperationCopy) return Qt::CopyAction; - if (op & blink::WebDragOperationLink) + if (op & blink::kWebDragOperationLink) return Qt::LinkAction; - if (op & blink::WebDragOperationMove || op & blink::WebDragOperationDelete) + if (op & blink::kWebDragOperationMove || op & blink::kWebDragOperationDelete) return Qt::MoveAction; return Qt::IgnoreAction; } @@ -1314,11 +1313,11 @@ static int toWeb(Qt::MouseButtons buttons) { int result = 0; if (buttons & Qt::LeftButton) - result |= blink::WebInputEvent::LeftButtonDown; + result |= blink::WebInputEvent::kLeftButtonDown; if (buttons & Qt::RightButton) - result |= blink::WebInputEvent::RightButtonDown; + result |= blink::WebInputEvent::kRightButtonDown; if (buttons & Qt::MiddleButton) - result |= blink::WebInputEvent::MiddleButtonDown; + result |= blink::WebInputEvent::kMiddleButtonDown; return result; } @@ -1326,13 +1325,13 @@ static int toWeb(Qt::KeyboardModifiers modifiers) { int result = 0; if (modifiers & Qt::ShiftModifier) - result |= blink::WebInputEvent::ShiftKey; + result |= blink::WebInputEvent::kShiftKey; if (modifiers & Qt::ControlModifier) - result |= blink::WebInputEvent::ControlKey; + result |= blink::WebInputEvent::kControlKey; if (modifiers & Qt::AltModifier) - result |= blink::WebInputEvent::AltKey; + result |= blink::WebInputEvent::kAltKey; if (modifiers & Qt::MetaModifier) - result |= blink::WebInputEvent::MetaKey; + result |= blink::WebInputEvent::kMetaKey; return result; } diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index b2df7e993..341fd38f0 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -73,7 +73,6 @@ #include "content/public/common/frame_navigate_params.h" #include "content/public/common/url_constants.h" #include "content/public/common/web_preferences.h" -#include "ui/events/latency_info.h" #include #include diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index e627fa06d..f9435ac34 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -138,25 +138,25 @@ void WebContentsViewQt::SetInitialFocus() Focus(); } -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeNone, blink::WebContextMenuData::MediaTypeNone) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeImage, blink::WebContextMenuData::MediaTypeImage) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeVideo, blink::WebContextMenuData::MediaTypeVideo) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeAudio, blink::WebContextMenuData::MediaTypeAudio) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeCanvas, blink::WebContextMenuData::MediaTypeCanvas) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeFile, blink::WebContextMenuData::MediaTypeFile) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypePlugin, blink::WebContextMenuData::MediaTypePlugin) - -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaNone, blink::WebContextMenuData::MediaNone) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaInError, blink::WebContextMenuData::MediaInError) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaPaused, blink::WebContextMenuData::MediaPaused) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaMuted, blink::WebContextMenuData::MediaMuted) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaLoop, blink::WebContextMenuData::MediaLoop) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanSave, blink::WebContextMenuData::MediaCanSave) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaHasAudio, blink::WebContextMenuData::MediaHasAudio) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanToggleControls, blink::WebContextMenuData::MediaCanToggleControls) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaControls, blink::WebContextMenuData::MediaControls) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanPrint, blink::WebContextMenuData::MediaCanPrint) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanRotate, blink::WebContextMenuData::MediaCanRotate) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeNone, blink::WebContextMenuData::kMediaTypeNone) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeImage, blink::WebContextMenuData::kMediaTypeImage) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeVideo, blink::WebContextMenuData::kMediaTypeVideo) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeAudio, blink::WebContextMenuData::kMediaTypeAudio) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeCanvas, blink::WebContextMenuData::kMediaTypeCanvas) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeFile, blink::WebContextMenuData::kMediaTypeFile) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypePlugin, blink::WebContextMenuData::kMediaTypePlugin) + +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaNone, blink::WebContextMenuData::kMediaNone) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaInError, blink::WebContextMenuData::kMediaInError) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaPaused, blink::WebContextMenuData::kMediaPaused) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaMuted, blink::WebContextMenuData::kMediaMuted) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaLoop, blink::WebContextMenuData::kMediaLoop) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanSave, blink::WebContextMenuData::kMediaCanSave) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaHasAudio, blink::WebContextMenuData::kMediaHasAudio) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanToggleControls, blink::WebContextMenuData::kMediaCanToggleControls) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaControls, blink::WebContextMenuData::kMediaControls) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanPrint, blink::WebContextMenuData::kMediaCanPrint) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanRotate, blink::WebContextMenuData::kMediaCanRotate) static inline WebEngineContextMenuData fromParams(const content::ContextMenuParams ¶ms) { @@ -198,11 +198,11 @@ void WebContentsViewQt::ShowContextMenu(content::RenderFrameHost *, const conten Qt::DropActions toQtDropActions(blink::WebDragOperationsMask ops) { Qt::DropActions result; - if (ops & blink::WebDragOperationCopy) + if (ops & blink::kWebDragOperationCopy) result |= Qt::CopyAction; - if (ops & blink::WebDragOperationLink) + if (ops & blink::kWebDragOperationLink) result |= Qt::LinkAction; - if (ops & blink::WebDragOperationMove || ops & blink::WebDragOperationDelete) + if (ops & blink::kWebDragOperationMove || ops & blink::kWebDragOperationDelete) result |= Qt::MoveAction; return result; } diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 05750d4ba..d88fd8035 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -70,7 +70,7 @@ #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" +#include "ui/native_theme/native_theme_features.h" #include "ui/gl/gl_switches.h" #if defined(OS_WIN) #include "sandbox/win/src/sandbox_types.h" @@ -346,9 +346,7 @@ WebEngineContext::WebEngineContext() #endif if (useEmbeddedSwitches) { - // Inspired by the Android port's default switches - if (!parsedCommandLine->HasSwitch(switches::kDisableOverlayScrollbar)) - parsedCommandLine->AppendSwitch(switches::kEnableOverlayScrollbar); + parsedCommandLine->AppendSwitchASCII(switches::kEnableFeatures, features::kOverlayScrollbar.name); if (!parsedCommandLine->HasSwitch(switches::kDisablePinch)) parsedCommandLine->AppendSwitch(switches::kEnablePinch); parsedCommandLine->AppendSwitch(switches::kEnableViewport); @@ -438,6 +436,8 @@ WebEngineContext::WebEngineContext() content::RenderProcessHostImpl::RegisterRendererMainThreadFactory(content::CreateInProcessRendererThread); content::RegisterGpuMainThreadFactory(content::CreateInProcessGpuThread); + mojo::edk::Init(); + content::ContentMainParams contentMainParams(m_mainDelegate.get()); contentMainParams.setup_signal_handlers = false; #if defined(OS_WIN) diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index da0de1de3..63c2aa519 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -83,21 +83,6 @@ private: WebEngineSettings *m_settings; }; -static inline bool isTouchScreenAvailable() { - static bool initialized = false; - static bool touchScreenAvailable = false; - if (!initialized) { - Q_FOREACH (const QTouchDevice *d, QTouchDevice::devices()) { - if (d->type() == QTouchDevice::TouchScreen) { - touchScreenAvailable = true; - break; - } - } - initialized = true; - } - return touchScreenAvailable; -} - static inline bool isTouchEventsAPIEnabled() { static bool initialized = false; static bool touchEventsAPIEnabled = false; @@ -114,7 +99,7 @@ static inline bool isTouchEventsAPIEnabled() { if (touchEventsSwitchValue == switches::kTouchEventFeatureDetectionEnabled) touchEventsAPIEnabled = true; else if (touchEventsSwitchValue == switches::kTouchEventFeatureDetectionAuto) - touchEventsAPIEnabled = isTouchScreenAvailable(); + touchEventsAPIEnabled = (ui::GetTouchScreensAvailability() == ui::TouchScreensAvailability::ENABLED); initialized = true; } @@ -323,7 +308,6 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p { // 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 // no longer have a command-line flag for viewport-meta. diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index 0ae71114b..e6ac63c0d 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -1036,25 +1036,25 @@ static inline double currentTimeForEvent(const QInputEvent* event) static WebMouseEvent::Button mouseButtonForEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) - return WebMouseEvent::Button::Left; + return WebMouseEvent::Button::kLeft; else if (event->button() == Qt::RightButton) - return WebMouseEvent::Button::Right; + return WebMouseEvent::Button::kRight; else if (event->button() == Qt::MidButton) - return WebMouseEvent::Button::Middle; + return WebMouseEvent::Button::kMiddle; if (event->type() != QEvent::MouseMove) - return WebMouseEvent::Button::NoButton; + return WebMouseEvent::Button::kNoButton; // This is technically wrong, mouse move should always have ButtonNone, // but it is consistent with aura and selection code depends on it: if (event->buttons() & Qt::LeftButton) - return WebMouseEvent::Button::Left; + return WebMouseEvent::Button::kLeft; else if (event->buttons() & Qt::RightButton) - return WebMouseEvent::Button::Right; + return WebMouseEvent::Button::kRight; else if (event->buttons() & Qt::MidButton) - return WebMouseEvent::Button::Middle; + return WebMouseEvent::Button::kMiddle; - return WebMouseEvent::Button::NoButton; + return WebMouseEvent::Button::kNoButton; } template @@ -1062,11 +1062,11 @@ static unsigned mouseButtonsModifiersForEvent(const T* event) { unsigned ret = 0; if (event->buttons() & Qt::LeftButton) - ret |= WebInputEvent::LeftButtonDown; + ret |= WebInputEvent::kLeftButtonDown; if (event->buttons() & Qt::RightButton) - ret |= WebInputEvent::RightButtonDown; + ret |= WebInputEvent::kRightButtonDown; if (event->buttons() & Qt::MidButton) - ret |= WebInputEvent::MiddleButtonDown; + ret |= WebInputEvent::kMiddleButtonDown; return ret; } @@ -1076,19 +1076,19 @@ static inline WebInputEvent::Modifiers modifierForKeyCode(int key) { switch (key) { case Qt::Key_Shift: - return WebInputEvent::ShiftKey; + return WebInputEvent::kShiftKey; case Qt::Key_Alt: - return WebInputEvent::AltKey; + return WebInputEvent::kAltKey; #if defined(Q_OS_OSX) case Qt::Key_Control: - return (!qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) ? WebInputEvent::MetaKey : WebInputEvent::ControlKey; + return (!qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) ? WebInputEvent::kMetaKey : WebInputEvent::kControlKey; case Qt::Key_Meta: - return (!qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) ? WebInputEvent::ControlKey : WebInputEvent::MetaKey; + return (!qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) ? WebInputEvent::kControlKey : WebInputEvent::kMetaKey; #else case Qt::Key_Control: - return WebInputEvent::ControlKey; + return WebInputEvent::kControlKey; case Qt::Key_Meta: - return WebInputEvent::MetaKey; + return WebInputEvent::kMetaKey; #endif default: return static_cast(0); @@ -1102,24 +1102,24 @@ static inline WebInputEvent::Modifiers modifiersForEvent(const QInputEvent* even #if defined(Q_OS_OSX) if (!qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) { if (modifiers & Qt::ControlModifier) - result |= WebInputEvent::MetaKey; + result |= WebInputEvent::kMetaKey; if (modifiers & Qt::MetaModifier) - result |= WebInputEvent::ControlKey; + result |= WebInputEvent::kControlKey; } else #endif { if (modifiers & Qt::ControlModifier) - result |= WebInputEvent::ControlKey; + result |= WebInputEvent::kControlKey; if (modifiers & Qt::MetaModifier) - result |= WebInputEvent::MetaKey; + result |= WebInputEvent::kMetaKey; } if (modifiers & Qt::ShiftModifier) - result |= WebInputEvent::ShiftKey; + result |= WebInputEvent::kShiftKey; if (modifiers & Qt::AltModifier) - result |= WebInputEvent::AltKey; + result |= WebInputEvent::kAltKey; if (modifiers & Qt::KeypadModifier) - result |= WebInputEvent::IsKeyPad; + result |= WebInputEvent::kIsKeyPad; switch (event->type()) { case QEvent::MouseButtonPress: @@ -1134,7 +1134,7 @@ static inline WebInputEvent::Modifiers modifiersForEvent(const QInputEvent* even case QEvent::KeyRelease: { const QKeyEvent *keyEvent = static_cast(event); if (keyEvent->isAutoRepeat()) - result |= WebInputEvent::IsAutoRepeat; + result |= WebInputEvent::kIsAutoRepeat; result |= modifierForKeyCode(keyEvent->key()); } default: @@ -1148,52 +1148,49 @@ static WebInputEvent::Type webEventTypeForEvent(const QEvent* event) { switch (event->type()) { case QEvent::MouseButtonPress: - return WebInputEvent::MouseDown; + return WebInputEvent::kMouseDown; case QEvent::MouseButtonRelease: - return WebInputEvent::MouseUp; + return WebInputEvent::kMouseUp; case QEvent::Enter: - return WebInputEvent::MouseEnter; + return WebInputEvent::kMouseEnter; case QEvent::Leave: - return WebInputEvent::MouseLeave; + return WebInputEvent::kMouseLeave; case QEvent::MouseMove: - return WebInputEvent::MouseMove; + return WebInputEvent::kMouseMove; case QEvent::Wheel: - return WebInputEvent::MouseWheel; + return WebInputEvent::kMouseWheel; case QEvent::KeyPress: - return WebInputEvent::RawKeyDown; + return WebInputEvent::kRawKeyDown; case QEvent::KeyRelease: - return WebInputEvent::KeyUp; + return WebInputEvent::kKeyUp; case QEvent::HoverMove: - return WebInputEvent::MouseMove; + return WebInputEvent::kMouseMove; case QEvent::TouchBegin: - return WebInputEvent::TouchStart; + return WebInputEvent::kTouchStart; case QEvent::TouchUpdate: - return WebInputEvent::TouchMove; + return WebInputEvent::kTouchMove; case QEvent::TouchEnd: - return WebInputEvent::TouchEnd; + return WebInputEvent::kTouchEnd; case QEvent::TouchCancel: - return WebInputEvent::TouchCancel; + return WebInputEvent::kTouchCancel; default: Q_ASSERT(false); - return WebInputEvent::MouseMove; + return WebInputEvent::kMouseMove; } } WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev, double dpiScale) { - WebMouseEvent webKitEvent; - webKitEvent.setTimeStampSeconds(currentTimeForEvent(ev)); - webKitEvent.setModifiers(modifiersForEvent(ev)); - webKitEvent.setType(webEventTypeForEvent(ev)); + WebMouseEvent webKitEvent(webEventTypeForEvent(ev), + ev->x() / dpiScale, + ev->y() / dpiScale, + ev->globalX(), + ev->globalY(), + modifiersForEvent(ev), + currentTimeForEvent(ev)); webKitEvent.button = mouseButtonForEvent(ev); - - webKitEvent.x = webKitEvent.windowX = ev->x() / dpiScale; - webKitEvent.y = webKitEvent.windowY = ev->y() / dpiScale; - webKitEvent.globalX = ev->globalX(); - webKitEvent.globalY = ev->globalY(); - - webKitEvent.clickCount = 0; + webKitEvent.click_count = 0; return webKitEvent; } @@ -1201,14 +1198,13 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev, double dpiScale) WebMouseEvent WebEventFactory::toWebMouseEvent(QHoverEvent *ev, double dpiScale) { WebMouseEvent webKitEvent; - webKitEvent.setTimeStampSeconds(currentTimeForEvent(ev)); - webKitEvent.setModifiers(modifiersForEvent(ev)); - webKitEvent.setType(webEventTypeForEvent(ev)); + webKitEvent.SetTimeStampSeconds(currentTimeForEvent(ev)); + webKitEvent.SetModifiers(modifiersForEvent(ev)); + webKitEvent.SetType(webEventTypeForEvent(ev)); - webKitEvent.x = webKitEvent.windowX = ev->pos().x() / dpiScale; - webKitEvent.y = webKitEvent.windowY = ev->pos().y() / dpiScale; - webKitEvent.movementX = ev->pos().x() - ev->oldPos().x(); - webKitEvent.movementY = ev->pos().y() - ev->oldPos().y(); + webKitEvent.SetPositionInWidget(ev->pos().x() / dpiScale, ev->pos().y() / dpiScale); + webKitEvent.movement_x = ev->pos().x() - ev->oldPos().x(); + webKitEvent.movement_y = ev->pos().y() - ev->oldPos().y(); return webKitEvent; } @@ -1217,26 +1213,26 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QHoverEvent *ev, double dpiScale) WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev, double dpiScale) { WebGestureEvent webKitEvent; - webKitEvent.setTimeStampSeconds(currentTimeForEvent(ev)); - webKitEvent.setModifiers(modifiersForEvent(ev)); + webKitEvent.SetTimeStampSeconds(currentTimeForEvent(ev)); + webKitEvent.SetModifiers(modifiersForEvent(ev)); webKitEvent.x = static_cast(ev->localPos().x() / dpiScale); webKitEvent.y = static_cast(ev->localPos().y() / dpiScale); - webKitEvent.globalX = static_cast(ev->screenPos().x() / dpiScale); - webKitEvent.globalY = static_cast(ev->screenPos().y() / dpiScale); + webKitEvent.global_x = static_cast(ev->screenPos().x() / dpiScale); + webKitEvent.global_y = static_cast(ev->screenPos().y() / dpiScale); - webKitEvent.sourceDevice = blink::WebGestureDeviceTouchpad; + webKitEvent.source_device = blink::kWebGestureDeviceTouchpad; Qt::NativeGestureType gestureType = ev->gestureType(); switch (gestureType) { case Qt::ZoomNativeGesture: - webKitEvent.setType(WebInputEvent::GesturePinchUpdate); - webKitEvent.data.pinchUpdate.scale = static_cast(ev->value() + 1.0); + webKitEvent.SetType(WebInputEvent::kGesturePinchUpdate); + webKitEvent.data.pinch_update.scale = static_cast(ev->value() + 1.0); break; case Qt::SmartZoomNativeGesture: - webKitEvent.setType(WebInputEvent::GestureDoubleTap); - webKitEvent.data.tap.tapCount = 1; + webKitEvent.SetType(WebInputEvent::kGestureDoubleTap); + webKitEvent.data.tap.tap_count = 1; break; case Qt::BeginNativeGesture: case Qt::EndNativeGesture: @@ -1244,7 +1240,7 @@ WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev, doub case Qt::PanNativeGesture: case Qt::SwipeNativeGesture: // Not implemented by Chromium for now. - webKitEvent.setType(blink::WebInputEvent::Undefined); + webKitEvent.SetType(blink::WebInputEvent::kUndefined); break; } @@ -1255,16 +1251,16 @@ WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev, doub blink::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev, double dpiScale) { WebMouseWheelEvent webEvent; - webEvent.deltaX = 0; - webEvent.deltaY = 0; - webEvent.wheelTicksX = 0; - webEvent.wheelTicksY = 0; - webEvent.setType(webEventTypeForEvent(ev)); - webEvent.setModifiers(modifiersForEvent(ev)); - webEvent.setTimeStampSeconds(currentTimeForEvent(ev)); + webEvent.delta_x = 0; + webEvent.delta_y = 0; + webEvent.wheel_ticks_x = 0; + webEvent.wheel_ticks_y = 0; + webEvent.SetType(webEventTypeForEvent(ev)); + webEvent.SetModifiers(modifiersForEvent(ev)); + webEvent.SetTimeStampSeconds(currentTimeForEvent(ev)); - webEvent.wheelTicksX = static_cast(ev->angleDelta().x()) / QWheelEvent::DefaultDeltasPerStep; - webEvent.wheelTicksY = static_cast(ev->angleDelta().y()) / QWheelEvent::DefaultDeltasPerStep; + webEvent.wheel_ticks_x = static_cast(ev->angleDelta().x()) / QWheelEvent::DefaultDeltasPerStep; + webEvent.wheel_ticks_y = static_cast(ev->angleDelta().y()) / QWheelEvent::DefaultDeltasPerStep; // We can't use the device specific QWheelEvent::pixelDelta(), so we calculate // a pixel delta based on ticks and scroll per line. @@ -1275,43 +1271,42 @@ blink::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev, doub #else const int wheelScrollLines = 3; #endif - webEvent.deltaX = webEvent.wheelTicksX * wheelScrollLines * cDefaultQtScrollStep; - webEvent.deltaY = webEvent.wheelTicksY * wheelScrollLines * cDefaultQtScrollStep; + webEvent.delta_x = webEvent.wheel_ticks_x * wheelScrollLines * cDefaultQtScrollStep; + webEvent.delta_y = webEvent.wheel_ticks_y * wheelScrollLines * cDefaultQtScrollStep; + + webEvent.SetPositionInWidget(ev->x() / dpiScale, ev->y() / dpiScale); + webEvent.SetPositionInScreen(ev->globalX(), ev->globalY()); - webEvent.x = webEvent.windowX = ev->x() / dpiScale; - webEvent.y = webEvent.windowY = ev->y() / dpiScale; - webEvent.globalX = ev->globalX(); - webEvent.globalY = ev->globalY(); return webEvent; } content::NativeWebKeyboardEvent WebEventFactory::toWebKeyboardEvent(QKeyEvent *ev) { content::NativeWebKeyboardEvent webKitEvent(reinterpret_cast(ev)); - webKitEvent.setTimeStampSeconds(currentTimeForEvent(ev)); - webKitEvent.setModifiers(modifiersForEvent(ev)); - webKitEvent.setType(webEventTypeForEvent(ev)); + webKitEvent.SetTimeStampSeconds(currentTimeForEvent(ev)); + webKitEvent.SetModifiers(modifiersForEvent(ev)); + webKitEvent.SetType(webEventTypeForEvent(ev)); - webKitEvent.nativeKeyCode = ev->nativeVirtualKey(); - webKitEvent.windowsKeyCode = windowsKeyCodeForKeyEvent(ev->key(), ev->modifiers() & Qt::KeypadModifier); - webKitEvent.domKey = getDomKeyFromQKeyEvent(ev); + webKitEvent.native_key_code = ev->nativeVirtualKey(); + webKitEvent.windows_key_code = windowsKeyCodeForKeyEvent(ev->key(), ev->modifiers() & Qt::KeypadModifier); + webKitEvent.dom_key = getDomKeyFromQKeyEvent(ev); ui::DomCode domCode = ui::DomCode::NONE; int scanCode = ev->nativeScanCode(); if (scanCode) domCode = ui::KeycodeConverter::NativeKeycodeToDomCode(scanCode); - webKitEvent.domCode = static_cast(domCode); + webKitEvent.dom_code = static_cast(domCode); const ushort* text = ev->text().utf16(); memcpy(&webKitEvent.text, text, std::min(sizeof(webKitEvent.text), size_t(ev->text().length() * 2))); - memcpy(&webKitEvent.unmodifiedText, text, std::min(sizeof(webKitEvent.unmodifiedText), size_t(ev->text().length() * 2))); + memcpy(&webKitEvent.unmodified_text, text, std::min(sizeof(webKitEvent.unmodified_text), size_t(ev->text().length() * 2))); - if (webKitEvent.windowsKeyCode == VK_RETURN) { + if (webKitEvent.windows_key_code == VK_RETURN) { // This is the same behavior as GTK: // We need to treat the enter key as a key press of character \r. This // is apparently just how webkit handles it and what it expects. - webKitEvent.unmodifiedText[0] = '\r'; - webKitEvent.text[0] = webKitEvent.unmodifiedText[0]; + webKitEvent.unmodified_text[0] = '\r'; + webKitEvent.text[0] = webKitEvent.unmodified_text[0]; } return webKitEvent; -- cgit v1.2.3