Bug 1023557 - Store the content description in ContainerLayer instead of FrameMetrics. r=kats,BenWa

This commit is contained in:
Botond Ballo 2014-07-31 16:11:47 -04:00
parent a84f8ca572
commit 1d35f25a8b
8 changed files with 44 additions and 58 deletions

View File

@ -740,46 +740,33 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
WriteParam(aMsg, aParam.mHasScrollgrab); WriteParam(aMsg, aParam.mHasScrollgrab);
WriteParam(aMsg, aParam.mUpdateScrollOffset); WriteParam(aMsg, aParam.mUpdateScrollOffset);
WriteParam(aMsg, aParam.mScrollGeneration); WriteParam(aMsg, aParam.mScrollGeneration);
aMsg->WriteBytes(aParam.mContentDescription,
sizeof(aParam.mContentDescription));
WriteParam(aMsg, aParam.mTransformScale); WriteParam(aMsg, aParam.mTransformScale);
} }
static bool Read(const Message* aMsg, void** aIter, paramType* aResult) static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{ {
const char* contentDescription; return (ReadParam(aMsg, aIter, &aResult->mScrollableRect) &&
if (!(ReadParam(aMsg, aIter, &aResult->mScrollableRect) && ReadParam(aMsg, aIter, &aResult->mViewport) &&
ReadParam(aMsg, aIter, &aResult->mViewport) && ReadParam(aMsg, aIter, &aResult->mScrollOffset) &&
ReadParam(aMsg, aIter, &aResult->mScrollOffset) && ReadParam(aMsg, aIter, &aResult->mDisplayPort) &&
ReadParam(aMsg, aIter, &aResult->mDisplayPort) && ReadParam(aMsg, aIter, &aResult->mDisplayPortMargins) &&
ReadParam(aMsg, aIter, &aResult->mDisplayPortMargins) && ReadParam(aMsg, aIter, &aResult->mUseDisplayPortMargins) &&
ReadParam(aMsg, aIter, &aResult->mUseDisplayPortMargins) && ReadParam(aMsg, aIter, &aResult->mCriticalDisplayPort) &&
ReadParam(aMsg, aIter, &aResult->mCriticalDisplayPort) && ReadParam(aMsg, aIter, &aResult->mCompositionBounds) &&
ReadParam(aMsg, aIter, &aResult->mCompositionBounds) && ReadParam(aMsg, aIter, &aResult->mRootCompositionSize) &&
ReadParam(aMsg, aIter, &aResult->mRootCompositionSize) && ReadParam(aMsg, aIter, &aResult->mScrollId) &&
ReadParam(aMsg, aIter, &aResult->mScrollId) && ReadParam(aMsg, aIter, &aResult->mResolution) &&
ReadParam(aMsg, aIter, &aResult->mResolution) && ReadParam(aMsg, aIter, &aResult->mCumulativeResolution) &&
ReadParam(aMsg, aIter, &aResult->mCumulativeResolution) && ReadParam(aMsg, aIter, &aResult->mZoom) &&
ReadParam(aMsg, aIter, &aResult->mZoom) && ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) &&
ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) && ReadParam(aMsg, aIter, &aResult->mMayHaveTouchListeners) &&
ReadParam(aMsg, aIter, &aResult->mMayHaveTouchListeners) && ReadParam(aMsg, aIter, &aResult->mMayHaveTouchCaret) &&
ReadParam(aMsg, aIter, &aResult->mMayHaveTouchCaret) && ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
ReadParam(aMsg, aIter, &aResult->mPresShellId) && ReadParam(aMsg, aIter, &aResult->mIsRoot) &&
ReadParam(aMsg, aIter, &aResult->mIsRoot) && ReadParam(aMsg, aIter, &aResult->mHasScrollgrab) &&
ReadParam(aMsg, aIter, &aResult->mHasScrollgrab) && ReadParam(aMsg, aIter, &aResult->mUpdateScrollOffset) &&
ReadParam(aMsg, aIter, &aResult->mUpdateScrollOffset) && ReadParam(aMsg, aIter, &aResult->mScrollGeneration) &&
ReadParam(aMsg, aIter, &aResult->mScrollGeneration) && ReadParam(aMsg, aIter, &aResult->mTransformScale));
aMsg->ReadBytes(aIter, &contentDescription,
sizeof(aResult->mContentDescription)) &&
ReadParam(aMsg, aIter, &aResult->mTransformScale))) {
return false;
}
// ReadBytes() doesn't actually copy the string, it only points
// a pointer to the string in its internal buffer.
strncpy(aResult->mContentDescription, contentDescription,
sizeof(aResult->mContentDescription));
aResult->mContentDescription[sizeof(aResult->mContentDescription) - 1] = '\0';
return true;
} }
}; };

