Bug 1348481 Part 3: Fix a dangerous typo in StyleSetHandleInlines (replaced one variable with another) and add assert to catch the problem it created. draft
authorBrad Werth <bwerth@mozilla.com>
Tue, 18 Apr 2017 11:29:13 -0700
changeset 571472 c3d54f057c6f9068b2696bae7224f15697610a27
parent 571471 de49cdb244f63a10c8608bf293cf3a7419921484
child 571473 c7e09b7df5e31a7c904fe3d77e88334d2e90aaf1
push id56805
push userbwerth@mozilla.com
push dateTue, 02 May 2017 18:03:06 +0000
bugs1348481
milestone55.0a1
Bug 1348481 Part 3: Fix a dangerous typo in StyleSetHandleInlines (replaced one variable with another) and add assert to catch the problem it created. MozReview-Commit-ID: L2tfMt7TM60
layout/style/ServoStyleSet.cpp
layout/style/StyleSetHandleInlines.h
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -655,16 +655,17 @@ ServoStyleSet::ReplaceSheets(SheetType a
 nsresult
 ServoStyleSet::InsertStyleSheetBefore(SheetType aType,
                                       ServoStyleSheet* aNewSheet,
                                       ServoStyleSheet* aReferenceSheet)
 {
   MOZ_ASSERT(aNewSheet);
   MOZ_ASSERT(aReferenceSheet);
   MOZ_ASSERT(aNewSheet->IsApplicable());
+  MOZ_ASSERT(aNewSheet != aReferenceSheet, "Can't place sheet before itself.");
   MOZ_ASSERT(aNewSheet->RawSheet(), "Raw sheet should be in place before insertion.");
   MOZ_ASSERT(aReferenceSheet->RawSheet(), "Reference sheet should have a raw sheet.");
 
   uint32_t beforeUniqueID = FindSheetOfType(aType, aReferenceSheet);
   if (beforeUniqueID == 0) {
     return NS_ERROR_INVALID_ARG;
   }
 
--- a/layout/style/StyleSetHandleInlines.h
+++ b/layout/style/StyleSetHandleInlines.h
@@ -180,17 +180,17 @@ StyleSetHandle::Ptr::ReplaceSheets(Sheet
 nsresult
 StyleSetHandle::Ptr::InsertStyleSheetBefore(SheetType aType,
                                 StyleSheet* aNewSheet,
                                 StyleSheet* aReferenceSheet)
 {
   FORWARD_CONCRETE(
     InsertStyleSheetBefore,
     (aType, aNewSheet->AsGecko(), aReferenceSheet->AsGecko()),
-    (aType, aReferenceSheet->AsServo(), aReferenceSheet->AsServo()));
+    (aType, aNewSheet->AsServo(), aReferenceSheet->AsServo()));
 }
 
 int32_t
 StyleSetHandle::Ptr::SheetCount(SheetType aType) const
 {
   FORWARD(SheetCount, (aType));
 }