Bug 565826. Use Element in SMIL code as needed. r=dholbert
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 14 May 2010 13:04:51 -0400
changeset 42326 1f2660a71a7aabe7a7d73b70c5545f26ac39e1dd
parent 42325 6363de2781b33ef85e51841ea7913ebe5ed6c31a
child 42327 8d16c0b81bcb02e0c0313433a7a510c1f1b8e083
push id13279
push userbzbarsky@mozilla.com
push dateFri, 14 May 2010 17:06:06 +0000
treeherdermozilla-central@5b155fd15dae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs565826
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 565826. Use Element in SMIL code as needed. r=dholbert
content/smil/nsISMILAnimationElement.h
content/smil/nsSMILAnimationController.cpp
content/smil/nsSMILCSSProperty.cpp
content/smil/nsSMILCSSProperty.h
content/smil/nsSMILMappedAttribute.h
content/smil/nsSMILTargetIdentifier.h
content/svg/content/src/nsSVGAnimationElement.cpp
content/svg/content/src/nsSVGAnimationElement.h
layout/svg/base/src/nsSVGUtils.cpp
layout/svg/base/src/nsSVGUtils.h
--- a/content/smil/nsISMILAnimationElement.h
+++ b/content/smil/nsISMILAnimationElement.h
@@ -52,16 +52,22 @@
 class nsISMILAttr;
 class nsSMILAnimationFunction;
 class nsSMILTimeContainer;
 class nsSMILTimedElement;
 class nsIContent;
 class nsIAtom;
 class nsAttrValue;
 
