aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-06-05 06:57:18 -0500
committerbors-servo <lbergstrom+bors@mozilla.com>2016-06-05 06:57:18 -0500
commitd768ee5d4c2ef0429e88191f01f977338c964359 (patch)
tree32cfbe0f5b4bc8410679901986f69acc66d27935
parent573c0a74684dc0043da4800a84065d72453641fd (diff)
parentdb5ddb561cb821ac89c8cc1002cdbddfd98400fa (diff)
downloadservo-d768ee5d4c2ef0429e88191f01f977338c964359.tar.gz
servo-d768ee5d4c2ef0429e88191f01f977338c964359.zip
Auto merge of #11619 - Ms2ger:freetype, r=nox
Some cleanup in gfx. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11619) <!-- Reviewable:end -->
-rw-r--r--components/gfx/lib.rs3
-rw-r--r--components/gfx/platform/freetype/font.rs2
-rw-r--r--components/gfx/platform/freetype/font_list.rs10
-rw-r--r--components/gfx/platform/mod.rs14
-rw-r--r--components/gfx/text/glyph.rs1
-rw-r--r--components/gfx/text/mod.rs6
-rw-r--r--components/gfx/text/shaping/harfbuzz.rs2
-rw-r--r--components/util/str.rs11
8 files changed, 22 insertions, 27 deletions
diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs
index e3f3f1d438f..58c92f304d9 100644
--- a/components/gfx/lib.rs
+++ b/components/gfx/lib.rs
@@ -104,8 +104,7 @@ pub mod paint_thread;
// Platform-specific implementations.
#[allow(unsafe_code)]
-pub mod platform;
+mod platform;
// Text
-#[allow(unsafe_code)]
pub mod text;
diff --git a/components/gfx/platform/freetype/font.rs b/components/gfx/platform/freetype/font.rs
index 7bc26800df0..a51741a6b87 100644
--- a/components/gfx/platform/freetype/font.rs
+++ b/components/gfx/platform/freetype/font.rs
@@ -23,9 +23,9 @@ use platform::font_template::FontTemplateData;
use std::sync::Arc;
use std::{mem, ptr};
use style::computed_values::{font_stretch, font_weight};
+use super::c_str_to_string;
use text::glyph::GlyphId;
use text::util::{fixed_to_float, float_to_fixed};
-use util::str::c_str_to_string;
fn float_to_fixed_ft(f: f64) -> i32 {
float_to_fixed(6, f)
diff --git a/components/gfx/platform/freetype/font_list.rs b/components/gfx/platform/freetype/font_list.rs
index ef89adeffd1..eaf909dce90 100644
--- a/components/gfx/platform/freetype/font_list.rs
+++ b/components/gfx/platform/freetype/font_list.rs
@@ -2,8 +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/. */
-#![allow(non_snake_case)]
-
extern crate fontconfig;
extern crate freetype;
@@ -18,7 +16,7 @@ use libc::{c_char, c_int};
use std::borrow::ToOwned;
use std::ffi::CString;
use std::ptr;
-use util::str::c_str_to_string;
+use super::c_str_to_string;
static FC_FAMILY: &'static [u8] = b"family\0";
static FC_FILE: &'static [u8] = b"file\0";
@@ -28,9 +26,9 @@ static FC_FONTFORMAT: &'static [u8] = b"fontformat\0";
pub fn for_each_available_family<F>(mut callback: F) where F: FnMut(String) {
unsafe {
let config = FcConfigGetCurrent();
- let fontSet = FcConfigGetFonts(config, FcSetSystem);
- for i in 0..((*fontSet).nfont as isize) {
- let font = (*fontSet).fonts.offset(i);
+ let font_set = FcConfigGetFonts(config, FcSetSystem);
+ for i in 0..((*font_set).nfont as isize) {
+ let font = (*font_set).fonts.offset(i);
let mut family: *mut FcChar8 = ptr::null_mut();
let mut format: *mut FcChar8 = ptr::null_mut();
let mut v: c_int = 0;
diff --git a/components/gfx/platform/mod.rs b/components/gfx/platform/mod.rs
index 729448c2586..fed55781486 100644
--- a/components/gfx/platform/mod.rs
+++ b/components/gfx/platform/mod.rs
@@ -9,7 +9,17 @@ pub use platform::freetype::{font, font_context, font_list, font_template};
pub use platform::macos::{font, font_context, font_list, font_template};
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
-pub mod freetype {
+mod freetype {
+ use libc::c_char;
+ use std::ffi::CStr;
+ use std::str;
+
+ /// Creates a String from the given null-terminated buffer.
+ /// Panics if the buffer does not contain UTF-8.
+ unsafe fn c_str_to_string(s: *const c_char) -> String {
+ str::from_utf8(CStr::from_ptr(s).to_bytes()).unwrap().to_owned()
+ }
+
pub mod font;
pub mod font_context;
pub mod font_list;
@@ -17,7 +27,7 @@ pub mod freetype {
}
#[cfg(target_os = "macos")]
-pub mod macos {
+mod macos {
pub mod font;
pub mod font_context;
pub mod font_list;
diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs
index a41202eb3a2..fe9dc415625 100644
--- a/components/gfx/text/glyph.rs
+++ b/components/gfx/text/glyph.rs
@@ -627,6 +627,7 @@ impl<'a> GlyphStore {
/// Used for SIMD.
#[inline]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
+ #[allow(unsafe_code)]
fn transmute_entry_buffer_to_u32_buffer(&self) -> &[u32] {
unsafe { mem::transmute(self.entry_buffer.as_slice()) }
}
diff --git a/components/gfx/text/mod.rs b/components/gfx/text/mod.rs
index 9afab389389..5aae0876428 100644
--- a/components/gfx/text/mod.rs
+++ b/components/gfx/text/mod.rs
@@ -2,12 +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/. */
-/* This file exists just to make it easier to import things inside of
- ./text/ without specifying the file they came out of imports.
-
-Note that you still must define each of the files as a module in
-servo.rc. This is not ideal and may be changed in the future. */
-
pub use text::shaping::Shaper;
pub use text::text_run::TextRun;
diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs
index 5e6b025e21c..5106418be61 100644
--- a/components/gfx/text/shaping/harfbuzz.rs
+++ b/components/gfx/text/shaping/harfbuzz.rs
@@ -2,6 +2,8 @@
* 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/. */
+#![allow(unsafe_code)]
+
use app_units::Au;
use euclid::Point2D;
use font::{DISABLE_KERNING_SHAPING_FLAG, Font, FontTableMethods, FontTableTag};
diff --git a/components/util/str.rs b/components/util/str.rs
index 7af63f4c7f3..7df67e1b421 100644
--- a/components/util/str.rs
+++ b/components/util/str.rs
@@ -3,14 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
-use libc::c_char;
use num_traits::ToPrimitive;
-use std::borrow::ToOwned;
use std::convert::AsRef;
-use std::ffi::CStr;
use std::iter::{Filter, Peekable};
use std::ops::Deref;
-use std::str::{Split, from_utf8};
+use std::str::Split;
pub type StaticCharVec = &'static [char];
pub type StaticStringVec = &'static [&'static str];
@@ -150,12 +147,6 @@ impl Deref for LowercaseString {
}
}
-/// Creates a String from the given null-terminated buffer.
-/// Panics if the buffer does not contain UTF-8.
-pub unsafe fn c_str_to_string(s: *const c_char) -> String {
- from_utf8(CStr::from_ptr(s).to_bytes()).unwrap().to_owned()
-}
-
pub fn str_join<I, T>(strs: I, join: &str) -> String
where I: IntoIterator<Item=T>, T: AsRef<str>,
{