Bug 792314 - Make nsDisplayTransform support untransformed frames. r=roc

This commit is contained in:
Matt Woodrow 2012-09-20 11:14:07 +12:00
parent 65c75afdfb
commit 944b66cc36
2 changed files with 54 additions and 10 deletions

View File

@ -333,12 +333,15 @@ AddAnimationsAndTransitionsToLayer(Layer* aLayer, nsDisplayListBuilder* aBuilder
nsIFrame* frame = aItem->GetUnderlyingFrame();
nsIContent* aContent = frame->GetContent();
nsIContent* content = frame->GetContent();
if (!content) {
return;
}
ElementTransitions* et =
nsTransitionManager::GetTransitionsForCompositor(aContent, aProperty);
nsTransitionManager::GetTransitionsForCompositor(content, aProperty);
ElementAnimations* ea =
nsAnimationManager::GetAnimationsForCompositor(aContent, aProperty);
nsAnimationManager::GetAnimationsForCompositor(content, aProperty);
if (!ea && !et) {
return;
@ -3149,9 +3152,25 @@ nsIFrame *GetTransformRootFrame(nsIFrame* aFrame)
return parent;
}
nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
nsDisplayList *aList, ComputeTransformFunction aTransformGetter,
uint32_t aIndex)
: nsDisplayItem(aBuilder, aFrame)
, mStoredList(aBuilder, aFrame, aList)
, mTransformGetter(aTransformGetter)
, mIndex(aIndex)
{
MOZ_COUNT_CTOR(nsDisplayTransform);
NS_ABORT_IF_FALSE(aFrame, "Must have a frame!");
NS_ABORT_IF_FALSE(!aFrame->IsTransformed(), "Can't specify a transform getter for a transformed frame!");
}
nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
nsDisplayList *aList, uint32_t aIndex)
: nsDisplayItem(aBuilder, aFrame), mStoredList(aBuilder, aFrame, aList), mIndex(aIndex)
: nsDisplayItem(aBuilder, aFrame)
, mStoredList(aBuilder, aFrame, aList)
, mTransformGetter(nullptr)
, mIndex(aIndex)
{
MOZ_COUNT_CTOR(nsDisplayTransform);
NS_ABORT_IF_FALSE(aFrame, "Must have a frame!");
@ -3162,7 +3181,10 @@ nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame
nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
nsDisplayItem *aItem, uint32_t aIndex)
: nsDisplayItem(aBuilder, aFrame), mStoredList(aBuilder, aFrame, aItem), mIndex(aIndex)
: nsDisplayItem(aBuilder, aFrame)
, mStoredList(aBuilder, aFrame, aItem)
, mTransformGetter(nullptr)
, mIndex(aIndex)
{
MOZ_COUNT_CTOR(nsDisplayTransform);
NS_ABORT_IF_FALSE(aFrame, "Must have a frame!");
@ -3541,10 +3563,19 @@ const gfx3DMatrix&
nsDisplayTransform::GetTransform(float aAppUnitsPerPixel)
{
if (mTransform.IsIdentity() || mCachedAppUnitsPerPixel != aAppUnitsPerPixel) {
mTransform =
GetResultingTransformMatrix(mFrame, ToReferenceFrame(),
aAppUnitsPerPixel);
mCachedAppUnitsPerPixel = aAppUnitsPerPixel;
if (mTransformGetter) {
gfxPoint3D newOrigin =
gfxPoint3D(NSAppUnitsToFloatPixels(mToReferenceFrame.x, aAppUnitsPerPixel),
NSAppUnitsToFloatPixels(mToReferenceFrame.y, aAppUnitsPerPixel),
0.0f);
mTransform = mTransformGetter(mFrame, aAppUnitsPerPixel);
mTransform = nsLayoutUtils::ChangeMatrixBasis(newOrigin, mTransform);
} else {
mTransform =
GetResultingTransformMatrix(mFrame, ToReferenceFrame(),
aAppUnitsPerPixel);
mCachedAppUnitsPerPixel = aAppUnitsPerPixel;
}
}
return mTransform;
}

View File

@ -2341,17 +2341,29 @@ private:
* of <translation-value>s, where percentages are percentages of the element's
* border box.
*
* INVARIANT: The wrapped frame is transformed.
* INVARIANT: The wrapped frame is transformed or we supplied a transform getter
* function.
* INVARIANT: The wrapped frame is non-null.
*/
class nsDisplayTransform: public nsDisplayItem
{
public:
/**
* Returns a matrix (in pixels) for the current frame. The matrix should be relative to
* the current frame's coordinate space.
*
* @param aFrame The frame to compute the transform for.
* @param aAppUnitsPerPixel The number of app units per graphics unit.
*/
typedef gfx3DMatrix (* ComputeTransformFunction)(nsIFrame* aFrame, float aAppUnitsPerPixel);
/* Constructor accepts a display list, empties it, and wraps it up. It also
* ferries the underlying frame to the nsDisplayItem constructor.
*/
nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
nsDisplayList *aList, uint32_t aIndex = 0);
nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
nsDisplayList *aList, ComputeTransformFunction aTransformGetter, uint32_t aIndex = 0);
nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
nsDisplayItem *aItem, uint32_t aIndex = 0);
@ -2510,6 +2522,7 @@ private:
nsDisplayWrapList mStoredList;
gfx3DMatrix mTransform;
ComputeTransformFunction mTransformGetter;
float mCachedAppUnitsPerPixel;
uint32_t mIndex;
};