Files
servo/components/script/dom/fetchlaterresult.rs
WaterWhisperer 2a759ed6de Replace allow(crown::unrooted_must_root) with expect(crown::unrooted_must_root) (#41815)
Testing: `./mach build -d --use-crown` with no warnings
Fixes: #41761

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2026-01-10 08:05:49 +00:00

54 lines
1.8 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* 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 crate::dom::bindings::codegen::Bindings::FetchLaterResultBinding::FetchLaterResultMethods;
use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object};
use crate::dom::bindings::root::DomRoot;
use crate::dom::window::Window;
use crate::fetch::DeferredFetchRecordId;
use crate::script_runtime::CanGc;
/// <https://fetch.spec.whatwg.org/#fetchlaterresult>
#[dom_struct]
pub(crate) struct FetchLaterResult {
reflector_: Reflector,
/// <https://fetch.spec.whatwg.org/#fetchlaterresult-activated-getter-steps>
#[no_trace]
deferred_record_id: DeferredFetchRecordId,
}
impl FetchLaterResult {
fn new_inherited(deferred_record_id: DeferredFetchRecordId) -> FetchLaterResult {
FetchLaterResult {
reflector_: Reflector::new(),
deferred_record_id,
}
}
pub(crate) fn new(
window: &Window,
deferred_record_id: DeferredFetchRecordId,
can_gc: CanGc,
) -> DomRoot<FetchLaterResult> {
reflect_dom_object(
Box::new(FetchLaterResult::new_inherited(deferred_record_id)),
window,
can_gc,
)
}
}
impl FetchLaterResultMethods<crate::DomTypeHolder> for FetchLaterResult {
/// <https://fetch.spec.whatwg.org/#dom-fetchlaterresult-activated>
fn Activated(&self) -> bool {
// The activated getter steps are to return the result of running thiss activated getter steps.
self.global()
.deferred_fetch_record_for_id(&self.deferred_record_id)
.activated_getter_steps()
}
}