Bug 562701, part a: Use Element in nsSMILCSSValueType::ValueFromString; r=smaug
authorMs2ger <ms2ger@gmail.com>
Mon, 28 Mar 2011 12:49:11 -0400
changeset 64093 d2f3c03bed30bd0c5dc00821ed9711ffce3f8cce
parent 64092 02b10719b05027c06348b87746ceca0497d02edd
child 64094 cf3a78e9a3103e1ea541c1b89b4080b05b35bc46
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs562701
milestone2.2a1pre
Bug 562701, part a: Use Element in nsSMILCSSValueType::ValueFromString; r=smaug
content/smil/nsSMILCSSValueType.cpp
content/smil/nsSMILCSSValueType.h
--- a/content/smil/nsSMILCSSValueType.cpp
+++ b/content/smil/nsSMILCSSValueType.cpp
@@ -40,19 +40,21 @@
 #include "nsSMILCSSValueType.h"
 #include "nsString.h"
 #include "nsStyleAnimation.h"
 #include "nsSMILParserUtils.h"
 #include "nsSMILValue.h"
 #include "nsCSSValue.h"
 #include "nsColor.h"
 #include "nsPresContext.h"
-#include "nsIContent.h"
+#include "mozilla/dom/Element.h"
 #include "nsDebug.h"
 
+using namespace mozilla::dom;
+
 /*static*/ nsSMILCSSValueType nsSMILCSSValueType::sSingleton;
 
 struct ValueWrapper {
   ValueWrapper(nsCSSProperty aPropID, const nsStyleAnimation::Value& aValue,
                nsPresContext* aPresContext) :
     mPropID(aPropID), mCSSValue(aValue), mPresContext(aPresContext) {}
 
   nsCSSProperty mPropID;
@@ -345,33 +347,33 @@ nsSMILCSSValueType::Interpolate(const ns
                                        endWrapper->mPresContext);
     return NS_OK;
   }
   return NS_ERROR_FAILURE;
 }
 
 // Helper function to extract presContext
 static nsPresContext*
-GetPresContextForElement(nsIContent* aElem)
+GetPresContextForElement(Element* aElem)
 {
   nsIDocument* doc = aElem->GetCurrentDoc();
   if (!doc) {
     // This can happen if we process certain types of restyles mid-sample
     // and remove anonymous animated content from the document as a result.
     // See bug 534975.
     return nsnull;
   }
   nsIPresShell* shell = doc->GetShell();
   return shell ? shell->GetPresContext() : nsnull;
 }
 
 // Helper function to parse a string into a nsStyleAnimation::Value
 static PRBool
 ValueFromStringHelper(nsCSSProperty aPropID,
-                      nsIContent* aTargetElement,
+                      Element* aTargetElement,
                       nsPresContext* aPresContext,
                       const nsAString& aString,
                       nsStyleAnimation::Value& aStyleAnimValue)
 {
   // If value is negative, we'll strip off the "-" so the CSS parser won't
   // barf, and then manually make the parsed value negative.
   // (This is a partial solution to let us accept some otherwise out-of-bounds
   // CSS values. Bug 501188 will provide a more complete fix.)
@@ -400,21 +402,20 @@ ValueFromStringHelper(nsCSSProperty aPro
                                   aPresContext->TextZoom());
   }
   return PR_TRUE;
 }
 
 // static
 void
 nsSMILCSSValueType::ValueFromString(nsCSSProperty aPropID,
-                                    nsIContent* aTargetElement,
+                                    Element* aTargetElement,
                                     const nsAString& aString,
                                     nsSMILValue& aValue)
 {
-  // XXXbz aTargetElement should be an Element
   NS_ABORT_IF_FALSE(aValue.IsNull(), "Outparam should be null-typed");
   nsPresContext* presContext = GetPresContextForElement(aTargetElement);
   if (!presContext) {
     NS_WARNING("Not parsing animation value; unable to get PresContext");
     return;
   }
 
   nsStyleAnimation::Value parsedValue;
--- a/content/smil/nsSMILCSSValueType.h
+++ b/content/smil/nsSMILCSSValueType.h
@@ -39,25 +39,32 @@
 
 #ifndef NS_SMILCSSVALUETYPE_H_
 #define NS_SMILCSSVALUETYPE_H_
 
 #include "nsISMILType.h"
 #include "nsCSSProperty.h"
 #include "nscore.h" // For NS_OVERRIDE
 
-class nsIContent;
 class nsAString;
 
+namespace mozilla {
+namespace dom {
+class Element;
+} // namespace dom
+} // namespace mozilla
+
 /*
  * nsSMILCSSValueType: Represents a SMIL-animated CSS value.
  */
 class nsSMILCSSValueType : public nsISMILType
 {
 public:
+  typedef mozilla::dom::Element Element;
+
   // Singleton for nsSMILValue objects to hold onto.
   static nsSMILCSSValueType sSingleton;
 
 protected:
   // nsISMILType Methods
   // -------------------
   NS_OVERRIDE virtual void     Init(nsSMILValue& aValue) const;
   NS_OVERRIDE virtual void     Destroy(nsSMILValue&) const;
@@ -92,17 +99,17 @@ public:
    *                              setting applies.
    * @param       aString         The string to be parsed as a CSS value.
    * @param [out] aValue          The nsSMILValue to be populated. Should
    *                              initially be null-typed.
    * @pre  aValue.IsNull()
    * @post aValue.IsNull() || aValue.mType == nsSMILCSSValueType::sSingleton
    */
   static void ValueFromString(nsCSSProperty aPropID,
-                              nsIContent* aTargetElement,
+                              Element* aTargetElement,
                               const nsAString& aString,
                               nsSMILValue& aValue);
 
   /**
    * Creates a string representation of the given nsSMILValue.
    *
    * Note: aValue is expected to be of this type (that is, it's expected to
    * have been initialized by nsSMILCSSValueType::sSingleton).  If aValue is a