SHA256
1
0
forked from pool/webkit2gtk3
webkit2gtk3/webkit-font-scaling.patch
Dominique Leuenberger 33ab37f443 Accepting request 864423 from GNOME:Next
- Add webkit-font-scaling.patch: Fix system font scaling not
  applied to 'font-size: XXXpt'; patch taken from upstream and
  rebased to apply cleanly
  (https://bugs.webkit.org/show_bug.cgi?id=218450).
- Pass `-q` to setup to disable printing long list of files
  extracted from source tarball.

OBS-URL: https://build.opensuse.org/request/show/864423
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/webkit2gtk3?expand=0&rev=286
2021-01-21 11:29:06 +00:00

109 lines
4.7 KiB
Diff

Index: webkitgtk-2.30.4/Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp
===================================================================
--- webkitgtk-2.30.4.orig/Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp
+++ webkitgtk-2.30.4/Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp
@@ -81,7 +81,6 @@ struct _WebKitSettingsPrivate {
CString mediaContentTypesRequiringHardwareSupport;
bool allowModalDialogs { false };
bool zoomTextOnly { false };
- double screenDpi { 96 };
#if PLATFORM(GTK)
bool enableBackForwardNavigationGestures { false };
#endif
@@ -176,7 +175,6 @@ enum {
static void webKitSettingsDispose(GObject* object)
{
- WebCore::setScreenDPIObserverHandler(nullptr, object);
G_OBJECT_CLASS(webkit_settings_parent_class)->dispose(object);
}
@@ -191,23 +189,6 @@ static void webKitSettingsConstructed(GO
bool mediaStreamEnabled = prefs->mediaStreamEnabled();
prefs->setMediaDevicesEnabled(mediaStreamEnabled);
prefs->setPeerConnectionEnabled(mediaStreamEnabled);
-
- settings->priv->screenDpi = WebCore::screenDPI();
- WebCore::setScreenDPIObserverHandler([settings]() {
- auto newScreenDpi = WebCore::screenDPI();
- if (newScreenDpi == settings->priv->screenDpi)
- return;
-
- auto scalingFactor = newScreenDpi / settings->priv->screenDpi;
- auto fontSize = settings->priv->preferences->defaultFontSize();
- auto monospaceFontSize = settings->priv->preferences->defaultFixedFontSize();
- settings->priv->screenDpi = newScreenDpi;
-
- g_object_freeze_notify(G_OBJECT(settings));
- webkit_settings_set_default_font_size(settings, std::round(fontSize * scalingFactor));
- webkit_settings_set_default_monospace_font_size(settings, std::round(monospaceFontSize * scalingFactor));
- g_object_thaw_notify(G_OBJECT(settings));
- }, object);
}
static void webKitSettingsSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
Index: webkitgtk-2.30.4/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
===================================================================
--- webkitgtk-2.30.4.orig/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
+++ webkitgtk-2.30.4/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
@@ -73,6 +73,7 @@
#include <WebCore/CertificateInfo.h>
#include <WebCore/GUniquePtrSoup.h>
#include <WebCore/JSDOMExceptionHandling.h>
+#include <WebCore/PlatformScreen.h>
#include <WebCore/RefPtrCairo.h>
#include <WebCore/URLSoup.h>
#include <glib/gi18n-lib.h>
@@ -306,6 +307,8 @@ struct _WebKitWebViewPrivate {
GRefPtr<WebKitWebsiteDataManager> websiteDataManager;
GRefPtr<WebKitWebsitePolicies> websitePolicies;
+
+ double textScaleFactor;
};
static guint signals[LAST_SIGNAL] = { 0, };
@@ -793,6 +796,15 @@ static void webkitWebViewConstructed(GOb
priv->backForwardList = adoptGRef(webkitBackForwardListCreate(&getPage(webView).backForwardList()));
priv->windowProperties = adoptGRef(webkitWindowPropertiesCreate());
+
+ priv->textScaleFactor = WebCore::screenDPI() / 96.;
+ getPage(webView).setTextZoomFactor(priv->textScaleFactor);
+ WebCore::setScreenDPIObserverHandler([webView] {
+ auto& page = getPage(webView);
+ auto zoomFactor = page.textZoomFactor() / webView->priv->textScaleFactor;
+ webView->priv->textScaleFactor = WebCore::screenDPI() / 96.;
+ page.setTextZoomFactor(zoomFactor * webView->priv->textScaleFactor);
+ }, webView);
}
static void webkitWebViewSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
@@ -956,6 +968,8 @@ static void webkitWebViewDispose(GObject
webView->priv->view->close();
#endif
+ WebCore::setScreenDPIObserverHandler(nullptr, webView);
+
G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
}
@@ -3600,7 +3614,7 @@ void webkit_web_view_set_zoom_level(WebK
auto& page = getPage(webView);
page.scalePage(1.0, IntPoint()); // Reset page scale when zoom level is changed
if (webkit_settings_get_zoom_text_only(webView->priv->settings.get()))
- page.setTextZoomFactor(zoomLevel);
+ page.setTextZoomFactor(zoomLevel * webView->priv->textScaleFactor);
else
page.setPageZoomFactor(zoomLevel);
g_object_notify(G_OBJECT(webView), "zoom-level");
@@ -3621,7 +3635,7 @@ gdouble webkit_web_view_get_zoom_level(W
auto& page = getPage(webView);
gboolean zoomTextOnly = webkit_settings_get_zoom_text_only(webView->priv->settings.get());
- return zoomTextOnly ? page.textZoomFactor() : page.pageZoomFactor();
+ return zoomTextOnly ? page.textZoomFactor() / webView->priv->textScaleFactor : page.pageZoomFactor();
}
/**