mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #25627 - pshaughn:definedpseudo, r=emilio,jdm
Implement :defined CSS selector <!-- Please describe your changes on the following line: --> ElementState::IN_DEFINED_STATE already existed but wasn't hooked up to anything; now it is set appropriately, and CSS is aware of it. The main test for this selector needed the window named getter for no important reason, so I made a one-line test change to avoid that. Remaining failures in the test are all about SVG elements. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #25010 <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
4edd1590f4
9 changed files with 52 additions and 7 deletions
|
@ -200,6 +200,8 @@ fn create_html_element(
|
|||
None => {
|
||||
if is_valid_custom_element_name(&*name.local) {
|
||||
result.set_custom_element_state(CustomElementState::Undefined);
|
||||
} else {
|
||||
result.set_custom_element_state(CustomElementState::Uncustomized);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -324,14 +324,23 @@ impl Element {
|
|||
}
|
||||
|
||||
pub fn set_custom_element_state(&self, state: CustomElementState) {
|
||||
self.ensure_rare_data().custom_element_state = state;
|
||||
// no need to inflate rare data for uncustomized
|
||||
if state != CustomElementState::Uncustomized || self.rare_data().is_some() {
|
||||
self.ensure_rare_data().custom_element_state = state;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#concept-element-defined
|
||||
let in_defined_state = match state {
|
||||
CustomElementState::Uncustomized | CustomElementState::Custom => true,
|
||||
_ => false,
|
||||
};
|
||||
self.set_state(ElementState::IN_DEFINED_STATE, in_defined_state)
|
||||
}
|
||||
|
||||
pub fn get_custom_element_state(&self) -> CustomElementState {
|
||||
if let Some(rare_data) = self.rare_data().as_ref() {
|
||||
return rare_data.custom_element_state;
|
||||
}
|
||||
CustomElementState::Undefined
|
||||
CustomElementState::Uncustomized
|
||||
}
|
||||
|
||||
pub fn set_custom_element_definition(&self, definition: Rc<CustomElementDefinition>) {
|
||||
|
@ -3039,6 +3048,7 @@ impl<'a> SelectorsElement for DomRoot<Element> {
|
|||
NonTSPseudoClass::Focus |
|
||||
NonTSPseudoClass::Fullscreen |
|
||||
NonTSPseudoClass::Hover |
|
||||
NonTSPseudoClass::Defined |
|
||||
NonTSPseudoClass::Enabled |
|
||||
NonTSPseudoClass::Disabled |
|
||||
NonTSPseudoClass::Checked |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue