mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Implement :valid :invalid pseudo classes (#26729)
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
2b67392fd5
commit
5f2c6c09cd
30 changed files with 324 additions and 241 deletions
|
@ -38,7 +38,7 @@ impl HTMLFieldSetElement {
|
|||
) -> HTMLFieldSetElement {
|
||||
HTMLFieldSetElement {
|
||||
htmlelement: HTMLElement::new_inherited_with_state(
|
||||
ElementState::IN_ENABLED_STATE,
|
||||
ElementState::IN_ENABLED_STATE | ElementState::IN_VALID_STATE,
|
||||
local_name,
|
||||
prefix,
|
||||
document,
|
||||
|
@ -63,6 +63,26 @@ impl HTMLFieldSetElement {
|
|||
proto,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn update_validity(&self) {
|
||||
let has_invalid_child = self
|
||||
.upcast::<Node>()
|
||||
.traverse_preorder(ShadowIncluding::No)
|
||||
.flat_map(DomRoot::downcast::<Element>)
|
||||
.any(|element| {
|
||||
if let Some(validatable) = element.as_maybe_validatable() {
|
||||
validatable.is_instance_validatable() &&
|
||||
!validatable.validity_state().invalid_flags().is_empty()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
});
|
||||
|
||||
self.upcast::<Element>()
|
||||
.set_state(ElementState::IN_VALID_STATE, !has_invalid_child);
|
||||
self.upcast::<Element>()
|
||||
.set_state(ElementState::IN_INVALID_STATE, has_invalid_child);
|
||||
}
|
||||
}
|
||||
|
||||
impl HTMLFieldSetElementMethods for HTMLFieldSetElement {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue