mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
:defined works
This commit is contained in:
parent
6d220d02de
commit
8ca4db2cd6
9 changed files with 52 additions and 7 deletions
|
@ -955,6 +955,7 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
||||||
NonTSPseudoClass::Focus |
|
NonTSPseudoClass::Focus |
|
||||||
NonTSPseudoClass::Fullscreen |
|
NonTSPseudoClass::Fullscreen |
|
||||||
NonTSPseudoClass::Hover |
|
NonTSPseudoClass::Hover |
|
||||||
|
NonTSPseudoClass::Defined |
|
||||||
NonTSPseudoClass::Enabled |
|
NonTSPseudoClass::Enabled |
|
||||||
NonTSPseudoClass::Disabled |
|
NonTSPseudoClass::Disabled |
|
||||||
NonTSPseudoClass::Checked |
|
NonTSPseudoClass::Checked |
|
||||||
|
|
|
@ -962,6 +962,7 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
||||||
NonTSPseudoClass::Focus |
|
NonTSPseudoClass::Focus |
|
||||||
NonTSPseudoClass::Fullscreen |
|
NonTSPseudoClass::Fullscreen |
|
||||||
NonTSPseudoClass::Hover |
|
NonTSPseudoClass::Hover |
|
||||||
|
NonTSPseudoClass::Defined |
|
||||||
NonTSPseudoClass::Enabled |
|
NonTSPseudoClass::Enabled |
|
||||||
NonTSPseudoClass::Disabled |
|
NonTSPseudoClass::Disabled |
|
||||||
NonTSPseudoClass::Checked |
|
NonTSPseudoClass::Checked |
|
||||||
|
|
|
@ -200,6 +200,8 @@ fn create_html_element(
|
||||||
None => {
|
None => {
|
||||||
if is_valid_custom_element_name(&*name.local) {
|
if is_valid_custom_element_name(&*name.local) {
|
||||||
result.set_custom_element_state(CustomElementState::Undefined);
|
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) {
|
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 {
|
pub fn get_custom_element_state(&self) -> CustomElementState {
|
||||||
if let Some(rare_data) = self.rare_data().as_ref() {
|
if let Some(rare_data) = self.rare_data().as_ref() {
|
||||||
return rare_data.custom_element_state;
|
return rare_data.custom_element_state;
|
||||||
}
|
}
|
||||||
CustomElementState::Undefined
|
CustomElementState::Uncustomized
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_custom_element_definition(&self, definition: Rc<CustomElementDefinition>) {
|
pub fn set_custom_element_definition(&self, definition: Rc<CustomElementDefinition>) {
|
||||||
|
@ -3039,6 +3048,7 @@ impl<'a> SelectorsElement for DomRoot<Element> {
|
||||||
NonTSPseudoClass::Focus |
|
NonTSPseudoClass::Focus |
|
||||||
NonTSPseudoClass::Fullscreen |
|
NonTSPseudoClass::Fullscreen |
|
||||||
NonTSPseudoClass::Hover |
|
NonTSPseudoClass::Hover |
|
||||||
|
NonTSPseudoClass::Defined |
|
||||||
NonTSPseudoClass::Enabled |
|
NonTSPseudoClass::Enabled |
|
||||||
NonTSPseudoClass::Disabled |
|
NonTSPseudoClass::Disabled |
|
||||||
NonTSPseudoClass::Checked |
|
NonTSPseudoClass::Checked |
|
||||||
|
|
|
@ -278,6 +278,7 @@ pub enum NonTSPseudoClass {
|
||||||
Active,
|
Active,
|
||||||
AnyLink,
|
AnyLink,
|
||||||
Checked,
|
Checked,
|
||||||
|
Defined,
|
||||||
Disabled,
|
Disabled,
|
||||||
Enabled,
|
Enabled,
|
||||||
Focus,
|
Focus,
|
||||||
|
@ -332,6 +333,7 @@ impl ToCss for NonTSPseudoClass {
|
||||||
Active => ":active",
|
Active => ":active",
|
||||||
AnyLink => ":any-link",
|
AnyLink => ":any-link",
|
||||||
Checked => ":checked",
|
Checked => ":checked",
|
||||||
|
Defined => ":defined",
|
||||||
Disabled => ":disabled",
|
Disabled => ":disabled",
|
||||||
Enabled => ":enabled",
|
Enabled => ":enabled",
|
||||||
Focus => ":focus",
|
Focus => ":focus",
|
||||||
|
@ -371,6 +373,7 @@ impl NonTSPseudoClass {
|
||||||
Focus => ElementState::IN_FOCUS_STATE,
|
Focus => ElementState::IN_FOCUS_STATE,
|
||||||
Fullscreen => ElementState::IN_FULLSCREEN_STATE,
|
Fullscreen => ElementState::IN_FULLSCREEN_STATE,
|
||||||
Hover => ElementState::IN_HOVER_STATE,
|
Hover => ElementState::IN_HOVER_STATE,
|
||||||
|
Defined => ElementState::IN_DEFINED_STATE,
|
||||||
Enabled => ElementState::IN_ENABLED_STATE,
|
Enabled => ElementState::IN_ENABLED_STATE,
|
||||||
Disabled => ElementState::IN_DISABLED_STATE,
|
Disabled => ElementState::IN_DISABLED_STATE,
|
||||||
Checked => ElementState::IN_CHECKED_STATE,
|
Checked => ElementState::IN_CHECKED_STATE,
|
||||||
|
@ -436,6 +439,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
|
||||||
"active" => Active,
|
"active" => Active,
|
||||||
"any-link" => AnyLink,
|
"any-link" => AnyLink,
|
||||||
"checked" => Checked,
|
"checked" => Checked,
|
||||||
|
"defined" => Defined,
|
||||||
"disabled" => Disabled,
|
"disabled" => Disabled,
|
||||||
"enabled" => Enabled,
|
"enabled" => Enabled,
|
||||||
"focus" => Focus,
|
"focus" => Focus,
|
||||||
|
|
|
@ -667507,7 +667507,7 @@
|
||||||
"testharness"
|
"testharness"
|
||||||
],
|
],
|
||||||
"custom-elements/pseudo-class-defined.html": [
|
"custom-elements/pseudo-class-defined.html": [
|
||||||
"24cb5fe4cd392246e292d255c0858aa7f2b5dd0e",
|
"ed12830d5a9582dbf3ec30c74a43fe381221a139",
|
||||||
"testharness"
|
"testharness"
|
||||||
],
|
],
|
||||||
"custom-elements/range-and-constructors.html": [
|
"custom-elements/range-and-constructors.html": [
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[Document-createElement.html]
|
|
||||||
[document.createElement must create an instance of autonomous custom elements when it has is attribute]
|
|
||||||
expected: FAIL
|
|
|
@ -1,8 +1,37 @@
|
||||||
[pseudo-class-defined.html]
|
[pseudo-class-defined.html]
|
||||||
expected: ERROR
|
|
||||||
[Untitled]
|
[Untitled]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[pseudo-class-defined]
|
[pseudo-class-defined]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
[createElementNS("http://www.w3.org/2000/svg", "div") should be :defined]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[Without browsing context: createElementNS("http://www.w3.org/2000/svg", "div") should be :defined]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[Without browsing context: createElementNS("http://www.w3.org/2000/svg", "p", { is: "" }) should be :defined]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[createElementNS("http://www.w3.org/2000/svg", "p", { is: "" }) should be :defined]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[Without browsing context: createElementNS("http://www.w3.org/2000/svg", "abbr", { is: "my-abbr" }) should be :defined]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[createElementNS("http://www.w3.org/2000/svg", "abbr", { is: "my-abbr" }) should be :defined]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[createElementNS("http://www.w3.org/2000/svg", "font-face") should be :defined]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[Without browsing context: createElementNS("http://www.w3.org/2000/svg", "font-face") should be :defined]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[createElementNS("http://www.w3.org/2000/svg", "a-a") should be :defined]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[Without browsing context: createElementNS("http://www.w3.org/2000/svg", "a-a") should be :defined]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ const testList = [
|
||||||
const neither = 'rgb(255, 0, 0)';
|
const neither = 'rgb(255, 0, 0)';
|
||||||
const defined = 'rgb(255, 165, 0)';
|
const defined = 'rgb(255, 165, 0)';
|
||||||
const not_defined = 'rgb(0, 0, 255)';
|
const not_defined = 'rgb(0, 0, 255)';
|
||||||
|
const iframe = document.getElementById("iframe");
|
||||||
iframe.srcdoc = `<style>
|
iframe.srcdoc = `<style>
|
||||||
* { color:${neither}; }
|
* { color:${neither}; }
|
||||||
:defined { color:${defined}; }
|
:defined { color:${defined}; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue