Move script::dom::namespace into util, in order to use it from style later.

This commit is contained in:
Simon Sapin 2014-01-25 08:22:51 -08:00
parent ae0cbda327
commit 624e2714d4
13 changed files with 13 additions and 14 deletions

View file

@ -5,8 +5,8 @@
use dom::bindings::codegen::AttrBinding;
use dom::bindings::utils::{Reflectable, Reflector, DOMString};
use dom::bindings::utils::reflect_dom_object;
use dom::namespace::{Namespace, Null};
use dom::window::Window;
use servo_util::namespace::{Namespace, Null};
use std::util;

View file

@ -16,7 +16,6 @@ use dom::event::{AbstractEvent, Event};
use dom::htmlcollection::HTMLCollection;
use dom::htmldocument::HTMLDocument;
use dom::mouseevent::MouseEvent;
use dom::namespace::Null;
use dom::node::{AbstractNode, Node, ElementNodeTypeId, DocumentNodeTypeId};
use dom::text::Text;
use dom::uievent::UIEvent;
@ -24,6 +23,7 @@ use dom::window::Window;
use dom::htmltitleelement::HTMLTitleElement;
use html::hubbub_html_parser::build_element_from_tag;
use layout_interface::{DocumentDamageLevel, ContentChangedDocumentDamage};
use servo_util::namespace::Null;
use js::jsapi::{JSObject, JSContext, JSTracer};
use std::ascii::StrAsciiExt;

View file

@ -15,13 +15,13 @@ use dom::clientrectlist::ClientRectList;
use dom::document::AbstractDocument;
use dom::node::{AbstractNode, ElementNodeTypeId, Node, NodeIterator};
use dom::document;
use dom::namespace;
use dom::namespace::{Namespace, Null};
use dom::htmlserializer::serialize;
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
use layout_interface::{ContentBoxesResponse, ContentChangedDocumentDamage};
use layout_interface::{MatchSelectorsDocumentDamage};
use style;
use servo_util::namespace;
use servo_util::namespace::{Namespace, Null};
use std::ascii::StrAsciiExt;
use std::cast;

View file

@ -6,8 +6,8 @@ use dom::bindings::codegen::HTMLDocumentBinding;
use dom::bindings::utils::{Reflectable, Reflector, Traceable};
use dom::document::{AbstractDocument, Document, HTML};
use dom::htmlcollection::HTMLCollection;
use dom::namespace::Null;
use dom::window::Window;
use servo_util::namespace::Null;
use js::jsapi::JSTracer;
use std::str::eq_slice;

View file

@ -9,7 +9,7 @@ use dom::element::{Element, ElementTypeId, HTMLElementTypeId};
use dom::node::{AbstractNode, Node};
use js::jsapi::{JSContext, JSVal};
use js::JSVAL_NULL;
use dom::namespace;
use servo_util::namespace;
pub struct HTMLElement {
element: Element

View file

@ -7,7 +7,6 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument;
use dom::element::HTMLImageElementTypeId;
use dom::htmlelement::HTMLElement;
use dom::namespace::Null;
use dom::node::{AbstractNode, Node};
use extra::url::Url;
use servo_util::geometry::to_px;
@ -15,6 +14,7 @@ use layout_interface::{ContentBoxQuery, ContentBoxResponse};
use servo_net::image_cache_task;
use servo_net::image_cache_task::ImageCacheTask;
use servo_util::url::make_url;
use servo_util::namespace::Null;
pub struct HTMLImageElement {
htmlelement: HTMLElement,

View file

@ -2,7 +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::namespace;
use servo_util::namespace;
use dom::attr::Attr;
use dom::node::NodeIterator;
use dom::node::{DoctypeNodeTypeId, DocumentFragmentNodeTypeId, CommentNodeTypeId, DocumentNodeTypeId, ElementNodeTypeId, TextNodeTypeId, AbstractNode};

View file

@ -1,43 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#[deriving(Eq, Clone)]
pub enum Namespace {
Null,
HTML,
XML,
XMLNS,
XLink,
SVG,
MathML,
Other(~str)
}
impl Namespace {
/// Empty string for "no namespace"
pub fn from_str(url: &str) -> Namespace {
match url {
"http://www.w3.org/1999/xhtml" => HTML,
"http://www.w3.org/XML/1998/namespace" => XML,
"http://www.w3.org/2000/xmlns/" => XMLNS,
"http://www.w3.org/1999/xlink" => XLink,
"http://www.w3.org/2000/svg" => SVG,
"http://www.w3.org/1998/Math/MathML" => MathML,
"" => Null,
ns => Other(ns.to_owned())
}
}
pub fn to_str<'a>(&'a self) -> Option<&'a str> {
match *self {
Null => None,
HTML => Some("http://www.w3.org/1999/xhtml"),
XML => Some("http://www.w3.org/XML/1998/namespace"),
XMLNS => Some("http://www.w3.org/2000/xmlns/"),
XLink => Some("http://www.w3.org/1999/xlink"),
SVG => Some("http://www.w3.org/2000/svg"),
MathML => Some("http://www.w3.org/1998/Math/MathML"),
Other(ref x) => Some(x.as_slice())
}
}
}