CanGc fixes in several files (#33958)

* few cangc fixes

Signed-off-by: L Ashwin B <lashwinib@gmail.com>

* few cangc fixes

Signed-off-by: L Ashwin B <lashwinib@gmail.com>

---------

Signed-off-by: L Ashwin B <lashwinib@gmail.com>
This commit is contained in:
chickenleaf 2024-10-22 03:02:22 +05:30 committed by GitHub
parent 1bf68567b8
commit ebfea9b352
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 170 additions and 129 deletions

View file

@ -110,7 +110,11 @@ impl FormDataMethods for FormData {
let datum = FormDatum {
ty: DOMString::from("file"),
name: DOMString::from(name.0.clone()),
value: FormDatumValue::File(DomRoot::from_ref(&*self.create_an_entry(blob, filename))),
value: FormDatumValue::File(DomRoot::from_ref(&*self.create_an_entry(
blob,
filename,
CanGc::note(),
))),
};
self.data
@ -187,7 +191,7 @@ impl FormDataMethods for FormData {
#[allow(crown::unrooted_must_root)]
// https://xhr.spec.whatwg.org/#dom-formdata-set
fn Set_(&self, name: USVString, blob: &Blob, filename: Option<USVString>) {
let file = self.create_an_entry(blob, filename);
let file = self.create_an_entry(blob, filename, CanGc::note());
let mut data = self.data.borrow_mut();
let local_name = LocalName::from(name.0.clone());
@ -207,7 +211,12 @@ impl FormDataMethods for FormData {
impl FormData {
// https://xhr.spec.whatwg.org/#create-an-entry
fn create_an_entry(&self, blob: &Blob, opt_filename: Option<USVString>) -> DomRoot<File> {
fn create_an_entry(
&self,
blob: &Blob,
opt_filename: Option<USVString>,
can_gc: CanGc,
) -> DomRoot<File> {
// Steps 3-4
let name = match opt_filename {
Some(filename) => DOMString::from(filename.0),
@ -229,6 +238,7 @@ impl FormData {
BlobImpl::new_from_bytes(bytes, blob.type_string()),
name,
None,
can_gc,
)
}