mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Pass an Atom to VirtualMethods::parse_plain_attribute.
This commit is contained in:
parent
f7407ee43d
commit
214c356ecd
3 changed files with 10 additions and 7 deletions
|
@ -509,7 +509,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
value: DOMString) -> AttrValue {
|
value: DOMString) -> AttrValue {
|
||||||
if *namespace == ns!("") {
|
if *namespace == ns!("") {
|
||||||
vtable_for(&NodeCast::from_ref(self))
|
vtable_for(&NodeCast::from_ref(self))
|
||||||
.parse_plain_attribute(local_name.as_slice(), value)
|
.parse_plain_attribute(local_name, value)
|
||||||
} else {
|
} else {
|
||||||
StringAttrValue(value)
|
StringAttrValue(value)
|
||||||
}
|
}
|
||||||
|
@ -1037,10 +1037,10 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
self.notify_content_changed();
|
self.notify_content_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_plain_attribute(&self, name: &str, value: DOMString) -> AttrValue {
|
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
|
||||||
match name {
|
match name {
|
||||||
"id" => AttrValue::from_atomic(value),
|
&atom!("id") => AttrValue::from_atomic(value),
|
||||||
"class" => AttrValue::from_tokenlist(value),
|
&atom!("class") => AttrValue::from_tokenlist(value),
|
||||||
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
|
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,9 +195,10 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_plain_attribute(&self, name: &str, value: DOMString) -> AttrValue {
|
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
|
||||||
match name {
|
match name {
|
||||||
"width" | "height" | "hspace" | "vspace" => AttrValue::from_u32(value, 0),
|
&atom!("width") | &atom!("height") |
|
||||||
|
&atom!("hspace") | &atom!("vspace") => AttrValue::from_u32(value, 0),
|
||||||
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
|
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,8 @@ use dom::node::{Node, NodeHelpers, ElementNodeTypeId, CloneChildrenFlag};
|
||||||
|
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
|
use string_cache::Atom;
|
||||||
|
|
||||||
/// Trait to allow DOM nodes to opt-in to overriding (or adding to) common
|
/// Trait to allow DOM nodes to opt-in to overriding (or adding to) common
|
||||||
/// behaviours. Replicates the effect of C++ virtual methods.
|
/// behaviours. Replicates the effect of C++ virtual methods.
|
||||||
pub trait VirtualMethods {
|
pub trait VirtualMethods {
|
||||||
|
@ -95,7 +97,7 @@ pub trait VirtualMethods {
|
||||||
|
|
||||||
/// Returns the right AttrValue variant for the attribute with name `name`
|
/// Returns the right AttrValue variant for the attribute with name `name`
|
||||||
/// on this element.
|
/// on this element.
|
||||||
fn parse_plain_attribute(&self, name: &str, value: DOMString) -> AttrValue {
|
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.parse_plain_attribute(name, value),
|
Some(ref s) => s.parse_plain_attribute(name, value),
|
||||||
_ => StringAttrValue(value),
|
_ => StringAttrValue(value),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue