mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +01:00
Combine some access to the thread local variable for script thread. (#38752)
This combines some access to the thread local variable for script thread. - We introduce a new UserInteractingScriptGuard which on drop handles the resetting of was_interacting to the previous value. Sometimes throughout the code `ScriptThread::is_user_interacting` was reset to the previous value while sometimes just set to false. This should remove this footgun. - This also reduces the amount of thread local access for MutationObservers and task queue. Testing: WPT tests should cover this. Fixes: This addresses part of https://github.com/servo/servo/issues/37969 but there is probably still stuff to be done. --------- Signed-off-by: Narfinger <Narfinger@users.noreply.github.com> Signed-off-by: Josh Matthews <josh@joshmatthews.net> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
5de041e6ef
commit
19f70dccf6
11 changed files with 156 additions and 117 deletions
|
@ -15,6 +15,7 @@ use js::jsval::JSVal;
|
|||
use profile_traits::ipc;
|
||||
use webxr_api::{self, Error as XRError, MockDeviceInit, MockDeviceMsg};
|
||||
|
||||
use crate::ScriptThread;
|
||||
use crate::dom::bindings::callback::ExceptionHandling;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||
|
@ -27,7 +28,6 @@ use crate::dom::fakexrdevice::{FakeXRDevice, get_origin, get_views, get_world};
|
|||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::promise::Promise;
|
||||
use crate::script_runtime::CanGc;
|
||||
use crate::script_thread::ScriptThread;
|
||||
|
||||
#[dom_struct]
|
||||
pub(crate) struct XRTest {
|
||||
|
@ -181,7 +181,7 @@ impl XRTestMethods<crate::DomTypeHolder> for XRTest {
|
|||
|
||||
/// <https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md>
|
||||
fn SimulateUserActivation(&self, f: Rc<Function>, can_gc: CanGc) {
|
||||
ScriptThread::set_user_interacting(true);
|
||||
let _guard = ScriptThread::user_interacting_guard();
|
||||
rooted!(in(*GlobalScope::get_cx()) let mut value: JSVal);
|
||||
let _ = f.Call__(
|
||||
vec![],
|
||||
|
@ -189,7 +189,6 @@ impl XRTestMethods<crate::DomTypeHolder> for XRTest {
|
|||
ExceptionHandling::Rethrow,
|
||||
can_gc,
|
||||
);
|
||||
ScriptThread::set_user_interacting(false);
|
||||
}
|
||||
|
||||
/// <https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue