Bug 1376295 Part 1: Allow null raw sheets in ServoStyleSheet memory calculations. draft
authorBrad Werth <bwerth@mozilla.com>
Tue, 27 Jun 2017 10:09:07 -0700
changeset 600628 2acb59ac6d3d243a18da557bb166aefbfc5b7461
parent 600616 f4e52135d9bdc6ce98bb37b450021445aed894ce
child 635044 3dce456d97da90bc35931ca6f77f12981291e2bd
push id65816
push userbwerth@mozilla.com
push dateTue, 27 Jun 2017 17:47:04 +0000
bugs1376295
milestone56.0a1
Bug 1376295 Part 1: Allow null raw sheets in ServoStyleSheet memory calculations. MozReview-Commit-ID: 2UmLRlUmOR8
layout/style/ServoStyleSheet.cpp
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -63,17 +63,21 @@ ServoStyleSheetInner::CloneFor(StyleShee
 }
 
 MOZ_DEFINE_MALLOC_SIZE_OF(ServoStyleSheetMallocSizeOf)
 
 size_t
 ServoStyleSheetInner::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
   size_t n = aMallocSizeOf(this);
-  n += Servo_StyleSheet_SizeOfIncludingThis(ServoStyleSheetMallocSizeOf, mSheet);
+  // mSheet will be null if the parsing has not completed.
+  if (mSheet) {
+    n += Servo_StyleSheet_SizeOfIncludingThis(ServoStyleSheetMallocSizeOf,
+                                              mSheet);
+  }
   return n;
 }
 
 ServoStyleSheet::ServoStyleSheet(css::SheetParsingMode aParsingMode,
                                  CORSMode aCORSMode,
                                  net::ReferrerPolicy aReferrerPolicy,
                                  const dom::SRIMetadata& aIntegrity)
   : StyleSheet(StyleBackendType::Servo, aParsingMode)