aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/abortsignal.rs71
-rw-r--r--components/script/dom/mod.rs1
2 files changed, 72 insertions, 0 deletions
diff --git a/components/script/dom/abortsignal.rs b/components/script/dom/abortsignal.rs
new file mode 100644
index 00000000000..57c6e9cd67e
--- /dev/null
+++ b/components/script/dom/abortsignal.rs
@@ -0,0 +1,71 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use dom_struct::dom_struct;
+use js::jsapi::Heap;
+use js::jsval::JSVal;
+use js::rust::{HandleObject, MutableHandleValue};
+
+use crate::dom::bindings::codegen::Bindings::AbortSignalBinding::AbortSignalMethods;
+use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::eventtarget::EventTarget;
+use crate::dom::globalscope::GlobalScope;
+use crate::script_runtime::{CanGc, JSContext};
+
+/// <https://dom.spec.whatwg.org/#abortsignal>
+#[dom_struct]
+pub(crate) struct AbortSignal {
+ eventtarget: EventTarget,
+
+ /// <https://dom.spec.whatwg.org/#abortsignal-abort-reason>
+ #[ignore_malloc_size_of = "mozjs"]
+ abort_reason: Heap<JSVal>,
+}
+
+impl AbortSignal {
+ #[allow(dead_code)]
+ fn new_inherited() -> AbortSignal {
+ AbortSignal {
+ eventtarget: EventTarget::new_inherited(),
+ abort_reason: Default::default(),
+ }
+ }
+
+ #[allow(dead_code)]
+ fn new_with_proto(
+ global: &GlobalScope,
+ proto: Option<HandleObject>,
+ can_gc: CanGc,
+ ) -> DomRoot<AbortSignal> {
+ reflect_dom_object_with_proto(
+ Box::new(AbortSignal::new_inherited()),
+ global,
+ proto,
+ can_gc,
+ )
+ }
+}
+
+impl AbortSignalMethods<crate::DomTypeHolder> for AbortSignal {
+ /// <https://dom.spec.whatwg.org/#dom-abortsignal-aborted>
+ fn Aborted(&self) -> bool {
+ // TODO
+ false
+ }
+
+ /// <https://dom.spec.whatwg.org/#dom-abortsignal-reason>
+ fn Reason(&self, _: JSContext, _rval: MutableHandleValue) {
+ // TODO
+ }
+
+ /// <https://dom.spec.whatwg.org/#dom-abortsignal-throwifaborted>
+ #[allow(unsafe_code)]
+ fn ThrowIfAborted(&self) {
+ // TODO
+ }
+
+ // <https://dom.spec.whatwg.org/#dom-abortsignal-onabort>
+ event_handler!(abort, GetOnabort, SetOnabort);
+}
diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs
index 388d8cfde2a..5d7f1966207 100644
--- a/components/script/dom/mod.rs
+++ b/components/script/dom/mod.rs
@@ -211,6 +211,7 @@ pub(crate) mod types {
}
pub(crate) mod abortcontroller;
+pub(crate) mod abortsignal;
#[allow(dead_code)]
pub(crate) mod abstractrange;
pub(crate) mod abstractworker;