mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Remove some as_slice calls.
This commit is contained in:
parent
4ee89363fb
commit
6a55ae06d7
34 changed files with 79 additions and 79 deletions
|
@ -32,7 +32,7 @@ struct BufferKey([usize; 2]);
|
||||||
impl Hash for BufferKey {
|
impl Hash for BufferKey {
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
let BufferKey(ref bytes) = *self;
|
let BufferKey(ref bytes) = *self;
|
||||||
bytes.as_slice().hash(state);
|
bytes.hash(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ use platform::font_list::get_variations_for_family;
|
||||||
use platform::font_list::get_last_resort_font_families;
|
use platform::font_list::get_last_resort_font_families;
|
||||||
use platform::font_context::FontContextHandle;
|
use platform::font_context::FontContextHandle;
|
||||||
|
|
||||||
use collections::str::Str;
|
|
||||||
use font_template::{FontTemplate, FontTemplateDescriptor};
|
use font_template::{FontTemplate, FontTemplateDescriptor};
|
||||||
use net_traits::{ResourceTask, load_whole_resource};
|
use net_traits::{ResourceTask, load_whole_resource};
|
||||||
use platform::font_template::FontTemplateData;
|
use platform::font_template::FontTemplateData;
|
||||||
|
@ -106,7 +105,7 @@ fn add_generic_font(generic_fonts: &mut HashMap<LowercaseString, LowercaseString
|
||||||
generic_name: &str, mapped_name: &str) {
|
generic_name: &str, mapped_name: &str) {
|
||||||
let opt_system_default = get_system_default_family(generic_name);
|
let opt_system_default = get_system_default_family(generic_name);
|
||||||
let family_name = match opt_system_default {
|
let family_name = match opt_system_default {
|
||||||
Some(system_default) => LowercaseString::new(system_default.as_slice()),
|
Some(system_default) => LowercaseString::new(&system_default),
|
||||||
None => LowercaseString::new(mapped_name),
|
None => LowercaseString::new(mapped_name),
|
||||||
};
|
};
|
||||||
generic_fonts.insert(LowercaseString::new(generic_name), family_name);
|
generic_fonts.insert(LowercaseString::new(generic_name), family_name);
|
||||||
|
@ -119,7 +118,7 @@ impl FontCache {
|
||||||
|
|
||||||
match msg {
|
match msg {
|
||||||
Command::GetFontTemplate(family, descriptor, result) => {
|
Command::GetFontTemplate(family, descriptor, result) => {
|
||||||
let family = LowercaseString::new(family.as_slice());
|
let family = LowercaseString::new(&family);
|
||||||
let maybe_font_template = self.get_font_template(&family, &descriptor);
|
let maybe_font_template = self.get_font_template(&family, &descriptor);
|
||||||
result.send(Reply::GetFontTemplateReply(maybe_font_template)).unwrap();
|
result.send(Reply::GetFontTemplateReply(maybe_font_template)).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -128,7 +127,7 @@ impl FontCache {
|
||||||
result.send(Reply::GetFontTemplateReply(Some(font_template))).unwrap();
|
result.send(Reply::GetFontTemplateReply(Some(font_template))).unwrap();
|
||||||
}
|
}
|
||||||
Command::AddWebFont(family_name, src, result) => {
|
Command::AddWebFont(family_name, src, result) => {
|
||||||
let family_name = LowercaseString::new(family_name.as_slice());
|
let family_name = LowercaseString::new(&family_name);
|
||||||
if !self.web_families.contains_key(&family_name) {
|
if !self.web_families.contains_key(&family_name) {
|
||||||
let family = FontFamily::new();
|
let family = FontFamily::new();
|
||||||
self.web_families.insert(family_name.clone(), family);
|
self.web_families.insert(family_name.clone(), family);
|
||||||
|
@ -141,7 +140,7 @@ impl FontCache {
|
||||||
match maybe_resource {
|
match maybe_resource {
|
||||||
Ok((_, bytes)) => {
|
Ok((_, bytes)) => {
|
||||||
let family = &mut self.web_families[family_name];
|
let family = &mut self.web_families[family_name];
|
||||||
family.add_template(url.to_string().as_slice(), Some(bytes));
|
family.add_template(&url.to_string(), Some(bytes));
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
debug!("Failed to load web font: family={:?} url={}", family_name, url);
|
debug!("Failed to load web font: family={:?} url={}", family_name, url);
|
||||||
|
@ -150,8 +149,8 @@ impl FontCache {
|
||||||
}
|
}
|
||||||
Source::Local(ref local_family_name) => {
|
Source::Local(ref local_family_name) => {
|
||||||
let family = &mut self.web_families[family_name];
|
let family = &mut self.web_families[family_name];
|
||||||
get_variations_for_family(local_family_name.as_slice(), |path| {
|
get_variations_for_family(&local_family_name, |path| {
|
||||||
family.add_template(path.as_slice(), None);
|
family.add_template(&path, None);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +167,7 @@ impl FontCache {
|
||||||
fn refresh_local_families(&mut self) {
|
fn refresh_local_families(&mut self) {
|
||||||
self.local_families.clear();
|
self.local_families.clear();
|
||||||
get_available_families(|family_name| {
|
get_available_families(|family_name| {
|
||||||
let family_name = LowercaseString::new(family_name.as_slice());
|
let family_name = LowercaseString::new(&family_name);
|
||||||
if !self.local_families.contains_key(&family_name) {
|
if !self.local_families.contains_key(&family_name) {
|
||||||
let family = FontFamily::new();
|
let family = FontFamily::new();
|
||||||
self.local_families.insert(family_name, family);
|
self.local_families.insert(family_name, family);
|
||||||
|
@ -188,12 +187,12 @@ impl FontCache {
|
||||||
// TODO(Issue #188): look up localized font family names if canonical name not found
|
// TODO(Issue #188): look up localized font family names if canonical name not found
|
||||||
// look up canonical name
|
// look up canonical name
|
||||||
if self.local_families.contains_key(family_name) {
|
if self.local_families.contains_key(family_name) {
|
||||||
debug!("FontList: Found font family with name={}", family_name.as_slice());
|
debug!("FontList: Found font family with name={}", &**family_name);
|
||||||
let s = &mut self.local_families[*family_name];
|
let s = &mut self.local_families[*family_name];
|
||||||
|
|
||||||
if s.templates.len() == 0 {
|
if s.templates.len() == 0 {
|
||||||
get_variations_for_family(family_name.as_slice(), |path| {
|
get_variations_for_family(&family_name, |path| {
|
||||||
s.add_template(path.as_slice(), None);
|
s.add_template(&path, None);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +205,7 @@ impl FontCache {
|
||||||
|
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
debug!("FontList: Couldn't find font family with name={}", family_name.as_slice());
|
debug!("FontList: Couldn't find font family with name={}", &**family_name);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +236,7 @@ impl FontCache {
|
||||||
let last_resort = get_last_resort_font_families();
|
let last_resort = get_last_resort_font_families();
|
||||||
|
|
||||||
for family in last_resort.iter() {
|
for family in last_resort.iter() {
|
||||||
let family = LowercaseString::new(family.as_slice());
|
let family = LowercaseString::new(family);
|
||||||
let maybe_font_in_family = self.find_font_in_local_family(&family, desc);
|
let maybe_font_in_family = self.find_font_in_local_family(&family, desc);
|
||||||
if maybe_font_in_family.is_some() {
|
if maybe_font_in_family.is_some() {
|
||||||
return maybe_font_in_family.unwrap();
|
return maybe_font_in_family.unwrap();
|
||||||
|
|
|
@ -164,7 +164,7 @@ impl FontContext {
|
||||||
// GWTODO: Check on real pages if this is faster as Vec() or HashMap().
|
// GWTODO: Check on real pages if this is faster as Vec() or HashMap().
|
||||||
let mut cache_hit = false;
|
let mut cache_hit = false;
|
||||||
for cached_font_entry in self.layout_font_cache.iter() {
|
for cached_font_entry in self.layout_font_cache.iter() {
|
||||||
if cached_font_entry.family.as_slice() == family.name() {
|
if cached_font_entry.family == family.name() {
|
||||||
match cached_font_entry.font {
|
match cached_font_entry.font {
|
||||||
None => {
|
None => {
|
||||||
cache_hit = true;
|
cache_hit = true;
|
||||||
|
|
|
@ -158,7 +158,7 @@ impl FontTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert!(self.strong_ref.is_none());
|
assert!(self.strong_ref.is_none());
|
||||||
let template_data = Arc::new(FontTemplateData::new(self.identifier.as_slice(), None));
|
let template_data = Arc::new(FontTemplateData::new(&self.identifier, None));
|
||||||
self.weak_ref = Some(template_data.downgrade());
|
self.weak_ref = Some(template_data.downgrade());
|
||||||
template_data
|
template_data
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,8 +133,8 @@ impl<'a> PaintContext<'a> {
|
||||||
image_rendering: image_rendering::T) {
|
image_rendering: image_rendering::T) {
|
||||||
let size = Size2D(image.width as i32, image.height as i32);
|
let size = Size2D(image.width as i32, image.height as i32);
|
||||||
let (pixel_width, pixels, source_format) = match image.pixels {
|
let (pixel_width, pixels, source_format) = match image.pixels {
|
||||||
PixelsByColorType::RGBA8(ref pixels) => (4, pixels.as_slice(), SurfaceFormat::B8G8R8A8),
|
PixelsByColorType::RGBA8(ref pixels) => (4, pixels, SurfaceFormat::B8G8R8A8),
|
||||||
PixelsByColorType::K8(ref pixels) => (1, pixels.as_slice(), SurfaceFormat::A8),
|
PixelsByColorType::K8(ref pixels) => (1, pixels, SurfaceFormat::A8),
|
||||||
PixelsByColorType::RGB8(_) => panic!("RGB8 color type not supported"),
|
PixelsByColorType::RGB8(_) => panic!("RGB8 color type not supported"),
|
||||||
PixelsByColorType::KA8(_) => panic!("KA8 color type not supported"),
|
PixelsByColorType::KA8(_) => panic!("KA8 color type not supported"),
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub fn get_variations_for_family<F>(family_name: &str, mut callback: F) where F:
|
||||||
debug!("Looking for faces of family: {}", family_name);
|
debug!("Looking for faces of family: {}", family_name);
|
||||||
|
|
||||||
let family_collection =
|
let family_collection =
|
||||||
core_text::font_collection::create_for_family(family_name.as_slice());
|
core_text::font_collection::create_for_family(family_name);
|
||||||
match family_collection {
|
match family_collection {
|
||||||
Some(family_collection) => {
|
Some(family_collection) => {
|
||||||
let family_descriptors = family_collection.get_descriptors();
|
let family_descriptors = family_collection.get_descriptors();
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl FontTemplateData {
|
||||||
pub fn new(identifier: &str, font_data: Option<Vec<u8>>) -> FontTemplateData {
|
pub fn new(identifier: &str, font_data: Option<Vec<u8>>) -> FontTemplateData {
|
||||||
let ctfont = match font_data {
|
let ctfont = match font_data {
|
||||||
Some(ref bytes) => {
|
Some(ref bytes) => {
|
||||||
let fontprov = CGDataProvider::from_buffer(bytes.as_slice());
|
let fontprov = CGDataProvider::from_buffer(bytes);
|
||||||
let cgfont_result = CGFont::from_data_provider(fontprov);
|
let cgfont_result = CGFont::from_data_provider(fontprov);
|
||||||
match cgfont_result {
|
match cgfont_result {
|
||||||
Ok(cgfont) => Some(core_text::font::new_from_CGFont(&cgfont, 0.0)),
|
Ok(cgfont) => Some(core_text::font::new_from_CGFont(&cgfont, 0.0)),
|
||||||
|
@ -34,7 +34,7 @@ impl FontTemplateData {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
Some(core_text::font::new_from_name(identifier.as_slice(), 0.0).unwrap())
|
Some(core_text::font::new_from_name(&identifier, 0.0).unwrap())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,7 @@ impl<'a> DetailedGlyphStore {
|
||||||
detail_offset: 0, // unused
|
detail_offset: 0, // unused
|
||||||
};
|
};
|
||||||
|
|
||||||
let i = (&*self.detail_lookup).binary_search_index(&key)
|
let i = self.detail_lookup.binary_search_index(&key)
|
||||||
.expect("Invalid index not found in detailed glyph lookup table!");
|
.expect("Invalid index not found in detailed glyph lookup table!");
|
||||||
|
|
||||||
assert!(i + (count as usize) <= self.detail_buffer.len());
|
assert!(i + (count as usize) <= self.detail_buffer.len());
|
||||||
|
@ -379,7 +379,7 @@ impl<'a> DetailedGlyphStore {
|
||||||
detail_offset: 0, // unused
|
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!");
|
.expect("Invalid index not found in detailed glyph lookup table!");
|
||||||
|
|
||||||
assert!(i + (detail_offset as usize) < self.detail_buffer.len());
|
assert!(i + (detail_offset as usize) < self.detail_buffer.len());
|
||||||
|
|
|
@ -119,7 +119,7 @@ impl<'a> Eq for ApplicableDeclarationsCacheQuery<'a> {}
|
||||||
|
|
||||||
impl<'a> PartialEq<ApplicableDeclarationsCacheEntry> for ApplicableDeclarationsCacheQuery<'a> {
|
impl<'a> PartialEq<ApplicableDeclarationsCacheEntry> for ApplicableDeclarationsCacheQuery<'a> {
|
||||||
fn eq(&self, other: &ApplicableDeclarationsCacheEntry) -> bool {
|
fn eq(&self, other: &ApplicableDeclarationsCacheEntry) -> bool {
|
||||||
let other_as_query = ApplicableDeclarationsCacheQuery::new(other.declarations.as_slice());
|
let other_as_query = ApplicableDeclarationsCacheQuery::new(&other.declarations);
|
||||||
self.eq(&other_as_query)
|
self.eq(&other_as_query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ impl StyleSharingCandidate {
|
||||||
match (&self.class, element.get_attr(&ns!(""), &atom!("class"))) {
|
match (&self.class, element.get_attr(&ns!(""), &atom!("class"))) {
|
||||||
(&None, Some(_)) | (&Some(_), None) => return false,
|
(&None, Some(_)) | (&Some(_), None) => return false,
|
||||||
(&Some(ref this_class), Some(element_class)) if
|
(&Some(ref this_class), Some(element_class)) if
|
||||||
element_class != this_class.as_slice() => {
|
element_class != &**this_class => {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
(&Some(_), Some(_)) | (&None, None) => {}
|
(&Some(_), Some(_)) | (&None, None) => {}
|
||||||
|
|
|
@ -1506,7 +1506,7 @@ impl Fragment {
|
||||||
}
|
}
|
||||||
match self.specific {
|
match self.specific {
|
||||||
SpecificFragmentInfo::UnscannedText(ref text_fragment_info) => {
|
SpecificFragmentInfo::UnscannedText(ref text_fragment_info) => {
|
||||||
util::str::is_whitespace(text_fragment_info.text.as_slice())
|
util::str::is_whitespace(&text_fragment_info.text)
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
|
||||||
let mut temporary_counter = Counter::new();
|
let mut temporary_counter = Counter::new();
|
||||||
let counter = self.traversal
|
let counter = self.traversal
|
||||||
.counters
|
.counters
|
||||||
.get(counter_name.as_slice())
|
.get(&*counter_name)
|
||||||
.unwrap_or(&mut temporary_counter);
|
.unwrap_or(&mut temporary_counter);
|
||||||
new_info = counter.render(self.traversal.layout_context,
|
new_info = counter.render(self.traversal.layout_context,
|
||||||
fragment.node,
|
fragment.node,
|
||||||
|
@ -200,13 +200,13 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
|
||||||
let mut temporary_counter = Counter::new();
|
let mut temporary_counter = Counter::new();
|
||||||
let counter = self.traversal
|
let counter = self.traversal
|
||||||
.counters
|
.counters
|
||||||
.get(counter_name.as_slice())
|
.get(&*counter_name)
|
||||||
.unwrap_or(&mut temporary_counter);
|
.unwrap_or(&mut temporary_counter);
|
||||||
new_info = counter.render(self.traversal.layout_context,
|
new_info = counter.render(self.traversal.layout_context,
|
||||||
fragment.node,
|
fragment.node,
|
||||||
fragment.style.clone(),
|
fragment.style.clone(),
|
||||||
counter_style,
|
counter_style,
|
||||||
RenderingMode::All(separator.as_slice()));
|
RenderingMode::All(&separator));
|
||||||
}
|
}
|
||||||
GeneratedContentInfo::ContentItem(ContentItem::OpenQuote) => {
|
GeneratedContentInfo::ContentItem(ContentItem::OpenQuote) => {
|
||||||
new_info = Some(render_text(self.traversal.layout_context,
|
new_info = Some(render_text(self.traversal.layout_context,
|
||||||
|
|
|
@ -1384,7 +1384,7 @@ impl Flow for InlineFlow {
|
||||||
kid.assign_block_size_for_inorder_child_if_necessary(layout_context, thread_id);
|
kid.assign_block_size_for_inorder_child_if_necessary(layout_context, thread_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.base.position.size.block = match self.lines.as_slice().last() {
|
self.base.position.size.block = match self.lines.last() {
|
||||||
Some(ref last_line) => last_line.bounds.start.b + last_line.bounds.size.block,
|
Some(ref last_line) => last_line.bounds.start.b + last_line.bounds.size.block,
|
||||||
None => Au(0),
|
None => Au(0),
|
||||||
};
|
};
|
||||||
|
|
|
@ -600,7 +600,7 @@ impl LayoutTask {
|
||||||
|
|
||||||
// TODO we don't really even need to load this if mq does not match
|
// TODO we don't really even need to load this if mq does not match
|
||||||
let (metadata, iter) = load_bytes_iter(&self.resource_task, url);
|
let (metadata, iter) = load_bytes_iter(&self.resource_task, url);
|
||||||
let protocol_encoding_label = metadata.charset.as_ref().map(|s| s.as_slice());
|
let protocol_encoding_label = metadata.charset.as_ref().map(|s| &**s);
|
||||||
let final_url = metadata.final_url;
|
let final_url = metadata.final_url;
|
||||||
|
|
||||||
let sheet = Stylesheet::from_bytes_iter(iter,
|
let sheet = Stylesheet::from_bytes_iter(iter,
|
||||||
|
|
|
@ -169,7 +169,7 @@ impl TableFlow {
|
||||||
TableLayout::Auto => {
|
TableLayout::Auto => {
|
||||||
computation.union_block(&TableFlow::update_automatic_column_inline_sizes(
|
computation.union_block(&TableFlow::update_automatic_column_inline_sizes(
|
||||||
column_inline_sizes,
|
column_inline_sizes,
|
||||||
row.cell_intrinsic_inline_sizes.as_slice()))
|
&row.cell_intrinsic_inline_sizes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ impl Flow for TableFlow {
|
||||||
self.block_flow.base.flags.remove(IMPACTED_BY_RIGHT_FLOATS);
|
self.block_flow.base.flags.remove(IMPACTED_BY_RIGHT_FLOATS);
|
||||||
|
|
||||||
let info = ChildInlineSizeInfo {
|
let info = ChildInlineSizeInfo {
|
||||||
column_computed_inline_sizes: self.column_computed_inline_sizes.as_slice(),
|
column_computed_inline_sizes: &self.column_computed_inline_sizes,
|
||||||
spacing: spacing_per_cell,
|
spacing: spacing_per_cell,
|
||||||
};
|
};
|
||||||
self.block_flow.propagate_assigned_inline_size_to_children(layout_context,
|
self.block_flow.propagate_assigned_inline_size_to_children(layout_context,
|
||||||
|
|
|
@ -281,7 +281,7 @@ impl Flow for TableRowFlow {
|
||||||
|
|
||||||
// Push those inline sizes down to the cells.
|
// Push those inline sizes down to the cells.
|
||||||
let info = ChildInlineSizeInfo {
|
let info = ChildInlineSizeInfo {
|
||||||
column_computed_inline_sizes: computed_inline_size_for_cells.as_slice(),
|
column_computed_inline_sizes: &computed_inline_size_for_cells,
|
||||||
spacing: self.spacing,
|
spacing: self.spacing,
|
||||||
};
|
};
|
||||||
self.block_flow.propagate_assigned_inline_size_to_children(layout_context,
|
self.block_flow.propagate_assigned_inline_size_to_children(layout_context,
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl Flow for TableRowGroupFlow {
|
||||||
containing_block_inline_size);
|
containing_block_inline_size);
|
||||||
|
|
||||||
let info = ChildInlineSizeInfo {
|
let info = ChildInlineSizeInfo {
|
||||||
column_computed_inline_sizes: self.column_computed_inline_sizes.as_slice(),
|
column_computed_inline_sizes: &self.column_computed_inline_sizes,
|
||||||
spacing: self.spacing,
|
spacing: self.spacing,
|
||||||
};
|
};
|
||||||
self.block_flow.propagate_assigned_inline_size_to_children(layout_context,
|
self.block_flow.propagate_assigned_inline_size_to_children(layout_context,
|
||||||
|
|
|
@ -324,7 +324,7 @@ impl Flow for TableWrapperFlow {
|
||||||
}
|
}
|
||||||
Some(ref assigned_column_inline_sizes) => {
|
Some(ref assigned_column_inline_sizes) => {
|
||||||
let info = ChildInlineSizeInfo {
|
let info = ChildInlineSizeInfo {
|
||||||
column_computed_inline_sizes: assigned_column_inline_sizes.as_slice(),
|
column_computed_inline_sizes: &assigned_column_inline_sizes,
|
||||||
spacing: self.block_flow.fragment.style().get_inheritedtable().border_spacing,
|
spacing: self.block_flow.fragment.style().get_inheritedtable().border_spacing,
|
||||||
};
|
};
|
||||||
self.block_flow
|
self.block_flow
|
||||||
|
|
|
@ -142,7 +142,7 @@ impl TextRunScanner {
|
||||||
};
|
};
|
||||||
|
|
||||||
let old_length = CharIndex(run_text.chars().count() as isize);
|
let old_length = CharIndex(run_text.chars().count() as isize);
|
||||||
last_whitespace = util::transform_text(in_fragment.as_slice(),
|
last_whitespace = util::transform_text(&in_fragment,
|
||||||
compression,
|
compression,
|
||||||
last_whitespace,
|
last_whitespace,
|
||||||
&mut run_text);
|
&mut run_text);
|
||||||
|
|
|
@ -254,7 +254,7 @@ impl<'ln> LayoutNode<'ln> {
|
||||||
s.push_str(" ");
|
s.push_str(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
s.push_str(self.debug_str().as_slice());
|
s.push_str(&self.debug_str());
|
||||||
println!("{}", s);
|
println!("{}", s);
|
||||||
|
|
||||||
for kid in self.children() {
|
for kid in self.children() {
|
||||||
|
|
|
@ -233,7 +233,7 @@ impl ImageCache {
|
||||||
ResponseAction::HeadersAvailable(_) => {}
|
ResponseAction::HeadersAvailable(_) => {}
|
||||||
ResponseAction::DataAvailable(data) => {
|
ResponseAction::DataAvailable(data) => {
|
||||||
let pending_load = self.pending_loads.get_mut(&msg.url).unwrap();
|
let pending_load = self.pending_loads.get_mut(&msg.url).unwrap();
|
||||||
pending_load.bytes.push_all(data.as_slice());
|
pending_load.bytes.push_all(&data);
|
||||||
}
|
}
|
||||||
ResponseAction::ResponseComplete(result) => {
|
ResponseAction::ResponseComplete(result) => {
|
||||||
match result {
|
match result {
|
||||||
|
@ -246,7 +246,7 @@ impl ImageCache {
|
||||||
let sender = self.decoder_sender.clone();
|
let sender = self.decoder_sender.clone();
|
||||||
|
|
||||||
self.task_pool.execute(move || {
|
self.task_pool.execute(move || {
|
||||||
let image = load_from_memory(bytes.as_slice());
|
let image = load_from_memory(&bytes);
|
||||||
let msg = DecoderMsg {
|
let msg = DecoderMsg {
|
||||||
url: url,
|
url: url,
|
||||||
image: image
|
image: image
|
||||||
|
|
|
@ -28,7 +28,7 @@ impl MIMEClassifier {
|
||||||
return self.sniff_unknown_type(!no_sniff, data);
|
return self.sniff_unknown_type(!no_sniff, data);
|
||||||
}
|
}
|
||||||
Some((ref media_type, ref media_subtype)) => {
|
Some((ref media_type, ref media_subtype)) => {
|
||||||
match (media_type.as_slice(), media_subtype.as_slice()) {
|
match (&**media_type, &**media_subtype) {
|
||||||
("uknown", "unknown") | ("application", "uknown") | ("*", "*") => {
|
("uknown", "unknown") | ("application", "uknown") | ("*", "*") => {
|
||||||
return self.sniff_unknown_type(!no_sniff,data);
|
return self.sniff_unknown_type(!no_sniff,data);
|
||||||
}
|
}
|
||||||
|
@ -50,14 +50,14 @@ impl MIMEClassifier {
|
||||||
.or(supplied_type.clone());
|
.or(supplied_type.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
if media_type.as_slice() == "image" {
|
if &**media_type == "image" {
|
||||||
let tp = self.image_classifier.classify(data);
|
let tp = self.image_classifier.classify(data);
|
||||||
if tp.is_some() {
|
if tp.is_some() {
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match (media_type.as_slice(), media_subtype.as_slice()) {
|
match (&**media_type, &**media_subtype) {
|
||||||
("audio", _) | ("video", _) | ("application", "ogg") => {
|
("audio", _) | ("video", _) | ("application", "ogg") => {
|
||||||
let tp = self.audio_video_classifer.classify(data);
|
let tp = self.audio_video_classifer.classify(data);
|
||||||
if tp.is_some() {
|
if tp.is_some() {
|
||||||
|
|
|
@ -34,9 +34,9 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
|
||||||
match png::load_png_from_memory(buffer) {
|
match png::load_png_from_memory(buffer) {
|
||||||
Ok(mut png_image) => {
|
Ok(mut png_image) => {
|
||||||
match png_image.pixels {
|
match png_image.pixels {
|
||||||
png::PixelsByColorType::RGB8(ref mut data) => byte_swap(data.as_mut_slice()),
|
png::PixelsByColorType::RGB8(ref mut data) => byte_swap(data),
|
||||||
png::PixelsByColorType::RGBA8(ref mut data) => {
|
png::PixelsByColorType::RGBA8(ref mut data) => {
|
||||||
byte_swap_and_premultiply(data.as_mut_slice())
|
byte_swap_and_premultiply(data)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,9 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
|
||||||
assert!(image.depth == 4);
|
assert!(image.depth == 4);
|
||||||
// handle gif separately because the alpha-channel has to be premultiplied
|
// handle gif separately because the alpha-channel has to be premultiplied
|
||||||
if is_gif(buffer) {
|
if is_gif(buffer) {
|
||||||
byte_swap_and_premultiply(image.data.as_mut_slice());
|
byte_swap_and_premultiply(&mut image.data);
|
||||||
} else {
|
} else {
|
||||||
byte_swap(image.data.as_mut_slice());
|
byte_swap(&mut image.data);
|
||||||
}
|
}
|
||||||
Some(png::Image {
|
Some(png::Image {
|
||||||
width: image.width as u32,
|
width: image.width as u32,
|
||||||
|
|
|
@ -48,11 +48,11 @@ fn expand_cased<'cx, T>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree],
|
||||||
match (res, it.count()) {
|
match (res, it.count()) {
|
||||||
(Some((s, span)), 0) => {
|
(Some((s, span)), 0) => {
|
||||||
let new_s = s.chars().map(transform).collect::<String>();
|
let new_s = s.chars().map(transform).collect::<String>();
|
||||||
base::MacEager::expr(cx.expr_str(span, token::intern_and_get_ident(new_s.as_slice())))
|
base::MacEager::expr(cx.expr_str(span, token::intern_and_get_ident(&new_s)))
|
||||||
}
|
}
|
||||||
(_, rest) => {
|
(_, rest) => {
|
||||||
if rest > 0 {
|
if rest > 0 {
|
||||||
cx.span_err(sp, format!("expected 1 argument, found {}", rest+1).as_slice());
|
cx.span_err(sp, &format!("expected 1 argument, found {}", rest+1));
|
||||||
}
|
}
|
||||||
base::DummyResult::expr(sp)
|
base::DummyResult::expr(sp)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
//! - `#[dom_struct]` : Implies `#[privatize]`,`#[jstraceable]`, and `#[must_root]`.
|
//! - `#[dom_struct]` : Implies `#[privatize]`,`#[jstraceable]`, and `#[must_root]`.
|
||||||
//! Use this for structs that correspond to a DOM type
|
//! Use this for structs that correspond to a DOM type
|
||||||
|
|
||||||
#![feature(plugin_registrar, quote, plugin, box_syntax, rustc_private, core, unicode)]
|
#![feature(plugin_registrar, quote, plugin, box_syntax, rustc_private, unicode)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate syntax;
|
extern crate syntax;
|
||||||
|
|
|
@ -32,10 +32,10 @@ impl LintPass for TransmutePass {
|
||||||
&& args.len() == 1 {
|
&& args.len() == 1 {
|
||||||
let tcx = cx.tcx;
|
let tcx = cx.tcx;
|
||||||
cx.span_lint(TRANSMUTE_TYPE_LINT, ex.span,
|
cx.span_lint(TRANSMUTE_TYPE_LINT, ex.span,
|
||||||
format!("Transmute to {} from {} detected",
|
&format!("Transmute to {} from {} detected",
|
||||||
expr_ty(tcx, ex).repr(tcx),
|
expr_ty(tcx, ex).repr(tcx),
|
||||||
expr_ty(tcx, &**args.get(0).unwrap()).repr(tcx)
|
expr_ty(tcx, &**args.get(0).unwrap()).repr(tcx)
|
||||||
).as_slice());
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -150,7 +150,7 @@ impl LintPass for UnrootedPass {
|
||||||
ty::ty_enum(did, _) => {
|
ty::ty_enum(did, _) => {
|
||||||
if ty::has_attr(cx.tcx, did, "must_root") {
|
if ty::has_attr(cx.tcx, did, "must_root") {
|
||||||
cx.span_lint(UNROOTED_MUST_ROOT, expr.span,
|
cx.span_lint(UNROOTED_MUST_ROOT, expr.span,
|
||||||
format!("Expression of type {} must be rooted", t.repr(cx.tcx)).as_slice());
|
&format!("Expression of type {} must be rooted", t.repr(cx.tcx)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -22,9 +22,9 @@ pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]>
|
||||||
// however the more efficient way is to simply reverse the iterators and zip them
|
// however the more efficient way is to simply reverse the iterators and zip them
|
||||||
// which will compare them in reverse until one of them runs out of segments
|
// which will compare them in reverse until one of them runs out of segments
|
||||||
if seg.iter().rev().zip(segments.iter().rev()).all(|(a,b)| a.identifier.as_str() == *b) {
|
if seg.iter().rev().zip(segments.iter().rev()).all(|(a,b)| a.identifier.as_str() == *b) {
|
||||||
match seg.as_slice().last() {
|
match seg.last() {
|
||||||
Some(&PathSegment {parameters: AngleBracketedParameters(ref a), ..}) => {
|
Some(&PathSegment {parameters: AngleBracketedParameters(ref a), ..}) => {
|
||||||
Some(a.types.as_slice())
|
Some(&a.types)
|
||||||
}
|
}
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
|
|
|
@ -592,7 +592,7 @@ mod system_reporter {
|
||||||
};
|
};
|
||||||
if looking_for == LookingFor::Segment {
|
if looking_for == LookingFor::Segment {
|
||||||
// Look for a segment info line.
|
// Look for a segment info line.
|
||||||
let cap = match seg_re.captures(line.as_slice()) {
|
let cap = match seg_re.captures(&line) {
|
||||||
Some(cap) => cap,
|
Some(cap) => cap,
|
||||||
None => continue,
|
None => continue,
|
||||||
};
|
};
|
||||||
|
@ -617,7 +617,7 @@ mod system_reporter {
|
||||||
looking_for = LookingFor::Rss;
|
looking_for = LookingFor::Rss;
|
||||||
} else {
|
} else {
|
||||||
// Look for an "Rss:" line.
|
// Look for an "Rss:" line.
|
||||||
let cap = match rss_re.captures(line.as_slice()) {
|
let cap = match rss_re.captures(&line) {
|
||||||
Some(cap) => cap,
|
Some(cap) => cap,
|
||||||
None => continue,
|
None => continue,
|
||||||
};
|
};
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl CORSRequest {
|
||||||
referer.port() == destination.port() {
|
referer.port() == destination.port() {
|
||||||
return Ok(None); // Not cross-origin, proceed with a normal fetch
|
return Ok(None); // Not cross-origin, proceed with a normal fetch
|
||||||
}
|
}
|
||||||
match destination.scheme.as_slice() {
|
match &*destination.scheme {
|
||||||
// TODO: If the request's same origin data url flag is set (which isn't the case for XHR)
|
// TODO: If the request's same origin data url flag is set (which isn't the case for XHR)
|
||||||
// we can fetch a data URL normally. about:blank can also be fetched by XHR
|
// we can fetch a data URL normally. about:blank can also be fetched by XHR
|
||||||
"http" | "https" => {
|
"http" | "https" => {
|
||||||
|
@ -221,7 +221,7 @@ impl CORSRequest {
|
||||||
// Substeps 1-3 (parsing rules: https://fetch.spec.whatwg.org/#http-new-header-syntax)
|
// Substeps 1-3 (parsing rules: https://fetch.spec.whatwg.org/#http-new-header-syntax)
|
||||||
let methods_substep4 = [self.method.clone()];
|
let methods_substep4 = [self.method.clone()];
|
||||||
let mut methods = match response.headers.get() {
|
let mut methods = match response.headers.get() {
|
||||||
Some(&AccessControlAllowMethods(ref v)) => v.as_slice(),
|
Some(&AccessControlAllowMethods(ref v)) => &**v,
|
||||||
_ => return error
|
_ => return error
|
||||||
};
|
};
|
||||||
let headers = match response.headers.get() {
|
let headers = match response.headers.get() {
|
||||||
|
@ -420,7 +420,7 @@ impl CORSCache {
|
||||||
fn is_simple_header(h: &HeaderView) -> bool {
|
fn is_simple_header(h: &HeaderView) -> bool {
|
||||||
//FIXME: use h.is::<HeaderType>() when AcceptLanguage and
|
//FIXME: use h.is::<HeaderType>() when AcceptLanguage and
|
||||||
//ContentLanguage headers exist
|
//ContentLanguage headers exist
|
||||||
match h.name().to_ascii_lowercase().as_slice() {
|
match &*h.name().to_ascii_lowercase() {
|
||||||
"accept" | "accept-language" | "content-language" => true,
|
"accept" | "accept-language" | "content-language" => true,
|
||||||
"content-type" => match h.value() {
|
"content-type" => match h.value() {
|
||||||
Some(&ContentType(Mime(TopLevel::Text, SubLevel::Plain, _))) |
|
Some(&ContentType(Mime(TopLevel::Text, SubLevel::Plain, _))) |
|
||||||
|
|
|
@ -1019,9 +1019,9 @@ pub mod longhands {
|
||||||
try!(dest.write_str(" "));
|
try!(dest.write_str(" "));
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
try!(Token::QuotedString(pair.0.as_slice().into_cow()).to_css(dest));
|
try!(Token::QuotedString((*pair.0).into_cow()).to_css(dest));
|
||||||
try!(dest.write_str(" "));
|
try!(dest.write_str(" "));
|
||||||
try!(Token::QuotedString(pair.1.as_slice().into_cow()).to_css(dest));
|
try!(Token::QuotedString((*pair.1).into_cow()).to_css(dest));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1381,12 +1381,10 @@ pub mod longhands {
|
||||||
if let Ok(value) = input.try(|input| {
|
if let Ok(value) = input.try(|input| {
|
||||||
match input.next() {
|
match input.next() {
|
||||||
Err(_) => Err(()),
|
Err(_) => Err(()),
|
||||||
Ok(Token::Ident(ref ident)) if ident.as_slice()
|
Ok(Token::Ident(ref ident)) if ident.eq_ignore_ascii_case("cover") => {
|
||||||
.eq_ignore_ascii_case("cover") => {
|
|
||||||
Ok(SpecifiedValue::Cover)
|
Ok(SpecifiedValue::Cover)
|
||||||
}
|
}
|
||||||
Ok(Token::Ident(ref ident)) if ident.as_slice()
|
Ok(Token::Ident(ref ident)) if ident.eq_ignore_ascii_case("contain") => {
|
||||||
.eq_ignore_ascii_case("contain") => {
|
|
||||||
Ok(SpecifiedValue::Contain)
|
Ok(SpecifiedValue::Contain)
|
||||||
}
|
}
|
||||||
Ok(_) => Err(()),
|
Ok(_) => Err(()),
|
||||||
|
|
|
@ -888,7 +888,7 @@ pub mod specified {
|
||||||
pub fn parse(input: &mut Parser) -> Result<Time,()> {
|
pub fn parse(input: &mut Parser) -> Result<Time,()> {
|
||||||
match input.next() {
|
match input.next() {
|
||||||
Ok(Token::Dimension(ref value, ref unit)) => {
|
Ok(Token::Dimension(ref value, ref unit)) => {
|
||||||
Time::parse_dimension(value.value, unit.as_slice())
|
Time::parse_dimension(value.value, &unit)
|
||||||
}
|
}
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use string_cache::{Atom, Namespace};
|
||||||
pub fn from_domstring(url: Option<DOMString>) -> Namespace {
|
pub fn from_domstring(url: Option<DOMString>) -> Namespace {
|
||||||
match url {
|
match url {
|
||||||
None => ns!(""),
|
None => ns!(""),
|
||||||
Some(ref s) => Namespace(Atom::from_slice(s.as_slice())),
|
Some(ref s) => Namespace(Atom::from_slice(s)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ pub struct Opts {
|
||||||
|
|
||||||
fn print_usage(app: &str, opts: &[getopts::OptGroup]) {
|
fn print_usage(app: &str, opts: &[getopts::OptGroup]) {
|
||||||
let message = format!("Usage: {} [ options ... ] [URL]\n\twhere options include", app);
|
let message = format!("Usage: {} [ options ... ] [URL]\n\twhere options include", app);
|
||||||
println!("{}", getopts::usage(message.as_slice(), opts));
|
println!("{}", getopts::usage(&message, opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_debug_usage(app: &str) {
|
pub fn print_debug_usage(app: &str) {
|
||||||
|
@ -262,16 +262,16 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
|
||||||
getopts::optflag("", "sniff-mime-types" , "Enable MIME sniffing"),
|
getopts::optflag("", "sniff-mime-types" , "Enable MIME sniffing"),
|
||||||
);
|
);
|
||||||
|
|
||||||
let opt_match = match getopts::getopts(args, opts.as_slice()) {
|
let opt_match = match getopts::getopts(args, &opts) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(f) => {
|
Err(f) => {
|
||||||
args_fail(f.to_string().as_slice());
|
args_fail(&f.to_string());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if opt_match.opt_present("h") || opt_match.opt_present("help") {
|
if opt_match.opt_present("h") || opt_match.opt_present("help") {
|
||||||
print_usage(app_name.as_slice(), opts.as_slice());
|
print_usage(&app_name, &opts);
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -280,16 +280,16 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
|
||||||
None => String::new()
|
None => String::new()
|
||||||
};
|
};
|
||||||
let mut debug_options = HashSet::new();
|
let mut debug_options = HashSet::new();
|
||||||
for split in debug_string.as_slice().split(',') {
|
for split in debug_string.split(',') {
|
||||||
debug_options.insert(split.clone());
|
debug_options.insert(split.clone());
|
||||||
}
|
}
|
||||||
if debug_options.contains(&"help") {
|
if debug_options.contains(&"help") {
|
||||||
print_debug_usage(app_name.as_slice());
|
print_debug_usage(&app_name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = if opt_match.free.is_empty() {
|
let url = if opt_match.free.is_empty() {
|
||||||
print_usage(app_name.as_slice(), opts.as_slice());
|
print_usage(&app_name, &opts);
|
||||||
args_fail("servo asks that you provide a URL");
|
args_fail("servo asks that you provide a URL");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -12,6 +12,7 @@ use std::borrow::ToOwned;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::iter::Filter;
|
use std::iter::Filter;
|
||||||
use std::num::{Int, ToPrimitive};
|
use std::num::{Int, ToPrimitive};
|
||||||
|
use std::ops::Deref;
|
||||||
use std::str::{from_utf8, FromStr, Split};
|
use std::str::{from_utf8, FromStr, Split};
|
||||||
|
|
||||||
pub type DOMString = String;
|
pub type DOMString = String;
|
||||||
|
@ -29,7 +30,7 @@ pub fn null_str_as_empty(s: &Option<DOMString>) -> DOMString {
|
||||||
|
|
||||||
pub fn null_str_as_empty_ref<'a>(s: &'a Option<DOMString>) -> &'a str {
|
pub fn null_str_as_empty_ref<'a>(s: &'a Option<DOMString>) -> &'a str {
|
||||||
match *s {
|
match *s {
|
||||||
Some(ref s) => s.as_slice(),
|
Some(ref s) => s,
|
||||||
None => ""
|
None => ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,7 +232,7 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA,()> {
|
||||||
new_input.push(ch)
|
new_input.push(ch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut input = new_input.as_slice();
|
let mut input = &*new_input;
|
||||||
|
|
||||||
// Step 8.
|
// Step 8.
|
||||||
for (char_count, (index, _)) in input.char_indices().enumerate() {
|
for (char_count, (index, _)) in input.char_indices().enumerate() {
|
||||||
|
@ -328,9 +329,11 @@ impl LowercaseString {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Str for LowercaseString {
|
impl Deref for LowercaseString {
|
||||||
|
type Target = str;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_slice(&self) -> &str {
|
fn deref(&self) -> &str {
|
||||||
&*self.inner
|
&*self.inner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue