mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
LibWeb: Make HostDefined and Intrinsics free functions [[nodiscard]]
Hopefully no one else will forget to call set_prototype with the cached prototype they just retrieved from a realm and spend a long time wondering why their object has no properties...
This commit is contained in:
parent
2d5bee256e
commit
07b950d8a6
Notes:
sideshowbarker
2024-07-17 06:54:15 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/07b950d8a6 Pull-request: https://github.com/SerenityOS/serenity/pull/15520
|
@ -27,7 +27,7 @@ struct HostDefined : public JS::Realm::HostDefined {
|
|||
JS::NonnullGCPtr<Intrinsics> intrinsics;
|
||||
};
|
||||
|
||||
inline HTML::EnvironmentSettingsObject& host_defined_environment_settings_object(JS::Realm& realm)
|
||||
[[nodiscard]] inline HTML::EnvironmentSettingsObject& host_defined_environment_settings_object(JS::Realm& realm)
|
||||
{
|
||||
return *verify_cast<HostDefined>(realm.host_defined())->environment_settings_object;
|
||||
}
|
||||
|
|
|
@ -60,24 +60,24 @@ private:
|
|||
JS::NonnullGCPtr<JS::Realm> m_realm;
|
||||
};
|
||||
|
||||
inline Intrinsics& host_defined_intrinsics(JS::Realm& realm)
|
||||
[[nodiscard]] inline Intrinsics& host_defined_intrinsics(JS::Realm& realm)
|
||||
{
|
||||
return *verify_cast<HostDefined>(realm.host_defined())->intrinsics;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JS::Object& ensure_web_prototype(JS::Realm& realm, String const& class_name)
|
||||
[[nodiscard]] JS::Object& ensure_web_prototype(JS::Realm& realm, String const& class_name)
|
||||
{
|
||||
return host_defined_intrinsics(realm).ensure_web_prototype<T>(class_name);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JS::NativeFunction& ensure_web_constructor(JS::Realm& realm, String const& class_name)
|
||||
[[nodiscard]] JS::NativeFunction& ensure_web_constructor(JS::Realm& realm, String const& class_name)
|
||||
{
|
||||
return host_defined_intrinsics(realm).ensure_web_constructor<T>(class_name);
|
||||
}
|
||||
|
||||
inline JS::Object& cached_web_prototype(JS::Realm& realm, String const& class_name)
|
||||
[[nodiscard]] inline JS::Object& cached_web_prototype(JS::Realm& realm, String const& class_name)
|
||||
{
|
||||
return host_defined_intrinsics(realm).cached_web_prototype(class_name);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue