Bug 1273838 - Part 3: Pass sheet base/referrer/principal to Servo_StylesheetFromUTF8Bytes. r=bholley
authorCameron McCormack <cam@mcc.id.au>
Sat, 21 May 2016 10:02:54 +1000
changeset 298356 3039198867c163ef94164d98d891d1cab8f45de2
parent 298355 1f8833469c1156f515e5c8d1e8915befe1dd8b6f
child 298357 6c73a31a85163322a63592c3d71c022b9d41ae5a
push id30281
push usercbook@mozilla.com
push dateTue, 24 May 2016 12:54:02 +0000
treeherdermozilla-central@829d3be6ba64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1273838
milestone49.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
Bug 1273838 - Part 3: Pass sheet base/referrer/principal to Servo_StylesheetFromUTF8Bytes. r=bholley
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
layout/style/ServoStyleSheet.cpp
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -276,17 +276,20 @@ void
 Servo_DropNodeData(ServoNodeData* data)
 {
   MOZ_CRASH("stylo: shouldn't be calling Servo_DropNodeData in a "
             "non-MOZ_STYLO build");
 }
 
 RawServoStyleSheet*
 Servo_StylesheetFromUTF8Bytes(const uint8_t* bytes, uint32_t length,
-                              mozilla::css::SheetParsingMode mode)
+                              mozilla::css::SheetParsingMode mode,
+                              ThreadSafeURIHolder* base,
+                              ThreadSafeURIHolder* referrer,
+                              ThreadSafePrincipalHolder* principal)
 {
   MOZ_CRASH("stylo: shouldn't be calling Servo_StylesheetFromUTF8Bytes in a "
             "non-MOZ_STYLO build");
 }
 
 void
 Servo_AddRefStyleSheet(RawServoStyleSheet* sheet)
 {
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -106,18 +106,22 @@ void Gecko_CopyListStyleTypeFrom(nsStyle
 // Object refcounting.
 NS_DECL_HOLDER_FFI_REFCOUNTING(nsIPrincipal, Principal)
 NS_DECL_HOLDER_FFI_REFCOUNTING(nsIURI, URI)
 
 // Styleset and Stylesheet management.
 //
 // TODO: Make these return already_AddRefed and UniquePtr when the binding
 // generator is smart enough to handle them.
-RawServoStyleSheet* Servo_StylesheetFromUTF8Bytes(const uint8_t* bytes, uint32_t length,
-                                                  mozilla::css::SheetParsingMode parsing_mode);
+RawServoStyleSheet* Servo_StylesheetFromUTF8Bytes(
+    const uint8_t* bytes, uint32_t length,
+    mozilla::css::SheetParsingMode parsing_mode,
+    ThreadSafeURIHolder* base,
+    ThreadSafeURIHolder* referrer,
+    ThreadSafePrincipalHolder* principal);
 void Servo_AddRefStyleSheet(RawServoStyleSheet* sheet);
 void Servo_ReleaseStyleSheet(RawServoStyleSheet* sheet);
 void Servo_AppendStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set);
 void Servo_PrependStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set);
 void Servo_RemoveStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set);
 void Servo_InsertStyleSheetBefore(RawServoStyleSheet* sheet,
                                   RawServoStyleSheet* reference,
                                   RawServoStyleSet* set);
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -72,19 +72,25 @@ ServoStyleSheet::ParseSheet(const nsAStr
                             nsIURI* aSheetURI,
                             nsIURI* aBaseURI,
                             nsIPrincipal* aSheetPrincipal,
                             uint32_t aLineNumber,
                             css::SheetParsingMode aParsingMode)
 {
   DropSheet();
 
+  RefPtr<ThreadSafeURIHolder> base = new ThreadSafeURIHolder(aBaseURI);
+  RefPtr<ThreadSafeURIHolder> referrer = new ThreadSafeURIHolder(aSheetURI);
+  RefPtr<ThreadSafePrincipalHolder> principal =
+    new ThreadSafePrincipalHolder(aSheetPrincipal);
+
   NS_ConvertUTF16toUTF8 input(aInput);
   mSheet = already_AddRefed<RawServoStyleSheet>(Servo_StylesheetFromUTF8Bytes(
-      reinterpret_cast<const uint8_t*>(input.get()), input.Length(), aParsingMode));
+      reinterpret_cast<const uint8_t*>(input.get()), input.Length(), aParsingMode,
+      base, referrer, principal));
 }
 
 void
 ServoStyleSheet::DropSheet()
 {
   mSheet = nullptr;
 }