Bug 1382925 - Part 2: Add FFI function to get stylesheet origin. r=emilio draft
authorCameron McCormack <cam@mcc.id.au>
Sat, 12 Aug 2017 18:34:34 +0800
changeset 645570 bdd8fcab5647fd5a3e263dd965eeb691f87af764
parent 645569 9f5d8baab0a2fd586702ca3b29fdc47dd225f493
child 645571 34f3b6fa85d952d69c81a5a453c62d0d04bda108
push id73781
push userbmo:cam@mcc.id.au
push dateSun, 13 Aug 2017 10:53:24 +0000
reviewersemilio
bugs1382925
milestone57.0a1
Bug 1382925 - Part 2: Add FFI function to get stylesheet origin. r=emilio MozReview-Commit-ID: F3VY6qagrpS
layout/style/ServoBindingList.h
layout/style/ServoStyleSheet.cpp
layout/style/ServoStyleSheet.h
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -39,16 +39,19 @@ SERVO_BINDING_FUNC(Servo_StyleSheet_HasR
 SERVO_BINDING_FUNC(Servo_StyleSheet_GetRules, ServoCssRulesStrong,
                    RawServoStyleSheetContentsBorrowed sheet)
 SERVO_BINDING_FUNC(Servo_StyleSheet_Clone, RawServoStyleSheetContentsStrong,
                    RawServoStyleSheetContentsBorrowed sheet,
                    const mozilla::ServoStyleSheet* reference_sheet);
 SERVO_BINDING_FUNC(Servo_StyleSheet_SizeOfIncludingThis, size_t,
                    mozilla::MallocSizeOf malloc_size_of,
                    RawServoStyleSheetContentsBorrowed sheet)
+SERVO_BINDING_FUNC(Servo_StyleSheet_GetOrigin,
+                   mozilla::OriginFlags,
+                   RawServoStyleSheetContentsBorrowed sheet)
 SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSetOwned, RawGeckoPresContextOwned pres_context)
 SERVO_BINDING_FUNC(Servo_StyleSet_Clear, void,
                    RawServoStyleSetBorrowed set)
 SERVO_BINDING_FUNC(Servo_StyleSet_RebuildCachedData, void,
                    RawServoStyleSetBorrowed set)
 SERVO_BINDING_FUNC(Servo_StyleSet_MediumFeaturesChanged, bool,
                    RawServoStyleSetBorrowed set, bool* viewport_units_used)
 SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set)
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -458,9 +458,15 @@ ServoStyleSheet::SizeOfIncludingThis(Mal
     // is worthwhile:
     // - s->mRuleList
 
     s = s->mNext ? s->mNext->AsServo() : nullptr;
   }
   return n;
 }
 
+OriginFlags
+ServoStyleSheet::GetOrigin()
+{
+  return Servo_StyleSheet_GetOrigin(Inner()->mContents);
+}
+
 } // namespace mozilla
--- a/layout/style/ServoStyleSheet.h
+++ b/layout/style/ServoStyleSheet.h
@@ -116,16 +116,19 @@ public:
   // nsICSSLoaderObserver interface
   NS_IMETHOD StyleSheetLoaded(StyleSheet* aSheet, bool aWasAlternate,
                               nsresult aStatus) final;
 
   // Internal GetCssRules method which do not have security check and
   // completelness check.
   ServoCSSRuleList* GetCssRulesInternal();
 
+  // Returns the stylesheet's Servo origin as an OriginFlags value.
+  OriginFlags GetOrigin();
+
 protected:
   virtual ~ServoStyleSheet();
 
   void LastRelease();
 
   ServoStyleSheetInner* Inner() const
   {
     return static_cast<ServoStyleSheetInner*>(mInner);