servo: Merge #7760 - Add form getters for additional elements; update test expectations (from aopicier:form_getter); r=Manishearth

This adds form getters for fieldset, label, object, output, select and
textarea elements.

Source-Repo: https://github.com/servo/servo
Source-Revision: a72d7a4f5222d029a34b2b4a7da21ebe095fde53
This commit is contained in:
Philipp Hartwig 2015-09-28 13:23:18 -06:00
parent 3bd02a6984
commit 2bfabff31c
12 changed files with 83 additions and 13 deletions

View File

@ -5,7 +5,7 @@
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;
@ -13,6 +13,7 @@ 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;
@ -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 {
@ -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/. */
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;
@ -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)
}
}

View File

@ -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;
@ -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 {
@ -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::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;
@ -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)
}
}

View File

@ -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;
@ -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);
@ -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::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};
@ -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);

View File

@ -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;

View File

@ -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;
};

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;