Add form getters for additional elements; update test expectations

This adds form getters for fieldset, label, object, output, select and
textarea elements.
This commit is contained in:
Philipp Hartwig 2015-09-27 19:08:53 +02:00
parent a1fb8cfbb0
commit 8d67914c7f
14 changed files with 83 additions and 61 deletions

View file

@ -5,7 +5,7 @@
use dom::attr::Attr; use dom::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding; use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding::HTMLFieldSetElementMethods; 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::codegen::InheritTypes::{HTMLFieldSetElementDerived, NodeCast};
use dom::bindings::js::{Root, RootedReference}; use dom::bindings::js::{Root, RootedReference};
use dom::document::Document; use dom::document::Document;
@ -13,6 +13,7 @@ use dom::element::{AttributeMutation, Element, ElementTypeId};
use dom::eventtarget::{EventTarget, EventTargetTypeId}; use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlcollection::{CollectionFilter, HTMLCollection}; use dom::htmlcollection::{CollectionFilter, HTMLCollection};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{Node, NodeTypeId, window_from_node}; use dom::node::{Node, NodeTypeId, window_from_node};
use dom::validitystate::ValidityState; use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods; use dom::virtualmethods::VirtualMethods;
@ -79,6 +80,11 @@ impl HTMLFieldSetElementMethods for HTMLFieldSetElement {
// https://www.whatwg.org/html/#dom-fieldset-disabled // https://www.whatwg.org/html/#dom-fieldset-disabled
make_bool_setter!(SetDisabled, "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 { impl VirtualMethods for HTMLFieldSetElement {
@ -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)
}
}

View file

@ -3,12 +3,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLLabelElementBinding; 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::codegen::InheritTypes::HTMLLabelElementDerived;
use dom::bindings::js::Root; use dom::bindings::js::Root;
use dom::document::Document; use dom::document::Document;
use dom::element::ElementTypeId; use dom::element::{Element, ElementTypeId};
use dom::eventtarget::{EventTarget, EventTargetTypeId}; use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{Node, NodeTypeId}; use dom::node::{Node, NodeTypeId};
use util::str::DOMString; use util::str::DOMString;
@ -43,3 +46,16 @@ impl HTMLLabelElement {
Node::reflect_node(box element, document, HTMLLabelElementBinding::Wrap) 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)
}
}

View file

@ -10,9 +10,10 @@ use dom::bindings::codegen::InheritTypes::HTMLObjectElementDerived;
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast}; use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast};
use dom::bindings::js::Root; use dom::bindings::js::Root;
use dom::document::Document; use dom::document::Document;
use dom::element::{AttributeMutation, ElementTypeId}; use dom::element::{AttributeMutation, Element, ElementTypeId};
use dom::eventtarget::{EventTarget, EventTargetTypeId}; use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{Node, NodeTypeId, window_from_node}; use dom::node::{Node, NodeTypeId, window_from_node};
use dom::validitystate::ValidityState; use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods; use dom::virtualmethods::VirtualMethods;
@ -92,6 +93,11 @@ impl HTMLObjectElementMethods for HTMLObjectElement {
// https://html.spec.whatwg.org/multipage/#dom-object-type // https://html.spec.whatwg.org/multipage/#dom-object-type
make_setter!(SetType, "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 { impl VirtualMethods for HTMLObjectElement {
@ -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)
}
}

View file

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

View file

@ -5,15 +5,16 @@
use dom::attr::{Attr, AttrValue}; use dom::attr::{Attr, AttrValue};
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding; use dom::bindings::codegen::Bindings::HTMLSelectElementBinding;
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods; 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::InheritTypes::{HTMLFieldSetElementDerived, HTMLSelectElementDerived};
use dom::bindings::codegen::UnionTypes::HTMLElementOrLong; use dom::bindings::codegen::UnionTypes::HTMLElementOrLong;
use dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement; use dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement;
use dom::bindings::js::Root; use dom::bindings::js::Root;
use dom::document::Document; use dom::document::Document;
use dom::element::{AttributeMutation, ElementTypeId}; use dom::element::{AttributeMutation, Element, ElementTypeId};
use dom::eventtarget::{EventTarget, EventTargetTypeId}; use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{Node, NodeTypeId, window_from_node}; use dom::node::{Node, NodeTypeId, window_from_node};
use dom::validitystate::ValidityState; use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods; use dom::virtualmethods::VirtualMethods;
@ -73,6 +74,11 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
// https://www.whatwg.org/html/#dom-fe-disabled // https://www.whatwg.org/html/#dom-fe-disabled
make_bool_setter!(SetDisabled, "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 // https://html.spec.whatwg.org/multipage/#dom-select-multiple
make_bool_getter!(Multiple); make_bool_getter!(Multiple);
@ -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)
}
}

