File webkit2gtk3-glib262.patch of Package webkit2gtk3.38159

diff -urp webkitgtk-2.47.90.orig/Source/cmake/OptionsGTK.cmake webkitgtk-2.47.90/Source/cmake/OptionsGTK.cmake
--- webkitgtk-2.47.90.orig/Source/cmake/OptionsGTK.cmake	2025-03-11 12:40:14.046412708 -0500
+++ webkitgtk-2.47.90/Source/cmake/OptionsGTK.cmake	2025-03-11 14:55:44.157225224 -0500
@@ -7,7 +7,6 @@ SET_PROJECT_VERSION(2 47 90)
 
 set(USER_AGENT_BRANDING "" CACHE STRING "Branding to add to user agent string")
 
-find_package(GLIB 2.70.0 REQUIRED COMPONENTS gio gio-unix gobject gthread gmodule)
 find_package(Cairo 1.16.0 REQUIRED)
 find_package(LibGcrypt 1.7.0 REQUIRED)
 find_package(Libtasn1 REQUIRED)
@@ -212,6 +211,13 @@ else ()
     SET_AND_EXPOSE_TO_BUILD(ENABLE_2022_GLIB_API OFF)
 endif ()
 
+if (ENABLE_2022_GLIB_API)
+    set(GLIB_MINIMUM_VERSION 2.70.0)
+else ()
+    set(GLIB_MINIMUM_VERSION 2.60.0)
+endif ()
+find_package(GLIB ${GLIB_MINIMUM_VERSION} REQUIRED COMPONENTS gio gio-unix gobject gthread gmodule)
+
 EXPOSE_STRING_VARIABLE_TO_BUILD(WEBKITGTK_API_INFIX)
 EXPOSE_STRING_VARIABLE_TO_BUILD(WEBKITGTK_API_VERSION)
 
@@ -284,6 +290,11 @@ if (ENABLED_COMPILER_SANITIZERS)
     set(ENABLE_DOCUMENTATION OFF)
 endif ()
 
+# GUri is available in GLib since version 2.66, but we only want to use it if version is >= 2.67.1.
+if (PC_GLIB_VERSION VERSION_GREATER "2.67.1" OR PC_GLIB_VERSION STREQUAL "2.67.1")
+    SET_AND_EXPOSE_TO_BUILD(HAVE_GURI 1)
+endif ()
+
 if (ENABLE_GAMEPAD)
     find_package(Manette 0.2.4)
     if (NOT Manette_FOUND)
diff -urp webkitgtk-2.47.90.orig/Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp webkitgtk-2.47.90/Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp
--- webkitgtk-2.47.90.orig/Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp	2025-02-25 02:25:41.383391400 -0600
+++ webkitgtk-2.47.90/Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp	2025-03-11 14:55:44.155616153 -0500
@@ -28,10 +28,13 @@ namespace WebCore {
 
 
 LowPowerModeNotifier::LowPowerModeNotifier(LowPowerModeChangeCallback&& callback)
+#if GLIB_CHECK_VERSION(2, 69, 1)
     : m_callback(WTFMove(callback))
     , m_powerProfileMonitor(adoptGRef(g_power_profile_monitor_dup_default()))
     , m_lowPowerModeEnabled(g_power_profile_monitor_get_power_saver_enabled(m_powerProfileMonitor.get()))
+#endif
 {
+#if GLIB_CHECK_VERSION(2, 69, 1)
     g_signal_connect_swapped(m_powerProfileMonitor.get(), "notify::power-saver-enabled", G_CALLBACK(+[] (LowPowerModeNotifier* self, GParamSpec*, GPowerProfileMonitor* monitor) {
         bool powerSaverEnabled = g_power_profile_monitor_get_power_saver_enabled(monitor);
         if (self->m_lowPowerModeEnabled != powerSaverEnabled) {
@@ -39,11 +42,16 @@ LowPowerModeNotifier::LowPowerModeNotifi
             self->m_callback(self->m_lowPowerModeEnabled);
         }
     }), this);
+#else
+    UNUSED_PARAM(callback);
+#endif
 }
 
 LowPowerModeNotifier::~LowPowerModeNotifier()
 {
+#if GLIB_CHECK_VERSION(2, 69, 1)
     g_signal_handlers_disconnect_by_data(m_powerProfileMonitor.get(), this);
+#endif
 }
 
 bool LowPowerModeNotifier::isLowPowerModeEnabled() const
diff -urp webkitgtk-2.47.90.orig/Source/WebCore/platform/LowPowerModeNotifier.h webkitgtk-2.47.90/Source/WebCore/platform/LowPowerModeNotifier.h
--- webkitgtk-2.47.90.orig/Source/WebCore/platform/LowPowerModeNotifier.h	2025-02-25 02:25:41.335390000 -0600
+++ webkitgtk-2.47.90/Source/WebCore/platform/LowPowerModeNotifier.h	2025-03-11 14:55:44.155567189 -0500
@@ -61,8 +61,10 @@ private:
     RetainPtr<WebLowPowerModeObserver> m_observer;
     LowPowerModeChangeCallback m_callback;
 #elif USE(GLIB)
+#if GLIB_CHECK_VERSION(2, 69, 1)
     LowPowerModeChangeCallback m_callback;
     GRefPtr<GPowerProfileMonitor> m_powerProfileMonitor;
+#endif
     bool m_lowPowerModeEnabled { false };
 #endif
 };
