Bug 1251615 - Add poison values to Layer to check for errors. r=mstange

MozReview-Commit-ID: l22oL5b9oB

--HG--
extra : rebase_source : 376ba3a71ee2b3d8384878b0e0273d2df580ea64
This commit is contained in:
Benoit Girard 2016-04-27 18:57:44 -04:00
parent 06cad672c8
commit 24566951d0
2 changed files with 25 additions and 2 deletions

View File

@ -21,6 +21,7 @@
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
#include "nsRect.h" // for IntRect
#include "nsTArray.h" // for AutoTArray, nsTArray_Impl
#include "mozilla/Poison.h"
#include "mozilla/layers/ImageHost.h"
#include "mozilla/layers/LayerManagerComposite.h"
#include "TreeTraversal.h" // for ForEachNode
@ -170,6 +171,7 @@ struct LayerPropertiesBase : public LayerProperties
nsIntRegion ComputeChange(NotifySubDocInvalidationFunc aCallback,
bool& aGeometryChanged)
{
mCanary.Check();
bool transformChanged = !mTransform.FuzzyEqual(GetTransformForInvalidation(mLayer)) ||
mLayer->GetPostXScale() != mPostXScale ||
mLayer->GetPostYScale() != mPostYScale;
@ -257,6 +259,7 @@ struct LayerPropertiesBase : public LayerProperties
float mOpacity;
ParentLayerIntRect mClipRect;
bool mUseClipRect;
mozilla::CorruptionCanary mCanary;
};
struct ContainerLayerProperties : public LayerPropertiesBase
@ -267,6 +270,7 @@ struct ContainerLayerProperties : public LayerPropertiesBase
, mPreYScale(aLayer->GetPreYScale())
{
for (Layer* child = aLayer->GetFirstChild(); child; child = child->GetNextSibling()) {
child->CheckCanary();
mChildren.AppendElement(Move(CloneLayerTreePropertiesInternal(child)));
}
}
@ -278,6 +282,8 @@ struct ContainerLayerProperties : public LayerPropertiesBase
nsIntRegion invalidOfLayer; // Invalid regions of this layer.
nsIntRegion result; // Invliad regions for children only.
container->CheckCanary();
bool childrenChanged = false;
if (mPreXScale != container->GetPreXScale() ||
@ -301,6 +307,7 @@ struct ContainerLayerProperties : public LayerPropertiesBase
nsDataHashtable<nsPtrHashKey<Layer>, uint32_t> oldIndexMap(mChildren.Length());
for (uint32_t i = 0; i < mChildren.Length(); ++i) {
mChildren[i]->mLayer->CheckCanary();
oldIndexMap.Put(mChildren[i]->mLayer, i);
}
@ -559,6 +566,8 @@ CloneLayerTreePropertiesInternal(Layer* aRoot, bool aIsMask /* = false */)
MOZ_ASSERT(!aIsMask || aRoot->GetType() == Layer::TYPE_IMAGE);
aRoot->CheckCanary();
switch (aRoot->GetType()) {
case Layer::TYPE_CONTAINER:
case Layer::TYPE_REF:

View File

@ -21,6 +21,7 @@
#include "mozilla/DebugOnly.h" // for DebugOnly
#include "mozilla/EventForwards.h" // for nsPaintEvent
#include "mozilla/Maybe.h" // for Maybe
#include "mozilla/Poison.h"
#include "mozilla/RefPtr.h" // for already_AddRefed
#include "mozilla/StyleAnimationValue.h" // for StyleAnimationValue, etc
#include "mozilla/TimeStamp.h" // for TimeStamp, TimeDuration
@ -1317,8 +1318,18 @@ public:
bool IsScrollInfoLayer() const;
const EventRegions& GetEventRegions() const { return mEventRegions; }
ContainerLayer* GetParent() { return mParent; }
Layer* GetNextSibling() { return mNextSibling; }
const Layer* GetNextSibling() const { return mNextSibling; }
Layer* GetNextSibling() {
if (mNextSibling) {
mNextSibling->CheckCanary();
}
return mNextSibling;
}
const Layer* GetNextSibling() const {
if (mNextSibling) {
mNextSibling->CheckCanary();
}
return mNextSibling;
}
Layer* GetPrevSibling() { return mPrevSibling; }
const Layer* GetPrevSibling() const { return mPrevSibling; }
virtual Layer* GetFirstChild() const { return nullptr; }
@ -1345,6 +1356,7 @@ public:
float GetScrollbarThumbRatio() { return mScrollbarThumbRatio; }
bool IsScrollbarContainer() { return mIsScrollbarContainer; }
Layer* GetMaskLayer() const { return mMaskLayer; }
void CheckCanary() const { mCanary.Check(); }
// Ancestor mask layers are associated with FrameMetrics, but for simplicity
// in maintaining the layer tree structure we attach them to the layer.
@ -1856,6 +1868,8 @@ protected:
void* mImplData;
RefPtr<Layer> mMaskLayer;
nsTArray<RefPtr<Layer>> mAncestorMaskLayers;
// Look for out-of-bound in the middle of the structure
mozilla::CorruptionCanary mCanary;
gfx::UserData mUserData;
gfx::IntRect mLayerBounds;
LayerIntRegion mVisibleRegion;