View file

@ -19,7 +19,7 @@ use dom::element::{AttributeMutation, Element, ElementTypeId};
use dom::event::{Event, EventBubbles, EventCancelable}; use dom::event::{Event, EventBubbles, EventCancelable};
use dom::eventtarget::{EventTarget, EventTargetTypeId}; use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlformelement::FormControl; use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::keyboardevent::KeyboardEvent; use dom::keyboardevent::KeyboardEvent;
use dom::node::{ChildrenMutation, Node, NodeDamage}; use dom::node::{ChildrenMutation, Node, NodeDamage};
use dom::node::{NodeTypeId, document_from_node, window_from_node}; use dom::node::{NodeTypeId, document_from_node, window_from_node};
@ -129,6 +129,11 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement {
// https://www.whatwg.org/html/#dom-fe-disabled // https://www.whatwg.org/html/#dom-fe-disabled
make_bool_setter!(SetDisabled, "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 // https://html.spec.whatwg.org/multipage/#attr-fe-name
make_getter!(Name); make_getter!(Name);

View file

@ -6,7 +6,7 @@
// https://www.whatwg.org/html/#htmlfieldsetelement // https://www.whatwg.org/html/#htmlfieldsetelement
interface HTMLFieldSetElement : HTMLElement { interface HTMLFieldSetElement : HTMLElement {
attribute boolean disabled; attribute boolean disabled;
//readonly attribute HTMLFormElement? form; readonly attribute HTMLFormElement? form;
// attribute DOMString name; // attribute DOMString name;
//readonly attribute DOMString type; //readonly attribute DOMString type;

View file

@ -5,7 +5,7 @@
// https://www.whatwg.org/html/#htmllabelelement // https://www.whatwg.org/html/#htmllabelelement
interface HTMLLabelElement : HTMLElement { interface HTMLLabelElement : HTMLElement {
//readonly attribute HTMLFormElement? form; readonly attribute HTMLFormElement? form;
// attribute DOMString htmlFor; // attribute DOMString htmlFor;
//readonly attribute HTMLElement? control; //readonly attribute HTMLElement? control;
}; };

View file

@ -10,7 +10,7 @@ interface HTMLObjectElement : HTMLElement {
// attribute boolean typeMustMatch; // attribute boolean typeMustMatch;
// attribute DOMString name; // attribute DOMString name;
// attribute DOMString useMap; // attribute DOMString useMap;
//readonly attribute HTMLFormElement? form; readonly attribute HTMLFormElement? form;
// attribute DOMString width; // attribute DOMString width;
// attribute DOMString height; // attribute DOMString height;
//readonly attribute Document? contentDocument; //readonly attribute Document? contentDocument;

View file

@ -6,7 +6,7 @@
// https://www.whatwg.org/html/#htmloutputelement // https://www.whatwg.org/html/#htmloutputelement
interface HTMLOutputElement : HTMLElement { interface HTMLOutputElement : HTMLElement {
//[PutForwards=value] readonly attribute DOMSettableTokenList htmlFor; //[PutForwards=value] readonly attribute DOMSettableTokenList htmlFor;
//readonly attribute HTMLFormElement? form; readonly attribute HTMLFormElement? form;
// attribute DOMString name; // attribute DOMString name;
//readonly attribute DOMString type; //readonly attribute DOMString type;

View file

@ -7,7 +7,7 @@
interface HTMLSelectElement : HTMLElement { interface HTMLSelectElement : HTMLElement {
// attribute boolean autofocus; // attribute boolean autofocus;
attribute boolean disabled; attribute boolean disabled;
//readonly attribute HTMLFormElement? form; readonly attribute HTMLFormElement? form;
attribute boolean multiple; attribute boolean multiple;
attribute DOMString name; attribute DOMString name;
// attribute boolean required; // attribute boolean required;

View file

@ -11,7 +11,7 @@ interface HTMLTextAreaElement : HTMLElement {
attribute unsigned long cols; attribute unsigned long cols;
// attribute DOMString dirName; // attribute DOMString dirName;
attribute boolean disabled; attribute boolean disabled;
//readonly attribute HTMLFormElement? form; readonly attribute HTMLFormElement? form;
// attribute DOMString inputMode; // attribute DOMString inputMode;
// attribute long maxLength; // attribute long maxLength;
// attribute long minLength; // attribute long minLength;

View file

@ -2730,9 +2730,6 @@
[HTMLObjectElement interface: attribute useMap] [HTMLObjectElement interface: attribute useMap]
expected: FAIL expected: FAIL
[HTMLObjectElement interface: attribute form]
expected: FAIL
[HTMLObjectElement interface: attribute width] [HTMLObjectElement interface: attribute width]
expected: FAIL expected: FAIL
@ -5031,18 +5028,12 @@
[HTMLLabelElement interface: existence and properties of interface object] [HTMLLabelElement interface: existence and properties of interface object]
expected: FAIL expected: FAIL
[HTMLLabelElement interface: attribute form]
expected: FAIL
[HTMLLabelElement interface: attribute htmlFor] [HTMLLabelElement interface: attribute htmlFor]
expected: FAIL expected: FAIL
[HTMLLabelElement interface: attribute control] [HTMLLabelElement interface: attribute control]
expected: FAIL 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)] [HTMLLabelElement interface: document.createElement("label") must inherit property "htmlFor" with the proper type (1)]
expected: FAIL expected: FAIL
@ -5391,9 +5382,6 @@
[HTMLSelectElement interface: attribute autofocus] [HTMLSelectElement interface: attribute autofocus]
expected: FAIL expected: FAIL
[HTMLSelectElement interface: attribute form]
expected: FAIL
[HTMLSelectElement interface: attribute required] [HTMLSelectElement interface: attribute required]
expected: FAIL expected: FAIL
@ -5448,9 +5436,6 @@
[HTMLSelectElement interface: document.createElement("select") must inherit property "autofocus" with the proper type (1)] [HTMLSelectElement interface: document.createElement("select") must inherit property "autofocus" with the proper type (1)]
expected: FAIL 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)] [HTMLSelectElement interface: document.createElement("select") must inherit property "required" with the proper type (6)]
expected: FAIL expected: FAIL
@ -5553,9 +5538,6 @@
[HTMLTextAreaElement interface: attribute dirName] [HTMLTextAreaElement interface: attribute dirName]
expected: FAIL expected: FAIL
[HTMLTextAreaElement interface: attribute form]
expected: FAIL
[HTMLTextAreaElement interface: attribute inputMode] [HTMLTextAreaElement interface: attribute inputMode]
expected: FAIL expected: FAIL
@ -5619,9 +5601,6 @@
[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "dirName" with the proper type (3)] [HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "dirName" with the proper type (3)]
expected: FAIL 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)] [HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "inputMode" with the proper type (6)]
expected: FAIL expected: FAIL
@ -5799,9 +5778,6 @@
[HTMLOutputElement interface: attribute htmlFor] [HTMLOutputElement interface: attribute htmlFor]
expected: FAIL expected: FAIL
[HTMLOutputElement interface: attribute form]
expected: FAIL
[HTMLOutputElement interface: attribute name] [HTMLOutputElement interface: attribute name]
expected: FAIL expected: FAIL
@ -5835,9 +5811,6 @@
[HTMLOutputElement interface: document.createElement("output") must inherit property "htmlFor" with the proper type (0)] [HTMLOutputElement interface: document.createElement("output") must inherit property "htmlFor" with the proper type (0)]
expected: FAIL 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)] [HTMLOutputElement interface: document.createElement("output") must inherit property "name" with the proper type (2)]
expected: FAIL expected: FAIL
@ -5946,9 +5919,6 @@
[HTMLFieldSetElement interface: existence and properties of interface object] [HTMLFieldSetElement interface: existence and properties of interface object]
expected: FAIL expected: FAIL
[HTMLFieldSetElement interface: attribute form]
expected: FAIL
[HTMLFieldSetElement interface: attribute name] [HTMLFieldSetElement interface: attribute name]
expected: FAIL expected: FAIL

View file

@ -1,23 +1,5 @@
[form.html] [form.html]
type: testharness type: testharness
[fieldset.form]
expected: FAIL
[keygen.form] [keygen.form]
expected: FAIL expected: FAIL
[label.form]
expected: FAIL
[object.form]
expected: FAIL
[output.form]
expected: FAIL
[select.form]
expected: FAIL
[textarea.form]
expected: FAIL