aboutsummaryrefslogtreecommitdiffstats
path: root/components/gfx
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2015-04-24 17:40:22 +0200
committerMs2ger <ms2ger@gmail.com>2015-04-24 17:44:47 +0200
commit6a55ae06d75e6997b54b56e006b0ba8a5dfb1fc6 (patch)
tree857a782c74937a216305a13eff73607a591bd196 /components/gfx
parent4ee89363fb6d538e28dd9375e69580d139ddacea (diff)
downloadservo-6a55ae06d75e6997b54b56e006b0ba8a5dfb1fc6.tar.gz
servo-6a55ae06d75e6997b54b56e006b0ba8a5dfb1fc6.zip
Remove some as_slice calls.
Diffstat (limited to 'components/gfx')
-rw-r--r--components/gfx/buffer_map.rs2
-rw-r--r--components/gfx/font_cache_task.rs25
-rw-r--r--components/gfx/font_context.rs2
-rw-r--r--components/gfx/font_template.rs2
-rw-r--r--components/gfx/paint_context.rs4
-rw-r--r--components/gfx/platform/macos/font_list.rs2
-rw-r--r--components/gfx/platform/macos/font_template.rs4
-rw-r--r--components/gfx/text/glyph.rs4
8 files changed, 22 insertions, 23 deletions
diff --git a/components/gfx/buffer_map.rs b/components/gfx/buffer_map.rs
index 01070851d88..e0cf4d22682 100644
--- a/components/gfx/buffer_map.rs
+++ b/components/gfx/buffer_map.rs
@@ -32,7 +32,7 @@ struct BufferKey([usize; 2]);
impl Hash for BufferKey {
fn hash<H: Hasher>(&self, state: &mut H) {
let BufferKey(ref bytes) = *self;
- bytes.as_slice().hash(state);
+ bytes.hash(state);
}
}
diff --git a/components/gfx/font_cache_task.rs b/components/gfx/font_cache_task.rs
index b3332e2a2e4..24e36ba3163 100644
--- a/components/gfx/font_cache_task.rs
+++ b/components/gfx/font_cache_task.rs
@@ -8,7 +8,6 @@ use platform::font_list::get_variations_for_family;
use platform::font_list::get_last_resort_font_families;
use platform::font_context::FontContextHandle;
-use collections::str::Str;
use font_template::{FontTemplate, FontTemplateDescriptor};
use net_traits::{ResourceTask, load_whole_resource};
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) {
let opt_system_default = get_system_default_family(generic_name);
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),
};
generic_fonts.insert(LowercaseString::new(generic_name), family_name);
@@ -119,7 +118,7 @@ impl FontCache {
match msg {
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);
result.send(Reply::GetFontTemplateReply(maybe_font_template)).unwrap();
}
@@ -128,7 +127,7 @@ impl FontCache {
result.send(Reply::GetFontTemplateReply(Some(font_template))).unwrap();
}
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) {
let family = FontFamily::new();
self.web_families.insert(family_name.clone(), family);
@@ -141,7 +140,7 @@ impl FontCache {
match maybe_resource {
Ok((_, bytes)) => {
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(_) => {
debug!("Failed to load web font: family={:?} url={}", family_name, url);
@@ -150,8 +149,8 @@ impl FontCache {
}
Source::Local(ref local_family_name) => {
let family = &mut self.web_families[family_name];
- get_variations_for_family(local_family_name.as_slice(), |path| {
- family.add_template(path.as_slice(), None);
+ get_variations_for_family(&local_family_name, |path| {
+ family.add_template(&path, None);
});
}
}
@@ -168,7 +167,7 @@ impl FontCache {
fn refresh_local_families(&mut self) {
self.local_families.clear();
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) {
let family = FontFamily::new();
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
// look up canonical 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];
if s.templates.len() == 0 {
- get_variations_for_family(family_name.as_slice(), |path| {
- s.add_template(path.as_slice(), None);
+ get_variations_for_family(&family_name, |path| {
+ s.add_template(&path, None);
});
}
@@ -206,7 +205,7 @@ impl FontCache {
None
} 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
}
}
@@ -237,7 +236,7 @@ impl FontCache {
let last_resort = get_last_resort_font_families();
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);
if maybe_font_in_family.is_some() {
return maybe_font_in_family.unwrap();
diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs
index 860bb62b375..534c844cb87 100644
--- a/components/gfx/font_context.rs
+++ b/components/gfx/font_context.rs
@@ -164,7 +164,7 @@ impl FontContext {
// GWTODO: Check on real pages if this is faster as Vec() or HashMap().
let mut cache_hit = false;
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 {
None => {
cache_hit = true;
diff --git a/components/gfx/font_template.rs b/components/gfx/font_template.rs
index 50cf8c57fee..e30eff4bd33 100644
--- a/components/gfx/font_template.rs
+++ b/components/gfx/font_template.rs
@@ -158,7 +158,7 @@ impl FontTemplate {
}
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());
template_data
}
diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs
index 93c7604c3d9..1af8b8f695d 100644
--- a/components/gfx/paint_context.rs
+++ b/components/gfx/paint_context.rs
@@ -133,8 +133,8 @@ impl<'a> PaintContext<'a> {
image_rendering: image_rendering::T) {
let size = Size2D(image.width as i32, image.height as i32);
let (pixel_width, pixels, source_format) = match image.pixels {
- PixelsByColorType::RGBA8(ref pixels) => (4, pixels.as_slice(), SurfaceFormat::B8G8R8A8),
- PixelsByColorType::K8(ref pixels) => (1, pixels.as_slice(), SurfaceFormat::A8),
+ PixelsByColorType::RGBA8(ref pixels) => (4, pixels, SurfaceFormat::B8G8R8A8),
+ PixelsByColorType::K8(ref pixels) => (1, pixels, SurfaceFormat::A8),
PixelsByColorType::RGB8(_) => panic!("RGB8 color type not supported"),
PixelsByColorType::KA8(_) => panic!("KA8 color type not supported"),
};
diff --git a/components/gfx/platform/macos/font_list.rs b/components/gfx/platform/macos/font_list.rs
index 4e327cea1b8..d5d221f375e 100644
--- a/components/gfx/platform/macos/font_list.rs
+++ b/components/gfx/platform/macos/font_list.rs
@@ -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);
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 {
Some(family_collection) => {
let family_descriptors = family_collection.get_descriptors();
diff --git a/components/gfx/platform/macos/font_template.rs b/components/gfx/platform/macos/font_template.rs
index 02865733990..a4cda3b5a66 100644
--- a/components/gfx/platform/macos/font_template.rs
+++ b/components/gfx/platform/macos/font_template.rs
@@ -26,7 +26,7 @@ impl FontTemplateData {
pub fn new(identifier: &str, font_data: Option<Vec<u8>>) -> FontTemplateData {
let ctfont = match font_data {
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);
match cgfont_result {
Ok(cgfont) => Some(core_text::font::new_from_CGFont(&cgfont, 0.0)),
@@ -34,7 +34,7 @@ impl FontTemplateData {
}
},
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())
}
};
diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs
index 23e9664fd9f..ba60e67e9a1 100644
--- a/components/gfx/text/glyph.rs
+++ b/components/gfx/text/glyph.rs
@@ -359,7 +359,7 @@ impl<'a> DetailedGlyphStore {
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!");
assert!(i + (count as usize) <= self.detail_buffer.len());
@@ -379,7 +379,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 + (detail_offset as usize) < self.detail_buffer.len());