mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 04:50:29 +00:00
LibJS: Make JS::Cell a Weakable
This makes things easier downstream of Cell, and is preparation for using weak pointers in prototype chain property caches.
This commit is contained in:
parent
b5a7a8dbfd
commit
3945e1a82a
Notes:
sideshowbarker
2024-07-17 08:59:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3945e1a82a Pull-request: https://github.com/SerenityOS/serenity/pull/24206 Reviewed-by: https://github.com/kennethmyhra
12 changed files with 13 additions and 31 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <AK/HashMap.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibJS/Heap/Internals.h>
|
||||
|
@ -27,7 +28,7 @@ public: \
|
|||
} \
|
||||
friend class JS::Heap;
|
||||
|
||||
class Cell {
|
||||
class Cell : public Weakable<Cell> {
|
||||
AK_MAKE_NONCOPYABLE(Cell);
|
||||
AK_MAKE_NONMOVABLE(Cell);
|
||||
|
||||
|
|
|
@ -50,11 +50,7 @@ Heap::Heap(VM& vm)
|
|||
gc_perf_string_id = perf_register_string(gc_signpost_string.characters_without_null_termination(), gc_signpost_string.length());
|
||||
#endif
|
||||
|
||||
if constexpr (HeapBlock::min_possible_cell_size <= 16) {
|
||||
m_size_based_cell_allocators.append(make<CellAllocator>(16));
|
||||
}
|
||||
static_assert(HeapBlock::min_possible_cell_size <= 24, "Heap Cell tracking uses too much data!");
|
||||
m_size_based_cell_allocators.append(make<CellAllocator>(32));
|
||||
static_assert(HeapBlock::min_possible_cell_size <= 32, "Heap Cell tracking uses too much data!");
|
||||
m_size_based_cell_allocators.append(make<CellAllocator>(64));
|
||||
m_size_based_cell_allocators.append(make<CellAllocator>(96));
|
||||
m_size_based_cell_allocators.append(make<CellAllocator>(128));
|
||||
|
|
|
@ -20,9 +20,7 @@
|
|||
namespace JS {
|
||||
|
||||
// 9.3 Realms, https://tc39.es/ecma262/#realm-record
|
||||
class Realm final
|
||||
: public Cell
|
||||
, public Weakable<Realm> {
|
||||
class Realm final : public Cell {
|
||||
JS_CELL(Realm, Cell);
|
||||
JS_DECLARE_ALLOCATOR(Realm);
|
||||
|
||||
|
|
|
@ -34,9 +34,7 @@ struct TransitionKey {
|
|||
}
|
||||
};
|
||||
|
||||
class Shape final
|
||||
: public Cell
|
||||
, public Weakable<Shape> {
|
||||
class Shape final : public Cell {
|
||||
JS_CELL(Shape, Cell);
|
||||
JS_DECLARE_ALLOCATOR(Shape);
|
||||
|
||||
|
|
|
@ -22,9 +22,7 @@ namespace Web::Bindings {
|
|||
}
|
||||
|
||||
// https://webidl.spec.whatwg.org/#dfn-platform-object
|
||||
class PlatformObject
|
||||
: public JS::Object
|
||||
, public Weakable<PlatformObject> {
|
||||
class PlatformObject : public JS::Object {
|
||||
JS_OBJECT(PlatformObject, JS::Object);
|
||||
|
||||
public:
|
||||
|
|
|
@ -25,9 +25,7 @@ struct CSSStyleSheetInit {
|
|||
bool disabled { false };
|
||||
};
|
||||
|
||||
class CSSStyleSheet final
|
||||
: public StyleSheet
|
||||
, public Weakable<CSSStyleSheet> {
|
||||
class CSSStyleSheet final : public StyleSheet {
|
||||
WEB_PLATFORM_OBJECT(CSSStyleSheet, StyleSheet);
|
||||
JS_DECLARE_ALLOCATOR(CSSStyleSheet);
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
namespace Web::HTML {
|
||||
|
||||
class BrowsingContext final : public JS::Cell
|
||||
, public Weakable<BrowsingContext> {
|
||||
class BrowsingContext final : public JS::Cell {
|
||||
JS_CELL(BrowsingContext, JS::Cell);
|
||||
JS_DECLARE_ALLOCATOR(BrowsingContext);
|
||||
|
||||
|
|
|
@ -45,9 +45,7 @@ struct TargetSnapshotParams {
|
|||
};
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#navigable
|
||||
class Navigable
|
||||
: public JS::Cell
|
||||
, public Weakable<Navigable> {
|
||||
class Navigable : public JS::Cell {
|
||||
JS_CELL(Navigable, JS::Cell);
|
||||
JS_DECLARE_ALLOCATOR(Navigable);
|
||||
|
||||
|
|
|
@ -14,9 +14,7 @@ namespace Web::HTML {
|
|||
|
||||
// NOTE: Temporary class to handle console messages from inside Workers
|
||||
|
||||
class WorkerDebugConsoleClient final
|
||||
: public JS::ConsoleClient
|
||||
, public Weakable<WorkerDebugConsoleClient> {
|
||||
class WorkerDebugConsoleClient final : public JS::ConsoleClient {
|
||||
JS_CELL(WorkerDebugConsoleClient, JS::ConsoleClient);
|
||||
JS_DECLARE_ALLOCATOR(WorkerDebugConsoleClient);
|
||||
|
||||
|
|
|
@ -37,8 +37,7 @@ enum class LayoutMode {
|
|||
|
||||
class Node
|
||||
: public JS::Cell
|
||||
, public TreeNode<Node>
|
||||
, public Weakable<Node> {
|
||||
, public TreeNode<Node> {
|
||||
JS_CELL(Node, JS::Cell);
|
||||
|
||||
public:
|
||||
|
|
|
@ -55,7 +55,7 @@ HTML::Navigable& Page::focused_navigable()
|
|||
|
||||
void Page::set_focused_navigable(Badge<EventHandler>, HTML::Navigable& navigable)
|
||||
{
|
||||
m_focused_navigable = navigable.make_weak_ptr();
|
||||
m_focused_navigable = navigable;
|
||||
}
|
||||
|
||||
void Page::load(URL::URL const& url)
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
namespace WebContent {
|
||||
|
||||
class WebContentConsoleClient final : public JS::ConsoleClient
|
||||
, public Weakable<WebContentConsoleClient> {
|
||||
class WebContentConsoleClient final : public JS::ConsoleClient {
|
||||
JS_CELL(WebContentConsoleClient, JS::ConsoleClient);
|
||||
JS_DECLARE_ALLOCATOR(WebContentConsoleClient);
|
||||
|
||||
|
|
Loading…
Reference in a new issue