servo: Merge #14644 - Ever so slightly less unstable (from servo:ever-so-slightly-less-unstable); r=heycam
authorSimon Sapin <simon.sapin@exyr.org>
Mon, 19 Dec 2016 22:09:02 -0800
changeset 387021 1dfcd30ab73121f531bd96ee70120a7396a48e12
parent 387020 5de39c8afbda88daa6964cadc57d59b58aa9561b
child 387022 afc991293b8bee3b27e52128ff9b3e1b2a22a1e8
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
servo: Merge #14644 - Ever so slightly less unstable (from servo:ever-so-slightly-less-unstable); r=heycam <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: e13f0017931e7f87cad13a13e3fe4e9bcbb9c554
servo/components/net/image_cache_thread.rs
servo/components/script/dom/bindings/codegen/CodegenRust.py
servo/components/script/dom/htmlmediaelement.rs
servo/components/style/viewport.rs
servo/ports/cef/lib.rs
servo/ports/cef/string_list.rs
servo/ports/cef/window.rs
servo/ports/cef/wrappers.rs
servo/tests/unit/style/lib.rs
servo/tests/unit/style/viewport.rs
--- a/servo/components/net/image_cache_thread.rs
+++ b/servo/components/net/image_cache_thread.rs
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 use immeta::load_from_buf;
 use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
 use ipc_channel::router::ROUTER;
-use net_traits::{CoreResourceThread, NetworkError, fetch_async, FetchResponseMsg, FetchMetadata, Metadata};
+use net_traits::{CoreResourceThread, NetworkError, fetch_async, FetchResponseMsg};
 use net_traits::image::base::{Image, ImageMetadata, PixelFormat, load_from_memory};
 use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheCommand, ImageCacheThread, ImageState};
 use net_traits::image_cache_thread::{ImageCacheResult, ImageOrMetadataAvailable, ImageResponse, UsePlaceholder};
 use net_traits::image_cache_thread::ImageResponder;
 use net_traits::request::{Destination, RequestInit, Type as RequestType};
 use servo_config::resource_files::resources_dir_path;
 use servo_url::ServoUrl;
 use std::borrow::ToOwned;
--- a/servo/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/servo/components/script/dom/bindings/codegen/CodegenRust.py
@@ -4255,17 +4255,19 @@ class CGUnionConversionStruct(CGThing):
 
     def try_method(self, t):
         templateVars = getUnionTypeTemplateVars(t, self.descriptorProvider)
         returnType = "Result<Option<%s>, ()>" % templateVars["typeName"]
         jsConversion = templateVars["jsConversion"]
 
         return CGWrapper(
             CGIndenter(jsConversion, 4),
-            pre="unsafe fn TryConvertTo%s(cx: *mut JSContext, value: HandleValue) -> %s {\n" % (t.name, returnType),
+            # TryConvertToObject is unused, but not generating it while generating others is tricky.
+            pre="#[allow(dead_code)] unsafe fn TryConvertTo%s(cx: *mut JSContext, value: HandleValue) -> %s {\n"
+                % (t.name, returnType),
             post="\n}")
 
     def define(self):
         from_jsval = self.from_jsval()
         methods = CGIndenter(CGList([
             self.try_method(t) for t in self.type.flatMemberTypes
         ], "\n\n"))
         return """
--- a/servo/components/script/dom/htmlmediaelement.rs
+++ b/servo/components/script/dom/htmlmediaelement.rs
@@ -432,26 +432,27 @@ impl HTMLMediaElement {
         // TODO step 3 (delay load event)
 
         // Step 4
         let doc = document_from_node(self);
         ScriptThread::await_stable_state(ResourceSelectionTask::new(self, doc.base_url()));
     }
 
     // https://html.spec.whatwg.org/multipage/#concept-media-load-algorithm
+    #[allow(unreachable_code)]
     fn resource_selection_algorithm_sync(&self, base_url: ServoUrl) {
         // TODO step 5 (populate pending text tracks)
 
         // Step 6
         let mode = if false {
             // TODO media provider object
             ResourceSelectionMode::Object
         } else if let Some(attr) = self.upcast::<Element>().get_attribute(&ns!(), &local_name!("src")) {
             ResourceSelectionMode::Attribute(attr.Value().to_string())
-        } else if false {
+        } else if false {  // TODO: when implementing this remove #[allow(unreachable_code)] above.
             // TODO <source> child
             ResourceSelectionMode::Children(panic!())
         } else {
             self.network_state.set(NETWORK_EMPTY);
             return;
         };
 
         // Step 7
--- a/servo/components/style/viewport.rs
+++ b/servo/components/style/viewport.rs
@@ -64,17 +64,17 @@ macro_rules! declare_viewport_descriptor
             $(
                 $assigned_variant($assigned_data),
             )+
         }
 
         const VIEWPORT_DESCRIPTOR_VARIANTS: usize = $number_of_variants;
 
         impl ViewportDescriptor {
-            fn discriminant_value(&self) -> usize {
+            pub fn discriminant_value(&self) -> usize {
                 match *self {
                     $(
                         ViewportDescriptor::$assigned_variant(..) => $assigned_discriminant,
                     )*
                 }
             }
         }
 
--- a/servo/ports/cef/lib.rs
+++ b/servo/ports/cef/lib.rs
@@ -1,33 +1,31 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #![feature(box_syntax)]
 #![feature(core_intrinsics)]
 #![feature(link_args)]
 #![feature(plugin)]
-#![feature(unicode)]
 
 #![allow(non_camel_case_types)]
 
 #![plugin(plugins)]
 
 #[macro_use]
 extern crate log;
 
 extern crate servo;
 extern crate compositing;
 
 extern crate euclid;
 extern crate gfx_traits;
 extern crate gleam;
 extern crate glutin_app;
-extern crate rustc_unicode;
 extern crate script_traits;
 extern crate servo_config;
 extern crate servo_geometry;
 extern crate servo_url;
 extern crate style_traits;
 
 extern crate net_traits;
 extern crate msg;
--- a/servo/ports/cef/string_list.rs
+++ b/servo/ports/cef/string_list.rs
@@ -2,18 +2,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 use libc::{c_int};
 use std::slice;
 use string::cef_string_utf16_set;
 use types::{cef_string_list_t,cef_string_t};
 
-use rustc_unicode::str::Utf16Encoder;
-
 //cef_string_list
 
 #[no_mangle]
 pub extern "C" fn cef_string_list_alloc() -> *mut cef_string_list_t {
     Box::into_raw(box vec!())
 }
 
 #[no_mangle]
@@ -33,17 +31,17 @@ pub extern "C" fn cef_string_list_append
 }
 
 #[no_mangle]
 pub extern "C" fn cef_string_list_value(lt: *mut cef_string_list_t, index: c_int, value: *mut cef_string_t) -> c_int {
     unsafe {
         if index < 0 || lt.is_null() { return 0; }
         if index as usize > (*lt).len() - 1 { return 0; }
         let ref string = (*lt)[index as usize];
-        let utf16_chars: Vec<u16> = Utf16Encoder::new(string.chars()).collect();
+        let utf16_chars: Vec<u16> = string.encode_utf16().collect();
         cef_string_utf16_set(utf16_chars.as_ptr(), utf16_chars.len(), value, 1)
     }
 }
 
 #[no_mangle]
 pub extern "C" fn cef_string_list_clear(lt: *mut cef_string_list_t) {
     unsafe {
         if lt.is_null() { return; }
--- a/servo/ports/cef/window.rs
+++ b/servo/ports/cef/window.rs
@@ -9,17 +9,16 @@
 
 #[cfg(target_os="linux")]
 use core::CEF_APP;
 use eutil::Downcast;
 #[cfg(target_os="linux")]
 use interfaces::CefApp;
 use interfaces::CefBrowser;
 use render_handler::CefRenderHandlerExtensions;
-use rustc_unicode::str::Utf16Encoder;
 use types::{cef_cursor_handle_t, cef_cursor_type_t, cef_rect_t};
 use wrappers::CefWrap;
 
 use compositing::compositor_thread::{self, CompositorProxy, CompositorReceiver};
 use compositing::windowing::{WindowEvent, WindowMethods};
 use euclid::point::Point2D;
 use euclid::scale_factor::ScaleFactor;
 use euclid::size::{Size2D, TypedSize2D};
@@ -326,20 +325,17 @@ impl WindowMethods for Window {
 
     fn status(&self, info: Option<String>) {
         let browser = self.cef_browser.borrow();
         let browser = match *browser {
             None => return,
             Some(ref browser) => browser,
         };
         let str = match info {
-            Some(s) => {
-                let utf16_chars: Vec<u16> = Utf16Encoder::new(s.chars()).collect();
-                utf16_chars
-            }
+            Some(s) => s.encode_utf16().collect::<Vec<u16>>(),
             None => vec![]
         };
 
         if check_ptr_exist!(browser.get_host().get_client(), get_display_handler) &&
            check_ptr_exist!(browser.get_host().get_client().get_display_handler(), on_status_message) {
             browser.get_host().get_client().get_display_handler().on_status_message((*browser).clone(), str.as_slice());
         }
     }
@@ -392,17 +388,17 @@ impl WindowMethods for Window {
     fn load_error(&self, code: NetError, url: String) {
         let browser = self.cef_browser.borrow();
         let browser = match *browser {
             None => return,
             Some(ref browser) => browser,
         };
         if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) &&
            check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_load_error) {
-            let utf16_chars: Vec<u16> = Utf16Encoder::new((url).chars()).collect();
+            let utf16_chars: Vec<u16> = url.encode_utf16().collect();
             browser.get_host()
                    .get_client()
                    .get_load_handler()
                    .on_load_error((*browser).clone(), browser.get_main_frame(),
                    code, &[], utf16_chars.as_slice());
         }
     }
 
@@ -423,20 +419,17 @@ impl WindowMethods for Window {
         let browser = match *browser {
             None => return,
             Some(ref browser) => browser,
         };
         let frame = browser.get_main_frame();
         let frame = frame.downcast();
         let mut title_visitor = frame.title_visitor.borrow_mut();
         let str = match string {
-            Some(s) => {
-                let utf16_chars: Vec<u16> = Utf16Encoder::new(s.chars()).collect();
-                utf16_chars
-            }
+            Some(s) => s.encode_utf16().collect(),
             None => vec![]
         };
 
         if check_ptr_exist!(browser.get_host().get_client(), get_display_handler) &&
            check_ptr_exist!(browser.get_host().get_client().get_display_handler(), on_title_change) {
             browser.get_host().get_client().get_display_handler().on_title_change((*browser).clone(), str.as_slice());
         }
         match &mut *title_visitor {
@@ -456,17 +449,17 @@ impl WindowMethods for Window {
             None => return,
             Some(ref browser) => browser,
         };
         let frame = browser.get_main_frame();
         let servoframe = frame.downcast();
         // FIXME(https://github.com/rust-lang/rust/issues/23338)
         let mut frame_url = servoframe.url.borrow_mut();
         *frame_url = url.into_string();
-        let utf16_chars: Vec<u16> = Utf16Encoder::new((*frame_url).chars()).collect();
+        let utf16_chars: Vec<u16> = frame_url.encode_utf16().collect();
         if check_ptr_exist!(browser.get_host().get_client(), get_display_handler) &&
            check_ptr_exist!(browser.get_host().get_client().get_display_handler(), on_address_change) {
             browser.get_host().get_client().get_display_handler().on_address_change((*browser).clone(), frame.clone(), utf16_chars.as_slice());
         }
     }
 
     fn handle_key(&self, _: Option<char>, _: Key, _: KeyModifiers) {
         // TODO(negge)
--- a/servo/ports/cef/wrappers.rs
+++ b/servo/ports/cef/wrappers.rs
@@ -3,17 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 use interfaces::{CefV8Value};
 use interfaces::{cef_app_t, CefApp, cef_drag_data_t, cef_post_data_element_t, cef_v8value_t, CefPostDataElement};
 use interfaces::{cef_dialog_handler_t, cef_focus_handler_t};
 use interfaces::{cef_download_handler_t, cef_drag_handler_t, cef_context_menu_handler_t};
 use interfaces::{cef_geolocation_handler_t, cef_jsdialog_handler_t, cef_keyboard_handler_t};
 use interfaces::{cef_load_handler_t, cef_request_handler_t};
-use rustc_unicode::str::Utf16Encoder;
 use types::{cef_base_t, cef_browser_settings_t, CefBrowserSettings, cef_color_model_t};
 use types::{cef_context_menu_edit_state_flags_t};
 use types::{cef_context_menu_media_state_flags_t};
 use types::{cef_context_menu_media_type_t, cef_context_menu_type_flags_t, cef_cookie_t, cef_cursor_info_t, CefCursorInfo, cef_cursor_type_t};
 use types::{cef_dom_document_type_t, cef_dom_node_type_t};
 use types::{cef_drag_operations_mask_t, cef_draggable_region_t, cef_duplex_mode_t};
 use types::{cef_errorcode_t, cef_event_flags_t, cef_event_handle_t};
 use types::{cef_file_dialog_mode_t, cef_focus_source_t};
@@ -250,17 +249,17 @@ impl<'a,'b> CefWrap<*mut *const c_char> 
     }
     unsafe fn to_rust(_: *mut *const c_char) -> &'a mut &'b str {
         panic!("unimplemented CEF type conversion: *mut *const c_char")
     }
 }
 
 impl<'a> CefWrap<cef_string_userfree_t> for String {
     fn to_c(string: String) -> cef_string_userfree_t {
-        let utf16_chars: Vec<u16> = Utf16Encoder::new(string.chars()).collect();
+        let utf16_chars: Vec<u16> = string.encode_utf16().collect();
 
         let boxed_string;
         unsafe {
             let buffer = libc::malloc((mem::size_of::<c_ushort>() as libc::size_t) *
                                       ((utf16_chars.len() + 1) as libc::size_t)) as *mut u16;
             for (i, ch) in utf16_chars.iter().enumerate() {
                 *buffer.offset(i as isize) = *ch
             }
--- a/servo/tests/unit/style/lib.rs
+++ b/servo/tests/unit/style/lib.rs
@@ -1,14 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #![cfg(test)]
-#![feature(core_intrinsics, plugin, test)]
+#![feature(plugin, test)]
 
 extern crate app_units;
 extern crate cssparser;
 extern crate euclid;
 #[macro_use] extern crate html5ever_atoms;
 #[macro_use] #[allow(unused_extern_crates)] extern crate matches;
 extern crate owning_ref;
 extern crate parking_lot;
--- a/servo/tests/unit/style/viewport.rs
+++ b/servo/tests/unit/style/viewport.rs
@@ -46,23 +46,21 @@ fn test_viewport_rule<F>(css: &str,
     });
     assert!(rule_count > 0);
 }
 
 fn test_meta_viewport<F>(meta: &str, callback: F)
     where F: Fn(&Vec<ViewportDescriptorDeclaration>, &str)
 {
     if let Some(mut rule) = ViewportRule::from_meta(meta) {
-        use std::intrinsics::discriminant_value;
-
         // from_meta uses a hash-map to collect the declarations, so we need to
         // sort them in a stable order for the tests
         rule.declarations.sort_by(|a, b| {
-            let a = unsafe { discriminant_value(&a.descriptor) };
-            let b = unsafe { discriminant_value(&b.descriptor) };
+            let a = a.descriptor.discriminant_value();
+            let b = b.descriptor.discriminant_value();
             a.cmp(&b)
         });
 
         callback(&rule.declarations, meta);
     } else {
         panic!("no @viewport rule for {}", meta);
     }
 }