зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1545699 - Don't sync-reload chrome:// user-agent stylesheets from nsChromeRegistry. r=bzbarsky
We assume in a bunch of other places that user agent stylesheets don't really change dynamically. It's not clear to me what this code is trying to accomplish or how is it supposed to work in a multi-process world, but I've left the author stylesheets code for now... Also, I'm pretty sure the styleset doesn't handle null sheets, so add a null-check to the author stylesheets. Differential Revision: https://phabricator.services.mozilla.com/D28211
This commit is contained in:
Родитель
b0e5ec67f3
Коммит
074dccfbba
|
@ -339,42 +339,10 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow) {
|
|||
RefreshWindow(piWindow);
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
// Get the document.
|
||||
RefPtr<Document> document = aWindow->GetDoc();
|
||||
if (!document) return NS_OK;
|
||||
|
||||
// Deal with the agent sheets first. Have to do all the style sets by hand.
|
||||
RefPtr<PresShell> presShell = document->GetPresShell();
|
||||
if (presShell) {
|
||||
// Reload only the chrome URL agent style sheets.
|
||||
nsTArray<RefPtr<StyleSheet>> agentSheets;
|
||||
rv = presShell->GetAgentStyleSheets(agentSheets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsTArray<RefPtr<StyleSheet>> newAgentSheets;
|
||||
for (StyleSheet* sheet : agentSheets) {
|
||||
nsIURI* uri = sheet->GetSheetURI();
|
||||
|
||||
if (IsChromeURI(uri)) {
|
||||
// Reload the sheet.
|
||||
RefPtr<StyleSheet> newSheet;
|
||||
rv = document->LoadChromeSheetSync(uri, true, &newSheet);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (newSheet) {
|
||||
newAgentSheets.AppendElement(newSheet);
|
||||
return NS_OK;
|
||||
}
|
||||
} else { // Just use the same sheet.
|
||||
rv = newAgentSheets.AppendElement(sheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
||||
rv = presShell->SetAgentStyleSheets(newAgentSheets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
size_t count = document->SheetCount();
|
||||
|
||||
// Build an array of style sheets we need to reload.
|
||||
|
@ -389,6 +357,9 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow) {
|
|||
|
||||
// Iterate over our old sheets and kick off a sync load of the new
|
||||
// sheet if and only if it's a non-inline sheet with a chrome URL.
|
||||
//
|
||||
// FIXME(emilio): What about user sheets? Also, does this do anything useful
|
||||
// anymore?
|
||||
for (StyleSheet* sheet : oldSheets) {
|
||||
MOZ_ASSERT(sheet,
|
||||
"SheetAt shouldn't return nullptr for "
|
||||
|
@ -397,12 +368,11 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow) {
|
|||
|
||||
if (!sheet->IsInline() && IsChromeURI(uri)) {
|
||||
// Reload the sheet.
|
||||
RefPtr<StyleSheet> newSheet;
|
||||
// XXX what about chrome sheets that have a title or are disabled? This
|
||||
// only works by sheer dumb luck.
|
||||
document->LoadChromeSheetSync(uri, false, &newSheet);
|
||||
// Even if it's null, we put in in there.
|
||||
newSheets.AppendElement(newSheet);
|
||||
if (RefPtr<StyleSheet> newSheet = document->LoadChromeSheetSync(uri)) {
|
||||
newSheets.AppendElement(newSheet);
|
||||
}
|
||||
} else {
|
||||
// Just use the same sheet.
|
||||
newSheets.AppendElement(sheet);
|
||||
|
|
|
@ -8747,11 +8747,10 @@ void Document::PreloadStyle(
|
|||
aReferrerPolicy, aIntegrity);
|
||||
}
|
||||
|
||||
nsresult Document::LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet,
|
||||
RefPtr<mozilla::StyleSheet>* aSheet) {
|
||||
css::SheetParsingMode mode =
|
||||
isAgentSheet ? css::eAgentSheetFeatures : css::eAuthorSheetFeatures;
|
||||
return CSSLoader()->LoadSheetSync(uri, mode, isAgentSheet, aSheet);
|
||||
RefPtr<StyleSheet> Document::LoadChromeSheetSync(nsIURI* uri) {
|
||||
RefPtr<StyleSheet> sheet;
|
||||
CSSLoader()->LoadSheetSync(uri, css::eAuthorSheetFeatures, false, &sheet);
|
||||
return sheet;
|
||||
}
|
||||
|
||||
void Document::ResetDocumentDirection() {
|
||||
|
|
|
@ -2853,9 +2853,8 @@ class Document : public nsINode,
|
|||
void ForgetImagePreload(nsIURI* aURI);
|
||||
|
||||
/**
|
||||
* Called by nsParser to preload style sheets. Can also be merged into the
|
||||
* parser if and when the parser is merged with libgklayout. aCrossOriginAttr
|
||||
* should be a void string if the attr is not present.
|
||||
* Called by nsParser to preload style sheets. aCrossOriginAttr should be a
|
||||
* void string if the attr is not present.
|
||||
*/
|
||||
void PreloadStyle(nsIURI* aURI, const Encoding* aEncoding,
|
||||
const nsAString& aCrossOriginAttr,
|
||||
|
@ -2863,15 +2862,11 @@ class Document : public nsINode,
|
|||
const nsAString& aIntegrity);
|
||||
|
||||
/**
|
||||
* Called by the chrome registry to load style sheets. Can be put
|
||||
* back there if and when when that module is merged with libgklayout.
|
||||
* Called by the chrome registry to load style sheets.
|
||||
*
|
||||
* This always does a synchronous load. If aIsAgentSheet is true,
|
||||
* it also uses the system principal and enables unsafe rules.
|
||||
* DO NOT USE FOR UNTRUSTED CONTENT.
|
||||
* This always does a synchronous load, and parses as a normal document sheet.
|
||||
*/
|
||||
nsresult LoadChromeSheetSync(nsIURI* aURI, bool aIsAgentSheet,
|
||||
RefPtr<StyleSheet>* aSheet);
|
||||
RefPtr<StyleSheet> LoadChromeSheetSync(nsIURI* aURI);
|
||||
|
||||
/**
|
||||
* Returns true if the locale used for the document specifies a direction of
|
||||
|
|
Загрузка…
Ссылка в новой задаче