LibWeb: Ensure EventHandler visits its mouse selection target

We hold a raw pointer to the mouse selection target, which is a mixin-
style class inherited only by JS::Cell classes. By not visiting this
object, we sometime had a dangling reference to it after it had been
garbage collected.
This commit is contained in:
Timothy Flynn 2025-02-26 20:40:10 -05:00 committed by Sam Atkins
commit d5be18617e
Notes: github-actions[bot] 2025-02-27 09:54:17 +00:00
7 changed files with 56 additions and 2 deletions

View file

@ -969,4 +969,9 @@ GC::Ptr<DOM::Position> FormAssociatedTextControlElement::cursor_position() const
return nullptr;
}
GC::Ref<JS::Cell> FormAssociatedTextControlElement::as_cell()
{
return form_associated_element_to_html_element();
}
}

View file

@ -160,7 +160,8 @@ enum class SelectionSource {
DOM,
};
class FormAssociatedTextControlElement : public FormAssociatedElement
class FormAssociatedTextControlElement
: public FormAssociatedElement
, public InputEventsTarget {
public:
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-textarea/input-relevant-value
@ -231,6 +232,8 @@ protected:
void relevant_value_was_changed();
private:
virtual GC::Ref<JS::Cell> as_cell() override;
void collapse_selection_to_offset(size_t);
void selection_was_changed();