LibGC+Everywhere: Factor out a LibGC from LibJS

Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
This commit is contained in:
Shannon Booth 2024-11-15 04:01:23 +13:00 committed by Andreas Kling
parent ce23efc5f6
commit f87041bf3a
Notes: github-actions[bot] 2024-11-15 13:50:17 +00:00
1722 changed files with 9939 additions and 9906 deletions

View file

@ -4,16 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGC/Heap.h>
#include <LibGfx/Bitmap.h>
#include <LibJS/Heap/Heap.h>
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/HTML/AnimatedBitmapDecodedImageData.h>
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(AnimatedBitmapDecodedImageData);
GC_DEFINE_ALLOCATOR(AnimatedBitmapDecodedImageData);
ErrorOr<JS::NonnullGCPtr<AnimatedBitmapDecodedImageData>> AnimatedBitmapDecodedImageData::create(JS::Realm& realm, Vector<Frame>&& frames, size_t loop_count, bool animated)
ErrorOr<GC::Ref<AnimatedBitmapDecodedImageData>> AnimatedBitmapDecodedImageData::create(JS::Realm& realm, Vector<Frame>&& frames, size_t loop_count, bool animated)
{
return realm.create<AnimatedBitmapDecodedImageData>(move(frames), loop_count, animated);
}

View file

