servo: Merge #7760 - Add form getters for additional elements; update test expectations (from aopicier:form_getter); r=Manishearth
authorPhilipp Hartwig <ph@phhart.de>
Mon, 28 Sep 2015 13:23:18 -0600
changeset 337220 d6d32c55b4db3666dbee5fead2ba73bf955db941
parent 337219 af1f5a7fecadbd7f6549b3033345a0bd25783c4d
child 337221 d369697e55f5f713710a427bd47caff6fd888701
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersManishearth
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
servo/components/script/dom/htmlfieldsetelement.rs
servo/components/script/dom/htmllabelelement.rs
servo/components/script/dom/htmlobjectelement.rs
servo/components/script/dom/htmloutputelement.rs
servo/components/script/dom/htmlselectelement.rs
servo/components/script/dom/htmltextareaelement.rs
servo/components/script/dom/webidls/HTMLFieldSetElement.webidl
servo/components/script/dom/webidls/HTMLLabelElement.webidl
servo/components/script/dom/webidls/HTMLObjectElement.webidl
servo/components/script/dom/webidls/HTMLOutputElement.webidl
servo/components/script/dom/webidls/HTMLSelectElement.webidl
servo/components/script/dom/webidls/HTMLTextAreaElement.webidl
--- a/servo/components/script/dom/htmlfieldsetelement.rs
+++ b/servo/components/script/dom/htmlfieldsetelement.rs
@@ -1,23 +1,24 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 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;
 use util::str::{DOMString, StaticStringVec};
 
 #[dom_struct]
 pub struct HTMLFieldSetElement {
     htmlelement: HTMLElement
@@ -74,16 +75,21 @@ impl HTMLFieldSetElementMethods for HTML
         ValidityState::new(window.r())
     }
 
     // https://www.whatwg.org/html/#dom-fieldset-disabled
     make_bool_getter!(Disabled);
 
     // 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 {
     fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> {
         let htmlelement: &HTMLElement = HTMLElementCast::from_ref(self);
         Some(htmlelement as &VirtualMethods)
     }
 
@@ -145,8 +151,14 @@ impl VirtualMethods for HTMLFieldSetElem
                         field.check_ancestors_disabled_state_for_form_control();
                     }
                 }
             },
             _ => {},
         }
     }
 }
+
+impl<'a> FormControl<'a> for &'a HTMLFieldSetElement {
+    fn to_element(self) -> &'a Element {
+        ElementCast::from_ref(self)
+    }
+}
--- a/servo/components/script/dom/htmllabelelement.rs
+++ b/servo/components/script/dom/htmllabelelement.rs
@@ -1,19 +1,22 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * 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;
 
 #[dom_struct]
 pub struct HTMLLabelElement {
     htmlelement: HTMLElement,
 }
 
@@ -38,8 +41,21 @@ impl HTMLLabelElement {
     #[allow(unrooted_must_root)]
     pub fn new(localName: DOMString,
                prefix: Option<DOMString>,
                document: &Document) -> Root<HTMLLabelElement> {
         let element = HTMLLabelElement::new_inherited(localName, prefix, document);
         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)
+    }
+}
--- a/servo/components/script/dom/htmlobjectelement.rs
+++ b/servo/components/script/dom/htmlobjectelement.rs
@@ -5,19 +5,20 @@
 use dom::attr::Attr;
 use dom::bindings::cell::DOMRefCell;
 use dom::bindings::codegen::Bindings::HTMLObjectElementBinding;
 use dom::bindings::codegen::Bindings::HTMLObjectElementBinding::HTMLObjectElementMethods;
 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;
 use net_traits::image::base::Image;
 use std::sync::Arc;
 use util::str::DOMString;
 
 #[dom_struct]
@@ -87,16 +88,21 @@ impl HTMLObjectElementMethods for HTMLOb
         ValidityState::new(window.r())
     }
 
     // https://html.spec.whatwg.org/multipage/#dom-object-type
     make_getter!(Type);
 
     // 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 {
     fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> {
         let htmlelement: &HTMLElement = HTMLElementCast::from_ref(self);
         Some(htmlelement as &VirtualMethods)
     }
 
@@ -107,8 +113,14 @@ impl VirtualMethods for HTMLObjectElemen
                 if let AttributeMutation::Set(_) = mutation {
                     self.process_data_url();
                 }
             },
             _ => {},
         }
     }
 }
+
+impl<'a> FormControl<'a> for &'a HTMLObjectElement {
+    fn to_element(self) -> &'a Element {
+        ElementCast::from_ref(self)
+    }
+}
--- a/servo/components/script/dom/htmloutputelement.rs
+++ b/servo/components/script/dom/htmloutputelement.rs
@@ -1,20 +1,22 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 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;
 
 #[dom_struct]
 pub struct HTMLOutputElement {
     htmlelement: HTMLElement
 }
