1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:27:35 +00:00

AK: Rename downcast<T> => verify_cast<T>

This makes it much clearer what this cast actually does: it will
VERIFY that the thing we're casting is a T (using is<T>()).
This commit is contained in:
Andreas Kling 2021-06-24 19:53:42 +02:00
parent 6215a9c2cb
commit ee3a73ddbb
61 changed files with 262 additions and 262 deletions

View file

@ -54,7 +54,7 @@ void StackWidget::child_event(Core::ChildEvent& event)
{
if (!event.child() || !is<Widget>(*event.child()))
return Widget::child_event(event);
auto& child = downcast<Widget>(*event.child());
auto& child = verify_cast<Widget>(*event.child());
if (event.type() == Event::ChildAdded) {
if (!m_active_widget)
set_active_widget(&child);

View file

@ -134,7 +134,7 @@ void TabWidget::child_event(Core::ChildEvent& event)
{
if (!event.child() || !is<Widget>(*event.child()))
return Widget::child_event(event);
auto& child = downcast<Widget>(*event.child());
auto& child = verify_cast<Widget>(*event.child());
if (event.type() == Event::ChildAdded) {
if (!m_active_widget)
set_active_widget(&child);

View file

@ -147,22 +147,22 @@ void Widget::child_event(Core::ChildEvent& event)
if (event.type() == Event::ChildAdded) {
if (event.child() && is<Widget>(*event.child()) && layout()) {
if (event.insertion_before_child() && is<Widget>(event.insertion_before_child()))
layout()->insert_widget_before(downcast<Widget>(*event.child()), downcast<Widget>(*event.insertion_before_child()));
layout()->insert_widget_before(verify_cast<Widget>(*event.child()), verify_cast<Widget>(*event.insertion_before_child()));
else
layout()->add_widget(downcast<Widget>(*event.child()));
layout()->add_widget(verify_cast<Widget>(*event.child()));
}
if (window() && event.child() && is<Widget>(*event.child()))
window()->did_add_widget({}, downcast<Widget>(*event.child()));
window()->did_add_widget({}, verify_cast<Widget>(*event.child()));
}
if (event.type() == Event::ChildRemoved) {
if (layout()) {
if (event.child() && is<Widget>(*event.child()))
layout()->remove_widget(downcast<Widget>(*event.child()));
layout()->remove_widget(verify_cast<Widget>(*event.child()));
else
invalidate_layout();
}
if (window() && event.child() && is<Widget>(*event.child()))
window()->did_remove_widget({}, downcast<Widget>(*event.child()));
window()->did_remove_widget({}, verify_cast<Widget>(*event.child()));
update();
}
return Core::Object::child_event(event);
@ -563,7 +563,7 @@ Widget* Widget::child_at(const Gfx::IntPoint& point) const
for (int i = children().size() - 1; i >= 0; --i) {
if (!is<Widget>(children()[i]))
continue;
auto& child = downcast<Widget>(children()[i]);
auto& child = verify_cast<Widget>(children()[i]);
if (!child.is_visible())
continue;
if (child.content_rect().contains(point))

View file

@ -245,7 +245,7 @@ public:
{
for_each_child([&](auto& child) {
if (is<Widget>(child))
return callback(downcast<Widget>(child));
return callback(verify_cast<Widget>(child));
return IterationDecision::Continue;
});
}
@ -370,13 +370,13 @@ private:
inline Widget* Widget::parent_widget()
{
if (parent() && is<Widget>(*parent()))
return &downcast<Widget>(*parent());
return &verify_cast<Widget>(*parent());
return nullptr;
}
inline const Widget* Widget::parent_widget() const
{
if (parent() && is<Widget>(*parent()))
return &downcast<const Widget>(*parent());
return &verify_cast<const Widget>(*parent());
return nullptr;
}
}