mirror of
https://github.com/servo/servo.git
synced 2025-09-29 16:19:14 +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
|
@ -589,8 +589,7 @@ impl JsTimerTask {
|
|||
// prep for step ? in nested set_timeout_or_interval calls
|
||||
timers.nesting_level.set(self.nesting_level);
|
||||
|
||||
let was_user_interacting = ScriptThread::is_user_interacting();
|
||||
ScriptThread::set_user_interacting(self.is_user_interacting);
|
||||
let _guard = ScriptThread::user_interacting_guard();
|
||||
match self.callback {
|
||||
InternalTimerCallback::StringTimerCallback(ref code_str) => {
|
||||
// Step 6.4. Let settings object be global's relevant settings object.
|
||||
|
@ -630,7 +629,6 @@ impl JsTimerTask {
|
|||
let _ = function.Call_(this, arguments, value.handle_mut(), Report, can_gc);
|
||||
},
|
||||
};
|
||||
ScriptThread::set_user_interacting(was_user_interacting);
|
||||
|
||||
// reset nesting level (see above)
|
||||
timers.nesting_level.set(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue