Bug 1290276 Part 4 - Make ServoStyleSet::RawSet() return a pointer. draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 05 Jun 2017 11:57:13 +0800
changeset 590808 9aeb2cb70e0bd5b2565721b45440e59cda65af7f
parent 590807 d8db84c5e5db239d10d869e591c3e9e20fe4c74e
child 590809 5dc03f9161e85173b63d8d4750e38581da141cfe
push id62831
push userbmo:tlin@mozilla.com
push dateThu, 08 Jun 2017 03:44:02 +0000
bugs1290276
milestone55.0a1
Bug 1290276 Part 4 - Make ServoStyleSet::RawSet() return a pointer. In next part, we'll use ServoStyleSet to host XBL stylesheets. The raw set is not available until the resources are loaded, so it's easier to tell that by checking whether the pointer is nullptr or not. MozReview-Commit-ID: Hqydd55FPO9
layout/style/ServoMediaList.cpp
layout/style/ServoStyleSet.h
--- a/layout/style/ServoMediaList.cpp
+++ b/layout/style/ServoMediaList.cpp
@@ -77,14 +77,15 @@ ServoMediaList::Delete(const nsAString& 
     return NS_OK;
   }
   return NS_ERROR_DOM_NOT_FOUND_ERR;
 }
 
 bool
 ServoMediaList::Matches(nsPresContext* aPresContext) const
 {
-  const RawServoStyleSet& rawSet =
+  const RawServoStyleSet* rawSet =
     aPresContext->StyleSet()->AsServo()->RawSet();
-  return Servo_MediaList_Matches(mRawList, &rawSet);
+  MOZ_ASSERT(rawSet, "The RawServoStyleSet should be valid!");
+  return Servo_MediaList_Matches(mRawList, rawSet);
 }
 
 } // namespace mozilla
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -137,17 +137,19 @@ public:
     return StylistNeedsUpdate();
   }
 
   bool MediumFeaturesChanged() const;
 
   void InvalidateStyleForCSSRuleChanges();
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
-  const RawServoStyleSet& RawSet() const { return *mRawSet; }
+  const RawServoStyleSet* RawSet() const {
+    return mRawSet.get();
+  }
 
   bool GetAuthorStyleDisabled() const;
   nsresult SetAuthorStyleDisabled(bool aStyleDisabled);
 
   void BeginUpdate();
   nsresult EndUpdate();
 
   already_AddRefed<nsStyleContext>