Bug 834877 part 5. Add an overload of GetAttribute that takes a DOMString. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 29 Jan 2013 09:42:15 -0500
changeset 120224 27e211d02a7ab9f13d1252cba8c4d4e538df0788
parent 120223 4f59efe7733355f97fb2a9fedf219a44bb306720
child 120225 c669c3af96d4c4ebd7b6c546cb33253abd62921b
push id24243
push userryanvm@gmail.com
push dateWed, 30 Jan 2013 00:49:21 +0000
treeherdermozilla-central@5c248ef0fe62 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs834877
milestone21.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 834877 part 5. Add an overload of GetAttribute that takes a DOMString. r=peterv
content/base/public/Element.h
content/base/src/Element.cpp
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -559,32 +559,39 @@ public:
   {
     nsDOMSlots *slots = DOMSlots();
     if (!slots->mAttributeMap) {
       slots->mAttributeMap = new nsDOMAttributeMap(this);
     }
 
     return slots->mAttributeMap;
   }
-  virtual void GetAttribute(const nsAString& aName, nsString& aReturn);
+  void GetAttribute(const nsAString& aName, nsString& aReturn)
+  {
+    mozilla::dom::DOMString str;
+    GetAttribute(aName, str);
+    str.ToString(aReturn);
+  }
+
+  void GetAttribute(const nsAString& aName, mozilla::dom::DOMString& aReturn);
   void GetAttributeNS(const nsAString& aNamespaceURI,
                       const nsAString& aLocalName,
                       nsAString& aReturn);
   void SetAttribute(const nsAString& aName, const nsAString& aValue,
                     ErrorResult& aError);
   void SetAttributeNS(const nsAString& aNamespaceURI,
                       const nsAString& aLocalName,
                       const nsAString& aValue,
                       ErrorResult& aError);
-  virtual void RemoveAttribute(const nsAString& aName,
-                               ErrorResult& aError);
+  void RemoveAttribute(const nsAString& aName,
+                       ErrorResult& aError);
   void RemoveAttributeNS(const nsAString& aNamespaceURI,
                          const nsAString& aLocalName,
                          ErrorResult& aError);
-  virtual bool HasAttribute(const nsAString& aName) const
+  bool HasAttribute(const nsAString& aName) const
   {
     return InternalGetExistingAttrNameFromQName(aName) != nullptr;
   }
   bool HasAttributeNS(const nsAString& aNamespaceURI,
                       const nsAString& aLocalName) const;
   already_AddRefed<nsIHTMLCollection>
     GetElementsByTagName(const nsAString& aQualifiedName);
   already_AddRefed<nsIHTMLCollection>
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -693,31 +693,31 @@ Element::GetClientRects(ErrorResult& aEr
   return rectList.forget();
 }
 
 
 //----------------------------------------------------------------------
 
 
 void
-Element::GetAttribute(const nsAString& aName, nsString& aReturn)
+Element::GetAttribute(const nsAString& aName, DOMString& aReturn)
 {
   const nsAttrValue* val =
     mAttrsAndChildren.GetAttr(aName,
                               IsHTML() && IsInHTMLDocument() ?
                                 eIgnoreCase : eCaseMatters);
   if (val) {
     val->ToString(aReturn);
   } else {
     if (IsXUL()) {
       // XXX should be SetDOMStringToNull(aReturn);
       // See bug 232598
-      aReturn.Truncate();
+      // aReturn is already empty
     } else {
-      SetDOMStringToNull(aReturn);
+      aReturn.SetNull();
     }
   }
 }
 
 void
 Element::SetAttribute(const nsAString& aName,
                       const nsAString& aValue,
                       ErrorResult& aError)