Skip to content

Commit

Permalink
Treat the keygen element as obsolete (servo#30429)
Browse files Browse the repository at this point in the history
* Eradicate the `keygen` element

* Run `./mach fmt`

* Fix relevant Servo test

* Fix outdated manifest
  • Loading branch information
EnnuiL authored Sep 26, 2023
1 parent f330cf5 commit 80d9a2b
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 47 deletions.
2 changes: 2 additions & 0 deletions components/script/dom/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
22 changes: 15 additions & 7 deletions components/script/dom/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3949,13 +3949,21 @@ impl Element {
fn click_event_filter_by_disabled_state(&self) -> bool {
let node = self.upcast::<Node>();
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,
}
}
Expand Down
7 changes: 0 additions & 7 deletions components/script/dom/htmlelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Node>().type_id() {
NodeTypeId::Element(ElementTypeId::HTMLElement(type_id)) => match type_id {
HTMLElementTypeId::HTMLInputElement => {
Expand All @@ -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::<Element>().local_name() == &local_name!("keygen") {
return true;
}

match self.upcast::<Node>().type_id() {
NodeTypeId::Element(ElementTypeId::HTMLElement(type_id)) => match type_id {
HTMLElementTypeId::HTMLButtonElement |
Expand Down
13 changes: 4 additions & 9 deletions components/script/dom/htmlformelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ impl HTMLFormElementMethods for HTMLFormElement {
elem.downcast::<HTMLTextAreaElement>().unwrap().form_owner()
},
_ => {
debug_assert!(
!elem.downcast::<HTMLElement>().unwrap().is_listed_element() ||
elem.local_name() == &local_name!("keygen")
);
debug_assert!(!elem
.downcast::<HTMLElement>()
.unwrap()
.is_listed_element());
return false;
},
},
Expand Down Expand Up @@ -1287,11 +1287,6 @@ impl HTMLFormElement {
)) => {
child.downcast::<HTMLInputElement>().unwrap().reset();
},
// TODO HTMLKeygenElement unimplemented
//NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLKeygenElement)) => {
// // Unimplemented
// {}
//}
NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLSelectElement,
)) => {
Expand Down
7 changes: 0 additions & 7 deletions components/script/dom/servoparser/async_html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } => {
Expand Down
7 changes: 0 additions & 7 deletions components/script/dom/servoparser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion resources/iso-8859-8.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion resources/user-agent.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wpt/mozilla/meta/MANIFEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -13256,7 +13256,7 @@
]
],
"htmlfieldsetelement_elements.html": [
"ee0ea4ae15f1f9cd4e1cdb76c5f4c9f13e139bef",
"cb5757555f2f7c52803e50c6cd4f191f49dda4c5",
[
null,
{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<fieldset>
<button>Click!</button>
</fieldset>
<!-- The keygen element should not be recognized as a listed element -->
<keygen name="key">
<textarea>
A
Expand All @@ -31,17 +32,16 @@
<script>
test(function() {
var fs = document.getElementById("fs");
assert_equals(fs.elements.length, 10);
assert_equals(fs.elements.length, 9);
assert_true(fs.elements[0] instanceof HTMLInputElement, "Should be HTMLInputElement");
assert_true(fs.elements[1] instanceof HTMLFieldSetElement, "Should be HTMLFieldSetElement");
assert_true(fs.elements[2] instanceof HTMLButtonElement, "Should be HTMLButtonElement");
assert_true(fs.elements[3] instanceof HTMLUnknownElement, "Should be HTMLUnknownElement");
assert_true(fs.elements[4] instanceof HTMLTextAreaElement, "Should be HTMLTextAreaElement");
assert_true(fs.elements[5] instanceof HTMLSelectElement, "Should be HTMLSelectElement");
assert_true(fs.elements[3] instanceof HTMLTextAreaElement, "Should be HTMLTextAreaElement");
assert_true(fs.elements[4] instanceof HTMLSelectElement, "Should be HTMLSelectElement");
assert_true(fs.elements[5] instanceof HTMLInputElement, "Should be HTMLInputElement");
assert_true(fs.elements[6] instanceof HTMLInputElement, "Should be HTMLInputElement");
assert_true(fs.elements[7] instanceof HTMLInputElement, "Should be HTMLInputElement");
assert_true(fs.elements[8] instanceof HTMLOutputElement, "Should be HTMLOutputElement");
assert_true(fs.elements[9] instanceof HTMLObjectElement, "Should be HTMLObjectElement");
assert_true(fs.elements[7] instanceof HTMLOutputElement, "Should be HTMLOutputElement");
assert_true(fs.elements[8] instanceof HTMLObjectElement, "Should be HTMLObjectElement");
});
</script>
</html>

0 comments on commit 80d9a2b

Please sign in to comment.