Auto merge of #6528 - mbrubeck:util_deps, r=Ms2ger

Reduce dependencies of the `util` crate

Because almost all our main crates depend on util, we should keep its dependencies minimal to increase parallelism and reduce the amount of stuff rebuilt when upstream crates are changed.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6528)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-07-01 07:54:15 -06:00
commit fc1e427ff9
14 changed files with 25 additions and 70 deletions

View file

@ -1055,7 +1055,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn device_pixels_per_screen_px(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32> {
match opts::get().device_pixels_per_px {
Some(device_pixels_per_px) => device_pixels_per_px,
Some(device_pixels_per_px) => ScaleFactor::new(device_pixels_per_px),
None => match opts::get().output_file {
Some(_) => ScaleFactor::new(1.0),
None => self.hidpi_factor

View file

@ -16,7 +16,6 @@ use dom::bindings::js::Root;
use dom::bindings::trace::trace_object;
use dom::browsercontext;
use dom::window;
use util::namespace;
use util::str::DOMString;
use libc;
@ -830,7 +829,7 @@ pub const DOM_CALLBACKS: DOMCallbacks = DOMCallbacks {
pub fn validate_and_extract(namespace: Option<DOMString>, qualified_name: &str)
-> Fallible<(Namespace, Option<Atom>, Atom)> {
// Step 1.
let namespace = namespace::from_domstring(namespace);
let namespace = namespace_from_domstring(namespace);
// Step 2.
try!(validate_qualified_name(qualified_name));
@ -966,3 +965,13 @@ pub fn xml_name_type(name: &str) -> XMLName {
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)),
}
}

View file

@ -32,7 +32,7 @@ use dom::bindings::error::Error::NoModificationAllowed;
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
use dom::bindings::js::{Root, RootedReference};
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::create::create_element;
use dom::domrect::DOMRect;
@ -67,7 +67,6 @@ use style::properties::longhands::{self, border_spacing, height};
use style::values::CSSFloat;
use style::values::specified::{self, CSSColor, CSSRGBA};
use util::geometry::Au;
use util::namespace;
use util::str::{DOMString, LengthOrPercentageOrAuto};
use cssparser::Color;
@ -1203,7 +1202,7 @@ impl<'a> ElementMethods for &'a Element {
fn GetAttributeNS(self,
namespace: 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))
.map(|attr| attr.r().Value())
}
@ -1255,7 +1254,7 @@ impl<'a> ElementMethods for &'a Element {
fn RemoveAttributeNS(self,
namespace: Option<DOMString>,
local_name: DOMString) {
let namespace = namespace::from_domstring(namespace);
let namespace = namespace_from_domstring(namespace);
let local_name = Atom::from_slice(&local_name);
self.remove_attribute(&namespace, &local_name);
}

View file

@ -8,11 +8,10 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, NodeCast};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, Root};
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::node::{Node, NodeHelpers, TreeIterator};
use dom::window::Window;
use util::namespace;
use util::str::{DOMString, split_html_space_chars};
use std::ascii::AsciiExt;
@ -105,7 +104,7 @@ impl HTMLCollection {
maybe_ns: Option<DOMString>) -> Root<HTMLCollection> {
let namespace_filter = match maybe_ns {
Some(ref namespace) if namespace == &"*" => None,
ns => Some(namespace::from_domstring(ns)),
ns => Some(namespace_from_domstring(ns)),
};
if tag == "*" {

View file

@ -8,10 +8,9 @@ use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::global::GlobalRef;
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::window::Window;
use util::namespace;
use util::str::DOMString;
use string_cache::Atom;
@ -69,7 +68,7 @@ impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
let owner = self.owner.root();
// FIXME(https://github.com/rust-lang/rust/issues/23338)
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))
}
@ -88,7 +87,7 @@ impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
let owner = self.owner.root();
// FIXME(https://github.com/rust-lang/rust/issues/23338)
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)
}

View file

