mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Stop using deprecated str::char_*
methods
Fixes deprecation warnings in the gfx crate.
This commit is contained in:
parent
7e67bb788c
commit
83feda3ac2
3 changed files with 15 additions and 23 deletions
|
@ -12,7 +12,6 @@
|
||||||
#![feature(mpsc_select)]
|
#![feature(mpsc_select)]
|
||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
#![feature(range_contains)]
|
#![feature(range_contains)]
|
||||||
#![feature(str_char)]
|
|
||||||
#![feature(unique)]
|
#![feature(unique)]
|
||||||
|
|
||||||
#![plugin(heapsize_plugin)]
|
#![plugin(heapsize_plugin)]
|
||||||
|
|
|
@ -311,11 +311,12 @@ impl Shaper {
|
||||||
debug!("{}: {:?} --> {}", i, ch, byte_to_glyph[i]);
|
debug!("{}: {:?} --> {}", i, ch, byte_to_glyph[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// some helpers
|
|
||||||
let mut glyph_span = 0..0;
|
let mut glyph_span = 0..0;
|
||||||
// this span contains first byte of first char, to last byte of last char in range.
|
|
||||||
// so, end() points to first byte of last+1 char, if it's less than byte_max.
|
// This span contains first byte of first char, to last byte of last char in range.
|
||||||
let mut char_byte_span = 0..0;
|
// So, char_byte_span.end points to first byte of last+1 char, if it's less than byte_max.
|
||||||
|
let mut char_byte_span;
|
||||||
|
|
||||||
let mut y_pos = Au(0);
|
let mut y_pos = Au(0);
|
||||||
|
|
||||||
// main loop over each glyph. each iteration usually processes 1 glyph and 1+ chars.
|
// main loop over each glyph. each iteration usually processes 1 glyph and 1+ chars.
|
||||||
|
@ -333,8 +334,8 @@ impl Shaper {
|
||||||
// find a range of chars corresponding to this glyph, plus
|
// find a range of chars corresponding to this glyph, plus
|
||||||
// any trailing chars that do not have associated glyphs.
|
// any trailing chars that do not have associated glyphs.
|
||||||
while char_byte_span.end < byte_max {
|
while char_byte_span.end < byte_max {
|
||||||
let range = text.char_range_at(char_byte_span.end);
|
let ch = text[char_byte_span.end..].chars().next().unwrap();
|
||||||
char_byte_span.end = range.next;
|
char_byte_span.end += ch.len_utf8();
|
||||||
|
|
||||||
debug!("Processing char byte span: off={}, len={} for glyph idx={}",
|
debug!("Processing char byte span: off={}, len={} for glyph idx={}",
|
||||||
char_byte_span.start, char_byte_span.len(), glyph_span.start);
|
char_byte_span.start, char_byte_span.len(), glyph_span.start);
|
||||||
|
@ -343,8 +344,8 @@ impl Shaper {
|
||||||
byte_to_glyph[char_byte_span.end] == NO_GLYPH {
|
byte_to_glyph[char_byte_span.end] == NO_GLYPH {
|
||||||
debug!("Extending char byte span to include byte offset={} with no associated \
|
debug!("Extending char byte span to include byte offset={} with no associated \
|
||||||
glyph", char_byte_span.end);
|
glyph", char_byte_span.end);
|
||||||
let range = text.char_range_at(char_byte_span.end);
|
let ch = text[char_byte_span.end..].chars().next().unwrap();
|
||||||
char_byte_span.end = range.next;
|
char_byte_span.end += ch.len_utf8();
|
||||||
glyph_spans_multiple_characters = true;
|
glyph_spans_multiple_characters = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,9 +414,8 @@ impl Shaper {
|
||||||
// extend, clipping at end of text range.
|
// extend, clipping at end of text range.
|
||||||
while covered_byte_span.end < byte_max &&
|
while covered_byte_span.end < byte_max &&
|
||||||
byte_to_glyph[covered_byte_span.end] == NO_GLYPH {
|
byte_to_glyph[covered_byte_span.end] == NO_GLYPH {
|
||||||
let range = text.char_range_at(covered_byte_span.end);
|
let ch = text[covered_byte_span.end..].chars().next().unwrap();
|
||||||
drop(range.ch);
|
covered_byte_span.end += ch.len_utf8();
|
||||||
covered_byte_span.end = range.next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if covered_byte_span.start >= byte_max {
|
if covered_byte_span.start >= byte_max {
|
||||||
|
@ -437,7 +437,7 @@ impl Shaper {
|
||||||
//
|
//
|
||||||
// NB: When we acquire the ability to handle ligatures that cross word boundaries,
|
// NB: When we acquire the ability to handle ligatures that cross word boundaries,
|
||||||
// we'll need to do something special to handle `word-spacing` properly.
|
// we'll need to do something special to handle `word-spacing` properly.
|
||||||
let character = text.char_at(char_byte_span.start);
|
let character = text[char_byte_span.clone()].chars().next().unwrap();
|
||||||
if is_bidi_control(character) {
|
if is_bidi_control(character) {
|
||||||
glyphs.add_nonglyph_for_char_index(char_idx, false, false);
|
glyphs.add_nonglyph_for_char_index(char_idx, false, false);
|
||||||
} else if character == '\t' {
|
} else if character == '\t' {
|
||||||
|
@ -482,11 +482,7 @@ impl Shaper {
|
||||||
glyphs.add_glyphs_for_char_index(char_idx, &datas);
|
glyphs.add_glyphs_for_char_index(char_idx, &datas);
|
||||||
|
|
||||||
// set the other chars, who have no glyphs
|
// set the other chars, who have no glyphs
|
||||||
let mut i = covered_byte_span.start;
|
for _ in text[covered_byte_span].chars().skip(1) {
|
||||||
loop {
|
|
||||||
let range = text.char_range_at(i);
|
|
||||||
i = range.next;
|
|
||||||
if i >= covered_byte_span.end { break; }
|
|
||||||
char_idx = char_idx + char_step;
|
char_idx = char_idx + char_step;
|
||||||
glyphs.add_nonglyph_for_char_index(char_idx, false, false);
|
glyphs.add_nonglyph_for_char_index(char_idx, false, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,11 +190,8 @@ impl<'a> TextRun {
|
||||||
let (mut byte_i, mut char_i) = (0, CharIndex(0));
|
let (mut byte_i, mut char_i) = (0, CharIndex(0));
|
||||||
let mut cur_slice_is_whitespace = false;
|
let mut cur_slice_is_whitespace = false;
|
||||||
let (mut byte_last_boundary, mut char_last_boundary) = (0, CharIndex(0));
|
let (mut byte_last_boundary, mut char_last_boundary) = (0, CharIndex(0));
|
||||||
while byte_i < text.len() {
|
|
||||||
let range = text.char_range_at(byte_i);
|
|
||||||
let ch = range.ch;
|
|
||||||
let next = range.next;
|
|
||||||
|
|
||||||
|
for ch in text.chars() {
|
||||||
// Slices alternate between whitespace and non-whitespace,
|
// Slices alternate between whitespace and non-whitespace,
|
||||||
// representing line break opportunities.
|
// representing line break opportunities.
|
||||||
let can_break_before = if cur_slice_is_whitespace {
|
let can_break_before = if cur_slice_is_whitespace {
|
||||||
|
@ -234,7 +231,7 @@ impl<'a> TextRun {
|
||||||
char_last_boundary = char_i;
|
char_last_boundary = char_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte_i = next;
|
byte_i = byte_i + ch.len_utf8();
|
||||||
char_i = char_i + CharIndex(1);
|
char_i = char_i + CharIndex(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue