Issue #2112 - Part 5: Remove Servo from forwarding code used by magic pointer classes

This commit is contained in:
FranklinDM 2024-03-25 02:02:08 +08:00 committed by roytam1
commit a93a7bed47
52 changed files with 274 additions and 1116 deletions

View file

@ -1153,10 +1153,6 @@ nsDOMStyleSheetSetList::EnsureFresh()
StyleSheet* sheet = mDocument->SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
// XXXheycam ServoStyleSheets don't expose their title yet.
if (sheet->IsServo()) {
NS_ERROR("stylo: ServoStyleSets don't expose their title yet");
continue;
}
sheet->AsGecko()->GetTitle(title);
if (!title.IsEmpty() && !mNames.Contains(title) && !Add(title)) {
return;
@ -2193,23 +2189,18 @@ nsDocument::FillStyleSet(StyleSetHandle aStyleSet)
}
}
if (aStyleSet->IsGecko()) {
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
for (StyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet);
}
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
for (StyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet);
}
}
// Iterate backwards to maintain order
for (StyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) {
if (sheet->IsApplicable()) {
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
}
// Iterate backwards to maintain order
for (StyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) {
if (sheet->IsApplicable()) {
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
}
} else {
NS_WARNING("stylo: Not yet checking nsStyleSheetService for Servo-backed "
"documents. See bug 1290224");
}
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eAgentSheet],
@ -3850,11 +3841,7 @@ nsDocument::AddStyleSheetToStyleSets(StyleSheet* aSheet)
className##Init init; \
init.mBubbles = true; \
init.mCancelable = true; \
/* XXXheycam ServoStyleSheet doesn't implement DOM interfaces yet */ \
if (aSheet->IsServo()) { \
NS_ERROR("stylo: can't dispatch events for ServoStyleSheets yet"); \
} \
init.mStylesheet = aSheet->IsGecko() ? aSheet->AsGecko() : nullptr; \
init.mStylesheet = aSheet->AsGecko(); \
init.memberName = argName; \
\
RefPtr<className> event = \
@ -5623,12 +5610,6 @@ nsIDocument::GetSelectedStyleSheetSet(nsAString& aSheetSet)
StyleSheet* sheet = SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
// XXXheycam Make this work with ServoStyleSheets.
if (sheet->IsServo()) {
NS_ERROR("stylo: can't handle alternate ServoStyleSheets yet");
continue;
}
bool disabled;
sheet->AsGecko()->GetDisabled(&disabled);
if (disabled) {
@ -5743,12 +5724,6 @@ nsDocument::EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
StyleSheet* sheet = SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
// XXXheycam Make this work with ServoStyleSheets.
if (sheet->IsServo()) {
NS_ERROR("stylo: can't handle alternate ServoStyleSheets yet");
continue;
}
sheet->AsGecko()->GetTitle(title);
if (!title.IsEmpty()) {
sheet->AsGecko()->SetEnabled(title.Equals(aSheetSet));
@ -9471,17 +9446,12 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
RefPtr<StyleSheet> sheet = SheetAt(i);
if (sheet) {
if (sheet->IsApplicable()) {
// XXXheycam Need to make ServoStyleSheet cloning work.
if (sheet->IsGecko()) {
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
clonedDoc->AddStyleSheet(clonedSheet);
}
} else {
NS_ERROR("stylo: ServoStyleSheet doesn't support cloning");
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
clonedDoc->AddStyleSheet(clonedSheet);
}
}
}
@ -9491,17 +9461,12 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
for (StyleSheet* sheet : Reversed(thisAsDoc->mOnDemandBuiltInUASheets)) {
if (sheet) {
if (sheet->IsApplicable()) {
// XXXheycam Need to make ServoStyleSheet cloning work.
if (sheet->IsGecko()) {
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
clonedDoc->AddOnDemandBuiltInUASheet(clonedSheet);
}
} else {
NS_ERROR("stylo: ServoStyleSheet doesn't support cloning");
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
clonedDoc->AddOnDemandBuiltInUASheet(clonedSheet);
}
}
}
@ -12203,14 +12168,8 @@ nsIDocument::FlushUserFontSet()
nsTArray<nsFontFaceRuleContainer> rules;
nsIPresShell* shell = GetShell();
if (shell) {
// XXXheycam ServoStyleSets don't support exposing @font-face rules yet.
if (shell->StyleSet()->IsGecko()) {
if (!shell->StyleSet()->AsGecko()->AppendFontFaceRules(rules)) {
return;
}
} else {
NS_WARNING("stylo: ServoStyleSets cannot handle @font-face rules yet. "
"See bug 1290237.");
if (!shell->StyleSet()->AsGecko()->AppendFontFaceRules(rules)) {
return;
}
}