diff -urp webkitgtk-2.47.90.orig/Source/WebCore/platform/network/soup/CertificateInfoSoup.cpp webkitgtk-2.47.90/Source/WebCore/platform/network/soup/CertificateInfoSoup.cpp
--- webkitgtk-2.47.90.orig/Source/WebCore/platform/network/soup/CertificateInfoSoup.cpp	2025-02-25 02:25:41.563395700 -0600
+++ webkitgtk-2.47.90/Source/WebCore/platform/network/soup/CertificateInfoSoup.cpp	2025-03-11 14:55:44.156325443 -0500
@@ -73,9 +73,11 @@ CertificateInfo CertificateInfo::isolate
         certificatesDataList.append(certificateData.release());
     }
 
+#if GLIB_CHECK_VERSION(2, 69, 0)
     GUniqueOutPtr<char> privateKey;
     GUniqueOutPtr<char> privateKeyPKCS11Uri;
     g_object_get(m_certificate.get(), "private-key-pem", &privateKey.outPtr(), "private-key-pkcs11-uri", &privateKeyPKCS11Uri.outPtr(), nullptr);
+#endif
 
     GType certificateType = g_tls_backend_get_certificate_type(g_tls_backend_get_default());
     GRefPtr<GTlsCertificate> certificate;
@@ -86,8 +88,10 @@ CertificateInfo CertificateInfo::isolate
             certificateType, nullptr, nullptr,
             "certificate-pem", certificateData.get(),
             "issuer", issuer,
+#if GLIB_CHECK_VERSION(2, 69, 0)
             "private-key-pem", certificatesDataList.isEmpty() ? privateKey.get() : nullptr,
             "private-key-pkcs11-uri", certificatesDataList.isEmpty() ? privateKeyPKCS11Uri.get() : nullptr,
+#endif
             nullptr)));
         RELEASE_ASSERT(certificate);
         issuer = certificate.get();
@@ -101,6 +105,7 @@ std::optional<CertificateSummary> Certif
     if (!m_certificate)
         return std::nullopt;
 
+#if GLIB_CHECK_VERSION(2, 69, 0)
     CertificateSummary summaryInfo;
 
     GRefPtr<GDateTime> validNotBefore;
@@ -125,6 +130,9 @@ std::optional<CertificateSummary> Certif
     }
 
     return summaryInfo;
+#else
+    return std::nullopt;
+#endif
 }
 
 } // namespace WebCore
diff -urp webkitgtk-2.47.90.orig/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp webkitgtk-2.47.90/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp
--- webkitgtk-2.47.90.orig/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp	2025-02-25 02:25:41.983405800 -0600
+++ webkitgtk-2.47.90/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp	2025-03-11 14:55:44.156758452 -0500
@@ -121,11 +121,13 @@ void ArgumentCoder<GRefPtr<GTlsCertifica
 
     encoder << certificatesData;
 
+#if GLIB_CHECK_VERSION(2, 69, 0)
     GRefPtr<GByteArray> privateKey;
     GUniqueOutPtr<char> privateKeyPKCS11Uri;
     g_object_get(certificate.get(), "private-key", &privateKey.outPtr(), "private-key-pkcs11-uri", &privateKeyPKCS11Uri.outPtr(), nullptr);
     encoder << privateKey;
     encoder << CString(privateKeyPKCS11Uri.get());
+#endif
 }
 
 std::optional<GRefPtr<GTlsCertificate>> ArgumentCoder<GRefPtr<GTlsCertificate>>::decode(Decoder& decoder)
@@ -138,6 +140,7 @@ std::optional<GRefPtr<GTlsCertificate>>
     if (!certificatesData->size())
         return GRefPtr<GTlsCertificate>();
 
+#if GLIB_CHECK_VERSION(2, 69, 0)
     std::optional<GRefPtr<GByteArray>> privateKey;
     decoder >> privateKey;
     if (UNLIKELY(!privateKey))
@@ -147,6 +150,7 @@ std::optional<GRefPtr<GTlsCertificate>>
     decoder >> privateKeyPKCS11Uri;
     if (UNLIKELY(!privateKeyPKCS11Uri))
         return std::nullopt;
+#endif
 
     GType certificateType = g_tls_backend_get_certificate_type(g_tls_backend_get_default());
     GRefPtr<GTlsCertificate> certificate;
@@ -156,8 +160,10 @@ std::optional<GRefPtr<GTlsCertificate>>
             certificateType, nullptr, nullptr,
             "certificate", certificateData.get(),
             "issuer", issuer,
