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

@ -1150,7 +1150,7 @@ nsDOMStyleSheetSetList::EnsureFresh()
for (size_t index = 0; index < count; index++) {
StyleSheet* sheet = mDocument->SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
sheet->AsGecko()->GetTitle(title);
sheet->AsConcrete()->GetTitle(title);
if (!title.IsEmpty() && !mNames.Contains(title) && !Add(title)) {
return;
}
@ -2071,7 +2071,7 @@ nsDocument::RemoveDocStyleSheetsFromStyleSets()
if (sheet->IsApplicable()) {
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
shell->StyleSet()->RemoveDocStyleSheet(sheet->AsGecko());
shell->StyleSet()->RemoveDocStyleSheet(sheet->AsConcrete());
}
}
// XXX Tell observers?
@ -2090,7 +2090,7 @@ nsDocument::RemoveStyleSheetsFromStyleSets(
if (sheet->IsApplicable()) {
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
shell->StyleSet()->RemoveStyleSheet(aType, sheet->AsGecko());
shell->StyleSet()->RemoveStyleSheet(aType, sheet->AsConcrete());
}
}
// XXX Tell observers?
@ -2161,7 +2161,7 @@ AppendSheetsToStyleSet(nsStyleSet* aStyleSet,
SheetType aType)
{
for (StyleSheet* sheet : Reversed(aSheets)) {
aStyleSet->AppendStyleSheet(aType, sheet->AsGecko());
aStyleSet->AppendStyleSheet(aType, sheet->AsConcrete());
}
}
@ -2177,21 +2177,21 @@ nsDocument::FillStyleSet(nsStyleSet* aStyleSet)
for (StyleSheet* sheet : Reversed(mStyleSheets)) {
if (sheet->IsApplicable()) {
aStyleSet->AddDocStyleSheet(sheet->AsGecko(), this);
aStyleSet->AddDocStyleSheet(sheet->AsConcrete(), this);
}
}
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
for (StyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet->AsGecko());
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet->AsConcrete());
}
}
// Iterate backwards to maintain order
for (StyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) {
if (sheet->IsApplicable()) {
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet->AsGecko());
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
}
@ -3807,7 +3807,7 @@ nsDocument::AddOnDemandBuiltInUASheet(StyleSheet* aSheet)
// do not override Firefox OS/Mobile's content.css sheet. Maybe we should
// have an insertion point to match the order of
// nsDocumentViewer::CreateStyleSet though?
shell->StyleSet()->PrependStyleSheet(SheetType::Agent, aSheet->AsGecko());
shell->StyleSet()->PrependStyleSheet(SheetType::Agent, aSheet->AsConcrete());
}
}
@ -3819,7 +3819,7 @@ nsDocument::AddStyleSheetToStyleSets(StyleSheet* aSheet)
{
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
shell->StyleSet()->AddDocStyleSheet(aSheet->AsGecko(), this);
shell->StyleSet()->AddDocStyleSheet(aSheet->AsConcrete(), this);
}
}
@ -3828,7 +3828,7 @@ nsDocument::AddStyleSheetToStyleSets(StyleSheet* aSheet)
className##Init init; \
init.mBubbles = true; \
init.mCancelable = true; \
init.mStylesheet = aSheet->AsGecko(); \
init.mStylesheet = aSheet->AsConcrete(); \
init.memberName = argName; \
\
RefPtr<className> event = \
@ -3886,7 +3886,7 @@ nsDocument::RemoveStyleSheetFromStyleSets(StyleSheet* aSheet)
{
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
shell->StyleSet()->RemoveDocStyleSheet(aSheet->AsGecko());
shell->StyleSet()->RemoveDocStyleSheet(aSheet->AsConcrete());
}
}
@ -4102,7 +4102,7 @@ nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, StyleSheet* aShee
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
SheetType type = ConvertAdditionalSheetType(aType);
shell->StyleSet()->AppendStyleSheet(type, aSheet->AsGecko());
shell->StyleSet()->AppendStyleSheet(type, aSheet->AsConcrete());
}
// Passing false, so documet.styleSheets.length will not be affected by
@ -4130,7 +4130,7 @@ nsDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheet
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
SheetType type = ConvertAdditionalSheetType(aType);
shell->StyleSet()->RemoveStyleSheet(type, sheetRef->AsGecko());
shell->StyleSet()->RemoveStyleSheet(type, sheetRef->AsConcrete());
}
}
@ -5598,13 +5598,13 @@ nsIDocument::GetSelectedStyleSheetSet(nsAString& aSheetSet)
NS_ASSERTION(sheet, "Null sheet in sheet list!");
bool disabled;
sheet->AsGecko()->GetDisabled(&disabled);
sheet->AsConcrete()->GetDisabled(&disabled);
if (disabled) {
// Disabled sheets don't affect the currently selected set
continue;
}
sheet->AsGecko()->GetTitle(title);
sheet->AsConcrete()->GetTitle(title);
if (aSheetSet.IsEmpty()) {
aSheetSet = title;
@ -5711,9 +5711,9 @@ nsDocument::EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
StyleSheet* sheet = SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
sheet->AsGecko()->GetTitle(title);
sheet->AsConcrete()->GetTitle(title);
if (!title.IsEmpty()) {
sheet->AsGecko()->SetEnabled(title.Equals(aSheetSet));
sheet->AsConcrete()->SetEnabled(title.Equals(aSheetSet));
}
}
if (aUpdateCSSLoader) {
@ -9434,7 +9434,7 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
if (sheet) {
if (sheet->IsApplicable()) {
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
sheet->AsConcrete()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
@ -9449,7 +9449,7 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
if (sheet) {
if (sheet->IsApplicable()) {
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
sheet->AsConcrete()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {