Bug 958596 - Add a content description field to FrameMetrics and populate it if the apz.printtree pref is on. r=kats,tn

This commit is contained in:
Botond Ballo 2014-01-22 16:37:57 -05:00
parent 82f927284a
commit bf9ca02460
5 changed files with 47 additions and 1 deletions

View File

@ -623,6 +623,7 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
WriteParam(aMsg, aParam.mDisableScrollingY);
WriteParam(aMsg, aParam.mUpdateScrollOffset);
WriteParam(aMsg, aParam.mScrollGeneration);
WriteParam(aMsg, aParam.mContentDescription);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
@ -645,7 +646,8 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
ReadParam(aMsg, aIter, &aResult->mDisableScrollingX) &&
ReadParam(aMsg, aIter, &aResult->mDisableScrollingY) &&
ReadParam(aMsg, aIter, &aResult->mUpdateScrollOffset) &&
ReadParam(aMsg, aIter, &aResult->mScrollGeneration));
ReadParam(aMsg, aIter, &aResult->mScrollGeneration) &&
ReadParam(aMsg, aIter, &aResult->mContentDescription));
}
};

View File

@ -7,6 +7,7 @@
#define GFX_FRAMEMETRICS_H
#include <stdint.h> // for uint32_t, uint64_t
#include <string> // for std::string
#include "Units.h" // for CSSRect, CSSPixel, etc
#include "mozilla/gfx/BasePoint.h" // for BasePoint
#include "mozilla/gfx/Rect.h" // for RoundedIn
@ -70,6 +71,8 @@ public:
bool operator==(const FrameMetrics& aOther) const
{
// mContentDescription is not compared on purpose as it's only used
// for debugging.
return mCompositionBounds.IsEqualEdges(aOther.mCompositionBounds) &&
mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
mCriticalDisplayPort.IsEqualEdges(aOther.mCriticalDisplayPort) &&
@ -336,6 +339,16 @@ public:
return mScrollGeneration;
}
const std::string& GetContentDescription() const
{
return mContentDescription;
}
void SetContentDescription(const std::string& aContentDescription)
{
mContentDescription = aContentDescription;
}
private:
// New fields from now on should be made private and old fields should
// be refactored to be private.
@ -350,6 +363,10 @@ private:
bool mUpdateScrollOffset;
// The scroll generation counter used to acknowledge the scroll offset update.
uint32_t mScrollGeneration;
// A description of the content element corresponding to this frame.
// This is empty unless the apz.printtree pref is turned on.
std::string mContentDescription;
};
/**

View File

@ -16,6 +16,7 @@
#include "mozilla/MouseEvents.h"
#include "mozilla/mozalloc.h" // for operator new
#include "mozilla/TouchEvents.h"
#include "mozilla/Preferences.h" // for Preferences
#include "nsDebug.h" // for NS_WARNING
#include "nsPoint.h" // for nsIntPoint
#include "nsThreadUtils.h" // for NS_IsMainThread
@ -30,12 +31,16 @@ 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"),
mTouchCount(0)
{
MOZ_ASSERT(NS_IsMainThread());
AsyncPanZoomController::InitializeGlobalState();
Preferences::AddBoolVarCache(&gPrintApzcTree, "apz.printtree", gPrintApzcTree);
}
APZCTreeManager::~APZCTreeManager()

View File

@ -592,6 +592,17 @@ static void AdjustForScrollBars(ScreenIntRect& aToAdjust, nsIScrollableFrame* aS
}
}
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,
@ -733,6 +744,14 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
AdjustForScrollBars(metrics.mCompositionBounds, scrollableFrame);
}
if (GetApzcTreePrintPref()) {
if (nsIContent* content = frameForCompositionBoundsCalculation->GetContent()) {
nsAutoString contentDescription;
content->Describe(contentDescription);
metrics.SetContentDescription(NS_LossyConvertUTF16toASCII(contentDescription).get());
}
}
metrics.mPresShellId = presShell->GetPresShellId();
// If the scroll frame's content is marked 'scrollgrab', record this

View File

@ -308,6 +308,9 @@ pref("media.audio_data.enabled", false);
// 2 = STICKY (Allow lock to be broken, with hysteresis)
pref("apz.axis_lock_mode", 0);
// Whether to print the APZC tree for debugging
pref("apz.printtree", false);
#ifdef XP_MACOSX
// Whether to run in native HiDPI mode on machines with "Retina"/HiDPI display;
// <= 0 : hidpi mode disabled, display will just use pixel-based upscaling