+#if GLIB_CHECK_VERSION(2, 69, 0)
             "private-key", i == certificatesData->size() - 1 ? privateKey->get() : nullptr,
             "private-key-pkcs11-uri", i == certificatesData->size() - 1 ? privateKeyPKCS11Uri->data() : nullptr,
+#endif
             nullptr)));
         issuer = certificate.get();
     }
diff -urp webkitgtk-2.47.90.orig/Source/WTF/wtf/glib/GRefPtr.cpp webkitgtk-2.47.90/Source/WTF/wtf/glib/GRefPtr.cpp
--- webkitgtk-2.47.90.orig/Source/WTF/wtf/glib/GRefPtr.cpp	2025-02-25 02:25:40.587372300 -0600
+++ webkitgtk-2.47.90/Source/WTF/wtf/glib/GRefPtr.cpp	2025-03-11 14:55:44.153649924 -0500
@@ -207,6 +207,7 @@ template <> void derefGPtr(GDBusNodeInfo
         g_dbus_node_info_unref(ptr);
 }
 
+#if HAVE(GURI)
 template <> GUri* refGPtr(GUri* ptr)
 {
     if (ptr)
@@ -219,6 +220,7 @@ template <> void derefGPtr(GUri* ptr)
     if (ptr)
         g_uri_unref(ptr);
 }
+#endif
 
 template <>
 GArray* refGPtr(GArray* ptr)
diff -urp webkitgtk-2.47.90.orig/Source/WTF/wtf/glib/GRefPtr.h webkitgtk-2.47.90/Source/WTF/wtf/glib/GRefPtr.h
--- webkitgtk-2.47.90.orig/Source/WTF/wtf/glib/GRefPtr.h	2025-02-25 02:25:40.587372300 -0600
+++ webkitgtk-2.47.90/Source/WTF/wtf/glib/GRefPtr.h	2025-03-11 14:55:44.154254146 -0500
@@ -264,8 +264,11 @@ template <> WTF_EXPORT_PRIVATE GArray* r
 template <> WTF_EXPORT_PRIVATE void derefGPtr(GArray*);
 template <> WTF_EXPORT_PRIVATE GResource* refGPtr(GResource*);
 template <> WTF_EXPORT_PRIVATE void derefGPtr(GResource*);
+
+#if HAVE(GURI)
 template <> WTF_EXPORT_PRIVATE GUri* refGPtr(GUri*);
 template <> WTF_EXPORT_PRIVATE void derefGPtr(GUri*);
+#endif
 
 template <typename T> inline T* refGPtr(T* ptr)
 {
diff -urp webkitgtk-2.47.90.orig/Source/WTF/wtf/glib/URLGLib.cpp webkitgtk-2.47.90/Source/WTF/wtf/glib/URLGLib.cpp
--- webkitgtk-2.47.90.orig/Source/WTF/wtf/glib/URLGLib.cpp	2025-02-25 02:25:40.591372300 -0600
+++ webkitgtk-2.47.90/Source/WTF/wtf/glib/URLGLib.cpp	2025-03-11 14:55:44.154797173 -0500
@@ -35,6 +35,7 @@
 
 namespace WTF {
 
+#if HAVE(GURI)
 URL::URL(GUri* uri)
 {
     if (!uri) {
@@ -56,6 +57,7 @@ GRefPtr<GUri> URL::createGUri() const
         static_cast<GUriFlags>(G_URI_FLAGS_HAS_PASSWORD | G_URI_FLAGS_ENCODED_PATH | G_URI_FLAGS_ENCODED_QUERY | G_URI_FLAGS_ENCODED_FRAGMENT | G_URI_FLAGS_SCHEME_NORMALIZE | G_URI_FLAGS_PARSE_RELAXED),
         nullptr));
 }
+#endif
 
 bool URL::hostIsIPAddress(StringView host)
 {
diff -urp webkitgtk-2.47.90.orig/Source/WTF/wtf/URL.h webkitgtk-2.47.90/Source/WTF/wtf/URL.h
--- webkitgtk-2.47.90.orig/Source/WTF/wtf/URL.h	2025-02-25 02:25:40.575372000 -0600
+++ webkitgtk-2.47.90/Source/WTF/wtf/URL.h	2025-03-11 14:55:44.151616091 -0500
@@ -27,7 +27,7 @@
 
 #include <wtf/text/WTFString.h>
 
-#if USE(GLIB)
+#if USE(GLIB) && HAVE(GURI)
 #include <wtf/glib/GRefPtr.h>
 #endif
 
@@ -237,7 +237,7 @@ public:
     WTF_EXPORT_PRIVATE operator NSURL *() const;
 #endif
 
-#if USE(GLIB)
+#if USE(GLIB) && HAVE(GURI)
     WTF_EXPORT_PRIVATE URL(GUri*);
     WTF_EXPORT_PRIVATE GRefPtr<GUri> createGUri() const;
 #endif
openSUSE Build Service is sponsored by