mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
script: stub AbortSignal
(#37033)
This is a stub for `AbortSignal`, which we would like to merge first in order to work in parallel on https://github.com/servo/servo/issues/34866, and perhaps also https://github.com/servo/servo/issues/36936 --------- Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com> Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> Co-authored-by: Taym Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
parent
270dcf879d
commit
324196351e
6 changed files with 330 additions and 0 deletions
71
components/script/dom/abortsignal.rs
Normal file
71
components/script/dom/abortsignal.rs
Normal file
|
@ -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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue