Bug 1343964 part 3 - Have ServoStyleSheet own a URLExtraData. r?heycam draft
authorXidorn Quan <me@upsuper.org>
Tue, 04 Apr 2017 13:41:44 +1000
changeset 555387 1289fcd8fffab2eaa85d3fe3fd47ff9b77e17959
parent 555386 8c4388ffbdeafddb2b1ccdc8de9261afcc270632
child 555388 619dbbcdf5dcdfbe2b1dfb15f925ca0e424f1459
push id52232
push userxquan@mozilla.com
push dateTue, 04 Apr 2017 07:17:53 +0000
reviewersheycam
bugs1343964
milestone55.0a1
Bug 1343964 part 3 - Have ServoStyleSheet own a URLExtraData. r?heycam MozReview-Commit-ID: CQyvrVtl0hr
layout/style/ServoStyleSheet.cpp
layout/style/ServoStyleSheet.h
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -95,23 +95,25 @@ ServoStyleSheet::ParseSheet(css::Loader*
     Inner()->mSheet =
       Servo_StyleSheet_FromUTF8Bytes(aLoader, this, &input,
                                      mParsingMode, extraData).Consume();
   } else {
     Servo_StyleSheet_ClearAndUpdate(Inner()->mSheet, aLoader,
                                     this, &input, extraData);
   }
 
+  Inner()->mURLData = extraData.forget();
   return NS_OK;
 }
 
 void
 ServoStyleSheet::LoadFailed()
 {
   Inner()->mSheet = Servo_StyleSheet_Empty(mParsingMode).Consume();
+  Inner()->mURLData = URLExtraData::Dummy();
 }
 
 // nsICSSLoaderObserver implementation
 NS_IMETHODIMP
 ServoStyleSheet::StyleSheetLoaded(StyleSheet* aSheet,
                                   bool aWasAlternate,
                                   nsresult aStatus)
 {
--- a/layout/style/ServoStyleSheet.h
+++ b/layout/style/ServoStyleSheet.h
@@ -7,16 +7,17 @@
 #ifndef mozilla_ServoStyleSheet_h
 #define mozilla_ServoStyleSheet_h
 
 #include "mozilla/dom/SRIMetadata.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/ServoBindingTypes.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInfo.h"
+#include "mozilla/URLExtraData.h"
 #include "nsStringFwd.h"
 
 namespace mozilla {
 
 class ServoCSSRuleList;
 
 namespace css {
 class Loader;
@@ -28,16 +29,23 @@ class Loader;
 
 struct ServoStyleSheetInner : public StyleSheetInfo
 {
   ServoStyleSheetInner(CORSMode aCORSMode,
                        ReferrerPolicy aReferrerPolicy,
                        const dom::SRIMetadata& aIntegrity);
 
   RefPtr<const RawServoStyleSheet> mSheet;
+  // XXX StyleSheetInfo already has mSheetURI, mBaseURI, and mPrincipal.
+  // Can we somehow replace them with URLExtraData directly? The issue
+  // is currently URLExtraData is immutable, but URIs in StyleSheetInfo
+  // seems to be mutable, so we probably cannot set them altogether.
+  // Also, this is mostly a duplicate reference of the same url data
+  // inside RawServoStyleSheet. We may want to just use that instead.
+  RefPtr<URLExtraData> mURLData;
 };
 
 
 /**
  * CSS style sheet object that is a wrapper for a Servo Stylesheet.
  */
 class ServoStyleSheet : public StyleSheet
 {