mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-14 02:46:57 +02:00
The Paintable tree and its supplemental painting data structures were GC allocated because that was the easiest way to manage it and avoid leaks introduced by ref cycles. This included the Paintable subclasses themselves plus StackingContext, ChromeWidget, Scrollbar, ResizeHandle, and scroll-frame state. We are now trying to reduce GC allocation churn on layout and painting updates, so keeping this short-lived rendering tree outside the JS heap is a better fit. Move Paintable to RefCountedTreeNode, make painting helpers ref-counted or weakly reference Paintables, and update the layout and event-handler call sites to use RefPtr/WeakPtr ownership.
42 lines
959 B
C++
42 lines
959 B
C++
/*
|
|
* Copyright (c) 2026, Jelle Raaijmakers <jelle@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGC/Ptr.h>
|
|
#include <LibJS/Heap/Cell.h>
|
|
#include <LibWeb/Forward.h>
|
|
#include <LibWeb/PixelUnits.h>
|
|
|
|
namespace Web {
|
|
|
|
class AutoScrollHandler {
|
|
public:
|
|
AutoScrollHandler(HTML::Navigable&, DOM::Element& container);
|
|
|
|
void visit_edges(JS::Cell::Visitor&) const;
|
|
|
|
CSSPixelPoint process(CSSPixelPoint mouse_position);
|
|
void perform_tick();
|
|
|
|
bool is_active() const { return m_active; }
|
|
|
|
static GC::Ptr<DOM::Element> find_scrollable_ancestor(Painting::Paintable const&);
|
|
static RefPtr<Painting::PaintableBox> auto_scroll_paintable(DOM::Element&);
|
|
|
|
private:
|
|
void activate();
|
|
void deactivate();
|
|
|
|
GC::Ref<HTML::Navigable> m_navigable;
|
|
GC::Ref<DOM::Element> m_container_element;
|
|
CSSPixelPoint m_mouse_position;
|
|
CSSPixelPoint m_fractional_delta;
|
|
bool m_active { false };
|
|
};
|
|
|
|
}
|