1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:37:42 +00:00

LibWeb: Switch to using AK::is and AK::downcast

This commit is contained in:
Andreas Kling 2020-07-26 17:16:18 +02:00
parent fe6474e692
commit 71556e39a4
73 changed files with 249 additions and 433 deletions

View file

@ -80,7 +80,7 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button
if (result.layout_node && result.layout_node->node()) {
RefPtr<Node> node = result.layout_node->node();
if (is<HTMLIFrameElement>(*node)) {
if (auto* subframe = to<HTMLIFrameElement>(*node).hosted_frame())
if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame())
return subframe->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers);
return false;
}
@ -113,7 +113,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
return false;
if (is<HTMLIFrameElement>(*node)) {
if (auto* subframe = to<HTMLIFrameElement>(*node).hosted_frame())
if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame())
return subframe->event_handler().handle_mousedown(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers);
return false;
}
@ -176,7 +176,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
RefPtr<Node> node = result.layout_node->node();
if (node && is<HTMLIFrameElement>(*node)) {
if (auto* subframe = to<HTMLIFrameElement>(*node).hosted_frame())
if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame())
return subframe->event_handler().handle_mousemove(position.translated(compute_mouse_event_offset({}, *result.layout_node)), buttons, modifiers);
return false;
}

View file

@ -125,7 +125,7 @@ void Frame::scroll_to_anchor(const String& fragment)
auto candidates = document()->get_elements_by_name(fragment);
for (auto* candidate : candidates) {
if (is<HTMLAnchorElement>(*candidate)) {
element = to<HTMLAnchorElement>(candidate);
element = downcast<HTMLAnchorElement>(candidate);
break;
}
}
@ -138,7 +138,7 @@ void Frame::scroll_to_anchor(const String& fragment)
Gfx::FloatRect float_rect { layout_node.box_type_agnostic_position(), { (float)viewport_rect().width(), (float)viewport_rect().height() } };
if (is<LayoutBox>(layout_node)) {
auto& layout_box = to<LayoutBox>(layout_node);
auto& layout_box = downcast<LayoutBox>(layout_node);
auto padding_box = layout_box.box_model().padding_box(layout_box);
float_rect.move_by(-padding_box.left, -padding_box.top);
}