@@ -47,9 +49,20 @@ impl HTMLOutputElement {
 }
 
 impl HTMLOutputElementMethods for HTMLOutputElement {
     // https://html.spec.whatwg.org/multipage/#dom-cva-validity
     fn Validity(&self) -> Root<ValidityState> {
         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)
+    }
+}
--- a/servo/components/script/dom/htmlselectelement.rs
+++ b/servo/components/script/dom/htmlselectelement.rs
@@ -1,24 +1,25 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 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;
 use std::borrow::ToOwned;
 use string_cache::Atom;
 use util::str::DOMString;
 
 #[dom_struct]
@@ -68,16 +69,21 @@ impl HTMLSelectElementMethods for HTMLSe
     }
 
     // https://www.whatwg.org/html/#dom-fe-disabled
     make_bool_getter!(Disabled);
 
     // 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);
 
     // https://html.spec.whatwg.org/multipage/#dom-select-multiple
     make_bool_setter!(SetMultiple, "multiple");
 
     // https://html.spec.whatwg.org/multipage/#dom-fe-name
     make_getter!(Name);
@@ -149,8 +155,14 @@ impl VirtualMethods for HTMLSelectElemen
 
     fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
         match local_name {
             &atom!("size") => AttrValue::from_u32(value, DEFAULT_SELECT_SIZE),
             _ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
         }
     }
 }
+
+impl<'a> FormControl<'a> for &'a HTMLSelectElement {
+    fn to_element(self) -> &'a Element {
+        ElementCast::from_ref(self)
+    }
+}
--- a/servo/components/script/dom/htmltextareaelement.rs
+++ b/servo/components/script/dom/htmltextareaelement.rs
@@ -14,17 +14,17 @@ use dom::bindings::codegen::InheritTypes
 use dom::bindings::global::GlobalRef;
 use dom::bindings::js::{LayoutJS, Root};
 use dom::bindings::refcounted::Trusted;
 use dom::document::Document;
 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};
 use dom::virtualmethods::VirtualMethods;
 use msg::constellation_msg::ConstellationChan;
 use script_task::ScriptTaskEventCategory::InputEvent;
 use script_task::{CommonScriptMsg, Runnable};
 use std::borrow::ToOwned;
@@ -124,16 +124,21 @@ impl HTMLTextAreaElementMethods for HTML
     make_limited_uint_setter!(SetCols, "cols", DEFAULT_COLS);
 
     // https://www.whatwg.org/html/#dom-fe-disabled
     make_bool_getter!(Disabled);
 
     // 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);
 
     // https://html.spec.whatwg.org/multipage/#attr-fe-name
     make_setter!(SetName, "name");
 
     // https://html.spec.whatwg.org/multipage/#dom-textarea-placeholder
     make_getter!(Placeholder);
--- a/servo/components/script/dom/webidls/HTMLFieldSetElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLFieldSetElement.webidl
@@ -1,17 +1,17 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // 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;
 
   //readonly attribute HTMLFormControlsCollection elements;
   readonly attribute HTMLCollection elements;
 
   //readonly attribute boolean willValidate;
--- a/servo/components/script/dom/webidls/HTMLLabelElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLLabelElement.webidl
@@ -1,11 +1,11 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://www.whatwg.org/html/#htmllabelelement
 interface HTMLLabelElement : HTMLElement {
-  //readonly attribute HTMLFormElement? form;
+  readonly attribute HTMLFormElement? form;
   //         attribute DOMString htmlFor;
   //readonly attribute HTMLElement? control;
 };
--- a/servo/components/script/dom/webidls/HTMLObjectElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLObjectElement.webidl
@@ -5,17 +5,17 @@
 
 // https://www.whatwg.org/html/#htmlobjectelement
 interface HTMLObjectElement : HTMLElement {
   //         attribute DOMString data;
            attribute DOMString type;
   //         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;
   //readonly attribute WindowProxy? contentWindow;
 
   //readonly attribute boolean willValidate;
   readonly attribute ValidityState validity;
   //readonly attribute DOMString validationMessage;
--- a/servo/components/script/dom/webidls/HTMLOutputElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLOutputElement.webidl
@@ -1,17 +1,17 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // 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;
   //         attribute DOMString defaultValue;
   //         attribute DOMString value;
 
   //readonly attribute boolean willValidate;
   readonly attribute ValidityState validity;
--- a/servo/components/script/dom/webidls/HTMLSelectElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLSelectElement.webidl
@@ -2,17 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://www.whatwg.org/html/#htmlselectelement
 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;
            attribute unsigned long size;
 
   readonly attribute DOMString type;
 
   //readonly attribute HTMLOptionsCollection options;
--- a/servo/components/script/dom/webidls/HTMLTextAreaElement.webidl
+++ b/servo/components/script/dom/webidls/HTMLTextAreaElement.webidl
@@ -6,17 +6,17 @@
 // https://www.whatwg.org/html/#htmltextareaelement
 interface HTMLTextAreaElement : HTMLElement {
   //         attribute DOMString autocomplete;
   //         attribute boolean autofocus;
              [SetterThrows]
              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;
            attribute DOMString name;
            attribute DOMString placeholder;
            attribute boolean readOnly;
            attribute boolean required;
            [SetterThrows]