script: Pass &mut JSContext in more places (#43252)

Continuation of #43220, removes many `temp_cx` calls introduced by that.

Testing: No behaviour change, a successful build is enough.
Fixes: #43241 #43240

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
Gae24
2026-03-14 11:03:48 +01:00
committed by GitHub
parent 9cf33b773d
commit e8b581aaf0
24 changed files with 299 additions and 252 deletions

View File

@@ -1392,18 +1392,18 @@ impl HTMLScriptElementMethods<crate::DomTypeHolder> for HTMLScriptElement {
}
/// <https://w3c.github.io/trusted-types/dist/spec/#the-innerText-idl-attribute>
fn SetInnerText(&self, input: TrustedScriptOrString, can_gc: CanGc) -> Fallible<()> {
fn SetInnerText(&self, cx: &mut JSContext, input: TrustedScriptOrString) -> Fallible<()> {
// Step 1: Let value be the result of calling Get Trusted Type compliant string with TrustedScript,
// this's relevant global object, the given value, HTMLScriptElement innerText, and script.
let value = TrustedScript::get_trusted_script_compliant_string(
&self.owner_global(),
input,
"HTMLScriptElement innerText",
can_gc,
CanGc::from_cx(cx),
)?;
*self.script_text.borrow_mut() = value.clone();
// Step 3: Run set the inner text steps with this and value.
self.upcast::<HTMLElement>().set_inner_text(value, can_gc);
self.upcast::<HTMLElement>().set_inner_text(cx, value);
Ok(())
}
@@ -1438,20 +1438,24 @@ impl HTMLScriptElementMethods<crate::DomTypeHolder> for HTMLScriptElement {
}
/// <https://w3c.github.io/trusted-types/dist/spec/#the-textContent-idl-attribute>
fn SetTextContent(&self, value: Option<TrustedScriptOrString>, can_gc: CanGc) -> Fallible<()> {
fn SetTextContent(
&self,
cx: &mut JSContext,
value: Option<TrustedScriptOrString>,
) -> Fallible<()> {
// Step 1: Let value be the result of calling Get Trusted Type compliant string with TrustedScript,
// this's relevant global object, the given value, HTMLScriptElement textContent, and script.
let value = TrustedScript::get_trusted_script_compliant_string(
&self.owner_global(),
value.unwrap_or(TrustedScriptOrString::String(DOMString::from(""))),
"HTMLScriptElement textContent",
can_gc,
CanGc::from_cx(cx),
)?;
// Step 2: Set this's script text value to value.
*self.script_text.borrow_mut() = value.clone();
// Step 3: Run set text content with this and value.
self.upcast::<Node>()
.set_text_content_for_element(Some(value), can_gc);
.set_text_content_for_element(cx, Some(value));
Ok(())
}