diff --git a/servo/ports/cef/lib.rs b/servo/ports/cef/lib.rs index d8046f504faa..afd3289b1ee6 100644 --- a/servo/ports/cef/lib.rs +++ b/servo/ports/cef/lib.rs @@ -23,6 +23,7 @@ extern crate js; extern crate layers; extern crate png; extern crate script; +extern crate unicode; extern crate net; extern crate msg; diff --git a/servo/ports/cef/window.rs b/servo/ports/cef/window.rs index 9e6acb473d2c..b4185695dcef 100644 --- a/servo/ports/cef/window.rs +++ b/servo/ports/cef/window.rs @@ -11,7 +11,7 @@ use eutil::Downcast; use interfaces::CefBrowser; use render_handler::CefRenderHandlerExtensions; 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::windowing::{WindowEvent, WindowMethods}; diff --git a/servo/ports/cef/wrappers.rs b/servo/ports/cef/wrappers.rs index cf3ebdd4b28e..a93531c198fe 100644 --- a/servo/ports/cef/wrappers.rs +++ b/servo/ports/cef/wrappers.rs @@ -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_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 unicode::str::Utf16Encoder; use libc::{self, c_char, c_int, c_ushort, c_void}; 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 { - chars: I, - extra: u16, -} - -impl Utf16Encoder { - pub fn new(chars: I) -> Utf16Encoder where I: Iterator { - Utf16Encoder { - chars: chars, - extra: 0, - } - } -} - -impl Iterator for Utf16Encoder where I: Iterator { - type Item = u16; - fn next(&mut self) -> Option { - 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 for &'a mut String { fn to_c(_: &'a mut String) -> cef_string_t { panic!("unimplemented CEF type conversion: &'a mut String");