Skip to content

Commit

Permalink
Add form getters for additional elements; update test expectations
Browse files Browse the repository at this point in the history
This adds form getters for fieldset, label, object, output, select and
textarea elements.
  • Loading branch information
aopicier committed Sep 27, 2015
1 parent a1fb8cf commit 8d67914
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 61 deletions.
14 changes: 13 additions & 1 deletion components/script/dom/htmlfieldsetelement.rs
Expand Up @@ -5,14 +5,15 @@
use dom::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding::HTMLFieldSetElementMethods;
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLLegendElementDerived};
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLLegendElementDerived};
use dom::bindings::codegen::InheritTypes::{HTMLFieldSetElementDerived, NodeCast};
use dom::bindings::js::{Root, RootedReference};
use dom::document::Document;
use dom::element::{AttributeMutation, Element, ElementTypeId};
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlcollection::{CollectionFilter, HTMLCollection};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{Node, NodeTypeId, window_from_node};
use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods;
Expand Down Expand Up @@ -79,6 +80,11 @@ impl HTMLFieldSetElementMethods for HTMLFieldSetElement {

// https://www.whatwg.org/html/#dom-fieldset-disabled
make_bool_setter!(SetDisabled, "disabled");

// https://html.spec.whatwg.org/multipage#dom-fae-form
fn GetForm(&self) -> Option<Root<HTMLFormElement>> {
self.form_owner()
}
}

impl VirtualMethods for HTMLFieldSetElement {
Expand Down Expand Up @@ -150,3 +156,9 @@ impl VirtualMethods for HTMLFieldSetElement {
}
}
}

impl<'a> FormControl<'a> for &'a HTMLFieldSetElement {
fn to_element(self) -> &'a Element {
ElementCast::from_ref(self)
}
}
18 changes: 17 additions & 1 deletion components/script/dom/htmllabelelement.rs
Expand Up @@ -3,12 +3,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use dom::bindings::codegen::Bindings::HTMLLabelElementBinding;
use dom::bindings::codegen::Bindings::HTMLLabelElementBinding::HTMLLabelElementMethods;
use dom::bindings::codegen::InheritTypes::ElementCast;
use dom::bindings::codegen::InheritTypes::HTMLLabelElementDerived;
use dom::bindings::js::Root;
use dom::document::Document;
use dom::element::ElementTypeId;
use dom::element::{Element, ElementTypeId};
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{Node, NodeTypeId};
use util::str::DOMString;

Expand Down Expand Up @@ -43,3 +46,16 @@ impl HTMLLabelElement {
Node::reflect_node(box element, document, HTMLLabelElementBinding::Wrap)
}
}

impl HTMLLabelElementMethods for HTMLLabelElement {
// https://html.spec.whatwg.org/multipage#dom-fae-form
fn GetForm(&self) -> Option<Root<HTMLFormElement>> {
self.form_owner()
}
}

impl<'a> FormControl<'a> for &'a HTMLLabelElement {
fn to_element(self) -> &'a Element {
ElementCast::from_ref(self)
}
}
14 changes: 13 additions & 1 deletion components/script/dom/htmlobjectelement.rs
Expand Up @@ -10,9 +10,10 @@ use dom::bindings::codegen::InheritTypes::HTMLObjectElementDerived;
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast};
use dom::bindings::js::Root;
use dom::document::Document;
use dom::element::{AttributeMutation, ElementTypeId};
use dom::element::{AttributeMutation, Element, ElementTypeId};
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{Node, NodeTypeId, window_from_node};
use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods;
Expand Down Expand Up @@ -92,6 +93,11 @@ impl HTMLObjectElementMethods for HTMLObjectElement {

// https://html.spec.whatwg.org/multipage/#dom-object-type
make_setter!(SetType, "type");

// https://html.spec.whatwg.org/multipage#dom-fae-form
fn GetForm(&self) -> Option<Root<HTMLFormElement>> {
self.form_owner()
}
}

impl VirtualMethods for HTMLObjectElement {
Expand All @@ -112,3 +118,9 @@ impl VirtualMethods for HTMLObjectElement {
}
}
}

impl<'a> FormControl<'a> for &'a HTMLObjectElement {
fn to_element(self) -> &'a Element {
ElementCast::from_ref(self)
}
}
15 changes: 14 additions & 1 deletion components/script/dom/htmloutputelement.rs
Expand Up @@ -4,12 +4,14 @@

