script/drag/
document_selection_drag.rs1use js::context::JSContext;
6
7use crate::dom::NodeTraits;
8use crate::dom::inputevent::HitTestResult;
9
10#[derive(JSTraceable, MallocSizeOf)]
11#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
12pub(crate) struct DocumentSelectionDragHandler;
13
14impl DocumentSelectionDragHandler {
15 pub(crate) fn still_connected(&self) -> bool {
16 true
17 }
18
19 pub(crate) fn moved(&self, cx: &mut JSContext, hit_test_result: &HitTestResult) -> bool {
23 let Some((container, offset)) = hit_test_result.dom_position_for_selection.as_ref() else {
24 return true;
25 };
26 let Some(selection) = container.owner_document().selection() else {
27 return true;
28 };
29 selection.collapse_or_extend_to_dom_position(cx, container, *offset);
30 true
31 }
32}