1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-24 01:15:07 +00:00
serenity/Userland/Libraries/LibWeb/Painting/Paintable.cpp
Aliaksandr Kalenik c7673605bb LibWeb: Move mouse wheel handling from Paintable to PaintableBox
It is only PaintableBox that can have scrollable overflow so it doesn't
make sense to have handle_mousewheel() implementation in Paintable.

Also new implementation of handle_mousewheel() takes in account overflow
limits from scrollable_overflow_rect().
2023-08-07 05:23:31 +02:00

86 lines
2.5 KiB
C++

/*
* Copyright (c) 2022-2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Painting/Paintable.h>
#include <LibWeb/Painting/PaintableBox.h>
namespace Web::Painting {
void Paintable::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_layout_node);
if (m_containing_block.has_value())
visitor.visit(m_containing_block.value());
}
Paintable::DispatchEventOfSameName Paintable::handle_mousedown(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned)
{
return DispatchEventOfSameName::Yes;
}
Paintable::DispatchEventOfSameName Paintable::handle_mouseup(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned)
{
return DispatchEventOfSameName::Yes;
}
Paintable::DispatchEventOfSameName Paintable::handle_mousemove(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned)
{
return DispatchEventOfSameName::Yes;
}
bool Paintable::handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned, int, int)
{
return false;
}
Optional<HitTestResult> Paintable::hit_test(CSSPixelPoint, HitTestType) const
{
return {};
}
Paintable const* Paintable::first_child() const
{
auto const* layout_child = m_layout_node->first_child();
for (; layout_child && !layout_child->paintable(); layout_child = layout_child->next_sibling())
;
return layout_child ? layout_child->paintable() : nullptr;
}
Paintable const* Paintable::next_sibling() const
{
auto const* layout_node = m_layout_node->next_sibling();
for (; layout_node && !layout_node->paintable(); layout_node = layout_node->next_sibling())
;
return layout_node ? layout_node->paintable() : nullptr;
}
Paintable const* Paintable::last_child() const
{
auto const* layout_child = m_layout_node->last_child();
for (; layout_child && !layout_child->paintable(); layout_child = layout_child->previous_sibling())
;
return layout_child ? layout_child->paintable() : nullptr;
}
Paintable const* Paintable::previous_sibling() const
{
auto const* layout_node = m_layout_node->previous_sibling();
for (; layout_node && !layout_node->paintable(); layout_node = layout_node->previous_sibling())
;
return layout_node ? layout_node->paintable() : nullptr;
}
StackingContext const* Paintable::stacking_context_rooted_here() const
{
if (!layout_node().is_box())
return nullptr;
return static_cast<PaintableBox const&>(*this).stacking_context();
}
}