mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
bfd354492e
With this change, we now have ~1200 CellAllocators across both LibJS and LibWeb in a normal WebContent instance. This gives us a minimum heap size of 4.7 MiB in the scenario where we only have one cell allocated per type. Of course, in practice there will be many more of each type, so the effective overhead is quite a bit smaller than that in practice. I left a few types unconverted to this mechanism because I got tired of doing this. :^)
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Forward.h>
|
|
#include <LibJS/Heap/HeapFunction.h>
|
|
#include <LibJS/SafeFunction.h>
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::DOM {
|
|
|
|
class DocumentObserver final : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(DocumentObserver, Bindings::PlatformObject);
|
|
JS_DECLARE_ALLOCATOR(DocumentObserver);
|
|
|
|
public:
|
|
[[nodiscard]] JS::GCPtr<JS::HeapFunction<void()>> document_became_inactive() const { return m_document_became_inactive; }
|
|
void set_document_became_inactive(Function<void()>);
|
|
|
|
[[nodiscard]] JS::GCPtr<JS::HeapFunction<void()>> document_completely_loaded() const { return m_document_completely_loaded; }
|
|
void set_document_completely_loaded(Function<void()>);
|
|
|
|
private:
|
|
explicit DocumentObserver(JS::Realm&, DOM::Document&);
|
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
virtual void finalize() override;
|
|
|
|
JS::NonnullGCPtr<DOM::Document> m_document;
|
|
JS::GCPtr<JS::HeapFunction<void()>> m_document_became_inactive;
|
|
JS::GCPtr<JS::HeapFunction<void()>> m_document_completely_loaded;
|
|
};
|
|
|
|
}
|