script/dom/
idbcursorwithvalue.rs1use dom_struct::dom_struct;
6use js::rust::MutableHandleValue;
7use storage_traits::indexeddb_thread::IndexedDBKeyRange;
8
9use crate::dom::bindings::codegen::Bindings::IDBCursorBinding::IDBCursorDirection;
10use crate::dom::bindings::codegen::Bindings::IDBCursorWithValueBinding::IDBCursorWithValueMethods;
11use crate::dom::bindings::reflector::reflect_dom_object;
12use crate::dom::bindings::root::DomRoot;
13use crate::dom::globalscope::GlobalScope;
14use crate::dom::idbcursor::{IDBCursor, ObjectStoreOrIndex};
15use crate::dom::idbtransaction::IDBTransaction;
16use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
17
18#[dom_struct]
19pub(crate) struct IDBCursorWithValue {
20 cursor: IDBCursor,
21}
22
23impl IDBCursorWithValue {
24 #[cfg_attr(crown, allow(crown::unrooted_must_root))]
25 fn new_inherited(
26 transaction: &IDBTransaction,
27 direction: IDBCursorDirection,
28 got_value: bool,
29 source: ObjectStoreOrIndex,
30 range: IndexedDBKeyRange,
31 key_only: bool,
32 ) -> IDBCursorWithValue {
33 IDBCursorWithValue {
34 cursor: IDBCursor::new_inherited(
35 transaction,
36 direction,
37 got_value,
38 source,
39 range,
40 key_only,
41 ),
42 }
43 }
44
45 #[cfg_attr(crown, allow(crown::unrooted_must_root))]
46 #[allow(clippy::too_many_arguments)]
47 pub(crate) fn new(
48 global: &GlobalScope,
49 transaction: &IDBTransaction,
50 direction: IDBCursorDirection,
51 got_value: bool,
52 source: ObjectStoreOrIndex,
53 range: IndexedDBKeyRange,
54 key_only: bool,
55 can_gc: CanGc,
56 ) -> DomRoot<IDBCursorWithValue> {
57 reflect_dom_object(
58 Box::new(IDBCursorWithValue::new_inherited(
59 transaction,
60 direction,
61 got_value,
62 source,
63 range,
64 key_only,
65 )),
66 global,
67 can_gc,
68 )
69 }
70}
71
72impl IDBCursorWithValueMethods<crate::DomTypeHolder> for IDBCursorWithValue {
73 fn Value(&self, _cx: SafeJSContext, value: MutableHandleValue) {
75 self.cursor.value(value);
76 }
77}