Add support for trait-based virtual methods on Nodes, and use it for before_remove_attr and after_set_attr.

This commit is contained in:
Josh Matthews 2014-04-09 20:02:40 +02:00 committed by Ms2ger
parent ea2560ef20
commit ca6cfb5bca
9 changed files with 173 additions and 65 deletions

View file

@ -8,7 +8,7 @@ use dom::attr::Attr;
use dom::bindings::codegen::InheritTypes::{CommentCast, DocumentCast, DocumentTypeCast};
use dom::bindings::codegen::InheritTypes::{ElementCast, TextCast, NodeCast};
use dom::bindings::codegen::InheritTypes::{CharacterDataCast, NodeBase, NodeDerived};
use dom::bindings::codegen::InheritTypes::ProcessingInstructionCast;
use dom::bindings::codegen::InheritTypes::{ProcessingInstructionCast, EventTargetCast};
use dom::bindings::codegen::NodeBinding::NodeConstants;
use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
@ -22,8 +22,9 @@ use dom::documenttype::DocumentType;
use dom::element::{Element, ElementTypeId, HTMLAnchorElementTypeId, IElement};
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::nodelist::{NodeList};
use dom::text::Text;
use dom::processinginstruction::ProcessingInstruction;
use dom::text::Text;
use dom::virtualmethods::VirtualMethods;
use dom::window::Window;
use html::hubbub_html_parser::build_element_from_tag;
use layout_interface::{LayoutChan, ReapLayoutDataMsg, UntrustedNodeAddress};
@ -1834,3 +1835,10 @@ pub fn window_from_node<T: NodeBase>(derived: &JS<T>) -> JS<Window> {
let document: JS<Document> = document_from_node(derived);
document.get().window.clone()
}
impl VirtualMethods for JS<Node> {
fn super_type(&self) -> Option<~VirtualMethods:> {
let eventtarget: JS<EventTarget> = EventTargetCast::from(self);
Some(~eventtarget as ~VirtualMethods:)
}
}