mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibJS+LibWeb: Add JS::Object::fast_is<T> helpers for some LibWeb types
These are slightly unfortunate as we're crossing the library boundary, but there's precedent with Object::is_dom_node(), and these are just knocking down a few more items that were showing up in profiles.
This commit is contained in:
parent
207afb0d3b
commit
d8188c9f14
Notes:
github-actions[bot]
2025-04-18 12:47:12 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/d8188c9f141 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4395
5 changed files with 24 additions and 0 deletions
|
@ -190,6 +190,11 @@ public:
|
|||
void define_native_accessor(Realm&, PropertyKey const&, ESCAPING Function<ThrowCompletionOr<Value>(VM&)> getter, ESCAPING Function<ThrowCompletionOr<Value>(VM&)> setter, PropertyAttributes attributes);
|
||||
|
||||
virtual bool is_dom_node() const { return false; }
|
||||
virtual bool is_dom_event() const { return false; }
|
||||
virtual bool is_html_window() const { return false; }
|
||||
virtual bool is_html_window_proxy() const { return false; }
|
||||
virtual bool is_html_location() const { return false; }
|
||||
|
||||
virtual bool is_function() const { return false; }
|
||||
virtual bool is_promise() const { return false; }
|
||||
virtual bool is_error() const { return false; }
|
||||
|
|
|
@ -159,6 +159,8 @@ protected:
|
|||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
private:
|
||||
virtual bool is_dom_event() const final { return true; }
|
||||
|
||||
FlyString m_type;
|
||||
GC::Ptr<EventTarget> m_target;
|
||||
GC::Ptr<EventTarget> m_related_target;
|
||||
|
@ -188,3 +190,6 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool JS::Object::fast_is<Web::DOM::Event>() const { return is_dom_event(); }
|
||||
|
|
|
@ -71,6 +71,8 @@ public:
|
|||
private:
|
||||
explicit Location(JS::Realm&);
|
||||
|
||||
virtual bool is_html_location() const override { return true; }
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
|
@ -86,3 +88,6 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool JS::Object::fast_is<Web::HTML::Location>() const { return is_html_location(); }
|
||||
|
|
|
@ -274,6 +274,8 @@ private:
|
|||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual void finalize() override;
|
||||
|
||||
virtual bool is_html_window() const override { return true; }
|
||||
|
||||
// ^HTML::GlobalEventHandlers
|
||||
virtual GC::Ptr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const&) override { return *this; }
|
||||
|
||||
|
@ -356,3 +358,6 @@ private:
|
|||
void run_animation_frame_callbacks(DOM::Document&, double now);
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool JS::Object::fast_is<Web::HTML::Window>() const { return is_html_window(); }
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
private:
|
||||
explicit WindowProxy(JS::Realm&);
|
||||
|
||||
virtual bool is_html_window_proxy() const override { return true; }
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
|
||||
// [[Window]], https://html.spec.whatwg.org/multipage/window-object.html#concept-windowproxy-window
|
||||
|
@ -47,3 +48,6 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool JS::Object::fast_is<Web::HTML::WindowProxy>() const { return is_html_window_proxy(); }
|
||||
|
|
Loading…
Add table
Reference in a new issue