aboutsummaryrefslogtreecommitdiffstats
path: root/components/util/namespace.rs
diff options
context:
space:
mode:
authorKeegan McAllister <kmcallister@mozilla.com>2014-09-29 18:30:01 -0700
committerKeegan McAllister <kmcallister@mozilla.com>2014-09-29 21:40:54 -0700
commitd50114c41d5233bc55ad1b86273995c0fa3f8d62 (patch)
tree1b11383f0fdfab841f3cc77c680226b9bc10aa59 /components/util/namespace.rs
parent6429750b339ca45651ac3a45df380f1badd3917c (diff)
downloadservo-d50114c41d5233bc55ad1b86273995c0fa3f8d62.tar.gz
servo-d50114c41d5233bc55ad1b86273995c0fa3f8d62.zip
Use string-cache's Namespace type
Diffstat (limited to 'components/util/namespace.rs')
-rw-r--r--components/util/namespace.rs43
1 files changed, 5 insertions, 38 deletions
diff --git a/components/util/namespace.rs b/components/util/namespace.rs
index 3dbb298a074..810ac7c4456 100644
--- a/components/util/namespace.rs
+++ b/components/util/namespace.rs
@@ -3,44 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use str::DOMString;
+use string_cache::{Atom, Namespace};
-#[deriving(Eq, PartialEq, Clone, Encodable, Hash, Show)]
-pub enum Namespace {
- Null,
- HTML,
- XML,
- XMLNS,
- XLink,
- SVG,
- MathML,
- Other(String)
-}
-
-impl Namespace {
- /// Empty string for "no namespace"
- pub fn from_str(url: Option<DOMString>) -> Namespace {
- match url {
- None => Null,
- Some(ref ns) if ns.as_slice() == "" => Null,
- Some(ref ns) if ns.as_slice() == "http://www.w3.org/1999/xhtml" => HTML,
- Some(ref ns) if ns.as_slice() == "http://www.w3.org/XML/1998/namespace" => XML,
- Some(ref ns) if ns.as_slice() == "http://www.w3.org/2000/xmlns/" => XMLNS,
- Some(ref ns) if ns.as_slice() == "http://www.w3.org/1999/xlink" => XLink,
- Some(ref ns) if ns.as_slice() == "http://www.w3.org/2000/svg" => SVG,
- Some(ref ns) if ns.as_slice() == "http://www.w3.org/1998/Math/MathML" => MathML,
- Some(ns) => Other(ns)
- }
- }
- pub fn to_str<'a>(&'a self) -> &'a str {
- match *self {
- Null => "",
- HTML => "http://www.w3.org/1999/xhtml",
- XML => "http://www.w3.org/XML/1998/namespace",
- XMLNS => "http://www.w3.org/2000/xmlns/",
- XLink => "http://www.w3.org/1999/xlink",
- SVG => "http://www.w3.org/2000/svg",
- MathML => "http://www.w3.org/1998/Math/MathML",
- Other(ref x) => x.as_slice()
- }
+pub fn from_domstring(url: Option<DOMString>) -> Namespace {
+ match url {
+ None => ns!(""),
+ Some(ref s) => Namespace(Atom::from_slice(s.as_slice())),
}
}