Backed out changeset 92a78fabeb8d (bug 1224186) for causing issues in /dom/interfaces.html
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 13 Apr 2016 15:09:26 +0200
changeset 316797 98048beb73c9f14d7bce903e97df5ec5a660e813
parent 316796 5a1f721a3c56460ae9a2118a129957b045cc1cb4
child 316798 a5d85a401db37ce21888bd641f78dc3d3007ca1c
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1224186
milestone48.0a1
backs out92a78fabeb8d727258cb5313bbc394f3e3786c09
Backed out changeset 92a78fabeb8d (bug 1224186) for causing issues in /dom/interfaces.html
dom/base/nsDOMTokenList.cpp
dom/base/nsDOMTokenList.h
dom/webidl/DOMTokenList.webidl
testing/web-platform/tests/dom/nodes/Element-classlist.html
--- a/dom/base/nsDOMTokenList.cpp
+++ b/dom/base/nsDOMTokenList.cpp
@@ -69,17 +69,17 @@ nsDOMTokenList::IndexedGetter(uint32_t a
     aFound = true;
     attr->AtomAt(aIndex)->ToString(aResult);
   } else {
     aFound = false;
   }
 }
 
 void
-nsDOMTokenList::SetValue(const nsAString& aValue, ErrorResult& rv)
+nsDOMTokenList::SetValue(const nsAString& aValue, mozilla::ErrorResult& rv)
 {
   if (!mElement) {
     return;
   }
 
   rv = mElement->SetAttr(kNameSpaceID_None, mAttrAtom, aValue, true);
 }
 
@@ -177,17 +177,17 @@ nsDOMTokenList::Add(const nsTArray<nsStr
     return;
   }
 
   const nsAttrValue* attr = GetParsedAttr();
   AddInternal(attr, aTokens);
 }
 
 void
-nsDOMTokenList::Add(const nsAString& aToken, ErrorResult& aError)
+nsDOMTokenList::Add(const nsAString& aToken, mozilla::ErrorResult& aError)
 {
   AutoTArray<nsString, 1> tokens;
   tokens.AppendElement(aToken);
   Add(tokens, aError);
 }
 
 void
 nsDOMTokenList::RemoveInternal(const nsAttrValue* aAttr,
@@ -263,17 +263,17 @@ nsDOMTokenList::Remove(const nsTArray<ns
   if (!attr) {
     return;
   }
 
   RemoveInternal(attr, aTokens);
 }
 
 void
-nsDOMTokenList::Remove(const nsAString& aToken, ErrorResult& aError)
+nsDOMTokenList::Remove(const nsAString& aToken, mozilla::ErrorResult& aError)
 {
   AutoTArray<nsString, 1> tokens;
   tokens.AppendElement(aToken);
   Remove(tokens, aError);
 }
 
 bool
 nsDOMTokenList::Toggle(const nsAString& aToken,
@@ -304,53 +304,16 @@ nsDOMTokenList::Toggle(const nsAString& 
       isPresent = true;
     }
   }
 
   return isPresent;
 }
 
 void
-nsDOMTokenList::Replace(const nsAString& aToken,
-                        const nsAString& aNewToken,
-                        ErrorResult& aError)
-{
-  // Doing this here instead of using `CheckToken` because if aToken had invalid
-  // characters, and aNewToken is empty, the returned error should be a
-  // SyntaxError, not an InvalidCharacterError.
-  if (aNewToken.IsEmpty()) {
-    aError.Throw(NS_ERROR_DOM_SYNTAX_ERR);
-    return;
-  }
-
-  aError = CheckToken(aToken);
-  if (aError.Failed()) {
-    return;
-  }
-
-  aError = CheckToken(aNewToken);
-  if (aError.Failed()) {
-    return;
-  }
-
-  const nsAttrValue* attr = GetParsedAttr();
-  if (!attr || !attr->Contains(aToken)) {
-    return;
-  }
-
-  AutoTArray<nsString, 1> tokens;
-
-  tokens.AppendElement(aToken);
-  RemoveInternal(attr, tokens);
-
-  tokens[0] = aNewToken;
-  AddInternal(attr, tokens);
-}
-
-void
 nsDOMTokenList::Stringify(nsAString& aResult)
 {
   if (!mElement) {
     aResult.Truncate();
     return;
   }
 
   mElement->GetAttr(kNameSpaceID_None, mAttrAtom, aResult);
--- a/dom/base/nsDOMTokenList.h
+++ b/dom/base/nsDOMTokenList.h
@@ -58,23 +58,20 @@ public:
   void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aResult);
   bool Contains(const nsAString& aToken, mozilla::ErrorResult& aError);
   void Add(const nsAString& aToken, mozilla::ErrorResult& aError);
   void Add(const nsTArray<nsString>& aTokens,
            mozilla::ErrorResult& aError);
   void Remove(const nsAString& aToken, mozilla::ErrorResult& aError);
   void Remove(const nsTArray<nsString>& aTokens,
               mozilla::ErrorResult& aError);
-  void Replace(const nsAString& aToken,
-               const nsAString& aNewToken,
-               mozilla::ErrorResult& aError);
   bool Toggle(const nsAString& aToken,
               const mozilla::dom::Optional<bool>& force,
               mozilla::ErrorResult& aError);
-
+  
   void GetValue(nsAString& aResult) { Stringify(aResult); }
   void SetValue(const nsAString& aValue, mozilla::ErrorResult& rv);
   void Stringify(nsAString& aResult);
 
 protected:
   virtual ~nsDOMTokenList();
 
   nsresult CheckToken(const nsAString& aStr);
--- a/dom/webidl/DOMTokenList.webidl
+++ b/dom/webidl/DOMTokenList.webidl
@@ -15,15 +15,13 @@ interface DOMTokenList {
   getter DOMString? item(unsigned long index);
   [Throws]
   boolean contains(DOMString token);
   [Throws]
   void add(DOMString... tokens);
   [Throws]
   void remove(DOMString... tokens);
   [Throws]
-  void replace(DOMString token, DOMString newToken);
-  [Throws]
   boolean toggle(DOMString token, optional boolean force);
   [SetterThrows]
   attribute DOMString value;
   stringifier DOMString ();
 };
--- a/testing/web-platform/tests/dom/nodes/Element-classlist.html
+++ b/testing/web-platform/tests/dom/nodes/Element-classlist.html
@@ -372,30 +372,16 @@ test(function () {
 test(function () {
   var realList = secondelem.classList;
   secondelem.classList = 'foo bar';
   assert_equals(secondelem.classList,realList);
   assert_equals(secondelem.classList.length,2);
   assert_equals(secondelem.classList[0],'foo');
   assert_equals(secondelem.classList[1],'bar');
 }, 'classList must have [PutForwards=value]');
-test(function () {
-  var foo = document.createElement('div');
-  foo.className = 'a';
-  foo.classList.replace('token1', 'token2');
-
-  assert_equals(foo.className, 'a');
-
-  foo.classList.replace('a', 'b');
-  assert_equals(foo.className, 'b');
-
-  assert_throws('SYNTAX_ERR', function () { foo.classList.replace('t with space', '') });
-  assert_throws('INVALID_CHARACTER_ERR', function () { foo.classList.replace('t with space', 'foo') });
-  assert_throws('SYNTAX_ERR', function () { foo.classList.replace('', 'foo') });
-}, 'classList.replace should work');
     </script>
   </head>
   <body>
 
     <div id="log"></div>
 
   </body>
 </html>