Skip to main content

Selection

Struct Selection 

Source
#[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

Source§

impl Selection

Source§

impl Selection

Source

fn new_inherited(document: &Document) -> Selection

Source

pub(crate) fn new(cx: &mut JSContext, document: &Document) -> DomRoot<Selection>

Source

pub(crate) fn visible_selection_dirty(&self) -> bool

Source

fn clear_cached_live_range(&self)

Source

pub(crate) fn update_from_live_range( &self, live_range: &Range, notification: SelectionLiveRangeNotification, )

Source

fn set_range(&self, new_range: Option<SelectionRange>) -> bool

Source

pub(crate) fn set_live_range(&self, new_range: Option<&Range>)

Source

fn selection_boundaries_changed(&self)

Source

fn iter_nodes_with_overlaps_document_selection_flag<'no_gc>( &self, no_gc: &'no_gc NoGC, ) -> impl Iterator<Item = UnrootedDom<'no_gc, Node>>

Source

pub(crate) fn update_overlaps_document_selection_flags<'no_gc>( &self, no_gc: &'no_gc NoGC, )

Source

pub(crate) fn queue_selectionchange_task(&self)

Source

fn is_in_document_of_range(&self, node: &Node) -> bool

Source

pub(crate) fn start_boundary(&self, cx: &mut JSContext) -> (DomRoot<Node>, u32)

Source

pub(crate) fn end_boundary(&self, cx: &mut JSContext) -> (DomRoot<Node>, u32)

Source

fn assert_valid_selection(&self)

Source

fn assert_valid_selection_and_live_range(&self)

Source

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.)

Source

pub(crate) fn expect_active_range(&self, cx: &mut JSContext) -> DomRoot<Range>

Source

pub(crate) fn set_visible_selection_dirty(&self)

Source

fn composed_anchor_position(&self) -> Option<(DomRoot<Node>, u32)>

Source

fn live_anchor_node(&self, cx: &mut JSContext) -> Option<DomRoot<Node>>

Source

fn live_anchor_offset(&self, cx: &mut JSContext) -> u32

Source

fn live_focus_node(&self, cx: &mut JSContext) -> Option<DomRoot<Node>>

Source

fn live_focus_offset(&self, cx: &mut JSContext) -> u32

Source

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.

Source

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.

Source

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.

Source

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 into node and will be removed from the DOM.
  • length: The length of the text content that was merged into node from siblings before current_node.
Source

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.

Source

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.

Source

pub(crate) fn collapse_to_dom_position( &self, cx: &mut JSContext, container: &Node, offset: Utf32CodeUnitsOrNodeOffset, )

Source

pub(crate) fn collapse_or_extend_to_dom_position( &self, cx: &mut JSContext, container: &Node, offset: Utf32CodeUnitsOrNodeOffset, )

Trait Implementations§

Source§

impl DomObject for Selection

Source§

type ReflectorType = ()

Source§

fn reflector(&self) -> &Reflector<Self::ReflectorType>

Returns the receiver’s reflector.
Source§

impl DomObjectWrap<DomTypeHolder> for Selection

Source§

const WRAP: unsafe fn(&mut JSContext, &GlobalScope, Option<HandleObject<'_>>, Box<Self>) -> Root<Dom<Self>>

Function pointer to the general wrap function type
Source§

impl Drop for Selection

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl HasParent for Selection

Source§

fn as_parent(&self) -> &Reflector

This is used in a type assertion to ensure that the source and webidls agree as to what the parent type is

Source§

type Parent = Reflector

Source§

impl IDLInterface for Selection

Source§

const PROTO_FIRST: u16 = 492

First prototype ID in the DFS-ordered range for this interface and its descendants.
Source§

const PROTO_LAST: u16 = 492

Last prototype ID in the DFS-ordered range for this interface and its descendants.
Source§

fn derives(class: &'static DOMClass) -> bool

Returns whether the given DOM class derives that interface.
Source§

impl MallocSizeOf for Selection

Source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.
Source§

impl MutDomObject for Selection

Source§

unsafe fn init_reflector<Actual>(&self, obj: *mut JSObject)

Initializes the Reflector Read more
Source§

unsafe fn init_reflector_without_associated_memory(&self, obj: *mut JSObject)

Initializes the Reflector without recording any associated memory usage. Read more
Source§

impl PartialEq for Selection

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl SelectionMethods<DomTypeHolder> for Selection

Source§

fn GetAnchorNode(&self, cx: &mut JSContext) -> Option<DomRoot<Node>>

Source§

fn AnchorOffset(&self, cx: &mut JSContext) -> u32

Source§

fn GetFocusNode(&self, cx: &mut JSContext) -> Option<DomRoot<Node>>

Source§

fn FocusOffset(&self, cx: &mut JSContext) -> u32

Source§

fn IsCollapsed(&self, cx: &mut JSContext) -> bool

Source§

fn RangeCount(&self) -> u32

Source§

fn Type(&self) -> DOMString

Source§

fn GetRangeAt(&self, cx: &mut JSContext, index: u32) -> Fallible<DomRoot<Range>>

Source§

fn AddRange(&self, range: &Range)

Source§

fn RemoveRange(&self, range: &Range) -> ErrorResult

Source§

fn RemoveAllRanges(&self)

Source§

fn Empty(&self)

Source§

fn Collapse( &self, _cx: &mut JSContext, node: Option<&Node>, offset: u32, ) -> ErrorResult

Source§

fn SetPosition( &self, cx: &mut JSContext, node: Option<&Node>, offset: u32, ) -> ErrorResult

Source§

fn CollapseToStart(&self, cx: &mut JSContext) -> ErrorResult

Source§

fn CollapseToEnd(&self, cx: &mut JSContext) -> ErrorResult

Source§

fn Extend(&self, _cx: &mut JSContext, node: &Node, offset: u32) -> ErrorResult

Source§

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

Source§

fn DeleteFromDocument(&self, cx: &mut JSContext) -> ErrorResult

Source§

fn ContainsNode(&self, node: &Node, allow_partial_containment: bool) -> bool

Source§

fn Stringifier(&self, cx: &mut JSContext) -> DOMString

Source§

impl ToJSValConvertible for Selection

Source§

fn to_jsval(&self, cx: &mut JSContext, rval: MutableHandleValue<'_>)

Convert self to a JSVal. JSAPI failure causes a panic.
Source§

impl Traceable for Selection

Source§

unsafe fn trace(&self, tracer: *mut JSTracer)

Trace self.
Source§

impl Eq for Selection

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<D, T> DomGlobalGeneric<D> for T
where D: DomTypes, T: DomObject,

Source§

fn global_from_reflector(&self) -> Root<Dom<<D as DomTypes>::GlobalScope>>
where Self: Sized,

Returns the [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<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ThisReflector for T
where T: DomObject,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,