зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #5303 - Update some code that's feature-gated under core (from Ms2ger:core); r=jdm
Source-Repo: https://github.com/servo/servo Source-Revision: 43f3f6c897916aea75773f74060ec84a338834d0
This commit is contained in:
Родитель
5dbe6eb389
Коммит
ed37ff9cb6
|
@ -237,7 +237,7 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
//start offset of the copyable rectangle
|
||||
let mut src = (src_read_rect.origin.y * stride + src_read_rect.origin.x * 4) as usize;
|
||||
//copy the data to the destination vector
|
||||
for _ in range(0, src_read_rect.size.height) {
|
||||
for _ in 0..src_read_rect.size.height {
|
||||
let row = &src_data[src .. src + (4 * src_read_rect.size.width) as usize];
|
||||
dest_data.push_all(row);
|
||||
src += stride as usize;
|
||||
|
@ -285,7 +285,7 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
return
|
||||
}
|
||||
|
||||
let source_surface = self.drawtarget.create_source_surface_from_data(imagedata.as_slice(),
|
||||
let source_surface = self.drawtarget.create_source_surface_from_data(&imagedata,
|
||||
image_data_rect.size, image_data_rect.size.width * 4, SurfaceFormat::B8G8R8A8);
|
||||
|
||||
let draw_surface_options = DrawSurfaceOptions::new(Filter::Linear, true);
|
||||
|
@ -383,7 +383,7 @@ impl FillOrStrokeStyle {
|
|||
Pattern::LinearGradient(LinearGradientPattern::new(
|
||||
&Point2D(linear_gradient_style.x0 as AzFloat, linear_gradient_style.y0 as AzFloat),
|
||||
&Point2D(linear_gradient_style.x1 as AzFloat, linear_gradient_style.y1 as AzFloat),
|
||||
drawtarget.create_gradient_stops(gradient_stops.as_slice(), ExtendMode::Clamp),
|
||||
drawtarget.create_gradient_stops(&gradient_stops, ExtendMode::Clamp),
|
||||
&Matrix2D::identity()))
|
||||
},
|
||||
FillOrStrokeStyle::RadialGradient(ref radial_gradient_style) => {
|
||||
|
@ -398,7 +398,7 @@ impl FillOrStrokeStyle {
|
|||
&Point2D(radial_gradient_style.x0 as AzFloat, radial_gradient_style.y0 as AzFloat),
|
||||
&Point2D(radial_gradient_style.x1 as AzFloat, radial_gradient_style.y1 as AzFloat),
|
||||
radial_gradient_style.r0 as AzFloat, radial_gradient_style.r1 as AzFloat,
|
||||
drawtarget.create_gradient_stops(gradient_stops.as_slice(), ExtendMode::Clamp),
|
||||
drawtarget.create_gradient_stops(&gradient_stops, ExtendMode::Clamp),
|
||||
&Matrix2D::identity()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* 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/. */
|
||||
|
||||
#![feature(core)]
|
||||
#![feature(collections)]
|
||||
|
||||
extern crate azure;
|
||||
|
|
|
@ -832,7 +832,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
};
|
||||
|
||||
let msg = ConstellationMsg::LoadUrl(root_pipeline_id,
|
||||
LoadData::new(Url::parse(url_string.as_slice()).unwrap()));
|
||||
LoadData::new(Url::parse(&url_string).unwrap()));
|
||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||
chan.send(msg).unwrap()
|
||||
}
|
||||
|
@ -1133,7 +1133,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
|
||||
if output_image {
|
||||
let path: Path =
|
||||
opts::get().output_file.as_ref().unwrap().as_slice().parse().unwrap();
|
||||
opts::get().output_file.as_ref().unwrap().parse().unwrap();
|
||||
let mut pixels = gl::read_pixels(0, 0,
|
||||
width as gl::GLsizei,
|
||||
height as gl::GLsizei,
|
||||
|
@ -1141,13 +1141,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
|
||||
gl::bind_framebuffer(gl::FRAMEBUFFER, 0);
|
||||
|
||||
gl::delete_buffers(texture_ids.as_slice());
|
||||
gl::delete_frame_buffers(framebuffer_ids.as_slice());
|
||||
gl::delete_buffers(&texture_ids);
|
||||
gl::delete_frame_buffers(&framebuffer_ids);
|
||||
|
||||
// flip image vertically (texture is upside down)
|
||||
let orig_pixels = pixels.clone();
|
||||
let stride = width * 3;
|
||||
for y in range(0, height) {
|
||||
for y in 0..height {
|
||||
let dst_start = y * stride;
|
||||
let src_start = (height - y - 1) * stride;
|
||||
let src_slice = &orig_pixels[src_start .. src_start + stride];
|
||||
|
|
|
@ -93,13 +93,13 @@ impl ActorRegistry {
|
|||
}
|
||||
|
||||
pub fn register_script_actor(&self, script_id: String, actor: String) {
|
||||
println!("registering {} ({})", actor.as_slice(), script_id.as_slice());
|
||||
println!("registering {} ({})", actor, script_id);
|
||||
let mut script_actors = self.script_actors.borrow_mut();
|
||||
script_actors.insert(script_id, actor);
|
||||
}
|
||||
|
||||
pub fn script_to_actor(&self, script_id: String) -> String {
|
||||
if script_id.as_slice() == "" {
|
||||
if script_id.is_empty() {
|
||||
return "".to_string();
|
||||
}
|
||||
self.script_actors.borrow().get(&script_id).unwrap().to_string()
|
||||
|
@ -111,8 +111,8 @@ impl ActorRegistry {
|
|||
|
||||
pub fn actor_to_script(&self, actor: String) -> String {
|
||||
for (key, value) in self.script_actors.borrow().iter() {
|
||||
println!("checking {}", value.as_slice());
|
||||
if value.as_slice() == actor.as_slice() {
|
||||
println!("checking {}", value);
|
||||
if *value == actor {
|
||||
return key.to_string();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,13 +121,13 @@ impl Actor for ConsoleActor {
|
|||
msg_type: &String,
|
||||
msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
Ok(match &**msg_type {
|
||||
"getCachedMessages" => {
|
||||
let types = msg.get(&"messageTypes".to_string()).unwrap().as_array().unwrap();
|
||||
let /*mut*/ messages = vec!();
|
||||
for msg_type in types.iter() {
|
||||
let msg_type = msg_type.as_string().unwrap();
|
||||
match msg_type.as_slice() {
|
||||
match &*msg_type {
|
||||
"ConsoleAPI" => {
|
||||
//TODO: figure out all consoleapi properties from FFOX source
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ impl Actor for HighlighterActor {
|
|||
msg_type: &String,
|
||||
_msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
Ok(match &**msg_type {
|
||||
"showBoxModel" => {
|
||||
let msg = ShowBoxModelReply {
|
||||
from: self.name(),
|
||||
|
@ -106,12 +106,12 @@ impl Actor for NodeActor {
|
|||
msg_type: &String,
|
||||
msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
Ok(match &**msg_type {
|
||||
"modifyAttributes" => {
|
||||
let target = msg.get(&"to".to_string()).unwrap().as_string().unwrap();
|
||||
let mods = msg.get(&"modifications".to_string()).unwrap().as_array().unwrap();
|
||||
let modifications = mods.iter().map(|json_mod| {
|
||||
json::decode(json_mod.to_string().as_slice()).unwrap()
|
||||
json::decode(&json_mod.to_string()).unwrap()
|
||||
}).collect();
|
||||
|
||||
self.script_chan.send(ModifyAttribute(self.pipeline,
|
||||
|
@ -280,7 +280,7 @@ impl Actor for WalkerActor {
|
|||
msg_type: &String,
|
||||
msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
Ok(match &**msg_type {
|
||||
"querySelector" => {
|
||||
let msg = QuerySelectorReply {
|
||||
from: self.name(),
|
||||
|
@ -426,7 +426,7 @@ impl Actor for PageStyleActor {
|
|||
msg_type: &String,
|
||||
msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
Ok(match &**msg_type {
|
||||
"getApplied" => {
|
||||
//TODO: query script for relevant applied styles to node (msg.node)
|
||||
let msg = GetAppliedReply {
|
||||
|
@ -498,7 +498,7 @@ impl Actor for InspectorActor {
|
|||
msg_type: &String,
|
||||
_msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
Ok(match &**msg_type {
|
||||
"getWalker" => {
|
||||
if self.walker.borrow().is_none() {
|
||||
let walker = WalkerActor {
|
||||
|
|
|
@ -55,7 +55,7 @@ impl Actor for RootActor {
|
|||
msg_type: &String,
|
||||
_msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
Ok(match &**msg_type {
|
||||
"listAddons" => {
|
||||
let actor = ErrorReply {
|
||||
from: "root".to_string(),
|
||||
|
@ -72,7 +72,7 @@ impl Actor for RootActor {
|
|||
from: "root".to_string(),
|
||||
selected: 0,
|
||||
tabs: self.tabs.iter().map(|tab| {
|
||||
registry.find::<TabActor>(tab.as_slice()).encodable()
|
||||
registry.find::<TabActor>(tab).encodable()
|
||||
}).collect()
|
||||
};
|
||||
stream.write_json_packet(&actor);
|
||||
|
|
|
@ -80,7 +80,7 @@ impl Actor for TabActor {
|
|||
msg_type: &String,
|
||||
_msg: &json::Object,
|
||||
stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(match msg_type.as_slice() {
|
||||
Ok(match &**msg_type {
|
||||
"reconfigure" => {
|
||||
stream.write_json_packet(&ReconfigureReply { from: self.name() });
|
||||
true
|
||||
|
@ -97,7 +97,7 @@ impl Actor for TabActor {
|
|||
javascriptEnabled: true,
|
||||
traits: TabTraits,
|
||||
};
|
||||
let console_actor = registry.find::<ConsoleActor>(self.console.as_slice());
|
||||
let console_actor = registry.find::<ConsoleActor>(&self.console);
|
||||
console_actor.streams.borrow_mut().push(stream.clone());
|
||||
stream.write_json_packet(&msg);
|
||||
console_actor.script_chan.send(
|
||||
|
@ -112,7 +112,7 @@ impl Actor for TabActor {
|
|||
from: self.name(),
|
||||
__type__: "detached".to_string(),
|
||||
};
|
||||
let console_actor = registry.find::<ConsoleActor>(self.console.as_slice());
|
||||
let console_actor = registry.find::<ConsoleActor>(&self.console);
|
||||
console_actor.streams.borrow_mut().pop();
|
||||
stream.write_json_packet(&msg);
|
||||
console_actor.script_chan.send(
|
||||
|
|
|
@ -87,7 +87,7 @@ pub fn start_server(port: u16) -> Sender<DevtoolsControlMsg> {
|
|||
static POLL_TIMEOUT: u64 = 300;
|
||||
|
||||
fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
|
||||
let listener = TcpListener::bind(format!("{}:{}", "127.0.0.1", port).as_slice());
|
||||
let listener = TcpListener::bind(&*format!("{}:{}", "127.0.0.1", port));
|
||||
|
||||
// bind the listener to the specified address
|
||||
let mut acceptor = listener.listen().unwrap();
|
||||
|
@ -193,7 +193,7 @@ fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
|
|||
actor_pipelines: &HashMap<PipelineId, String>) {
|
||||
let console_actor_name = find_console_actor(actors.clone(), id, actor_pipelines);
|
||||
let actors = actors.lock().unwrap();
|
||||
let console_actor = actors.find::<ConsoleActor>(console_actor_name.as_slice());
|
||||
let console_actor = actors.find::<ConsoleActor>(&console_actor_name);
|
||||
match console_message {
|
||||
ConsoleMessage::LogMessage(message, filename, lineNumber, columnNumber) => {
|
||||
let msg = ConsoleAPICall {
|
||||
|
@ -220,7 +220,7 @@ fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
|
|||
actor_pipelines: &HashMap<PipelineId, String>) -> String {
|
||||
let actors = actors.lock().unwrap();
|
||||
let ref tab_actor_name = (*actor_pipelines)[id];
|
||||
let tab_actor = actors.find::<TabActor>(tab_actor_name.as_slice());
|
||||
let tab_actor = actors.find::<TabActor>(tab_actor_name);
|
||||
let console_actor_name = tab_actor.console.clone();
|
||||
return console_actor_name;
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ impl JsonPacketStream for TcpStream {
|
|||
fn write_json_packet<'a, T: Encodable>(&mut self, obj: &T) {
|
||||
let s = json::encode(obj).unwrap().replace("__type__", "type");
|
||||
println!("<- {}", s);
|
||||
self.write_str(s.len().to_string().as_slice()).unwrap();
|
||||
self.write_str(&s.len().to_string()).unwrap();
|
||||
self.write_u8(':' as u8).unwrap();
|
||||
self.write_str(s.as_slice()).unwrap();
|
||||
self.write_str(&s).unwrap();
|
||||
}
|
||||
|
||||
fn read_json_packet<'a>(&mut self) -> IoResult<Json> {
|
||||
|
@ -35,11 +35,11 @@ impl JsonPacketStream for TcpStream {
|
|||
Ok(c) if c != colon => buffer.push(c as u8),
|
||||
Ok(_) => {
|
||||
let packet_len_str = String::from_utf8(buffer).unwrap();
|
||||
let packet_len = num::from_str_radix(packet_len_str.as_slice(), 10).unwrap();
|
||||
let packet_len = num::from_str_radix(&packet_len_str, 10).unwrap();
|
||||
let packet_buf = self.read_exact(packet_len).unwrap();
|
||||
let packet = String::from_utf8(packet_buf).unwrap();
|
||||
println!("{}", packet);
|
||||
return Ok(Json::from_str(packet.as_slice()).unwrap())
|
||||
return Ok(Json::from_str(&packet).unwrap())
|
||||
},
|
||||
Err(ref e) if e.kind == EndOfFile =>
|
||||
return Err(IoError { kind: EndOfFile, desc: "EOF", detail: None }),
|
||||
|
|
|
@ -1079,7 +1079,7 @@ impl DisplayItem {
|
|||
paint_context.draw_linear_gradient(&gradient.base.bounds,
|
||||
&gradient.start_point,
|
||||
&gradient.end_point,
|
||||
gradient.stops.as_slice());
|
||||
&gradient.stops);
|
||||
}
|
||||
|
||||
DisplayItem::LineClass(ref line) => {
|
||||
|
|
|
@ -84,7 +84,7 @@ impl FontTemplate {
|
|||
}
|
||||
|
||||
pub fn identifier<'a>(&'a self) -> &'a str {
|
||||
self.identifier.as_slice()
|
||||
&*self.identifier
|
||||
}
|
||||
|
||||
/// Get the data for creating a font if it matches a given descriptor.
|
||||
|
|
|
@ -36,7 +36,7 @@ pub fn get_available_families<F>(mut callback: F) where F: FnMut(String) {
|
|||
unsafe {
|
||||
let config = FcConfigGetCurrent();
|
||||
let fontSet = FcConfigGetFonts(config, FcSetSystem);
|
||||
for i in range(0, (*fontSet).nfont as int) {
|
||||
for i in 0..((*fontSet).nfont as int) {
|
||||
let font = (*fontSet).fonts.offset(i);
|
||||
let mut family: *mut FcChar8 = ptr::null_mut();
|
||||
let mut v: c_int = 0;
|
||||
|
@ -74,7 +74,7 @@ pub fn get_variations_for_family<F>(family_name: &str, mut callback: F)
|
|||
|
||||
debug!("found {} variations", (*matches).nfont);
|
||||
|
||||
for i in range(0, (*matches).nfont as int) {
|
||||
for i in 0..((*matches).nfont as int) {
|
||||
let font = (*matches).fonts.offset(i);
|
||||
let mut file: *mut FcChar8 = ptr::null_mut();
|
||||
let file = if FcPatternGetString(*font, FC_FILE.as_ptr() as *mut c_char, 0, &mut file) == FcResultMatch {
|
||||
|
|
|
@ -356,7 +356,7 @@ impl<'a> DetailedGlyphStore {
|
|||
detail_offset: 0, // unused
|
||||
};
|
||||
|
||||
let i = self.detail_lookup.as_slice().binary_search_index(&key)
|
||||
let i = (&*self.detail_lookup).binary_search_index(&key)
|
||||
.expect("Invalid index not found in detailed glyph lookup table!");
|
||||
|
||||
assert!(i + (count as uint) <= self.detail_buffer.len());
|
||||
|
@ -600,7 +600,7 @@ impl<'a> GlyphStore {
|
|||
data_for_glyphs[i].offset)
|
||||
}).collect();
|
||||
|
||||
self.detail_store.add_detailed_glyphs_for_entry(i, glyphs_vec.as_slice());
|
||||
self.detail_store.add_detailed_glyphs_for_entry(i, &glyphs_vec);
|
||||
GlyphEntry::complex(first_glyph_data.cluster_start,
|
||||
first_glyph_data.ligature_start,
|
||||
glyph_count)
|
||||
|
|
|
@ -306,7 +306,7 @@ impl Shaper {
|
|||
}
|
||||
|
||||
debug!("(glyph idx) -> (text byte offset)");
|
||||
for i in range(0, glyph_data.len()) {
|
||||
for i in 0..glyph_data.len() {
|
||||
// loc refers to a *byte* offset within the utf8 string.
|
||||
let loc = glyph_data.byte_offset_of_glyph(i);
|
||||
if loc < byte_max {
|
||||
|
@ -481,7 +481,7 @@ impl Shaper {
|
|||
}
|
||||
|
||||
// now add the detailed glyph entry.
|
||||
glyphs.add_glyphs_for_char_index(char_idx, datas.as_slice());
|
||||
glyphs.add_glyphs_for_char_index(char_idx, &datas);
|
||||
|
||||
// set the other chars, who have no glyphs
|
||||
let mut i = covered_byte_span.begin();
|
||||
|
|
|
@ -186,7 +186,7 @@ impl<'a> Iterator for LineIterator<'a> {
|
|||
|
||||
impl<'a> TextRun {
|
||||
pub fn new(font: &mut Font, text: String, options: &ShapingOptions) -> TextRun {
|
||||
let glyphs = TextRun::break_and_shape(font, text.as_slice(), options);
|
||||
let glyphs = TextRun::break_and_shape(font, &text, options);
|
||||
let run = TextRun {
|
||||
text: Arc::new(text),
|
||||
font_metrics: font.metrics.clone(),
|
||||
|
@ -331,7 +331,7 @@ impl<'a> TextRun {
|
|||
|
||||
/// Returns the index of the first glyph run containing the given character index.
|
||||
fn index_of_first_glyph_run_containing(&self, index: CharIndex) -> Option<uint> {
|
||||
self.glyphs.as_slice().binary_search_index_by(&index, CharIndexComparator)
|
||||
(&**self.glyphs).binary_search_index_by(&index, CharIndexComparator)
|
||||
}
|
||||
|
||||
/// Returns an iterator that will iterate over all slices of glyphs that represent natural
|
||||
|
|
|
@ -54,7 +54,7 @@ impl Cookie {
|
|||
|
||||
// Step 6
|
||||
let host_only = if !domain.is_empty() {
|
||||
if !Cookie::domain_match(url_host.as_slice(), domain.as_slice()) {
|
||||
if !Cookie::domain_match(&url_host, &domain) {
|
||||
return None;
|
||||
} else {
|
||||
cookie.domain = Some(domain);
|
||||
|
@ -69,7 +69,7 @@ impl Cookie {
|
|||
let mut path = cookie.path.unwrap_or("".to_owned());
|
||||
if path.is_empty() || path.char_at(0) != '/' {
|
||||
let url_path = request.serialize_path();
|
||||
let url_path = url_path.as_ref().map(|path| path.as_slice());
|
||||
let url_path = url_path.as_ref().map(|path| &**path);
|
||||
path = Cookie::default_path(url_path.unwrap_or(""));
|
||||
}
|
||||
cookie.path = Some(path);
|
||||
|
@ -136,14 +136,14 @@ impl Cookie {
|
|||
}
|
||||
} else {
|
||||
if let (Some(ref domain), &Some(ref cookie_domain)) = (domain, &self.cookie.domain) {
|
||||
if !Cookie::domain_match(domain.as_slice(), cookie_domain.as_slice()) {
|
||||
if !Cookie::domain_match(domain, cookie_domain) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let (Some(ref path), &Some(ref cookie_path)) = (url.serialize_path(), &self.cookie.path) {
|
||||
if !Cookie::path_match(path.as_slice(), cookie_path.as_slice()) {
|
||||
if !Cookie::path_match(path, cookie_path) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -177,12 +177,12 @@ fn test_domain_match() {
|
|||
|
||||
#[test]
|
||||
fn test_default_path() {
|
||||
assert!(Cookie::default_path("/foo/bar/baz/").as_slice() == "/foo/bar/baz");
|
||||
assert!(Cookie::default_path("/foo/").as_slice() == "/foo");
|
||||
assert!(Cookie::default_path("/foo").as_slice() == "/");
|
||||
assert!(Cookie::default_path("/").as_slice() == "/");
|
||||
assert!(Cookie::default_path("").as_slice() == "/");
|
||||
assert!(Cookie::default_path("foo").as_slice() == "/");
|
||||
assert!(&*Cookie::default_path("/foo/bar/baz/") == "/foo/bar/baz");
|
||||
assert!(&*Cookie::default_path("/foo/") == "/foo");
|
||||
assert!(&*Cookie::default_path("/foo") == "/");
|
||||
assert!(&*Cookie::default_path("/") == "/");
|
||||
assert!(&*Cookie::default_path("") == "/");
|
||||
assert!(&*Cookie::default_path("foo") == "/");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -201,7 +201,7 @@ fn fn_cookie_constructor() {
|
|||
let cookie = cookie_rs::Cookie::parse(" baz = bar; Domain = ").unwrap();
|
||||
assert!(Cookie::new_wrapped(cookie.clone(), url, CookieSource::HTTP).is_some());
|
||||
let cookie = Cookie::new_wrapped(cookie, url, CookieSource::HTTP).unwrap();
|
||||
assert!(cookie.cookie.domain.as_ref().unwrap().as_slice() == "example.com");
|
||||
assert!(&**cookie.cookie.domain.as_ref().unwrap() == "example.com");
|
||||
|
||||
// cookie public domains test
|
||||
let cookie = cookie_rs::Cookie::parse(" baz = bar; Domain = gov.ac").unwrap();
|
||||
|
|
|
@ -112,7 +112,7 @@ impl CookieStorage {
|
|||
(match acc.len() {
|
||||
0 => acc,
|
||||
_ => acc + ";"
|
||||
}) + c.cookie.name.as_slice() + "=" + c.cookie.value.as_slice()
|
||||
}) + &c.cookie.name + "=" + &c.cookie.value
|
||||
};
|
||||
let result = url_cookies.iter_mut().fold("".to_string(), reducer);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ pub fn factory(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
|
|||
|
||||
fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
|
||||
let url = load_data.url;
|
||||
assert!("data" == url.scheme.as_slice());
|
||||
assert!(&*url.scheme == "data");
|
||||
|
||||
let mut metadata = Metadata::default(url.clone());
|
||||
|
||||
|
@ -39,11 +39,11 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
|
|||
match url.query {
|
||||
Some(query) => {
|
||||
scheme_data.push_str("?");
|
||||
scheme_data.push_str(query.as_slice());
|
||||
scheme_data.push_str(&query);
|
||||
},
|
||||
None => ()
|
||||
}
|
||||
let parts: Vec<&str> = scheme_data.as_slice().splitn(1, ',').collect();
|
||||
let parts: Vec<&str> = scheme_data.splitn(1, ',').collect();
|
||||
if parts.len() != 2 {
|
||||
start_sending(senders, metadata).send(Done(Err("invalid data uri".to_string()))).unwrap();
|
||||
return;
|
||||
|
@ -70,7 +70,7 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
|
|||
// FIXME(#2909): It’s unclear what to do with non-alphabet characters,
|
||||
// but Acid 3 apparently depends on spaces being ignored.
|
||||
let bytes = bytes.into_iter().filter(|&b| b != ' ' as u8).collect::<Vec<u8>>();
|
||||
match bytes.as_slice().from_base64() {
|
||||
match bytes.from_base64() {
|
||||
Err(..) => {
|
||||
progress_chan.send(Done(Err("non-base64 data uri".to_string()))).unwrap();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ pub enum HeaderOrMethod {
|
|||
impl HeaderOrMethod {
|
||||
fn match_header(&self, header_name: &str) -> bool {
|
||||
match *self {
|
||||
HeaderOrMethod::HeaderData(ref s) => s.as_slice().eq_ignore_ascii_case(header_name),
|
||||
HeaderOrMethod::HeaderData(ref s) => s.eq_ignore_ascii_case(header_name),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
@ -294,10 +294,10 @@ impl CORSCacheTask {
|
|||
tx.send(());
|
||||
},
|
||||
CORSCacheTaskMsg::MatchHeader(request, header, tx) => {
|
||||
tx.send(self.cache.match_header(request, header.as_slice()));
|
||||
tx.send(self.cache.match_header(request, &header));
|
||||
},
|
||||
CORSCacheTaskMsg::MatchHeaderUpdate(request, header, new_max_age, tx) => {
|
||||
tx.send(self.cache.match_header_and_update(request, header.as_slice(), new_max_age));
|
||||
tx.send(self.cache.match_header_and_update(request, &header, new_max_age));
|
||||
},
|
||||
CORSCacheTaskMsg::MatchMethod(request, method, tx) => {
|
||||
tx.send(self.cache.match_method(request, method));
|
||||
|
|
|
@ -119,9 +119,9 @@ impl Request {
|
|||
|
||||
/// [Basic fetch](http://fetch.spec.whatwg.org#basic-fetch)
|
||||
pub fn basic_fetch(&mut self) -> Response {
|
||||
match self.url.scheme.as_slice() {
|
||||
match &*self.url.scheme {
|
||||
"about" => match self.url.non_relative_scheme_data() {
|
||||
Some(s) if s.as_slice() == "blank" => {
|
||||
Some(s) if &*s == "blank" => {
|
||||
let mut response = Response::new();
|
||||
response.headers.set(ContentType(Mime(
|
||||
TopLevel::Text, SubLevel::Html,
|
||||
|
|
|
@ -110,7 +110,7 @@ impl Response {
|
|||
ResponseType::Default | ResponseType::Error => unreachable!(),
|
||||
ResponseType::Basic => {
|
||||
let headers = old_headers.iter().filter(|header| {
|
||||
match header.name().to_ascii_lowercase().as_slice() {
|
||||
match &*header.name().to_ascii_lowercase() {
|
||||
"set-cookie" | "set-cookie2" => false,
|
||||
_ => true
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ impl Response {
|
|||
},
|
||||
ResponseType::CORS => {
|
||||
let headers = old_headers.iter().filter(|header| {
|
||||
match header.name().to_ascii_lowercase().as_slice() {
|
||||
match &*header.name().to_ascii_lowercase() {
|
||||
"cache-control" | "content-language" |
|
||||
"content-type" | "expires" | "last-modified" | "Pragma" => false,
|
||||
// XXXManishearth handle Access-Control-Expose-Headers
|
||||
|
|
|
@ -34,7 +34,7 @@ fn read_all(reader: &mut io::Stream, progress_chan: &Sender<ProgressMsg>)
|
|||
|
||||
pub fn factory(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
|
||||
let url = load_data.url;
|
||||
assert!("file" == url.scheme.as_slice());
|
||||
assert!(&*url.scheme == "file");
|
||||
let senders = ResponseSenders {
|
||||
immediate_consumer: start_chan,
|
||||
eventual_consumer: load_data.consumer,
|
||||
|
|
|
@ -64,20 +64,20 @@ fn load(mut load_data: LoadData, start_chan: Sender<TargetedLoadResponse>, cooki
|
|||
// real URL that should be used for which the source is to be viewed.
|
||||
// Change our existing URL to that and keep note that we are viewing
|
||||
// the source rather than rendering the contents of the URL.
|
||||
let viewing_source = if url.scheme == "view-source" {
|
||||
let inner_url = load_data.url.non_relative_scheme_data().unwrap();
|
||||
url = Url::parse(inner_url).unwrap();
|
||||
match url.scheme.as_slice() {
|
||||
"http" | "https" => {}
|
||||
_ => {
|
||||
let s = format!("The {} scheme with view-source is not supported", url.scheme);
|
||||
send_error(url, s, senders);
|
||||
return;
|
||||
}
|
||||
};
|
||||
true
|
||||
let viewing_source = if &*url.scheme == "view-source" {
|
||||
let inner_url = load_data.url.non_relative_scheme_data().unwrap();
|
||||
url = Url::parse(inner_url).unwrap();
|
||||
match &*url.scheme {
|
||||
"http" | "https" => {}
|
||||
_ => {
|
||||
let s = format!("The {} scheme with view-source is not supported", url.scheme);
|
||||
send_error(url, s, senders);
|
||||
return;
|
||||
}
|
||||
};
|
||||
true
|
||||
} else {
|
||||
false
|
||||
false
|
||||
};
|
||||
|
||||
// Loop to handle redirects.
|
||||
|
@ -89,7 +89,7 @@ fn load(mut load_data: LoadData, start_chan: Sender<TargetedLoadResponse>, cooki
|
|||
return;
|
||||
}
|
||||
|
||||
match url.scheme.as_slice() {
|
||||
match &*url.scheme {
|
||||
"http" | "https" => {}
|
||||
_ => {
|
||||
let s = format!("{} request, but we don't support that scheme", url.scheme);
|
||||
|
@ -252,7 +252,7 @@ reason: \"certificate verify failed\" }]";
|
|||
}
|
||||
_ => {}
|
||||
}
|
||||
let new_url = match UrlParser::new().base_url(&url).parse(new_url.as_slice()) {
|
||||
let new_url = match UrlParser::new().base_url(&url).parse(&new_url) {
|
||||
Ok(u) => u,
|
||||
Err(e) => {
|
||||
send_error(url, e.to_string(), senders);
|
||||
|
|
|
@ -316,7 +316,7 @@ impl ImageCache {
|
|||
debug!("image_cache_task: started image decode for {}", url.serialize());
|
||||
let image = profile(time::TimeProfilerCategory::ImageDecoding,
|
||||
None, time_profiler_chan, || {
|
||||
load_from_memory(data.as_slice())
|
||||
load_from_memory(&data)
|
||||
});
|
||||
|
||||
let image = image.map(|image| Arc::new(box image));
|
||||
|
@ -456,7 +456,7 @@ fn load_image_data(url: Url, resource_task: ResourceTask) -> Result<Vec<u8>, ()>
|
|||
loop {
|
||||
match progress_port.recv().unwrap() {
|
||||
Payload(data) => {
|
||||
image_data.push_all(data.as_slice());
|
||||
image_data.push_all(&data);
|
||||
}
|
||||
Done(Ok(..)) => {
|
||||
return Ok(image_data);
|
||||
|
|
|
@ -57,7 +57,7 @@ pub fn global_init() {
|
|||
};
|
||||
|
||||
unsafe {
|
||||
let host_table = boxed::into_raw(parse_hostsfile(lines.as_slice()));
|
||||
let host_table = boxed::into_raw(parse_hostsfile(&lines));
|
||||
HOST_TABLE = Some(host_table);
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ pub fn load_whole_resource(resource_task: &ResourceTask, url: Url)
|
|||
let mut buf = vec!();
|
||||
loop {
|
||||
match response.progress_port.recv().unwrap() {
|
||||
ProgressMsg::Payload(data) => buf.push_all(data.as_slice()),
|
||||
ProgressMsg::Payload(data) => buf.push_all(&data),
|
||||
ProgressMsg::Done(Ok(())) => return Ok((response.metadata, buf)),
|
||||
ProgressMsg::Done(Err(e)) => return Err(e)
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ impl ResourceManager {
|
|||
self.load(load_data)
|
||||
}
|
||||
ControlMsg::SetCookiesForUrl(request, cookie_list, source) => {
|
||||
let header = Header::parse_header([cookie_list.into_bytes()].as_slice());
|
||||
let header = Header::parse_header(&[cookie_list.into_bytes()]);
|
||||
if let Some(SetCookie(cookies)) = header {
|
||||
for bare_cookie in cookies.into_iter() {
|
||||
if let Some(cookie) = cookie::Cookie::new_wrapped(bare_cookie, &request, source) {
|
||||
|
@ -342,7 +342,7 @@ impl ResourceManager {
|
|||
}
|
||||
}
|
||||
|
||||
let loader = match load_data.url.scheme.as_slice() {
|
||||
let loader = match &*load_data.url.scheme {
|
||||
"file" => from_factory(file_loader::factory),
|
||||
"http" | "https" | "view-source" => http_loader::factory(self.resource_task.clone()),
|
||||
"data" => from_factory(data_loader::factory),
|
||||
|
@ -549,9 +549,7 @@ fn test_replace_hosts() {
|
|||
//Start the resource task and make a request to our TCP server
|
||||
let resource_task = new_resource_task(None);
|
||||
let (start_chan, _) = channel();
|
||||
let mut raw_url: String = "http://foo.bar.com:".to_string();
|
||||
raw_url = raw_url + port.to_string().as_slice();
|
||||
let url = Url::parse(raw_url.as_slice()).unwrap();
|
||||
let url = Url::parse(&format!("http://foo.bar.com:{}", port)).unwrap();
|
||||
resource_task.send(ControlMsg::Load(replace_hosts(LoadData::new(url, start_chan), host_table)));
|
||||
|
||||
match acceptor.accept() {
|
||||
|
|
|
@ -141,7 +141,7 @@ impl StorageManager {
|
|||
}
|
||||
|
||||
let updated = data.get_mut(&origin).map(|entry| {
|
||||
if entry.get(&origin).map_or(true, |item| item.as_slice() != value.as_slice()) {
|
||||
if entry.get(&origin).map_or(true, |item| *item != value) {
|
||||
entry.insert(name.clone(), value.clone());
|
||||
true
|
||||
} else {
|
||||
|
@ -182,12 +182,12 @@ impl StorageManager {
|
|||
|
||||
fn get_origin_as_string(&self, url: Url) -> String {
|
||||
let mut origin = "".to_string();
|
||||
origin.push_str(url.scheme.as_slice());
|
||||
origin.push_str(&url.scheme);
|
||||
origin.push_str("://");
|
||||
url.domain().map(|domain| origin.push_str(domain.as_slice()));
|
||||
url.domain().map(|domain| origin.push_str(&domain));
|
||||
url.port().map(|port| {
|
||||
origin.push_str(":");
|
||||
origin.push_str(port.to_string().as_slice());
|
||||
origin.push_str(&port.to_string());
|
||||
});
|
||||
origin.push_str("/");
|
||||
origin
|
||||
|
|
|
@ -27,7 +27,7 @@ impl LintPass for PrivatizePass {
|
|||
match field.node {
|
||||
ast::StructField_ { kind: ast::NamedField(ident, visibility), .. } if visibility == Public => {
|
||||
cx.span_lint(PRIVATIZE, field.span,
|
||||
format!("Field {} is public where only private fields are allowed", ident.name).as_slice());
|
||||
&format!("Field {} is public where only private fields are allowed", ident.name));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -1109,7 +1109,7 @@ pub mod longhands {
|
|||
Ok(_) => return Err(()),
|
||||
Err(_) => break,
|
||||
};
|
||||
if content::counter_name_is_illegal(counter_name.as_slice()) {
|
||||
if content::counter_name_is_illegal(&counter_name) {
|
||||
return Err(())
|
||||
}
|
||||
let counter_delta = input.try(|input| input.expect_integer()).unwrap_or(1) as i32;
|
||||
|
@ -2075,7 +2075,7 @@ pub mod longhands {
|
|||
|
||||
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||
let mut lengths = [ None, None ];
|
||||
for i in range(0, 2) {
|
||||
for i in 0..2 {
|
||||
match specified::Length::parse_non_negative(input) {
|
||||
Err(()) => break,
|
||||
Ok(length) => lengths[i] = Some(length),
|
||||
|
|
|
@ -326,7 +326,7 @@ impl LowercaseString {
|
|||
impl Str for LowercaseString {
|
||||
#[inline]
|
||||
fn as_slice(&self) -> &str {
|
||||
self.inner.as_slice()
|
||||
&*self.inner
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ impl TaskPool {
|
|||
|
||||
let state = Arc::new(Mutex::new(rx));
|
||||
|
||||
for i in range(0, tasks) {
|
||||
for i in 0..tasks {
|
||||
let state = state.clone();
|
||||
spawn_named(
|
||||
format!("TaskPoolWorker {}/{}", i+1, tasks),
|
||||
|
|
|
@ -44,7 +44,7 @@ impl Formatable for Option<TimerMetadata> {
|
|||
match self {
|
||||
// TODO(cgaebel): Center-align in the format strings as soon as rustc supports it.
|
||||
&Some(ref meta) => {
|
||||
let url = meta.url.as_slice();
|
||||
let url = &*meta.url;
|
||||
let url = if url.len() > 30 {
|
||||
&url[..30]
|
||||
} else {
|
||||
|
@ -243,7 +243,7 @@ impl TimeProfiler {
|
|||
if data_len > 0 {
|
||||
let (mean, median, min, max) =
|
||||
(data.iter().map(|&x|x).sum() / (data_len as f64),
|
||||
data.as_slice()[data_len / 2],
|
||||
data[data_len / 2],
|
||||
data.iter().fold(f64::INFINITY, |a, &b| a.min(b)),
|
||||
data.iter().fold(-f64::INFINITY, |a, &b| a.max(b)));
|
||||
println!("{:-35}{} {:15.4} {:15.4} {:15.4} {:15.4} {:15}",
|
||||
|
|
|
@ -231,7 +231,7 @@ impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
|||
// Set up data structures.
|
||||
let (supervisor_chan, supervisor_port) = channel();
|
||||
let (mut infos, mut threads) = (vec!(), vec!());
|
||||
for i in range(0, thread_count) {
|
||||
for i in 0..thread_count {
|
||||
let (worker_chan, worker_port) = channel();
|
||||
let pool = BufferPool::new();
|
||||
let (worker, thief) = pool.deque();
|
||||
|
@ -250,8 +250,8 @@ impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
|||
}
|
||||
|
||||
// Connect workers to one another.
|
||||
for i in range(0, thread_count) {
|
||||
for j in range(0, thread_count) {
|
||||
for i in 0..thread_count {
|
||||
for j in 0..thread_count {
|
||||
if i != j {
|
||||
threads[i].other_deques.push(infos[j].thief.clone())
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
|||
}
|
||||
|
||||
// Get our deques back.
|
||||
for _ in range(0, self.workers.len()) {
|
||||
for _ in 0..self.workers.len() {
|
||||
match self.port.recv().unwrap() {
|
||||
SupervisorMsg::ReturnDeque(index, deque) => self.workers[index].deque = Some(deque),
|
||||
SupervisorMsg::Finished => panic!("unexpected finished message!"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче