Issue #2488 - Part 6: Define and declare CSSStyleSheet cast functions directly in StyleSheet

This renames AsGecko calls to AsConcrete and removes the header containing leftover Stylo macros.
This commit is contained in:
FranklinDM 2024-03-29 16:30:12 +08:00 committed by roytam1
commit f0116f51db
18 changed files with 109 additions and 134 deletions

View file

@ -1397,7 +1397,7 @@ PresShell::UpdatePreferenceStyles()
RemovePreferenceStyles();
mStyleSet->AppendStyleSheet(SheetType::User, newPrefSheet->AsGecko());
mStyleSet->AppendStyleSheet(SheetType::User, newPrefSheet->AsConcrete());
mPrefStyleSheet = newPrefSheet;
mStyleSet->EndUpdate();
@ -1407,7 +1407,7 @@ void
PresShell::RemovePreferenceStyles()
{
if (mPrefStyleSheet) {
mStyleSet->RemoveStyleSheet(SheetType::User, mPrefStyleSheet->AsGecko());
mStyleSet->RemoveStyleSheet(SheetType::User, mPrefStyleSheet->AsConcrete());
mPrefStyleSheet = nullptr;
}
}
@ -1430,13 +1430,13 @@ PresShell::AddUserSheet(nsISupports* aSheet)
// Iterate forwards when removing so the searches for RemoveStyleSheet are as
// short as possible.
for (StyleSheet* sheet : userSheets) {
mStyleSet->RemoveStyleSheet(SheetType::User, sheet->AsGecko());
mStyleSet->RemoveStyleSheet(SheetType::User, sheet->AsConcrete());
}
// Now iterate backwards, so that the order of userSheets will be the same as
// the order of sheets from it in the style set.
for (StyleSheet* sheet : Reversed(userSheets)) {
mStyleSet->PrependStyleSheet(SheetType::User, sheet->AsGecko());
mStyleSet->PrependStyleSheet(SheetType::User, sheet->AsConcrete());
}
mStyleSet->EndUpdate();
@ -1454,7 +1454,7 @@ PresShell::AddAgentSheet(nsISupports* aSheet)
return;
}
mStyleSet->AppendStyleSheet(SheetType::Agent, sheet->AsGecko());
mStyleSet->AppendStyleSheet(SheetType::Agent, sheet->AsConcrete());
RestyleForCSSRuleChanges();
}
@ -1471,9 +1471,9 @@ PresShell::AddAuthorSheet(nsISupports* aSheet)
StyleSheet* firstAuthorSheet =
mDocument->GetFirstAdditionalAuthorSheet();
if (firstAuthorSheet) {
mStyleSet->InsertStyleSheetBefore(SheetType::Doc, sheet->AsGecko(), firstAuthorSheet->AsGecko());
mStyleSet->InsertStyleSheetBefore(SheetType::Doc, sheet->AsConcrete(), firstAuthorSheet->AsConcrete());
} else {
mStyleSet->AppendStyleSheet(SheetType::Doc, sheet->AsGecko());
mStyleSet->AppendStyleSheet(SheetType::Doc, sheet->AsConcrete());
}
RestyleForCSSRuleChanges();
@ -1487,7 +1487,7 @@ PresShell::RemoveSheet(SheetType aType, nsISupports* aSheet)
return;
}
mStyleSet->RemoveStyleSheet(aType, sheet->AsGecko());
mStyleSet->RemoveStyleSheet(aType, sheet->AsConcrete());
RestyleForCSSRuleChanges();
}
@ -4471,7 +4471,7 @@ PresShell::RecordStyleSheetChange(StyleSheet* aStyleSheet)
if (mStylesHaveChanged)
return;
Element* scopeElement = aStyleSheet->AsGecko()->GetScopeElement();
Element* scopeElement = aStyleSheet->AsConcrete()->GetScopeElement();
if (scopeElement) {
mChangedScopeStyleRoots.AppendElement(scopeElement);
return;
@ -8771,7 +8771,7 @@ PresShell::SetAgentStyleSheets(const nsTArray<RefPtr<StyleSheet>>& aSheets)
{
nsTArray<RefPtr<CSSStyleSheet>> newSheets(aSheets.Length());
for (auto& sheet : aSheets) {
newSheets.AppendElement(sheet->AsGecko());
newSheets.AppendElement(sheet->AsConcrete());
}
return mStyleSet->ReplaceSheets(SheetType::Agent, newSheets);
}
@ -8779,13 +8779,13 @@ PresShell::SetAgentStyleSheets(const nsTArray<RefPtr<StyleSheet>>& aSheets)
nsresult
PresShell::AddOverrideStyleSheet(StyleSheet* aSheet)
{
return mStyleSet->PrependStyleSheet(SheetType::Override, aSheet->AsGecko());
return mStyleSet->PrependStyleSheet(SheetType::Override, aSheet->AsConcrete());
}
nsresult
PresShell::RemoveOverrideStyleSheet(StyleSheet* aSheet)
{
return mStyleSet->RemoveStyleSheet(SheetType::Override, aSheet->AsGecko());
return mStyleSet->RemoveStyleSheet(SheetType::Override, aSheet->AsConcrete());
}
static void