servo: Merge #12691 - Parse style sheets with a real base URL in geckolib (from heycam:style-sheet-base); r=bholley
authorCameron McCormack <cam@mcc.id.au>
Tue, 02 Aug 2016 12:56:11 -0500
changeset 339421 fd4b3b2bc96a3ea88d74bcabb3c0f201ea015878
parent 339420 cf3c934f0b9904f3ea3531de0673441a8059a5ae
child 339422 7c845ce5f2c6cf6e10581b689dd99f678cf88e3a
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1291207
servo: Merge #12691 - Parse style sheets with a real base URL in geckolib (from heycam:style-sheet-base); r=bholley <!-- Please describe your changes on the following line: --> Corresponding Gecko change is [bug 1291207](https://bugzilla.mozilla.org/show_bug.cgi?id=1291207). r? @bholley --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./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 - [X] 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: 7807895d5839ddd8e042b7e741961a75b70c37d8
servo/ports/geckolib/gecko_bindings/bindings.rs
servo/ports/geckolib/glue.rs
--- a/servo/ports/geckolib/gecko_bindings/bindings.rs
+++ b/servo/ports/geckolib/gecko_bindings/bindings.rs
@@ -308,16 +308,18 @@ extern "C" {
                                  value: *mut nsStyleUnion);
     pub fn Gecko_SetStyleCoordCalcValue(unit: *mut nsStyleUnit,
                                         value: *mut nsStyleUnion,
                                         calc: CalcValue);
     pub fn Gecko_AddRefCalcArbitraryThread(aPtr: *mut Calc);
     pub fn Gecko_ReleaseCalcArbitraryThread(aPtr: *mut Calc);
     pub fn Servo_StylesheetFromUTF8Bytes(bytes: *const u8, length: u32,
                                          parsing_mode: SheetParsingMode,
+                                         base_bytes: *const u8,
+                                         base_length: u32,
                                          base: *mut ThreadSafeURIHolder,
                                          referrer: *mut ThreadSafeURIHolder,
                                          principal:
                                              *mut ThreadSafePrincipalHolder)
      -> *mut RawServoStyleSheet;
     pub fn Servo_AddRefStyleSheet(sheet: *mut RawServoStyleSheet);
     pub fn Servo_ReleaseStyleSheet(sheet: *mut RawServoStyleSheet);
     pub fn Servo_AppendStyleSheet(sheet: *mut RawServoStyleSheet,
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -148,30 +148,32 @@ pub extern "C" fn Servo_DropNodeData(dat
         let _ = Box::<NonOpaqueStyleData>::from_raw(data as *mut NonOpaqueStyleData);
     }
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const u8,
                                                 length: u32,
                                                 mode: SheetParsingMode,
+                                                base_bytes: *const u8,
+                                                base_length: u32,
                                                 base: *mut ThreadSafeURIHolder,
                                                 referrer: *mut ThreadSafeURIHolder,
                                                 principal: *mut ThreadSafePrincipalHolder)
                                                 -> *mut RawServoStyleSheet {
     let input = unsafe { from_utf8_unchecked(slice::from_raw_parts(bytes, length as usize)) };
 
     let origin = match mode {
         SheetParsingMode::eAuthorSheetFeatures => Origin::Author,
         SheetParsingMode::eUserSheetFeatures => Origin::User,
         SheetParsingMode::eAgentSheetFeatures => Origin::UserAgent,
     };
 
-    // FIXME(heycam): Pass in the real base URL.
-    let url = Url::parse("about:none").unwrap();
+    let base_str = unsafe { from_utf8_unchecked(slice::from_raw_parts(base_bytes, base_length as usize)) };
+    let url = Url::parse(base_str).unwrap();
     let extra_data = ParserContextExtraData {
         base: Some(GeckoArcURI::new(base)),
         referrer: Some(GeckoArcURI::new(referrer)),
         principal: Some(GeckoArcPrincipal::new(principal)),
     };
     let sheet = Arc::new(Stylesheet::from_str(input, url, origin, Box::new(StdoutErrorReporter),
                                               extra_data));
     unsafe {