@ -12,8 +12,8 @@
namespace Web::HTML {
class AnimatedBitmapDecodedImageData final : public DecodedImageData {
JS_CELL(AnimatedBitmapDecodedImageData, DecodedImageData);
JS_DECLARE_ALLOCATOR(AnimatedBitmapDecodedImageData);
GC_CELL(AnimatedBitmapDecodedImageData, DecodedImageData);
GC_DECLARE_ALLOCATOR(AnimatedBitmapDecodedImageData);
public:
struct Frame {
@ -21,7 +21,7 @@ public:
int duration { 0 };
};
static ErrorOr<JS::NonnullGCPtr<AnimatedBitmapDecodedImageData>> create(JS::Realm&, Vector<Frame>&&, size_t loop_count, bool animated);
static ErrorOr<GC::Ref<AnimatedBitmapDecodedImageData>> create(JS::Realm&, Vector<Frame>&&, size_t loop_count, bool animated);
virtual ~AnimatedBitmapDecodedImageData() override;
virtual RefPtr<Gfx::ImmutableBitmap> bitmap(size_t frame_index, Gfx::IntSize = {}) const override;

View file

@ -11,7 +11,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(AnimationFrameCallbackDriver);
GC_DEFINE_ALLOCATOR(AnimationFrameCallbackDriver);
void AnimationFrameCallbackDriver::visit_edges(Cell::Visitor& visitor)
{

View file

@ -9,18 +9,18 @@
#pragma once
#include <AK/HashMap.h>
#include <LibGC/Function.h>
#include <LibGC/Ptr.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibJS/Heap/HeapFunction.h>
#include <LibWeb/WebIDL/Types.h>
namespace Web::HTML {
class AnimationFrameCallbackDriver final : public JS::Cell {
JS_CELL(AnimationFrameCallbackDriver, JS::Cell);
JS_DECLARE_ALLOCATOR(AnimationFrameCallbackDriver);
GC_CELL(AnimationFrameCallbackDriver, JS::Cell);
GC_DECLARE_ALLOCATOR(AnimationFrameCallbackDriver);
using Callback = JS::NonnullGCPtr<JS::HeapFunction<void(double)>>;
using Callback = GC::Ref<GC::Function<void(double)>>;
public:
[[nodiscard]] WebIDL::UnsignedLong add(Callback handler);

View file

@ -21,11 +21,11 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(AudioTrack);
GC_DEFINE_ALLOCATOR(AudioTrack);
static IDAllocator s_audio_track_id_allocator;
AudioTrack::AudioTrack(JS::Realm& realm, JS::NonnullGCPtr<HTMLMediaElement> media_element, NonnullRefPtr<Audio::Loader> loader)
AudioTrack::AudioTrack(JS::Realm& realm, GC::Ref<HTMLMediaElement> media_element, NonnullRefPtr<Audio::Loader> loader)
: PlatformObject(realm)
, m_media_element(media_element)
, m_audio_plugin(Platform::AudioCodecPlugin::create(move(loader)).release_value_but_fixme_should_propagate_errors())

View file

@ -15,12 +15,12 @@ namespace Web::HTML {
class AudioTrack final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(AudioTrack, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(AudioTrack);
GC_DECLARE_ALLOCATOR(AudioTrack);
public:
virtual ~AudioTrack() override;
void set_audio_track_list(Badge<AudioTrackList>, JS::GCPtr<AudioTrackList> audio_track_list) { m_audio_track_list = audio_track_list; }
void set_audio_track_list(Badge<AudioTrackList>, GC::Ptr<AudioTrackList> audio_track_list) { m_audio_track_list = audio_track_list; }
void play(Badge<HTMLAudioElement>);
void pause(Badge<HTMLAudioElement>);
@ -39,7 +39,7 @@ public:
void set_enabled(bool enabled);
private:
AudioTrack(JS::Realm&, JS::NonnullGCPtr<HTMLMediaElement>, NonnullRefPtr<Audio::Loader>);
AudioTrack(JS::Realm&, GC::Ref<HTMLMediaElement>, NonnullRefPtr<Audio::Loader>);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
@ -59,8 +59,8 @@ private:
// https://html.spec.whatwg.org/multipage/media.html#dom-audiotrack-enabled
bool m_enabled { false };
JS::NonnullGCPtr<HTMLMediaElement> m_media_element;
JS::GCPtr<AudioTrackList> m_audio_track_list;
GC::Ref<HTMLMediaElement> m_media_element;
GC::Ptr<AudioTrackList> m_audio_track_list;
NonnullOwnPtr<Platform::AudioCodecPlugin> m_audio_plugin;
};

View file

@ -13,7 +13,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(AudioTrackList);
GC_DEFINE_ALLOCATOR(AudioTrackList);
AudioTrackList::AudioTrackList(JS::Realm& realm)
: DOM::EventTarget(realm, MayInterfereWithIndexedPropertyAccess::Yes)
@ -44,7 +44,7 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> AudioTrackList::internal
return Base::internal_get_own_property(property_name);
}
void AudioTrackList::add_track(Badge<HTMLMediaElement>, JS::NonnullGCPtr<AudioTrack> audio_track)
void AudioTrackList::add_track(Badge<HTMLMediaElement>, GC::Ref<AudioTrack> audio_track)
{
m_audio_tracks.append(audio_track);
audio_track->set_audio_track_list({}, this);
@ -56,7 +56,7 @@ void AudioTrackList::remove_all_tracks(Badge<HTMLMediaElement>)
}
// https://html.spec.whatwg.org/multipage/media.html#dom-audiotracklist-gettrackbyid
JS::GCPtr<AudioTrack> AudioTrackList::get_track_by_id(StringView id) const
GC::Ptr<AudioTrack> AudioTrackList::get_track_by_id(StringView id) const
{
// The AudioTrackList getTrackById(id) and VideoTrackList getTrackById(id) methods must return the first AudioTrack
// or VideoTrack object (respectively) in the AudioTrackList or VideoTrackList object (respectively) whose identifier

View file

@ -8,7 +8,7 @@
#include <AK/Badge.h>
#include <AK/String.h>
#include <LibJS/Heap/MarkedVector.h>
#include <LibGC/MarkedVector.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/HTML/AudioTrack.h>
@ -16,16 +16,16 @@ namespace Web::HTML {
class AudioTrackList final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(AudioTrackList, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(AudioTrackList);
GC_DECLARE_ALLOCATOR(AudioTrackList);
public:
void add_track(Badge<HTMLMediaElement>, JS::NonnullGCPtr<AudioTrack>);
void add_track(Badge<HTMLMediaElement>, GC::Ref<AudioTrack>);
void remove_all_tracks(Badge<HTMLMediaElement>);
// https://html.spec.whatwg.org/multipage/media.html#dom-audiotracklist-length
size_t length() const { return m_audio_tracks.size(); }
JS::GCPtr<AudioTrack> get_track_by_id(StringView id) const;
GC::Ptr<AudioTrack> get_track_by_id(StringView id) const;
bool has_enabled_track() const;
template<typename Callback>
@ -54,7 +54,7 @@ private:
virtual void initialize(JS::Realm&) override;
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const& property_name) const override;
Vector<JS::NonnullGCPtr<AudioTrack>> m_audio_tracks;
Vector<GC::Ref<AudioTrack>> m_audio_tracks;
};
}

View file

@ -10,9 +10,9 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(BeforeUnloadEvent);
GC_DEFINE_ALLOCATOR(BeforeUnloadEvent);
JS::NonnullGCPtr<BeforeUnloadEvent> BeforeUnloadEvent::create(JS::Realm& realm, FlyString const& event_name, DOM::EventInit const& event_init)
GC::Ref<BeforeUnloadEvent> BeforeUnloadEvent::create(JS::Realm& realm, FlyString const& event_name, DOM::EventInit const& event_init)
{
return realm.create<BeforeUnloadEvent>(realm, event_name, event_init);
}

View file

@ -13,10 +13,10 @@ namespace Web::HTML {
class BeforeUnloadEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(BeforeUnloadEvent, DOM::Event);
JS_DECLARE_ALLOCATOR(BeforeUnloadEvent);
GC_DECLARE_ALLOCATOR(BeforeUnloadEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<BeforeUnloadEvent> create(JS::Realm&, FlyString const& event_name, DOM::EventInit const& = {});
[[nodiscard]] static GC::Ref<BeforeUnloadEvent> create(JS::Realm&, FlyString const& event_name, DOM::EventInit const& = {});
BeforeUnloadEvent(JS::Realm&, FlyString const& event_name, DOM::EventInit const&);

View file

@ -12,9 +12,9 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(BroadcastChannel);
GC_DEFINE_ALLOCATOR(BroadcastChannel);
JS::NonnullGCPtr<BroadcastChannel> BroadcastChannel::construct_impl(JS::Realm& realm, FlyString const& name)
GC::Ref<BroadcastChannel> BroadcastChannel::construct_impl(JS::Realm& realm, FlyString const& name)
{
return realm.create<BroadcastChannel>(realm, name);
}

View file

@ -12,10 +12,10 @@ namespace Web::HTML {
class BroadcastChannel final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(BroadcastChannel, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(BroadcastChannel);
GC_DECLARE_ALLOCATOR(BroadcastChannel);
public:
[[nodiscard]] static JS::NonnullGCPtr<BroadcastChannel> construct_impl(JS::Realm&, FlyString const& name);
[[nodiscard]] static GC::Ref<BroadcastChannel> construct_impl(JS::Realm&, FlyString const& name);
FlyString name();

View file

@ -34,7 +34,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(BrowsingContext);
GC_DEFINE_ALLOCATOR(BrowsingContext);
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#matches-about:blank
bool url_matches_about_blank(URL::URL const& url)
@ -90,7 +90,7 @@ URL::Origin determine_the_origin(Optional<URL::URL> const& url, SandboxingFlagSe
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-auxiliary-browsing-context
WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext::create_a_new_auxiliary_browsing_context_and_document(JS::NonnullGCPtr<Page> page, JS::NonnullGCPtr<HTML::BrowsingContext> opener)
WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext::create_a_new_auxiliary_browsing_context_and_document(GC::Ref<Page> page, GC::Ref<HTML::BrowsingContext> opener)
{
// 1. Let openerTopLevelBrowsingContext be opener's top-level traversable's active browsing context.
auto opener_top_level_browsing_context = opener->top_level_traversable()->active_browsing_context();
@ -123,7 +123,7 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
return BrowsingContext::BrowsingContextAndDocument { browsing_context, document };
}
static void populate_with_html_head_body(JS::NonnullGCPtr<DOM::Document> document)
static void populate_with_html_head_body(GC::Ref<DOM::Document> document)
{
auto html_node = MUST(DOM::create_element(document, HTML::TagNames::html, Namespace::HTML));
auto head_element = MUST(DOM::create_element(document, HTML::TagNames::head, Namespace::HTML));
@ -134,12 +134,12 @@ static void populate_with_html_head_body(JS::NonnullGCPtr<DOM::Document> documen
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-browsing-context
WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext::create_a_new_browsing_context_and_document(JS::NonnullGCPtr<Page> page, JS::GCPtr<DOM::Document> creator, JS::GCPtr<DOM::Element> embedder, JS::NonnullGCPtr<BrowsingContextGroup> group)
WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext::create_a_new_browsing_context_and_document(GC::Ref<Page> page, GC::Ptr<DOM::Document> creator, GC::Ptr<DOM::Element> embedder, GC::Ref<BrowsingContextGroup> group)
{
auto& vm = group->vm();
// 1. Let browsingContext be a new browsing context.
JS::NonnullGCPtr<BrowsingContext> browsing_context = *vm.heap().allocate<BrowsingContext>(page);
GC::Ref<BrowsingContext> browsing_context = *vm.heap().allocate<BrowsingContext>(page);
// 2. Let unsafeContextCreationTime be the unsafe shared current time.
[[maybe_unused]] auto unsafe_context_creation_time = HighResolutionTime::unsafe_shared_current_time();
@ -173,7 +173,7 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
// FIXME: 9. Let agent be the result of obtaining a similar-origin window agent given origin, group, and false.
JS::GCPtr<Window> window;
GC::Ptr<Window> window;
// 10. Let realm execution context be the result of creating a new JavaScript realm given agent and the following customizations:
auto realm_execution_context = Bindings::create_a_new_javascript_realm(
@ -289,7 +289,7 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
return BrowsingContext::BrowsingContextAndDocument { browsing_context, document };
}
BrowsingContext::BrowsingContext(JS::NonnullGCPtr<Page> page)
BrowsingContext::BrowsingContext(GC::Ref<Page> page)
: m_page(page)
{
}
@ -311,7 +311,7 @@ void BrowsingContext::visit_edges(Cell::Visitor& visitor)
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#bc-traversable
JS::NonnullGCPtr<HTML::TraversableNavigable> BrowsingContext::top_level_traversable() const
GC::Ref<HTML::TraversableNavigable> BrowsingContext::top_level_traversable() const
{
// A browsing context's top-level traversable is its active document's node navigable's top-level traversable.
auto traversable = active_document()->navigable()->top_level_traversable();
@ -329,7 +329,7 @@ bool BrowsingContext::is_top_level() const
return active_document() != nullptr && active_document()->navigable() != nullptr && active_document()->navigable()->is_traversable();
}
JS::GCPtr<BrowsingContext> BrowsingContext::top_level_browsing_context() const
GC::Ptr<BrowsingContext> BrowsingContext::top_level_browsing_context() const
{
auto const* start = this;
@ -388,7 +388,7 @@ HTML::WindowProxy const* BrowsingContext::window_proxy() const
return m_window_proxy.ptr();
}
void BrowsingContext::set_window_proxy(JS::GCPtr<WindowProxy> window_proxy)
void BrowsingContext::set_window_proxy(GC::Ptr<WindowProxy> window_proxy)
{
m_window_proxy = move(window_proxy);
}
@ -415,7 +415,7 @@ void BrowsingContext::remove()
VERIFY(group());
// 2. Let group be browsingContext's group.
JS::NonnullGCPtr<BrowsingContextGroup> group = *this->group();
GC::Ref<BrowsingContextGroup> group = *this->group();
// 3. Set browsingContext's group to null.
set_group(nullptr);
@ -434,11 +434,11 @@ BrowsingContext const* BrowsingContext::the_one_permitted_sandboxed_navigator()
return nullptr;
}
JS::GCPtr<BrowsingContext> BrowsingContext::first_child() const
GC::Ptr<BrowsingContext> BrowsingContext::first_child() const
{
return m_first_child;
}
JS::GCPtr<BrowsingContext> BrowsingContext::next_sibling() const
GC::Ptr<BrowsingContext> BrowsingContext::next_sibling() const
{
return m_next_sibling;
}
@ -504,7 +504,7 @@ bool BrowsingContext::is_familiar_with(BrowsingContext const& other) const
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#snapshotting-target-snapshot-params
SandboxingFlagSet determine_the_creation_sandboxing_flags(BrowsingContext const&, JS::GCPtr<DOM::Element>)
SandboxingFlagSet determine_the_creation_sandboxing_flags(BrowsingContext const&, GC::Ptr<DOM::Element>)
{
// FIXME: Populate this once we have the proper flag sets on BrowsingContext
return {};

View file

@ -28,24 +28,24 @@
namespace Web::HTML {
class BrowsingContext final : public JS::Cell {
JS_CELL(BrowsingContext, JS::Cell);
JS_DECLARE_ALLOCATOR(BrowsingContext);
GC_CELL(BrowsingContext, JS::Cell);
GC_DECLARE_ALLOCATOR(BrowsingContext);
public:
struct BrowsingContextAndDocument {
JS::NonnullGCPtr<BrowsingContext> browsing_context;
JS::NonnullGCPtr<DOM::Document> document;
GC::Ref<BrowsingContext> browsing_context;
GC::Ref<DOM::Document> document;
};
static WebIDL::ExceptionOr<BrowsingContextAndDocument> create_a_new_browsing_context_and_document(JS::NonnullGCPtr<Page> page, JS::GCPtr<DOM::Document> creator, JS::GCPtr<DOM::Element> embedder, JS::NonnullGCPtr<BrowsingContextGroup> group);
static WebIDL::ExceptionOr<BrowsingContextAndDocument> create_a_new_auxiliary_browsing_context_and_document(JS::NonnullGCPtr<Page> page, JS::NonnullGCPtr<HTML::BrowsingContext> opener);
static WebIDL::ExceptionOr<BrowsingContextAndDocument> create_a_new_browsing_context_and_document(GC::Ref<Page> page, GC::Ptr<DOM::Document> creator, GC::Ptr<DOM::Element> embedder, GC::Ref<BrowsingContextGroup> group);
static WebIDL::ExceptionOr<BrowsingContextAndDocument> create_a_new_auxiliary_browsing_context_and_document(GC::Ref<Page> page, GC::Ref<HTML::BrowsingContext> opener);
virtual ~BrowsingContext() override;
JS::NonnullGCPtr<HTML::TraversableNavigable> top_level_traversable() const;
GC::Ref<HTML::TraversableNavigable> top_level_traversable() const;
JS::GCPtr<BrowsingContext> first_child() const;
JS::GCPtr<BrowsingContext> next_sibling() const;
GC::Ptr<BrowsingContext> first_child() const;
GC::Ptr<BrowsingContext> next_sibling() const;
bool is_ancestor_of(BrowsingContext const&) const;
bool is_familiar_with(BrowsingContext const&) const;
@ -103,7 +103,7 @@ public:
HTML::WindowProxy* window_proxy();
HTML::WindowProxy const* window_proxy() const;
void set_window_proxy(JS::GCPtr<WindowProxy>);
void set_window_proxy(GC::Ptr<WindowProxy>);
HTML::Window* active_window();
HTML::Window const* active_window() const;
@ -113,7 +113,7 @@ public:
u64 virtual_browsing_context_group_id() const { return m_virtual_browsing_context_group_id; }
JS::GCPtr<BrowsingContext> top_level_browsing_context() const;
GC::Ptr<BrowsingContext> top_level_browsing_context() const;
BrowsingContextGroup* group();
BrowsingContextGroup const* group() const;
@ -127,23 +127,23 @@ public:
bool has_navigable_been_destroyed() const;
JS::GCPtr<BrowsingContext> opener_browsing_context() const { return m_opener_browsing_context; }
void set_opener_browsing_context(JS::GCPtr<BrowsingContext> browsing_context) { m_opener_browsing_context = browsing_context; }
GC::Ptr<BrowsingContext> opener_browsing_context() const { return m_opener_browsing_context; }
void set_opener_browsing_context(GC::Ptr<BrowsingContext> browsing_context) { m_opener_browsing_context = browsing_context; }
void set_is_popup(TokenizedFeature::Popup is_popup) { m_is_popup = is_popup; }
private:
explicit BrowsingContext(JS::NonnullGCPtr<Page>);
explicit BrowsingContext(GC::Ref<Page>);
virtual void visit_edges(Cell::Visitor&) override;
JS::NonnullGCPtr<Page> m_page;
GC::Ref<Page> m_page;
// https://html.spec.whatwg.org/multipage/document-sequences.html#browsing-context
JS::GCPtr<HTML::WindowProxy> m_window_proxy;
GC::Ptr<HTML::WindowProxy> m_window_proxy;
// https://html.spec.whatwg.org/multipage/browsers.html#opener-browsing-context
JS::GCPtr<BrowsingContext> m_opener_browsing_context;
GC::Ptr<BrowsingContext> m_opener_browsing_context;
// https://html.spec.whatwg.org/multipage/document-sequences.html#opener-origin-at-creation
Optional<URL::Origin> m_opener_origin_at_creation;
@ -161,17 +161,17 @@ private:
u64 m_virtual_browsing_context_group_id = { 0 };
// https://html.spec.whatwg.org/multipage/browsers.html#tlbc-group
JS::GCPtr<BrowsingContextGroup> m_group;
GC::Ptr<BrowsingContextGroup> m_group;
JS::GCPtr<BrowsingContext> m_first_child;
JS::GCPtr<BrowsingContext> m_last_child;
JS::GCPtr<BrowsingContext> m_next_sibling;
JS::GCPtr<BrowsingContext> m_previous_sibling;
GC::Ptr<BrowsingContext> m_first_child;
GC::Ptr<BrowsingContext> m_last_child;
GC::Ptr<BrowsingContext> m_next_sibling;
GC::Ptr<BrowsingContext> m_previous_sibling;
};
URL::Origin determine_the_origin(Optional<URL::URL> const&, SandboxingFlagSet, Optional<URL::Origin> source_origin);
SandboxingFlagSet determine_the_creation_sandboxing_flags(BrowsingContext const&, JS::GCPtr<DOM::Element> embedder);
SandboxingFlagSet determine_the_creation_sandboxing_flags(BrowsingContext const&, GC::Ptr<DOM::Element> embedder);
// FIXME: Find a better home for these
bool url_matches_about_blank(URL::URL const& url);

View file

@ -11,16 +11,16 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(BrowsingContextGroup);
GC_DEFINE_ALLOCATOR(BrowsingContextGroup);
// https://html.spec.whatwg.org/multipage/browsers.html#browsing-context-group-set
static HashTable<JS::NonnullGCPtr<BrowsingContextGroup>>& user_agent_browsing_context_group_set()
static HashTable<GC::Ref<BrowsingContextGroup>>& user_agent_browsing_context_group_set()
{
static HashTable<JS::NonnullGCPtr<BrowsingContextGroup>> set;
static HashTable<GC::Ref<BrowsingContextGroup>> set;
return set;
}
BrowsingContextGroup::BrowsingContextGroup(JS::NonnullGCPtr<Web::Page> page)
BrowsingContextGroup::BrowsingContextGroup(GC::Ref<Web::Page> page)
: m_page(page)
{
user_agent_browsing_context_group_set().set(*this);
@ -39,7 +39,7 @@ void BrowsingContextGroup::visit_edges(Cell::Visitor& visitor)
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-browsing-context-group-and-document
auto BrowsingContextGroup::create_a_new_browsing_context_group_and_document(JS::NonnullGCPtr<Page> page) -> WebIDL::ExceptionOr<BrowsingContextGroupAndDocument>
auto BrowsingContextGroup::create_a_new_browsing_context_group_and_document(GC::Ref<Page> page) -> WebIDL::ExceptionOr<BrowsingContextGroupAndDocument>
{
// 1. Let group be a new browsing context group.
// 2. Append group to the user agent's browsing context group set.

View file

@ -15,15 +15,15 @@
namespace Web::HTML {
class BrowsingContextGroup final : public JS::Cell {
JS_CELL(BrowsingContextGroup, JS::Cell);
JS_DECLARE_ALLOCATOR(BrowsingContextGroup);
GC_CELL(BrowsingContextGroup, JS::Cell);
GC_DECLARE_ALLOCATOR(BrowsingContextGroup);
public:
struct BrowsingContextGroupAndDocument {
JS::NonnullGCPtr<HTML::BrowsingContextGroup> browsing_context;
JS::NonnullGCPtr<DOM::Document> document;
GC::Ref<HTML::BrowsingContextGroup> browsing_context;
GC::Ref<DOM::Document> document;
};
static WebIDL::ExceptionOr<BrowsingContextGroupAndDocument> create_a_new_browsing_context_group_and_document(JS::NonnullGCPtr<Page>);
static WebIDL::ExceptionOr<BrowsingContextGroupAndDocument> create_a_new_browsing_context_group_and_document(GC::Ref<Page>);
~BrowsingContextGroup();
@ -36,14 +36,14 @@ public:
void append(BrowsingContext&);
private:
explicit BrowsingContextGroup(JS::NonnullGCPtr<Web::Page>);
explicit BrowsingContextGroup(GC::Ref<Web::Page>);
virtual void visit_edges(Cell::Visitor&) override;
// https://html.spec.whatwg.org/multipage/browsers.html#browsing-context-group-set
OrderedHashTable<JS::NonnullGCPtr<BrowsingContext>> m_browsing_context_set;
OrderedHashTable<GC::Ref<BrowsingContext>> m_browsing_context_set;
JS::NonnullGCPtr<Page> m_page;
GC::Ref<Page> m_page;
};
}

View file

@ -13,7 +13,7 @@ namespace Web::HTML {
static void default_source_size(CanvasImageSource const& image, float& source_width, float& source_height)
{
image.visit(
[&source_width, &source_height](JS::Handle<HTMLImageElement> const& source) {
[&source_width, &source_height](GC::Root<HTMLImageElement> const& source) {
if (source->immutable_bitmap()) {
source_width = source->immutable_bitmap()->width();
source_height = source->immutable_bitmap()->height();
@ -23,7 +23,7 @@ static void default_source_size(CanvasImageSource const& image, float& source_wi
source_height = source->height();
}
},
[&source_width, &source_height](JS::Handle<SVG::SVGImageElement> const& source) {
[&source_width, &source_height](GC::Root<SVG::SVGImageElement> const& source) {
if (source->current_image_bitmap()) {
source_width = source->current_image_bitmap()->width();
source_height = source->current_image_bitmap()->height();
@ -33,7 +33,7 @@ static void default_source_size(CanvasImageSource const& image, float& source_wi
source_height = source->height()->anim_val()->value();
}
},
[&source_width, &source_height](JS::Handle<HTML::HTMLVideoElement> const& source) {
[&source_width, &source_height](GC::Root<HTML::HTMLVideoElement> const& source) {
if (auto const bitmap = source->bitmap(); bitmap) {
source_width = bitmap->width();
source_height = bitmap->height();
@ -42,7 +42,7 @@ static void default_source_size(CanvasImageSource const& image, float& source_wi
source_height = source->video_height();
}
},
[&source_width, &source_height](JS::Handle<HTMLCanvasElement> const& source) {
[&source_width, &source_height](GC::Root<HTMLCanvasElement> const& source) {
if (source->surface()) {
source_width = source->surface()->size().width();
source_height = source->surface()->size().height();

View file

@ -16,7 +16,7 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesource
// NOTE: This is the Variant created by the IDL wrapper generator, and needs to be updated accordingly.
using CanvasImageSource = Variant<JS::Handle<HTMLImageElement>, JS::Handle<SVG::SVGImageElement>, JS::Handle<HTMLCanvasElement>, JS::Handle<ImageBitmap>, JS::Handle<HTMLVideoElement>>;
using CanvasImageSource = Variant<GC::Root<HTMLImageElement>, GC::Root<SVG::SVGImageElement>, GC::Root<HTMLCanvasElement>, GC::Root<ImageBitmap>, GC::Root<HTMLVideoElement>>;
// https://html.spec.whatwg.org/multipage/canvas.html#canvasdrawimage
class CanvasDrawImage {

View file

@ -22,7 +22,7 @@ template<typename IncludingClass>
class CanvasFillStrokeStyles {
public:
~CanvasFillStrokeStyles() = default;
using FillOrStrokeStyleVariant = Variant<String, JS::Handle<CanvasGradient>, JS::Handle<CanvasPattern>>;
using FillOrStrokeStyleVariant = Variant<String, GC::Root<CanvasGradient>, GC::Root<CanvasPattern>>;
void set_fill_style(FillOrStrokeStyleVariant style)
{
@ -107,25 +107,25 @@ public:
return my_drawing_state().stroke_style.to_js_fill_or_stroke_style();
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> create_radial_gradient(double x0, double y0, double r0, double x1, double y1, double r1)
WebIDL::ExceptionOr<GC::Ref<CanvasGradient>> create_radial_gradient(double x0, double y0, double r0, double x1, double y1, double r1)
{
auto& realm = static_cast<IncludingClass&>(*this).realm();
return CanvasGradient::create_radial(realm, x0, y0, r0, x1, y1, r1);
}
JS::NonnullGCPtr<CanvasGradient> create_linear_gradient(double x0, double y0, double x1, double y1)
GC::Ref<CanvasGradient> create_linear_gradient(double x0, double y0, double x1, double y1)
{
auto& realm = static_cast<IncludingClass&>(*this).realm();
return CanvasGradient::create_linear(realm, x0, y0, x1, y1).release_value_but_fixme_should_propagate_errors();
}
JS::NonnullGCPtr<CanvasGradient> create_conic_gradient(double start_angle, double x, double y)
GC::Ref<CanvasGradient> create_conic_gradient(double start_angle, double x, double y)
{
auto& realm = static_cast<IncludingClass&>(*this).realm();
return CanvasGradient::create_conic(realm, start_angle, x, y).release_value_but_fixme_should_propagate_errors();
}
WebIDL::ExceptionOr<JS::GCPtr<CanvasPattern>> create_pattern(CanvasImageSource const& image, StringView repetition)
WebIDL::ExceptionOr<GC::Ptr<CanvasPattern>> create_pattern(CanvasImageSource const& image, StringView repetition)
{
auto& realm = static_cast<IncludingClass&>(*this).realm();
return CanvasPattern::create(realm, image, repetition);

View file

@ -15,9 +15,9 @@ class CanvasImageData {
public:
virtual ~CanvasImageData() = default;
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<ImageData>> create_image_data(int width, int height, Optional<ImageDataSettings> const& settings = {}) const = 0;
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<ImageData>> create_image_data(ImageData const&) const = 0;
virtual WebIDL::ExceptionOr<JS::GCPtr<ImageData>> get_image_data(int x, int y, int width, int height, Optional<ImageDataSettings> const& settings = {}) const = 0;
virtual WebIDL::ExceptionOr<GC::Ref<ImageData>> create_image_data(int width, int height, Optional<ImageDataSettings> const& settings = {}) const = 0;
virtual WebIDL::ExceptionOr<GC::Ref<ImageData>> create_image_data(ImageData const&) const = 0;
virtual WebIDL::ExceptionOr<GC::Ptr<ImageData>> get_image_data(int x, int y, int width, int height, Optional<ImageDataSettings> const& settings = {}) const = 0;
virtual void put_image_data(ImageData const&, float x, float y) = 0;
protected:

View file

@ -50,7 +50,7 @@ private:
void ensure_subpath(float x, float y);
JS::NonnullGCPtr<Bindings::PlatformObject> m_self;
GC::Ref<Bindings::PlatformObject> m_self;
Optional<CanvasState const&> m_canvas_state;
Gfx::Path m_path;
};

View file

@ -34,7 +34,7 @@ public:
void reset();
bool is_context_lost();
using FillOrStrokeVariant = Variant<Gfx::Color, JS::Handle<CanvasGradient>, JS::Handle<CanvasPattern>>;
using FillOrStrokeVariant = Variant<Gfx::Color, GC::Root<CanvasGradient>, GC::Root<CanvasPattern>>;
struct FillOrStrokeStyle {
FillOrStrokeStyle(Gfx::Color color)
@ -42,12 +42,12 @@ public:
{
}
FillOrStrokeStyle(JS::Handle<CanvasGradient> gradient)
FillOrStrokeStyle(GC::Root<CanvasGradient> gradient)
: m_fill_or_stroke_style(gradient)
{
}
FillOrStrokeStyle(JS::Handle<CanvasPattern> pattern)
FillOrStrokeStyle(GC::Root<CanvasPattern> pattern)
: m_fill_or_stroke_style(pattern)
{
}
@ -57,7 +57,7 @@ public:
Optional<Gfx::Color> as_color() const;
Gfx::Color to_color_but_fixme_should_accept_any_paint_style() const;
using JsFillOrStrokeStyle = Variant<String, JS::Handle<CanvasGradient>, JS::Handle<CanvasPattern>>;
using JsFillOrStrokeStyle = Variant<String, GC::Root<CanvasGradient>, GC::Root<CanvasPattern>>;
JsFillOrStrokeStyle to_js_fill_or_stroke_style() const
{

View file

@ -19,7 +19,7 @@ public:
virtual void fill_text(StringView, float x, float y, Optional<double> max_width) = 0;
virtual void stroke_text(StringView, float x, float y, Optional<double> max_width) = 0;
virtual JS::NonnullGCPtr<TextMetrics> measure_text(StringView text) = 0;
virtual GC::Ref<TextMetrics> measure_text(StringView text) = 0;
protected:
CanvasText() = default;

View file

@ -75,7 +75,7 @@ public:
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-gettransform
WebIDL::ExceptionOr<JS::NonnullGCPtr<Geometry::DOMMatrix>> get_transform()
WebIDL::ExceptionOr<GC::Ref<Geometry::DOMMatrix>> get_transform()
{
auto& realm = static_cast<IncludingClass&>(*this).realm();
auto transform = my_drawing_state().transform;

View file

@ -13,10 +13,10 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(CanvasGradient);
GC_DEFINE_ALLOCATOR(CanvasGradient);
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createradialgradient
WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> CanvasGradient::create_radial(JS::Realm& realm, double x0, double y0, double r0, double x1, double y1, double r1)
WebIDL::ExceptionOr<GC::Ref<CanvasGradient>> CanvasGradient::create_radial(JS::Realm& realm, double x0, double y0, double r0, double x1, double y1, double r1)
{
// If either of r0 or r1 are negative, then an "IndexSizeError" DOMException must be thrown.
if (r0 < 0)
@ -29,14 +29,14 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> CanvasGradient::create_rad
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createlineargradient
WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> CanvasGradient::create_linear(JS::Realm& realm, double x0, double y0, double x1, double y1)
WebIDL::ExceptionOr<GC::Ref<CanvasGradient>> CanvasGradient::create_linear(JS::Realm& realm, double x0, double y0, double x1, double y1)
{
auto linear_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasLinearGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, Gfx::FloatPoint { x1, y1 }));
return realm.create<CanvasGradient>(realm, *linear_gradient);
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createconicgradient
WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> CanvasGradient::create_conic(JS::Realm& realm, double start_angle, double x, double y)
WebIDL::ExceptionOr<GC::Ref<CanvasGradient>> CanvasGradient::create_conic(JS::Realm& realm, double start_angle, double x, double y)
{
auto conic_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasConicGradientPaintStyle::create(Gfx::FloatPoint { x, y }, start_angle));
return realm.create<CanvasGradient>(realm, *conic_gradient);

View file

@ -14,12 +14,12 @@ namespace Web::HTML {
class CanvasGradient final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(CanvasGradient, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(CanvasGradient);
GC_DECLARE_ALLOCATOR(CanvasGradient);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> create_radial(JS::Realm&, double x0, double y0, double r0, double x1, double y1, double r1);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> create_linear(JS::Realm&, double x0, double y0, double x1, double y1);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> create_conic(JS::Realm&, double start_angle, double x, double y);
static WebIDL::ExceptionOr<GC::Ref<CanvasGradient>> create_radial(JS::Realm&, double x0, double y0, double r0, double x1, double y1, double r1);
static WebIDL::ExceptionOr<GC::Ref<CanvasGradient>> create_linear(JS::Realm&, double x0, double y0, double x1, double y1);
static WebIDL::ExceptionOr<GC::Ref<CanvasGradient>> create_conic(JS::Realm&, double start_angle, double x, double y);
WebIDL::ExceptionOr<void> add_color_stop(double offset, StringView color);

View file

@ -15,7 +15,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(CanvasPattern);
GC_DEFINE_ALLOCATOR(CanvasPattern);
void CanvasPatternPaintStyle::paint(Gfx::IntRect physical_bounding_box, PaintFunction paint) const
{
@ -93,7 +93,7 @@ CanvasPattern::CanvasPattern(JS::Realm& realm, CanvasPatternPaintStyle& pattern)
CanvasPattern::~CanvasPattern() = default;
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createpattern
WebIDL::ExceptionOr<JS::GCPtr<CanvasPattern>> CanvasPattern::create(JS::Realm& realm, CanvasImageSource const& image, StringView repetition)
WebIDL::ExceptionOr<GC::Ptr<CanvasPattern>> CanvasPattern::create(JS::Realm& realm, CanvasImageSource const& image, StringView repetition)
{
auto parse_repetition = [&](auto repetition) -> Optional<CanvasPatternPaintStyle::Repetition> {
if (repetition == "repeat"sv)
@ -112,7 +112,7 @@ WebIDL::ExceptionOr<JS::GCPtr<CanvasPattern>> CanvasPattern::create(JS::Realm& r
// 2. If usability is bad, then return null.
if (usability == CanvasImageSourceUsability::Bad)
return JS::GCPtr<CanvasPattern> {};
return GC::Ptr<CanvasPattern> {};
// 3. Assert: usability is good.
VERIFY(usability == CanvasImageSourceUsability::Good);
@ -129,11 +129,11 @@ WebIDL::ExceptionOr<JS::GCPtr<CanvasPattern>> CanvasPattern::create(JS::Realm& r
// Note: Bitmap won't be null here, as if it were it would have "bad" usability.
auto bitmap = image.visit(
[](JS::Handle<HTMLImageElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return source->immutable_bitmap(); },
[](JS::Handle<SVG::SVGImageElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return source->current_image_bitmap(); },
[](JS::Handle<HTMLCanvasElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return Gfx::ImmutableBitmap::create_snapshot_from_painting_surface(*source->surface()); },
[](JS::Handle<HTMLVideoElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return Gfx::ImmutableBitmap::create(*source->bitmap()); },
[](JS::Handle<ImageBitmap> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return Gfx::ImmutableBitmap::create(*source->bitmap()); });
[](GC::Root<HTMLImageElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return source->immutable_bitmap(); },
[](GC::Root<SVG::SVGImageElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return source->current_image_bitmap(); },
[](GC::Root<HTMLCanvasElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return Gfx::ImmutableBitmap::create_snapshot_from_painting_surface(*source->surface()); },
[](GC::Root<HTMLVideoElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return Gfx::ImmutableBitmap::create(*source->bitmap()); },
[](GC::Root<ImageBitmap> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return Gfx::ImmutableBitmap::create(*source->bitmap()); });
// 6. Let pattern be a new CanvasPattern object with the image image and the repetition behavior given by repetition.
auto pattern = TRY_OR_THROW_OOM(realm.vm(), CanvasPatternPaintStyle::create(*bitmap, *repetition_value));

View file

@ -41,10 +41,10 @@ private:
class CanvasPattern final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(CanvasPattern, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(CanvasPattern);
GC_DECLARE_ALLOCATOR(CanvasPattern);
public:
static WebIDL::ExceptionOr<JS::GCPtr<CanvasPattern>> create(JS::Realm&, CanvasImageSource const& image, StringView repetition);
static WebIDL::ExceptionOr<GC::Ptr<CanvasPattern>> create(JS::Realm&, CanvasImageSource const& image, StringView repetition);
~CanvasPattern();

View file

@ -31,9 +31,9 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(CanvasRenderingContext2D);
GC_DEFINE_ALLOCATOR(CanvasRenderingContext2D);
JS::NonnullGCPtr<CanvasRenderingContext2D> CanvasRenderingContext2D::create(JS::Realm& realm, HTMLCanvasElement& element)
GC::Ref<CanvasRenderingContext2D> CanvasRenderingContext2D::create(JS::Realm& realm, HTMLCanvasElement& element)
{
return realm.create<CanvasRenderingContext2D>(realm, element);
}
@ -69,7 +69,7 @@ HTMLCanvasElement const& CanvasRenderingContext2D::canvas_element() const
return *m_element;
}
JS::NonnullGCPtr<HTMLCanvasElement> CanvasRenderingContext2D::canvas_for_binding() const
GC::Ref<HTMLCanvasElement> CanvasRenderingContext2D::canvas_for_binding() const
{
return *m_element;
}
@ -124,20 +124,20 @@ WebIDL::ExceptionOr<void> CanvasRenderingContext2D::draw_image_internal(CanvasIm
return {};
auto bitmap = image.visit(
[](JS::Handle<HTMLImageElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
[](GC::Root<HTMLImageElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
return source->immutable_bitmap();
},
[](JS::Handle<SVG::SVGImageElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
[](GC::Root<SVG::SVGImageElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
return source->current_image_bitmap();
},
[](JS::Handle<HTMLCanvasElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
[](GC::Root<HTMLCanvasElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
auto surface = source->surface();
if (!surface)
return {};
return Gfx::ImmutableBitmap::create_snapshot_from_painting_surface(*surface);
},
[](JS::Handle<HTMLVideoElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return Gfx::ImmutableBitmap::create(*source->bitmap()); },
[](JS::Handle<ImageBitmap> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
[](GC::Root<HTMLVideoElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> { return Gfx::ImmutableBitmap::create(*source->bitmap()); },
[](GC::Root<ImageBitmap> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
return Gfx::ImmutableBitmap::create(*source->bitmap());
});
if (!bitmap)
@ -346,7 +346,7 @@ void CanvasRenderingContext2D::fill(Path2D& path, StringView fill_rule)
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createimagedata
WebIDL::ExceptionOr<JS::NonnullGCPtr<ImageData>> CanvasRenderingContext2D::create_image_data(int width, int height, Optional<ImageDataSettings> const& settings) const
WebIDL::ExceptionOr<GC::Ref<ImageData>> CanvasRenderingContext2D::create_image_data(int width, int height, Optional<ImageDataSettings> const& settings) const
{
// 1. If one or both of sw and sh are zero, then throw an "IndexSizeError" DOMException.
if (width == 0 || height == 0)
@ -367,7 +367,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ImageData>> CanvasRenderingContext2D::creat
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createimagedata-imagedata
WebIDL::ExceptionOr<JS::NonnullGCPtr<ImageData>> CanvasRenderingContext2D::create_image_data(ImageData const& image_data) const
WebIDL::ExceptionOr<GC::Ref<ImageData>> CanvasRenderingContext2D::create_image_data(ImageData const& image_data) const
{
// 1. Let newImageData be a new ImageData object.
// 2. Initialize newImageData given the value of imagedata's width attribute, the value of imagedata's height attribute, and defaultColorSpace set to the value of imagedata's colorSpace attribute.
@ -379,7 +379,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ImageData>> CanvasRenderingContext2D::creat
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getimagedata
WebIDL::ExceptionOr<JS::GCPtr<ImageData>> CanvasRenderingContext2D::get_image_data(int x, int y, int width, int height, Optional<ImageDataSettings> const& settings) const
WebIDL::ExceptionOr<GC::Ptr<ImageData>> CanvasRenderingContext2D::get_image_data(int x, int y, int width, int height, Optional<ImageDataSettings> const& settings) const
{
// 1. If either the sw or sh arguments are zero, then throw an "IndexSizeError" DOMException.
if (width == 0 || height == 0)
@ -464,7 +464,7 @@ void CanvasRenderingContext2D::reset_to_default_state()
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-measuretext
JS::NonnullGCPtr<TextMetrics> CanvasRenderingContext2D::measure_text(StringView text)
GC::Ref<TextMetrics> CanvasRenderingContext2D::measure_text(StringView text)
{
// The measureText(text) method steps are to run the text preparation
// algorithm, passing it text and the object implementing the CanvasText
@ -625,7 +625,7 @@ WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasI
// 1. Switch on image:
auto usability = TRY(image.visit(
// HTMLOrSVGImageElement
[](JS::Handle<HTMLImageElement> const& image_element) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
[](GC::Root<HTMLImageElement> const& image_element) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
// FIXME: If image's current request's state is broken, then throw an "InvalidStateError" DOMException.
// If image is not fully decodable, then return bad.
@ -638,7 +638,7 @@ WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasI
return Optional<CanvasImageSourceUsability> {};
},
// FIXME: Don't duplicate this for HTMLImageElement and SVGImageElement.
[](JS::Handle<SVG::SVGImageElement> const& image_element) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
[](GC::Root<SVG::SVGImageElement> const& image_element) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
// FIXME: If image's current request's state is broken, then throw an "InvalidStateError" DOMException.
// If image is not fully decodable, then return bad.
@ -651,7 +651,7 @@ WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasI
return Optional<CanvasImageSourceUsability> {};
},
[](JS::Handle<HTML::HTMLVideoElement> const& video_element) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
[](GC::Root<HTML::HTMLVideoElement> const& video_element) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
// If image's readyState attribute is either HAVE_NOTHING or HAVE_METADATA, then return bad.
if (video_element->ready_state() == HTML::HTMLMediaElement::ReadyState::HaveNothing || video_element->ready_state() == HTML::HTMLMediaElement::ReadyState::HaveMetadata) {
return { CanvasImageSourceUsability::Bad };
@ -661,7 +661,7 @@ WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasI
// HTMLCanvasElement
// FIXME: OffscreenCanvas
[](JS::Handle<HTMLCanvasElement> const& canvas_element) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
[](GC::Root<HTMLCanvasElement> const& canvas_element) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
// If image has either a horizontal dimension or a vertical dimension equal to zero, then throw an "InvalidStateError" DOMException.
if (canvas_element->width() == 0 || canvas_element->height() == 0)
return WebIDL::InvalidStateError::create(canvas_element->realm(), "Canvas width or height is zero"_string);
@ -670,7 +670,7 @@ WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasI
// ImageBitmap
// FIXME: VideoFrame
[](JS::Handle<ImageBitmap> const& image_bitmap) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
[](GC::Root<ImageBitmap> const& image_bitmap) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
if (image_bitmap->is_detached())
return WebIDL::InvalidStateError::create(image_bitmap->realm(), "Image bitmap is detached"_string);
return Optional<CanvasImageSourceUsability> {};
@ -688,20 +688,20 @@ bool image_is_not_origin_clean(CanvasImageSource const& image)
// An object image is not origin-clean if, switching on image's type:
return image.visit(
// HTMLOrSVGImageElement
[](JS::Handle<HTMLImageElement> const&) {
[](GC::Root<HTMLImageElement> const&) {
// FIXME: image's current request's image data is CORS-cross-origin.
return false;
},
[](JS::Handle<SVG::SVGImageElement> const&) {
[](GC::Root<SVG::SVGImageElement> const&) {
// FIXME: image's current request's image data is CORS-cross-origin.
return false;
},
[](JS::Handle<HTML::HTMLVideoElement> const&) {
[](GC::Root<HTML::HTMLVideoElement> const&) {
// FIXME: image's media data is CORS-cross-origin.
return false;
},
// HTMLCanvasElement
[](OneOf<JS::Handle<HTMLCanvasElement>, JS::Handle<ImageBitmap>> auto const&) {
[](OneOf<GC::Root<HTMLCanvasElement>, GC::Root<ImageBitmap>> auto const&) {
// FIXME: image's bitmap's origin-clean flag is false.
return false;
});

View file

@ -54,10 +54,10 @@ class CanvasRenderingContext2D
, public CanvasTextDrawingStyles<CanvasRenderingContext2D> {
WEB_PLATFORM_OBJECT(CanvasRenderingContext2D, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(CanvasRenderingContext2D);
GC_DECLARE_ALLOCATOR(CanvasRenderingContext2D);
public:
[[nodiscard]] static JS::NonnullGCPtr<CanvasRenderingContext2D> create(JS::Realm&, HTMLCanvasElement&);
[[nodiscard]] static GC::Ref<CanvasRenderingContext2D> create(JS::Realm&, HTMLCanvasElement&);
virtual ~CanvasRenderingContext2D() override;
virtual void fill_rect(float x, float y, float width, float height) override;
@ -76,16 +76,16 @@ public:
virtual void fill(StringView fill_rule) override;
virtual void fill(Path2D& path, StringView fill_rule) override;
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<ImageData>> create_image_data(int width, int height, Optional<ImageDataSettings> const& settings = {}) const override;
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<ImageData>> create_image_data(ImageData const& image_data) const override;
virtual WebIDL::ExceptionOr<JS::GCPtr<ImageData>> get_image_data(int x, int y, int width, int height, Optional<ImageDataSettings> const& settings = {}) const override;
virtual WebIDL::ExceptionOr<GC::Ref<ImageData>> create_image_data(int width, int height, Optional<ImageDataSettings> const& settings = {}) const override;
virtual WebIDL::ExceptionOr<GC::Ref<ImageData>> create_image_data(ImageData const& image_data) const override;
virtual WebIDL::ExceptionOr<GC::Ptr<ImageData>> get_image_data(int x, int y, int width, int height, Optional<ImageDataSettings> const& settings = {}) const override;
virtual void put_image_data(ImageData const&, float x, float y) override;
virtual void reset_to_default_state() override;
JS::NonnullGCPtr<HTMLCanvasElement> canvas_for_binding() const;
GC::Ref<HTMLCanvasElement> canvas_for_binding() const;
virtual JS::NonnullGCPtr<TextMetrics> measure_text(StringView text) override;
virtual GC::Ref<TextMetrics> measure_text(StringView text) override;
virtual void clip(StringView fill_rule) override;
virtual void clip(Path2D& path, StringView fill_rule) override;
@ -143,7 +143,7 @@ private:
void paint_shadow_for_fill_internal(Gfx::Path const&, Gfx::WindingRule);
void paint_shadow_for_stroke_internal(Gfx::Path const&);
JS::NonnullGCPtr<HTMLCanvasElement> m_element;
GC::Ref<HTMLCanvasElement> m_element;
OwnPtr<Gfx::Painter> m_painter;
// https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-origin-clean

View file

@ -10,14 +10,14 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(CloseEvent);
GC_DEFINE_ALLOCATOR(CloseEvent);
JS::NonnullGCPtr<CloseEvent> CloseEvent::create(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init)
GC::Ref<CloseEvent> CloseEvent::create(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init)
{
return realm.create<CloseEvent>(realm, event_name, event_init);
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<CloseEvent>> CloseEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init)
WebIDL::ExceptionOr<GC::Ref<CloseEvent>> CloseEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init)
{
return create(realm, event_name, event_init);
}

View file

@ -20,11 +20,11 @@ struct CloseEventInit : public DOM::EventInit {
class CloseEvent : public DOM::Event {
WEB_PLATFORM_OBJECT(CloseEvent, DOM::Event);
JS_DECLARE_ALLOCATOR(CloseEvent);
GC_DECLARE_ALLOCATOR(CloseEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<CloseEvent> create(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CloseEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init);
[[nodiscard]] static GC::Ref<CloseEvent> create(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init = {});
static WebIDL::ExceptionOr<GC::Ref<CloseEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init);
virtual ~CloseEvent() override;

View file

@ -18,10 +18,10 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(CloseWatcher);
GC_DEFINE_ALLOCATOR(CloseWatcher);
// https://html.spec.whatwg.org/multipage/interaction.html#establish-a-close-watcher
JS::NonnullGCPtr<CloseWatcher> CloseWatcher::establish(HTML::Window& window)
GC::Ref<CloseWatcher> CloseWatcher::establish(HTML::Window& window)
{
// 1. Assert: window's associated Document is fully active.
VERIFY(window.associated_document().is_fully_active());
@ -40,7 +40,7 @@ JS::NonnullGCPtr<CloseWatcher> CloseWatcher::establish(HTML::Window& window)
}
// https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher
WebIDL::ExceptionOr<JS::NonnullGCPtr<CloseWatcher>> CloseWatcher::construct_impl(JS::Realm& realm, CloseWatcherOptions const& options)
WebIDL::ExceptionOr<GC::Ref<CloseWatcher>> CloseWatcher::construct_impl(JS::Realm& realm, CloseWatcherOptions const& options)
{
auto& window = verify_cast<HTML::Window>(realm.global_object());

View file

@ -13,17 +13,17 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/interaction.html#closewatcheroptions
struct CloseWatcherOptions {
JS::GCPtr<DOM::AbortSignal> signal;
GC::Ptr<DOM::AbortSignal> signal;
};
// https://html.spec.whatwg.org/multipage/interaction.html#the-closewatcher-interface
class CloseWatcher final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(CloseWatcher, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(CloseWatcher);
GC_DECLARE_ALLOCATOR(CloseWatcher);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CloseWatcher>> construct_impl(JS::Realm&, CloseWatcherOptions const& = {});
[[nodiscard]] static JS::NonnullGCPtr<CloseWatcher> establish(HTML::Window&);
static WebIDL::ExceptionOr<GC::Ref<CloseWatcher>> construct_impl(JS::Realm&, CloseWatcherOptions const& = {});
[[nodiscard]] static GC::Ref<CloseWatcher> establish(HTML::Window&);
bool request_close();
void close();

View file

@ -14,9 +14,9 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(CloseWatcherManager);
GC_DEFINE_ALLOCATOR(CloseWatcherManager);
JS::NonnullGCPtr<CloseWatcherManager> CloseWatcherManager::create(JS::Realm& realm)
GC::Ref<CloseWatcherManager> CloseWatcherManager::create(JS::Realm& realm)
{
return realm.create<CloseWatcherManager>(realm);
}
@ -26,12 +26,12 @@ CloseWatcherManager::CloseWatcherManager(JS::Realm& realm)
{
}
void CloseWatcherManager::add(JS::NonnullGCPtr<CloseWatcher> close_watcher)
void CloseWatcherManager::add(GC::Ref<CloseWatcher> close_watcher)
{
// If manager's groups's size is less than manager's allowed number of groups
if (m_groups.size() < m_allowed_number_of_groups) {
// then append « closeWatcher » to manager's groups.
JS::MarkedVector<JS::NonnullGCPtr<CloseWatcher>> new_group(realm().heap());
GC::MarkedVector<GC::Ref<CloseWatcher>> new_group(realm().heap());
new_group.append(close_watcher);
m_groups.append(move(new_group));
} else {
@ -49,7 +49,7 @@ void CloseWatcherManager::remove(CloseWatcher const& close_watcher)
{
// 2. For each group of manager's groups: remove closeWatcher from group
for (auto& group : m_groups) {
group.remove_first_matching([&close_watcher](JS::NonnullGCPtr<CloseWatcher>& entry) {
group.remove_first_matching([&close_watcher](GC::Ref<CloseWatcher>& entry) {
return entry.ptr() == &close_watcher;
});
}
@ -68,7 +68,7 @@ bool CloseWatcherManager::process_close_watchers()
auto& group = m_groups.last();
// Ambiguous spec wording. We copy the groups to avoid modifying the original while iterating.
// See https://github.com/whatwg/html/issues/10240
JS::MarkedVector<JS::NonnullGCPtr<CloseWatcher>> group_copy(realm().heap());
GC::MarkedVector<GC::Ref<CloseWatcher>> group_copy(realm().heap());
group_copy.ensure_capacity(group.size());
for (auto& close_watcher : group) {
group_copy.append(close_watcher);

View file

@ -14,12 +14,12 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/interaction.html#close-watcher-manager
class CloseWatcherManager final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(CloseWatcherManager, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(CloseWatcherManager);
GC_DECLARE_ALLOCATOR(CloseWatcherManager);
public:
[[nodiscard]] static JS::NonnullGCPtr<CloseWatcherManager> create(JS::Realm&);
[[nodiscard]] static GC::Ref<CloseWatcherManager> create(JS::Realm&);
void add(JS::NonnullGCPtr<CloseWatcher>);
void add(GC::Ref<CloseWatcher>);
void remove(CloseWatcher const&);
bool process_close_watchers();
@ -32,7 +32,7 @@ private:
virtual void visit_edges(Cell::Visitor&) override;
Vector<Vector<JS::NonnullGCPtr<CloseWatcher>>> m_groups;
Vector<Vector<GC::Ref<CloseWatcher>>> m_groups;
uint32_t m_allowed_number_of_groups { 1 };
bool m_next_user_interaction_allows_a_new_group { true };
};

View file

@ -136,7 +136,7 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<HT
// 2. If IsCallable(value) is true, then set value to an anonymous built-in function, created in the current Realm Record, that performs the same steps as the IDL operation P on object O.
if (value->is_function()) {
value = JS::NativeFunction::create(
realm, [function = JS::make_handle(*value)](auto& vm) {
realm, [function = GC::make_root(*value)](auto& vm) {
return JS::call(vm, function.value(), JS::js_undefined(), vm.running_execution_context().arguments.span());
},
0, "");
@ -148,24 +148,24 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<HT
// 5. Otherwise:
else {
// 1. Let crossOriginGet be undefined.
Optional<JS::GCPtr<JS::FunctionObject>> cross_origin_get;
Optional<GC::Ptr<JS::FunctionObject>> cross_origin_get;
// 2. If e.[[NeedsGet]] is true, then set crossOriginGet to an anonymous built-in function, created in the current Realm Record, that performs the same steps as the getter of the IDL attribute P on object O.
if (*entry.needs_get) {
cross_origin_get = JS::NativeFunction::create(
realm, [object_ptr, getter = JS::make_handle(*original_descriptor->get)](auto& vm) {
realm, [object_ptr, getter = GC::make_root(*original_descriptor->get)](auto& vm) {
return JS::call(vm, getter.cell(), object_ptr, vm.running_execution_context().arguments.span());
},
0, "");
}
// 3. Let crossOriginSet be undefined.
Optional<JS::GCPtr<JS::FunctionObject>> cross_origin_set;
Optional<GC::Ptr<JS::FunctionObject>> cross_origin_set;
// If e.[[NeedsSet]] is true, then set crossOriginSet to an anonymous built-in function, created in the current Realm Record, that performs the same steps as the setter of the IDL attribute P on object O.
if (*entry.needs_set) {
cross_origin_set = JS::NativeFunction::create(
realm, [object_ptr, setter = JS::make_handle(*original_descriptor->set)](auto& vm) {
realm, [object_ptr, setter = GC::make_root(*original_descriptor->set)](auto& vm) {
return JS::call(vm, setter.cell(), object_ptr, vm.running_execution_context().arguments.span());
},
0, "");
@ -237,13 +237,13 @@ JS::ThrowCompletionOr<bool> cross_origin_set(JS::VM& vm, JS::Object& object, JS:
}
// 7.2.3.7 CrossOriginOwnPropertyKeys ( O ), https://html.spec.whatwg.org/multipage/browsers.html#crossoriginownpropertykeys-(-o-)
JS::MarkedVector<JS::Value> cross_origin_own_property_keys(Variant<HTML::Location const*, HTML::Window const*> const& object)
GC::MarkedVector<JS::Value> cross_origin_own_property_keys(Variant<HTML::Location const*, HTML::Window const*> const& object)
{
auto& event_loop = HTML::main_thread_event_loop();
auto& vm = event_loop.vm();
// 1. Let keys be a new empty List.
auto keys = JS::MarkedVector<JS::Value> { vm.heap() };
auto keys = GC::MarkedVector<JS::Value> { vm.heap() };
// 2. For each e of CrossOriginProperties(O), append e.[[Property]] to keys.
for (auto& entry : cross_origin_properties(object))

View file

@ -21,6 +21,6 @@ bool is_platform_object_same_origin(JS::Object const&);
Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<HTML::Location*, HTML::Window*> const&, JS::PropertyKey const&);
JS::ThrowCompletionOr<JS::Value> cross_origin_get(JS::VM&, JS::Object const&, JS::PropertyKey const&, JS::Value receiver);
JS::ThrowCompletionOr<bool> cross_origin_set(JS::VM&, JS::Object&, JS::PropertyKey const&, JS::Value, JS::Value receiver);
JS::MarkedVector<JS::Value> cross_origin_own_property_keys(Variant<HTML::Location const*, HTML::Window const*> const&);
GC::MarkedVector<JS::Value> cross_origin_own_property_keys(Variant<HTML::Location const*, HTML::Window const*> const&);
}

View file

@ -17,13 +17,13 @@ struct AlreadyConstructedCustomElementMarker {
// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-definition
class CustomElementDefinition : public JS::Cell {
JS_CELL(CustomElementDefinition, JS::Cell);
JS_DECLARE_ALLOCATOR(CustomElementDefinition);
GC_CELL(CustomElementDefinition, JS::Cell);
GC_DECLARE_ALLOCATOR(CustomElementDefinition);
using LifecycleCallbacksStorage = OrderedHashMap<FlyString, JS::GCPtr<WebIDL::CallbackType>>;
using ConstructionStackStorage = Vector<Variant<JS::Handle<DOM::Element>, AlreadyConstructedCustomElementMarker>>;
using LifecycleCallbacksStorage = OrderedHashMap<FlyString, GC::Ptr<WebIDL::CallbackType>>;
using ConstructionStackStorage = Vector<Variant<GC::Root<DOM::Element>, AlreadyConstructedCustomElementMarker>>;
static JS::NonnullGCPtr<CustomElementDefinition> create(JS::Realm& realm, String const& name, String const& local_name, WebIDL::CallbackType& constructor, Vector<String>&& observed_attributes, LifecycleCallbacksStorage&& lifecycle_callbacks, bool form_associated, bool disable_internals, bool disable_shadow)
static GC::Ref<CustomElementDefinition> create(JS::Realm& realm, String const& name, String const& local_name, WebIDL::CallbackType& constructor, Vector<String>&& observed_attributes, LifecycleCallbacksStorage&& lifecycle_callbacks, bool form_associated, bool disable_internals, bool disable_shadow)
{
return realm.create<CustomElementDefinition>(name, local_name, constructor, move(observed_attributes), move(lifecycle_callbacks), form_associated, disable_internals, disable_shadow);
}
@ -74,7 +74,7 @@ private:
// https://html.spec.whatwg.org/multipage/custom-elements.html#concept-custom-element-definition-constructor
// A Web IDL CustomElementConstructor callback function type value wrapping the custom element constructor
JS::NonnullGCPtr<WebIDL::CallbackType> m_constructor;
GC::Ref<WebIDL::CallbackType> m_constructor;
// https://html.spec.whatwg.org/multipage/custom-elements.html#concept-custom-element-definition-observed-attributes
// A list of observed attributes

View file

@ -20,8 +20,8 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(CustomElementRegistry);
JS_DEFINE_ALLOCATOR(CustomElementDefinition);
GC_DEFINE_ALLOCATOR(CustomElementRegistry);
GC_DEFINE_ALLOCATOR(CustomElementDefinition);
CustomElementRegistry::CustomElementRegistry(JS::Realm& realm)
: Bindings::PlatformObject(realm)
@ -44,7 +44,7 @@ void CustomElementRegistry::visit_edges(Visitor& visitor)
}
// https://webidl.spec.whatwg.org/#es-callback-function
static JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> convert_value_to_callback_function(JS::VM& vm, JS::Value value)
static JS::ThrowCompletionOr<GC::Ref<WebIDL::CallbackType>> convert_value_to_callback_function(JS::VM& vm, JS::Value value)
{
// FIXME: De-duplicate this from the IDL generator.
// 1. If the result of calling IsCallable(V) is false and the conversion to an IDL value is not being performed due to V being assigned to an attribute whose type is a nullable callback function that is annotated with [LegacyTreatNonObjectAsNull], then throw a TypeError.
@ -288,7 +288,7 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
// 18. Let upgrade candidates be all elements that are shadow-including descendants of document, whose namespace is the HTML namespace and whose local name is localName, in shadow-including tree order.
// Additionally, if extends is non-null, only include elements whose is value is equal to name.
Vector<JS::Handle<DOM::Element>> upgrade_candidates;
Vector<GC::Root<DOM::Element>> upgrade_candidates;
document.for_each_shadow_including_descendant([&](DOM::Node& inclusive_descendant) {
if (!is<DOM::Element>(inclusive_descendant))
@ -297,7 +297,7 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
auto& inclusive_descendant_element = static_cast<DOM::Element&>(inclusive_descendant);
if (inclusive_descendant_element.namespace_uri() == Namespace::HTML && inclusive_descendant_element.local_name() == local_name && (!extends.has_value() || inclusive_descendant_element.is_value() == name))
upgrade_candidates.append(JS::make_handle(inclusive_descendant_element));
upgrade_candidates.append(GC::make_root(inclusive_descendant_element));
return TraversalDecision::Continue;
});
@ -323,7 +323,7 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
}
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-get
Variant<JS::Handle<WebIDL::CallbackType>, JS::Value> CustomElementRegistry::get(String const& name) const
Variant<GC::Root<WebIDL::CallbackType>, JS::Value> CustomElementRegistry::get(String const& name) const
{
// 1. If this CustomElementRegistry contains an entry with name name, then return that entry's constructor.
auto existing_definition_iterator = m_custom_element_definitions.find_if([&name](auto const& definition) {
@ -331,14 +331,14 @@ Variant<JS::Handle<WebIDL::CallbackType>, JS::Value> CustomElementRegistry::get(
});
if (!existing_definition_iterator.is_end())
return JS::make_handle((*existing_definition_iterator)->constructor());
return GC::make_root((*existing_definition_iterator)->constructor());
// 2. Otherwise, return undefined.
return JS::js_undefined();
}
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-getname
Optional<String> CustomElementRegistry::get_name(JS::Handle<WebIDL::CallbackType> const& constructor) const
Optional<String> CustomElementRegistry::get_name(GC::Root<WebIDL::CallbackType> const& constructor) const
{
// 1. If this CustomElementRegistry contains an entry with constructor constructor, then return that entry's name.
auto existing_definition_iterator = m_custom_element_definitions.find_if([&constructor](auto const& definition) {
@ -353,7 +353,7 @@ Optional<String> CustomElementRegistry::get_name(JS::Handle<WebIDL::CallbackType
}
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-whendefined
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> CustomElementRegistry::when_defined(String const& name)
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> CustomElementRegistry::when_defined(String const& name)
{
auto& realm = this->realm();
@ -362,7 +362,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> CustomElementRegistry::wh
return WebIDL::create_rejected_promise(realm, WebIDL::SyntaxError::create(realm, MUST(String::formatted("'{}' is not a valid custom element name"sv, name))));
// 2. If this CustomElementRegistry contains an entry with name name, then return a new promise resolved with that entry's constructor.
auto existing_definition_iterator = m_custom_element_definitions.find_if([&name](JS::Handle<CustomElementDefinition> const& definition) {
auto existing_definition_iterator = m_custom_element_definitions.find_if([&name](GC::Root<CustomElementDefinition> const& definition) {
return definition->name() == name;
});
@ -374,7 +374,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> CustomElementRegistry::wh
// 4. If map does not contain an entry with key name, create an entry in map with key name and whose value is a new promise.
// 5. Let promise be the value of the entry in map with key name.
JS::GCPtr<WebIDL::Promise> promise;
GC::Ptr<WebIDL::Promise> promise;
auto existing_promise_iterator = m_when_defined_promise_map.find(name);
if (existing_promise_iterator != m_when_defined_promise_map.end()) {
@ -386,21 +386,21 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> CustomElementRegistry::wh
// 5. Return promise.
VERIFY(promise);
return JS::NonnullGCPtr { *promise };
return GC::Ref { *promise };
}
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade
void CustomElementRegistry::upgrade(JS::NonnullGCPtr<DOM::Node> root) const
void CustomElementRegistry::upgrade(GC::Ref<DOM::Node> root) const
{
// 1. Let candidates be a list of all of root's shadow-including inclusive descendant elements, in shadow-including tree order.
Vector<JS::Handle<DOM::Element>> candidates;
Vector<GC::Root<DOM::Element>> candidates;
root->for_each_shadow_including_inclusive_descendant([&](DOM::Node& inclusive_descendant) {
if (!is<DOM::Element>(inclusive_descendant))
return TraversalDecision::Continue;
auto& inclusive_descendant_element = static_cast<DOM::Element&>(inclusive_descendant);
candidates.append(JS::make_handle(inclusive_descendant_element));
candidates.append(GC::make_root(inclusive_descendant_element));
return TraversalDecision::Continue;
});
@ -410,18 +410,18 @@ void CustomElementRegistry::upgrade(JS::NonnullGCPtr<DOM::Node> root) const
candidate->try_to_upgrade();
}
JS::GCPtr<CustomElementDefinition> CustomElementRegistry::get_definition_with_name_and_local_name(String const& name, String const& local_name) const
GC::Ptr<CustomElementDefinition> CustomElementRegistry::get_definition_with_name_and_local_name(String const& name, String const& local_name) const
{
auto definition_iterator = m_custom_element_definitions.find_if([&](JS::Handle<CustomElementDefinition> const& definition) {
auto definition_iterator = m_custom_element_definitions.find_if([&](GC::Root<CustomElementDefinition> const& definition) {
return definition->name() == name && definition->local_name() == local_name;
});
return definition_iterator.is_end() ? nullptr : definition_iterator->ptr();
}
JS::GCPtr<CustomElementDefinition> CustomElementRegistry::get_definition_from_new_target(JS::FunctionObject const& new_target) const
GC::Ptr<CustomElementDefinition> CustomElementRegistry::get_definition_from_new_target(JS::FunctionObject const& new_target) const
{
auto definition_iterator = m_custom_element_definitions.find_if([&](JS::Handle<CustomElementDefinition> const& definition) {
auto definition_iterator = m_custom_element_definitions.find_if([&](GC::Root<CustomElementDefinition> const& definition) {
return definition->constructor().callback.ptr() == &new_target;
});

View file

@ -19,19 +19,19 @@ struct ElementDefinitionOptions {
// https://html.spec.whatwg.org/multipage/custom-elements.html#customelementregistry
class CustomElementRegistry : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(CustomElementRegistry, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(CustomElementRegistry);
GC_DECLARE_ALLOCATOR(CustomElementRegistry);
public:
virtual ~CustomElementRegistry() override;
JS::ThrowCompletionOr<void> define(String const& name, WebIDL::CallbackType* constructor, ElementDefinitionOptions options);
Variant<JS::Handle<WebIDL::CallbackType>, JS::Value> get(String const& name) const;
Optional<String> get_name(JS::Handle<WebIDL::CallbackType> const& constructor) const;
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> when_defined(String const& name);
void upgrade(JS::NonnullGCPtr<DOM::Node> root) const;
Variant<GC::Root<WebIDL::CallbackType>, JS::Value> get(String const& name) const;
Optional<String> get_name(GC::Root<WebIDL::CallbackType> const& constructor) const;
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> when_defined(String const& name);
void upgrade(GC::Ref<DOM::Node> root) const;
JS::GCPtr<CustomElementDefinition> get_definition_with_name_and_local_name(String const& name, String const& local_name) const;
JS::GCPtr<CustomElementDefinition> get_definition_from_new_target(JS::FunctionObject const& new_target) const;
GC::Ptr<CustomElementDefinition> get_definition_with_name_and_local_name(String const& name, String const& local_name) const;
GC::Ptr<CustomElementDefinition> get_definition_from_new_target(JS::FunctionObject const& new_target) const;
private:
CustomElementRegistry(JS::Realm&);
@ -40,7 +40,7 @@ private:
virtual void visit_edges(Visitor&) override;
// Every CustomElementRegistry has a set of custom element definitions, initially empty. In general, algorithms in this specification look up elements in the registry by any of name, local name, or constructor.
Vector<JS::NonnullGCPtr<CustomElementDefinition>> m_custom_element_definitions;
Vector<GC::Ref<CustomElementDefinition>> m_custom_element_definitions;
// https://html.spec.whatwg.org/multipage/custom-elements.html#element-definition-is-running
// Every CustomElementRegistry also has an element definition is running flag which is used to prevent reentrant invocations of element definition. It is initially unset.
@ -48,7 +48,7 @@ private:
// https://html.spec.whatwg.org/multipage/custom-elements.html#when-defined-promise-map
// Every CustomElementRegistry also has a when-defined promise map, mapping valid custom element names to promises. It is used to implement the whenDefined() method.
OrderedHashMap<String, JS::NonnullGCPtr<WebIDL::Promise>> m_when_defined_promise_map;
OrderedHashMap<String, GC::Ref<WebIDL::Promise>> m_when_defined_promise_map;
};
}

View file

@ -16,9 +16,9 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(DOMParser);
GC_DEFINE_ALLOCATOR(DOMParser);
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMParser>> DOMParser::construct_impl(JS::Realm& realm)
WebIDL::ExceptionOr<GC::Ref<DOMParser>> DOMParser::construct_impl(JS::Realm& realm)
{
return realm.create<DOMParser>(realm);
}
@ -37,12 +37,12 @@ void DOMParser::initialize(JS::Realm& realm)
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
JS::NonnullGCPtr<DOM::Document> DOMParser::parse_from_string(StringView string, Bindings::DOMParserSupportedType type)
GC::Ref<DOM::Document> DOMParser::parse_from_string(StringView string, Bindings::DOMParserSupportedType type)
{
// FIXME: 1. Let compliantString to the result of invoking the Get Trusted Type compliant string algorithm with TrustedHTML, this's relevant global object, string, "DOMParser parseFromString", and "script".
// 2. Let document be a new Document, whose content type is type and url is this's relevant global object's associated Document's URL.
JS::GCPtr<DOM::Document> document;
GC::Ptr<DOM::Document> document;
// 3. Switch on type:
if (type == Bindings::DOMParserSupportedType::Text_Html) {

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibJS/Heap/GCPtr.h>
#include <LibGC/Ptr.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Forward.h>
@ -17,14 +17,14 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparser
class DOMParser final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DOMParser, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMParser);
GC_DECLARE_ALLOCATOR(DOMParser);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMParser>> construct_impl(JS::Realm&);
static WebIDL::ExceptionOr<GC::Ref<DOMParser>> construct_impl(JS::Realm&);
virtual ~DOMParser() override;
JS::NonnullGCPtr<DOM::Document> parse_from_string(StringView, Bindings::DOMParserSupportedType type);
GC::Ref<DOM::Document> parse_from_string(StringView, Bindings::DOMParserSupportedType type);
private:
explicit DOMParser(JS::Realm&);

View file

@ -11,9 +11,9 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(DOMStringList);
GC_DEFINE_ALLOCATOR(DOMStringList);
JS::NonnullGCPtr<DOMStringList> DOMStringList::create(JS::Realm& realm, Vector<String> list)
GC::Ref<DOMStringList> DOMStringList::create(JS::Realm& realm, Vector<String> list)
{
return realm.create<DOMStringList>(realm, list);
}

View file

@ -13,10 +13,10 @@ namespace Web::HTML {
class DOMStringList final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DOMStringList, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMStringList);
GC_DECLARE_ALLOCATOR(DOMStringList);
public:
static JS::NonnullGCPtr<DOMStringList> create(JS::Realm&, Vector<String>);
static GC::Ref<DOMStringList> create(JS::Realm&, Vector<String>);
u32 length() const;
Optional<String> item(u32 index) const;

View file

@ -13,9 +13,9 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(DOMStringMap);
GC_DEFINE_ALLOCATOR(DOMStringMap);
JS::NonnullGCPtr<DOMStringMap> DOMStringMap::create(DOM::Element& element)
GC::Ref<DOMStringMap> DOMStringMap::create(DOM::Element& element)
{
auto& realm = element.realm();
return realm.create<DOMStringMap>(element);

View file

@ -15,10 +15,10 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/dom.html#domstringmap
class DOMStringMap final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DOMStringMap, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMStringMap);
GC_DECLARE_ALLOCATOR(DOMStringMap);
public:
[[nodiscard]] static JS::NonnullGCPtr<DOMStringMap> create(DOM::Element&);
[[nodiscard]] static GC::Ref<DOMStringMap> create(DOM::Element&);
virtual ~DOMStringMap() override;
@ -47,7 +47,7 @@ private:
Vector<NameValuePair> get_name_value_pairs() const;
// https://html.spec.whatwg.org/multipage/dom.html#concept-domstringmap-element
JS::NonnullGCPtr<DOM::Element> m_associated_element;
GC::Ref<DOM::Element> m_associated_element;
};
}

View file

@ -19,7 +19,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(DataTransfer);
GC_DEFINE_ALLOCATOR(DataTransfer);
namespace DataTransferEffect {
@ -29,13 +29,13 @@ ENUMERATE_DATA_TRANSFER_EFFECTS
}
JS::NonnullGCPtr<DataTransfer> DataTransfer::create(JS::Realm& realm, NonnullRefPtr<DragDataStore> drag_data_store)
GC::Ref<DataTransfer> DataTransfer::create(JS::Realm& realm, NonnullRefPtr<DragDataStore> drag_data_store)
{
return realm.create<DataTransfer>(realm, move(drag_data_store));
}
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer
JS::NonnullGCPtr<DataTransfer> DataTransfer::construct_impl(JS::Realm& realm)
GC::Ref<DataTransfer> DataTransfer::construct_impl(JS::Realm& realm)
{
// 1. Set the drag data store's item list to be an empty list.
auto drag_data_store = DragDataStore::create();
@ -115,7 +115,7 @@ void DataTransfer::set_effect_allowed_internal(FlyString effect_allowed)
}
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-items
JS::NonnullGCPtr<DataTransferItemList> DataTransfer::items()
GC::Ref<DataTransferItemList> DataTransfer::items()
{
// The items attribute must return a DataTransferItemList object associated with the DataTransfer object.
if (!m_items)
@ -181,7 +181,7 @@ String DataTransfer::get_data(String const& format_argument) const
}
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-files
JS::NonnullGCPtr<FileAPI::FileList> DataTransfer::files() const
GC::Ref<FileAPI::FileList> DataTransfer::files() const
{
auto& realm = this->realm();
@ -212,7 +212,7 @@ JS::NonnullGCPtr<FileAPI::FileList> DataTransfer::files() const
FileAPI::FilePropertyBag options {};
options.type = item.type_string;
auto file = MUST(FileAPI::File::create(realm, { JS::make_handle(blob) }, file_name, move(options)));
auto file = MUST(FileAPI::File::create(realm, { GC::make_root(blob) }, file_name, move(options)));
files->add_file(file);
}
@ -233,7 +233,7 @@ void DataTransfer::disassociate_with_drag_data_store()
update_data_transfer_types_list();
}
JS::NonnullGCPtr<DataTransferItem> DataTransfer::add_item(DragDataStoreItem item)
GC::Ref<DataTransferItem> DataTransfer::add_item(DragDataStoreItem item)
{
auto& realm = this->realm();
@ -260,7 +260,7 @@ bool DataTransfer::contains_item_with_type(DragDataStoreItem::Kind kind, String
return false;
}
JS::NonnullGCPtr<DataTransferItem> DataTransfer::item(size_t index) const
GC::Ref<DataTransferItem> DataTransfer::item(size_t index) const
{
VERIFY(index < m_item_list.size());
return m_item_list[index];

View file

@ -34,11 +34,11 @@ ENUMERATE_DATA_TRANSFER_EFFECTS
// https://html.spec.whatwg.org/multipage/dnd.html#the-datatransfer-interface
class DataTransfer : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DataTransfer, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DataTransfer);
GC_DECLARE_ALLOCATOR(DataTransfer);
public:
static JS::NonnullGCPtr<DataTransfer> create(JS::Realm&, NonnullRefPtr<DragDataStore>);
static JS::NonnullGCPtr<DataTransfer> construct_impl(JS::Realm&);
static GC::Ref<DataTransfer> create(JS::Realm&, NonnullRefPtr<DragDataStore>);
static GC::Ref<DataTransfer> construct_impl(JS::Realm&);
virtual ~DataTransfer() override;
FlyString const& drop_effect() const { return m_drop_effect; }
@ -50,18 +50,18 @@ public:
void set_effect_allowed(FlyString);
void set_effect_allowed_internal(FlyString);
JS::NonnullGCPtr<DataTransferItemList> items();
GC::Ref<DataTransferItemList> items();
ReadonlySpan<String> types() const;
String get_data(String const& format) const;
JS::NonnullGCPtr<FileAPI::FileList> files() const;
GC::Ref<FileAPI::FileList> files() const;
Optional<DragDataStore::Mode> mode() const;
void disassociate_with_drag_data_store();
JS::NonnullGCPtr<DataTransferItem> add_item(DragDataStoreItem item);
GC::Ref<DataTransferItem> add_item(DragDataStoreItem item);
bool contains_item_with_type(DragDataStoreItem::Kind, String const& type) const;
JS::NonnullGCPtr<DataTransferItem> item(size_t index) const;
GC::Ref<DataTransferItem> item(size_t index) const;
DragDataStoreItem const& drag_data(size_t index) const;
size_t length() const;
@ -80,8 +80,8 @@ private:
FlyString m_effect_allowed { DataTransferEffect::none };
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-items
JS::GCPtr<DataTransferItemList> m_items;
Vector<JS::NonnullGCPtr<DataTransferItem>> m_item_list;
GC::Ptr<DataTransferItemList> m_items;
Vector<GC::Ref<DataTransferItem>> m_item_list;
// https://html.spec.whatwg.org/multipage/dnd.html#concept-datatransfer-types
Vector<String> m_types;

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Heap/HeapFunction.h>
#include <LibGC/Function.h>
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/DataTransferItemPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
@ -17,14 +17,14 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(DataTransferItem);
GC_DEFINE_ALLOCATOR(DataTransferItem);
JS::NonnullGCPtr<DataTransferItem> DataTransferItem::create(JS::Realm& realm, JS::NonnullGCPtr<DataTransfer> data_transfer, size_t item_index)
GC::Ref<DataTransferItem> DataTransferItem::create(JS::Realm& realm, GC::Ref<DataTransfer> data_transfer, size_t item_index)
{
return realm.create<DataTransferItem>(realm, data_transfer, item_index);
}
DataTransferItem::DataTransferItem(JS::Realm& realm, JS::NonnullGCPtr<DataTransfer> data_transfer, size_t item_index)
DataTransferItem::DataTransferItem(JS::Realm& realm, GC::Ref<DataTransfer> data_transfer, size_t item_index)
: PlatformObject(realm)
, m_data_transfer(data_transfer)
, m_item_index(item_index)
@ -91,7 +91,7 @@ Optional<DragDataStore::Mode> DataTransferItem::mode() const
}
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransferitem-getasstring
void DataTransferItem::get_as_string(JS::GCPtr<WebIDL::CallbackType> callback) const
void DataTransferItem::get_as_string(GC::Ptr<WebIDL::CallbackType> callback) const
{
auto& realm = this->realm();
auto& vm = realm.vm();
@ -116,13 +116,13 @@ void DataTransferItem::get_as_string(JS::GCPtr<WebIDL::CallbackType> callback) c
auto data = JS::PrimitiveString::create(vm, MUST(String::from_utf8({ item.data })));
HTML::queue_a_task(HTML::Task::Source::Unspecified, nullptr, nullptr,
JS::HeapFunction<void()>::create(realm.heap(), [callback, data]() {
GC::Function<void()>::create(realm.heap(), [callback, data]() {
(void)WebIDL::invoke_callback(*callback, {}, data);
}));
}
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransferitem-getasfile
JS::GCPtr<FileAPI::File> DataTransferItem::get_as_file() const
GC::Ptr<FileAPI::File> DataTransferItem::get_as_file() const
{
auto& realm = this->realm();
@ -146,11 +146,11 @@ JS::GCPtr<FileAPI::File> DataTransferItem::get_as_file() const
FileAPI::FilePropertyBag options {};
options.type = item.type_string;
return MUST(FileAPI::File::create(realm, { JS::make_handle(blob) }, file_name, move(options)));
return MUST(FileAPI::File::create(realm, { GC::make_root(blob) }, file_name, move(options)));
}
// https://wicg.github.io/entries-api/#dom-datatransferitem-webkitgetasentry
JS::GCPtr<EntriesAPI::FileSystemEntry> DataTransferItem::webkit_get_as_entry() const
GC::Ptr<EntriesAPI::FileSystemEntry> DataTransferItem::webkit_get_as_entry() const
{
auto& realm = this->realm();

View file

@ -17,29 +17,29 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/dnd.html#the-datatransferitem-interface
class DataTransferItem : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DataTransferItem, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DataTransferItem);
GC_DECLARE_ALLOCATOR(DataTransferItem);
public:
static JS::NonnullGCPtr<DataTransferItem> create(JS::Realm&, JS::NonnullGCPtr<DataTransfer>, size_t item_index);
static GC::Ref<DataTransferItem> create(JS::Realm&, GC::Ref<DataTransfer>, size_t item_index);
virtual ~DataTransferItem() override;
String kind() const;
String type() const;
void get_as_string(JS::GCPtr<WebIDL::CallbackType>) const;
JS::GCPtr<FileAPI::File> get_as_file() const;
void get_as_string(GC::Ptr<WebIDL::CallbackType>) const;
GC::Ptr<FileAPI::File> get_as_file() const;
JS::GCPtr<EntriesAPI::FileSystemEntry> webkit_get_as_entry() const;
GC::Ptr<EntriesAPI::FileSystemEntry> webkit_get_as_entry() const;
private:
DataTransferItem(JS::Realm&, JS::NonnullGCPtr<DataTransfer>, size_t item_index);
DataTransferItem(JS::Realm&, GC::Ref<DataTransfer>, size_t item_index);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(JS::Cell::Visitor&) override;
Optional<DragDataStore::Mode> mode() const;
JS::NonnullGCPtr<DataTransfer> m_data_transfer;
GC::Ref<DataTransfer> m_data_transfer;
Optional<size_t> m_item_index;
};

View file

@ -15,14 +15,14 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(DataTransferItemList);
GC_DEFINE_ALLOCATOR(DataTransferItemList);
JS::NonnullGCPtr<DataTransferItemList> DataTransferItemList::create(JS::Realm& realm, JS::NonnullGCPtr<DataTransfer> data_transfer)
GC::Ref<DataTransferItemList> DataTransferItemList::create(JS::Realm& realm, GC::Ref<DataTransfer> data_transfer)
{
return realm.create<DataTransferItemList>(realm, data_transfer);
}
DataTransferItemList::DataTransferItemList(JS::Realm& realm, JS::NonnullGCPtr<DataTransfer> data_transfer)
DataTransferItemList::DataTransferItemList(JS::Realm& realm, GC::Ref<DataTransfer> data_transfer)
: PlatformObject(realm)
, m_data_transfer(data_transfer)
{
@ -52,7 +52,7 @@ WebIDL::UnsignedLong DataTransferItemList::length() const
}
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransferitemlist-add
WebIDL::ExceptionOr<JS::GCPtr<DataTransferItem>> DataTransferItemList::add(String const& data, String const& type)
WebIDL::ExceptionOr<GC::Ptr<DataTransferItem>> DataTransferItemList::add(String const& data, String const& type)
{
auto& realm = this->realm();
@ -87,7 +87,7 @@ WebIDL::ExceptionOr<JS::GCPtr<DataTransferItem>> DataTransferItemList::add(Strin
}
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransferitemlist-add
JS::GCPtr<DataTransferItem> DataTransferItemList::add(JS::NonnullGCPtr<FileAPI::File> file)
GC::Ptr<DataTransferItem> DataTransferItemList::add(GC::Ref<FileAPI::File> file)
{
// 1. If the DataTransferItemList object is not in the read/write mode, return null.
if (m_data_transfer->mode() != DragDataStore::Mode::ReadWrite)

View file

@ -16,26 +16,26 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/dnd.html#the-datatransferitemlist-interface
class DataTransferItemList : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DataTransferItemList, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DataTransferItemList);
GC_DECLARE_ALLOCATOR(DataTransferItemList);
public:
static JS::NonnullGCPtr<DataTransferItemList> create(JS::Realm&, JS::NonnullGCPtr<DataTransfer>);
static GC::Ref<DataTransferItemList> create(JS::Realm&, GC::Ref<DataTransfer>);
virtual ~DataTransferItemList() override;
WebIDL::UnsignedLong length() const;
WebIDL::ExceptionOr<JS::GCPtr<DataTransferItem>> add(String const& data, String const& type);
JS::GCPtr<DataTransferItem> add(JS::NonnullGCPtr<FileAPI::File>);
WebIDL::ExceptionOr<GC::Ptr<DataTransferItem>> add(String const& data, String const& type);
GC::Ptr<DataTransferItem> add(GC::Ref<FileAPI::File>);
private:
DataTransferItemList(JS::Realm&, JS::NonnullGCPtr<DataTransfer>);
DataTransferItemList(JS::Realm&, GC::Ref<DataTransfer>);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(JS::Cell::Visitor&) override;
virtual Optional<JS::Value> item_value(size_t index) const override;
JS::NonnullGCPtr<DataTransfer> m_data_transfer;
GC::Ref<DataTransfer> m_data_transfer;
};
}

View file

@ -129,7 +129,7 @@ bool is_valid_date_string(StringView value)
}
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-date-string
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Date>> parse_date_string(JS::Realm& realm, StringView value)
WebIDL::ExceptionOr<GC::Ref<JS::Date>> parse_date_string(JS::Realm& realm, StringView value)
{
// FIXME: Implement spec compliant date string parsing
auto parts = value.split_view('-', SplitBehavior::KeepEmpty);
@ -225,7 +225,7 @@ bool is_valid_time_string(StringView value)
}
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-time-string
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Date>> parse_time_string(JS::Realm& realm, StringView value)
WebIDL::ExceptionOr<GC::Ref<JS::Date>> parse_time_string(JS::Realm& realm, StringView value)
{
// FIXME: Implement spec compliant time string parsing
auto parts = value.split_view(':', SplitBehavior::KeepEmpty);

View file

@ -17,10 +17,10 @@ u32 week_number_of_the_last_day(u64 year);
bool is_valid_week_string(StringView value);
bool is_valid_month_string(StringView value);
bool is_valid_date_string(StringView value);
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Date>> parse_date_string(JS::Realm& realm, StringView value);
WebIDL::ExceptionOr<GC::Ref<JS::Date>> parse_date_string(JS::Realm& realm, StringView value);
bool is_valid_local_date_and_time_string(StringView value);
String normalize_local_date_and_time_string(String const& value);
bool is_valid_time_string(StringView value);
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Date>> parse_time_string(JS::Realm& realm, StringView value);
WebIDL::ExceptionOr<GC::Ref<JS::Date>> parse_time_string(JS::Realm& realm, StringView value);
}

View file

@ -15,7 +15,7 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/images.html#img-req-data
class DecodedImageData : public JS::Cell {
JS_CELL(DecodedImageData, JS::Cell);
GC_CELL(DecodedImageData, JS::Cell);
public:
virtual ~DecodedImageData();

View file

@ -15,9 +15,9 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(DedicatedWorkerGlobalScope);
GC_DEFINE_ALLOCATOR(DedicatedWorkerGlobalScope);
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(JS::Realm& realm, JS::NonnullGCPtr<Web::Page> page)
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(JS::Realm& realm, GC::Ref<Web::Page> page)
: WorkerGlobalScope(realm, page)
{
m_legacy_platform_object_flags = LegacyPlatformObjectFlags { .has_global_interface_extended_attribute = true };
@ -58,7 +58,7 @@ WebIDL::ExceptionOr<void> DedicatedWorkerGlobalScope::post_message(JS::Value mes
}
// https://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-postmessage
WebIDL::ExceptionOr<void> DedicatedWorkerGlobalScope::post_message(JS::Value message, Vector<JS::Handle<JS::Object>> const& transfer)
WebIDL::ExceptionOr<void> DedicatedWorkerGlobalScope::post_message(JS::Value message, Vector<GC::Root<JS::Object>> const& transfer)
{
// The postMessage(message, transfer) and postMessage(message, options) methods on DedicatedWorkerGlobalScope objects act as if,
// when invoked, it immediately invoked the respective postMessage(message, transfer) and postMessage(message, options)

View file

@ -20,13 +20,13 @@ class DedicatedWorkerGlobalScope
: public WorkerGlobalScope
, public Bindings::DedicatedWorkerGlobalScopeGlobalMixin {
WEB_PLATFORM_OBJECT(DedicatedWorkerGlobalScope, WorkerGlobalScope);
JS_DECLARE_ALLOCATOR(DedicatedWorkerGlobalScope);
GC_DECLARE_ALLOCATOR(DedicatedWorkerGlobalScope);
public:
virtual ~DedicatedWorkerGlobalScope() override;
WebIDL::ExceptionOr<void> post_message(JS::Value message, StructuredSerializeOptions const&);
WebIDL::ExceptionOr<void> post_message(JS::Value message, Vector<JS::Handle<JS::Object>> const& transfer);
WebIDL::ExceptionOr<void> post_message(JS::Value message, Vector<GC::Root<JS::Object>> const& transfer);
void set_name(String name) { m_name = move(name); }
String name() const { return m_name; }
@ -43,7 +43,7 @@ public:
virtual void finalize() override;
private:
DedicatedWorkerGlobalScope(JS::Realm&, JS::NonnullGCPtr<Web::Page>);
DedicatedWorkerGlobalScope(JS::Realm&, GC::Ref<Web::Page>);
virtual void initialize_web_interfaces_impl() override;

View file

@ -10,15 +10,15 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(DocumentState);
GC_DEFINE_ALLOCATOR(DocumentState);
DocumentState::DocumentState() = default;
DocumentState::~DocumentState() = default;
JS::NonnullGCPtr<DocumentState> DocumentState::clone() const
GC::Ref<DocumentState> DocumentState::clone() const
{
JS::NonnullGCPtr<DocumentState> cloned = *heap().allocate<DocumentState>();
GC::Ref<DocumentState> cloned = *heap().allocate<DocumentState>();
cloned->m_document = m_document;
cloned->m_history_policy_container = m_history_policy_container;
cloned->m_request_referrer = m_request_referrer;

View file

@ -20,25 +20,25 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-2
class DocumentState final : public JS::Cell {
JS_CELL(DocumentState, JS::Cell);
JS_DECLARE_ALLOCATOR(DocumentState);
GC_CELL(DocumentState, JS::Cell);
GC_DECLARE_ALLOCATOR(DocumentState);
public:
struct NestedHistory {
String id;
Vector<JS::NonnullGCPtr<SessionHistoryEntry>> entries;
Vector<GC::Ref<SessionHistoryEntry>> entries;
};
virtual ~DocumentState();
JS::NonnullGCPtr<DocumentState> clone() const;
GC::Ref<DocumentState> clone() const;
enum class Client {
Tag,
};
[[nodiscard]] JS::GCPtr<DOM::Document> document() const { return m_document; }
void set_document(JS::GCPtr<DOM::Document> document) { m_document = document; }
[[nodiscard]] GC::Ptr<DOM::Document> document() const { return m_document; }
void set_document(GC::Ptr<DOM::Document> document) { m_document = document; }
[[nodiscard]] Variant<PolicyContainer, Client> history_policy_container() const { return m_history_policy_container; }
void set_history_policy_container(Variant<PolicyContainer, Client> history_policy_container) { m_history_policy_container = move(history_policy_container); }
@ -79,7 +79,7 @@ private:
void visit_edges(Cell::Visitor&) override;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-document
JS::GCPtr<DOM::Document> m_document;
GC::Ptr<DOM::Document> m_document;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-history-policy-container
Variant<PolicyContainer, Client> m_history_policy_container { Client::Tag };

View file

@ -10,14 +10,14 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(DragEvent);
GC_DEFINE_ALLOCATOR(DragEvent);
JS::NonnullGCPtr<DragEvent> DragEvent::create(JS::Realm& realm, FlyString const& event_name, DragEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y)
GC::Ref<DragEvent> DragEvent::create(JS::Realm& realm, FlyString const& event_name, DragEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y)
{
return realm.create<DragEvent>(realm, event_name, event_init, page_x, page_y, offset_x, offset_y);
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<DragEvent>> DragEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, DragEventInit const& event_init)
WebIDL::ExceptionOr<GC::Ref<DragEvent>> DragEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, DragEventInit const& event_init)
{
return create(realm, event_name, event_init);
}

View file

@ -14,21 +14,21 @@
namespace Web::HTML {
struct DragEventInit : public UIEvents::MouseEventInit {
JS::GCPtr<DataTransfer> data_transfer;
GC::Ptr<DataTransfer> data_transfer;
};
// https://html.spec.whatwg.org/multipage/dnd.html#the-dragevent-interface
class DragEvent : public UIEvents::MouseEvent {
WEB_PLATFORM_OBJECT(DragEvent, UIEvents::MouseEvent);
JS_DECLARE_ALLOCATOR(DragEvent);
GC_DECLARE_ALLOCATOR(DragEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<DragEvent> create(JS::Realm&, FlyString const& event_name, DragEventInit const& event_init = {}, double page_x = 0, double page_y = 0, double offset_x = 0, double offset_y = 0);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DragEvent>> construct_impl(JS::Realm&, FlyString const& event_name, DragEventInit const& event_init);
[[nodiscard]] static GC::Ref<DragEvent> create(JS::Realm&, FlyString const& event_name, DragEventInit const& event_init = {}, double page_x = 0, double page_y = 0, double offset_x = 0, double offset_y = 0);
static WebIDL::ExceptionOr<GC::Ref<DragEvent>> construct_impl(JS::Realm&, FlyString const& event_name, DragEventInit const& event_init);
virtual ~DragEvent() override;
JS::GCPtr<DataTransfer> data_transfer() { return m_data_transfer; }
GC::Ptr<DataTransfer> data_transfer() { return m_data_transfer; }
private:
DragEvent(JS::Realm&, FlyString const& event_name, DragEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y);
@ -36,7 +36,7 @@ private:
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(JS::Cell::Visitor&) override;
JS::GCPtr<DataTransfer> m_data_transfer;
GC::Ptr<DataTransfer> m_data_transfer;
};
}

View file

@ -12,9 +12,9 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(ElementInternals);
GC_DEFINE_ALLOCATOR(ElementInternals);
JS::NonnullGCPtr<ElementInternals> ElementInternals::create(JS::Realm& realm, HTMLElement& target_element)
GC::Ref<ElementInternals> ElementInternals::create(JS::Realm& realm, HTMLElement& target_element)
{
return realm.create<ElementInternals>(realm, target_element);
}
@ -26,7 +26,7 @@ ElementInternals::ElementInternals(JS::Realm& realm, HTMLElement& target_element
}
// https://html.spec.whatwg.org/#dom-elementinternals-shadowroot
JS::GCPtr<DOM::ShadowRoot> ElementInternals::shadow_root() const
GC::Ptr<DOM::ShadowRoot> ElementInternals::shadow_root() const
{
// 1. Let target be this's target element.
auto target = m_target_element;

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/WeakPtr.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibGC/Ptr.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/Forward.h>
@ -16,12 +16,12 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/custom-elements.html#elementinternals
class ElementInternals final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(ElementInternals, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(ElementInternals);
GC_DECLARE_ALLOCATOR(ElementInternals);
public:
static JS::NonnullGCPtr<ElementInternals> create(JS::Realm&, HTMLElement& target_element);
static GC::Ref<ElementInternals> create(JS::Realm&, HTMLElement& target_element);
JS::GCPtr<DOM::ShadowRoot> shadow_root() const;
GC::Ptr<DOM::ShadowRoot> shadow_root() const;
private:
explicit ElementInternals(JS::Realm&, HTMLElement& target_element);
@ -30,7 +30,7 @@ private:
virtual void visit_edges(JS::Cell::Visitor& visitor) override;
// https://html.spec.whatwg.org/multipage/custom-elements.html#internals-target
JS::NonnullGCPtr<HTMLElement> m_target_element;
GC::Ref<HTMLElement> m_target_element;
};
}

View file

@ -10,14 +10,14 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(ErrorEvent);
GC_DEFINE_ALLOCATOR(ErrorEvent);
JS::NonnullGCPtr<ErrorEvent> ErrorEvent::create(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
GC::Ref<ErrorEvent> ErrorEvent::create(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
{
return realm.create<ErrorEvent>(realm, event_name, event_init);
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> ErrorEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
WebIDL::ExceptionOr<GC::Ref<ErrorEvent>> ErrorEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
{
return create(realm, event_name, event_init);
}

View file

@ -23,11 +23,11 @@ struct ErrorEventInit : public DOM::EventInit {
// https://html.spec.whatwg.org/multipage/webappapis.html#errorevent
class ErrorEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(ErrorEvent, DOM::Event);
JS_DECLARE_ALLOCATOR(ErrorEvent);
GC_DECLARE_ALLOCATOR(ErrorEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<ErrorEvent> create(JS::Realm&, FlyString const& event_name, ErrorEventInit const& = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> construct_impl(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init);
[[nodiscard]] static GC::Ref<ErrorEvent> create(JS::Realm&, FlyString const& event_name, ErrorEventInit const& = {});
static WebIDL::ExceptionOr<GC::Ref<ErrorEvent>> construct_impl(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init);
virtual ~ErrorEvent() override;

View file

@ -9,7 +9,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(EventHandler);
GC_DEFINE_ALLOCATOR(EventHandler);
EventHandler::EventHandler(ByteString s)
: value(move(s))
@ -26,7 +26,7 @@ void EventHandler::visit_edges(Cell::Visitor& visitor)
Base::visit_edges(visitor);
visitor.visit(listener);
if (auto* callback = value.get_pointer<JS::GCPtr<WebIDL::CallbackType>>())
if (auto* callback = value.get_pointer<GC::Ptr<WebIDL::CallbackType>>())
visitor.visit(*callback);
}

View file

@ -8,15 +8,15 @@
#include <AK/ByteString.h>
#include <AK/Variant.h>
#include <LibGC/CellAllocator.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/CellAllocator.h>
#include <LibWeb/WebIDL/CallbackType.h>
namespace Web::HTML {
class EventHandler final : public JS::Cell {
JS_CELL(EventHandler, JS::Cell);
JS_DECLARE_ALLOCATOR(EventHandler);
GC_CELL(EventHandler, JS::Cell);
GC_DECLARE_ALLOCATOR(EventHandler);
public:
explicit EventHandler(ByteString);
@ -27,10 +27,10 @@ public:
// NOTE: This does not contain Empty as part of the optimization of not allocating all event handler attributes up front.
// FIXME: The string should actually be an "internal raw uncompiled handler" struct. This struct is just the uncompiled source code plus a source location for reporting parse errors.
// https://html.spec.whatwg.org/multipage/webappapis.html#internal-raw-uncompiled-handler
Variant<ByteString, JS::GCPtr<WebIDL::CallbackType>> value;
Variant<ByteString, GC::Ptr<WebIDL::CallbackType>> value;
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-listener
JS::GCPtr<DOM::DOMEventListener> listener;
GC::Ptr<DOM::DOMEventListener> listener;
private:
virtual void visit_edges(Cell::Visitor&) override;

View file

@ -25,7 +25,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(EventLoop);
GC_DEFINE_ALLOCATOR(EventLoop);
EventLoop::EventLoop(Type type)
: m_type(type)
@ -33,7 +33,7 @@ EventLoop::EventLoop(Type type)
m_task_queue = heap().allocate<TaskQueue>(*this);
m_microtask_queue = heap().allocate<TaskQueue>(*this);
m_rendering_task_function = JS::create_heap_function(heap(), [this] {
m_rendering_task_function = GC::create_function(heap(), [this] {
update_the_rendering();
});
}
@ -54,7 +54,7 @@ void EventLoop::visit_edges(Visitor& visitor)
void EventLoop::schedule()
{
if (!m_system_event_loop_timer) {
m_system_event_loop_timer = Platform::Timer::create_single_shot(heap(), 0, JS::create_heap_function(heap(), [this] {
m_system_event_loop_timer = Platform::Timer::create_single_shot(heap(), 0, GC::create_function(heap(), [this] {
process();
}));
}
@ -69,7 +69,7 @@ EventLoop& main_thread_event_loop()
}
// https://html.spec.whatwg.org/multipage/webappapis.html#spin-the-event-loop
void EventLoop::spin_until(JS::NonnullGCPtr<JS::HeapFunction<bool()>> goal_condition)
void EventLoop::spin_until(GC::Ref<GC::Function<bool()>> goal_condition)
{
// FIXME: The spec wants us to do the rest of the enclosing algorithm (i.e. the caller)
// in the context of the currently running task on entry. That's not possible with this implementation.
@ -92,7 +92,7 @@ void EventLoop::spin_until(JS::NonnullGCPtr<JS::HeapFunction<bool()>> goal_condi
// 2. Perform any steps that appear after this spin the event loop instance in the original algorithm.
// NOTE: This is achieved by returning from the function.
Platform::EventLoopPlugin::the().spin_until(JS::create_heap_function(heap(), [this, goal_condition] {
Platform::EventLoopPlugin::the().spin_until(GC::create_function(heap(), [this, goal_condition] {
if (goal_condition->function()())
return true;
if (m_task_queue->has_runnable_tasks()) {
@ -109,7 +109,7 @@ void EventLoop::spin_until(JS::NonnullGCPtr<JS::HeapFunction<bool()>> goal_condi
// NOTE: This is achieved by returning from the function.
}
void EventLoop::spin_processing_tasks_with_source_until(Task::Source source, JS::NonnullGCPtr<JS::HeapFunction<bool()>> goal_condition)
void EventLoop::spin_processing_tasks_with_source_until(Task::Source source, GC::Ref<GC::Function<bool()>> goal_condition)
{
auto& vm = this->vm();
vm.save_execution_context_stack();
@ -120,7 +120,7 @@ void EventLoop::spin_processing_tasks_with_source_until(Task::Source source, JS:
// NOTE: HTML event loop processing steps could run a task with arbitrary source
m_skip_event_loop_processing_steps = true;
Platform::EventLoopPlugin::the().spin_until(JS::create_heap_function(heap(), [this, source, goal_condition] {
Platform::EventLoopPlugin::the().spin_until(GC::create_function(heap(), [this, source, goal_condition] {
if (goal_condition->function()())
return true;
if (m_task_queue->has_runnable_tasks()) {
@ -154,7 +154,7 @@ void EventLoop::process()
return;
// 1. Let oldestTask and taskStartTime be null.
JS::GCPtr<Task> oldest_task;
GC::Ptr<Task> oldest_task;
[[maybe_unused]] double task_start_time = 0;
// 2. If the event loop has a task queue with at least one runnable task, then:
@ -404,7 +404,7 @@ void EventLoop::update_the_rendering()
}
// https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task
TaskID queue_a_task(HTML::Task::Source source, JS::GCPtr<EventLoop> event_loop, JS::GCPtr<DOM::Document> document, JS::NonnullGCPtr<JS::HeapFunction<void()>> steps)
TaskID queue_a_task(HTML::Task::Source source, GC::Ptr<EventLoop> event_loop, GC::Ptr<DOM::Document> document, GC::Ref<GC::Function<void()>> steps)
{
// 1. If event loop was not given, set event loop to the implied event loop.
if (!event_loop)
@ -429,7 +429,7 @@ TaskID queue_a_task(HTML::Task::Source source, JS::GCPtr<EventLoop> event_loop,
}
// https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-global-task
TaskID queue_global_task(HTML::Task::Source source, JS::Object& global_object, JS::NonnullGCPtr<JS::HeapFunction<void()>> steps)
TaskID queue_global_task(HTML::Task::Source source, JS::Object& global_object, GC::Ref<GC::Function<void()>> steps)
{
// 1. Let event loop be global's relevant agent's event loop.
auto& global_custom_data = verify_cast<Bindings::WebEngineCustomData>(*global_object.vm().custom_data());
@ -447,7 +447,7 @@ TaskID queue_global_task(HTML::Task::Source source, JS::Object& global_object, J
}
// https://html.spec.whatwg.org/#queue-a-microtask
void queue_a_microtask(DOM::Document const* document, JS::NonnullGCPtr<JS::HeapFunction<void()>> steps)
void queue_a_microtask(DOM::Document const* document, GC::Ref<GC::Function<void()>> steps)
{
// 1. If event loop was not given, set event loop to the implied event loop.
auto& event_loop = HTML::main_thread_event_loop();
@ -515,14 +515,14 @@ void EventLoop::perform_a_microtask_checkpoint()
// FIXME: 8. Record timing info for microtask checkpoint.
}
Vector<JS::Handle<DOM::Document>> EventLoop::documents_in_this_event_loop() const
Vector<GC::Root<DOM::Document>> EventLoop::documents_in_this_event_loop() const
{
Vector<JS::Handle<DOM::Document>> documents;
Vector<GC::Root<DOM::Document>> documents;
for (auto& document : m_documents) {
VERIFY(document);
if (document->is_decoded_svg())
continue;
documents.append(JS::make_handle(*document));
documents.append(GC::make_root(*document));
}
return documents;
}
@ -565,12 +565,12 @@ void EventLoop::unregister_environment_settings_object(Badge<EnvironmentSettings
}
// https://html.spec.whatwg.org/multipage/webappapis.html#same-loop-windows
Vector<JS::Handle<HTML::Window>> EventLoop::same_loop_windows() const
Vector<GC::Root<HTML::Window>> EventLoop::same_loop_windows() const
{
Vector<JS::Handle<HTML::Window>> windows;
Vector<GC::Root<HTML::Window>> windows;
for (auto& document : documents_in_this_event_loop()) {
if (document->is_fully_active())
windows.append(JS::make_handle(document->window()));
windows.append(GC::make_root(document->window()));
}
return windows;
}

View file

@ -10,16 +10,16 @@
#include <AK/Noncopyable.h>
#include <AK/WeakPtr.h>
#include <LibCore/Forward.h>
#include <LibGC/Ptr.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibWeb/HTML/EventLoop/TaskQueue.h>
#include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h>
namespace Web::HTML {
class EventLoop : public JS::Cell {
JS_CELL(EventLoop, JS::Cell);
JS_DECLARE_ALLOCATOR(EventLoop);
GC_CELL(EventLoop, JS::Cell);
GC_DECLARE_ALLOCATOR(EventLoop);
struct PauseHandle {
PauseHandle(EventLoop&, JS::Object const& global, HighResolutionTime::DOMHighResTimeStamp);
@ -28,8 +28,8 @@ class EventLoop : public JS::Cell {
AK_MAKE_NONCOPYABLE(PauseHandle);
AK_MAKE_NONMOVABLE(PauseHandle);
JS::NonnullGCPtr<EventLoop> event_loop;
JS::NonnullGCPtr<JS::Object const> global;
GC::Ref<EventLoop> event_loop;
GC::Ref<JS::Object const> global;
HighResolutionTime::DOMHighResTimeStamp const time_before_pause;
};
@ -53,8 +53,8 @@ public:
TaskQueue& microtask_queue() { return *m_microtask_queue; }
TaskQueue const& microtask_queue() const { return *m_microtask_queue; }
void spin_until(JS::NonnullGCPtr<JS::HeapFunction<bool()>> goal_condition);
void spin_processing_tasks_with_source_until(Task::Source, JS::NonnullGCPtr<JS::HeapFunction<bool()>> goal_condition);
void spin_until(GC::Ref<GC::Function<bool()>> goal_condition);
void spin_processing_tasks_with_source_until(Task::Source, GC::Ref<GC::Function<bool()>> goal_condition);
void process();
void queue_task_to_update_the_rendering();
@ -72,9 +72,9 @@ public:
void register_document(Badge<DOM::Document>, DOM::Document&);
void unregister_document(Badge<DOM::Document>, DOM::Document&);
Vector<JS::Handle<DOM::Document>> documents_in_this_event_loop() const;
Vector<GC::Root<DOM::Document>> documents_in_this_event_loop() const;
Vector<JS::Handle<HTML::Window>> same_loop_windows() const;
Vector<GC::Root<HTML::Window>> same_loop_windows() const;
void push_onto_backup_incumbent_realm_stack(JS::Realm&);
void pop_backup_incumbent_realm_stack();
@ -99,18 +99,18 @@ private:
Type m_type { Type::Window };
JS::GCPtr<TaskQueue> m_task_queue;
JS::GCPtr<TaskQueue> m_microtask_queue;
GC::Ptr<TaskQueue> m_task_queue;
GC::Ptr<TaskQueue> m_microtask_queue;
// https://html.spec.whatwg.org/multipage/webappapis.html#currently-running-task
JS::GCPtr<Task> m_currently_running_task { nullptr };
GC::Ptr<Task> m_currently_running_task { nullptr };
// https://html.spec.whatwg.org/multipage/webappapis.html#last-render-opportunity-time
double m_last_render_opportunity_time { 0 };
// https://html.spec.whatwg.org/multipage/webappapis.html#last-idle-period-start-time
double m_last_idle_period_start_time { 0 };
JS::GCPtr<Platform::Timer> m_system_event_loop_timer;
GC::Ptr<Platform::Timer> m_system_event_loop_timer;
// https://html.spec.whatwg.org/#performing-a-microtask-checkpoint
bool m_performing_a_microtask_checkpoint { false };
@ -123,7 +123,7 @@ private:
// https://html.spec.whatwg.org/multipage/webappapis.html#backup-incumbent-settings-object-stack
// https://whatpr.org/html/9893/webappapis.html#backup-incumbent-realm-stack
Vector<JS::NonnullGCPtr<JS::Realm>> m_backup_incumbent_realm_stack;
Vector<GC::Ref<JS::Realm>> m_backup_incumbent_realm_stack;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#termination-nesting-level
size_t m_termination_nesting_level { 0 };
@ -134,13 +134,13 @@ private:
bool m_is_running_rendering_task { false };
JS::GCPtr<JS::HeapFunction<void()>> m_rendering_task_function;
GC::Ptr<GC::Function<void()>> m_rendering_task_function;
};
EventLoop& main_thread_event_loop();
TaskID queue_a_task(HTML::Task::Source, JS::GCPtr<EventLoop>, JS::GCPtr<DOM::Document>, JS::NonnullGCPtr<JS::HeapFunction<void()>> steps);
TaskID queue_global_task(HTML::Task::Source, JS::Object&, JS::NonnullGCPtr<JS::HeapFunction<void()>> steps);
void queue_a_microtask(DOM::Document const*, JS::NonnullGCPtr<JS::HeapFunction<void()>> steps);
TaskID queue_a_task(HTML::Task::Source, GC::Ptr<EventLoop>, GC::Ptr<DOM::Document>, GC::Ref<GC::Function<void()>> steps);
TaskID queue_global_task(HTML::Task::Source, JS::Object&, GC::Ref<GC::Function<void()>> steps);
void queue_a_microtask(DOM::Document const*, GC::Ref<GC::Function<void()>> steps);
void perform_a_microtask_checkpoint();
}

View file

@ -10,7 +10,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(Task);
GC_DEFINE_ALLOCATOR(Task);
static IDAllocator s_unique_task_source_allocator { static_cast<int>(Task::Source::UniqueTaskSourceStart) };
@ -20,12 +20,12 @@ static IDAllocator s_unique_task_source_allocator { static_cast<int>(Task::Sourc
return next_task_id++;
}
JS::NonnullGCPtr<Task> Task::create(JS::VM& vm, Source source, JS::GCPtr<DOM::Document const> document, JS::NonnullGCPtr<JS::HeapFunction<void()>> steps)
GC::Ref<Task> Task::create(JS::VM& vm, Source source, GC::Ptr<DOM::Document const> document, GC::Ref<GC::Function<void()>> steps)
{
return vm.heap().allocate<Task>(source, document, move(steps));
}
Task::Task(Source source, JS::GCPtr<DOM::Document const> document, JS::NonnullGCPtr<JS::HeapFunction<void()>> steps)
Task::Task(Source source, GC::Ptr<DOM::Document const> document, GC::Ref<GC::Function<void()>> steps)
: m_id(allocate_task_id())
, m_source(source)
, m_steps(steps)

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/DistinctNumeric.h>
#include <LibGC/CellAllocator.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/CellAllocator.h>
#include <LibWeb/Forward.h>
namespace Web::HTML {
@ -18,8 +18,8 @@ struct UniqueTaskSource;
AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u64, TaskID, Comparison);
class Task final : public JS::Cell {
JS_CELL(Task, JS::Cell);
JS_DECLARE_ALLOCATOR(Task);
GC_CELL(Task, JS::Cell);
GC_DECLARE_ALLOCATOR(Task);
public:
// https://html.spec.whatwg.org/multipage/webappapis.html#generic-task-sources
@ -74,7 +74,7 @@ public:
UniqueTaskSourceStart
};
static JS::NonnullGCPtr<Task> create(JS::VM&, Source, JS::GCPtr<DOM::Document const>, JS::NonnullGCPtr<JS::HeapFunction<void()>> steps);
static GC::Ref<Task> create(JS::VM&, Source, GC::Ptr<DOM::Document const>, GC::Ref<GC::Function<void()>> steps);
virtual ~Task() override;
@ -87,14 +87,14 @@ public:
bool is_runnable() const;
private:
Task(Source, JS::GCPtr<DOM::Document const>, JS::NonnullGCPtr<JS::HeapFunction<void()>> steps);
Task(Source, GC::Ptr<DOM::Document const>, GC::Ref<GC::Function<void()>> steps);
virtual void visit_edges(Visitor&) override;
TaskID m_id {};
Source m_source { Source::Unspecified };
JS::NonnullGCPtr<JS::HeapFunction<void()>> m_steps;
JS::GCPtr<DOM::Document const> m_document;
GC::Ref<GC::Function<void()>> m_steps;
GC::Ptr<DOM::Document const> m_document;
};
struct UniqueTaskSource {

View file

@ -4,13 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Heap/MarkedVector.h>
#include <LibGC/MarkedVector.h>
#include <LibWeb/HTML/EventLoop/EventLoop.h>
#include <LibWeb/HTML/EventLoop/TaskQueue.h>
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(TaskQueue);
GC_DEFINE_ALLOCATOR(TaskQueue);
TaskQueue::TaskQueue(HTML::EventLoop& event_loop)
: m_event_loop(event_loop)
@ -26,13 +26,13 @@ void TaskQueue::visit_edges(Visitor& visitor)
visitor.visit(m_tasks);
}
void TaskQueue::add(JS::NonnullGCPtr<Task> task)
void TaskQueue::add(GC::Ref<Task> task)
{
m_tasks.append(task);
m_event_loop->schedule();
}
JS::GCPtr<Task> TaskQueue::take_first_runnable()
GC::Ptr<Task> TaskQueue::take_first_runnable()
{
if (m_event_loop->execution_paused())
return nullptr;
@ -63,9 +63,9 @@ void TaskQueue::remove_tasks_matching(Function<bool(HTML::Task const&)> filter)
});
}
JS::MarkedVector<JS::NonnullGCPtr<Task>> TaskQueue::take_tasks_matching(Function<bool(HTML::Task const&)> filter)
GC::MarkedVector<GC::Ref<Task>> TaskQueue::take_tasks_matching(Function<bool(HTML::Task const&)> filter)
{
JS::MarkedVector<JS::NonnullGCPtr<Task>> matching_tasks(heap());
GC::MarkedVector<GC::Ref<Task>> matching_tasks(heap());
for (size_t i = 0; i < m_tasks.size();) {
auto& task = m_tasks.at(i);

View file

@ -13,8 +13,8 @@
namespace Web::HTML {
class TaskQueue : public JS::Cell {
JS_CELL(TaskQueue, JS::Cell);
JS_DECLARE_ALLOCATOR(TaskQueue);
GC_CELL(TaskQueue, JS::Cell);
GC_DECLARE_ALLOCATOR(TaskQueue);
public:
explicit TaskQueue(HTML::EventLoop&);
@ -25,11 +25,11 @@ public:
bool has_runnable_tasks() const;
bool has_rendering_tasks() const;
void add(JS::NonnullGCPtr<HTML::Task>);
JS::GCPtr<HTML::Task> take_first_runnable();
void add(GC::Ref<HTML::Task>);
GC::Ptr<HTML::Task> take_first_runnable();
void enqueue(JS::NonnullGCPtr<HTML::Task> task) { add(task); }
JS::GCPtr<HTML::Task> dequeue()
void enqueue(GC::Ref<HTML::Task> task) { add(task); }
GC::Ptr<HTML::Task> dequeue()
{
if (m_tasks.is_empty())
return {};
@ -37,16 +37,16 @@ public:
}
void remove_tasks_matching(Function<bool(HTML::Task const&)>);
JS::MarkedVector<JS::NonnullGCPtr<Task>> take_tasks_matching(Function<bool(HTML::Task const&)>);
GC::MarkedVector<GC::Ref<Task>> take_tasks_matching(Function<bool(HTML::Task const&)>);
Task const* last_added_task() const;
private:
virtual void visit_edges(Visitor&) override;
JS::NonnullGCPtr<HTML::EventLoop> m_event_loop;
GC::Ref<HTML::EventLoop> m_event_loop;
Vector<JS::NonnullGCPtr<HTML::Task>> m_tasks;
Vector<GC::Ref<HTML::Task>> m_tasks;
};
}

View file

@ -6,7 +6,7 @@
#include <AK/ScopeGuard.h>
#include <LibCore/EventLoop.h>
#include <LibJS/Heap/Heap.h>
#include <LibGC/Heap.h>
#include <LibJS/Runtime/Realm.h>
#include <LibJS/Runtime/VM.h>
#include <LibWeb/Bindings/EventSourcePrototype.h>
@ -29,10 +29,10 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(EventSource);
GC_DEFINE_ALLOCATOR(EventSource);
// https://html.spec.whatwg.org/multipage/server-sent-events.html#dom-eventsource
WebIDL::ExceptionOr<JS::NonnullGCPtr<EventSource>> EventSource::construct_impl(JS::Realm& realm, StringView url, EventSourceInit event_source_init_dict)
WebIDL::ExceptionOr<GC::Ref<EventSource>> EventSource::construct_impl(JS::Realm& realm, StringView url, EventSourceInit event_source_init_dict)
{
auto& vm = realm.vm();
@ -87,7 +87,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<EventSource>> EventSource::construct_impl(J
// 14. Let processEventSourceEndOfBody given response res be the following step: if res is not a network error, then
// reestablish the connection.
auto process_event_source_end_of_body = [event_source](JS::NonnullGCPtr<Fetch::Infrastructure::Response> response) {
auto process_event_source_end_of_body = [event_source](GC::Ref<Fetch::Infrastructure::Response> response) {
if (!response->is_network_error())
event_source->reestablish_the_connection();
};
@ -97,7 +97,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<EventSource>> EventSource::construct_impl(J
Fetch::Infrastructure::FetchAlgorithms::Input fetch_algorithms_input {};
fetch_algorithms_input.process_response_end_of_body = move(process_event_source_end_of_body);
fetch_algorithms_input.process_response = [event_source](JS::NonnullGCPtr<Fetch::Infrastructure::Response> response) {
fetch_algorithms_input.process_response = [event_source](GC::Ref<Fetch::Infrastructure::Response> response) {
auto& realm = event_source->realm();
// FIXME: If the response is CORS cross-origin, we must use its internal response to query any of its data. See:
@ -130,7 +130,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<EventSource>> EventSource::construct_impl(J
else {
event_source->announce_the_connection();
auto process_body_chunk = JS::create_heap_function(realm.heap(), [event_source, pending_data = ByteBuffer()](ByteBuffer body) mutable {
auto process_body_chunk = GC::create_function(realm.heap(), [event_source, pending_data = ByteBuffer()](ByteBuffer body) mutable {
if (pending_data.is_empty())
pending_data = move(body);
else
@ -146,10 +146,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<EventSource>> EventSource::construct_impl(J
pending_data = MUST(pending_data.slice(end_index, pending_data.size() - end_index));
});
auto process_end_of_body = JS::create_heap_function(realm.heap(), []() {
auto process_end_of_body = GC::create_function(realm.heap(), []() {
// This case is handled by `process_event_source_end_of_body` above.
});
auto process_body_error = JS::create_heap_function(realm.heap(), [](JS::Value) {
auto process_body_error = GC::create_function(realm.heap(), [](JS::Value) {
// This case is handled by `process_event_source_end_of_body` above.
});
@ -269,7 +269,7 @@ void EventSource::announce_the_connection()
// When a user agent is to announce the connection, the user agent must queue a task which, if the readyState attribute
// is set to a value other than CLOSED, sets the readyState attribute to OPEN and fires an event named open at the
// EventSource object.
HTML::queue_a_task(HTML::Task::Source::RemoteEvent, nullptr, nullptr, JS::create_heap_function(heap(), [this]() {
HTML::queue_a_task(HTML::Task::Source::RemoteEvent, nullptr, nullptr, GC::create_function(heap(), [this]() {
if (m_ready_state != ReadyState::Closed) {
m_ready_state = ReadyState::Open;
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::open));
@ -283,7 +283,7 @@ void EventSource::reestablish_the_connection()
bool initial_task_has_run { false };
// 1. Queue a task to run the following steps:
HTML::queue_a_task(HTML::Task::Source::RemoteEvent, nullptr, nullptr, JS::create_heap_function(heap(), [&]() {
HTML::queue_a_task(HTML::Task::Source::RemoteEvent, nullptr, nullptr, GC::create_function(heap(), [&]() {
ScopeGuard guard { [&]() { initial_task_has_run = true; } };
// 1. If the readyState attribute is set to CLOSED, abort the task.
@ -298,7 +298,7 @@ void EventSource::reestablish_the_connection()
}));
// 2. Wait a delay equal to the reconnection time of the event source.
HTML::main_thread_event_loop().spin_until(JS::create_heap_function(heap(), [&, delay_start = MonotonicTime::now()]() {
HTML::main_thread_event_loop().spin_until(GC::create_function(heap(), [&, delay_start = MonotonicTime::now()]() {
return (MonotonicTime::now() - delay_start) >= m_reconnection_time;
}));
@ -309,17 +309,17 @@ void EventSource::reestablish_the_connection()
// 4. Wait until the aforementioned task has run, if it has not yet run.
if (!initial_task_has_run) {
HTML::main_thread_event_loop().spin_until(JS::create_heap_function(heap(), [&]() { return initial_task_has_run; }));
HTML::main_thread_event_loop().spin_until(GC::create_function(heap(), [&]() { return initial_task_has_run; }));
}
// 5. Queue a task to run the following steps:
HTML::queue_a_task(HTML::Task::Source::RemoteEvent, nullptr, nullptr, JS::create_heap_function(heap(), [this]() {
HTML::queue_a_task(HTML::Task::Source::RemoteEvent, nullptr, nullptr, GC::create_function(heap(), [this]() {
// 1. If the EventSource object's readyState attribute is not set to CONNECTING, then return.
if (m_ready_state != ReadyState::Connecting)
return;
// 2. Let request be the EventSource object's request.
JS::NonnullGCPtr request { *m_request };
GC::Ref request { *m_request };
// 3. If the EventSource object's last event ID string is not the empty string, then:
if (!m_last_event_id.is_empty()) {
@ -340,7 +340,7 @@ void EventSource::fail_the_connection()
// When a user agent is to fail the connection, the user agent must queue a task which, if the readyState attribute
// is set to a value other than CLOSED, sets the readyState attribute to CLOSED and fires an event named error at the
// EventSource object. Once the user agent has failed the connection, it does not attempt to reconnect.
HTML::queue_a_task(HTML::Task::Source::RemoteEvent, nullptr, nullptr, JS::create_heap_function(heap(), [this]() {
HTML::queue_a_task(HTML::Task::Source::RemoteEvent, nullptr, nullptr, GC::create_function(heap(), [this]() {
if (m_ready_state != ReadyState::Closed) {
m_ready_state = ReadyState::Closed;
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error));
@ -461,7 +461,7 @@ void EventSource::dispatch_the_event()
// 8. Queue a task which, if the readyState attribute is set to a value other than CLOSED, dispatches the newly created
// event at the EventSource object.
HTML::queue_a_task(HTML::Task::Source::RemoteEvent, nullptr, nullptr, JS::create_heap_function(heap(), [this, event]() {
HTML::queue_a_task(HTML::Task::Source::RemoteEvent, nullptr, nullptr, GC::create_function(heap(), [this, event]() {
if (m_ready_state != ReadyState::Closed)
dispatch_event(event);
}));

View file

@ -10,8 +10,8 @@
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <AK/Time.h>
#include <LibGC/Ptr.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibURL/URL.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/Forward.h>
@ -26,12 +26,12 @@ struct EventSourceInit {
class EventSource : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(EventSource, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(EventSource);
GC_DECLARE_ALLOCATOR(EventSource);
public:
virtual ~EventSource() override;
static WebIDL::ExceptionOr<JS::NonnullGCPtr<EventSource>> construct_impl(JS::Realm&, StringView url, EventSourceInit event_source_init_dict = {});
static WebIDL::ExceptionOr<GC::Ref<EventSource>> construct_impl(JS::Realm&, StringView url, EventSourceInit event_source_init_dict = {});
// https://html.spec.whatwg.org/multipage/server-sent-events.html#dom-eventsource-url
String url() const { return MUST(String::from_byte_string(m_url.serialize())); }
@ -79,7 +79,7 @@ private:
URL::URL m_url;
// https://html.spec.whatwg.org/multipage/server-sent-events.html#concept-event-stream-request
JS::GCPtr<Fetch::Infrastructure::Request> m_request;
GC::Ptr<Fetch::Infrastructure::Request> m_request;
// https://html.spec.whatwg.org/multipage/server-sent-events.html#concept-event-stream-reconnection-time
AK::Duration m_reconnection_time { AK::Duration::from_seconds(3) };
@ -94,8 +94,8 @@ private:
ReadyState m_ready_state { ReadyState::Connecting };
JS::GCPtr<Fetch::Infrastructure::FetchAlgorithms> m_fetch_algorithms;
JS::GCPtr<Fetch::Infrastructure::FetchController> m_fetch_controller;
GC::Ptr<Fetch::Infrastructure::FetchAlgorithms> m_fetch_algorithms;
GC::Ptr<Fetch::Infrastructure::FetchController> m_fetch_controller;
};
}

View file

@ -8,7 +8,7 @@
#include <AK/TypeCasts.h>
#include <AK/Vector.h>
#include <LibJS/Heap/Handle.h>
#include <LibGC/Root.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/ShadowRoot.h>
@ -20,7 +20,7 @@
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/interaction.html#fire-a-focus-event
static void fire_a_focus_event(JS::GCPtr<DOM::EventTarget> focus_event_target, JS::GCPtr<DOM::EventTarget> related_focus_target, FlyString const& event_name, bool bubbles)
static void fire_a_focus_event(GC::Ptr<DOM::EventTarget> focus_event_target, GC::Ptr<DOM::EventTarget> related_focus_target, FlyString const& event_name, bool bubbles)
{
// To fire a focus event named e at an element t with a given related target r, fire an event named e at t, using FocusEvent,
// with the relatedTarget attribute initialized to r, the view attribute initialized to t's node document's relevant global
@ -38,7 +38,7 @@ static void fire_a_focus_event(JS::GCPtr<DOM::EventTarget> focus_event_target, J
}
// https://html.spec.whatwg.org/multipage/interaction.html#focus-update-steps
static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vector<JS::Handle<DOM::Node>> new_chain, DOM::Node* new_focus_target)
static void run_focus_update_steps(Vector<GC::Root<DOM::Node>> old_chain, Vector<GC::Root<DOM::Node>> new_chain, DOM::Node* new_focus_target)
{
// 1. If the last entry in old chain and the last entry in new chain are the same,
// pop the last entry from old chain and the last entry from new chain and redo this step.
@ -67,7 +67,7 @@ static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vect
}
}
JS::GCPtr<DOM::EventTarget> blur_event_target;
GC::Ptr<DOM::EventTarget> blur_event_target;
if (is<DOM::Element>(*entry)) {
// 2. If entry is an element, let blur event target be entry.
blur_event_target = entry.ptr();
@ -80,7 +80,7 @@ static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vect
// and the last entry in new chain is also an Element,
// then let related blur target be the last entry in new chain.
// Otherwise, let related blur target be null.
JS::GCPtr<DOM::EventTarget> related_blur_target;
GC::Ptr<DOM::EventTarget> related_blur_target;
if (!old_chain.is_empty()
&& &entry == &old_chain.last()
&& is<DOM::Element>(*entry)
@ -112,7 +112,7 @@ static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vect
else if (is<DOM::Document>(*entry))
entry->document().set_focused_element(static_cast<DOM::Document&>(*entry).document_element());
JS::GCPtr<DOM::EventTarget> focus_event_target;
GC::Ptr<DOM::EventTarget> focus_event_target;
if (is<DOM::Element>(*entry)) {
// 2. If entry is an element, let focus event target be entry.
focus_event_target = entry.ptr();
@ -125,7 +125,7 @@ static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vect
// and the last entry in old chain is also an Element,
// then let related focus target be the last entry in old chain.
// Otherwise, let related focus target be null.
JS::GCPtr<DOM::EventTarget> related_focus_target;
GC::Ptr<DOM::EventTarget> related_focus_target;
if (!new_chain.is_empty()
&& &entry == &new_chain.last()
&& is<DOM::Element>(*entry)
@ -146,14 +146,14 @@ static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vect
}
// https://html.spec.whatwg.org/multipage/interaction.html#focus-chain
static Vector<JS::Handle<DOM::Node>> focus_chain(DOM::Node* subject)
static Vector<GC::Root<DOM::Node>> focus_chain(DOM::Node* subject)
{
// FIXME: Move this somewhere more spec-friendly.
if (!subject)
return {};
// 1. Let output be an empty list.
Vector<JS::Handle<DOM::Node>> output;
Vector<GC::Root<DOM::Node>> output;
// 2. Let currentObject be subject.
auto* current_object = subject;
@ -161,7 +161,7 @@ static Vector<JS::Handle<DOM::Node>> focus_chain(DOM::Node* subject)
// 3. While true:
while (true) {
// 1. Append currentObject to output.
output.append(JS::make_handle(*current_object));
output.append(GC::make_root(*current_object));
// FIXME: 2. If currentObject is an area element's shape, then append that area element to output.

View file

@ -689,7 +689,7 @@ void FormAssociatedTextControlElement::select_all()
selection_was_changed();
}
void FormAssociatedTextControlElement::set_selection_anchor(JS::NonnullGCPtr<DOM::Node> anchor_node, size_t anchor_offset)
void FormAssociatedTextControlElement::set_selection_anchor(GC::Ref<DOM::Node> anchor_node, size_t anchor_offset)
{
auto text_node = form_associated_element_to_text_node();
if (!text_node || anchor_node != text_node)
@ -698,7 +698,7 @@ void FormAssociatedTextControlElement::set_selection_anchor(JS::NonnullGCPtr<DOM
selection_was_changed();
}
void FormAssociatedTextControlElement::set_selection_focus(JS::NonnullGCPtr<DOM::Node> focus_node, size_t focus_offset)
void FormAssociatedTextControlElement::set_selection_focus(GC::Ref<DOM::Node> focus_node, size_t focus_offset)
{
auto text_node = form_associated_element_to_text_node();
if (!text_node || focus_node != text_node)
@ -809,7 +809,7 @@ void FormAssociatedTextControlElement::decrement_cursor_position_to_previous_wor
selection_was_changed();
}
JS::GCPtr<DOM::Position> FormAssociatedTextControlElement::cursor_position() const
GC::Ptr<DOM::Position> FormAssociatedTextControlElement::cursor_position() const
{
auto const node = form_associated_element_to_text_node();
if (!node)

View file

@ -172,15 +172,15 @@ public:
virtual void did_edit_text_node() = 0;
virtual JS::GCPtr<DOM::Text> form_associated_element_to_text_node() = 0;
virtual JS::GCPtr<DOM::Text const> form_associated_element_to_text_node() const { return const_cast<FormAssociatedTextControlElement&>(*this).form_associated_element_to_text_node(); }
virtual GC::Ptr<DOM::Text> form_associated_element_to_text_node() = 0;
virtual GC::Ptr<DOM::Text const> form_associated_element_to_text_node() const { return const_cast<FormAssociatedTextControlElement&>(*this).form_associated_element_to_text_node(); }
virtual void handle_insert(String const&) override;
virtual void handle_delete(DeleteDirection) override;
virtual void handle_return_key() override;
virtual void select_all() override;
virtual void set_selection_anchor(JS::NonnullGCPtr<DOM::Node>, size_t offset) override;
virtual void set_selection_focus(JS::NonnullGCPtr<DOM::Node>, size_t offset) override;
virtual void set_selection_anchor(GC::Ref<DOM::Node>, size_t offset) override;
virtual void set_selection_focus(GC::Ref<DOM::Node>, size_t offset) override;
virtual void move_cursor_to_start(CollapseSelection) override;
virtual void move_cursor_to_end(CollapseSelection) override;
virtual void increment_cursor_position_offset(CollapseSelection) override;
@ -188,7 +188,7 @@ public:
virtual void increment_cursor_position_to_next_word(CollapseSelection) override;
virtual void decrement_cursor_position_to_previous_word(CollapseSelection) override;
JS::GCPtr<DOM::Position> cursor_position() const;
GC::Ptr<DOM::Position> cursor_position() const;
protected:
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-textarea/input-relevant-value

View file

@ -19,7 +19,7 @@
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#create-an-entry
WebIDL::ExceptionOr<XHR::FormDataEntry> create_entry(JS::Realm& realm, String const& name, Variant<JS::NonnullGCPtr<FileAPI::Blob>, String> const& value, Optional<String> const& filename)
WebIDL::ExceptionOr<XHR::FormDataEntry> create_entry(JS::Realm& realm, String const& name, Variant<GC::Ref<FileAPI::Blob>, String> const& value, Optional<String> const& filename)
{
auto& vm = realm.vm();
@ -28,18 +28,18 @@ WebIDL::ExceptionOr<XHR::FormDataEntry> create_entry(JS::Realm& realm, String co
auto entry_value = TRY(value.visit(
// 2. If value is a string, then set value to the result of converting value into a scalar value string.
[&](String const& string) -> WebIDL::ExceptionOr<Variant<JS::Handle<FileAPI::File>, String>> {
[&](String const& string) -> WebIDL::ExceptionOr<Variant<GC::Root<FileAPI::File>, String>> {
return TRY_OR_THROW_OOM(vm, Infra::convert_to_scalar_value_string(string));
},
// 3. Otherwise:
[&](JS::NonnullGCPtr<FileAPI::Blob> blob) -> WebIDL::ExceptionOr<Variant<JS::Handle<FileAPI::File>, String>> {
[&](GC::Ref<FileAPI::Blob> blob) -> WebIDL::ExceptionOr<Variant<GC::Root<FileAPI::File>, String>> {
// 1. If value is not a File object, then set value to a new File object, representing the same bytes, whose
// name attribute value is "blob".
if (!is<FileAPI::File>(*blob)) {
FileAPI::FilePropertyBag options {};
options.type = blob->type();
blob = TRY(FileAPI::File::create(realm, { JS::make_handle(*blob) }, "blob"_string, move(options)));
blob = TRY(FileAPI::File::create(realm, { GC::make_root(*blob) }, "blob"_string, move(options)));
}
// 2. If filename is given, then set value to a new File object, representing the same bytes, whose name
@ -48,10 +48,10 @@ WebIDL::ExceptionOr<XHR::FormDataEntry> create_entry(JS::Realm& realm, String co
FileAPI::FilePropertyBag options {};
options.type = blob->type();
blob = TRY(FileAPI::File::create(realm, { JS::make_handle(*blob) }, *filename, move(options)));
blob = TRY(FileAPI::File::create(realm, { GC::make_root(*blob) }, *filename, move(options)));
}
return JS::make_handle(verify_cast<FileAPI::File>(*blob));
return GC::make_root(verify_cast<FileAPI::File>(*blob));
}));
// 4. Return an entry whose name is name and whose value is value.
@ -62,7 +62,7 @@ WebIDL::ExceptionOr<XHR::FormDataEntry> create_entry(JS::Realm& realm, String co
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-the-form-data-set
WebIDL::ExceptionOr<Optional<Vector<XHR::FormDataEntry>>> construct_entry_list(JS::Realm& realm, HTMLFormElement& form, JS::GCPtr<HTMLElement> submitter, Optional<String> encoding)
WebIDL::ExceptionOr<Optional<Vector<XHR::FormDataEntry>>> construct_entry_list(JS::Realm& realm, HTMLFormElement& form, GC::Ptr<HTMLElement> submitter, Optional<String> encoding)
{
// 1. If form's constructing entry list is true, then return null.
if (form.constructing_entry_list())
@ -165,13 +165,13 @@ WebIDL::ExceptionOr<Optional<Vector<XHR::FormDataEntry>>> construct_entry_list(J
FileAPI::FilePropertyBag options {};
options.type = "application/octet-stream"_string;
auto file = TRY(FileAPI::File::create(realm, {}, String {}, options));
entry_list.append(XHR::FormDataEntry { .name = name.to_string(), .value = JS::make_handle(file) });
entry_list.append(XHR::FormDataEntry { .name = name.to_string(), .value = GC::make_root(file) });
}
// 2. Otherwise, for each file in selected files, create an entry with name and a File object representing the file, and append it to entry list.
else {
for (size_t i = 0; i < file_element->files()->length(); i++) {
auto file = JS::NonnullGCPtr { *file_element->files()->item(i) };
entry_list.append(XHR::FormDataEntry { .name = name.to_string(), .value = JS::make_handle(file) });
auto file = GC::Ref { *file_element->files()->item(i) };
entry_list.append(XHR::FormDataEntry { .name = name.to_string(), .value = GC::make_root(file) });
}
}
}
@ -272,7 +272,7 @@ ErrorOr<SerializedFormData> serialize_to_multipart_form_data(Vector<XHR::FormDat
auto escaped_name = TRY(escape_line_feed_carriage_return_double_quote(normalized_name));
TRY(entry.value.visit(
[&](JS::Handle<FileAPI::File> const& file) -> ErrorOr<void> {
[&](GC::Root<FileAPI::File> const& file) -> ErrorOr<void> {
// For filenames replace any 0x0A (LF) bytes with the byte sequence `%0A`, 0x0D (CR) with `%0D` and 0x22 (") with `%22`
auto escaped_filename = TRY(escape_line_feed_carriage_return_double_quote(file->name()));
// Add a `Content-Disposition` header with a `name` set to entry's name and `filename` set to entry's filename.

View file

@ -15,8 +15,8 @@ struct SerializedFormData {
ByteBuffer serialized_data;
};
WebIDL::ExceptionOr<XHR::FormDataEntry> create_entry(JS::Realm& realm, String const& name, Variant<JS::NonnullGCPtr<FileAPI::Blob>, String> const& value, Optional<String> const& filename = {});
WebIDL::ExceptionOr<Optional<Vector<XHR::FormDataEntry>>> construct_entry_list(JS::Realm&, HTMLFormElement&, JS::GCPtr<HTMLElement> submitter = nullptr, Optional<String> encoding = Optional<String> {});
WebIDL::ExceptionOr<XHR::FormDataEntry> create_entry(JS::Realm& realm, String const& name, Variant<GC::Ref<FileAPI::Blob>, String> const& value, Optional<String> const& filename = {});
WebIDL::ExceptionOr<Optional<Vector<XHR::FormDataEntry>>> construct_entry_list(JS::Realm&, HTMLFormElement&, GC::Ptr<HTMLElement> submitter = nullptr, Optional<String> encoding = Optional<String> {});
ErrorOr<String> normalize_line_breaks(StringView value);
ErrorOr<SerializedFormData> serialize_to_multipart_form_data(Vector<XHR::FormDataEntry> const& entry_list);

View file

@ -10,9 +10,9 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(FormDataEvent);
GC_DEFINE_ALLOCATOR(FormDataEvent);
WebIDL::ExceptionOr<JS::NonnullGCPtr<FormDataEvent>> FormDataEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, FormDataEventInit const& event_init)
WebIDL::ExceptionOr<GC::Ref<FormDataEvent>> FormDataEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, FormDataEventInit const& event_init)
{
return realm.create<FormDataEvent>(realm, event_name, event_init);
}

View file

@ -12,19 +12,19 @@
namespace Web::HTML {
struct FormDataEventInit : public DOM::EventInit {
JS::GCPtr<XHR::FormData> form_data {};
GC::Ptr<XHR::FormData> form_data {};
};
class FormDataEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(FormDataEvent, DOM::Event);
JS_DECLARE_ALLOCATOR(FormDataEvent);
GC_DECLARE_ALLOCATOR(FormDataEvent);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<FormDataEvent>> construct_impl(JS::Realm&, FlyString const& event_name, FormDataEventInit const& event_init);
static WebIDL::ExceptionOr<GC::Ref<FormDataEvent>> construct_impl(JS::Realm&, FlyString const& event_name, FormDataEventInit const& event_init);
virtual ~FormDataEvent() override;
JS::GCPtr<XHR::FormData> form_data() const { return m_form_data; }
GC::Ptr<XHR::FormData> form_data() const { return m_form_data; }
private:
FormDataEvent(JS::Realm&, FlyString const& event_name, FormDataEventInit const& event_init);
@ -33,7 +33,7 @@ private:
virtual void visit_edges(Cell::Visitor&) override;
JS::GCPtr<XHR::FormData> m_form_data;
GC::Ptr<XHR::FormData> m_form_data;
};
}

View file

@ -94,7 +94,7 @@ public:
#undef __ENUMERATE
protected:
virtual JS::GCPtr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const& event_name) = 0;
virtual GC::Ptr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const& event_name) = 0;
};
}

View file

@ -30,9 +30,9 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(HTMLAllCollection);
GC_DEFINE_ALLOCATOR(HTMLAllCollection);
JS::NonnullGCPtr<HTMLAllCollection> HTMLAllCollection::create(DOM::ParentNode& root, Scope scope, Function<bool(DOM::Element const&)> filter)
GC::Ref<HTMLAllCollection> HTMLAllCollection::create(DOM::ParentNode& root, Scope scope, Function<bool(DOM::Element const&)> filter)
{
return root.realm().create<HTMLAllCollection>(root, scope, move(filter));
}
@ -84,9 +84,9 @@ static bool is_all_named_element(DOM::Element const& element)
|| is<HTML::HTMLTextAreaElement>(element);
}
JS::MarkedVector<JS::NonnullGCPtr<DOM::Element>> HTMLAllCollection::collect_matching_elements() const
GC::MarkedVector<GC::Ref<DOM::Element>> HTMLAllCollection::collect_matching_elements() const
{
JS::MarkedVector<JS::NonnullGCPtr<DOM::Element>> elements(m_root->heap());
GC::MarkedVector<GC::Ref<DOM::Element>> elements(m_root->heap());
if (m_scope == Scope::Descendants) {
m_root->for_each_in_subtree_of_type<DOM::Element>([&](auto& element) {
if (m_filter(element))
@ -111,7 +111,7 @@ size_t HTMLAllCollection::length() const
}
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmlallcollection-item
Variant<JS::NonnullGCPtr<DOM::HTMLCollection>, JS::NonnullGCPtr<DOM::Element>, Empty> HTMLAllCollection::item(Optional<FlyString> const& name_or_index) const
Variant<GC::Ref<DOM::HTMLCollection>, GC::Ref<DOM::Element>, Empty> HTMLAllCollection::item(Optional<FlyString> const& name_or_index) const
{
// 1. If nameOrIndex was not provided, return null.
if (!name_or_index.has_value())
@ -122,7 +122,7 @@ Variant<JS::NonnullGCPtr<DOM::HTMLCollection>, JS::NonnullGCPtr<DOM::Element>, E
}
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmlallcollection-nameditem
Variant<JS::NonnullGCPtr<DOM::HTMLCollection>, JS::NonnullGCPtr<DOM::Element>, Empty> HTMLAllCollection::named_item(FlyString const& name) const
Variant<GC::Ref<DOM::HTMLCollection>, GC::Ref<DOM::Element>, Empty> HTMLAllCollection::named_item(FlyString const& name) const
{
// The namedItem(name) method steps are to return the result of getting the "all"-named element(s) from this given name.
return get_the_all_named_elements(name);
@ -158,7 +158,7 @@ Vector<FlyString> HTMLAllCollection::supported_property_names() const
}
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#concept-get-all-named
Variant<JS::NonnullGCPtr<DOM::HTMLCollection>, JS::NonnullGCPtr<DOM::Element>, Empty> HTMLAllCollection::get_the_all_named_elements(FlyString const& name) const
Variant<GC::Ref<DOM::HTMLCollection>, GC::Ref<DOM::Element>, Empty> HTMLAllCollection::get_the_all_named_elements(FlyString const& name) const
{
// 1. If name is the empty string, return null.
if (name.is_empty())
@ -188,7 +188,7 @@ Variant<JS::NonnullGCPtr<DOM::HTMLCollection>, JS::NonnullGCPtr<DOM::Element>, E
}
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#concept-get-all-indexed
JS::GCPtr<DOM::Element> HTMLAllCollection::get_the_all_indexed_element(u32 index) const
GC::Ptr<DOM::Element> HTMLAllCollection::get_the_all_indexed_element(u32 index) const
{
// To get the "all"-indexed element from an HTMLAllCollection collection given an index index, return the indexth
// element in collection, or null if there is no such indexth element.
@ -199,7 +199,7 @@ JS::GCPtr<DOM::Element> HTMLAllCollection::get_the_all_indexed_element(u32 index
}
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#concept-get-all-indexed-or-named
Variant<JS::NonnullGCPtr<DOM::HTMLCollection>, JS::NonnullGCPtr<DOM::Element>, Empty> HTMLAllCollection::get_the_all_indexed_or_named_elements(JS::PropertyKey const& name_or_index) const
Variant<GC::Ref<DOM::HTMLCollection>, GC::Ref<DOM::Element>, Empty> HTMLAllCollection::get_the_all_indexed_or_named_elements(JS::PropertyKey const& name_or_index) const
{
// 1. If nameOrIndex, converted to a JavaScript String value, is an array index property name, return the result of getting the "all"-indexed element from
// collection given the number represented by nameOrIndex.
@ -207,7 +207,7 @@ Variant<JS::NonnullGCPtr<DOM::HTMLCollection>, JS::NonnullGCPtr<DOM::Element>, E
auto maybe_element = get_the_all_indexed_element(name_or_index.as_number());
if (!maybe_element)
return Empty {};
return JS::NonnullGCPtr<DOM::Element> { *maybe_element };
return GC::Ref<DOM::Element> { *maybe_element };
}
// 2. Return the result of getting the "all"-named element(s) from collection given nameOrIndex.

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/Function.h>
#include <LibGC/Ptr.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/HTMLCollection.h>
#include <LibWeb/Forward.h>
@ -17,22 +17,22 @@ namespace Web::HTML {
class HTMLAllCollection : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(HTMLAllCollection, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(HTMLAllCollection);
GC_DECLARE_ALLOCATOR(HTMLAllCollection);
public:
enum class Scope {
Children,
Descendants,
};
[[nodiscard]] static JS::NonnullGCPtr<HTMLAllCollection> create(DOM::ParentNode& root, Scope, ESCAPING Function<bool(DOM::Element const&)> filter);
[[nodiscard]] static GC::Ref<HTMLAllCollection> create(DOM::ParentNode& root, Scope, ESCAPING Function<bool(DOM::Element const&)> filter);
virtual ~HTMLAllCollection() override;
size_t length() const;
Variant<JS::NonnullGCPtr<DOM::HTMLCollection>, JS::NonnullGCPtr<DOM::Element>, Empty> item(Optional<FlyString> const& name_or_index) const;
Variant<JS::NonnullGCPtr<DOM::HTMLCollection>, JS::NonnullGCPtr<DOM::Element>, Empty> named_item(FlyString const& name) const;
Variant<GC::Ref<DOM::HTMLCollection>, GC::Ref<DOM::Element>, Empty> item(Optional<FlyString> const& name_or_index) const;
Variant<GC::Ref<DOM::HTMLCollection>, GC::Ref<DOM::Element>, Empty> named_item(FlyString const& name) const;
JS::MarkedVector<JS::NonnullGCPtr<DOM::Element>> collect_matching_elements() const;
GC::MarkedVector<GC::Ref<DOM::Element>> collect_matching_elements() const;
virtual Optional<JS::Value> item_value(size_t index) const override;
virtual JS::Value named_item_value(FlyString const& name) const override;
@ -46,13 +46,13 @@ protected:
virtual bool is_htmldda() const override { return true; }
private:
Variant<JS::NonnullGCPtr<DOM::HTMLCollection>, JS::NonnullGCPtr<DOM::Element>, Empty> get_the_all_named_elements(FlyString const& name) const;
JS::GCPtr<DOM::Element> get_the_all_indexed_element(u32 index) const;
Variant<JS::NonnullGCPtr<DOM::HTMLCollection>, JS::NonnullGCPtr<DOM::Element>, Empty> get_the_all_indexed_or_named_elements(JS::PropertyKey const& name_or_index) const;
Variant<GC::Ref<DOM::HTMLCollection>, GC::Ref<DOM::Element>, Empty> get_the_all_named_elements(FlyString const& name) const;
GC::Ptr<DOM::Element> get_the_all_indexed_element(u32 index) const;
Variant<GC::Ref<DOM::HTMLCollection>, GC::Ref<DOM::Element>, Empty> get_the_all_indexed_or_named_elements(JS::PropertyKey const& name_or_index) const;
virtual void visit_edges(Cell::Visitor&) override;
JS::NonnullGCPtr<DOM::ParentNode> m_root;
GC::Ref<DOM::ParentNode> m_root;
Function<bool(DOM::Element const&)> m_filter;
Scope m_scope { Scope::Descendants };
};

View file

@ -19,7 +19,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(HTMLAnchorElement);
GC_DEFINE_ALLOCATOR(HTMLAnchorElement);
HTMLAnchorElement::HTMLAnchorElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
@ -155,7 +155,7 @@ Optional<ARIA::Role> HTMLAnchorElement::default_role() const
}
// https://html.spec.whatwg.org/multipage/text-level-semantics.html#dom-a-rellist
JS::NonnullGCPtr<DOM::DOMTokenList> HTMLAnchorElement::rel_list()
GC::Ref<DOM::DOMTokenList> HTMLAnchorElement::rel_list()
{
// The IDL attribute relList must reflect the rel content attribute.
if (!m_rel_list)

View file

@ -15,7 +15,7 @@ class HTMLAnchorElement final
: public HTMLElement
, public HTMLHyperlinkElementUtils {
WEB_PLATFORM_OBJECT(HTMLAnchorElement, HTMLElement);
JS_DECLARE_ALLOCATOR(HTMLAnchorElement);
GC_DECLARE_ALLOCATOR(HTMLAnchorElement);
public:
virtual ~HTMLAnchorElement() override;
@ -24,7 +24,7 @@ public:
String target() const { return get_attribute_value(HTML::AttributeNames::target); }
String download() const { return get_attribute_value(HTML::AttributeNames::download); }
JS::NonnullGCPtr<DOM::DOMTokenList> rel_list();
GC::Ref<DOM::DOMTokenList> rel_list();
String text() const;
void set_text(String const&);
@ -72,7 +72,7 @@ private:
virtual Optional<ARIA::Role> default_role() const override;
JS::GCPtr<DOM::DOMTokenList> m_rel_list;
GC::Ptr<DOM::DOMTokenList> m_rel_list;
};
}

View file

@ -12,7 +12,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(HTMLAreaElement);
GC_DEFINE_ALLOCATOR(HTMLAreaElement);
HTMLAreaElement::HTMLAreaElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
@ -46,7 +46,7 @@ void HTMLAreaElement::attribute_changed(FlyString const& name, Optional<String>
}
// https://html.spec.whatwg.org/multipage/image-maps.html#dom-area-rellist
JS::NonnullGCPtr<DOM::DOMTokenList> HTMLAreaElement::rel_list()
GC::Ref<DOM::DOMTokenList> HTMLAreaElement::rel_list()
{
// The IDL attribute relList must reflect the rel content attribute.
if (!m_rel_list)

View file

@ -16,11 +16,11 @@ class HTMLAreaElement final
: public HTMLElement
, public HTMLHyperlinkElementUtils {
WEB_PLATFORM_OBJECT(HTMLAreaElement, HTMLElement);
JS_DECLARE_ALLOCATOR(HTMLAreaElement);
GC_DECLARE_ALLOCATOR(HTMLAreaElement);
public:
virtual ~HTMLAreaElement() override;
JS::NonnullGCPtr<DOM::DOMTokenList> rel_list();
GC::Ref<DOM::DOMTokenList> rel_list();
private:
HTMLAreaElement(DOM::Document&, DOM::QualifiedName);
@ -55,7 +55,7 @@ private:
virtual Optional<ARIA::Role> default_role() const override;
JS::GCPtr<DOM::DOMTokenList> m_rel_list;
GC::Ptr<DOM::DOMTokenList> m_rel_list;
};
}

View file

@ -14,7 +14,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(HTMLAudioElement);
GC_DEFINE_ALLOCATOR(HTMLAudioElement);
HTMLAudioElement::HTMLAudioElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLMediaElement(document, move(qualified_name))
@ -29,7 +29,7 @@ void HTMLAudioElement::initialize(JS::Realm& realm)
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLAudioElement);
}
JS::GCPtr<Layout::Node> HTMLAudioElement::create_layout_node(CSS::StyleProperties style)
GC::Ptr<Layout::Node> HTMLAudioElement::create_layout_node(CSS::StyleProperties style)
{
return heap().allocate<Layout::AudioBox>(document(), *this, move(style));
}

View file

@ -12,7 +12,7 @@ namespace Web::HTML {
class HTMLAudioElement final : public HTMLMediaElement {
WEB_PLATFORM_OBJECT(HTMLAudioElement, HTMLMediaElement);
JS_DECLARE_ALLOCATOR(HTMLAudioElement);
GC_DECLARE_ALLOCATOR(HTMLAudioElement);
public:
virtual ~HTMLAudioElement() override;
@ -25,7 +25,7 @@ private:
virtual void initialize(JS::Realm&) override;
virtual JS::GCPtr<Layout::Node> create_layout_node(CSS::StyleProperties) override;
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::StyleProperties) override;
virtual void adjust_computed_style(CSS::StyleProperties&) override;
virtual void on_playing() override;

View file

@ -12,7 +12,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(HTMLBRElement);
GC_DEFINE_ALLOCATOR(HTMLBRElement);
HTMLBRElement::HTMLBRElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
@ -27,7 +27,7 @@ void HTMLBRElement::initialize(JS::Realm& realm)
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLBRElement);
}
JS::GCPtr<Layout::Node> HTMLBRElement::create_layout_node(CSS::StyleProperties style)
GC::Ptr<Layout::Node> HTMLBRElement::create_layout_node(CSS::StyleProperties style)
{
return heap().allocate<Layout::BreakNode>(document(), *this, move(style));
}

View file

@ -12,12 +12,12 @@ namespace Web::HTML {
class HTMLBRElement final : public HTMLElement {
WEB_PLATFORM_OBJECT(HTMLBRElement, HTMLElement);
JS_DECLARE_ALLOCATOR(HTMLBRElement);
GC_DECLARE_ALLOCATOR(HTMLBRElement);
public:
virtual ~HTMLBRElement() override;
virtual JS::GCPtr<Layout::Node> create_layout_node(CSS::StyleProperties) override;
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::StyleProperties) override;
virtual void adjust_computed_style(CSS::StyleProperties&) override;
private:

View file

@ -10,7 +10,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(HTMLBaseElement);
GC_DEFINE_ALLOCATOR(HTMLBaseElement);
HTMLBaseElement::HTMLBaseElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))

View file

@ -12,7 +12,7 @@ namespace Web::HTML {
class HTMLBaseElement final : public HTMLElement {
WEB_PLATFORM_OBJECT(HTMLBaseElement, HTMLElement);
JS_DECLARE_ALLOCATOR(HTMLBaseElement);
GC_DECLARE_ALLOCATOR(HTMLBaseElement);
public:
virtual ~HTMLBaseElement() override;

View file

@ -17,7 +17,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(HTMLBodyElement);
GC_DEFINE_ALLOCATOR(HTMLBodyElement);
HTMLBodyElement::HTMLBodyElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
@ -96,7 +96,7 @@ void HTMLBodyElement::attribute_changed(FlyString const& name, Optional<String>
#undef __ENUMERATE
}
JS::GCPtr<DOM::EventTarget> HTMLBodyElement::global_event_handlers_to_event_target(FlyString const& event_name)
GC::Ptr<DOM::EventTarget> HTMLBodyElement::global_event_handlers_to_event_target(FlyString const& event_name)
{
// NOTE: This is a little weird, but IIUC document.body.onload actually refers to window.onload
// NOTE: document.body can return either a HTMLBodyElement or HTMLFrameSetElement, so both these elements must support this mapping.
@ -106,7 +106,7 @@ JS::GCPtr<DOM::EventTarget> HTMLBodyElement::global_event_handlers_to_event_targ
return *this;
}
JS::GCPtr<DOM::EventTarget> HTMLBodyElement::window_event_handlers_to_event_target()
GC::Ptr<DOM::EventTarget> HTMLBodyElement::window_event_handlers_to_event_target()
{
// All WindowEventHandlers on HTMLFrameSetElement (e.g. document.body.onrejectionhandled) are mapped to window.on{event}.
// NOTE: document.body can return either a HTMLBodyElement or HTMLFrameSetElement, so both these elements must support this mapping.

View file

@ -16,7 +16,7 @@ class HTMLBodyElement final
: public HTMLElement
, public WindowEventHandlers {
WEB_PLATFORM_OBJECT(HTMLBodyElement, HTMLElement);
JS_DECLARE_ALLOCATOR(HTMLBodyElement);
GC_DECLARE_ALLOCATOR(HTMLBodyElement);
public:
virtual ~HTMLBodyElement() override;
@ -38,10 +38,10 @@ private:
virtual void initialize(JS::Realm&) override;
// ^HTML::GlobalEventHandlers
virtual JS::GCPtr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const& event_name) override;
virtual GC::Ptr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const& event_name) override;
// ^HTML::WindowEventHandlers
virtual JS::GCPtr<DOM::EventTarget> window_event_handlers_to_event_target() override;
virtual GC::Ptr<DOM::EventTarget> window_event_handlers_to_event_target() override;
RefPtr<CSS::ImageStyleValue> m_background_style_value;
};

View file

@ -11,7 +11,7 @@
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(HTMLButtonElement);
GC_DEFINE_ALLOCATOR(HTMLButtonElement);
HTMLButtonElement::HTMLButtonElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))

View file

@ -21,7 +21,7 @@ class HTMLButtonElement final
: public HTMLElement
, public FormAssociatedElement {
WEB_PLATFORM_OBJECT(HTMLButtonElement, HTMLElement);
JS_DECLARE_ALLOCATOR(HTMLButtonElement);
GC_DECLARE_ALLOCATOR(HTMLButtonElement);
FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLButtonElement)
public:

Some files were not shown because too many files have changed in this diff Show more