ladybird/Userland/Libraries/LibWeb/Bindings/Wrapper.h
Andreas Kling 6a1b82df2b LibJS: Put zombie cell tracking code behind a compile-time flag
Since this is a debug-only feature, let's not have it impact GC marking
performance when you don't need it.
2021-10-02 16:39:28 +02:00

36 lines
607 B
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullRefPtr.h>
#include <AK/Weakable.h>
#include <LibJS/Runtime/Object.h>
#include <LibWeb/Forward.h>
namespace Web::Bindings {
class Wrapper
: public JS::Object
, public Weakable<Wrapper> {
JS_OBJECT(Wrapper, JS::Object);
public:
protected:
explicit Wrapper(Object& prototype)
: Object(prototype)
{
}
#ifdef JS_TRACK_ZOMBIE_CELLS
virtual void did_become_zombie() override
{
revoke_weak_ptrs();
}
#endif
};
}