Implement clone_content method

This commit is contained in:
Daisuke Akatsuka 2017-08-14 17:20:19 +09:00
parent e0b834033d
commit c05baa2327
3 changed files with 93 additions and 15 deletions

View file

@ -919,3 +919,16 @@ impl<T> Rect<T> where T: GeckoStyleCoordConvertible {
)
}
}
/// Convert to String from given chars pointer.
pub unsafe fn string_from_chars_pointer(p: *const u16) -> String {
use std::slice;
let mut length = 0;
let mut iter = p;
while *iter != 0 {
length += 1;
iter = iter.offset(1);
}
let char_vec = slice::from_raw_parts(p, length as usize);
String::from_utf16_lossy(char_vec)
}