Add plugins for compositing and net crates #7699

Changed to_string calls to to_owned calls
where was a need.
This commit is contained in:
Maciej Skrzypkowski 2015-09-22 13:47:05 +02:00
parent 44de9173cc
commit 88815d21ba
18 changed files with 43 additions and 31 deletions

View file

@ -43,6 +43,9 @@ path = "../canvas_traits"
[dependencies.canvas] [dependencies.canvas]
path = "../canvas" path = "../canvas"
[dependencies.plugins]
path = "../plugins"
[dependencies.azure] [dependencies.azure]
git = "https://github.com/servo/rust-azure" git = "https://github.com/servo/rust-azure"

View file

@ -248,7 +248,7 @@ fn initialize_png(width: usize, height: usize) -> (Vec<gl::GLuint>, Vec<gl::GLui
} }
pub fn reporter_name() -> String { pub fn reporter_name() -> String {
"compositor-reporter".to_string() "compositor-reporter".to_owned()
} }
impl<Window: WindowMethods> IOCompositor<Window> { impl<Window: WindowMethods> IOCompositor<Window> {

View file

@ -486,10 +486,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
} }
ConstellationMsg::GetClipboardContents(sender) => { ConstellationMsg::GetClipboardContents(sender) => {
let result = self.clipboard_ctx.as_ref().map_or( let result = self.clipboard_ctx.as_ref().map_or(
"".to_string(), "".to_owned(),
|ctx| ctx.get_contents().unwrap_or_else(|e| { |ctx| ctx.get_contents().unwrap_or_else(|e| {
debug!("Error getting clipboard contents ({}), defaulting to empty string", e); debug!("Error getting clipboard contents ({}), defaulting to empty string", e);
"".to_string() "".to_owned()
}) })
); );
sender.send(result).unwrap(); sender.send(result).unwrap();

View file

@ -6,6 +6,8 @@
#![feature(iter_cmp)] #![feature(iter_cmp)]
#![feature(slice_bytes)] #![feature(slice_bytes)]
#![feature(vec_push_all)] #![feature(vec_push_all)]
#![feature(plugin)]
#![plugin(plugins)]
#![deny(unsafe_code)] #![deny(unsafe_code)]

View file

@ -16,6 +16,9 @@ path = "../util"
[dependencies.devtools_traits] [dependencies.devtools_traits]
path = "../devtools_traits" path = "../devtools_traits"
[dependencies.plugins]
path = "../plugins"
[dependencies.png] [dependencies.png]
git = "https://github.com/servo/rust-png" git = "https://github.com/servo/rust-png"
features = [ "serde-serialization" ] features = [ "serde-serialization" ]

View file

@ -21,7 +21,7 @@ pub fn factory(mut load_data: LoadData, start_chan: LoadConsumer, classifier: Ar
let chan = start_sending(start_chan, Metadata { let chan = start_sending(start_chan, Metadata {
final_url: load_data.url, final_url: load_data.url,
content_type: Some(ContentType(Mime(TopLevel::Text, SubLevel::Html, vec![]))), content_type: Some(ContentType(Mime(TopLevel::Text, SubLevel::Html, vec![]))),
charset: Some("utf-8".to_string()), charset: Some("utf-8".to_owned()),
headers: None, headers: None,
status: Some(RawStatus(200, "OK".into())), status: Some(RawStatus(200, "OK".into())),
}); });
@ -37,7 +37,7 @@ pub fn factory(mut load_data: LoadData, start_chan: LoadConsumer, classifier: Ar
} }
_ => { _ => {
start_sending(start_chan, Metadata::default(load_data.url)) start_sending(start_chan, Metadata::default(load_data.url))
.send(Done(Err("Unknown about: URL.".to_string()))) .send(Done(Err("Unknown about: URL.".to_owned())))
.unwrap(); .unwrap();
return return
} }

View file

@ -46,7 +46,7 @@ impl Cookie {
// Step 5 // Step 5
match PUB_DOMAINS.iter().find(|&x| domain == *x) { match PUB_DOMAINS.iter().find(|&x| domain == *x) {
Some(val) if *val == url_host => domain = "".to_string(), Some(val) if *val == url_host => domain = "".to_owned(),
Some(_) => return None, Some(_) => return None,
None => {} None => {}
} }
@ -154,7 +154,7 @@ impl Cookie {
} }
} }
if self.cookie.secure && url.scheme != "https".to_string() { if self.cookie.secure && url.scheme != "https".to_owned() {
return false; return false;
} }
if self.cookie.httponly && source == CookieSource::NonHTTP { if self.cookie.httponly && source == CookieSource::NonHTTP {

View file

@ -107,7 +107,7 @@ impl CookieStorage {
_ => acc + ";" _ => acc + ";"
}) + &c.cookie.name + "=" + &c.cookie.value }) + &c.cookie.name + "=" + &c.cookie.value
}; };
let result = url_cookies.iter_mut().fold("".to_string(), reducer); let result = url_cookies.iter_mut().fold("".to_owned(), reducer);
info!(" === COOKIES SENT: {}", result); info!(" === COOKIES SENT: {}", result);
match result.len() { match result.len() {

View file

@ -41,7 +41,7 @@ pub fn load(load_data: LoadData, start_chan: LoadConsumer) {
let parts: Vec<&str> = scheme_data.splitn(2, ',').collect(); let parts: Vec<&str> = scheme_data.splitn(2, ',').collect();
if parts.len() != 2 { if parts.len() != 2 {
start_sending(start_chan, start_sending(start_chan,
metadata).send(Done(Err("invalid data uri".to_string()))).unwrap(); metadata).send(Done(Err("invalid data uri".to_owned()))).unwrap();
return; return;
} }
@ -68,7 +68,7 @@ pub fn load(load_data: LoadData, start_chan: LoadConsumer) {
let bytes = bytes.into_iter().filter(|&b| b != ' ' as u8).collect::<Vec<u8>>(); let bytes = bytes.into_iter().filter(|&b| b != ' ' as u8).collect::<Vec<u8>>();
match bytes.from_base64() { match bytes.from_base64() {
Err(..) => { Err(..) => {
progress_chan.send(Done(Err("non-base64 data uri".to_string()))).unwrap(); progress_chan.send(Done(Err("non-base64 data uri".to_owned()))).unwrap();
} }
Ok(data) => { Ok(data) => {
progress_chan.send(Payload(data)).unwrap(); progress_chan.send(Payload(data)).unwrap();

View file

@ -167,7 +167,7 @@ impl CORSCache for BasicCORSCache {
None => { None => {
self.insert(CORSCacheEntry::new(request.origin, request.destination, new_max_age, self.insert(CORSCacheEntry::new(request.origin, request.destination, new_max_age,
request.credentials, request.credentials,
HeaderOrMethod::HeaderData(header_name.to_string()))); HeaderOrMethod::HeaderData(header_name.to_owned())));
false false
} }
} }
@ -228,13 +228,13 @@ impl CORSCache for CORSCacheSender {
fn match_header(&mut self, request: CacheRequestDetails, header_name: &str) -> bool { fn match_header(&mut self, request: CacheRequestDetails, header_name: &str) -> bool {
let (tx, rx) = channel(); let (tx, rx) = channel();
self.send(CORSCacheTaskMsg::MatchHeader(request, header_name.to_string(), tx)); self.send(CORSCacheTaskMsg::MatchHeader(request, header_name.to_owned(), tx));
rx.recv().unwrap_or(false) rx.recv().unwrap_or(false)
} }
fn match_header_and_update(&mut self, request: CacheRequestDetails, header_name: &str, new_max_age: u32) -> bool { fn match_header_and_update(&mut self, request: CacheRequestDetails, header_name: &str, new_max_age: u32) -> bool {
let (tx, rx) = channel(); let (tx, rx) = channel();
self.send(CORSCacheTaskMsg::MatchHeaderUpdate(request, header_name.to_string(), new_max_age, tx)); self.send(CORSCacheTaskMsg::MatchHeaderUpdate(request, header_name.to_owned(), new_max_age, tx));
rx.recv().unwrap_or(false) rx.recv().unwrap_or(false)
} }

View file

@ -155,7 +155,7 @@ impl Request {
=> vec![qitem(Mime(TopLevel::Image, SubLevel::Png, vec![])), => vec![qitem(Mime(TopLevel::Image, SubLevel::Png, vec![])),
// FIXME: This should properly generate a MimeType that has a // FIXME: This should properly generate a MimeType that has a
// SubLevel of svg+xml (https://github.com/hyperium/mime.rs/issues/22) // SubLevel of svg+xml (https://github.com/hyperium/mime.rs/issues/22)
qitem(Mime(TopLevel::Image, SubLevel::Ext("svg+xml".to_string()), vec![])), qitem(Mime(TopLevel::Image, SubLevel::Ext("svg+xml".to_owned()), vec![])),
QualityItem::new(Mime(TopLevel::Image, SubLevel::Star, vec![]), q(0.8)), QualityItem::new(Mime(TopLevel::Image, SubLevel::Star, vec![]), q(0.8)),
QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.5))], QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.5))],
Context::Form | Context::Frame | Context::Hyperlink | Context::Form | Context::Frame | Context::Hyperlink |
@ -164,14 +164,14 @@ impl Request {
=> vec![qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])), => vec![qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])),
// FIXME: This should properly generate a MimeType that has a // FIXME: This should properly generate a MimeType that has a
// SubLevel of xhtml+xml (https://github.com/hyperium/mime.rs/issues/22) // SubLevel of xhtml+xml (https://github.com/hyperium/mime.rs/issues/22)
qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_string()), vec![])), qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_owned()), vec![])),
QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), q(0.9)), QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), q(0.9)),
QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.8))], QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.8))],
Context::Internal if self.context_frame_type != ContextFrameType::ContextNone Context::Internal if self.context_frame_type != ContextFrameType::ContextNone
=> vec![qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])), => vec![qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])),
// FIXME: This should properly generate a MimeType that has a // FIXME: This should properly generate a MimeType that has a
// SubLevel of xhtml+xml (https://github.com/hyperium/mime.rs/issues/22) // SubLevel of xhtml+xml (https://github.com/hyperium/mime.rs/issues/22)
qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_string()), vec![])), qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_owned()), vec![])),
QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), q(0.9)), QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), q(0.9)),
QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.8))], QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.8))],
Context::Style Context::Style

