diff options
author | Paul Rouget <me@paulrouget.com> | 2020-03-26 08:36:57 +0100 |
---|---|---|
committer | Paul Rouget <me@paulrouget.com> | 2020-03-26 08:36:57 +0100 |
commit | 5621c887fd5b387c7cab80c182fe579889822212 (patch) | |
tree | 46ad1ef360d96ea993432a413176ad7c0423e90a /components/script/script_runtime.rs | |
parent | 6ca767d7f92eb22eb7631283973ef8305567bf07 (diff) | |
download | servo-5621c887fd5b387c7cab80c182fe579889822212.tar.gz servo-5621c887fd5b387c7cab80c182fe579889822212.zip |
Propagate user interacting flag to timers and promises
Diffstat (limited to 'components/script/script_runtime.rs')
-rw-r--r-- | components/script/script_runtime.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 3cce6291d63..abe411521af 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -42,9 +42,11 @@ use js::glue::{ StreamConsumerNoteResponseURLs, StreamConsumerStreamEnd, StreamConsumerStreamError, }; use js::jsapi::ContextOptionsRef; +use js::jsapi::GetPromiseUserInputEventHandlingState; use js::jsapi::InitConsumeStreamCallback; use js::jsapi::InitDispatchToEventLoop; use js::jsapi::MimeType; +use js::jsapi::PromiseUserInputEventHandlingState; use js::jsapi::StreamConsumer as JSStreamConsumer; use js::jsapi::{BuildIdCharVector, DisableIncrementalGC, GCDescription, GCProgress}; use js::jsapi::{Dispatchable as JSRunnable, Dispatchable_MaybeShuttingDown}; @@ -197,7 +199,7 @@ unsafe extern "C" fn empty(extra: *const c_void) -> bool { unsafe extern "C" fn enqueue_promise_job( extra: *const c_void, cx: *mut RawJSContext, - _promise: HandleObject, + promise: HandleObject, job: HandleObject, _allocation_site: HandleObject, incumbent_global: HandleObject, @@ -208,10 +210,18 @@ unsafe extern "C" fn enqueue_promise_job( let microtask_queue = &*(extra as *const MicrotaskQueue); let global = GlobalScope::from_object(incumbent_global.get()); let pipeline = global.pipeline_id(); + let interaction = if promise.get().is_null() { + PromiseUserInputEventHandlingState::DontCare + } else { + GetPromiseUserInputEventHandlingState(promise) + }; + let is_user_interacting = + interaction == PromiseUserInputEventHandlingState::HadUserInteractionAtCreation; microtask_queue.enqueue( Microtask::Promise(EnqueuedPromiseCallback { callback: PromiseJobCallback::new(cx, job.get()), pipeline, + is_user_interacting, }), cx, ); |