Auto merge of #9013 - antrik:debug-fontgroup, r=Ms2ger

Derive Debug for FontGroup and Homu is a bully

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9013)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-12-18 14:23:15 +05:30
commit 6490d1e1c5
10 changed files with 20 additions and 9 deletions

View file

@ -89,6 +89,7 @@ pub struct FontMetrics {
pub type SpecifiedFontStyle = FontStyle; pub type SpecifiedFontStyle = FontStyle;
#[derive(Debug)]
pub struct Font { pub struct Font {
pub handle: FontHandle, pub handle: FontHandle,
pub metrics: FontMetrics, pub metrics: FontMetrics,
@ -115,7 +116,7 @@ bitflags! {
} }
/// Various options that control text shaping. /// Various options that control text shaping.
#[derive(Clone, Eq, PartialEq, Hash, Copy)] #[derive(Clone, Eq, PartialEq, Hash, Copy, Debug)]
pub struct ShapingOptions { pub struct ShapingOptions {
/// Spacing to add between each letter. Corresponds to the CSS 2.1 `letter-spacing` property. /// Spacing to add between each letter. Corresponds to the CSS 2.1 `letter-spacing` property.
/// NB: You will probably want to set the `IGNORE_LIGATURES_SHAPING_FLAG` if this is non-null. /// NB: You will probably want to set the `IGNORE_LIGATURES_SHAPING_FLAG` if this is non-null.
@ -129,7 +130,7 @@ pub struct ShapingOptions {
} }
/// An entry in the shape cache. /// An entry in the shape cache.
#[derive(Clone, Eq, PartialEq, Hash)] #[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct ShapeCacheEntry { pub struct ShapeCacheEntry {
text: String, text: String,
options: ShapingOptions, options: ShapingOptions,
@ -217,6 +218,7 @@ impl Font {
} }
} }
#[derive(Debug)]
pub struct FontGroup { pub struct FontGroup {
pub fonts: SmallVec<[Rc<RefCell<Font>>; 8]>, pub fonts: SmallVec<[Rc<RefCell<Font>>; 8]>,
} }

View file

@ -14,7 +14,7 @@ use style::computed_values::{font_stretch, font_weight};
/// to be expanded or refactored when we support more of the font styling parameters. /// to be expanded or refactored when we support more of the font styling parameters.
/// ///
/// NB: If you change this, you will need to update `style::properties::compute_font_hash()`. /// NB: If you change this, you will need to update `style::properties::compute_font_hash()`.
#[derive(Clone, Copy, Eq, Hash, Deserialize, Serialize)] #[derive(Clone, Copy, Eq, Hash, Deserialize, Serialize, Debug)]
pub struct FontTemplateDescriptor { pub struct FontTemplateDescriptor {
pub weight: font_weight::T, pub weight: font_weight::T,
pub stretch: font_stretch::T, pub stretch: font_stretch::T,

View file

@ -45,6 +45,7 @@ impl FontTableMethods for FontTable {
} }
} }
#[derive(Debug)]
pub struct FontHandle { pub struct FontHandle {
// The font binary. This must stay valid for the lifetime of the font, // The font binary. This must stay valid for the lifetime of the font,
// if the font is created using FT_Memory_Face. // if the font is created using FT_Memory_Face.

View file

@ -70,7 +70,7 @@ pub type UserPtr = *mut User;
// WARNING: We need to be careful how we use this struct. See the comment about Rc<> in // WARNING: We need to be careful how we use this struct. See the comment about Rc<> in
// FontContextHandle. // FontContextHandle.
#[derive(Clone)] #[derive(Clone, Debug)]
pub struct FreeTypeLibraryHandle { pub struct FreeTypeLibraryHandle {
pub ctx: FT_Library, pub ctx: FT_Library,
mem: FT_Memory, mem: FT_Memory,
@ -98,7 +98,7 @@ impl HeapSizeOf for FreeTypeLibraryHandle {
} }
} }
#[derive(Clone, HeapSizeOf)] #[derive(Clone, HeapSizeOf, Debug)]
pub struct FontContextHandle { pub struct FontContextHandle {
// WARNING: FreeTypeLibraryHandle contains raw pointers, is clonable, and also implements // WARNING: FreeTypeLibraryHandle contains raw pointers, is clonable, and also implements
// `Drop`. This field needs to be Rc<> to make sure that the `drop` function is only called // `Drop`. This field needs to be Rc<> to make sure that the `drop` function is only called

View file

@ -10,7 +10,7 @@ use string_cache::Atom;
/// The identifier is an absolute path, and the bytes /// The identifier is an absolute path, and the bytes
/// field is the loaded data that can be passed to /// field is the loaded data that can be passed to
/// freetype and azure directly. /// freetype and azure directly.
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize, Debug)]
pub struct FontTemplateData { pub struct FontTemplateData {
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
pub identifier: Atom, pub identifier: Atom,

View file

@ -57,6 +57,7 @@ impl FontTableMethods for FontTable {
} }
} }
#[derive(Debug)]
pub struct FontHandle { pub struct FontHandle {
pub font_data: Arc<FontTemplateData>, pub font_data: Arc<FontTemplateData>,
pub ctfont: CTFont, pub ctfont: CTFont,

View file

@ -4,7 +4,7 @@
use util::mem::HeapSizeOf; use util::mem::HeapSizeOf;
#[derive(Clone)] #[derive(Clone, Debug)]
pub struct FontContextHandle { pub struct FontContextHandle {
ctx: () ctx: ()
} }

View file

@ -17,7 +17,7 @@ use string_cache::Atom;
/// The identifier is a PostScript font name. The /// The identifier is a PostScript font name. The
/// CTFont object is cached here for use by the /// CTFont object is cached here for use by the
/// paint functions that create CGFont references. /// paint functions that create CGFont references.
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize, Debug)]
pub struct FontTemplateData { pub struct FontTemplateData {
/// The `CTFont` object, if present. This is cached here so that we don't have to keep creating /// The `CTFont` object, if present. This is cached here so that we don't have to keep creating
/// `CTFont` instances over and over. It can always be recreated from the `identifier` and/or /// `CTFont` instances over and over. It can always be recreated from the `identifier` and/or
@ -64,6 +64,7 @@ impl FontTemplateData {
} }
} }
#[derive(Debug)]
pub struct CachedCTFont(Mutex<Option<CTFont>>); pub struct CachedCTFont(Mutex<Option<CTFont>>);
impl Deref for CachedCTFont { impl Deref for CachedCTFont {

View file

@ -134,11 +134,13 @@ impl ShapedGlyphData {
} }
} }
#[derive(Debug)]
struct FontAndShapingOptions { struct FontAndShapingOptions {
font: *mut Font, font: *mut Font,
options: ShapingOptions, options: ShapingOptions,
} }
#[derive(Debug)]
pub struct Shaper { pub struct Shaper {
hb_face: *mut hb_face_t, hb_face: *mut hb_face_t,
hb_font: *mut hb_font_t, hb_font: *mut hb_font_t,

View file

@ -12,7 +12,11 @@ use std::hash::{Hash, Hasher, SipHasher};
use std::slice::Iter; use std::slice::Iter;
pub struct HashCache<K, V> { #[derive(Debug)]
pub struct HashCache<K, V>
where K: Clone + PartialEq + Eq + Hash,
V: Clone,
{
entries: HashMap<K, V, DefaultState<SipHasher>>, entries: HashMap<K, V, DefaultState<SipHasher>>,
} }