use dom::bindings::codegen::Bindings::HTMLOutputElementBinding;
use dom::bindings::codegen::Bindings::HTMLOutputElementBinding::HTMLOutputElementMethods;
use dom::bindings::codegen::InheritTypes::ElementCast;
use dom::bindings::codegen::InheritTypes::HTMLOutputElementDerived;
use dom::bindings::js::Root;
use dom::document::Document;
use dom::element::ElementTypeId;
use dom::element::{Element, ElementTypeId};
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{Node, NodeTypeId, window_from_node};
use dom::validitystate::ValidityState;
use util::str::DOMString;
Expand Down Expand Up @@ -52,4 +54,15 @@ impl HTMLOutputElementMethods for HTMLOutputElement {
let window = window_from_node(self);
ValidityState::new(window.r())
}

// https://html.spec.whatwg.org/multipage#dom-fae-form
fn GetForm(&self) -> Option<Root<HTMLFormElement>> {
self.form_owner()
}
}

impl<'a> FormControl<'a> for &'a HTMLOutputElement {
fn to_element(self) -> &'a Element {
ElementCast::from_ref(self)
}
}
16 changes: 14 additions & 2 deletions components/script/dom/htmlselectelement.rs
Expand Up @@ -5,15 +5,16 @@
use dom::attr::{Attr, AttrValue};
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding;
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods;
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, NodeCast};
use dom::bindings::codegen::InheritTypes::{HTMLFieldSetElementDerived, HTMLSelectElementDerived};
use dom::bindings::codegen::UnionTypes::HTMLElementOrLong;
use dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement;
use dom::bindings::js::Root;
use dom::document::Document;
use dom::element::{AttributeMutation, ElementTypeId};
use dom::element::{AttributeMutation, Element, ElementTypeId};
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{Node, NodeTypeId, window_from_node};
use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods;
Expand Down Expand Up @@ -73,6 +74,11 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
// https://www.whatwg.org/html/#dom-fe-disabled
make_bool_setter!(SetDisabled, "disabled");

// https://html.spec.whatwg.org/multipage#dom-fae-form
fn GetForm(&self) -> Option<Root<HTMLFormElement>> {
self.form_owner()
}

// https://html.spec.whatwg.org/multipage/#dom-select-multiple
make_bool_getter!(Multiple);

Expand Down Expand Up @@ -154,3 +160,9 @@ impl VirtualMethods for HTMLSelectElement {
}
}
}

