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.
This commit is contained in:
Bruno de Oliveira Abinader 2014-10-21 14:00:48 -04:00
parent f5e8df9dac
commit bbab8831e0
18 changed files with 255 additions and 225 deletions

View file

@ -2,6 +2,8 @@
* 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::AttrHelpers;
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding::HTMLFieldSetElementMethods;
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFieldSetElementDerived, NodeCast};
@ -83,15 +85,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLFieldSetElement> {
Some(htmlelement as &VirtualMethods)
}
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.clone()),
_ => (),
Some(ref s) => s.after_set_attr(attr),
_ => ()
}
let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() {
"disabled" => {
match attr.local_name() {
&atom!("disabled") => {
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.set_disabled_state(true);
node.set_enabled_state(false);
let maybe_legend = node.children().find(|node| node.is_htmllegendelement());
@ -115,15 +117,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLFieldSetElement> {
}
}
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),
_ => ()
}
let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() {
"disabled" => {
match attr.local_name() {
&atom!("disabled") => {
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.set_disabled_state(false);
node.set_enabled_state(true);
let maybe_legend = node.children().find(|node| node.is_htmllegendelement());