diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index 3b02507bb98..18e44abdb85 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -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 diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index fd368b27eb6..d93d0c201c1 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -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 uri; + sheet->GetSheetURI(getter_AddRefs(uri)); + nsCAutoString uriStr; + uri->GetSpec(uriStr); + if (uriStr.Equals(aStyleSheetURI)) + return; + } + } + + nsCOMPtr uri; + NS_NewURI(getter_AddRefs(uri), aStyleSheetURI); + if (uri) { + nsCOMPtr sheet; + cssLoader->LoadAgentSheet(uri, getter_AddRefs(sheet)); + if (sheet) { + BeginUpdate(UPDATE_STYLE); + AddCatalogStyleSheet(sheet); + EndUpdate(UPDATE_STYLE); + } + } + } +} + nsIScriptGlobalObject* nsDocument::GetScriptGlobalObject() const { diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index 244f1ccc55a..0350a960107 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -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); /** diff --git a/mozilla/content/svg/content/src/nsSVGElementFactory.cpp b/mozilla/content/svg/content/src/nsSVGElementFactory.cpp index 6adb8c97870..c78098c62e4 100644 --- a/mozilla/content/svg/content/src/nsSVGElementFactory.cpp +++ b/mozilla/content/svg/content/src/nsSVGElementFactory.cpp @@ -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) diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 648aded5e3b..d60e6530a26 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -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 uri; - sheet->GetSheetURI(getter_AddRefs(uri)); - nsCAutoString uriStr; - uri->GetSpec(uriStr); - if (uriStr.Equals(kMathMLStyleSheetURI)) { - alreadyLoaded = PR_TRUE; - break; - } - } - } - if (!alreadyLoaded) { - nsCOMPtr uri; - NS_NewURI(getter_AddRefs(uri), kMathMLStyleSheetURI); - if (uri) { - nsCOMPtr 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); } diff --git a/mozilla/layout/svg/base/src/Makefile.in b/mozilla/layout/svg/base/src/Makefile.in index d4f53b5e32d..1dafcd6e176 100644 --- a/mozilla/layout/svg/base/src/Makefile.in +++ b/mozilla/layout/svg/base/src/Makefile.in @@ -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