add CanGc as argument to Validatable.validity_state (#40155)

add CanGc as argument to Validatable.validity_state

Testing: These changes do not require tests because they are a refactor.
Addresses part of https://github.com/servo/servo/issues/34573.

Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
This commit is contained in:
Yerkebulan Tulibergenov
2025-10-24 23:06:32 -07:00
committed by GitHub
parent 92cc41abdd
commit 132bd24c6d
14 changed files with 90 additions and 88 deletions

View File

@@ -568,7 +568,7 @@ impl HTMLSelectElementMethods<crate::DomTypeHolder> for HTMLSelectElement {
}
/// <https://html.spec.whatwg.org/multipage/#dom-select-value>
fn SetValue(&self, value: DOMString) {
fn SetValue(&self, value: DOMString, can_gc: CanGc) {
let mut opt_iter = self.list_of_options();
// Reset until we find an <option> with a matching value
for opt in opt_iter.by_ref() {
@@ -584,8 +584,8 @@ impl HTMLSelectElementMethods<crate::DomTypeHolder> for HTMLSelectElement {
opt.set_selectedness(false);
}
self.validity_state()
.perform_validation_and_update(ValidationFlags::VALUE_MISSING, CanGc::note());
self.validity_state(can_gc)
.perform_validation_and_update(ValidationFlags::VALUE_MISSING, can_gc);
}
/// <https://html.spec.whatwg.org/multipage/#dom-select-selectedindex>
@@ -630,8 +630,8 @@ impl HTMLSelectElementMethods<crate::DomTypeHolder> for HTMLSelectElement {
}
/// <https://html.spec.whatwg.org/multipage/#dom-cva-validity>
fn Validity(&self) -> DomRoot<ValidityState> {
self.validity_state()
fn Validity(&self, can_gc: CanGc) -> DomRoot<ValidityState> {
self.validity_state(can_gc)
}
/// <https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity>
@@ -650,8 +650,8 @@ impl HTMLSelectElementMethods<crate::DomTypeHolder> for HTMLSelectElement {
}
/// <https://html.spec.whatwg.org/multipage/#dom-cva-setcustomvalidity>
fn SetCustomValidity(&self, error: DOMString) {
self.validity_state().set_custom_error_message(error);
fn SetCustomValidity(&self, error: DOMString, can_gc: CanGc) {
self.validity_state(can_gc).set_custom_error_message(error);
}
}
@@ -667,7 +667,7 @@ impl VirtualMethods for HTMLSelectElement {
.attribute_mutated(attr, mutation, can_gc);
match *attr.local_name() {
local_name!("required") => {
self.validity_state()
self.validity_state(can_gc)
.perform_validation_and_update(ValidationFlags::VALUE_MISSING, can_gc);
},
local_name!("disabled") => {
@@ -684,7 +684,7 @@ impl VirtualMethods for HTMLSelectElement {
},
}
self.validity_state()
self.validity_state(can_gc)
.perform_validation_and_update(ValidationFlags::VALUE_MISSING, can_gc);
},
local_name!("form") => {
@@ -776,9 +776,9 @@ impl Validatable for HTMLSelectElement {
self.upcast()
}
fn validity_state(&self) -> DomRoot<ValidityState> {
fn validity_state(&self, can_gc: CanGc) -> DomRoot<ValidityState> {
self.validity_state
.or_init(|| ValidityState::new(&self.owner_window(), self.upcast(), CanGc::note()))
.or_init(|| ValidityState::new(&self.owner_window(), self.upcast(), can_gc))
}
fn is_instance_validatable(&self) -> bool {