servo: Merge #18347 - Take a `u8` pointer and a length instead of `nsACString` pointer from Gecko (from hsivonen:ptr-and-length-from-gecko); r=SimonSapin
authorHenri Sivonen <hsivonen@hsivonen.fi>
Fri, 01 Sep 2017 12:25:54 -0500
changeset 378253 8b71bab736b58e93777c095995f31b10e5eb797f
parent 378252 8db33f829a1e35e12504a28358f237a84a5f25c2
child 378254 32fb897ebe85c0a5134e987f2dfc15284f8ae8b4
push id50243
push userservo-vcs-sync@mozilla.com
push dateFri, 01 Sep 2017 18:54:37 +0000
treeherderautoland@8b71bab736b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersSimonSapin
bugs1354989
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #18347 - Take a `u8` pointer and a length instead of `nsACString` pointer from Gecko (from hsivonen:ptr-and-length-from-gecko); r=SimonSapin This is the Servo side change of [bug 1354989](https://bugzilla.mozilla.org/show_bug.cgi?id=1354989). - [ ] `./mach build -d` does not report any errors Fails for unrelated reason when building `servo-skia`. - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because this changes the Gecko interface and m-c not burning is the test. Source-Repo: https://github.com/servo/servo Source-Revision: d8598b5abfa92f16357b7afa40b00748e94949d5
servo/components/style/gecko/generated/bindings.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/gecko/generated/bindings.rs
+++ b/servo/components/style/gecko/generated/bindings.rs
@@ -1925,17 +1925,18 @@ extern "C" {
 extern "C" {
     pub fn Servo_Element_IsDisplayNone(element: RawGeckoElementBorrowed)
      -> bool;
 }
 extern "C" {
     pub fn Servo_StyleSheet_FromUTF8Bytes(loader: *mut Loader,
                                           gecko_stylesheet:
                                               *mut ServoStyleSheet,
-                                          data: *const nsACString,
+                                          data: *const u8,
+                                          data_len: usize,
                                           parsing_mode: SheetParsingMode,
                                           extra_data:
                                               *mut RawGeckoURLExtraData,
                                           line_number_offset: u32,
                                           quirks_mode: nsCompatibility,
                                           reusable_sheets:
                                               *mut LoaderReusableStyleSheets)
      -> RawServoStyleSheetContentsStrong;
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -857,25 +857,26 @@ pub extern "C" fn Servo_StyleSheet_Empty
         )
     ).into_strong()
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(
     loader: *mut Loader,
     stylesheet: *mut ServoStyleSheet,
-    data: *const nsACString,
+    data: *const u8,
+    data_len: usize,
     mode: SheetParsingMode,
     extra_data: *mut URLExtraData,
     line_number_offset: u32,
     quirks_mode: nsCompatibility,
     reusable_sheets: *mut LoaderReusableStyleSheets
 ) -> RawServoStyleSheetContentsStrong {
     let global_style_data = &*GLOBAL_STYLE_DATA;
-    let input = unsafe { data.as_ref().unwrap().as_str_unchecked() };
+    let input = unsafe { ::std::str::from_utf8_unchecked(::std::slice::from_raw_parts(data, data_len)) };
 
     let origin = match mode {
         SheetParsingMode::eAuthorSheetFeatures => Origin::Author,
         SheetParsingMode::eUserSheetFeatures => Origin::User,
         SheetParsingMode::eAgentSheetFeatures => Origin::UserAgent,
         SheetParsingMode::eSafeAgentSheetFeatures => Origin::UserAgent,
     };