From b7ee55825707dd381a616d9f16bbfa9fe0044e23 Mon Sep 17 00:00:00 2001
From: oreo639 <oreo6391@gmail.com>
Date: Mon, 10 Feb 2025 15:50:17 -0800
Subject: [PATCH] libwebkit2gtk41: update to 2.46.6, drop webkit2gtk

---
 srcpkgs/libwebkit2gtk41                       |  1 -
 srcpkgs/libwebkit2gtk41-devel                 |  2 +-
 .../patches/fix_armv6l.patch                  |  0
 .../patches/prefer-pthread.patch              |  0
 .../patches/reproducible.patch                |  0
 .../{webkit2gtk => libwebkit2gtk41}/template  | 63 +++----------------
 .../{webkit2gtk => libwebkit2gtk41}/update    |  0
 srcpkgs/libwebkitgtk60                        |  2 +-
 srcpkgs/libwebkitgtk60-devel                  |  2 +-
 srcpkgs/webkit2gtk-devel                      |  1 -
 .../patches/fix_create_gl_context.patch       | 54 ----------------
 srcpkgs/webkit2gtk/patches/x86-no-sse2.patch  | 29 ---------
 12 files changed, 12 insertions(+), 142 deletions(-)
 delete mode 120000 srcpkgs/libwebkit2gtk41
 rename srcpkgs/{webkit2gtk => libwebkit2gtk41}/patches/fix_armv6l.patch (100%)
 rename srcpkgs/{webkit2gtk => libwebkit2gtk41}/patches/prefer-pthread.patch (100%)
 rename srcpkgs/{webkit2gtk => libwebkit2gtk41}/patches/reproducible.patch (100%)
 rename srcpkgs/{webkit2gtk => libwebkit2gtk41}/template (79%)
 rename srcpkgs/{webkit2gtk => libwebkit2gtk41}/update (100%)
 delete mode 120000 srcpkgs/webkit2gtk-devel
 delete mode 100644 srcpkgs/webkit2gtk/patches/fix_create_gl_context.patch
 delete mode 100644 srcpkgs/webkit2gtk/patches/x86-no-sse2.patch

diff --git a/srcpkgs/libwebkit2gtk41 b/srcpkgs/libwebkit2gtk41
deleted file mode 120000
index 8ae98428991..00000000000
--- a/srcpkgs/libwebkit2gtk41
+++ /dev/null
@@ -1 +0,0 @@
-webkit2gtk
\ No newline at end of file
diff --git a/srcpkgs/libwebkit2gtk41-devel b/srcpkgs/libwebkit2gtk41-devel
index 8ae98428991..a56a647c20e 120000
--- a/srcpkgs/libwebkit2gtk41-devel
+++ b/srcpkgs/libwebkit2gtk41-devel
@@ -1 +1 @@
-webkit2gtk
\ No newline at end of file
+libwebkit2gtk41
\ No newline at end of file
diff --git a/srcpkgs/webkit2gtk/patches/fix_armv6l.patch b/srcpkgs/libwebkit2gtk41/patches/fix_armv6l.patch
similarity index 100%
rename from srcpkgs/webkit2gtk/patches/fix_armv6l.patch
rename to srcpkgs/libwebkit2gtk41/patches/fix_armv6l.patch
diff --git a/srcpkgs/webkit2gtk/patches/prefer-pthread.patch b/srcpkgs/libwebkit2gtk41/patches/prefer-pthread.patch
similarity index 100%
rename from srcpkgs/webkit2gtk/patches/prefer-pthread.patch
rename to srcpkgs/libwebkit2gtk41/patches/prefer-pthread.patch
diff --git a/srcpkgs/webkit2gtk/patches/reproducible.patch b/srcpkgs/libwebkit2gtk41/patches/reproducible.patch
similarity index 100%
rename from srcpkgs/webkit2gtk/patches/reproducible.patch
rename to srcpkgs/libwebkit2gtk41/patches/reproducible.patch
diff --git a/srcpkgs/webkit2gtk/template b/srcpkgs/libwebkit2gtk41/template
similarity index 79%
rename from srcpkgs/webkit2gtk/template
rename to srcpkgs/libwebkit2gtk41/template
index f435dea2319..c6762f8089f 100644
--- a/srcpkgs/webkit2gtk/template
+++ b/srcpkgs/libwebkit2gtk41/template
@@ -1,6 +1,6 @@
-# Template file for 'webkit2gtk'
-pkgname=webkit2gtk
-version=2.44.2
+# Template file for 'libwebkit2gtk41'
+pkgname=libwebkit2gtk41
+version=2.46.6
 revision=1
 build_style=cmake
 build_helper="gir"
@@ -24,23 +24,21 @@ hostmakedepends="perl python3 pkg-config gperf flex ruby gettext glib-devel
  $(vopt_if wayland 'wayland-devel libxml2-devel')"
 makedepends="at-spi2-core-devel libjpeg-turbo-devel libpng-devel
  harfbuzz-devel gst-plugins-base1-devel gst-plugins-bad1-devel sqlite-devel
- libsoup-devel libsoup3-devel libxslt-devel gnutls-devel icu-devel enchant2-devel
+ libsoup3-devel libxslt-devel gnutls-devel icu-devel enchant2-devel
  dbus-glib-devel libwebp-devel gtk+3-devel gtk4-devel libgudev-devel
  libsecret-devel ruby-devel geoclue2-devel libnotify-devel hyphen-devel
- woff2-devel freetype-devel libavif-devel qt5-devel libmanette-devel
+ woff2-devel freetype-devel libavif-devel qt5-devel libmanette-devel sysprof-devel
  libgcrypt-devel libnuspell-devel libpsl-devel $(vopt_if x11 libXt-devel)
  $(vopt_if wayland 'MesaLib-devel libxkbcommon-devel wayland-devel wayland-protocols')"
 depends="gst-plugins-good1"
-short_desc="GTK+3 port of the WebKit browser engine"
+short_desc="GTK+3 port of the WebKit browser engine (soup3)"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later, BSD-2-Clause"
 homepage="https://webkitgtk.org/"
 distfiles="https://webkitgtk.org/releases/webkitgtk-${version}.tar.xz"
-checksum=523f42c8ff24832add17631f6eaafe8f9303afe316ef1a7e1844b952a7f7521b
+checksum=f2b31de693220ba9bab76ce6ddfe5b0bfab2515cb2b0a70f3c54d4050766c32b
 make_check=no # TODO
 
-replaces="webkit2gtk-common>0"
-
 build_options="gir wayland x11 bubblewrap jit sampling_profiler minibrowser
  clang lto gtk_doc"
 build_options_default="gir wayland x11 bubblewrap minibrowser"
