Make the style struct store the specified transform list so that we can animate matching lists without matrix decomposition. (Bug 531344) r=dholbert

This commit is contained in:
L. David Baron 2010-07-02 21:18:56 -07:00
parent 60a8a56e92
commit 8e80eed347
4 changed files with 26 additions and 22 deletions

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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

View File

@ -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<nsTransition, 1> 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;
}
};