diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-12-05 22:13:50 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-12-06 02:35:10 +0100 |
commit | af879523eabbdb72b672aab50da1f83bb782ed1e (patch) | |
tree | 4071fb814c411a6c2fd52192d0994bd4861af94d /components/gfx | |
parent | 37cd870a9e41fe6e6ba12e0622f2e2a935fda89a (diff) | |
download | servo-af879523eabbdb72b672aab50da1f83bb782ed1e.tar.gz servo-af879523eabbdb72b672aab50da1f83bb782ed1e.zip |
style: Make all keywords CamelCase for consistency.
This prevents confusion and paves the ground for derive(Parse) of them.
Diffstat (limited to 'components/gfx')
-rw-r--r-- | components/gfx/font.rs | 4 | ||||
-rw-r--r-- | components/gfx/font_context.rs | 13 | ||||
-rw-r--r-- | components/gfx/platform/freetype/font.rs | 15 | ||||
-rw-r--r-- | components/gfx/platform/macos/font.rs | 27 | ||||
-rw-r--r-- | components/gfx/platform/windows/font.rs | 57 |
5 files changed, 61 insertions, 55 deletions
diff --git a/components/gfx/font.rs b/components/gfx/font.rs index bfeedef5f07..b8ed41840a3 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -261,8 +261,8 @@ impl Font { #[inline] pub fn glyph_index(&self, codepoint: char) -> Option<GlyphId> { let codepoint = match self.variant { - font_variant_caps::T::small_caps => codepoint.to_uppercase().next().unwrap(), //FIXME: #5938 - font_variant_caps::T::normal => codepoint, + font_variant_caps::T::SmallCaps => codepoint.to_uppercase().next().unwrap(), //FIXME: #5938 + font_variant_caps::T::Normal => codepoint, }; self.handle.glyph_index(codepoint) } diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index 13c3d777579..d95318b8fde 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -20,7 +20,8 @@ use std::hash::{BuildHasherDefault, Hash, Hasher}; use std::rc::Rc; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; -use style::computed_values::{font_style, font_variant_caps}; +use style::computed_values::font_style::T as FontStyle; +use style::computed_values::font_variant_caps::T as FontVariantCaps; use style::properties::style_structs; use webrender_api; @@ -78,14 +79,14 @@ impl FontContext { template: Arc<FontTemplateData>, descriptor: FontTemplateDescriptor, pt_size: Au, - variant: font_variant_caps::T, + variant: FontVariantCaps, font_key: webrender_api::FontKey) -> Result<Font, ()> { // TODO: (Bug #3463): Currently we only support fake small-caps // painting. We should also support true small-caps (where the // font supports it) in the future. let actual_pt_size = match variant { - font_variant_caps::T::small_caps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR), - font_variant_caps::T::normal => pt_size, + FontVariantCaps::SmallCaps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR), + FontVariantCaps::Normal => pt_size, }; let handle = FontHandle::new_from_template(&self.platform_handle, @@ -130,8 +131,8 @@ impl FontContext { let desc = FontTemplateDescriptor::new(style.font_weight, style.font_stretch, - style.font_style == font_style::T::italic || - style.font_style == font_style::T::oblique); + style.font_style == FontStyle::Italic || + style.font_style == FontStyle::Oblique); let mut fonts: SmallVec<[Rc<RefCell<Font>>; 8]> = SmallVec::new(); diff --git a/components/gfx/platform/freetype/font.rs b/components/gfx/platform/freetype/font.rs index f77f77be494..112fc285b59 100644 --- a/components/gfx/platform/freetype/font.rs +++ b/components/gfx/platform/freetype/font.rs @@ -20,7 +20,8 @@ use platform::font_template::FontTemplateData; use std::{mem, ptr}; use std::os::raw::{c_char, c_long}; use std::sync::Arc; -use style::computed_values::{font_stretch, font_weight}; +use style::computed_values::font_stretch::T as FontStretch; +use style::computed_values::font_weight::T as FontWeight; use super::c_str_to_string; use text::glyph::GlyphId; use text::util::fixed_to_float; @@ -134,8 +135,8 @@ impl FontHandleMethods for FontHandle { fn is_italic(&self) -> bool { unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC as c_long != 0 } } - fn boldness(&self) -> font_weight::T { - let default_weight = font_weight::T::normal(); + fn boldness(&self) -> FontWeight { + let default_weight = FontWeight::normal(); if unsafe { (*self.face).style_flags & FT_STYLE_FLAG_BOLD as c_long == 0 } { default_weight } else { @@ -145,9 +146,9 @@ impl FontHandleMethods for FontHandle { if valid { let weight =(*os2).usWeightClass as i32; if weight < 10 { - font_weight::T::from_int(weight * 100).unwrap() + FontWeight::from_int(weight * 100).unwrap() } else if weight >= 100 && weight < 1000 { - font_weight::T::from_int(weight / 100 * 100).unwrap() + FontWeight::from_int(weight / 100 * 100).unwrap() } else { default_weight } @@ -157,9 +158,9 @@ impl FontHandleMethods for FontHandle { } } } - fn stretchiness(&self) -> font_stretch::T { + fn stretchiness(&self) -> FontStretch { // TODO(pcwalton): Implement this. - font_stretch::T::normal + FontStretch::Normal } fn glyph_index(&self, codepoint: char) -> Option<GlyphId> { diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs index aaaad7332ba..3ecef760a15 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/gfx/platform/macos/font.rs @@ -21,7 +21,8 @@ use platform::macos::font_context::FontContextHandle; use std::{fmt, ptr}; use std::ops::Range; use std::sync::Arc; -use style::computed_values::{font_stretch, font_weight}; +use style::computed_values::font_stretch::T as FontStretch; +use style::computed_values::font_weight::T as FontWeight; use text::glyph::GlyphId; const KERN_PAIR_LEN: usize = 6; @@ -210,29 +211,29 @@ impl FontHandleMethods for FontHandle { self.ctfont.symbolic_traits().is_italic() } - fn boldness(&self) -> font_weight::T { + fn boldness(&self) -> FontWeight { let normalized = self.ctfont.all_traits().normalized_weight(); // [-1.0, 1.0] let normalized = if normalized <= 0.0 { 4.0 + normalized * 3.0 // [1.0, 4.0] } else { 4.0 + normalized * 5.0 // [4.0, 9.0] }; // [1.0, 9.0], centered on 4.0 - font_weight::T::from_int(normalized.round() as i32 * 100).unwrap() + FontWeight::from_int(normalized.round() as i32 * 100).unwrap() } - fn stretchiness(&self) -> font_stretch::T { + fn stretchiness(&self) -> FontStretch { let normalized = self.ctfont.all_traits().normalized_width(); // [-1.0, 1.0] let normalized = (normalized + 1.0) / 2.0 * 9.0; // [0.0, 9.0] match normalized { - v if v < 1.0 => font_stretch::T::ultra_condensed, - v if v < 2.0 => font_stretch::T::extra_condensed, - v if v < 3.0 => font_stretch::T::condensed, - v if v < 4.0 => font_stretch::T::semi_condensed, - v if v < 5.0 => font_stretch::T::normal, - v if v < 6.0 => font_stretch::T::semi_expanded, - v if v < 7.0 => font_stretch::T::expanded, - v if v < 8.0 => font_stretch::T::extra_expanded, - _ => font_stretch::T::ultra_expanded, + v if v < 1.0 => FontStretch::UltraCondensed, + v if v < 2.0 => FontStretch::ExtraCondensed, + v if v < 3.0 => FontStretch::Condensed, + v if v < 4.0 => FontStretch::SemiCondensed, + v if v < 5.0 => FontStretch::Normal, + v if v < 6.0 => FontStretch::SemiExpanded, + v if v < 7.0 => FontStretch::Expanded, + v if v < 8.0 => FontStretch::ExtraExpanded, + _ => FontStretch::UltraExpanded, } } diff --git a/components/gfx/platform/windows/font.rs b/components/gfx/platform/windows/font.rs index 38a2e6e0db3..5a7433d26f7 100644 --- a/components/gfx/platform/windows/font.rs +++ b/components/gfx/platform/windows/font.rs @@ -16,7 +16,8 @@ use platform::font_template::FontTemplateData; use platform::windows::font_context::FontContextHandle; use platform::windows::font_list::font_from_atom; use std::sync::Arc; -use style::computed_values::{font_stretch, font_weight}; +use style::computed_values::font_stretch::T as StyleFontStretch; +use style::computed_values::font_weight::T as StyleFontWeight; use text::glyph::GlyphId; use truetype; @@ -94,8 +95,8 @@ fn get_family_face_indices(records: &[truetype::naming_table::Record]) -> Option struct FontInfo { family_name: String, face_name: String, - weight: font_weight::T, - stretch: font_stretch::T, + weight: StyleFontWeight, + stretch: StyleFontStretch, style: FontStyle, } @@ -155,19 +156,21 @@ impl FontInfo { }, }; - let weight = font_weight::T:: - from_int(min(9, max(1, weight_val as i32 / 100)) * 100).unwrap(); + let weight = + StyleFontWeight::from_int( + min(9, max(1, weight_val as i32 / 100)) * 100 + ).unwrap(); let stretch = match min(9, max(1, width_val)) { - 1 => font_stretch::T::ultra_condensed, - 2 => font_stretch::T::extra_condensed, - 3 => font_stretch::T::condensed, - 4 => font_stretch::T::semi_condensed, - 5 => font_stretch::T::normal, - 6 => font_stretch::T::semi_expanded, - 7 => font_stretch::T::expanded, - 8 => font_stretch::T::extra_expanded, - 9 => font_stretch::T::ultra_expanded, + 1 => StyleFontStretch::UltraCondensed, + 2 => StyleFontStretch::ExtraCondensed, + 3 => StyleFontStretch::Condensed, + 4 => StyleFontStretch::SemiCondensed, + 5 => StyleFontStretch::Normal, + 6 => StyleFontStretch::SemiExpanded, + 7 => StyleFontStretch::Expanded, + 8 => StyleFontStretch::ExtraExpanded, + 9 => StyleFontStretch::UltraExpanded, _ => return Err(()), }; @@ -188,7 +191,7 @@ impl FontInfo { fn new_from_font(font: &Font) -> Result<FontInfo, ()> { let style = font.style(); - let weight = font_weight::T(match font.weight() { + let weight = StyleFontWeight(match font.weight() { FontWeight::Thin => 100, FontWeight::ExtraLight => 200, FontWeight::Light => 300, @@ -204,16 +207,16 @@ impl FontInfo { FontWeight::ExtraBlack => 900, }); let stretch = match font.stretch() { - FontStretch::Undefined => font_stretch::T::normal, - FontStretch::UltraCondensed => font_stretch::T::ultra_condensed, - FontStretch::ExtraCondensed => font_stretch::T::extra_condensed, - FontStretch::Condensed => font_stretch::T::condensed, - FontStretch::SemiCondensed => font_stretch::T::semi_condensed, - FontStretch::Normal => font_stretch::T::normal, - FontStretch::SemiExpanded => font_stretch::T::semi_expanded, - FontStretch::Expanded => font_stretch::T::expanded, - FontStretch::ExtraExpanded => font_stretch::T::extra_expanded, - FontStretch::UltraExpanded => font_stretch::T::ultra_expanded, + FontStretch::Undefined => StyleFontStretch::Normal, + FontStretch::UltraCondensed => StyleFontStretch::UltraCondensed, + FontStretch::ExtraCondensed => StyleFontStretch::ExtraCondensed, + FontStretch::Condensed => StyleFontStretch::Condensed, + FontStretch::SemiCondensed => StyleFontStretch::SemiCondensed, + FontStretch::Normal => StyleFontStretch::Normal, + FontStretch::SemiExpanded => StyleFontStretch::SemiExpanded, + FontStretch::Expanded => StyleFontStretch::Expanded, + FontStretch::ExtraExpanded => StyleFontStretch::ExtraExpanded, + FontStretch::UltraExpanded => StyleFontStretch::UltraExpanded, }; Ok(FontInfo { @@ -300,11 +303,11 @@ impl FontHandleMethods for FontHandle { } } - fn boldness(&self) -> font_weight::T { + fn boldness(&self) -> StyleFontWeight { self.info.weight } - fn stretchiness(&self) -> font_stretch::T { + fn stretchiness(&self) -> StyleFontStretch { self.info.stretch } |