LibJS+LibWeb: Add various fast_is<T>() helpers for common things

This commit is contained in:
Andreas Kling
2025-12-15 20:14:39 -06:00
committed by Andreas Kling
parent 9f4a96de67
commit 737d9727c2
Notes: github-actions[bot] 2025-12-20 15:14:14 +00:00
10 changed files with 69 additions and 0 deletions

View File

@@ -971,6 +971,9 @@ protected:
Document(JS::Realm&, URL::URL const&, TemporaryDocumentForFragmentParsing = TemporaryDocumentForFragmentParsing::No);
private:
// ^JS::Object
virtual bool is_dom_document() const final { return true; }
// ^HTML::GlobalEventHandlers
virtual GC::Ptr<EventTarget> global_event_handlers_to_event_target(FlyString const&) final { return *this; }
@@ -1372,3 +1375,10 @@ inline bool Node::fast_is<Document>() const { return is_document(); }
bool is_a_registrable_domain_suffix_of_or_is_equal_to(StringView host_suffix_string, URL::Host const& original_host);
}
namespace JS {
template<>
inline bool JS::Object::fast_is<Web::DOM::Document>() const { return is_dom_document(); }
}