View File

@ -7,7 +7,6 @@
#define GFX_FRAMEMETRICS_H #define GFX_FRAMEMETRICS_H
#include <stdint.h> // for uint32_t, uint64_t #include <stdint.h> // for uint32_t, uint64_t
#include <string> // for std::string
#include "Units.h" // for CSSRect, CSSPixel, etc #include "Units.h" // for CSSRect, CSSPixel, etc
#include "mozilla/gfx/BasePoint.h" // for BasePoint #include "mozilla/gfx/BasePoint.h" // for BasePoint
#include "mozilla/gfx/Rect.h" // for RoundedIn #include "mozilla/gfx/Rect.h" // for RoundedIn
@ -92,7 +91,6 @@ public:
, mZoom(1) , mZoom(1)
, mUpdateScrollOffset(false) , mUpdateScrollOffset(false)
, mScrollGeneration(0) , mScrollGeneration(0)
, mContentDescription()
, mRootCompositionSize(0, 0) , mRootCompositionSize(0, 0)
, mDisplayPortMargins(0, 0, 0, 0) , mDisplayPortMargins(0, 0, 0, 0)
, mUseDisplayPortMargins(false) , mUseDisplayPortMargins(false)
@ -103,8 +101,6 @@ public:
bool operator==(const FrameMetrics& aOther) const bool operator==(const FrameMetrics& aOther) const
{ {
// mContentDescription is not compared on purpose as it's only used
// for debugging.
return mCompositionBounds.IsEqualEdges(aOther.mCompositionBounds) && return mCompositionBounds.IsEqualEdges(aOther.mCompositionBounds) &&
mRootCompositionSize == aOther.mRootCompositionSize && mRootCompositionSize == aOther.mRootCompositionSize &&
mDisplayPort.IsEqualEdges(aOther.mDisplayPort) && mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
@ -402,18 +398,6 @@ public:
return mScrollGeneration; return mScrollGeneration;
} }
std::string GetContentDescription() const
{
return std::string(mContentDescription);
}
void SetContentDescription(const std::string& aContentDescription)
{
strncpy(mContentDescription, aContentDescription.c_str(), sizeof(mContentDescription));
// forcibly null-terminate in case aContentDescription is too long
mContentDescription[sizeof(mContentDescription) - 1] = '\0';
}
ViewID GetScrollId() const ViewID GetScrollId() const
{ {
return mScrollId; return mScrollId;
@ -503,10 +487,6 @@ private:
// The scroll generation counter used to acknowledge the scroll offset update. // The scroll generation counter used to acknowledge the scroll offset update.
uint32_t mScrollGeneration; uint32_t mScrollGeneration;
// A description of the content element corresponding to this frame.
// This is empty unless the apz.printtree pref is turned on.
char mContentDescription[20];
// The size of the root scrollable's composition bounds, but in local CSS pixels. // The size of the root scrollable's composition bounds, but in local CSS pixels.
CSSSize mRootCompositionSize; CSSSize mRootCompositionSize;

View File

@ -922,7 +922,7 @@ ContainerLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
aAttrs = ContainerLayerAttributes(GetFrameMetrics(), mScrollHandoffParentId, aAttrs = ContainerLayerAttributes(GetFrameMetrics(), mScrollHandoffParentId,
mPreXScale, mPreYScale, mPreXScale, mPreYScale,
mInheritedXScale, mInheritedYScale, mInheritedXScale, mInheritedYScale,
mBackgroundColor); mBackgroundColor, mContentDescription);
} }
bool bool

View File