impl<'a> FormControl<'a> for &'a HTMLSelectElement {
fn to_element(self) -> &'a Element {
ElementCast::from_ref(self)
}
}
7 changes: 6 additions & 1 deletion components/script/dom/htmltextareaelement.rs
Expand Up @@ -19,7 +19,7 @@ use dom::element::{AttributeMutation, Element, ElementTypeId};
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlformelement::FormControl;
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::keyboardevent::KeyboardEvent;
use dom::node::{ChildrenMutation, Node, NodeDamage};
use dom::node::{NodeTypeId, document_from_node, window_from_node};
Expand Down Expand Up @@ -129,6 +129,11 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement {
// https://www.whatwg.org/html/#dom-fe-disabled
make_bool_setter!(SetDisabled, "disabled");

// https://html.spec.whatwg.org/multipage#dom-fae-form
fn GetForm(&self) -> Option<Root<HTMLFormElement>> {
self.form_owner()
}

// https://html.spec.whatwg.org/multipage/#attr-fe-name
make_getter!(Name);

Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/webidls/HTMLFieldSetElement.webidl
Expand Up @@ -6,7 +6,7 @@
// https://www.whatwg.org/html/#htmlfieldsetelement
interface HTMLFieldSetElement : HTMLElement {
attribute boolean disabled;
//readonly attribute HTMLFormElement? form;
readonly attribute HTMLFormElement? form;
// attribute DOMString name;

//readonly attribute DOMString type;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/webidls/HTMLLabelElement.webidl
Expand Up @@ -5,7 +5,7 @@

// https://www.whatwg.org/html/#htmllabelelement
interface HTMLLabelElement : HTMLElement {
//readonly attribute HTMLFormElement? form;
readonly attribute HTMLFormElement? form;
// attribute DOMString htmlFor;
//readonly attribute HTMLElement? control;
};
2 changes: 1 addition & 1 deletion components/script/dom/webidls/HTMLObjectElement.webidl
Expand Up @@ -10,7 +10,7 @@ interface HTMLObjectElement : HTMLElement {
// attribute boolean typeMustMatch;
// attribute DOMString name;
// attribute DOMString useMap;
//readonly attribute HTMLFormElement? form;
readonly attribute HTMLFormElement? form;
// attribute DOMString width;
// attribute DOMString height;
//readonly attribute Document? contentDocument;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/webidls/HTMLOutputElement.webidl
Expand Up @@ -6,7 +6,7 @@
// https://www.whatwg.org/html/#htmloutputelement
interface HTMLOutputElement : HTMLElement {
//[PutForwards=value] readonly attribute DOMSettableTokenList htmlFor;
//readonly attribute HTMLFormElement? form;
readonly attribute HTMLFormElement? form;
// attribute DOMString name;

//readonly attribute DOMString type;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/webidls/HTMLSelectElement.webidl
Expand Up @@ -7,7 +7,7 @@
interface HTMLSelectElement : HTMLElement {
// attribute boolean autofocus;
attribute boolean disabled;
//readonly attribute HTMLFormElement? form;
readonly attribute HTMLFormElement? form;
attribute boolean multiple;
attribute DOMString name;
// attribute boolean required;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/webidls/HTMLTextAreaElement.webidl
Expand Up @@ -11,7 +11,7 @@ interface HTMLTextAreaElement : HTMLElement {
attribute unsigned long cols;
// attribute DOMString dirName;
attribute boolean disabled;
//readonly attribute HTMLFormElement? form;
readonly attribute HTMLFormElement? form;
// attribute DOMString inputMode;
// attribute long maxLength;
// attribute long minLength;
Expand Down
30 changes: 0 additions & 30 deletions tests/wpt/metadata/html/dom/interfaces.html.ini
Expand Up @@ -2730,9 +2730,6 @@
[HTMLObjectElement interface: attribute useMap]
expected: FAIL

[HTMLObjectElement interface: attribute form]
expected: FAIL

[HTMLObjectElement interface: attribute width]
expected: FAIL

Expand Down Expand Up @@ -5031,18 +5028,12 @@
[HTMLLabelElement interface: existence and properties of interface object]
expected: FAIL

[HTMLLabelElement interface: attribute form]
expected: FAIL

[HTMLLabelElement interface: attribute htmlFor]
expected: FAIL

[HTMLLabelElement interface: attribute control]
expected: FAIL

[HTMLLabelElement interface: document.createElement("label") must inherit property "form" with the proper type (0)]
expected: FAIL

[HTMLLabelElement interface: document.createElement("label") must inherit property "htmlFor" with the proper type (1)]
expected: FAIL

Expand Down Expand Up @@ -5391,9 +5382,6 @@
[HTMLSelectElement interface: attribute autofocus]
expected: FAIL

[HTMLSelectElement interface: attribute form]
expected: FAIL

[HTMLSelectElement interface: attribute required]
expected: FAIL

Expand Down Expand Up @@ -5448,9 +5436,6 @@
[HTMLSelectElement interface: document.createElement("select") must inherit property "autofocus" with the proper type (1)]
expected: FAIL

[HTMLSelectElement interface: document.createElement("select") must inherit property "form" with the proper type (3)]
expected: FAIL

[HTMLSelectElement interface: document.createElement("select") must inherit property "required" with the proper type (6)]
expected: FAIL

Expand Down Expand Up @@ -5553,9 +5538,6 @@
[HTMLTextAreaElement interface: attribute dirName]
expected: FAIL

[HTMLTextAreaElement interface: attribute form]
expected: FAIL

[HTMLTextAreaElement interface: attribute inputMode]
expected: FAIL

Expand Down Expand Up @@ -5619,9 +5601,6 @@
[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "dirName" with the proper type (3)]
expected: FAIL

[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "form" with the proper type (5)]
expected: FAIL

[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "inputMode" with the proper type (6)]
expected: FAIL

Expand Down Expand Up @@ -5799,9 +5778,6 @@
[HTMLOutputElement interface: attribute htmlFor]
expected: FAIL
[HTMLOutputElement interface: attribute form]
expected: FAIL
[HTMLOutputElement interface: attribute name]
expected: FAIL
Expand Down Expand Up @@ -5835,9 +5811,6 @@
[HTMLOutputElement interface: document.createElement("output") must inherit property "htmlFor" with the proper type (0)]
expected: FAIL
[HTMLOutputElement interface: document.createElement("output") must inherit property "form" with the proper type (1)]
expected: FAIL
[HTMLOutputElement interface: document.createElement("output") must inherit property "name" with the proper type (2)]
expected: FAIL
Expand Down Expand Up @@ -5946,9 +5919,6 @@
[HTMLFieldSetElement interface: existence and properties of interface object]
expected: FAIL
[HTMLFieldSetElement interface: attribute form]
expected: FAIL
[HTMLFieldSetElement interface: attribute name]
expected: FAIL
Expand Down
@@ -1,23 +1,5 @@
[form.html]
type: testharness
[fieldset.form]
expected: FAIL

[keygen.form]
expected: FAIL

[label.form]
expected: FAIL

[object.form]
expected: FAIL

[output.form]
expected: FAIL

[select.form]
expected: FAIL

[textarea.form]
expected: FAIL

0 comments on commit 8d67914

Please sign in to comment.