#[repr(C)]pub(crate) struct Selection {
reflector_: Reflector,
document: Dom<Document>,
range: DomRefCell<Option<SelectionRange>>,
live_range: MutNullableDom<Range>,
direction: Cell<Direction>,
has_scheduled_selectionchange_event: Cell<bool>,
visible_selection_dirty: Cell<bool>,
}Expand description
Fields§
§reflector_: Reflector§document: Dom<Document>§range: DomRefCell<Option<SelectionRange>>A range that holds the start and end of this selection, which may potentially cross shadow roots.
live_range: MutNullableDom<Range>The live range version of this selection, which will never cross shadow roots.
direction: Cell<Direction>The Direction of this Selection which determines which endpoint of
Self::range is the anchor and which is the focus.
has_scheduled_selectionchange_event: Cell<bool>§visible_selection_dirty: Cell<bool>Whether or not this Selection needs to remark DOM nodes with selection flags
after a change to its underlying Range.
Implementations§
Source§impl Selection
impl Selection
fn __assert_parent_type(&self)
Source§impl Selection
impl Selection
Sourcepub(crate) fn delete_the_selection(
&self,
cx: &mut JSContext,
context_object: &Document,
block_merging: SelectionDeletionBlockMerging,
strip_wrappers: SelectionDeletionStripWrappers,
direction: SelectionDeleteDirection,
)
pub(crate) fn delete_the_selection( &self, cx: &mut JSContext, context_object: &Document, block_merging: SelectionDeletionBlockMerging, strip_wrappers: SelectionDeletionStripWrappers, direction: SelectionDeleteDirection, )
Sourcepub(crate) fn set_the_selection_value(
&self,
cx: &mut JSContext,
new_value: Option<DOMString>,
command: CommandName,
context_object: &Document,
)
pub(crate) fn set_the_selection_value( &self, cx: &mut JSContext, new_value: Option<DOMString>, command: CommandName, context_object: &Document, )
Source§impl Selection
impl Selection
fn new_inherited(document: &Document) -> Selection
pub(crate) fn new(cx: &mut JSContext, document: &Document) -> DomRoot<Selection>
pub(crate) fn visible_selection_dirty(&self) -> bool
fn clear_cached_live_range(&self)
pub(crate) fn update_from_live_range( &self, live_range: &Range, notification: SelectionLiveRangeNotification, )
fn set_range(&self, new_range: Option<SelectionRange>) -> bool
pub(crate) fn set_live_range(&self, new_range: Option<&Range>)
fn selection_boundaries_changed(&self)
fn iter_nodes_with_overlaps_document_selection_flag<'no_gc>( &self, no_gc: &'no_gc NoGC, ) -> impl Iterator<Item = UnrootedDom<'no_gc, Node>>
pub(crate) fn update_overlaps_document_selection_flags<'no_gc>( &self, no_gc: &'no_gc NoGC, )
Sourcepub(crate) fn queue_selectionchange_task(&self)
pub(crate) fn queue_selectionchange_task(&self)
fn is_in_document_of_range(&self, node: &Node) -> bool
pub(crate) fn start_boundary(&self, cx: &mut JSContext) -> (DomRoot<Node>, u32)
pub(crate) fn end_boundary(&self, cx: &mut JSContext) -> (DomRoot<Node>, u32)
fn assert_valid_selection(&self)
fn assert_valid_selection_and_live_range(&self)
Sourcepub(crate) fn active_range(&self, cx: &mut JSContext) -> Option<DomRoot<Range>>
pub(crate) fn active_range(&self, cx: &mut JSContext) -> Option<DomRoot<Range>>
https://w3c.github.io/editing/docs/execCommand/#active-range
The active range is the range of the selection given by calling getSelection() on the context object. (Thus the active range may be null.)
pub(crate) fn expect_active_range(&self, cx: &mut JSContext) -> DomRoot<Range>
pub(crate) fn set_visible_selection_dirty(&self)
fn composed_anchor_position(&self) -> Option<(DomRoot<Node>, u32)>
Sourcefn live_anchor_offset(&self, cx: &mut JSContext) -> u32
fn live_anchor_offset(&self, cx: &mut JSContext) -> u32
Sourcefn live_focus_offset(&self, cx: &mut JSContext) -> u32
fn live_focus_offset(&self, cx: &mut JSContext) -> u32
Sourcepub(crate) fn insert_steps(&self, parent: &Node, child: &Node, count: u32)
pub(crate) fn insert_steps(&self, parent: &Node, child: &Node, count: u32)
https://dom.spec.whatwg.org/#concept-node-insert steps 5.1-5.2 and https://dom.spec.whatwg.org/#move steps 17.1-17.2 adapted for selections.
Sourcepub(crate) fn remove_steps_for_removed_subtree(
&self,
inclusive_descendant_of_removed_node: &Node,
parent_of_removed_node: &Node,
index_of_removed_node: &mut dyn FnMut() -> u32,
)
pub(crate) fn remove_steps_for_removed_subtree( &self, inclusive_descendant_of_removed_node: &Node, parent_of_removed_node: &Node, index_of_removed_node: &mut dyn FnMut() -> u32, )
https://dom.spec.whatwg.org/#live-range-pre-remove-steps steps 4 and 5 adapted for selections.
These steps are run on the inclusive descendants of a removed node, but to avoid having to iterate through those nodes twice, they are run when the inclusive descendants themselves are unbound from the tree.
Sourcepub(crate) fn remove_steps_for_parent(
&self,
parent: &Node,
node_index: &mut dyn FnMut() -> u32,
)
pub(crate) fn remove_steps_for_parent( &self, parent: &Node, node_index: &mut dyn FnMut() -> u32, )
https://dom.spec.whatwg.org/#live-range-pre-remove-steps steps 6 and 7 adapted for selections.
Sourcepub(crate) fn normalization_steps(
&self,
parent: &Node,
node: &Node,
current_node: &Node,
current_node_index: &dyn Fn() -> u32,
length: u32,
)
pub(crate) fn normalization_steps( &self, parent: &Node, node: &Node, current_node: &Node, current_node_index: &dyn Fn() -> u32, length: u32, )
https://dom.spec.whatwg.org/#dom-node-normalize Steps 6.1-6.4 adapted for selections.
parent: The parent of both other node arguments.node: The node that text is being merged into.current_node: The node which has text being merged intonodeand will be removed from the DOM.length: The length of the text content that was merged intonodefrom siblings beforecurrent_node.
Sourcepub(crate) fn replace_data_steps(
&self,
node: &Node,
offset: u32,
removed_code_units: u32,
added_code_units: &mut dyn FnMut() -> u32,
)
pub(crate) fn replace_data_steps( &self, node: &Node, offset: u32, removed_code_units: u32, added_code_units: &mut dyn FnMut() -> u32, )
https://dom.spec.whatwg.org/#concept-cd-replace steps 8-11 adapted for selections.
Sourcepub(crate) fn text_split_steps(
&self,
node: &Node,
offset: u32,
parent_node: &Node,
new_node: &Node,
)
pub(crate) fn text_split_steps( &self, node: &Node, offset: u32, parent_node: &Node, new_node: &Node, )
https://dom.spec.whatwg.org/#concept-text-split steps 7.2-7.3 adapted for selections.
pub(crate) fn collapse_to_dom_position( &self, cx: &mut JSContext, container: &Node, offset: Utf32CodeUnitsOrNodeOffset, )
pub(crate) fn collapse_or_extend_to_dom_position( &self, cx: &mut JSContext, container: &Node, offset: Utf32CodeUnitsOrNodeOffset, )
Trait Implementations§
Source§impl DomObject for Selection
impl DomObject for Selection
type ReflectorType = ()
Source§fn reflector(&self) -> &Reflector<Self::ReflectorType>
fn reflector(&self) -> &Reflector<Self::ReflectorType>
Source§impl DomObjectWrap<DomTypeHolder> for Selection
impl DomObjectWrap<DomTypeHolder> for Selection
Source§impl IDLInterface for Selection
impl IDLInterface for Selection
Source§const PROTO_FIRST: u16 = 492
const PROTO_FIRST: u16 = 492
Source§const PROTO_LAST: u16 = 492
const PROTO_LAST: u16 = 492
Source§impl MallocSizeOf for Selection
impl MallocSizeOf for Selection
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Source§impl MutDomObject for Selection
impl MutDomObject for Selection
Source§impl SelectionMethods<DomTypeHolder> for Selection
impl SelectionMethods<DomTypeHolder> for Selection
Source§fn AnchorOffset(&self, cx: &mut JSContext) -> u32
fn AnchorOffset(&self, cx: &mut JSContext) -> u32
Source§fn FocusOffset(&self, cx: &mut JSContext) -> u32
fn FocusOffset(&self, cx: &mut JSContext) -> u32
Source§fn IsCollapsed(&self, cx: &mut JSContext) -> bool
fn IsCollapsed(&self, cx: &mut JSContext) -> bool
Source§fn RemoveRange(&self, range: &Range) -> ErrorResult
fn RemoveRange(&self, range: &Range) -> ErrorResult
Source§fn SetPosition(
&self,
cx: &mut JSContext,
node: Option<&Node>,
offset: u32,
) -> ErrorResult
fn SetPosition( &self, cx: &mut JSContext, node: Option<&Node>, offset: u32, ) -> ErrorResult
Source§fn CollapseToStart(&self, cx: &mut JSContext) -> ErrorResult
fn CollapseToStart(&self, cx: &mut JSContext) -> ErrorResult
Source§fn CollapseToEnd(&self, cx: &mut JSContext) -> ErrorResult
fn CollapseToEnd(&self, cx: &mut JSContext) -> ErrorResult
Source§fn SetBaseAndExtent(
&self,
_cx: &mut JSContext,
anchor_node: &Node,
anchor_offset: u32,
focus_node: &Node,
focus_offset: u32,
) -> ErrorResult
fn SetBaseAndExtent( &self, _cx: &mut JSContext, anchor_node: &Node, anchor_offset: u32, focus_node: &Node, focus_offset: u32, ) -> ErrorResult
Source§fn SelectAllChildren(&self, _cx: &mut JSContext, node: &Node) -> ErrorResult
fn SelectAllChildren(&self, _cx: &mut JSContext, node: &Node) -> ErrorResult
Source§fn DeleteFromDocument(&self, cx: &mut JSContext) -> ErrorResult
fn DeleteFromDocument(&self, cx: &mut JSContext) -> ErrorResult
Source§fn Stringifier(&self, cx: &mut JSContext) -> DOMString
fn Stringifier(&self, cx: &mut JSContext) -> DOMString
Source§impl ToJSValConvertible for Selection
impl ToJSValConvertible for Selection
Source§fn to_jsval(&self, cx: &mut JSContext, rval: MutableHandleValue<'_>)
fn to_jsval(&self, cx: &mut JSContext, rval: MutableHandleValue<'_>)
self to a JSVal. JSAPI failure causes a panic.impl Eq for Selection
Auto Trait Implementations§
impl !Freeze for Selection
impl !RefUnwindSafe for Selection
impl !Send for Selection
impl !Sync for Selection
impl Unpin for Selection
impl UnsafeUnpin for Selection
impl !UnwindSafe for Selection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<D, T> DomGlobalGeneric<D> for T
impl<D, T> DomGlobalGeneric<D> for T
Source§fn global_from_reflector(&self) -> Root<Dom<<D as DomTypes>::GlobalScope>>where
Self: Sized,
fn global_from_reflector(&self) -> Root<Dom<<D as DomTypes>::GlobalScope>>where
Self: Sized,
GlobalScope] of the realm that the DomObject was created in. If this
object is a Node, this will be different from it’s owning Document if adopted by. For
Nodes it’s almost always better to use NodeTraits::owning_global.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more