Backport of [1] from 6.8/6.9 for [2].

[1] https://codereview.qt-project.org/c/qt/qtwebengine/+/569910
[2] https://bugreports.qt.io/browse/QTBUG-113574

From 21a9add47def34322b799683e1e1daff88dc4a06 Mon Sep 17 00:00:00 2001
From: David Edmundson <davidedmundson@kde.org>
Date: Wed, 19 Jun 2024 10:37:45 +0100
Subject: [PATCH] Use device pixel ratio of the window rather than the screen

Window device pixel ratio can differ from the screen depending on the
platform. The window is the more authorative source with new events in
Qt to support that.

In Chromium the rendering is still based off a screen factor, but each
view will have a completely independent set of screen variables, so we
can adjust the screen to match our current view.

Chromium itself also alters the screen scale factor on a per window
basis for their own native Wayland backend or if recording a window.
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -875,4 +875,9 @@
 
     display::ScreenInfos newScreenInfos = screenInfosFromQtForUpdate(window->screen());
+
+    // We always want to use the scale from our current window
+    // This screen information is stored on a per-view basis
+    auto &screen = newScreenInfos.mutable_current();
+    screen.device_scale_factor = window->devicePixelRatio();
     if (screen_infos_ == newScreenInfos)
         return false;
--- a/src/core/render_widget_host_view_qt_delegate_item.cpp
+++ b/src/core/render_widget_host_view_qt_delegate_item.cpp
@@ -346,4 +346,6 @@
                 onHide();
         }
+    } else if (change == QQuickItem::ItemDevicePixelRatioHasChanged) {
+        m_client->visualPropertiesChanged();
     }
 }
