mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
auto merge of #1013 : huonw/servo/text-iter, r=pcwalton
And 3 other minor clean-ups: removing a redundant `if`, a redundant function call, and using `slice_from` where it is possible.
This commit is contained in:
commit
59d2d345c8
3 changed files with 5 additions and 18 deletions
|
@ -266,12 +266,8 @@ impl Shaper {
|
||||||
byteToGlyph = vec::from_elem(byte_max, NO_GLYPH);
|
byteToGlyph = vec::from_elem(byte_max, NO_GLYPH);
|
||||||
} else {
|
} else {
|
||||||
byteToGlyph = vec::from_elem(byte_max, CONTINUATION_BYTE);
|
byteToGlyph = vec::from_elem(byte_max, CONTINUATION_BYTE);
|
||||||
let mut i = 0;
|
for (i, _) in text.char_offset_iter() {
|
||||||
while i < byte_max {
|
|
||||||
byteToGlyph[i] = NO_GLYPH;
|
byteToGlyph[i] = NO_GLYPH;
|
||||||
let range = text.char_range_at(i);
|
|
||||||
ignore(range.ch);
|
|
||||||
i = range.next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,11 +288,8 @@ impl Shaper {
|
||||||
|
|
||||||
debug!("text: %s", text);
|
debug!("text: %s", text);
|
||||||
debug!("(char idx): char->(glyph index):");
|
debug!("(char idx): char->(glyph index):");
|
||||||
let mut i = 0u;
|
for (i, ch) in text.char_offset_iter() {
|
||||||
while i < byte_max {
|
debug!("%u: %? --> %d", i, ch, byteToGlyph[i] as int);
|
||||||
let range = text.char_range_at(i);
|
|
||||||
debug!("%u: %? --> %d", i, range.ch, byteToGlyph[i] as int);
|
|
||||||
i = range.next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// some helpers
|
// some helpers
|
||||||
|
@ -369,11 +362,6 @@ impl Shaper {
|
||||||
all_glyphs_are_within_cluster = false;
|
all_glyphs_are_within_cluster = false;
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// If true, keep checking. Else, stop.
|
|
||||||
if !all_glyphs_are_within_cluster {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("All glyphs within char_byte_span cluster?: %?",
|
debug!("All glyphs within char_byte_span cluster?: %?",
|
||||||
|
@ -554,4 +542,3 @@ extern fn get_font_table_func(_: *hb_face_t, tag: hb_tag_t, user_data: *c_void)
|
||||||
extern fn destroy_blob_func(_: *c_void) {
|
extern fn destroy_blob_func(_: *c_void) {
|
||||||
// TODO: Previous code here was broken. Rewrite.
|
// TODO: Previous code here was broken. Rewrite.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ impl<'self> TextRun {
|
||||||
|
|
||||||
// Create a glyph store for the final slice if it's nonempty.
|
// Create a glyph store for the final slice if it's nonempty.
|
||||||
if byte_i > byte_last_boundary {
|
if byte_i > byte_last_boundary {
|
||||||
let slice = text.slice(byte_last_boundary, text.len()).to_owned();
|
let slice = text.slice_from(byte_last_boundary).to_owned();
|
||||||
debug!("creating glyph store for final slice %? (ws? %?), %? - %? in run %?",
|
debug!("creating glyph store for final slice %? (ws? %?), %? - %? in run %?",
|
||||||
slice, cur_slice_is_whitespace, byte_last_boundary, text.len(), text);
|
slice, cur_slice_is_whitespace, byte_last_boundary, text.len(), text);
|
||||||
glyphs.push(font.shape_text(slice, cur_slice_is_whitespace));
|
glyphs.push(font.shape_text(slice, cur_slice_is_whitespace));
|
||||||
|
|
|
@ -775,7 +775,7 @@ pub fn FindEnumStringIndex(cx: *JSContext,
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
let length = 0;
|
let length = 0;
|
||||||
let chars = JS_GetStringCharsAndLength(cx, jsstr, ptr::to_unsafe_ptr(&length));
|
let chars = JS_GetStringCharsAndLength(cx, jsstr, &length);
|
||||||
if chars.is_null() {
|
if chars.is_null() {
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue