From e20ac6891219ef8e451faacbb578747a89fdc6b0 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 2 Aug 2016 21:08:01 -0700 Subject: [PATCH] Bug 1291891 - Implement ServoStyleSet::ReplaceSheets. r=emilio --- layout/style/ServoStyleSet.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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