mirror of
https://github.com/servo/servo.git
synced 2025-07-18 21:03:45 +01:00
Remove our copy of Utf16Encoder in favor of the built-in equivalent (fixes #4725).
This commit is contained in:
parent
1b23c4fd57
commit
9ee3278c28
3 changed files with 3 additions and 34 deletions
|
@ -23,6 +23,7 @@ extern crate js;
|
||||||
extern crate layers;
|
extern crate layers;
|
||||||
extern crate png;
|
extern crate png;
|
||||||
extern crate script;
|
extern crate script;
|
||||||
|
extern crate unicode;
|
||||||
|
|
||||||
extern crate net;
|
extern crate net;
|
||||||
extern crate msg;
|
extern crate msg;
|
||||||
|
|
|
@ -11,7 +11,7 @@ use eutil::Downcast;
|
||||||
use interfaces::CefBrowser;
|
use interfaces::CefBrowser;
|
||||||
use render_handler::CefRenderHandlerExtensions;
|
use render_handler::CefRenderHandlerExtensions;
|
||||||
use types::{cef_cursor_handle_t, cef_rect_t};
|
use types::{cef_cursor_handle_t, cef_rect_t};
|
||||||
use wrappers::Utf16Encoder;
|
use unicode::str::Utf16Encoder;
|
||||||
|
|
||||||
use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver};
|
use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver};
|
||||||
use compositing::windowing::{WindowEvent, WindowMethods};
|
use compositing::windowing::{WindowEvent, WindowMethods};
|
||||||
|
|
|
@ -29,6 +29,7 @@ use types::{cef_termination_status_t, cef_text_input_context_t, cef_thread_id_t}
|
||||||
use types::{cef_time_t, cef_transition_type_t, cef_urlrequest_status_t};
|
use types::{cef_time_t, cef_transition_type_t, cef_urlrequest_status_t};
|
||||||
use types::{cef_v8_accesscontrol_t, cef_v8_propertyattribute_t, cef_value_type_t};
|
use types::{cef_v8_accesscontrol_t, cef_v8_propertyattribute_t, cef_value_type_t};
|
||||||
use types::{cef_window_info_t, cef_xml_encoding_type_t, cef_xml_node_type_t};
|
use types::{cef_window_info_t, cef_xml_encoding_type_t, cef_xml_node_type_t};
|
||||||
|
use unicode::str::Utf16Encoder;
|
||||||
|
|
||||||
use libc::{self, c_char, c_int, c_ushort, c_void};
|
use libc::{self, c_char, c_int, c_ushort, c_void};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -271,39 +272,6 @@ extern "C" fn free_utf16_buffer(buffer: *mut c_ushort) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(pcwalton): Post Rust-upgrade, remove this and use `collections::str::Utf16Encoder`.
|
|
||||||
pub struct Utf16Encoder<I> {
|
|
||||||
chars: I,
|
|
||||||
extra: u16,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I> Utf16Encoder<I> {
|
|
||||||
pub fn new(chars: I) -> Utf16Encoder<I> where I: Iterator<Item=char> {
|
|
||||||
Utf16Encoder {
|
|
||||||
chars: chars,
|
|
||||||
extra: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I> Iterator for Utf16Encoder<I> where I: Iterator<Item=char> {
|
|
||||||
type Item = u16;
|
|
||||||
fn next(&mut self) -> Option<u16> {
|
|
||||||
if self.extra != 0 {
|
|
||||||
return Some(mem::replace(&mut self.extra, 0))
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut buf = [0u16; 2];
|
|
||||||
self.chars.next().map(|ch| {
|
|
||||||
let n = ch.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
|
|
||||||
if n == 2 {
|
|
||||||
self.extra = buf[1]
|
|
||||||
}
|
|
||||||
buf[0]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> CefWrap<cef_string_t> for &'a mut String {
|
impl<'a> CefWrap<cef_string_t> for &'a mut String {
|
||||||
fn to_c(_: &'a mut String) -> cef_string_t {
|
fn to_c(_: &'a mut String) -> cef_string_t {
|
||||||
panic!("unimplemented CEF type conversion: &'a mut String");
|
panic!("unimplemented CEF type conversion: &'a mut String");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue