Bug 1348481 Part 4: Fix a dangerous typo in StyleSetInlines (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 564605 9276a9858a83f3e4d3a61006a81c0c6504ac3586
parent 564604 a19649338666e483dd14773fb2cf9f3783db22c2
child 564606 c8f75efe7840790905301626bb88346b12b1ba6a
push id54663
push userbwerth@mozilla.com
push dateTue, 18 Apr 2017 20:47:30 +0000
bugs1348481
milestone55.0a1
Bug 1348481 Part 4: Fix a dangerous typo in StyleSetInlines (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
@@ -638,16 +638,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.");
 
   size_t idx = FindLocalIndexOfSheetOfType(aReferenceSheet, aType);
   if (idx == NO_RAW_INDEX) {
     return NS_ERROR_INVALID_ARG;
   }
   size_t referenceRawIndex = mSheets[aType][idx].rawIndex;
   size_t oldRawIndex = RemoveSheetOfType(aNewSheet, aType);
 
--- a/layout/style/StyleSetHandleInlines.h
+++ b/layout/style/StyleSetHandleInlines.h
@@ -183,17 +183,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));
 }