mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Remove string_cache dependency from util.
Move `namespace::from_domstring` from util to script::dom, because it is used only in that crate.
This commit is contained in:
parent
efa60d3a24
commit
13072c7b0c
11 changed files with 21 additions and 42 deletions
|
@ -16,7 +16,6 @@ use dom::bindings::js::Root;
|
||||||
use dom::bindings::trace::trace_object;
|
use dom::bindings::trace::trace_object;
|
||||||
use dom::browsercontext;
|
use dom::browsercontext;
|
||||||
use dom::window;
|
use dom::window;
|
||||||
use util::namespace;
|
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
|
@ -830,7 +829,7 @@ pub const DOM_CALLBACKS: DOMCallbacks = DOMCallbacks {
|
||||||
pub fn validate_and_extract(namespace: Option<DOMString>, qualified_name: &str)
|
pub fn validate_and_extract(namespace: Option<DOMString>, qualified_name: &str)
|
||||||
-> Fallible<(Namespace, Option<Atom>, Atom)> {
|
-> Fallible<(Namespace, Option<Atom>, Atom)> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let namespace = namespace::from_domstring(namespace);
|
let namespace = namespace_from_domstring(namespace);
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
try!(validate_qualified_name(qualified_name));
|
try!(validate_qualified_name(qualified_name));
|
||||||
|
@ -966,3 +965,13 @@ pub fn xml_name_type(name: &str) -> XMLName {
|
||||||
true => XMLName::Name
|
true => XMLName::Name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert a possibly-null URL to a namespace.
|
||||||
|
///
|
||||||
|
/// If the URL is None, returns the empty namespace.
|
||||||
|
pub fn namespace_from_domstring(url: Option<DOMString>) -> Namespace {
|
||||||
|
match url {
|
||||||
|
None => ns!(""),
|
||||||
|
Some(ref s) => Namespace(Atom::from_slice(s)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ use dom::bindings::error::Error::NoModificationAllowed;
|
||||||
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
|
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
|
||||||
use dom::bindings::js::{Root, RootedReference};
|
use dom::bindings::js::{Root, RootedReference};
|
||||||
use dom::bindings::trace::RootedVec;
|
use dom::bindings::trace::RootedVec;
|
||||||
use dom::bindings::utils::{xml_name_type, validate_and_extract};
|
use dom::bindings::utils::{namespace_from_domstring, xml_name_type, validate_and_extract};
|
||||||
use dom::bindings::utils::XMLName::InvalidXMLName;
|
use dom::bindings::utils::XMLName::InvalidXMLName;
|
||||||
use dom::create::create_element;
|
use dom::create::create_element;
|
||||||
use dom::domrect::DOMRect;
|
use dom::domrect::DOMRect;
|
||||||
|
@ -67,7 +67,6 @@ use style::properties::longhands::{self, border_spacing, height};
|
||||||
use style::values::CSSFloat;
|
use style::values::CSSFloat;
|
||||||
use style::values::specified::{self, CSSColor, CSSRGBA};
|
use style::values::specified::{self, CSSColor, CSSRGBA};
|
||||||
use util::geometry::Au;
|
use util::geometry::Au;
|
||||||
use util::namespace;
|
|
||||||
use util::str::{DOMString, LengthOrPercentageOrAuto};
|
use util::str::{DOMString, LengthOrPercentageOrAuto};
|
||||||
|
|
||||||
use cssparser::Color;
|
use cssparser::Color;
|
||||||
|
@ -1203,7 +1202,7 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
fn GetAttributeNS(self,
|
fn GetAttributeNS(self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
local_name: DOMString) -> Option<DOMString> {
|
local_name: DOMString) -> Option<DOMString> {
|
||||||
let namespace = &namespace::from_domstring(namespace);
|
let namespace = &namespace_from_domstring(namespace);
|
||||||
self.get_attribute(namespace, &Atom::from_slice(&local_name))
|
self.get_attribute(namespace, &Atom::from_slice(&local_name))
|
||||||
.map(|attr| attr.r().Value())
|
.map(|attr| attr.r().Value())
|
||||||
}
|
}
|
||||||
|
@ -1255,7 +1254,7 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
fn RemoveAttributeNS(self,
|
fn RemoveAttributeNS(self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
local_name: DOMString) {
|
local_name: DOMString) {
|
||||||
let namespace = namespace::from_domstring(namespace);
|
let namespace = namespace_from_domstring(namespace);
|
||||||
let local_name = Atom::from_slice(&local_name);
|
let local_name = Atom::from_slice(&local_name);
|
||||||
self.remove_attribute(&namespace, &local_name);
|
self.remove_attribute(&namespace, &local_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,10 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, NodeCast};
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::global::GlobalRef;
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::trace::JSTraceable;
|
use dom::bindings::trace::JSTraceable;
|
||||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
use dom::bindings::utils::{namespace_from_domstring, Reflector, reflect_dom_object};
|
||||||
use dom::element::{Element, AttributeHandlers, ElementHelpers};
|
use dom::element::{Element, AttributeHandlers, ElementHelpers};
|
||||||
use dom::node::{Node, NodeHelpers, TreeIterator};
|
use dom::node::{Node, NodeHelpers, TreeIterator};
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use util::namespace;
|
|
||||||
use util::str::{DOMString, split_html_space_chars};
|
use util::str::{DOMString, split_html_space_chars};
|
||||||
|
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
|
@ -105,7 +104,7 @@ impl HTMLCollection {
|
||||||
maybe_ns: Option<DOMString>) -> Root<HTMLCollection> {
|
maybe_ns: Option<DOMString>) -> Root<HTMLCollection> {
|
||||||
let namespace_filter = match maybe_ns {
|
let namespace_filter = match maybe_ns {
|
||||||
Some(ref namespace) if namespace == &"*" => None,
|
Some(ref namespace) if namespace == &"*" => None,
|
||||||
ns => Some(namespace::from_domstring(ns)),
|
ns => Some(namespace_from_domstring(ns)),
|
||||||
};
|
};
|
||||||
|
|
||||||
if tag == "*" {
|
if tag == "*" {
|
||||||
|
|
|
@ -8,10 +8,9 @@ use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible};
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::global::GlobalRef;
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
use dom::bindings::utils::{namespace_from_domstring, Reflector, reflect_dom_object};
|
||||||
use dom::element::{AttributeHandlers, Element, ElementHelpers};
|
use dom::element::{AttributeHandlers, Element, ElementHelpers};
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use util::namespace;
|
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
|
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
|
@ -69,7 +68,7 @@ impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
let owner = owner.r();
|
let owner = owner.r();
|
||||||
let ns = namespace::from_domstring(namespace);
|
let ns = namespace_from_domstring(namespace);
|
||||||
owner.get_attribute(&ns, &Atom::from_slice(&local_name))
|
owner.get_attribute(&ns, &Atom::from_slice(&local_name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +87,7 @@ impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
let owner = owner.r();
|
let owner = owner.r();
|
||||||
let ns = namespace::from_domstring(namespace);
|
let ns = namespace_from_domstring(namespace);
|
||||||
owner.remove_attribute(&ns, &Atom::from_slice(&local_name)).ok_or(Error::NotFound)
|
owner.remove_attribute(&ns, &Atom::from_slice(&local_name)).ok_or(Error::NotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ use dom::bindings::js::Root;
|
||||||
use dom::bindings::js::RootedReference;
|
use dom::bindings::js::RootedReference;
|
||||||
use dom::bindings::trace::JSTraceable;
|
use dom::bindings::trace::JSTraceable;
|
||||||
use dom::bindings::trace::RootedVec;
|
use dom::bindings::trace::RootedVec;
|
||||||
use dom::bindings::utils::{Reflectable, reflect_dom_object};
|
use dom::bindings::utils::{namespace_from_domstring, Reflectable, reflect_dom_object};
|
||||||
use dom::characterdata::{CharacterData, CharacterDataHelpers, CharacterDataTypeId};
|
use dom::characterdata::{CharacterData, CharacterDataHelpers, CharacterDataTypeId};
|
||||||
use dom::comment::Comment;
|
use dom::comment::Comment;
|
||||||
use dom::document::{Document, DocumentHelpers, IsHTMLDocument, DocumentSource};
|
use dom::document::{Document, DocumentHelpers, IsHTMLDocument, DocumentSource};
|
||||||
|
@ -51,7 +51,6 @@ use devtools_traits::NodeInfo;
|
||||||
use parse::html::parse_html_fragment;
|
use parse::html::parse_html_fragment;
|
||||||
use script_traits::UntrustedNodeAddress;
|
use script_traits::UntrustedNodeAddress;
|
||||||
use util::geometry::Au;
|
use util::geometry::Au;
|
||||||
use util::namespace;
|
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
use util::task_state;
|
use util::task_state;
|
||||||
use selectors::parser::Selector;
|
use selectors::parser::Selector;
|
||||||
|
@ -2446,7 +2445,7 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-lookupprefix
|
// https://dom.spec.whatwg.org/#dom-node-lookupprefix
|
||||||
fn LookupPrefix(self, namespace: Option<DOMString>) -> Option<DOMString> {
|
fn LookupPrefix(self, namespace: Option<DOMString>) -> Option<DOMString> {
|
||||||
let namespace = namespace::from_domstring(namespace);
|
let namespace = namespace_from_domstring(namespace);
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if namespace == ns!("") {
|
if namespace == ns!("") {
|
||||||
|
|
2
components/servo/Cargo.lock
generated
2
components/servo/Cargo.lock
generated
|
@ -1312,8 +1312,6 @@ dependencies = [
|
||||||
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,4 @@ num_cpus = "0.2.2"
|
||||||
cssparser = "0.3.1"
|
cssparser = "0.3.1"
|
||||||
num = "0.1.24"
|
num = "0.1.24"
|
||||||
url = "*"
|
url = "*"
|
||||||
string_cache = "0.1"
|
|
||||||
string_cache_plugin = "0.1"
|
|
||||||
euclid = "0.1"
|
euclid = "0.1"
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
#![feature(step_trait)]
|
#![feature(step_trait)]
|
||||||
#![feature(zero_one)]
|
#![feature(zero_one)]
|
||||||
|
|
||||||
#![plugin(string_cache_plugin)]
|
|
||||||
|
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
|
||||||
extern crate azure;
|
extern crate azure;
|
||||||
|
@ -34,7 +32,6 @@ extern crate num_cpus;
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
extern crate rustc_serialize;
|
extern crate rustc_serialize;
|
||||||
extern crate smallvec;
|
extern crate smallvec;
|
||||||
extern crate string_cache;
|
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -48,7 +45,6 @@ pub mod linked_list;
|
||||||
pub mod geometry;
|
pub mod geometry;
|
||||||
pub mod logical_geometry;
|
pub mod logical_geometry;
|
||||||
pub mod mem;
|
pub mod mem;
|
||||||
pub mod namespace;
|
|
||||||
pub mod opts;
|
pub mod opts;
|
||||||
pub mod persistent_list;
|
pub mod persistent_list;
|
||||||
pub mod range;
|
pub mod range;
|
||||||
|
|
|
@ -1,14 +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/. */
|
|
||||||
|
|
||||||
use str::DOMString;
|
|
||||||
use string_cache::{Atom, Namespace};
|
|
||||||
|
|
||||||
pub fn from_domstring(url: Option<DOMString>) -> Namespace {
|
|
||||||
match url {
|
|
||||||
None => ns!(""),
|
|
||||||
Some(ref s) => Namespace(Atom::from_slice(s)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
2
ports/cef/Cargo.lock
generated
2
ports/cef/Cargo.lock
generated
|
@ -1296,8 +1296,6 @@ dependencies = [
|
||||||
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
2
ports/gonk/Cargo.lock
generated
2
ports/gonk/Cargo.lock
generated
|
@ -1185,8 +1185,6 @@ dependencies = [
|
||||||
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue