Bug 779085 - Move attribute stuff from FragmentOrElement to nsGenericElement r=bz
authorDavid Zbarsky <dzbarsky@gmail.com>
Fri, 21 Sep 2012 01:33:31 -0400
changeset 107711 6b3d739129915c6e6685208e1bfd78e12f725950
parent 107710 deda9b2561abf5c34de864d1492b7047fa885dd7
child 107712 1ba44c7c860a695cc0eb0ec6939143251609c284
push id23507
push userryanvm@gmail.com
push dateSat, 22 Sep 2012 02:38:57 +0000
treeherdermozilla-central@8f359a9d1f19 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs779085
milestone18.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 779085 - Move attribute stuff from FragmentOrElement to nsGenericElement r=bz
content/base/src/FragmentOrElement.cpp
content/base/src/nsGenericElement.cpp
content/base/src/nsGenericElement.h
--- a/content/base/src/FragmentOrElement.cpp
+++ b/content/base/src/FragmentOrElement.cpp
@@ -742,29 +742,17 @@ FragmentOrElement::HasAttributes(bool* a
   *aReturn = GetAttrCount() > 0;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 FragmentOrElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
 {
-  if (!IsElement()) {
-    *aAttributes = nullptr;
-    return NS_OK;
-  }
-
-  nsDOMSlots *slots = DOMSlots();
-
-  if (!slots->mAttributeMap) {
-    slots->mAttributeMap = new nsDOMAttributeMap(this->AsElement());
-  }
-
-  NS_ADDREF(*aAttributes = slots->mAttributeMap);
-
+  *aAttributes = nullptr;
   return NS_OK;
 }
 
 nsresult
 FragmentOrElement::HasChildNodes(bool* aReturn)
 {
   *aReturn = mAttrsAndChildren.ChildCount() > 0;
 
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -1682,16 +1682,30 @@ nsGenericElement::GetExistingAttrNameFro
   }
   else {
     NS_ADDREF(nodeInfo = name->NodeInfo());
   }
 
   return nodeInfo;
 }
 
+NS_IMETHODIMP
+nsGenericElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
+{
+  nsDOMSlots *slots = DOMSlots();
+
+  if (!slots->mAttributeMap) {
+    slots->mAttributeMap = new nsDOMAttributeMap(this);
+  }
+
+  NS_ADDREF(*aAttributes = slots->mAttributeMap);
+
+  return NS_OK;
+}
+
 // static
 bool
 nsGenericElement::ShouldBlur(nsIContent *aContent)
 {
   // Determine if the current element is focused, if it is not focused
   // then we should not try to blur
   nsIDocument *document = aContent->GetDocument();
   if (!document)
--- a/content/base/src/nsGenericElement.h
+++ b/content/base/src/nsGenericElement.h
@@ -76,16 +76,19 @@ public:
                               bool aNullParent = true);
   virtual nsIAtom *GetClassAttributeName() const;
   virtual 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);
   }
+
+  NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes);
+
   /**
    * Helper for SetAttr/SetParsedAttr. This method will return true if aNotify
    * is true or there are mutation listeners that must be triggered, the
    * attribute is currently set, and the new value that is about to be set is
    * different to the current value. As a perf optimization the new and old
    * values will not actually be compared if we aren't notifying and we don't
    * have mutation listeners (in which case it's cheap to just return false
    * and let the caller go ahead and set the value).