Bug 562701, part c: Use Element in nsStyleAnimation::ComputeValue; r=dbaron
authorMs2ger <ms2ger@gmail.com>
Mon, 28 Mar 2011 12:51:59 -0400
changeset 64095 f8aa658b3d39e6247e616f2960b82d297216c37a
parent 64094 cf3a78e9a3103e1ea541c1b89b4080b05b35bc46
child 64096 9df21e557f713c3d104d262f3be8418614f223fa
push idunknown
push userunknown
push dateunknown
reviewersdbaron
bugs562701
milestone2.2a1pre
Bug 562701, part c: Use Element in nsStyleAnimation::ComputeValue; r=dbaron
content/smil/nsSMILCSSProperty.cpp
layout/style/nsStyleAnimation.cpp
layout/style/nsStyleAnimation.h
--- a/content/smil/nsSMILCSSProperty.cpp
+++ b/content/smil/nsSMILCSSProperty.cpp
@@ -37,17 +37,17 @@
 
 /* representation of a SMIL-animatable CSS property on an element */
 
 #include "nsSMILCSSProperty.h"
 #include "nsSMILCSSValueType.h"
 #include "nsSMILValue.h"
 #include "nsComputedDOMStyle.h"
 #include "nsStyleAnimation.h"
-#include "nsIContent.h"
+#include "mozilla/dom/Element.h"
 #include "nsIDOMElement.h"
 
 using namespace mozilla::dom;
 
 // Helper function
 static PRBool
 GetCSSComputedValue(nsIContent* aElem,
                     nsCSSProperty aPropID,
--- a/layout/style/nsStyleAnimation.cpp
+++ b/layout/style/nsStyleAnimation.cpp
@@ -45,20 +45,22 @@
 #include "mozilla/css/StyleRule.h"
 #include "nsString.h"
 #include "nsStyleContext.h"
 #include "nsStyleSet.h"
 #include "nsComputedDOMStyle.h"
 #include "nsCSSParser.h"
 #include "mozilla/css/Declaration.h"
 #include "nsCSSStruct.h"
+#include "mozilla/dom/Element.h"
 #include "prlog.h"
 #include <math.h>
 
 namespace css = mozilla::css;
+namespace dom = mozilla::dom;
 
 // HELPER METHODS
 // --------------
 /*
  * Given two units, this method returns a common unit that they can both be
  * converted into, if possible.  This is intended to facilitate
  * interpolation, distance-computation, and addition between "similar" units.
  *
@@ -1775,17 +1777,17 @@ nsStyleAnimation::AddWeighted(nsCSSPrope
   }
 
   NS_ABORT_IF_FALSE(false, "Can't interpolate using the given common unit");
   return PR_FALSE;
 }
 
 already_AddRefed<css::StyleRule>
 BuildStyleRule(nsCSSProperty aProperty,
-               nsIContent* aTargetElement,
+               dom::Element* aTargetElement,
                const nsAString& aSpecifiedValue,
                PRBool aUseSVGMode)
 {
   // Set up an empty CSS Declaration
   nsAutoPtr<css::Declaration> declaration(new css::Declaration());
   declaration->InitializeEmpty();
 
   PRBool changed; // ignored, but needed as outparam for ParseProperty
@@ -1817,25 +1819,24 @@ BuildStyleRule(nsCSSProperty aProperty,
     return nsnull;
   }
 
   return NS_NewCSSStyleRule(nsnull, declaration.forget());
 }
 
 inline
 already_AddRefed<nsStyleContext>
-LookupStyleContext(nsIContent* aElement)
+LookupStyleContext(dom::Element* aElement)
 {
   nsIDocument* doc = aElement->GetCurrentDoc();
   nsIPresShell* shell = doc->GetShell();
   if (!shell) {
     return nsnull;
   }
-  return nsComputedDOMStyle::GetStyleContextForElement(aElement->AsElement(),
-                                                       nsnull, shell);
+  return nsComputedDOMStyle::GetStyleContextForElement(aElement, nsnull, shell);
 }
 
 
 /**
  * Helper function: StyleWithDeclarationAdded
  * Creates a nsStyleRule with the specified property set to the specified
  * value, and returns a nsStyleContext for this rule, as a sibling of the
  * given element's nsStyleContext.
@@ -1850,17 +1851,17 @@ LookupStyleContext(nsIContent* aElement)
  * @param aSpecifiedValue The value for |aProperty| in our custom style
  *                        context.
  * @param aUseSVGMode     A flag to indicate whether we should parse
  *                        |aSpecifiedValue| in SVG mode.
  * @return The generated custom nsStyleContext, or nsnull on failure.
  */
 already_AddRefed<nsStyleContext>
 StyleWithDeclarationAdded(nsCSSProperty aProperty,
-                          nsIContent* aTargetElement,
+                          dom::Element* aTargetElement,
                           const nsAString& aSpecifiedValue,
                           PRBool aUseSVGMode)
 {
   NS_ABORT_IF_FALSE(aTargetElement, "null target element");
   NS_ABORT_IF_FALSE(aTargetElement->GetCurrentDoc(),
                     "element needs to be in a document "
                     "if we're going to look up its style context");
 
@@ -1883,22 +1884,21 @@ StyleWithDeclarationAdded(nsCSSProperty 
   nsCOMArray<nsIStyleRule> ruleArray;
   ruleArray.AppendObject(styleRule);
   nsStyleSet* styleSet = styleContext->PresContext()->StyleSet();
   return styleSet->ResolveStyleByAddingRules(styleContext, ruleArray);
 }
 
 PRBool
 nsStyleAnimation::ComputeValue(nsCSSProperty aProperty,
-                               nsIContent* aTargetElement,
+                               dom::Element* aTargetElement,
                                const nsAString& aSpecifiedValue,
                                PRBool aUseSVGMode,
                                Value& aComputedValue)
 {
-  // XXXbz aTargetElement should be an Element
   NS_ABORT_IF_FALSE(aTargetElement, "null target element");
   NS_ABORT_IF_FALSE(aTargetElement->GetCurrentDoc(),
                     "we should only be able to actively animate nodes that "
                     "are in a document");
 
   nsCSSProperty propToParse =
     nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_REPORT_OTHER_NAME)
       ? nsCSSProps::OtherNameFor(aProperty) : aProperty;
--- a/layout/style/nsStyleAnimation.h
+++ b/layout/style/nsStyleAnimation.h
@@ -45,25 +45,30 @@
 #include "prtypes.h"
 #include "nsAString.h"
 #include "nsCRTGlue.h"
 #include "nsStringBuffer.h"
 #include "nsCSSProperty.h"
 #include "nsCoord.h"
 #include "nsColor.h"
 
-class nsIContent;
 class nsPresContext;
 class nsStyleContext;
 class nsCSSValue;
 struct nsCSSValueList;
 struct nsCSSValuePair;
 struct nsCSSValuePairList;
 struct nsCSSRect;
 
+namespace mozilla {
+namespace dom {
+class Element;
+} // namespace dom
+} // namespace mozilla
+
 /**
  * Utility class to handle animated style values
  */
 class nsStyleAnimation {
 public:
   class Value;
 
   // Mathematical methods
@@ -166,17 +171,17 @@ public:
    * @param aSpecifiedValue The specified value, from which we'll build our
    *                        computed value.
    * @param aUseSVGMode     A flag to indicate whether we should parse
    *                        |aSpecifiedValue| in SVG mode.
    * @param [out] aComputedValue The resulting computed value.
    * @return PR_TRUE on success, PR_FALSE on failure.
    */
   static PRBool ComputeValue(nsCSSProperty aProperty,
-                             nsIContent* aElement,
+                             mozilla::dom::Element* aElement,
                              const nsAString& aSpecifiedValue,
                              PRBool aUseSVGMode,
                              Value& aComputedValue);
 
   /**
    * Creates a specified value for the given computed value.
    *
    * The first overload fills in an nsCSSValue object; the second