зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1250790 - Don't try to add CSSStyleSheets from the style sheet service to a ServoStyleSet. r=bholley
This commit is contained in:
Родитель
0252199029
Коммит
49f6905565
|
@ -2334,15 +2334,26 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI)
|
|||
MOZ_ASSERT(aURI);
|
||||
|
||||
mozAutoDocUpdate upd(this, UPDATE_STYLE, true);
|
||||
RemoveDocStyleSheetsFromStyleSets();
|
||||
RemoveStyleSheetsFromStyleSets(mOnDemandBuiltInUASheets, SheetType::Agent);
|
||||
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAgentSheet], SheetType::Agent);
|
||||
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eUserSheet], SheetType::User);
|
||||
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAuthorSheet], SheetType::Doc);
|
||||
if (mStyleSetFilled) {
|
||||
// Skip removing style sheets from the style set if we know we haven't
|
||||
// filled the style set. (This allows us to avoid calling
|
||||
// GetStyleBackendType() too early.)
|
||||
RemoveDocStyleSheetsFromStyleSets();
|
||||
RemoveStyleSheetsFromStyleSets(mOnDemandBuiltInUASheets, SheetType::Agent);
|
||||
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAgentSheet], SheetType::Agent);
|
||||
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eUserSheet], SheetType::User);
|
||||
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAuthorSheet], SheetType::Doc);
|
||||
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
RemoveStyleSheetsFromStyleSets(*sheetService->AuthorStyleSheets(), SheetType::Doc);
|
||||
if (GetStyleBackendType() == StyleBackendType::Gecko) {
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
RemoveStyleSheetsFromStyleSets(*sheetService->AuthorStyleSheets(), SheetType::Doc);
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("stylo: nsStyleSheetService doesn't handle ServoStyleSheets yet");
|
||||
}
|
||||
|
||||
mStyleSetFilled = false;
|
||||
}
|
||||
|
||||
// Release all the sheets
|
||||
|
@ -2398,24 +2409,30 @@ nsDocument::FillStyleSet(StyleSetHandle aStyleSet)
|
|||
NS_PRECONDITION(aStyleSet->SheetCount(SheetType::Doc) == 0,
|
||||
"Style set already has document sheets?");
|
||||
|
||||
MOZ_ASSERT(!mStyleSetFilled);
|
||||
|
||||
for (StyleSheetHandle sheet : Reversed(mStyleSheets)) {
|
||||
if (sheet->IsApplicable()) {
|
||||
aStyleSet->AddDocStyleSheet(sheet, this);
|
||||
}
|
||||
}
|
||||
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
for (StyleSheetHandle sheet : *sheetService->AuthorStyleSheets()) {
|
||||
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet);
|
||||
if (aStyleSet->IsGecko()) {
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
for (StyleSheetHandle sheet : *sheetService->AuthorStyleSheets()) {
|
||||
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate backwards to maintain order
|
||||
for (StyleSheetHandle sheet : Reversed(mOnDemandBuiltInUASheets)) {
|
||||
if (sheet->IsApplicable()) {
|
||||
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
// Iterate backwards to maintain order
|
||||
for (StyleSheetHandle sheet : Reversed(mOnDemandBuiltInUASheets)) {
|
||||
if (sheet->IsApplicable()) {
|
||||
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("stylo: nsStyleSheetService doesn't handle ServoStyleSheets yet");
|
||||
}
|
||||
|
||||
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eAgentSheet],
|
||||
|
@ -2424,6 +2441,8 @@ nsDocument::FillStyleSet(StyleSetHandle aStyleSet)
|
|||
SheetType::User);
|
||||
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eAuthorSheet],
|
||||
SheetType::Doc);
|
||||
|
||||
mStyleSetFilled = true;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -3858,6 +3877,7 @@ nsDocument::DeleteShell()
|
|||
RebuildUserFontSet();
|
||||
|
||||
mPresShell = nullptr;
|
||||
mStyleSetFilled = false;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1682,6 +1682,10 @@ public:
|
|||
// that we only report them once for the document.
|
||||
bool mReportedUseCounters:1;
|
||||
|
||||
// Whether we have filled our pres shell's style set with the document's
|
||||
// additional sheets and sheets from the nsStyleSheetService.
|
||||
bool mStyleSetFilled:1;
|
||||
|
||||
uint8_t mPendingFullscreenRequests;
|
||||
|
||||
uint8_t mXMLDeclarationBits;
|
||||
|
|
|
@ -2339,14 +2339,18 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
|||
}
|
||||
}
|
||||
|
||||
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
for (StyleSheetHandle sheet : *sheetService->AgentStyleSheets()) {
|
||||
styleSet->AppendStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
for (StyleSheetHandle sheet : Reversed(*sheetService->UserStyleSheets())) {
|
||||
styleSet->PrependStyleSheet(SheetType::User, sheet);
|
||||
if (styleSet->IsGecko()) {
|
||||
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
for (StyleSheetHandle sheet : *sheetService->AgentStyleSheets()) {
|
||||
styleSet->AppendStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
for (StyleSheetHandle sheet : Reversed(*sheetService->UserStyleSheets())) {
|
||||
styleSet->PrependStyleSheet(SheetType::User, sheet);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("stylo: nsStyleSheetService doesn't handle ServoStyleSheets yet");
|
||||
}
|
||||
|
||||
// Caller will handle calling EndUpdate, per contract.
|
||||
|
|
|
@ -1404,6 +1404,11 @@ PresShell::RemovePreferenceStyles()
|
|||
void
|
||||
PresShell::AddUserSheet(nsISupports* aSheet)
|
||||
{
|
||||
if (mStyleSet->IsServo()) {
|
||||
NS_ERROR("stylo: nsStyleSheetService doesn't handle ServoStyleSheets yet");
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure this does what nsDocumentViewer::CreateStyleSet does wrt
|
||||
// ordering. We want this new sheet to come after all the existing stylesheet
|
||||
// service sheets, but before other user sheets; see nsIStyleSheetService.idl
|
||||
|
|
Загрузка…
Ссылка в новой задаче