diff options
author | Bruno de Oliveira Abinader <bruno.d@partner.samsung.com> | 2014-10-21 14:00:48 -0400 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno.d@partner.samsung.com> | 2014-10-22 11:13:58 -0400 |
commit | bbab8831e0286be7ebf0c2dc964d6a6b6c30d65f (patch) | |
tree | b525d0f5b04bc318b79c4f00f36ba4aaba44e9b9 /components/script/dom/virtualmethods.rs | |
parent | f5e8df9dac9330f2818906c471ed05f5975828c6 (diff) | |
download | servo-bbab8831e0286be7ebf0c2dc964d6a6b6c30d65f.tar.gz servo-bbab8831e0286be7ebf0c2dc964d6a6b6c30d65f.zip |
Usage of JSRef<Attr> in before_remove_attr & after_set_attr
JSRef<Attr> does not require allocating a DOMString for value, which are
unused in most cases. It also provides more access to Attr data.
Diffstat (limited to 'components/script/dom/virtualmethods.rs')
-rw-r--r-- | components/script/dom/virtualmethods.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 0e5d0d6d5b3..edde69f8f10 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -2,6 +2,7 @@ * 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::attr::{AttrValue, StringAttrValue}; use dom::bindings::codegen::InheritTypes::ElementCast; use dom::bindings::codegen::InheritTypes::HTMLAnchorElementCast; @@ -62,7 +63,6 @@ use dom::htmltextareaelement::HTMLTextAreaElement; use dom::node::{Node, NodeHelpers, ElementNodeTypeId}; use servo_util::str::DOMString; -use string_cache::Atom; /// Trait to allow DOM nodes to opt-in to overriding (or adding to) common /// behaviours. Replicates the effect of C++ virtual methods. @@ -73,18 +73,18 @@ pub trait VirtualMethods { /// Called when changing or adding attributes, after the attribute's value /// has been updated. - fn after_set_attr(&self, name: &Atom, value: DOMString) { + fn after_set_attr(&self, attr: JSRef<Attr>) { match self.super_type() { - Some(ref s) => s.after_set_attr(name, value), + Some(ref s) => s.after_set_attr(attr), _ => (), } } /// Called when changing or removing attributes, before any modification /// has taken place. - fn before_remove_attr(&self, name: &Atom, value: DOMString) { + fn before_remove_attr(&self, attr: JSRef<Attr>) { match self.super_type() { - Some(ref s) => s.before_remove_attr(name, value), + Some(ref s) => s.before_remove_attr(attr), _ => (), } } |