View file

@ -29,7 +29,7 @@ fn read_block(reader: &mut File) -> Result<ReadStatus, String> {
buf.truncate(n); buf.truncate(n);
Ok(ReadStatus::Partial(buf)) Ok(ReadStatus::Partial(buf))
} }
Err(e) => Err(e.description().to_string()), Err(e) => Err(e.description().to_owned()),
} }
} }
@ -68,7 +68,7 @@ pub fn factory(load_data: LoadData, senders: LoadConsumer, classifier: Arc<MIMEC
} }
Err(e) => { Err(e) => {
let progress_chan = start_sending(senders, metadata); let progress_chan = start_sending(senders, metadata);
progress_chan.send(Done(Err(e.description().to_string()))).unwrap(); progress_chan.send(Done(Err(e.description().to_owned()))).unwrap();
} }
} }
} }

View file

@ -121,7 +121,7 @@ pub fn preload_hsts_domains() -> Option<HSTSList> {
pub fn secure_url(url: &Url) -> Url { pub fn secure_url(url: &Url) -> Url {
if &*url.scheme == "http" { if &*url.scheme == "http" {
let mut secure_url = url.clone(); let mut secure_url = url.clone();
secure_url.scheme = "https".to_string(); secure_url.scheme = "https".to_owned();
secure_url.relative_scheme_data_mut() secure_url.relative_scheme_data_mut()
.map(|scheme_data| { .map(|scheme_data| {
scheme_data.default_port = Some(443); scheme_data.default_port = Some(443);

View file

@ -124,7 +124,7 @@ fn load_for_consumer(load_data: LoadData,
send_error(url, e, start_chan) send_error(url, e, start_chan)
} }
Err(LoadError::MaxRedirects(url)) => { Err(LoadError::MaxRedirects(url)) => {
send_error(url, "too many redirects".to_string(), start_chan) send_error(url, "too many redirects".to_owned(), start_chan)
} }
Err(LoadError::Cors(url, msg)) | Err(LoadError::Cors(url, msg)) |
Err(LoadError::InvalidRedirect(url, msg)) | Err(LoadError::InvalidRedirect(url, msg)) |
@ -237,7 +237,7 @@ impl HttpRequestFactory for NetworkHttpRequestFactory {
) )
}, },
Err(e) => { Err(e) => {
return Err(LoadError::Connection(url, e.description().to_string())) return Err(LoadError::Connection(url, e.description().to_owned()))
} }
}; };
@ -267,13 +267,13 @@ impl HttpRequest for WrappedHttpRequest {
let url = self.request.url.clone(); let url = self.request.url.clone();
let mut request_writer = match self.request.start() { let mut request_writer = match self.request.start() {
Ok(streaming) => streaming, Ok(streaming) => streaming,
Err(e) => return Err(LoadError::Connection(url, e.description().to_string())) Err(e) => return Err(LoadError::Connection(url, e.description().to_owned()))
}; };
if let Some(ref data) = *body { if let Some(ref data) = *body {
match request_writer.write_all(&data) { match request_writer.write_all(&data) {
Err(e) => { Err(e) => {
return Err(LoadError::Connection(url, e.description().to_string())) return Err(LoadError::Connection(url, e.description().to_owned()))
} }
_ => {} _ => {}
} }
@ -282,9 +282,9 @@ impl HttpRequest for WrappedHttpRequest {
let response = match request_writer.send() { let response = match request_writer.send() {
Ok(w) => w, Ok(w) => w,
Err(HttpError::Io(ref io_error)) if io_error.kind() == io::ErrorKind::ConnectionAborted => { Err(HttpError::Io(ref io_error)) if io_error.kind() == io::ErrorKind::ConnectionAborted => {
return Err(LoadError::ConnectionAborted(io_error.description().to_string())); return Err(LoadError::ConnectionAborted(io_error.description().to_owned()));
}, },
Err(e) => return Err(LoadError::Connection(url, e.description().to_string())) Err(e) => return Err(LoadError::Connection(url, e.description().to_owned()))
}; };
Ok(WrappedHttpResponse { response: response }) Ok(WrappedHttpResponse { response: response })
@ -315,7 +315,7 @@ fn set_default_accept(headers: &mut Headers) {
if !headers.has::<Accept>() { if !headers.has::<Accept>() {
let accept = Accept(vec![ let accept = Accept(vec![
qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])), qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])),
qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_string()), vec![])), qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_owned()), vec![])),
QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), Quality(900u16)), QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), Quality(900u16)),
QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), Quality(800u16)), QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), Quality(800u16)),
]); ]);
@ -374,7 +374,7 @@ fn update_sts_list_from_response(url: &Url, response: &HttpResponse, hsts_list:
IncludeSubdomains::NotIncluded IncludeSubdomains::NotIncluded
}; };
if let Some(entry) = HSTSEntry::new(host.to_string(), include_subdomains, Some(header.max_age)) { if let Some(entry) = HSTSEntry::new(host.to_owned(), include_subdomains, Some(header.max_age)) {
info!("adding host {} to the strict transport security list", host); info!("adding host {} to the strict transport security list", host);
info!("- max-age {}", header.max_age); info!("- max-age {}", header.max_age);
if header.include_subdomains { if header.include_subdomains {
@ -638,7 +638,7 @@ pub fn load<A>(load_data: LoadData,
return Err( return Err(
LoadError::Cors( LoadError::Cors(
url, url,
"Preflight fetch inconsistent with main fetch".to_string())); "Preflight fetch inconsistent with main fetch".to_owned()));
} else { } else {
// XXXManishearth There are some CORS-related steps here, // XXXManishearth There are some CORS-related steps here,
// but they don't seem necessary until credentials are implemented // but they don't seem necessary until credentials are implemented
@ -667,7 +667,7 @@ pub fn load<A>(load_data: LoadData,
} }
if redirected_to.contains(&url) { if redirected_to.contains(&url) {
return Err(LoadError::InvalidRedirect(doc_url, "redirect loop".to_string())); return Err(LoadError::InvalidRedirect(doc_url, "redirect loop".to_owned()));
} }
redirected_to.insert(doc_url.clone()); redirected_to.insert(doc_url.clone());

View file

@ -8,6 +8,8 @@
#![feature(path_ext)] #![feature(path_ext)]
#![feature(plugin)] #![feature(plugin)]
#![feature(vec_push_all)] #![feature(vec_push_all)]
#![feature(plugin)]
#![plugin(plugins)]
extern crate net_traits; extern crate net_traits;
extern crate cookie as cookie_rs; extern crate cookie as cookie_rs;

View file

@ -244,7 +244,7 @@ impl ResourceManager {
_ => { _ => {
debug!("resource_task: no loader for scheme {}", load_data.url.scheme); debug!("resource_task: no loader for scheme {}", load_data.url.scheme);
start_sending(consumer, Metadata::default(load_data.url)) start_sending(consumer, Metadata::default(load_data.url))
.send(ProgressMsg::Done(Err("no loader for scheme".to_string()))).unwrap(); .send(ProgressMsg::Done(Err("no loader for scheme".to_owned()))).unwrap();
return return
} }
}; };

View file

@ -172,7 +172,7 @@ impl StorageManager {
} }
fn origin_as_string(&self, url: Url) -> String { fn origin_as_string(&self, url: Url) -> String {
let mut origin = "".to_string(); let mut origin = "".to_owned();
origin.push_str(&url.scheme); origin.push_str(&url.scheme);
origin.push_str("://"); origin.push_str("://");
url.domain().map(|domain| origin.push_str(&domain)); url.domain().map(|domain| origin.push_str(&domain));

View file

@ -241,6 +241,7 @@ dependencies = [
"net_traits 0.0.1", "net_traits 0.0.1",
"num 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)",
"plugins 0.0.1",
"png 0.1.0 (git+https://github.com/servo/rust-png)", "png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile_traits 0.0.1", "profile_traits 0.0.1",
"script_traits 0.0.1", "script_traits 0.0.1",
@ -1086,6 +1087,7 @@ dependencies = [
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"net_traits 0.0.1", "net_traits 0.0.1",
"openssl 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"png 0.1.0 (git+https://github.com/servo/rust-png)", "png 0.1.0 (git+https://github.com/servo/rust-png)",
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"regex_macros 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "regex_macros 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",