mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 287389: SVG should not munge ua.css at build time. r+sr=bzbarsky
This commit is contained in:
parent
8a1c410a8c
commit
4ed8801383
@ -421,6 +421,7 @@ public:
|
||||
virtual PRInt32 GetNumberOfCatalogStyleSheets() const = 0;
|
||||
virtual nsIStyleSheet* GetCatalogStyleSheetAt(PRInt32 aIndex) const = 0;
|
||||
virtual void AddCatalogStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI) = 0;
|
||||
|
||||
/**
|
||||
* Get this document's CSSLoader. May return null in error
|
||||
|
@ -1750,6 +1750,40 @@ nsDocument::AddCatalogStyleSheet(nsIStyleSheet* aSheet)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::EnsureCatalogStyleSheet(const char *aStyleSheetURI)
|
||||
{
|
||||
nsICSSLoader* cssLoader = GetCSSLoader();
|
||||
PRBool enabled;
|
||||
if (cssLoader && NS_SUCCEEDED(cssLoader->GetEnabled(&enabled)) && enabled) {
|
||||
PRInt32 sheetCount = GetNumberOfCatalogStyleSheets();
|
||||
for (PRInt32 i = 0; i < sheetCount; i++) {
|
||||
nsIStyleSheet* sheet = GetCatalogStyleSheetAt(i);
|
||||
NS_ASSERTION(sheet, "unexpected null stylesheet in the document");
|
||||
if (sheet) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
sheet->GetSheetURI(getter_AddRefs(uri));
|
||||
nsCAutoString uriStr;
|
||||
uri->GetSpec(uriStr);
|
||||
if (uriStr.Equals(aStyleSheetURI))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), aStyleSheetURI);
|
||||
if (uri) {
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
cssLoader->LoadAgentSheet(uri, getter_AddRefs(sheet));
|
||||
if (sheet) {
|
||||
BeginUpdate(UPDATE_STYLE);
|
||||
AddCatalogStyleSheet(sheet);
|
||||
EndUpdate(UPDATE_STYLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsIScriptGlobalObject*
|
||||
nsDocument::GetScriptGlobalObject() const
|
||||
{
|
||||
|
@ -323,6 +323,7 @@ public:
|
||||
virtual PRInt32 GetNumberOfCatalogStyleSheets() const;
|
||||
virtual nsIStyleSheet* GetCatalogStyleSheetAt(PRInt32 aIndex) const;
|
||||
virtual void AddCatalogStyleSheet(nsIStyleSheet* aSheet);
|
||||
virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -136,6 +136,13 @@ NS_NewSVGElement(nsIContent** aResult, nsINodeInfo *aNodeInfo)
|
||||
if (!SVGEnabled())
|
||||
return NS_NewXMLElement(aResult, aNodeInfo);
|
||||
|
||||
static const char kSVGStyleSheetURI[] = "resource://gre/res/svg.css";
|
||||
|
||||
// this bit of code is to load svg.css on demand
|
||||
nsIDocument* doc = nsContentUtils::GetDocument(aNodeInfo);
|
||||
if (doc)
|
||||
doc->EnsureCatalogStyleSheet(kSVGStyleSheetURI);
|
||||
|
||||
nsIAtom *name = aNodeInfo->NameAtom();
|
||||
|
||||
if (name == nsSVGAtoms::polyline)
|
||||
|
@ -833,47 +833,8 @@ NS_NewMathMLElement(nsIContent** aResult, nsINodeInfo* aNodeInfo)
|
||||
|
||||
// this bit of code is to load mathml.css on demand
|
||||
nsIDocument* doc = nsContentUtils::GetDocument(aNodeInfo);
|
||||
if (doc) {
|
||||
nsICSSLoader* cssLoader = doc->GetCSSLoader();
|
||||
PRBool enabled;
|
||||
if (cssLoader && NS_SUCCEEDED(cssLoader->GetEnabled(&enabled)) && enabled) {
|
||||
PRBool alreadyLoaded = PR_FALSE;
|
||||
PRInt32 sheetCount = doc->GetNumberOfCatalogStyleSheets();
|
||||
for (PRInt32 i = 0; i < sheetCount; i++) {
|
||||
nsIStyleSheet* sheet = doc->GetCatalogStyleSheetAt(i);
|
||||
NS_ASSERTION(sheet, "unexpected null stylesheet in the document");
|
||||
if (sheet) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
sheet->GetSheetURI(getter_AddRefs(uri));
|
||||
nsCAutoString uriStr;
|
||||
uri->GetSpec(uriStr);
|
||||
if (uriStr.Equals(kMathMLStyleSheetURI)) {
|
||||
alreadyLoaded = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!alreadyLoaded) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), kMathMLStyleSheetURI);
|
||||
if (uri) {
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
cssLoader->LoadAgentSheet(uri, getter_AddRefs(sheet));
|
||||
#ifdef NS_DEBUG
|
||||
nsCAutoString uriStr;
|
||||
uri->GetSpec(uriStr);
|
||||
printf("MathML Factory: loading catalog stylesheet: %s ... %s\n", uriStr.get(), sheet.get() ? "Done" : "Failed");
|
||||
NS_ASSERTION(uriStr.Equals(kMathMLStyleSheetURI), "resolved URI unexpected");
|
||||
#endif
|
||||
if (sheet) {
|
||||
doc->BeginUpdate(UPDATE_STYLE);
|
||||
doc->AddCatalogStyleSheet(sheet);
|
||||
doc->EndUpdate(UPDATE_STYLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (doc)
|
||||
doc->EnsureCatalogStyleSheet(kMathMLStyleSheetURI);
|
||||
|
||||
return NS_NewXMLElement(aResult, aNodeInfo);
|
||||
}
|
||||
|
@ -113,7 +113,6 @@ libs::
|
||||
$(INSTALL) $(EXPORT_RESOURCE_CONTENT) $(DIST)/bin/res/dtd
|
||||
$(INSTALL) $(srcdir)/svg.css $(DIST)/bin/res
|
||||
$(INSTALL) $(srcdir)/svg.properties $(DIST)/bin/res
|
||||
$(PERL) $(srcdir)/install-svg-css.pl $(DIST)/bin/res/ua.css
|
||||
|
||||
install::
|
||||
$(SYSINSTALL) $(IFLAGS1) $(EXPORT_RESOURCE_CONTENT) $(DESTDIR)$(mozappdir)/res/dtd
|
||||
|
Loading…
Reference in New Issue
Block a user