1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 00:48:11 +00:00

LibCore: Remove some hand-rolled type information from Core::Object

Both is_action() and is_window() can be answered by RTTI.
This commit is contained in:
Andreas Kling 2021-01-01 15:58:07 +01:00
parent 32fd59b471
commit 42179715c3
5 changed files with 2 additions and 8 deletions

View file

@ -118,8 +118,6 @@ public:
void deferred_invoke(Function<void(Object&)>);
bool is_widget() const { return m_widget; }
virtual bool is_action() const { return false; }
virtual bool is_window() const { return false; }
void save_to(AK::JsonObject&);

View file

@ -144,8 +144,6 @@ public:
void set_group(Badge<ActionGroup>, ActionGroup*);
private:
virtual bool is_action() const override { return true; }
Action(const StringView& text, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
Action(const StringView& text, const Shortcut&, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
Action(const StringView& text, const Shortcut&, RefPtr<Gfx::Bitmap>&& icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);

View file

@ -45,7 +45,7 @@ int Dialog::exec()
{
ASSERT(!m_event_loop);
m_event_loop = make<Core::EventLoop>();
if (parent() && parent()->is_window()) {
if (parent() && is<Window>(parent())) {
auto& parent_window = *static_cast<Window*>(parent());
if (parent_window.is_visible()) {
center_within(parent_window);

View file

@ -142,7 +142,7 @@ void Window::show()
Window* Window::find_parent_window()
{
for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
if (ancestor->is_window())
if (is<Window>(ancestor))
return static_cast<Window*>(ancestor);
}
return nullptr;

View file

@ -204,8 +204,6 @@ protected:
virtual void wm_event(WMEvent&);
private:
virtual bool is_window() const override final { return true; }
void update_cursor();
void focus_a_widget_if_possible(FocusSource);