aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlformelement.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-09-30 19:06:18 -0600
committerbors-servo <metajack+bors@gmail.com>2015-09-30 19:06:18 -0600
commit94e85a5226fe5b18bde40a2d5f6727b717bd148f (patch)
treec4ac4972811867509d341485c7216865e30b698d /components/script/dom/htmlformelement.rs
parentbb7742eecf00dd4cb5bfcbafcae36d928a5b8b89 (diff)
parentb46243c00bda362df9891895d5496ace599971ea (diff)
downloadservo-94e85a5226fe5b18bde40a2d5f6727b717bd148f.tar.gz
servo-94e85a5226fe5b18bde40a2d5f6727b717bd148f.zip
Auto merge of #7801 - aopicier:refactor_formcontrol, r=Manishearth
Refactor FormControl trait The trait is now implemented for HTMLFooElement instead of &HTMLFooElement and does no longer require an impl body. Suggested by @Manishearth <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7801) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmlformelement.rs')
-rw-r--r--components/script/dom/htmlformelement.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index b16b2ec5609..632b084c293 100644
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -15,9 +15,11 @@ use dom::bindings::codegen::InheritTypes::HTMLElementCast;
use dom::bindings::codegen::InheritTypes::HTMLFormElementCast;
use dom::bindings::codegen::InheritTypes::HTMLFormElementDerived;
use dom::bindings::codegen::InheritTypes::HTMLInputElementCast;
+use dom::bindings::codegen::InheritTypes::{ElementBase, ElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLTextAreaElementCast, NodeCast};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{Root};
+use dom::bindings::utils::Reflectable;
use dom::document::Document;
use dom::element::{Element, ElementTypeId};
use dom::event::{Event, EventBubbles, EventCancelable};
@@ -515,10 +517,10 @@ impl<'a> FormSubmitter<'a> {
}
}
-pub trait FormControl<'a> : Copy + Sized {
+pub trait FormControl: ElementBase + Reflectable {
// FIXME: This is wrong (https://github.com/servo/servo/issues/3553)
// but we need html5ever to do it correctly
- fn form_owner(self) -> Option<Root<HTMLFormElement>> {
+ fn form_owner(&self) -> Option<Root<HTMLFormElement>> {
// https://html.spec.whatwg.org/multipage/#reset-the-form-owner
let elem = self.to_element();
let owner = elem.get_string_attribute(&atom!("form"));
@@ -544,12 +546,12 @@ pub trait FormControl<'a> : Copy + Sized {
None
}
- fn get_form_attribute<InputFn, OwnerFn>(self,
+ fn get_form_attribute<InputFn, OwnerFn>(&self,
attr: &Atom,
input: InputFn,
owner: OwnerFn)
-> DOMString
- where InputFn: Fn(Self) -> DOMString,
+ where InputFn: Fn(&Self) -> DOMString,
OwnerFn: Fn(&HTMLFormElement) -> DOMString
{
if self.to_element().has_attribute(attr) {
@@ -559,7 +561,9 @@ pub trait FormControl<'a> : Copy + Sized {
}
}
- fn to_element(self) -> &'a Element;
+ fn to_element(&self) -> &Element {
+ ElementCast::from_ref(self)
+ }
}
impl VirtualMethods for HTMLFormElement {