mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb: Rename is_scrollable()
to could_be_scrolled_by_wheel_event()
Previous name for misleading because it checks if box could be scrolled by user input event which is diffent from checking if box is scrollable. For example box with `overflow: hidden` is scrollable but it can't be scrolled by user input event.
This commit is contained in:
parent
dd37d1c536
commit
74dde4dc0f
Notes:
github-actions[bot]
2025-01-30 23:39:27 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/74dde4dc0f2 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3410 Reviewed-by: https://github.com/gmta ✅
4 changed files with 10 additions and 10 deletions
|
@ -1651,7 +1651,7 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
|
|||
}
|
||||
|
||||
if (paintable_box()) {
|
||||
if (paintable_box()->is_scrollable()) {
|
||||
if (paintable_box()->could_be_scrolled_by_wheel_event()) {
|
||||
MUST(object.add("scrollable"sv, true));
|
||||
}
|
||||
if (!paintable_box()->is_visible()) {
|
||||
|
|
|
@ -335,7 +335,7 @@ void PaintableBox::after_paint(PaintContext& context, [[maybe_unused]] PaintPhas
|
|||
}
|
||||
}
|
||||
|
||||
bool PaintableBox::is_scrollable(ScrollDirection direction) const
|
||||
bool PaintableBox::could_be_scrolled_by_wheel_event(ScrollDirection direction) const
|
||||
{
|
||||
auto overflow = direction == ScrollDirection::Horizontal ? computed_values().overflow_x() : computed_values().overflow_y();
|
||||
auto scrollable_overflow_rect = this->scrollable_overflow_rect();
|
||||
|
@ -348,9 +348,9 @@ bool PaintableBox::is_scrollable(ScrollDirection direction) const
|
|||
return overflow == CSS::Overflow::Scroll;
|
||||
}
|
||||
|
||||
bool PaintableBox::is_scrollable() const
|
||||
bool PaintableBox::could_be_scrolled_by_wheel_event() const
|
||||
{
|
||||
return is_scrollable(ScrollDirection::Horizontal) || is_scrollable(ScrollDirection::Vertical);
|
||||
return could_be_scrolled_by_wheel_event(ScrollDirection::Horizontal) || could_be_scrolled_by_wheel_event(ScrollDirection::Vertical);
|
||||
}
|
||||
|
||||
static constexpr CSSPixels scrollbar_thumb_thickness = 8;
|
||||
|
@ -375,7 +375,7 @@ Optional<CSSPixelRect> PaintableBox::scroll_thumb_rect(ScrollDirection direction
|
|||
|
||||
Optional<PaintableBox::ScrollbarData> PaintableBox::compute_scrollbar_data(ScrollDirection direction) const
|
||||
{
|
||||
if (!is_scrollable(direction)) {
|
||||
if (!could_be_scrolled_by_wheel_event(direction)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -907,7 +907,7 @@ Paintable::DispatchEventOfSameName PaintableBox::handle_mousemove(Badge<EventHan
|
|||
|
||||
bool PaintableBox::handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned, int wheel_delta_x, int wheel_delta_y)
|
||||
{
|
||||
if (!is_scrollable()) {
|
||||
if (!could_be_scrolled_by_wheel_event()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1360,7 +1360,7 @@ PaintableBox const* PaintableBox::nearest_scrollable_ancestor() const
|
|||
{
|
||||
auto const* paintable = this->containing_block();
|
||||
while (paintable) {
|
||||
if (paintable->is_scrollable())
|
||||
if (paintable->could_be_scrolled_by_wheel_event())
|
||||
return paintable;
|
||||
if (paintable->is_fixed_position())
|
||||
return nullptr;
|
||||
|
|
|
@ -232,7 +232,7 @@ public:
|
|||
StickyInsets const& sticky_insets() const { return *m_sticky_insets; }
|
||||
void set_sticky_insets(OwnPtr<StickyInsets> sticky_insets) { m_sticky_insets = move(sticky_insets); }
|
||||
|
||||
[[nodiscard]] bool is_scrollable() const;
|
||||
[[nodiscard]] bool could_be_scrolled_by_wheel_event() const;
|
||||
|
||||
void set_used_values_for_grid_template_columns(RefPtr<CSS::GridTrackSizeListStyleValue> style_value) { m_used_values_for_grid_template_columns = move(style_value); }
|
||||
RefPtr<CSS::GridTrackSizeListStyleValue> const& used_values_for_grid_template_columns() const { return m_used_values_for_grid_template_columns; }
|
||||
|
@ -262,7 +262,7 @@ protected:
|
|||
};
|
||||
Optional<ScrollbarData> compute_scrollbar_data(ScrollDirection) const;
|
||||
[[nodiscard]] Optional<CSSPixelRect> scroll_thumb_rect(ScrollDirection) const;
|
||||
[[nodiscard]] bool is_scrollable(ScrollDirection) const;
|
||||
[[nodiscard]] bool could_be_scrolled_by_wheel_event(ScrollDirection) const;
|
||||
|
||||
TraversalDecision hit_test_scrollbars(CSSPixelPoint position, Function<TraversalDecision(HitTestResult)> const& callback) const;
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ void ViewportPaintable::refresh_scroll_state()
|
|||
CSSPixels min_x_offset_relative_to_nearest_scrollable_ancestor;
|
||||
CSSPixels max_x_offset_relative_to_nearest_scrollable_ancestor;
|
||||
auto const* containing_block_of_sticky_box = sticky_box.containing_block();
|
||||
if (containing_block_of_sticky_box->is_scrollable()) {
|
||||
if (containing_block_of_sticky_box->could_be_scrolled_by_wheel_event()) {
|
||||
min_y_offset_relative_to_nearest_scrollable_ancestor = 0;
|
||||
max_y_offset_relative_to_nearest_scrollable_ancestor = containing_block_of_sticky_box->scrollable_overflow_rect()->height() - sticky_box.absolute_border_box_rect().height();
|
||||
min_x_offset_relative_to_nearest_scrollable_ancestor = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue