Bug 258511 - preference to disable native SVG support. r=bzbarsky, sr=roc

This commit is contained in:
tor%cs.brown.edu 2005-02-21 18:11:18 +00:00
Родитель 8640af79b5
Коммит a0375d13dc
7 изменённых файлов: 99 добавлений и 20 удалений

Просмотреть файл

@ -41,7 +41,8 @@
#include "nsIAtom.h"
#include "nsINodeInfo.h"
#include "nsSVGAtoms.h"
#include "nsContentDLF.h"
#include "nsContentUtils.h"
nsresult
NS_NewSVGPolylineElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
@ -96,9 +97,45 @@ NS_NewSVGTitleElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
nsresult
NS_NewSVGClipPathElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
static PRBool gSVGEnabled;
static const char SVG_PREF_STR[] = "svg.enabled";
PR_STATIC_CALLBACK(int)
SVGPrefChanged(const char *aPref, void *aClosure)
{
PRBool prefVal = nsContentUtils::GetBoolPref(SVG_PREF_STR);
if (prefVal == gSVGEnabled)
return 0;
gSVGEnabled = prefVal;
if (gSVGEnabled)
nsContentDLF::RegisterSVG();
else
nsContentDLF::UnregisterSVG();
return 0;
}
PRBool
SVGEnabled()
{
static PRBool sInitialized = PR_FALSE;
if (sInitialized)
return gSVGEnabled;
gSVGEnabled = nsContentUtils::GetBoolPref(SVG_PREF_STR);
nsContentUtils::RegisterPrefCallback(SVG_PREF_STR, SVGPrefChanged, nsnull);
sInitialized = PR_TRUE;
return gSVGEnabled;
}
nsresult
NS_NewSVGElement(nsIContent** aResult, nsINodeInfo *aNodeInfo)
{
if (!SVGEnabled())
return NS_NewXMLElement(aResult, aNodeInfo);
nsIAtom *name = aNodeInfo->NameAtom();
if (name == nsSVGAtoms::polyline)

Просмотреть файл

@ -213,6 +213,9 @@ extern nsresult
NS_NewSVGImageFrame(nsIPresShell *aPresShell, nsIContent *aContent, nsIFrame** newFrame);
nsresult
NS_NewSVGClipPathFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame** aNewFrame);
// defined in nsSVGElementFactory.cpp
extern PRBool SVGEnabled();
#endif
#include "nsIDocument.h"
@ -4091,7 +4094,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsFrameConstructorState& aState,
else
#endif
#ifdef MOZ_SVG
if (aDocElement->GetNameSpaceID() == kNameSpaceID_SVG) {
if (aDocElement->GetNameSpaceID() == kNameSpaceID_SVG && SVGEnabled()) {
rv = NS_NewSVGOuterSVGFrame(mPresShell, aDocElement, &contentFrame);
if (NS_FAILED(rv)) {
return rv;
@ -7549,7 +7552,8 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsFrameConstructorState& aState,
#ifdef MOZ_SVG
if (NS_SUCCEEDED(rv) &&
(!frameItems->childList || lastChild == frameItems->lastChild) &&
aNameSpaceID == kNameSpaceID_SVG) {
aNameSpaceID == kNameSpaceID_SVG &&
SVGEnabled()) {
rv = ConstructSVGFrame(aState, aContent, adjParentFrame, aTag,
aNameSpaceID, styleContext,
*frameItems, pseudoParent);

Просмотреть файл

@ -106,7 +106,10 @@ CPPSRCS = \
nsContentDLF.cpp \
$(NULL)
EXPORTS = nsLayoutCID.h
EXPORTS = \
nsLayoutCID.h \
nsContentDLF.h \
$(NULL)
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)gkbase_s.$(LIB_SUFFIX) \

Просмотреть файл

@ -110,6 +110,9 @@ static char* gSVGTypes[] = {
"image/svg+xml",
0
};
// defined in nsSVGElementFactory.cpp
extern PRBool SVGEnabled();
#endif
static const char* const gRDFTypes[] = {
@ -189,9 +192,11 @@ nsContentDLF::CreateInstance(const char* aCommand,
}
#ifdef MOZ_SVG
for (typeIndex = 0; gSVGTypes[typeIndex] && !knownType; ++typeIndex) {
if (type.Equals(gSVGTypes[typeIndex])) {
knownType = PR_TRUE;
if (SVGEnabled()) {
for (typeIndex = 0; gSVGTypes[typeIndex] && !knownType; ++typeIndex) {
if (type.Equals(gSVGTypes[typeIndex])) {
knownType = PR_TRUE;
}
}
}
#endif // MOZ_SVG
@ -235,14 +240,16 @@ nsContentDLF::CreateInstance(const char* aCommand,
}
#ifdef MOZ_SVG
// Try SVG
typeIndex = 0;
while(gSVGTypes[typeIndex]) {
if (!PL_strcmp(gSVGTypes[typeIndex++], aContentType)) {
return CreateDocument(aCommand,
aChannel, aLoadGroup,
aContainer, kSVGDocumentCID,
aDocListener, aDocViewer);
if (SVGEnabled()) {
// Try SVG
typeIndex = 0;
while(gSVGTypes[typeIndex]) {
if (!PL_strcmp(gSVGTypes[typeIndex++], aContentType)) {
return CreateDocument(aCommand,
aChannel, aLoadGroup,
aContainer, kSVGDocumentCID,
aDocListener, aDocViewer);
}
}
}
#endif
@ -532,6 +539,27 @@ static nsresult UnregisterTypes(nsICategoryManager* aCatMgr,
}
#ifdef MOZ_SVG
NS_IMETHODIMP
nsContentDLF::RegisterSVG()
{
nsresult rv;
nsCOMPtr<nsICategoryManager> catmgr(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
return RegisterTypes(catmgr, gSVGTypes);
}
NS_IMETHODIMP
nsContentDLF::UnregisterSVG()
{
nsresult rv;
nsCOMPtr<nsICategoryManager> catmgr(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
return UnregisterTypes(catmgr, gSVGTypes);
}
#endif
NS_IMETHODIMP
nsContentDLF::RegisterDocumentFactories(nsIComponentManager* aCompMgr,
@ -552,11 +580,6 @@ nsContentDLF::RegisterDocumentFactories(nsIComponentManager* aCompMgr,
rv = RegisterTypes(catmgr, gXMLTypes);
if (NS_FAILED(rv))
break;
#ifdef MOZ_SVG
rv = RegisterTypes(catmgr, gSVGTypes);
if (NS_FAILED(rv))
break;
#endif
rv = RegisterTypes(catmgr, gRDFTypes);
if (NS_FAILED(rv))
break;

Просмотреть файл

@ -87,6 +87,11 @@ public:
static nsICSSStyleSheet* gUAStyleSheet;
#ifdef MOZ_SVG
static NS_IMETHODIMP RegisterSVG();
static NS_IMETHODIMP UnregisterSVG();
#endif
static NS_IMETHODIMP
RegisterDocumentFactories(nsIComponentManager* aCompMgr,
nsIFile* aPath,

Просмотреть файл

@ -213,6 +213,9 @@ void NS_FreeSVGRendererLibartGlobals();
void NS_InitSVGRendererGDIPlusGlobals();
void NS_FreeSVGRendererGDIPlusGlobals();
#endif
// defined in nsSVGElementFactory.cpp
extern PRBool SVGEnabled();
#endif
//-----------------------------------------------------------------------------
@ -306,6 +309,8 @@ Initialize(nsIModule* aSelf)
#endif
#ifdef MOZ_SVG
if (SVGEnabled())
nsContentDLF::RegisterSVG();
nsSVGAtoms::AddRefAtoms();
#ifdef MOZ_SVG_RENDERER_LIBART
NS_InitSVGRendererLibartGlobals();

Просмотреть файл

@ -864,6 +864,8 @@ pref("editor.positioning.offset", 0);
pref("dom.max_script_run_time", 5);
pref("svg.enabled", false);
#ifdef XP_WIN
pref("font.name.serif.ar", "Times New Roman");
pref("font.name.sans-serif.ar", "Arial");