From 80d9a2bb4f53090f07b1fd4900ddcf7d49f6fdac Mon Sep 17 00:00:00 2001 From: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> Date: Tue, 26 Sep 2023 18:37:46 -0300 Subject: [PATCH] Treat the `keygen` element as obsolete (#30429) * Eradicate the `keygen` element * Run `./mach fmt` * Fix relevant Servo test * Fix outdated manifest --- components/script/dom/create.rs | 2 ++ components/script/dom/document.rs | 22 +++++++++++++------ components/script/dom/htmlelement.rs | 7 ------ components/script/dom/htmlformelement.rs | 13 ++++------- .../script/dom/servoparser/async_html.rs | 7 ------ components/script/dom/servoparser/mod.rs | 7 ------ resources/iso-8859-8.css | 2 +- resources/user-agent.css | 2 +- tests/wpt/mozilla/meta/MANIFEST.json | 2 +- .../mozilla/htmlfieldsetelement_elements.html | 14 ++++++------ 10 files changed, 31 insertions(+), 47 deletions(-) diff --git a/components/script/dom/create.rs b/components/script/dom/create.rs index c53bf3516cf..d97ad1add04 100644 --- a/components/script/dom/create.rs +++ b/components/script/dom/create.rs @@ -308,6 +308,8 @@ pub fn create_native_html_element( // https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:isindex-2 local_name!("isindex") => make!(HTMLUnknownElement), local_name!("kbd") => make!(HTMLElement), + // https://html.spec.whatwg.org/multipage/#keygen + local_name!("keygen") => make!(HTMLUnknownElement), local_name!("label") => make!(HTMLLabelElement), local_name!("legend") => make!(HTMLLegendElement), local_name!("li") => make!(HTMLLIElement), diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 070d8b0d906..c0c7ded2e3c 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -3949,13 +3949,21 @@ impl Element { fn click_event_filter_by_disabled_state(&self) -> bool { let node = self.upcast::(); match node.type_id() { - NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLButtonElement)) | - NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) | - // NodeTypeId::Element(ElementTypeId::HTMLKeygenElement) | - NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) | - NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) | - NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) - if self.disabled_state() => true, + NodeTypeId::Element(ElementTypeId::HTMLElement( + HTMLElementTypeId::HTMLButtonElement, + )) | + NodeTypeId::Element(ElementTypeId::HTMLElement( + HTMLElementTypeId::HTMLInputElement, + )) | + NodeTypeId::Element(ElementTypeId::HTMLElement( + HTMLElementTypeId::HTMLOptionElement, + )) | + NodeTypeId::Element(ElementTypeId::HTMLElement( + HTMLElementTypeId::HTMLSelectElement, + )) | + NodeTypeId::Element(ElementTypeId::HTMLElement( + HTMLElementTypeId::HTMLTextAreaElement, + )) if self.disabled_state() => true, _ => false, } } diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 01ba77278cd..c6cf8628896 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -650,7 +650,6 @@ impl HTMLElement { // https://html.spec.whatwg.org/multipage/#category-label pub fn is_labelable_element(&self) -> bool { - // Note: HTMLKeygenElement is omitted because Servo doesn't currently implement it match self.upcast::().type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(type_id)) => match type_id { HTMLElementTypeId::HTMLInputElement => { @@ -670,12 +669,6 @@ impl HTMLElement { // https://html.spec.whatwg.org/multipage/#category-listed pub fn is_listed_element(&self) -> bool { - // Servo does not implement HTMLKeygenElement - // https://github.com/servo/servo/issues/2782 - if self.upcast::().local_name() == &local_name!("keygen") { - return true; - } - match self.upcast::().type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(type_id)) => match type_id { HTMLElementTypeId::HTMLButtonElement | diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 6003ae66b06..a18d3209215 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -366,10 +366,10 @@ impl HTMLFormElementMethods for HTMLFormElement { elem.downcast::().unwrap().form_owner() }, _ => { - debug_assert!( - !elem.downcast::().unwrap().is_listed_element() || - elem.local_name() == &local_name!("keygen") - ); + debug_assert!(!elem + .downcast::() + .unwrap() + .is_listed_element()); return false; }, }, @@ -1287,11 +1287,6 @@ impl HTMLFormElement { )) => { child.downcast::().unwrap().reset(); }, - // TODO HTMLKeygenElement unimplemented - //NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLKeygenElement)) => { - // // Unimplemented - // {} - //} NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLSelectElement, )) => { diff --git a/components/script/dom/servoparser/async_html.rs b/components/script/dom/servoparser/async_html.rs index a06749a7fd0..08e3238754b 100644 --- a/components/script/dom/servoparser/async_html.rs +++ b/components/script/dom/servoparser/async_html.rs @@ -521,13 +521,6 @@ impl Tokenizer { if let Some(control) = control { control.set_form_owner_from_parser(&form); - } else { - // TODO remove this code when keygen is implemented. - assert_eq!( - node.NodeName(), - "KEYGEN", - "Unknown form-associatable element" - ); } }, ParseOperation::Pop { node } => { diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index ce99735e8b3..a21bec9b8c6 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -1182,13 +1182,6 @@ impl TreeSink for Sink { if let Some(control) = control { control.set_form_owner_from_parser(&form); - } else { - // TODO remove this code when keygen is implemented. - assert_eq!( - node.NodeName(), - "KEYGEN", - "Unknown form-associatable element" - ); } } diff --git a/resources/iso-8859-8.css b/resources/iso-8859-8.css index 3651061c391..9a34476860e 100644 --- a/resources/iso-8859-8.css +++ b/resources/iso-8859-8.css @@ -18,6 +18,6 @@ tbody, tfoot, tr, td, th, dir, dd, dl, dt, menu, ol, ul, li, [dir=ltr i], unicode-bidi: bidi-override; } input:not([type=submit i]):not([type=reset i]):not([type=button i]), -textarea, keygen { +textarea { unicode-bidi: normal; } diff --git a/resources/user-agent.css b/resources/user-agent.css index 06410f74b81..bc1a14c7815 100644 --- a/resources/user-agent.css +++ b/resources/user-agent.css @@ -250,7 +250,7 @@ table:matches( } -input, select, option, optgroup, button, textarea, keygen { +input, select, option, optgroup, button, textarea { text-indent: initial; text-transform: none; } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index c509870b10a..db7900cf84b 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -13256,7 +13256,7 @@ ] ], "htmlfieldsetelement_elements.html": [ - "ee0ea4ae15f1f9cd4e1cdb76c5f4c9f13e139bef", + "cb5757555f2f7c52803e50c6cd4f191f49dda4c5", [ null, {} diff --git a/tests/wpt/mozilla/tests/mozilla/htmlfieldsetelement_elements.html b/tests/wpt/mozilla/tests/mozilla/htmlfieldsetelement_elements.html index ee0ea4ae15f..cb5757555f2 100644 --- a/tests/wpt/mozilla/tests/mozilla/htmlfieldsetelement_elements.html +++ b/tests/wpt/mozilla/tests/mozilla/htmlfieldsetelement_elements.html @@ -7,6 +7,7 @@
+