@@ -151,12 +149,7 @@ pre_configure() {
 }
 
 post_configure() {
-	mkdir -p webkit2gtk-40 webkit2gtk-60
-	(
-		cd webkit2gtk-40
-		configure_args="${configure_args} -DUSE_SOUP2=ON -DENABLE_WEBDRIVER=OFF" \
-		do_configure
-	)
+	mkdir -p webkit2gtk-60
 
 	(
 		cd webkit2gtk-60
@@ -166,12 +159,10 @@ post_configure() {
 }
 
 post_build() {
-	(cd webkit2gtk-40 && NINJA_STATUS="[2/3][%f/%t] " do_build)
-	(cd webkit2gtk-60 && NINJA_STATUS="[3/3][%f/%t] " do_build)
+	(cd webkit2gtk-60 && NINJA_STATUS="[2/2][%f/%t] " do_build)
 }
 
 post_install() {
-	(cd webkit2gtk-40 && do_install)
 	(cd webkit2gtk-60 && do_install)
 
 	vlicense Source/WebCore/LICENSE-APPLE
@@ -179,42 +170,6 @@ post_install() {
 	vlicense Source/WebCore/LICENSE-LGPL-2
 }
 
-webkit2gtk-devel_package() {
-	depends="gtk+3-devel libsoup-devel ${sourcepkg}>=${version}_${revision}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include/webkitgtk-4.0
-		vmove "usr/lib/pkgconfig/*-4.0.pc"
-		if [ "$build_option_gir" ]; then
-			vmove "usr/share/gir-1.0/*-4.0.gir"
-		fi
-		if [ "$build_option_gtk_doc" ]; then
-			vmove "usr/share/doc/*-4.0"
-		fi
-		vmove "usr/lib/*-4.0.so"
-	}
-}
-
-libwebkit2gtk41_package() {
-	depends="${_depends}"
-	short_desc="GTK+3 port of the WebKit browser engine (soup3)"
-	pkg_install() {
-		vmove usr/bin/WebKitWebDriver
-		vmove usr/libexec/webkit2gtk-4.1
-		vmove usr/lib/webkit2gtk-4.1
-		if [ "$build_option_gir" ]; then
-			vmove "usr/lib/girepository-1.0/*-4.1.typelib"
-		fi
-		vmove "usr/lib/*-4.1.so.*"
-		for file in $(find ${DESTDIR}/usr/share/locale -name "*-4.1.mo"); do
-			vmove ${file/$DESTDIR/}
-		done
-		vlicense Source/WebCore/LICENSE-APPLE
-		vlicense Source/WebCore/LICENSE-LGPL-2.1
-		vlicense Source/WebCore/LICENSE-LGPL-2
-	}
-}
-
 libwebkit2gtk41-devel_package() {
 	depends="gtk+3-devel libsoup3-devel libwebkit2gtk41>=${version}_${revision}"
 	short_desc="GTK+3 port of the WebKit browser engine (soup3) - development files"
diff --git a/srcpkgs/webkit2gtk/update b/srcpkgs/libwebkit2gtk41/update
similarity index 100%
rename from srcpkgs/webkit2gtk/update
rename to srcpkgs/libwebkit2gtk41/update
diff --git a/srcpkgs/libwebkitgtk60 b/srcpkgs/libwebkitgtk60
index 8ae98428991..a56a647c20e 120000
--- a/srcpkgs/libwebkitgtk60
+++ b/srcpkgs/libwebkitgtk60
@@ -1 +1 @@
-webkit2gtk
\ No newline at end of file
+libwebkit2gtk41
\ No newline at end of file
diff --git a/srcpkgs/libwebkitgtk60-devel b/srcpkgs/libwebkitgtk60-devel
index 8ae98428991..a56a647c20e 120000
--- a/srcpkgs/libwebkitgtk60-devel
+++ b/srcpkgs/libwebkitgtk60-devel
@@ -1 +1 @@
-webkit2gtk
\ No newline at end of file
+libwebkit2gtk41
\ No newline at end of file
diff --git a/srcpkgs/webkit2gtk-devel b/srcpkgs/webkit2gtk-devel
deleted file mode 120000
index 8ae98428991..00000000000
--- a/srcpkgs/webkit2gtk-devel
+++ /dev/null
@@ -1 +0,0 @@
-webkit2gtk
\ No newline at end of file
diff --git a/srcpkgs/webkit2gtk/patches/fix_create_gl_context.patch b/srcpkgs/webkit2gtk/patches/fix_create_gl_context.patch
deleted file mode 100644
index 047e364124d..00000000000
--- a/srcpkgs/webkit2gtk/patches/fix_create_gl_context.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From 3ec05c63ec38d19773c074f60eb2f9406e298b47 Mon Sep 17 00:00:00 2001
-From: Carlos Garcia Campos <cgarcia@igalia.com>
-Date: Fri, 14 Jun 2024 09:56:54 +0200
-Subject: [PATCH] REGRESSION(273818@main): [GTK] Eclipse crashes when rendering
- tooltips: gdk_window_create_gl_context: assertion 'GDK_IS_WINDOW (window)'
- failed in WebKit::AcceleratedBackingStoreDMABuf::ensureGLContext
- https://bugs.webkit.org/show_bug.cgi?id=271477
-
-Reviewed by NOBODY (OOPS!).
-
-Update the buffer contents on prepareForRendering to make sure the view
-is already realized, which is required to create the gl context.
-
-* Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp:
-(WebKit::AcceleratedBackingStoreDMABuf::frame):
-(WebKit::AcceleratedBackingStoreDMABuf::prepareForRendering):
----
- .../gtk/AcceleratedBackingStoreDMABuf.cpp         | 15 ++++++---------
- 1 file changed, 6 insertions(+), 9 deletions(-)
-
-diff --git a/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp b/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp
-index b71fb0a8ac06..66d8a4801aba 100644
---- a/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp
-+++ b/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp
-@@ -544,12 +544,6 @@ void AcceleratedBackingStoreDMABuf::frame(uint64_t bufferID)
-         return;
-     }
- 
--    if (buffer->type() == Buffer::Type::EglImage) {
--        ensureGLContext();
--        gdk_gl_context_make_current(m_gdkGLContext.get());
--    }
--    buffer->didUpdateContents();
--
-     m_pendingBuffer = buffer;
-     gtk_widget_queue_draw(m_webPage.viewWidget());
- }
-@@ -613,10 +607,13 @@ void AcceleratedBackingStoreDMABuf::update(const LayerTreeContext& context)
- 
- bool AcceleratedBackingStoreDMABuf::prepareForRendering()
- {
--    if (m_gdkGLContext)
--        gdk_gl_context_make_current(m_gdkGLContext.get());
--
-     if (m_pendingBuffer) {
-+        if (m_pendingBuffer->type() == Buffer::Type::EglImage) {
-+            ensureGLContext();
-+            gdk_gl_context_make_current(m_gdkGLContext.get());
-+        }
-+        m_pendingBuffer->didUpdateContents();
-+
-         if (m_committedBuffer)
-             m_webPage.legacyMainFrameProcess().send(Messages::AcceleratedSurfaceDMABuf::ReleaseBuffer(m_committedBuffer->id()), m_surfaceID);
-         m_committedBuffer = WTFMove(m_pendingBuffer);
diff --git a/srcpkgs/webkit2gtk/patches/x86-no-sse2.patch b/srcpkgs/webkit2gtk/patches/x86-no-sse2.patch
deleted file mode 100644
index 3a0e5f158cb..00000000000
--- a/srcpkgs/webkit2gtk/patches/x86-no-sse2.patch
+++ /dev/null
@@ -1,29 +0,0 @@
---- a/Source/cmake/WebKitCompilerFlags.cmake
-+++ b/Source/cmake/WebKitCompilerFlags.cmake
-@@ -162,15 +162,6 @@ if (COMPILER_IS_GCC_OR_CLANG)
-         WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-Wno-expansion-to-defined)
-     endif ()
- 
--    # Force SSE2 fp on x86 builds.
--    if (WTF_CPU_X86 AND NOT CMAKE_CROSSCOMPILING)
--        WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-msse2 -mfpmath=sse)
--        include(DetectSSE2)
--        if (NOT SSE2_SUPPORT_FOUND)
--            message(FATAL_ERROR "SSE2 support is required to compile WebKit")
--        endif ()
--    endif ()
--
-     # Makes builds faster. The GCC manual warns about the possibility that the assembler being
-     # used may not support input from a pipe, but in practice the toolchains we support all do.
-     WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-pipe)
---- a/Source/ThirdParty/ANGLE/src/common/platform.h
-+++ b/Source/ThirdParty/ANGLE/src/common/platform.h
-@@ -102,7 +102,7 @@
- #if defined(_MSC_VER) && !defined(_M_ARM) && !defined(_M_ARM64)
- #    include <intrin.h>
- #    define ANGLE_USE_SSE
--#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__))
-+#elif defined(__GNUC__) && defined(__x86_64__)
- #    include <x86intrin.h>
- #    define ANGLE_USE_SSE
- #endif