diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2015-05-02 12:27:42 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2015-05-14 18:28:39 +0200 |
commit | b86672af0c16d234150ac79297458f199c853825 (patch) | |
tree | daaef697f759ca4401728363e710c989502c3161 /components/script/dom | |
parent | 2176aab6425d3350bd9893fdb5bec6b53614a918 (diff) | |
download | servo-b86672af0c16d234150ac79297458f199c853825.tar.gz servo-b86672af0c16d234150ac79297458f199c853825.zip |
Implement HTMLAppletElement.name
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/htmlappletelement.rs | 27 | ||||
-rw-r--r-- | components/script/dom/macros.rs | 14 | ||||
-rw-r--r-- | components/script/dom/virtualmethods.rs | 4 | ||||
-rw-r--r-- | components/script/dom/webidls/HTMLAppletElement.webidl | 2 |
4 files changed, 45 insertions, 2 deletions
diff --git a/components/script/dom/htmlappletelement.rs b/components/script/dom/htmlappletelement.rs index 4ef0bc6cd2e..585df5d5273 100644 --- a/components/script/dom/htmlappletelement.rs +++ b/components/script/dom/htmlappletelement.rs @@ -3,13 +3,20 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLAppletElementBinding; +use dom::bindings::codegen::Bindings::HTMLAppletElementBinding::HTMLAppletElementMethods; + +use dom::attr::AttrValue; use dom::bindings::codegen::InheritTypes::HTMLAppletElementDerived; +use dom::bindings::codegen::InheritTypes::HTMLElementCast; use dom::bindings::js::{JSRef, Temporary}; use dom::document::Document; -use dom::element::ElementTypeId; +use dom::element::{AttributeHandlers, ElementTypeId}; use dom::eventtarget::{EventTarget, EventTargetTypeId}; use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; use dom::node::{Node, NodeTypeId}; +use dom::virtualmethods::VirtualMethods; + +use string_cache::Atom; use util::str::DOMString; #[dom_struct] @@ -37,3 +44,21 @@ impl HTMLAppletElement { } } +impl<'a> HTMLAppletElementMethods for JSRef<'a, HTMLAppletElement> { + // https://html.spec.whatwg.org/#the-applet-element:dom-applet-name + make_getter!(Name); + make_atomic_setter!(SetName, "name"); +} + +impl<'a> VirtualMethods for JSRef<'a, HTMLAppletElement> { + fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> { + Some(HTMLElementCast::from_borrowed_ref(self) as &VirtualMethods) + } + + fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue { + match name { + &atom!("name") => AttrValue::from_atomic(value), + _ => self.super_type().unwrap().parse_plain_attribute(name, value), + } + } +} diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs index 176feb927b9..97a8e7a74d7 100644 --- a/components/script/dom/macros.rs +++ b/components/script/dom/macros.rs @@ -199,6 +199,20 @@ macro_rules! make_limited_uint_setter( }; ); +#[macro_export] +macro_rules! make_atomic_setter( + ( $attr:ident, $htmlname:expr ) => ( + fn $attr(self, value: DOMString) { + use dom::element::{Element, AttributeHandlers}; + use dom::bindings::codegen::InheritTypes::ElementCast; + use string_cache::Atom; + let element: JSRef<Element> = ElementCast::from_ref(self); + // FIXME(pcwalton): Do this at compile time, not at runtime. + element.set_atomic_attribute(&Atom::from_slice($htmlname), value) + } + ); +); + /// For use on non-jsmanaged types /// Use #[jstraceable] on JS managed types macro_rules! no_jsmanaged_fields( diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 05bd23307a2..a4ceb09e026 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -6,6 +6,7 @@ use dom::attr::{Attr, AttrValue}; use dom::bindings::codegen::InheritTypes::ElementCast; use dom::bindings::codegen::InheritTypes::HTMLAnchorElementCast; use dom::bindings::codegen::InheritTypes::HTMLAreaElementCast; +use dom::bindings::codegen::InheritTypes::HTMLAppletElementCast; use dom::bindings::codegen::InheritTypes::HTMLBodyElementCast; use dom::bindings::codegen::InheritTypes::HTMLButtonElementCast; use dom::bindings::codegen::InheritTypes::HTMLCanvasElementCast; @@ -144,6 +145,9 @@ pub fn vtable_for<'a>(node: &'a JSRef<'a, Node>) -> &'a (VirtualMethods + 'a) { let element: &'a JSRef<'a, HTMLAnchorElement> = HTMLAnchorElementCast::to_borrowed_ref(node).unwrap(); element as &'a (VirtualMethods + 'a) } + NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAppletElement)) => { + HTMLAppletElementCast::to_borrowed_ref(node).unwrap() as &'a (VirtualMethods + 'a) + } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) => { let element: &'a JSRef<'a, HTMLAreaElement> = HTMLAreaElementCast::to_borrowed_ref(node).unwrap(); element as &'a (VirtualMethods + 'a) diff --git a/components/script/dom/webidls/HTMLAppletElement.webidl b/components/script/dom/webidls/HTMLAppletElement.webidl index ff86973dac4..b7f6350de53 100644 --- a/components/script/dom/webidls/HTMLAppletElement.webidl +++ b/components/script/dom/webidls/HTMLAppletElement.webidl @@ -12,7 +12,7 @@ interface HTMLAppletElement : HTMLElement { // attribute DOMString codeBase; // attribute DOMString height; // attribute unsigned long hspace; - // attribute DOMString name; + attribute DOMString name; // attribute DOMString _object; // the underscore is not part of the identifier // attribute unsigned long vspace; // attribute DOMString width; |