diff --git a/layout/style/ServoStyleSet.cpp b/layout/style/ServoStyleSet.cpp index 5c782069e9ff..c9bbd0c44b20 100644 --- a/layout/style/ServoStyleSet.cpp +++ b/layout/style/ServoStyleSet.cpp @@ -263,7 +263,23 @@ nsresult ServoStyleSet::ReplaceSheets(SheetType aType, const nsTArray>& aNewSheets) { - MOZ_CRASH("stylo: not implemented"); + // Gecko uses a two-dimensional array keyed by sheet type, whereas Servo + // stores a flattened list. This makes ReplaceSheets a pretty clunky thing + // to express. If the need ever arises, we can easily make this more efficent, + // probably by aligning the representations better between engines. + + for (ServoStyleSheet* sheet : mSheets[aType]) { + Servo_RemoveStyleSheet(sheet->RawSheet(), mRawSet.get()); + } + + mSheets[aType].Clear(); + mSheets[aType].AppendElements(aNewSheets); + + for (ServoStyleSheet* sheet : mSheets[aType]) { + Servo_AppendStyleSheet(sheet->RawSheet(), mRawSet.get()); + } + + return NS_OK; } nsresult