Bug 614732 - Add prefs for enabling/disabling display-list hit-testing/painting. r=roc.

This commit is contained in:
Jonathan Watt 2012-05-17 05:05:04 +01:00
parent 6aaa7e645b
commit 396b0f9473
3 changed files with 35 additions and 19 deletions

View File

@ -270,6 +270,8 @@ nsLayoutStatics::Initialize()
nsWindowMemoryReporter::Init();
nsSVGUtils::Init();
return NS_OK;
}

View File

@ -160,31 +160,26 @@ static const PRUint8 gsRGBToLinearRGBMap[256] = {
239, 242, 244, 246, 248, 250, 253, 255
};
static bool gSMILEnabled;
static const char SMIL_PREF_STR[] = "svg.smil.enabled";
static int
SMILPrefChanged(const char *aPref, void *aClosure)
{
bool prefVal = Preferences::GetBool(SMIL_PREF_STR);
gSMILEnabled = prefVal;
return 0;
}
static bool sSMILEnabled;
static bool sSVGDisplayListHitTestingEnabled;
static bool sSVGDisplayListPaintingEnabled;
bool
NS_SMILEnabled()
{
static bool sInitialized = false;
if (!sInitialized) {
/* check and register ourselves with the pref */
gSMILEnabled = Preferences::GetBool(SMIL_PREF_STR);
Preferences::RegisterCallback(SMILPrefChanged, SMIL_PREF_STR);
return sSMILEnabled;
}
sInitialized = true;
}
bool
NS_SVGDisplayListHitTestingEnabled()
{
return sSVGDisplayListHitTestingEnabled;
}
return gSMILEnabled;
bool
NS_SVGDisplayListPaintingEnabled()
{
return sSVGDisplayListPaintingEnabled;
}
// we only take the address of this:
@ -237,6 +232,20 @@ SVGAutoRenderState::IsPaintingToWindow(nsRenderingContext *aContext)
return false;
}
void
nsSVGUtils::Init()
{
Preferences::AddBoolVarCache(&sSMILEnabled,
"svg.smil.enabled",
true);
Preferences::AddBoolVarCache(&sSVGDisplayListHitTestingEnabled,
"svg.display-lists.hit-testing.enabled");
Preferences::AddBoolVarCache(&sSVGDisplayListPaintingEnabled,
"svg.display-lists.painting.enabled");
}
nsSVGSVGElement*
nsSVGUtils::GetOuterSVGElement(nsSVGElement *aSVGElement)
{

View File

@ -143,6 +143,9 @@ IsSVGWhitespace(PRUnichar aChar)
*/
bool NS_SMILEnabled();
bool NS_SVGDisplayListHitTestingEnabled();
bool NS_SVGDisplayListPaintingEnabled();
/**
* Sometimes we need to distinguish between an empty box and a box
* that contains an element that has no size e.g. a point at the origin.
@ -225,6 +228,8 @@ public:
typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
typedef mozilla::SVGPreserveAspectRatio SVGPreserveAspectRatio;
static void Init();
/*
* Get the parent element of an nsIContent
*/