SHA256
1
0
forked from pool/webkit2gtk3

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
This commit is contained in:
Dominique Leuenberger 2021-01-21 11:29:06 +00:00 committed by Git OBS Bridge
parent 0d5b8df5ee
commit 33ab37f443
3 changed files with 123 additions and 2 deletions

108
webkit-font-scaling.patch Normal file
View File

@ -0,0 +1,108 @@
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();
}
/**

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Tue Jan 19 19:12:53 UTC 2021 - Atri Bhattacharya <badshah400@gmail.com>
- 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.
-------------------------------------------------------------------
Tue Dec 15 14:06:42 UTC 2020 - Dominique Leuenberger <dimstar@opensuse.org>

View File

@ -1,7 +1,7 @@
#
# spec file for package webkit2gtk3
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -43,6 +43,8 @@ Source98: baselibs.conf
Source99: webkit2gtk3.keyring
# PATCH-FIX-OPENSUSE no-forced-sse.patch jengelh@iani.de -- cure execution of illegal instruction in i586 firefox.
Patch0: no-forced-sse.patch
# PATCH-FIX-UPSTREAM webkit-font-scaling.patch https://bugs.webkit.org/show_bug.cgi?id=218450 badshah400@gmail.com -- Fix system font scaling not applied to 'font-size: XXXpt'
Patch1: webkit-font-scaling.patch
# Below patches are for 15.0/15.1 only
# PATCH-FIX-OPENSUSE webkit-process.patch boo#1159329 mgorse@suse.com -- use single web process for evolution and geary.
Patch100: webkit-process.patch
@ -273,8 +275,9 @@ A small test browswer from webkit, useful for testing features.
%lang_package -n %{_pkgname_no_slpp}
%prep
%setup -n webkitgtk-%{version}
%setup -q -n webkitgtk-%{version}
%patch0 -p1
%patch1 -p1
%if 0%{?suse_version} <= 1500 && 0%{?sle_version} < 150200
%patch100 -p1
%patch101 -p1