Bug 1371488 part 1 - Don't create empty servo sheet for stylesheet of @import rule when loading failed. r?emilio draft
authorXidorn Quan <me@upsuper.org>
Fri, 09 Jun 2017 10:52:35 +1000
changeset 592943 a9cb916fb8f06e73c006d94bce0a0e212250ebd2
parent 592942 132f93b630e65cedf5985ffc4350c1e31d22b50b
child 592944 0b49f13489f85166b9221087c247abc220813ce9
child 592960 03706ea621f1663f9d24ecd3e03321aba00fb67e
push id63546
push userxquan@mozilla.com
push dateMon, 12 Jun 2017 23:52:58 +0000
reviewersemilio
bugs1371488
milestone56.0a1
Bug 1371488 part 1 - Don't create empty servo sheet for stylesheet of @import rule when loading failed. r?emilio MozReview-Commit-ID: EnjVQIe1oeY
layout/style/ServoStyleSheet.cpp
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -171,17 +171,22 @@ ServoStyleSheet::ParseSheet(css::Loader*
 
   Inner()->mURLData = extraData.forget();
   return NS_OK;
 }
 
 void
 ServoStyleSheet::LoadFailed()
 {
-  Inner()->mSheet = Servo_StyleSheet_Empty(mParsingMode).Consume();
+  if (!Inner()->mSheet) {
+    // Only create empty stylesheet if this is a top level stylesheet.
+    // The raw sheet for stylesheet of @import rule is already set in
+    // loader, and we should not touch it.
+    Inner()->mSheet = Servo_StyleSheet_Empty(mParsingMode).Consume();
+  }
   Inner()->mURLData = URLExtraData::Dummy();
 }
 
 nsresult
 ServoStyleSheet::ReparseSheet(const nsAString& aInput)
 {
   // TODO(kuoe0): Bug 1367996 - Need to call document notification
   // (StyleRuleAdded() and StyleRuleRemoved()) like what we do in