Bug 1030115 - fix apz.printtree caching to use gfxPrefs. r=kats, bas

This commit is contained in:
Gijs Kruitbosch 2014-06-25 16:12:32 +01:00
parent 7c98880020
commit 69b99988f1
4 changed files with 9 additions and 22 deletions

View File

@ -166,11 +166,11 @@ public:
mDepth(0),
mStartOfLine(true),
mConditionedOnPref(false),
mPref(nullptr) {}
mPrefFunction(nullptr) {}
template <typename T>
TreeLog& operator<<(const T& aObject) {
if (mConditionedOnPref && !*mPref) {
if (mConditionedOnPref && !mPrefFunction()) {
return *this;
}
if (mStartOfLine) {
@ -190,9 +190,9 @@ public:
void IncreaseIndent() { ++mDepth; }
void DecreaseIndent() { --mDepth; }
void ConditionOnPref(bool* aPref) {
void ConditionOnPrefFunction(bool(*aPrefFunction)()) {
mConditionedOnPref = true;
mPref = aPref;
mPrefFunction = aPrefFunction;
}
private:
Log<LOG_DEBUG> mLog;
@ -200,7 +200,7 @@ private:
uint32_t mDepth;
bool mStartOfLine;
bool mConditionedOnPref;
bool* mPref;
bool (*mPrefFunction)();
template <typename T>
static bool EndsInNewline(const T& aObject) {

View File

@ -34,9 +34,6 @@ namespace layers {
float APZCTreeManager::sDPI = 160.0;
// Pref that enables printing of the APZC tree for debugging.
static bool gPrintApzcTree = false;
APZCTreeManager::APZCTreeManager()
: mTreeLock("APZCTreeLock"),
mInOverscrolledApzc(false),
@ -46,8 +43,7 @@ APZCTreeManager::APZCTreeManager()
{
MOZ_ASSERT(NS_IsMainThread());
AsyncPanZoomController::InitializeGlobalState();
Preferences::AddBoolVarCache(&gPrintApzcTree, "apz.printtree", gPrintApzcTree);
mApzcTreeLog.ConditionOnPref(&gPrintApzcTree);
mApzcTreeLog.ConditionOnPrefFunction(gfxPrefs::APZPrintTree);
}
APZCTreeManager::~APZCTreeManager()

View File

@ -132,6 +132,7 @@ private:
DECL_GFX_PREF(Live, "apz.overscroll.snap_back.spring_friction", APZOverscrollSnapBackSpringFriction, float, 0.1f);
DECL_GFX_PREF(Live, "apz.overscroll.snap_back.mass", APZOverscrollSnapBackMass, float, 1000.0f);
DECL_GFX_PREF(Live, "apz.pan_repaint_interval", APZPanRepaintInterval, int32_t, 250);
DECL_GFX_PREF(Live, "apz.printtree", APZPrintTree, bool, false);
DECL_GFX_PREF(Live, "apz.subframe.enabled", APZSubframeEnabled, bool, false);
DECL_GFX_PREF(Once, "apz.test.logging_enabled", APZTestLoggingEnabled, bool, false);
DECL_GFX_PREF(Live, "apz.touch_start_tolerance", APZTouchStartTolerance, float, 1.0f/4.5f);

View File

@ -23,6 +23,7 @@
#include "nsStyleStructInlines.h"
#include "nsStyleTransformMatrix.h"
#include "gfxMatrix.h"
#include "gfxPrefs.h"
#include "nsSVGIntegrationUtils.h"
#include "nsLayoutUtils.h"
#include "nsIScrollableFrame.h"
@ -616,17 +617,6 @@ static void UnmarkFrameForDisplay(nsIFrame* aFrame) {
}
}
static bool gPrintApzcTree = false;
static bool GetApzcTreePrintPref() {
static bool initialized = false;
if (!initialized) {
Preferences::AddBoolVarCache(&gPrintApzcTree, "apz.printtree", gPrintApzcTree);
initialized = true;
}
return gPrintApzcTree;
}
static void RecordFrameMetrics(nsIFrame* aForFrame,
nsIFrame* aScrollFrame,
const nsIFrame* aReferenceFrame,
@ -799,7 +789,7 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
nsLayoutUtils::CalculateRootCompositionSize(aScrollFrame ? aScrollFrame : aForFrame,
isRootContentDocRootScrollFrame, metrics));
if (GetApzcTreePrintPref()) {
if (gfxPrefs::APZPrintTree()) {
if (nsIContent* content = frameForCompositionBoundsCalculation->GetContent()) {
nsAutoString contentDescription;
content->Describe(contentDescription);