From 3e1898e9035650c7b8b8adc8774514f855570524 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 21 Dec 2016 15:33:24 -0800 Subject: [PATCH] Bug 1325728 - Use Gecko's existing mechanism to coordinate flushing the Stylist. r=heycam --- layout/style/ServoBindingList.h | 9 +++++---- layout/style/ServoStyleSet.cpp | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/layout/style/ServoBindingList.h b/layout/style/ServoBindingList.h index 22182498afba..a8f1a5bb6d05 100644 --- a/layout/style/ServoBindingList.h +++ b/layout/style/ServoBindingList.h @@ -39,14 +39,15 @@ SERVO_BINDING_FUNC(Servo_StyleSheet_GetRules, ServoCssRulesStrong, SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSetOwned) SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set) SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void, - RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet) + RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet, bool flush) SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void, - RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet) + RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet, bool flush) SERVO_BINDING_FUNC(Servo_StyleSet_RemoveStyleSheet, void, - RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet) + RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet, bool flush) SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void, RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet, - RawServoStyleSheetBorrowed reference) + RawServoStyleSheetBorrowed reference, bool flush) +SERVO_BINDING_FUNC(Servo_StyleSet_FlushStyleSheets, void, RawServoStyleSetBorrowed set) SERVO_BINDING_FUNC(Servo_StyleSet_NoteStyleSheetsChanged, void, RawServoStyleSetBorrowed set) diff --git a/layout/style/ServoStyleSet.cpp b/layout/style/ServoStyleSet.cpp index 68fe19053b55..16bafc99e2c7 100644 --- a/layout/style/ServoStyleSet.cpp +++ b/layout/style/ServoStyleSet.cpp @@ -85,7 +85,7 @@ ServoStyleSet::EndUpdate() return NS_OK; } - // ... do something ... + Servo_StyleSet_FlushStyleSheets(mRawSet.get()); return NS_OK; } @@ -249,7 +249,7 @@ ServoStyleSet::AppendStyleSheet(SheetType aType, mSheets[aType].AppendElement(aSheet); // Maintain a mirrored list of sheets on the servo side. - Servo_StyleSet_AppendStyleSheet(mRawSet.get(), aSheet->RawSheet()); + Servo_StyleSet_AppendStyleSheet(mRawSet.get(), aSheet->RawSheet(), !mBatching); return NS_OK; } @@ -266,7 +266,7 @@ ServoStyleSet::PrependStyleSheet(SheetType aType, mSheets[aType].InsertElementAt(0, aSheet); // Maintain a mirrored list of sheets on the servo side. - Servo_StyleSet_PrependStyleSheet(mRawSet.get(), aSheet->RawSheet()); + Servo_StyleSet_PrependStyleSheet(mRawSet.get(), aSheet->RawSheet(), !mBatching); return NS_OK; } @@ -282,7 +282,7 @@ ServoStyleSet::RemoveStyleSheet(SheetType aType, mSheets[aType].RemoveElement(aSheet); // Maintain a mirrored list of sheets on the servo side. - Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), aSheet->RawSheet()); + Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), aSheet->RawSheet(), !mBatching); return NS_OK; } @@ -297,14 +297,18 @@ ServoStyleSet::ReplaceSheets(SheetType aType, // probably by aligning the representations better between engines. for (ServoStyleSheet* sheet : mSheets[aType]) { - Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), sheet->RawSheet()); + Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), sheet->RawSheet(), false); } mSheets[aType].Clear(); mSheets[aType].AppendElements(aNewSheets); for (ServoStyleSheet* sheet : mSheets[aType]) { - Servo_StyleSet_AppendStyleSheet(mRawSet.get(), sheet->RawSheet()); + Servo_StyleSet_AppendStyleSheet(mRawSet.get(), sheet->RawSheet(), false); + } + + if (!mBatching) { + Servo_StyleSet_FlushStyleSheets(mRawSet.get()); } return NS_OK; @@ -329,7 +333,7 @@ ServoStyleSet::InsertStyleSheetBefore(SheetType aType, // Maintain a mirrored list of sheets on the servo side. Servo_StyleSet_InsertStyleSheetBefore(mRawSet.get(), aNewSheet->RawSheet(), - aReferenceSheet->RawSheet()); + aReferenceSheet->RawSheet(), !mBatching); return NS_OK; } @@ -372,9 +376,9 @@ ServoStyleSet::AddDocStyleSheet(ServoStyleSheet* aSheet, mSheets[SheetType::Doc].SafeElementAt(index + 1); if (followingSheet) { Servo_StyleSet_InsertStyleSheetBefore(mRawSet.get(), aSheet->RawSheet(), - followingSheet->RawSheet()); + followingSheet->RawSheet(), !mBatching); } else { - Servo_StyleSet_AppendStyleSheet(mRawSet.get(), aSheet->RawSheet()); + Servo_StyleSet_AppendStyleSheet(mRawSet.get(), aSheet->RawSheet(), !mBatching); } return NS_OK;