Removed util.

This commit is contained in:
Alan Jeffrey 2016-12-14 10:37:58 -06:00
parent 01b6ad55bd
commit 9be4fd56ce
133 changed files with 396 additions and 352 deletions

View file

@ -70,13 +70,14 @@ script_traits = {path = "../script_traits"}
selectors = "0.15"
serde = "0.8"
servo_atoms = {path = "../atoms"}
servo_config = {path = "../config", features = ["servo"] }
servo_geometry = {path = "../geometry" }
servo_url = {path = "../url", features = ["servo"] }
smallvec = "0.1"
style = {path = "../style"}
style_traits = {path = "../style_traits"}
time = "0.1.12"
url = {version = "1.2", features = ["heap_size", "query_encoding"]}
util = {path = "../util"}
uuid = {version = "0.3.1", features = ["v4"]}
websocket = "0.17"
xml5ever = {version = "0.2", features = ["unstable"]}

View file

@ -5603,7 +5603,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'dom::globalscope::GlobalScope',
'mem::heap_size_of_raw_self_and_children',
'libc',
'util::prefs::PREFS',
'servo_config::prefs::PREFS',
'std::borrow::ToOwned',
'std::cmp',
'std::mem',

View file

@ -56,8 +56,8 @@ use js::jsval::{ObjectValue, StringValue};
use js::rust::{ToString, get_object_class, is_dom_class, is_dom_object, maybe_wrap_value};
use libc;
use num_traits::Float;
use servo_config::opts;
use std::{char, mem, ptr, slice};
use util::opts;
/// A trait to check whether a given `JSObject` implements an IDL interface.
pub trait IDLInterface {

View file

@ -5,7 +5,7 @@
//! Machinery to conditionally expose things.
use js::jsapi::{HandleObject, JSContext};
use util::prefs::PREFS;
use servo_config::prefs::PREFS;
/// A container with a condition.
pub struct Guard<T: Clone + Copy> {

View file

@ -19,8 +19,8 @@ use dom::element::Element;
use dom::node::{Node, NodeDamage};
use dom::processinginstruction::ProcessingInstruction;
use dom::text::Text;
use servo_config::opts;
use std::cell::Ref;
use util::opts;
// https://dom.spec.whatwg.org/#characterdata
#[dom_struct]

View file

@ -78,7 +78,7 @@ use dom::htmlunknownelement::HTMLUnknownElement;
use dom::htmlvideoelement::HTMLVideoElement;
use dom::svgsvgelement::SVGSVGElement;
use html5ever_atoms::{Prefix, QualName};
use util::prefs::PREFS;
use servo_config::prefs::PREFS;
fn create_svg_element(name: QualName,
prefix: Option<DOMString>,

View file

@ -38,8 +38,8 @@ use std::mem::replace;
use std::sync::{Arc, Mutex};
use std::sync::atomic::AtomicBool;
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
use std::thread;
use style::thread_state;
use util::thread::spawn_named;
/// Set the `worker` field of a related DedicatedWorkerGlobalScope object to a particular
/// value for the duration of this object's lifetime. This ensures that the related Worker
@ -160,7 +160,7 @@ impl DedicatedWorkerGlobalScope {
let name = format!("WebWorker for {}", serialized_worker_url);
let top_level_frame_id = FrameId::installed();
spawn_named(name, move || {
thread::Builder::new().name(name).spawn(move || {
thread_state::initialize(thread_state::SCRIPT | thread_state::IN_WORKER);
if let Some(top_level_frame_id) = top_level_frame_id {
@ -243,7 +243,7 @@ impl DedicatedWorkerGlobalScope {
global.handle_event(event);
}
}, reporter_name, parent_sender, CommonScriptMsg::CollectReports);
});
}).expect("Thread spawning failed");
}
pub fn script_chan(&self) -> Box<ScriptChan + Send> {

View file

@ -113,6 +113,7 @@ use script_traits::{ScriptMsg as ConstellationMsg, TouchpadPressurePhase};
use script_traits::{TouchEventType, TouchId};
use script_traits::UntrustedNodeAddress;
use servo_atoms::Atom;
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
@ -133,7 +134,6 @@ use style::str::{split_html_space_chars, str_join};
use style::stylesheets::Stylesheet;
use time;
use url::percent_encoding::percent_decode;
use util::prefs::PREFS;
pub enum TouchEventResult {
Processed(bool),

View file

@ -34,9 +34,9 @@ use servo_atoms::Atom;
use std::cell::Cell;
use std::ptr;
use std::sync::Arc;
use std::thread;
use task_source::TaskSource;
use task_source::file_reading::{FileReadingTaskSource, FileReadingRunnable, FileReadingTask};
use util::thread::spawn_named;
#[derive(PartialEq, Clone, Copy, JSTraceable, HeapSizeOf)]
pub enum FileReaderFunction {
@ -401,9 +401,10 @@ impl FileReader {
let wrapper = global.get_runnable_wrapper();
let task_source = global.file_reading_task_source();
spawn_named("file reader async operation".to_owned(), move || {
thread::Builder::new().name("file reader async operation".to_owned()).spawn(move || {
perform_annotated_read_operation(gen_id, load_data, blob_contents, fr, task_source, wrapper)
});
}).expect("Thread spawning failed");
Ok(())
}

View file

@ -28,10 +28,10 @@ use html5ever_atoms::LocalName;
use net_traits::ReferrerPolicy;
use num_traits::ToPrimitive;
use script_traits::MozBrowserEvent;
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::default::Default;
use style::attr::AttrValue;
use util::prefs::PREFS;
#[dom_struct]
pub struct HTMLAnchorElement {

View file

@ -48,13 +48,13 @@ use script_traits::{IFrameLoadInfo, IFrameLoadInfoWithData, LoadData};
use script_traits::{MozBrowserEvent, NewLayoutInfo, ScriptMsg as ConstellationMsg};
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
use servo_atoms::Atom;
use servo_config::prefs::PREFS;
use servo_config::servo_version;
use servo_url::ServoUrl;
use std::cell::Cell;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::context::ReflowGoal;
use task_source::TaskSource;
use util::prefs::PREFS;
use util::servo_version;
bitflags! {
#[derive(JSTraceable, HeapSizeOf)]

View file

@ -19,6 +19,7 @@ use dom::node::{Node, UnbindContext, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use html5ever_atoms::LocalName;
use parking_lot::RwLock;
use servo_config::prefs::PREFS;
use std::ascii::AsciiExt;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
@ -89,7 +90,7 @@ impl HTMLMetaElement {
}
fn apply_viewport(&self) {
if !::util::prefs::PREFS.get("layout.viewport.enabled").as_boolean().unwrap_or(false) {
if !PREFS.get("layout.viewport.enabled").as_boolean().unwrap_or(false) {
return;
}
let element = self.upcast::<Element>();

View file

@ -14,9 +14,9 @@ use dom::event::{Event, EventBubbles, EventCancelable};
use dom::eventtarget::EventTarget;
use dom::uievent::UIEvent;
use dom::window::Window;
use servo_config::prefs::PREFS;
use std::cell::Cell;
use std::default::Default;
use util::prefs::PREFS;
#[dom_struct]
pub struct MouseEvent {

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::str::DOMString;
use util::opts;
use servo_config::opts;
pub fn Product() -> DOMString {
DOMString::from("Gecko")

View file

@ -28,13 +28,12 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as Req
use rand::random;
use script_runtime::{CommonScriptMsg, StackRootTLS, get_reports, new_rt_and_cx, ScriptChan};
use script_traits::{TimerEvent, WorkerGlobalScopeInit, ScopeThings, ServiceWorkerMsg, WorkerScriptLoadOrigin};
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
use std::thread;
use std::time::Duration;
use style::thread_state::{self, IN_WORKER, SCRIPT};
use util::prefs::PREFS;
use util::thread::spawn_named;
/// Messages used to control service worker event loop
pub enum ServiceWorkerScriptMsg {
@ -151,7 +150,7 @@ impl ServiceWorkerGlobalScope {
.. } = scope_things;
let serialized_worker_url = script_url.to_string();
spawn_named(format!("ServiceWorker for {}", serialized_worker_url), move || {
thread::Builder::new().name(format!("ServiceWorker for {}", serialized_worker_url)).spawn(move || {
thread_state::initialize(SCRIPT | IN_WORKER);
let roots = RootCollection::new();
let _stack_roots_tls = StackRootTLS::new(&roots);
@ -202,11 +201,11 @@ impl ServiceWorkerGlobalScope {
scope.execute_script(DOMString::from(source));
// Service workers are time limited
spawn_named("SWTimeoutThread".to_owned(), move || {
thread::Builder::new().name("SWTimeoutThread".to_owned()).spawn(move || {
let sw_lifetime_timeout = PREFS.get("dom.serviceworker.timeout_seconds").as_u64().unwrap();
thread::sleep(Duration::new(sw_lifetime_timeout, 0));
let _ = timer_chan.send(());
});
}).expect("Thread spawning failed");
global.dispatch_activate();
let reporter_name = format!("service-worker-reporter-{}", random::<u64>());
@ -217,7 +216,7 @@ impl ServiceWorkerGlobalScope {
}
}
}, reporter_name, scope.script_chan(), CommonScriptMsg::CollectReports);
});
}).expect("Thread spawning failed");
}
fn handle_event(&self, event: MixedMessage) -> bool {

View file

@ -32,10 +32,10 @@ use network_listener::PreInvoke;
use profile_traits::time::{TimerMetadata, TimerMetadataFrameType};
use profile_traits::time::{TimerMetadataReflowType, ProfilerCategory, profile};
use script_thread::ScriptThread;
use servo_config::resource_files::read_resource_file;
use servo_url::ServoUrl;
use std::cell::Cell;
use std::mem;
use util::resource_files::read_resource_file;
mod html;
mod xml;

View file

@ -37,11 +37,11 @@ use js::jsapi::{HandleObject, HandleValue, JSContext, JSObject, JSAutoCompartmen
use js::jsapi::{JS_NewPlainObject, JS_NewUint8ClampedArray};
use js::jsval::{JSVal, NullValue};
use script_traits::MsDuration;
use servo_config::prefs::PREFS;
use std::borrow::ToOwned;
use std::ptr;
use std::rc::Rc;
use timers::OneshotTimerCallback;
use util::prefs::PREFS;
#[dom_struct]
pub struct TestBinding {

View file

@ -9,11 +9,11 @@ use dom::bindings::js::RootedReference;
use dom::bindings::str::DOMString;
use dom::htmlheadelement::HTMLHeadElement;
use dom::node::Node;
use servo_config::opts;
use servo_config::resource_files::resources_dir_path;
use std::borrow::ToOwned;
use std::fs::read_dir;
use std::path::PathBuf;
use util::opts;
use util::resource_files::resources_dir_path;
pub fn load_script(head: &HTMLHeadElement) {

View file

@ -77,6 +77,9 @@ use script_traits::{DocumentState, TimerEvent, TimerEventId};
use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest, WindowSizeData, WindowSizeType};
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use servo_atoms::Atom;
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_geometry::{f32_rect_to_au_rect, max_rect};
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
@ -106,9 +109,6 @@ use timers::{IsInterval, TimerCallback};
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
use tinyfiledialogs::{self, MessageBoxIcon};
use url::Position;
use util::geometry::{self, max_rect};
use util::opts;
use util::prefs::PREFS;
use webdriver_handlers::jsval_to_webdriver;
/// Current state of the window object
@ -1413,13 +1413,13 @@ impl Window {
}
pub fn set_page_clip_rect_with_new_viewport(&self, viewport: Rect<f32>) -> bool {
let rect = geometry::f32_rect_to_au_rect(viewport.clone());
let rect = f32_rect_to_au_rect(viewport.clone());
self.current_viewport.set(rect);
// We use a clipping rectangle that is five times the size of the of the viewport,
// so that we don't collect display list items for areas too far outside the viewport,
// but also don't trigger reflows every time the viewport changes.
static VIEWPORT_EXPANSION: f32 = 2.0; // 2 lengths on each side plus original length is 5 total.
let proposed_clip_rect = geometry::f32_rect_to_au_rect(
let proposed_clip_rect = f32_rect_to_au_rect(
viewport.inflate(viewport.size.width * VIEWPORT_EXPANSION,
viewport.size.height * VIEWPORT_EXPANSION));
let clip_rect = self.page_clip_rect.get();

View file

@ -53,6 +53,7 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit, RequestMode
use net_traits::trim_http_whitespace;
use network_listener::{NetworkListener, PreInvoke};
use servo_atoms::Atom;
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
@ -64,7 +65,6 @@ use task_source::networking::NetworkingTaskSource;
use time;
use timers::{OneshotTimerCallback, OneshotTimerHandle};
use url::Position;
use util::prefs::PREFS;
#[derive(JSTraceable, PartialEq, Copy, Clone, HeapSizeOf)]
enum XMLHttpRequestState {

View file

@ -83,6 +83,8 @@ extern crate script_traits;
extern crate selectors;
extern crate serde;
#[macro_use] extern crate servo_atoms;
#[macro_use] extern crate servo_config;
extern crate servo_geometry;
extern crate servo_url;
extern crate smallvec;
#[macro_use]
@ -93,7 +95,6 @@ extern crate time;
extern crate tinyfiledialogs;
extern crate url;
#[macro_use]
extern crate util;
extern crate uuid;
extern crate webrender_traits;
extern crate websocket;

View file

@ -25,6 +25,8 @@ use js::rust::Runtime;
use msg::constellation_msg::PipelineId;
use profile_traits::mem::{Report, ReportKind, ReportsChan};
use script_thread::{Runnable, STACK_ROOTS, trace_thread};
use servo_config::opts;
use servo_config::prefs::PREFS;
use std::cell::Cell;
use std::io::{Write, stdout};
use std::marker::PhantomData;
@ -35,8 +37,6 @@ use std::ptr;
use std::rc::Rc;
use style::thread_state;
use time::{Tm, now};
use util::opts;
use util::prefs::PREFS;
/// Common messages used to control the event loops in both the script and the worker
pub enum CommonScriptMsg {

View file

@ -91,6 +91,7 @@ use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent,
use script_traits::CompositorEvent::{TouchEvent, TouchpadPressureEvent};
use script_traits::webdriver_msg::WebDriverScriptCommand;
use serviceworkerjob::{Job, JobQueue, AsyncJobHandler, FinishJobHandler, InvokeType, SettleType};
use servo_config::opts;
use servo_url::ServoUrl;
use std::cell::Cell;
use std::collections::{hash_map, HashMap, HashSet};
@ -101,6 +102,7 @@ use std::result::Result;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{Receiver, Select, Sender, channel};
use std::thread;
use style::context::ReflowGoal;
use style::dom::{TNode, UnsafeNode};
use style::thread_state;
@ -112,8 +114,6 @@ use task_source::networking::NetworkingTaskSource;
use task_source::user_interaction::{UserInteractionTask, UserInteractionTaskSource};
use time::Tm;
use url::Position;
use util::opts;
use util::thread;
use webdriver_handlers;
thread_local!(pub static STACK_ROOTS: Cell<Option<RootCollectionPtr>> = Cell::new(None));
@ -519,8 +519,7 @@ impl ScriptThreadFactory for ScriptThread {
let (sender, receiver) = channel();
let layout_chan = sender.clone();
thread::spawn_named(format!("ScriptThread {:?}", state.id),
move || {
thread::Builder::new().name(format!("ScriptThread {:?}", state.id)).spawn(move || {
thread_state::initialize(thread_state::SCRIPT);
PipelineNamespace::install(state.pipeline_namespace_id);
FrameId::install(state.top_level_frame_id);
@ -553,7 +552,7 @@ impl ScriptThreadFactory for ScriptThread {
// This must always be the very last operation performed before the thread completes
failsafe.neuter();
});
}).expect("Thread spawning failed");
(sender, receiver)
}

View file

@ -16,11 +16,11 @@ use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use net_traits::{CustomResponseMediator, CoreResourceMsg};
use script_traits::{ServiceWorkerMsg, ScopeThings, SWManagerMsg, SWManagerSenders, DOMMessage};
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::collections::HashMap;
use std::sync::mpsc::{channel, Sender, Receiver, RecvError};
use util::prefs::PREFS;
use util::thread::spawn_named;
use std::thread;
enum Message {
FromResource(CustomResponseMediator),
@ -60,11 +60,11 @@ impl ServiceWorkerManager {
let resource_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(resource_port);
let _ = sw_senders.resource_sender.send(CoreResourceMsg::NetworkMediator(resource_chan));
let _ = sw_senders.swmanager_sender.send(SWManagerMsg::OwnSender(own_sender.clone()));
spawn_named("ServiceWorkerManager".to_owned(), move || {
thread::Builder::new().name("ServiceWorkerManager".to_owned()).spawn(move || {
ServiceWorkerManager::new(own_sender,
from_constellation,
resource_port).handle_message();
});
}).expect("Thread spawning failed");
}
pub fn get_matching_scope(&self, load_url: &ServoUrl) -> Option<ServoUrl> {

View file

@ -18,12 +18,12 @@ use js::jsapi::{HandleValue, Heap};
use js::jsval::{JSVal, UndefinedValue};
use script_traits::{MsDuration, precise_time_ms};
use script_traits::{TimerEvent, TimerEventId, TimerEventRequest, TimerSource};
use servo_config::prefs::PREFS;
use std::cell::Cell;
use std::cmp::{self, Ord, Ordering};
use std::collections::HashMap;
use std::default::Default;
use std::rc::Rc;
use util::prefs::PREFS;
#[derive(JSTraceable, PartialEq, Eq, Copy, Clone, HeapSizeOf, Hash, PartialOrd, Ord, Debug)]
pub struct OneshotTimerHandle(i32);