Bug 967844. Part 2: Move mContentDescription from Layer to FrameMetrics. r=kats

--HG--
extra : rebase_source : d5a2d8ea13369db215e96e721efc3ce0b354a523
This commit is contained in:
Robert O'Callahan 2014-08-30 00:23:25 +12:00
parent e7bf334884
commit 8d98e875f0
8 changed files with 38 additions and 30 deletions

View File

@ -754,6 +754,17 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
WriteParam(aMsg, aParam.mScrollGeneration);
WriteParam(aMsg, aParam.mTransformScale);
WriteParam(aMsg, aParam.mBackgroundColor);
WriteParam(aMsg, aParam.GetContentDescription());
}
static bool ReadContentDescription(const Message* aMsg, void** aIter, paramType* aResult)
{
nsCString str;
if (!ReadParam(aMsg, aIter, &str)) {
return false;
}
aResult->SetContentDescription(str);
return true;
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
@ -781,7 +792,8 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
ReadParam(aMsg, aIter, &aResult->mUpdateScrollOffset) &&
ReadParam(aMsg, aIter, &aResult->mScrollGeneration) &&
ReadParam(aMsg, aIter, &aResult->mTransformScale) &&
ReadParam(aMsg, aIter, &aResult->mBackgroundColor));
ReadParam(aMsg, aIter, &aResult->mBackgroundColor) &&
ReadContentDescription(aMsg, aIter, aResult));
}
};

View File

@ -13,6 +13,7 @@
#include "mozilla/gfx/ScaleFactor.h" // for ScaleFactor
#include "mozilla/gfx/Logging.h" // for Log
#include "gfxColor.h"
#include "nsString.h"
namespace IPC {
template <typename T> struct ParamTraits;
@ -99,7 +100,9 @@ public:
, mPresShellId(-1)
, mViewport(0, 0, 0, 0)
, mBackgroundColor(0, 0, 0, 0)
{}
{
mContentDescription[0] = '\0';
}
// Default copy ctor and operator= are fine
@ -125,7 +128,8 @@ public:
mScrollOffset == aOther.mScrollOffset &&
mHasScrollgrab == aOther.mHasScrollgrab &&
mUpdateScrollOffset == aOther.mUpdateScrollOffset &&
mBackgroundColor == aOther.mBackgroundColor;
mBackgroundColor == aOther.mBackgroundColor &&
!strcmp(mContentDescription, aOther.mContentDescription);
}
bool operator!=(const FrameMetrics& aOther) const
{
@ -480,6 +484,18 @@ public:
mBackgroundColor = aBackgroundColor;
}
nsCString GetContentDescription() const
{
return nsCString(mContentDescription);
}
void SetContentDescription(const nsCString& aContentDescription)
{
strncpy(mContentDescription, aContentDescription.get(),
sizeof(mContentDescription));
mContentDescription[sizeof(mContentDescription) - 1] = 0;
}
private:
// New fields from now on should be made private and old fields should
// be refactored to be private.
@ -551,6 +567,11 @@ private:
// The background color to use when overscrolling.
gfxRGBA mBackgroundColor;
// A description of the content element corresponding to this frame.
// This is empty unless this is a scrollable ContainerLayer and the
// apz.printtree pref is turned on.
char mContentDescription[20];
};
/**

View File

@ -328,13 +328,6 @@ public:
return mLayer->GetClipRect();
}
const std::string& GetContentDescription() const
{
MOZ_ASSERT(IsValid());
return mLayer->GetContentDescription();
}
// Expose an opaque pointer to the layer. Mostly used for printf
// purposes. This is not intended to be a general-purpose accessor
// for the underlying layer.

View File

@ -1171,17 +1171,6 @@ public:
}
}
void SetContentDescription(const std::string& aContentDescription)
{
if (mContentDescription == aContentDescription) {
return;
}
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ContentDescription", this));
mContentDescription = aContentDescription;
Mutated();
}
// These getters can be used anytime.
float GetOpacity() { return mOpacity; }
gfx::CompositionOp GetMixBlendMode() const { return mMixBlendMode; }
@ -1215,7 +1204,6 @@ public:
FrameMetrics::ViewID GetScrollbarTargetContainerId() { return mScrollbarTargetId; }
ScrollDirection GetScrollbarDirection() { return mScrollbarDirection; }
Layer* GetMaskLayer() const { return mMaskLayer; }
const std::string& GetContentDescription() const { return mContentDescription; }
// Note that all lengths in animation data are either in CSS pixels or app
@ -1643,10 +1631,6 @@ protected:
// If this layer is used for OMTA, then this counter is used to ensure we
// stay in sync with the animation manager
uint64_t mAnimationGeneration;
// A description of the content element corresponding to this frame.
// This is empty unless this is a scrollable ContainerLayer and the
// apz.printtree pref is turned on.
std::string mContentDescription;
#ifdef MOZ_DUMP_PAINTING
nsTArray<nsCString> mExtraDumpInfo;
#endif

View File

@ -308,7 +308,7 @@ APZCTreeManager::PrepareAPZCForLayer(const LayerMetricsWrapper& aLayer,
<< "\tsr=" << aMetrics.mScrollableRect
<< (aLayer.GetVisibleRegion().IsEmpty() ? "\tscrollinfo" : "")
<< (apzc->HasScrollgrab() ? "\tscrollgrab" : "")
<< "\t" << aLayer.GetContentDescription();
<< "\t" << aMetrics.GetContentDescription().get();
// Bind the APZC instance into the tree of APZCs
if (aNextSibling) {

View File

@ -321,7 +321,6 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
layer->SetAnimations(common.animations());
layer->SetInvalidRegion(common.invalidRegion());
layer->SetFrameMetrics(common.metrics());
layer->SetContentDescription(common.contentDescription());
typedef SpecificLayerAttributes Specific;
const SpecificLayerAttributes& specific = attrs.specific();

View File

@ -609,7 +609,6 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies,
common.animations() = mutant->GetAnimations();
common.invalidRegion() = mutant->GetInvalidRegion();
common.metrics() = mutant->GetAllFrameMetrics();
common.contentDescription() = mutant->GetContentDescription();
attrs.specific() = null_t();
mutant->FillSpecificAttributes(attrs.specific());

View File

@ -835,7 +835,7 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
if (nsIContent* content = frameForCompositionBoundsCalculation->GetContent()) {
nsAutoString contentDescription;
content->Describe(contentDescription);
aRoot->SetContentDescription(NS_LossyConvertUTF16toASCII(contentDescription).get());
metrics.SetContentDescription(NS_LossyConvertUTF16toASCII(contentDescription));
}
}