@ -1770,6 +1770,17 @@ public:
Mutated(); Mutated();
} }
void SetContentDescription(const std::string& aContentDescription)
{
if (mContentDescription == aContentDescription) {
return;
}
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ContentDescription", this));
mContentDescription = aContentDescription;
Mutated();
}
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs); virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs);
void SortChildrenBy3DZOrder(nsTArray<Layer*>& aArray); void SortChildrenBy3DZOrder(nsTArray<Layer*>& aArray);
@ -1789,6 +1800,7 @@ public:
float GetInheritedYScale() const { return mInheritedYScale; } float GetInheritedYScale() const { return mInheritedYScale; }
gfxRGBA GetBackgroundColor() const { return mBackgroundColor; } gfxRGBA GetBackgroundColor() const { return mBackgroundColor; }
const std::string& GetContentDescription() const { return mContentDescription; }
MOZ_LAYER_DECL_NAME("ContainerLayer", TYPE_CONTAINER) MOZ_LAYER_DECL_NAME("ContainerLayer", TYPE_CONTAINER)
@ -1881,6 +1893,10 @@ protected:
// When multi-layer-apz (bug 967844) is implemented, this is likely to move // When multi-layer-apz (bug 967844) is implemented, this is likely to move
// elsewhere (e.g. to Layer). // elsewhere (e.g. to Layer).
gfxRGBA mBackgroundColor; gfxRGBA mBackgroundColor;
// A description of the content element corresponding to this frame.
// This is empty unless this ContainerLayer is scrollable and the
// apz.printtree pref is turned on.
std::string mContentDescription;
bool mUseIntermediateSurface; bool mUseIntermediateSurface;
bool mSupportsComponentAlphaChildren; bool mSupportsComponentAlphaChildren;
bool mMayHaveReadbackChild; bool mMayHaveReadbackChild;

View File

@ -269,7 +269,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
<< "\tsr=" << container->GetFrameMetrics().mScrollableRect << "\tsr=" << container->GetFrameMetrics().mScrollableRect
<< (aLayer->GetVisibleRegion().IsEmpty() ? "\tscrollinfo" : "") << (aLayer->GetVisibleRegion().IsEmpty() ? "\tscrollinfo" : "")
<< (apzc->HasScrollgrab() ? "\tscrollgrab" : "") << (apzc->HasScrollgrab() ? "\tscrollgrab" : "")
<< "\t" << container->GetFrameMetrics().GetContentDescription(); << "\t" << container->GetContentDescription();
// Bind the APZC instance into the tree of APZCs // Bind the APZC instance into the tree of APZCs
if (aNextSibling) { if (aNextSibling) {

View File

@ -353,6 +353,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
containerLayer->SetPreScale(attrs.preXScale(), attrs.preYScale()); containerLayer->SetPreScale(attrs.preXScale(), attrs.preYScale());
containerLayer->SetInheritedScale(attrs.inheritedXScale(), attrs.inheritedYScale()); containerLayer->SetInheritedScale(attrs.inheritedXScale(), attrs.inheritedYScale());
containerLayer->SetBackgroundColor(attrs.backgroundColor().value()); containerLayer->SetBackgroundColor(attrs.backgroundColor().value());
containerLayer->SetContentDescription(attrs.contentDescription());
break; break;
} }
case Specific::TColorLayerAttributes: { case Specific::TColorLayerAttributes: {

View File

@ -41,6 +41,7 @@ using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h";
using struct mozilla::layers::FenceHandle from "mozilla/layers/FenceUtils.h"; using struct mozilla::layers::FenceHandle from "mozilla/layers/FenceUtils.h";
using struct mozilla::layers::FenceHandleFromChild from "mozilla/layers/FenceUtils.h"; using struct mozilla::layers::FenceHandleFromChild from "mozilla/layers/FenceUtils.h";
using mozilla::layers::TextureIdentifier from "mozilla/layers/CompositorTypes.h"; using mozilla::layers::TextureIdentifier from "mozilla/layers/CompositorTypes.h";
using std::string from "string";
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
@ -227,6 +228,7 @@ struct ContainerLayerAttributes {
float inheritedXScale; float inheritedXScale;
float inheritedYScale; float inheritedYScale;
LayerColor backgroundColor; LayerColor backgroundColor;
string contentDescription;
}; };
struct ColorLayerAttributes { LayerColor color; nsIntRect bounds; }; struct ColorLayerAttributes { LayerColor color; nsIntRect bounds; };
struct CanvasLayerAttributes { GraphicsFilterType filter; nsIntRect bounds; }; struct CanvasLayerAttributes { GraphicsFilterType filter; nsIntRect bounds; };

View File

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