+namespace mozilla {
+namespace dom {
+class Element;
+} // namespace dom
+} // namespace mozilla
+
 enum nsSMILTargetAttrType {
   eSMILTargetAttrType_auto,
   eSMILTargetAttrType_CSS,
   eSMILTargetAttrType_XML
 };
 
 class nsISMILAnimationElement : public nsISupports
 {
@@ -105,17 +111,17 @@ public:
   /*
    * Check for the presence of an attribute in the global namespace.
    */
   virtual PRBool HasAnimAttr(nsIAtom* aAttName) const = 0;
 
   /*
    * Returns the target (animated) element.
    */
-  virtual nsIContent* GetTargetElementContent() = 0;
+  virtual mozilla::dom::Element* GetTargetElementContent() = 0;
 
   /*
    * Returns the name of the target (animated) attribute or property.
    */
   virtual nsIAtom* GetTargetAttributeName() const = 0;
 
   /*
    * Returns the type of the target (animated) attribute or property.
--- a/content/smil/nsSMILAnimationController.cpp
+++ b/content/smil/nsSMILAnimationController.cpp
@@ -38,21 +38,24 @@
 
 #include "nsSMILAnimationController.h"
 #include "nsSMILCompositor.h"
 #include "nsSMILCSSProperty.h"
 #include "nsCSSProps.h"
 #include "nsComponentManagerUtils.h"
 #include "nsITimer.h"
 #include "nsIContent.h"
+#include "mozilla/dom/Element.h"
 #include "nsIDocument.h"
 #include "nsISMILAnimationElement.h"
 #include "nsIDOMSVGAnimationElement.h"
 #include "nsSMILTimedElement.h"
 
+using namespace mozilla::dom;
+
 //----------------------------------------------------------------------
 // nsSMILAnimationController implementation
 
 // Helper method
 static nsRefreshDriver*
 GetRefreshDriverForDoc(nsIDocument* aDoc)
 {
   nsIPresShell* shell = aDoc->GetPrimaryShell();
@@ -627,17 +630,17 @@ nsSMILAnimationController::AddAnimationT
 // Helper function that, given a nsISMILAnimationElement, looks up its target
 // element & target attribute and populates a nsSMILTargetIdentifier
 // for this target.
 /*static*/ PRBool
 nsSMILAnimationController::GetTargetIdentifierForAnimation(
     nsISMILAnimationElement* aAnimElem, nsSMILTargetIdentifier& aResult)
 {
   // Look up target (animated) element
-  nsIContent* targetElem = aAnimElem->GetTargetElementContent();
+  Element* targetElem = aAnimElem->GetTargetElementContent();
   if (!targetElem)
     // Animation has no target elem -- skip it.
     return PR_FALSE;
 
   // Look up target (animated) attribute
   //
   // XXXdholbert As mentioned in SMILANIM section 3.1, attributeName may
   // have an XMLNS prefix to indicate the XML namespace. Need to parse
--- a/content/smil/nsSMILCSSProperty.cpp
+++ b/content/smil/nsSMILCSSProperty.cpp
@@ -41,16 +41,18 @@
 #include "nsSMILCSSValueType.h"
 #include "nsSMILValue.h"
 #include "nsCSSDeclaration.h"
 #include "nsComputedDOMStyle.h"
 #include "nsStyleAnimation.h"
 #include "nsIContent.h"
 #include "nsIDOMElement.h"
 
+using namespace mozilla::dom;
+
 // Helper function
 static PRBool
 GetCSSComputedValue(nsIContent* aElem,
                     nsCSSProperty aPropID,
                     nsAString& aResult)
 {
   NS_ABORT_IF_FALSE(!nsCSSProps::IsShorthand(aPropID),
                     "Can't look up computed value of shorthand property");
@@ -80,17 +82,17 @@ GetCSSComputedValue(nsIContent* aElem,
     computedStyle->GetPropertyValue(aPropID, aResult);
     return PR_TRUE;
   }
   return PR_FALSE;
 }
 
 // Class Methods
 nsSMILCSSProperty::nsSMILCSSProperty(nsCSSProperty aPropID,
-                                     nsIContent* aElement)
+                                     Element* aElement)
   : mPropID(aPropID), mElement(aElement)
 {
   NS_ABORT_IF_FALSE(IsPropertyAnimatable(mPropID),
                     "Creating a nsSMILCSSProperty for a property "
                     "that's not supported for animation");
 }
 
 nsSMILValue
--- a/content/smil/nsSMILCSSProperty.h
+++ b/content/smil/nsSMILCSSProperty.h
@@ -43,30 +43,36 @@
 #include "nsISMILAttr.h"
 #include "nsIAtom.h"
 #include "nsCSSProperty.h"
 #include "nsCSSValue.h"
 
 class nsIContent;
 class nsCSSDeclaration;
 
+namespace mozilla {
+namespace dom {
+class Element;
+} // namespace dom
+} // namespace mozilla
+
 /**
  * nsSMILCSSProperty: Implements the nsISMILAttr interface for SMIL animations
  * that target CSS properties.  Represents a particular animation-targeted CSS
  * property on a particular element.
  */
 class nsSMILCSSProperty : public nsISMILAttr
 {
 public:
   /**
    * Constructs a new nsSMILCSSProperty.
    * @param  aPropID   The CSS property we're interested in animating.
    * @param  aElement  The element whose CSS property is being animated.
    */
-  nsSMILCSSProperty(nsCSSProperty aPropID, nsIContent* aElement);
+  nsSMILCSSProperty(nsCSSProperty aPropID, mozilla::dom::Element* aElement);
 
   // nsISMILAttr methods
   virtual nsresult ValueFromString(const nsAString& aStr,
                                    const nsISMILAnimationElement* aSrcElement,
                                    nsSMILValue& aValue,
                                    PRBool& aCanCache) const;
   virtual nsSMILValue GetBaseValue() const;
   virtual nsresult    SetAnimValue(const nsSMILValue& aValue);
@@ -83,12 +89,12 @@ public:
   static PRBool IsPropertyAnimatable(nsCSSProperty aPropID);
 
 protected:
   nsCSSProperty mPropID;
   // Using non-refcounted pointer for mElement -- we know mElement will stay
   // alive for my lifetime because a nsISMILAttr (like me) only lives as long
   // as the Compositing step, and DOM elements don't get a chance to die during
   // that time.
-  nsIContent*   mElement;
+  mozilla::dom::Element*   mElement;
 };
 
 #endif // NS_SMILCSSPROPERTY_H_
--- a/content/smil/nsSMILMappedAttribute.h
+++ b/content/smil/nsSMILMappedAttribute.h
@@ -61,17 +61,17 @@ class nsSMILMappedAttribute : public nsS
 public:
   /**
    * Constructs a new nsSMILMappedAttribute.
    *
    * @param  aPropID   The CSS property for the mapped attribute we're
    *                   interested in animating.
    * @param  aElement  The element whose attribute is being animated.
    */
-  nsSMILMappedAttribute(nsCSSProperty aPropID, nsIContent* aElement) :
+  nsSMILMappedAttribute(nsCSSProperty aPropID, mozilla::dom::Element* aElement) :
     nsSMILCSSProperty(aPropID, aElement) {}
 
   // nsISMILAttr methods
   virtual nsresult ValueFromString(const nsAString& aStr,
                                    const nsISMILAnimationElement* aSrcElement,
                                    nsSMILValue& aValue,
                                    PRBool& aCanCache) const;
   virtual nsSMILValue GetBaseValue() const;
--- a/content/smil/nsSMILTargetIdentifier.h
+++ b/content/smil/nsSMILTargetIdentifier.h
@@ -33,17 +33,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef NS_SMILTARGETIDENTIFIER_H_
 #define NS_SMILTARGETIDENTIFIER_H_
 
-#include "nsIContent.h"
+#include "mozilla/dom/Element.h"
 #include "nsAutoPtr.h"
 #include "prtypes.h"
 
 /**
  * Struct: nsSMILTargetIdentifier
  *
  * Tuple of: { Animated Element, Attribute Name, Attribute Type (CSS vs. XML) }
  *
@@ -62,17 +62,17 @@ struct nsSMILTargetIdentifier
 
   inline PRBool Equals(const nsSMILTargetIdentifier& aOther) const
   {
     return (aOther.mElement       == mElement &&
             aOther.mAttributeName == mAttributeName &&
             aOther.mIsCSS         == mIsCSS);
   }
 
-  nsRefPtr<nsIContent> mElement;
+  nsRefPtr<mozilla::dom::Element> mElement;
   nsRefPtr<nsIAtom>    mAttributeName; // XXX need to consider namespaces here
   PRPackedBool         mIsCSS;
 };
 
 /**
  * Class: nsSMILWeakTargetIdentifier
  *
  * Version of the above struct that uses non-owning pointers.  These are kept
--- a/content/svg/content/src/nsSVGAnimationElement.cpp
+++ b/content/svg/content/src/nsSVGAnimationElement.cpp
@@ -38,16 +38,18 @@
 
 #include "nsSVGAnimationElement.h"
 #include "nsSVGSVGElement.h"
 #include "nsSMILTimeContainer.h"
 #include "nsSMILAnimationController.h"
 #include "nsSMILAnimationFunction.h"
 #include "nsISMILAttr.h"
 
+using namespace mozilla::dom;
+
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGAnimationElement, nsSVGAnimationElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGAnimationElement, nsSVGAnimationElementBase)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGAnimationElement)
   NS_INTERFACE_MAP_ENTRY(nsISMILAnimationElement)
@@ -130,17 +132,17 @@ nsSVGAnimationElement::GetAnimAttr(nsIAt
 }
 
 PRBool
 nsSVGAnimationElement::HasAnimAttr(nsIAtom* aAttName) const
 {
   return HasAttr(kNameSpaceID_None, aAttName);
 }
 
-nsIContent*
+Element*
 nsSVGAnimationElement::GetTargetElementContent()
 {
   if (HasAttr(kNameSpaceID_XLink, nsGkAtoms::href)) {
     return mHrefTarget.get();
   }
   NS_ABORT_IF_FALSE(!mHrefTarget.get(),
                     "We shouldn't have an xlink:href target "
                     "if we don't have an xlink:href attribute");
--- a/content/svg/content/src/nsSVGAnimationElement.h
+++ b/content/svg/content/src/nsSVGAnimationElement.h
@@ -86,17 +86,17 @@ public:
                                 nsAttrValue& aResult);
 
   // nsISMILAnimationElement interface
   virtual const nsIContent& Content() const;
   virtual nsIContent& Content();
   virtual const nsAttrValue* GetAnimAttr(nsIAtom* aName) const;
   virtual PRBool GetAnimAttr(nsIAtom* aAttName, nsAString& aResult) const;
   virtual PRBool HasAnimAttr(nsIAtom* aAttName) const;
-  virtual nsIContent* GetTargetElementContent();
+  virtual mozilla::dom::Element* GetTargetElementContent();
   virtual nsIAtom* GetTargetAttributeName() const;
   virtual nsSMILTargetAttrType GetTargetAttributeType() const;
   virtual nsSMILTimedElement& TimedElement();
   virtual nsSMILTimeContainer* GetTimeContainer();
 
 protected:
   void UpdateHrefTarget(nsIContent* aNodeForContext,
                         const nsAString& aHrefStr);
--- a/layout/svg/base/src/nsSVGUtils.cpp
+++ b/layout/svg/base/src/nsSVGUtils.cpp
@@ -230,37 +230,38 @@ NS_SMILEnabled()
 
     sInitialized = PR_TRUE;
   }
 
   return gSMILEnabled;
 }
 #endif // MOZ_SMIL
 
-nsIContent*
+Element*
 nsSVGUtils::GetParentElement(nsIContent *aContent)
 {
   // XXXbz I _think_ this is right.  We want to be using the binding manager
   // that would have attached the binding that gives us our anonymous parent.
   // That's the binding manager for the document we actually belong to, which
   // is our owner doc.
   nsIDocument* ownerDoc = aContent->GetOwnerDoc();
   nsBindingManager* bindingManager =
     ownerDoc ? ownerDoc->BindingManager() : nsnull;
 
   if (bindingManager) {
     // if we have a binding manager -- do we have an anonymous parent?
     nsIContent *result = bindingManager->GetInsertionParent(aContent);
     if (result) {
-      return result;
+      return result->AsElement();
     }
   }
 
   // otherewise use the explicit one, whether it's null or not...
-  return aContent->GetParent();
+  nsIContent* parent = aContent->GetParent();
+  return parent ? parent->AsElement() : nsnull;
 }
 
 float
 nsSVGUtils::GetFontSize(Element *aElement)
 {
   if (!aElement)
     return 1.0f;
 
--- a/layout/svg/base/src/nsSVGUtils.h
+++ b/layout/svg/base/src/nsSVGUtils.h
@@ -205,17 +205,17 @@ public:
 NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGFilterProperty, NS_ISVGFILTERPROPERTY_IID)
 
 class nsSVGUtils
 {
 public:
   /*
    * Get the parent element of an nsIContent
    */
-  static nsIContent *GetParentElement(nsIContent *aContent);
+  static mozilla::dom::Element *GetParentElement(nsIContent *aContent);
 
   /*
    * Get a font-size (em) of an nsIContent
    */
   static float GetFontSize(mozilla::dom::Element *aElement);
   static float GetFontSize(nsIFrame *aFrame);
   static float GetFontSize(nsStyleContext *aStyleContext);
   /*