Bug 1361843 part 3. Clear the stylist when styleshets change, but don't do anything else until there's an explicit sheet flush. r?emilio
MozReview-Commit-ID: IhK1ECeuYbM
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -47,33 +47,29 @@ SERVO_BINDING_FUNC(Servo_StyleSheet_GetR
RawServoStyleSheetBorrowed sheet)
SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSetOwned, RawGeckoPresContextOwned pres_context)
SERVO_BINDING_FUNC(Servo_StyleSet_RebuildData, void,
RawServoStyleSetBorrowed set)
SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set)
SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void,
RawServoStyleSetBorrowed set,
RawServoStyleSheetBorrowed sheet,
- uint32_t unique_id,
- bool flush)
+ uint32_t unique_id)
SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void,
RawServoStyleSetBorrowed set,
RawServoStyleSheetBorrowed sheet,
- uint32_t unique_id,
- bool flush)
+ uint32_t unique_id)
SERVO_BINDING_FUNC(Servo_StyleSet_RemoveStyleSheet, void,
RawServoStyleSetBorrowed set,
- uint32_t unique_id,
- bool flush)
+ uint32_t unique_id)
SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void,
RawServoStyleSetBorrowed set,
RawServoStyleSheetBorrowed sheet,
uint32_t unique_id,
- uint32_t before_unique_id,
- bool flush)
+ uint32_t before_unique_id)
SERVO_BINDING_FUNC(Servo_StyleSet_FlushStyleSheets, void, RawServoStyleSetBorrowed set)
SERVO_BINDING_FUNC(Servo_StyleSet_NoteStyleSheetsChanged, void,
RawServoStyleSetBorrowed set, bool author_style_disabled)
SERVO_BINDING_FUNC(Servo_StyleSet_FillKeyframesForName, bool,
RawServoStyleSetBorrowed set,
const nsACString* property,
nsTimingFunctionBorrowed timing_function,
ServoComputedValuesBorrowed computed_values,
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -62,18 +62,17 @@ ServoStyleSet::Init(nsPresContext* aPres
// type, which this preserves.
// Set the uniqueIDs as we go.
entry.uniqueID = ++mUniqueIDCounter;
MOZ_ASSERT(entry.sheet->RawSheet(), "We should only append non-null raw sheets.");
Servo_StyleSet_AppendStyleSheet(mRawSet.get(),
entry.sheet->RawSheet(),
- entry.uniqueID,
- false);
+ entry.uniqueID);
}
}
// No need to Servo_StyleSet_FlushStyleSheets because we just created the
// mRawSet, so there was nothing to flush.
}
void
@@ -167,22 +166,17 @@ ServoStyleSet::BeginUpdate()
{
++mBatching;
}
nsresult
ServoStyleSet::EndUpdate()
{
MOZ_ASSERT(mBatching > 0);
- if (--mBatching > 0) {
- return NS_OK;
- }
-
- Servo_StyleSet_FlushStyleSheets(mRawSet.get());
- mStylistMayNeedRebuild = false;
+ --mBatching;
return NS_OK;
}
already_AddRefed<nsStyleContext>
ServoStyleSet::ResolveStyleFor(Element* aElement,
nsStyleContext* aParentContext,
LazyComputeBehavior aMayCompute)
{
@@ -571,18 +565,17 @@ ServoStyleSet::AppendStyleSheet(SheetTyp
// original position as part of the call to Servo_StyleSet_AppendStyleSheet.
uint32_t oldUniqueID = RemoveSheetOfType(aType, aSheet);
uint32_t newUniqueID = AppendSheetOfType(aType, aSheet, oldUniqueID);
if (mRawSet) {
// Maintain a mirrored list of sheets on the servo side.
Servo_StyleSet_AppendStyleSheet(mRawSet.get(),
aSheet->RawSheet(),
- newUniqueID,
- !mBatching);
+ newUniqueID);
mStylistMayNeedRebuild = true;
}
return NS_OK;
}
nsresult
ServoStyleSet::PrependStyleSheet(SheetType aType,
@@ -598,35 +591,34 @@ ServoStyleSet::PrependStyleSheet(SheetTy
// original position as part of the call to Servo_StyleSet_PrependStyleSheet.
uint32_t oldUniqueID = RemoveSheetOfType(aType, aSheet);
uint32_t newUniqueID = PrependSheetOfType(aType, aSheet, oldUniqueID);
if (mRawSet) {
// Maintain a mirrored list of sheets on the servo side.
Servo_StyleSet_PrependStyleSheet(mRawSet.get(),
aSheet->RawSheet(),
- newUniqueID,
- !mBatching);
+ newUniqueID);
mStylistMayNeedRebuild = true;
}
return NS_OK;
}
nsresult
ServoStyleSet::RemoveStyleSheet(SheetType aType,
ServoStyleSheet* aSheet)
{
MOZ_ASSERT(aSheet);
MOZ_ASSERT(nsStyleSet::IsCSSSheetType(aType));
uint32_t uniqueID = RemoveSheetOfType(aType, aSheet);
if (mRawSet && uniqueID) {
// Maintain a mirrored list of sheets on the servo side.
- Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), uniqueID, !mBatching);
+ Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), uniqueID);
mStylistMayNeedRebuild = true;
}
return NS_OK;
}
nsresult
ServoStyleSet::ReplaceSheets(SheetType aType,
@@ -637,38 +629,32 @@ ServoStyleSet::ReplaceSheets(SheetType a
// to express. If the need ever arises, we can easily make this more efficent,
// probably by aligning the representations better between engines.
mStylistMayNeedRebuild = true;
// Remove all the existing sheets first.
if (mRawSet) {
for (const Entry& entry : mEntries[aType]) {
- Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), entry.uniqueID, false);
+ Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), entry.uniqueID);
}
}
mEntries[aType].Clear();
// Add in all the new sheets.
for (auto& sheet : aNewSheets) {
uint32_t uniqueID = AppendSheetOfType(aType, sheet);
if (mRawSet) {
MOZ_ASSERT(sheet->RawSheet(), "Raw sheet should be in place before replacement.");
Servo_StyleSet_AppendStyleSheet(mRawSet.get(),
sheet->RawSheet(),
- uniqueID,
- false);
+ uniqueID);
}
}
- if (!mBatching) {
- Servo_StyleSet_FlushStyleSheets(mRawSet.get());
- mStylistMayNeedRebuild = false;
- }
-
return NS_OK;
}
nsresult
ServoStyleSet::InsertStyleSheetBefore(SheetType aType,
ServoStyleSheet* aNewSheet,
ServoStyleSheet* aReferenceSheet)
{
@@ -693,18 +679,17 @@ ServoStyleSet::InsertStyleSheetBefore(Sh
beforeUniqueID,
oldUniqueID);
if (mRawSet) {
// Maintain a mirrored list of sheets on the servo side.
Servo_StyleSet_InsertStyleSheetBefore(mRawSet.get(),
aNewSheet->RawSheet(),
newUniqueID,
- beforeUniqueID,
- !mBatching);
+ beforeUniqueID);
mStylistMayNeedRebuild = true;
}
return NS_OK;
}
int32_t
ServoStyleSet::SheetCount(SheetType aType) const
@@ -749,32 +734,30 @@ ServoStyleSet::AddDocStyleSheet(ServoSty
beforeUniqueID,
oldUniqueID);
if (mRawSet) {
// Maintain a mirrored list of sheets on the servo side.
Servo_StyleSet_InsertStyleSheetBefore(mRawSet.get(),
aSheet->RawSheet(),
newUniqueID,
- beforeUniqueID,
- !mBatching);
+ beforeUniqueID);
mStylistMayNeedRebuild = true;
}
} else {
// This case is append.
uint32_t newUniqueID = AppendSheetOfType(SheetType::Doc,
aSheet,
oldUniqueID);
if (mRawSet) {
// Maintain a mirrored list of sheets on the servo side.
Servo_StyleSet_AppendStyleSheet(mRawSet.get(),
aSheet->RawSheet(),
- newUniqueID,
- !mBatching);
+ newUniqueID);
mStylistMayNeedRebuild = true;
}
}
return NS_OK;
}
already_AddRefed<nsStyleContext>
@@ -904,20 +887,16 @@ ServoStyleSet::StyleSubtreeForReconstruc
MOZ_ASSERT(!postTraversalRequired);
}
void
ServoStyleSet::NoteStyleSheetsChanged()
{
mStylistMayNeedRebuild = true;
Servo_StyleSet_NoteStyleSheetsChanged(mRawSet.get(), mAuthorStyleDisabled);
- if (!mBatching) {
- Servo_StyleSet_FlushStyleSheets(mRawSet.get());
- mStylistMayNeedRebuild = false;
- }
}
#ifdef DEBUG
void
ServoStyleSet::AssertTreeIsClean()
{
DocumentStyleRootIterator iter(mPresContext->Document());
while (Element* root = iter.GetNextStyleRoot()) {