servo: Merge #6626 - Remove dead code from gfx/text (from mbrubeck:gfx-dead); r=glennw

r? @pcwalton

Source-Repo: https://github.com/servo/servo
Source-Revision: 27d7f942547fa2091828d358c239dd9a2ed08885
This commit is contained in:
Matt Brubeck 2015-07-14 09:40:52 -06:00
Родитель 31494292e3
Коммит 3a30805259
5 изменённых файлов: 4 добавлений и 91 удалений

Просмотреть файл

@ -86,7 +86,6 @@ pub struct FontMetrics {
}
pub type SpecifiedFontStyle = FontStyle;
pub type UsedFontStyle = FontStyle;
pub struct Font {
pub handle: FontHandle,

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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;

Просмотреть файл

@ -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),
}
}
}

Просмотреть файл

@ -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
}
}