File webkit2gtk3-glib262.patch of Package webkit2gtk3

diff -urp webkitgtk-2.49.90.epoxy/Source/cmake/OptionsGTK.cmake webkitgtk-2.49.90.glib262/Source/cmake/OptionsGTK.cmake
--- webkitgtk-2.49.90.epoxy/Source/cmake/OptionsGTK.cmake	2025-09-05 16:31:46.209367248 -0500
+++ webkitgtk-2.49.90.glib262/Source/cmake/OptionsGTK.cmake	2025-09-06 10:51:58.274257777 -0500
@@ -8,7 +8,6 @@ SET_PROJECT_VERSION(2 49 90)
 set(USER_AGENT_BRANDING "" CACHE STRING "Branding to add to user agent string")
 
 # Update Source/WTF/wtf/Platform.h to match required GLib versions.
-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)
@@ -214,6 +213,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.49.90.epoxy/Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp webkitgtk-2.49.90.glib262/Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp
--- webkitgtk-2.49.90.epoxy/Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp	2025-08-08 04:17:55.336475000 -0500
+++ webkitgtk-2.49.90.glib262/Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp	2025-09-05 16:34:28.255246596 -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.49.90.epoxy/Source/WebCore/platform/LowPowerModeNotifier.h webkitgtk-2.49.90.glib262/Source/WebCore/platform/LowPowerModeNotifier.h
--- webkitgtk-2.49.90.epoxy/Source/WebCore/platform/LowPowerModeNotifier.h	2025-08-08 04:17:55.292475700 -0500
+++ webkitgtk-2.49.90.glib262/Source/WebCore/platform/LowPowerModeNotifier.h	2025-09-05 16:34:28.255634611 -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.49.90.epoxy/Source/WebCore/platform/network/soup/CertificateInfoSoup.cpp webkitgtk-2.49.90.glib262/Source/WebCore/platform/network/soup/CertificateInfoSoup.cpp
--- webkitgtk-2.49.90.epoxy/Source/WebCore/platform/network/soup/CertificateInfoSoup.cpp	2025-08-08 04:17:55.504471500 -0500
+++ webkitgtk-2.49.90.glib262/Source/WebCore/platform/network/soup/CertificateInfoSoup.cpp	2025-09-05 16:34:28.256079184 -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.49.90.epoxy/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp webkitgtk-2.49.90.glib262/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp
--- webkitgtk-2.49.90.epoxy/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp	2025-08-08 04:17:55.920463600 -0500
+++ webkitgtk-2.49.90.glib262/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp	2025-09-05 16:34:28.256465205 -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 (!privateKey) [[unlikely]]
@@ -147,6 +150,7 @@ std::optional<GRefPtr<GTlsCertificate>>
     decoder >> privateKeyPKCS11Uri;
     if (!privateKeyPKCS11Uri) [[unlikely]]
         return std::nullopt;
+#endif
 
     GType certificateType = g_tls_backend_get_certificate_type(g_tls_backend_get_default());
     GRefPtr<GTlsCertificate> certificate;
@@ -157,8 +161,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();
         i++;
diff -urp webkitgtk-2.49.90.epoxy/Source/WTF/wtf/glib/GRefPtr.h webkitgtk-2.49.90.glib262/Source/WTF/wtf/glib/GRefPtr.h
--- webkitgtk-2.49.90.epoxy/Source/WTF/wtf/glib/GRefPtr.h	2025-08-08 04:17:54.504491300 -0500
+++ webkitgtk-2.49.90.glib262/Source/WTF/wtf/glib/GRefPtr.h	2025-09-08 11:49:33.046732495 -0500
@@ -328,7 +328,9 @@ WTF_DEFINE_GREF_TRAITS_INLINE(GMainLoop,
 WTF_DEFINE_GREF_TRAITS_INLINE(GMappedFile, g_mapped_file_ref, g_mapped_file_unref)
 WTF_DEFINE_GREF_TRAITS_INLINE(GPtrArray, g_ptr_array_ref, g_ptr_array_unref)
 WTF_DEFINE_GREF_TRAITS_INLINE(GSource, g_source_ref, g_source_unref)
+#if HAVE(GURI)
 WTF_DEFINE_GREF_TRAITS_INLINE(GUri, g_uri_ref, g_uri_unref)
+#endif
 WTF_DEFINE_GREF_TRAITS_INLINE(GVariantBuilder, g_variant_builder_ref, g_variant_builder_unref)
 WTF_DEFINE_GREF_TRAITS_INLINE(GVariant, g_variant_ref_sink, g_variant_unref, g_variant_is_floating)
 
diff -urp webkitgtk-2.49.90.epoxy/Source/WTF/wtf/glib/URLGLib.cpp webkitgtk-2.49.90.glib262/Source/WTF/wtf/glib/URLGLib.cpp
--- webkitgtk-2.49.90.epoxy/Source/WTF/wtf/glib/URLGLib.cpp	2025-08-08 04:17:54.504491300 -0500
+++ webkitgtk-2.49.90.glib262/Source/WTF/wtf/glib/URLGLib.cpp	2025-09-05 16:34:28.257384276 -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.49.90.epoxy/Source/WTF/wtf/Platform.h webkitgtk-2.49.90.glib262/Source/WTF/wtf/Platform.h
--- webkitgtk-2.49.90.epoxy/Source/WTF/wtf/Platform.h	2025-08-08 04:17:54.468492000 -0500
+++ webkitgtk-2.49.90.glib262/Source/WTF/wtf/Platform.h	2025-09-08 14:32:57.304792442 -0500
@@ -84,7 +84,7 @@
 
 #if PLATFORM(GTK)
 #define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_56
-#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_70
+#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_62
 #if USE(GTK4)
 #define GDK_VERSION_MIN_REQUIRED GDK_VERSION_4_0
 #else
diff -urp webkitgtk-2.49.90.epoxy/Source/WTF/wtf/URL.h webkitgtk-2.49.90.glib262/Source/WTF/wtf/URL.h
--- webkitgtk-2.49.90.epoxy/Source/WTF/wtf/URL.h	2025-08-08 04:17:54.484491600 -0500
+++ webkitgtk-2.49.90.glib262/Source/WTF/wtf/URL.h	2025-09-05 16:34:28.257662834 -0500
@@ -27,7 +27,7 @@
 
 #include <wtf/text/WTFString.h>
 
-#if USE(GLIB)
+#if USE(GLIB) && HAVE(GURI)
 #include <wtf/glib/GRefPtr.h>
 #endif
 
@@ -240,7 +240,7 @@ public:
     WTF_EXPORT_PRIVATE static NSURL *emptyNSURL();
 #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