From dcf89d342fb192bf1439ecc27851f49c93fb008e Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 28 Apr 2026 18:12:15 +0200 Subject: [PATCH] Revert "[DOM] Ensure the GC sees consistent states while adopting DOM nodes." This reverts commit 07c08f37be33ccff30fdc07b8fd6f2ec282e15bf. --- dom/bindings/BindingUtils.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index d934e86716..080705174e 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -2210,6 +2210,11 @@ ReparentWrapper(JSContext* aCx, JS::Handle aObjArg, ErrorResult& aErr js::GetReservedOrProxyPrivateSlot(aObj, DOM_OBJECT_SLOT)); js::SetReservedOrProxyPrivateSlot(aObj, DOM_OBJECT_SLOT, JS::PrivateValue(nullptr)); + aObj = xpc::TransplantObject(aCx, aObj, newobj); + if (!aObj) { + MOZ_CRASH(); + } + nsWrapperCache* cache = nullptr; CallQueryInterface(native, &cache); bool preserving = cache->PreservingWrapper(); @@ -2217,20 +2222,6 @@ ReparentWrapper(JSContext* aCx, JS::Handle aObjArg, ErrorResult& aErr cache->SetWrapper(aObj); cache->SetPreservingWrapper(preserving); - aObj = xpc::TransplantObject(aCx, aObj, newobj); - if (!aObj) { - MOZ_CRASH(); - } - - // Update the wrapper cache again if transplanting didn't use newobj but - // returned some other object. - if (aObj != newobj) { - preserving = cache->PreservingWrapper(); - cache->SetPreservingWrapper(false); - cache->SetWrapper(aObj); - cache->SetPreservingWrapper(preserving); - } - if (propertyHolder) { JS::Rooted copyTo(aCx); if (isProxy) {