diff options
author | Matt Brubeck <mbrubeck@limpet.net> | 2015-07-14 14:32:45 -0700 |
---|---|---|
committer | Matt Brubeck <mbrubeck@limpet.net> | 2015-07-14 14:32:45 -0700 |
commit | e0d98acabc2a67a56e4cf05e75419ca13a741dab (patch) | |
tree | 7a9862190d4cd44943de5a8d0ba37fb738d1416b | |
parent | 7de4ba0f826f8239d6ac540417028265e62085c5 (diff) | |
download | servo-e0d98acabc2a67a56e4cf05e75419ca13a741dab.tar.gz servo-e0d98acabc2a67a56e4cf05e75419ca13a741dab.zip |
Remove dead code from gfx/text
-rw-r--r-- | components/gfx/font.rs | 1 | ||||
-rw-r--r-- | components/gfx/text/glyph.rs | 9 | ||||
-rw-r--r-- | components/gfx/text/mod.rs | 2 | ||||
-rw-r--r-- | components/gfx/text/text_run.rs | 74 | ||||
-rw-r--r-- | components/gfx/text/util.rs | 9 |
5 files changed, 4 insertions, 91 deletions
diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 824523be4bd..27f872ba11f 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -86,7 +86,6 @@ pub struct FontMetrics { } pub type SpecifiedFontStyle = FontStyle; -pub type UsedFontStyle = FontStyle; pub struct Font { pub handle: FontHandle, diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index 108a29a2b19..d1dc0b8297e 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -523,8 +523,9 @@ int_range_index! { } impl<'a> GlyphStore { - // Initializes the glyph store, but doesn't actually shape anything. - // Use the set_glyph, set_glyphs() methods to store glyph data. + /// Initializes the glyph store, but doesn't actually shape anything. + /// + /// Use the `add_*` methods to store glyph data. pub fn new(length: usize, is_whitespace: bool) -> GlyphStore { assert!(length > 0); @@ -621,10 +622,6 @@ impl<'a> GlyphStore { self.entry_buffer[i.to_usize()] = entry; } - pub fn iter_glyphs_for_char_index(&'a self, i: CharIndex) -> GlyphIterator<'a> { - self.iter_glyphs_for_char_range(&Range::new(i, CharIndex(1))) - } - #[inline] pub fn iter_glyphs_for_char_range(&'a self, rang: &Range<CharIndex>) -> GlyphIterator<'a> { if rang.begin() >= self.char_len() { diff --git a/components/gfx/text/mod.rs b/components/gfx/text/mod.rs index f705347c441..9afab389389 100644 --- a/components/gfx/text/mod.rs +++ b/components/gfx/text/mod.rs @@ -12,7 +12,7 @@ pub use text::shaping::Shaper; pub use text::text_run::TextRun; pub mod glyph; -#[path="shaping/mod.rs"] pub mod shaping; +pub mod shaping; pub mod text_run; pub mod util; diff --git a/components/gfx/text/text_run.rs b/components/gfx/text/text_run.rs index 35ffeef7caf..a9bf0b409f5 100644 --- a/components/gfx/text/text_run.rs +++ b/components/gfx/text/text_run.rs @@ -139,52 +139,6 @@ impl<'a> Iterator for CharacterSliceIterator<'a> { } } -pub struct LineIterator<'a> { - range: Range<CharIndex>, - clump: Option<Range<CharIndex>>, - slices: NaturalWordSliceIterator<'a>, -} - -impl<'a> Iterator for LineIterator<'a> { - type Item = Range<CharIndex>; - - fn next(&mut self) -> Option<Range<CharIndex>> { - // Loop until we hit whitespace and are in a clump. - loop { - match self.slices.next() { - Some(slice) => { - match (slice.glyphs.is_whitespace(), self.clump) { - (false, Some(ref mut c)) => { - c.extend_by(slice.range.length()); - } - (false, None) => { - let mut range = slice.range; - range.shift_by(slice.offset); - self.clump = Some(range); - } - (true, None) => { /* chomp whitespace */ } - (true, Some(clump)) => { - self.clump = None; - // The final whitespace clump is not included. - return Some(clump); - } - } - } - None => { - // Flush any remaining characters as a line. - if self.clump.is_some() { - let mut range = self.clump.take().unwrap(); - range.extend_to(self.range.end()); - return Some(range); - } else { - return None; - } - } - } - } - } -} - impl<'a> TextRun { pub fn new(font: &mut Font, text: String, options: &ShapingOptions) -> TextRun { let glyphs = TextRun::break_and_shape(font, &text, options); @@ -273,21 +227,6 @@ impl<'a> TextRun { glyphs } - pub fn char_len(&self) -> CharIndex { - match self.glyphs.last() { - None => CharIndex(0), - Some(ref glyph_run) => glyph_run.range.end(), - } - } - - pub fn glyphs(&'a self) -> &'a Vec<GlyphRun> { - &*self.glyphs - } - - pub fn range_is_trimmable_whitespace(&self, range: &Range<CharIndex>) -> bool { - self.natural_word_slices_in_range(range).all(|slice| slice.glyphs.is_whitespace()) - } - pub fn ascent(&self) -> Au { self.font_metrics.ascent } @@ -326,11 +265,6 @@ impl<'a> TextRun { }) } - /// Returns the first glyph run containing the given character index. - pub fn first_glyph_run_containing(&'a self, index: CharIndex) -> Option<&'a GlyphRun> { - self.index_of_first_glyph_run_containing(index).map(|index| &self.glyphs[index]) - } - /// Returns the index of the first glyph run containing the given character index. fn index_of_first_glyph_run_containing(&self, index: CharIndex) -> Option<usize> { (&**self.glyphs).binary_search_index_by(&index, CharIndexComparator) @@ -366,12 +300,4 @@ impl<'a> TextRun { range: *range, } } - - pub fn iter_natural_lines_for_range(&'a self, range: &Range<CharIndex>) -> LineIterator<'a> { - LineIterator { - range: *range, - clump: None, - slices: self.natural_word_slices_in_range(range), - } - } } diff --git a/components/gfx/text/util.rs b/components/gfx/text/util.rs index 60223ff7a73..59f3010c87d 100644 --- a/components/gfx/text/util.rs +++ b/components/gfx/text/util.rs @@ -105,12 +105,3 @@ pub fn float_to_fixed(before: usize, f: f64) -> i32 { pub fn fixed_to_float(before: usize, f: i32) -> f64 { f as f64 * 1.0f64 / ((1i32 << before) as f64) } - -pub fn fixed_to_rounded_int(before: isize, f: i32) -> isize { - let half = 1i32 << (before-1) as usize; - if f > 0i32 { - ((half + f) >> before) as isize - } else { - -((half - f) >> before as usize) as isize - } -} |