Bug 776517 - Move GetExistingAttrNameFromQName from nsIContent to dom::Element; r=smaug
authorMs2ger <ms2ger@gmail.com>
Wed, 24 Jul 2013 09:39:46 +0200
changeset 151959 c2707e67339cef6a87433b9acad6397f81c000b2
parent 151958 f1dd3c73f48126e7b9e8671c204d35915d3c4820
child 151960 3b4ca49280476bc4e976d6a0de68ef09f8aa45b3
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs776517
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 776517 - Move GetExistingAttrNameFromQName from nsIContent to dom::Element; r=smaug
content/base/public/Element.h
content/base/public/nsIContent.h
content/base/src/DocumentFragment.h
content/base/src/nsGenericDOMDataNode.cpp
content/base/src/nsGenericDOMDataNode.h
content/xul/document/src/XULDocument.cpp
content/xul/templates/src/nsXULContentBuilder.cpp
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -401,17 +401,30 @@ private:
 public:
   virtual void UpdateEditableState(bool aNotify) MOZ_OVERRIDE;
 
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) MOZ_OVERRIDE;
   virtual void UnbindFromTree(bool aDeep = true,
                               bool aNullParent = true) MOZ_OVERRIDE;
-  virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const MOZ_OVERRIDE;
+
+  /**
+   * Normalizes an attribute name and returns it as a nodeinfo if an attribute
+   * with that name exists. This method is intended for character case
+   * conversion if the content object is case insensitive (e.g. HTML). Returns
+   * the nodeinfo of the attribute with the specified name if one exists or
+   * null otherwise.
+   *
+   * @param aStr the unparsed attribute string
+   * @return the node info. May be nullptr.
+   */
+  already_AddRefed<nsINodeInfo>
+  GetExistingAttrNameFromQName(const nsAString& aStr) const;
+
   nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
                    const nsAString& aValue, bool aNotify)
   {
     return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
   }
 
   /**
    * Helper for SetAttr/SetParsedAttr. This method will return true if aNotify
--- a/content/base/public/nsIContent.h
+++ b/content/base/public/nsIContent.h
@@ -29,18 +29,18 @@ struct IMEState;
 enum nsLinkState {
   eLinkState_Unvisited  = 1,
   eLinkState_Visited    = 2,
   eLinkState_NotLink    = 3 
 };
 
 // IID for the nsIContent interface
 #define NS_ICONTENT_IID \
-{ 0Xf22c131c, 0Xc554, 0X4d06, \
-  { 0X81, 0Xac, 0X86, 0X64, 0X2f, 0X05, 0Xcc, 0X81 } }
+{ 0x976f4cd1, 0xbdfc, 0x4a1e, \
+  { 0x82, 0x46, 0x1c, 0x13, 0x9c, 0xd3, 0x73, 0x7f } }
 
 /**
  * A node of content in a document's content model. This interface
  * is supported by all content objects.
  */
 class nsIContent : public nsINode {
 public:
   typedef mozilla::widget::IMEState IMEState;
@@ -315,28 +315,16 @@ public:
   /**
    * Returns an atom holding the name of the attribute of type ID on
    * this content node (if applicable).  Returns null for non-element
    * content nodes.
    */
   virtual nsIAtom *GetIDAttributeName() const = 0;
 
   /**
-   * Normalizes an attribute name and returns it as a nodeinfo if an attribute
-   * with that name exists. This method is intended for character case
-   * conversion if the content object is case insensitive (e.g. HTML). Returns
-   * the nodeinfo of the attribute with the specified name if one exists or
-   * null otherwise.
-   *
-   * @param aStr the unparsed attribute string
-   * @return the node info. May be nullptr.
-   */
-  virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const = 0;
-
-  /**
    * Set attribute values. All attribute values are assumed to have a
    * canonical string representation that can be used for these
    * methods. The SetAttr method is assumed to perform a translation
    * of the canonical form into the underlying content specific
    * form.
    *
    * @param aNameSpaceID the namespace of the attribute
    * @param aName the name of the attribute
--- a/content/base/src/DocumentFragment.h
+++ b/content/base/src/DocumentFragment.h
@@ -69,22 +69,16 @@ public:
   virtual ~DocumentFragment()
   {
   }
 
   virtual JSObject* WrapNode(JSContext *aCx,
                              JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // nsIContent
-  virtual already_AddRefed<nsINodeInfo>
-    GetExistingAttrNameFromQName(const nsAString& aStr) const MOZ_OVERRIDE
-  {
-    return nullptr;
-  }
-
   nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
                    const nsAString& aValue, bool aNotify)
   {
     return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
   }
   virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
                            nsIAtom* aPrefix, const nsAString& aValue,
                            bool aNotify) MOZ_OVERRIDE
--- a/content/base/src/nsGenericDOMDataNode.cpp
+++ b/content/base/src/nsGenericDOMDataNode.cpp
@@ -567,22 +567,16 @@ nsGenericDOMDataNode::GetChildren(uint32
 }
 
 nsIAtom *
 nsGenericDOMDataNode::GetIDAttributeName() const
 {
   return nullptr;
 }
 
-already_AddRefed<nsINodeInfo>
-nsGenericDOMDataNode::GetExistingAttrNameFromQName(const nsAString& aStr) const
-{
-  return nullptr;
-}
-
 nsresult
 nsGenericDOMDataNode::SetAttr(int32_t aNameSpaceID, nsIAtom* aAttr,
                               nsIAtom* aPrefix, const nsAString& aValue,
                               bool aNotify)
 {
   return NS_OK;
 }
 
--- a/content/base/src/nsGenericDOMDataNode.h
+++ b/content/base/src/nsGenericDOMDataNode.h
@@ -110,17 +110,17 @@ public:
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) MOZ_OVERRIDE;
   virtual void UnbindFromTree(bool aDeep = true,
                               bool aNullParent = true) MOZ_OVERRIDE;
 
   virtual already_AddRefed<nsINodeList> GetChildren(uint32_t aFilter) MOZ_OVERRIDE;
 
   virtual nsIAtom *GetIDAttributeName() const MOZ_OVERRIDE;
-  virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const MOZ_OVERRIDE;
+
   nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
                    const nsAString& aValue, bool aNotify)
   {
     return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
   }
   virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
                            nsIAtom* aPrefix, const nsAString& aValue,
                            bool aNotify) MOZ_OVERRIDE;
--- a/content/xul/document/src/XULDocument.cpp
+++ b/content/xul/document/src/XULDocument.cpp
@@ -1288,26 +1288,25 @@ NS_IMETHODIMP
 XULDocument::Persist(const nsAString& aID,
                      const nsAString& aAttr)
 {
     // If we're currently reading persisted attributes out of the
     // localstore, _don't_ re-enter and try to set them again!
     if (mApplyingPersistedAttrs)
         return NS_OK;
 
-    nsresult rv;
-
-    nsIContent *element = nsDocument::GetElementById(aID);
-    if (! element)
+    Element* element = nsDocument::GetElementById(aID);
+    if (!element)
         return NS_OK;
 
     nsCOMPtr<nsIAtom> tag;
     int32_t nameSpaceID;
 
     nsCOMPtr<nsINodeInfo> ni = element->GetExistingAttrNameFromQName(aAttr);
+    nsresult rv;
     if (ni) {
         tag = ni->NameAtom();
         nameSpaceID = ni->NamespaceID();
     }
     else {
         // Make sure that this QName is going to be valid.
         const PRUnichar *colon;
         rv = nsContentUtils::CheckQName(PromiseFlatString(aAttr), true, &colon);
--- a/content/xul/templates/src/nsXULContentBuilder.cpp
+++ b/content/xul/templates/src/nsXULContentBuilder.cpp
@@ -141,17 +141,17 @@ protected:
      * Add any necessary persistent attributes (persist="...") from the
      * local store to a generated node.
      *
      * @param aTemplateNode node within template
      * @param aRealNode generated node to set persisted attibutes upon
      * @param aResult result to look up variable->value bindings in
      */
     nsresult
-    AddPersistentAttributes(nsIContent* aTemplateNode,
+    AddPersistentAttributes(Element* aTemplateNode,
                             nsIXULTemplateResult* aResult,
                             nsIContent* aRealNode);
 
     /**
      * Recalculate any attributes that have variable references. This will
      * be called when a binding has been changed to update the attributes.
      * The attributes are copied from the node aTemplateNode in the template
      * to the generated node aRealNode, using the values from the result
@@ -508,26 +508,26 @@ nsXULContentBuilder::BuildContentFromTem
         // are created below it.
         //
         // isUnique will be true for nodes above the generation element,
         // isGenerationElement will be true for the generation element,
         // and both will be false for descendants
         bool isGenerationElement = false;
         bool isUnique = aIsUnique;
 
-        {
-            // We identify the resource element by presence of a
-            // "uri='rdf:*'" attribute. (We also support the older
-            // "uri='...'" syntax.)
-            if (tmplKid->HasAttr(kNameSpaceID_None, nsGkAtoms::uri) && aMatch->IsActive()) {
-                isGenerationElement = true;
-                isUnique = false;
-            }
+        // We identify the resource element by presence of a
+        // "uri='rdf:*'" attribute. (We also support the older
+        // "uri='...'" syntax.)
+        if (tmplKid->HasAttr(kNameSpaceID_None, nsGkAtoms::uri) && aMatch->IsActive()) {
+            isGenerationElement = true;
+            isUnique = false;
         }
 
+        MOZ_ASSERT_IF(isGenerationElement, tmplKid->IsElement());
+
         nsIAtom *tag = tmplKid->Tag();
 
 #ifdef PR_LOGGING
         if (PR_LOG_TEST(gXULTemplateLog, PR_LOG_DEBUG)) {
             PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
                    ("xultemplate[%p]     building %s %s %s",
                     this, nsAtomCString(tag).get(),
                     (isGenerationElement ? "[resource]" : ""),
@@ -674,17 +674,18 @@ nsXULContentBuilder::BuildContentFromTem
             // template to incrementally build content.
             mTemplateMap.Put(realKid, tmplKid);
 
             rv = CopyAttributesToElement(tmplKid, realKid, aChild, false);
             if (NS_FAILED(rv)) return rv;
 
             // Add any persistent attributes
             if (isGenerationElement) {
-                rv = AddPersistentAttributes(tmplKid, aChild, realKid);
+                rv = AddPersistentAttributes(tmplKid->AsElement(), aChild,
+                                             realKid);
                 if (NS_FAILED(rv)) return rv;
             }
 
             // the unique content recurses up above. Also, don't recurse if
             // this is a self reference (a reference to the same resource)
             // or we'll end up regenerating the same content.
             if (!aIsSelfReference && !isUnique) {
                 // this call creates the content inside the generation node,
@@ -778,17 +779,17 @@ nsXULContentBuilder::CopyAttributesToEle
             }
         }
     }
 
     return NS_OK;
 }
 
 nsresult
-nsXULContentBuilder::AddPersistentAttributes(nsIContent* aTemplateNode,
+nsXULContentBuilder::AddPersistentAttributes(Element* aTemplateNode,
                                              nsIXULTemplateResult* aResult,
                                              nsIContent* aRealNode)
 {
     if (!mRoot)
         return NS_OK;
 
     nsCOMPtr<nsIRDFResource> resource;
     nsresult rv = GetResultResource(aResult, getter_AddRefs(resource));