From 8e80eed3477410e8f610af1861ff8fd7fce07522 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Fri, 2 Jul 2010 21:18:56 -0700 Subject: [PATCH] Make the style struct store the specified transform list so that we can animate matching lists without matrix decomposition. (Bug 531344) r=dholbert --- layout/style/nsComputedDOMStyle.cpp | 2 +- layout/style/nsRuleNode.cpp | 23 ++++++++++------------- layout/style/nsStyleStruct.cpp | 10 +++++----- layout/style/nsStyleStruct.h | 13 ++++++++++--- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index e373930dbcc..3be04919e5c 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -1021,7 +1021,7 @@ nsresult nsComputedDOMStyle::GetMozTransform(nsIDOMCSSValue **aValue) /* If the "no transforms" flag is set, then we should construct a * single-element entry and hand it back. */ - if (!display->mTransformPresent) { + if (!display->HasTransform()) { nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); if (!val) return NS_ERROR_OUT_OF_MEMORY; diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index c9431b167aa..3e06fbc752c 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -4459,31 +4459,28 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct, */ /* If it's 'none,' indicate that there are no transforms. */ - if (head->mValue.GetUnit() == eCSSUnit_None) - display->mTransformPresent = PR_FALSE; - - /* If we need to inherit, do so by making a full deep-copy. */ + if (head->mValue.GetUnit() == eCSSUnit_None) { + display->mSpecifiedTransform = nsnull; + } + /* If we need to inherit, copy the pointer owned by a style rule */ else if (head->mValue.GetUnit() == eCSSUnit_Inherit) { - display->mTransformPresent = parentDisplay->mTransformPresent; - if (parentDisplay->mTransformPresent) + display->mSpecifiedTransform = parentDisplay->mSpecifiedTransform; + if (parentDisplay->mSpecifiedTransform) display->mTransform = parentDisplay->mTransform; canStoreInRuleTree = PR_FALSE; } /* If it's 'initial', then we reset to empty. */ - else if (head->mValue.GetUnit() == eCSSUnit_Initial) - display->mTransformPresent = PR_FALSE; - + else if (head->mValue.GetUnit() == eCSSUnit_Initial) { + display->mSpecifiedTransform = nsnull; + } /* Otherwise, we are looking at a list of CSS tokens. We'll read each of * them in as an array of nsTransformFunction objects, then will accumulate * them all together to form the final transform matrix. */ else { - + display->mSpecifiedTransform = head; // weak pointer, owned by rule display->mTransform = ReadTransforms(head, aContext, mPresContext, canStoreInRuleTree); - - /* Make sure to say that this data is valid! */ - display->mTransformPresent = PR_TRUE; } } diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 136402cb030..1c71cd85294 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1808,7 +1808,7 @@ nsStyleDisplay::nsStyleDisplay() mClipFlags = NS_STYLE_CLIP_AUTO; mClip.SetRect(0,0,0,0); mOpacity = 1.0f; - mTransformPresent = PR_FALSE; // No transform + mSpecifiedTransform = nsnull; mTransformOrigin[0].SetPercentValue(0.5f); // Transform is centered on origin mTransformOrigin[1].SetPercentValue(0.5f); mTransitions.AppendElement(); @@ -1846,8 +1846,8 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource) mOpacity = aSource.mOpacity; /* Copy over the transformation information. */ - mTransformPresent = aSource.mTransformPresent; - if (mTransformPresent) + mSpecifiedTransform = aSource.mSpecifiedTransform; + if (mSpecifiedTransform) mTransform = aSource.mTransform; /* Copy over transform origin. */ @@ -1894,10 +1894,10 @@ nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const /* If we've added or removed the transform property, we need to reconstruct the frame to add * or remove the view object, and also to handle abs-pos and fixed-pos containers. */ - if (mTransformPresent != aOther.mTransformPresent) { + if (HasTransform() != aOther.HasTransform()) { NS_UpdateHint(hint, nsChangeHint_ReconstructFrame); } - else if (mTransformPresent) { + else if (HasTransform()) { /* Otherwise, if we've kept the property lying around and we already had a * transform, we need to see whether or not we've changed the transform. * If so, we need to do a reflow and a repaint. The reflow is to recompute diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 45b35343944..b7493394850 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -71,6 +71,7 @@ class nsIFrame; class imgIRequest; class imgIContainer; +struct nsCSSValueList; // Includes nsStyleStructID. #include "nsStyleStructFwd.h" @@ -1288,9 +1289,15 @@ struct nsStyleDisplay { PRUint8 mOverflowY; // [reset] see nsStyleConsts.h PRUint8 mResize; // [reset] see nsStyleConsts.h PRUint8 mClipFlags; // [reset] see nsStyleConsts.h - PRPackedBool mTransformPresent; // [reset] Whether there is a -moz-transform. + + // mSpecifiedTransform is the list of transform functions as + // specified, or null to indicate there is no transform. (inherit or + // initial are replaced by an actual list of transform functions, or + // null, as appropriate.) (owned by the style rule) + const nsCSSValueList *mSpecifiedTransform; // [reset] nsStyleTransformMatrix mTransform; // [reset] The stored transform matrix nsStyleCoord mTransformOrigin[2]; // [reset] percent, coord. + nsAutoTArray mTransitions; // [reset] // The number of elements in mTransitions that are not from repeating // a list due to another property being longer. @@ -1333,7 +1340,7 @@ struct nsStyleDisplay { /* Returns true if we're positioned or there's a transform in effect. */ PRBool IsPositioned() const { return IsAbsolutelyPositioned() || - NS_STYLE_POSITION_RELATIVE == mPosition || mTransformPresent; + NS_STYLE_POSITION_RELATIVE == mPosition || HasTransform(); } PRBool IsScrollableOverflow() const { @@ -1353,7 +1360,7 @@ struct nsStyleDisplay { /* Returns whether the element has the -moz-transform property. */ PRBool HasTransform() const { - return mTransformPresent; + return mSpecifiedTransform != nsnull; } };