@ -30,7 +30,7 @@ use dom::bindings::js::Root;
use dom::bindings::js::RootedReference;
use dom::bindings::trace::JSTraceable;
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::comment::Comment;
use dom::document::{Document, DocumentHelpers, IsHTMLDocument, DocumentSource};
@ -51,7 +51,6 @@ use devtools_traits::NodeInfo;
use parse::html::parse_html_fragment;
use script_traits::UntrustedNodeAddress;
use util::geometry::Au;
use util::namespace;
use util::str::DOMString;
use util::task_state;
use selectors::parser::Selector;
@ -2446,7 +2445,7 @@ impl<'a> NodeMethods for &'a Node {
// https://dom.spec.whatwg.org/#dom-node-lookupprefix
fn LookupPrefix(self, namespace: Option<DOMString>) -> Option<DOMString> {
let namespace = namespace::from_domstring(namespace);
let namespace = namespace_from_domstring(namespace);
// Step 1.
if namespace == ns!("") {

View file

@ -1304,8 +1304,6 @@ dependencies = [
"bitflags 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
"lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1313,11 +1311,7 @@ dependencies = [
"plugins 0.0.1",
"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)",
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
"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)",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
]

View file

@ -18,28 +18,18 @@ doctest = false
[dependencies.plugins]
path = "../plugins"
[dependencies.selectors]
git = "https://github.com/servo/rust-selectors"
[dependencies.azure]
git = "https://github.com/servo/rust-azure"
[dependencies.layers]
git = "https://github.com/servo/rust-layers"
[dependencies]
log = "*"
bitflags = "*"
libc = "*"
rand = "*"
rustc-serialize = "0.3"
time = "0.1.12"
smallvec = "0.1"
num_cpus = "0.2.2"
cssparser = "0.3.1"
num = "0.1.24"
lazy_static = "0.1.10"
url = "*"
string_cache = "0.1"
string_cache_plugin = "0.1"
euclid = "0.1"

View file

@ -18,8 +18,6 @@
#![feature(step_trait)]
#![feature(zero_one)]
#![plugin(string_cache_plugin)]
#[macro_use] extern crate log;
extern crate azure;
@ -28,15 +26,12 @@ extern crate alloc;
#[macro_use] extern crate cssparser;
extern crate euclid;
extern crate getopts;
extern crate layers;
extern crate libc;
extern crate num as num_lib;
extern crate num_cpus;
extern crate rand;
extern crate rustc_serialize;
extern crate selectors;
extern crate smallvec;
extern crate string_cache;
extern crate url;
use std::sync::Arc;
@ -50,7 +45,6 @@ pub mod linked_list;
pub mod geometry;
pub mod logical_geometry;
pub mod mem;
pub mod namespace;
pub mod opts;
pub mod persistent_list;
pub mod range;

View file

@ -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)),
}
}

View file

@ -7,9 +7,7 @@
use geometry::ScreenPx;
use euclid::scale_factor::ScaleFactor;
use euclid::size::{Size2D, TypedSize2D};
use layers::geometry::DevicePixel;
use getopts;
use num_cpus;
use std::collections::HashSet;
@ -44,7 +42,7 @@ pub struct Opts {
/// The ratio of device pixels per px at the default scale. If unspecified, will use the
/// platform default setting.
pub device_pixels_per_px: Option<ScaleFactor<ScreenPx, DevicePixel, f32>>,
pub device_pixels_per_px: Option<f32>,
/// `None` to disable the time profiler or `Some` with an interval in seconds to enable it and
/// cause it to produce output on that interval (`-p`).
@ -328,7 +326,7 @@ pub fn from_cmdline_args(args: &[String]) {
};
let device_pixels_per_px = opt_match.opt_str("device-pixel-ratio").map(|dppx_str|
ScaleFactor::new(dppx_str.parse().unwrap())
dppx_str.parse().unwrap()
);
let mut paint_threads: usize = match opt_match.opt_str("t") {

6
ports/cef/Cargo.lock generated
View file

@ -1288,8 +1288,6 @@ dependencies = [
"bitflags 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
"lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1297,11 +1295,7 @@ dependencies = [
"plugins 0.0.1",
"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)",
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
"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)",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
]

View file

@ -41,7 +41,7 @@ pub fn create_window(parent: WindowID) -> Rc<Window> {
// Read command-line options.
let opts = opts::get();
let foreground = opts.output_file.is_none();
let scale_factor = opts.device_pixels_per_px.unwrap_or(ScaleFactor::new(1.0));
let scale_factor = ScaleFactor::new(opts.device_pixels_per_px.unwrap_or(1.0));
let size = opts.initial_window_size.as_f32() * scale_factor;
// Open a window.

6
ports/gonk/Cargo.lock generated
View file

@ -1177,8 +1177,6 @@ dependencies = [
"bitflags 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
"lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1186,11 +1184,7 @@ dependencies = [
"plugins 0.0.1",
"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)",
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
"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)",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
]