Bug 881252 - Warn use of getUserData() or setUserData(). r=bz
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Tue, 11 Jun 2013 07:41:42 +0900
changeset 134574 4b69dc0eb786deabc4dbe290e9e622bc108ee1e5
parent 134573 1a7469edb07eea09276bf46a3cf3eb1339cde299
child 134575 7ef0e47cddd4d3df5f86d1e4a8617d3eba7a1a9d
push id29278
push userVYV03354@nifty.ne.jp
push dateMon, 10 Jun 2013 22:42:33 +0000
treeherdermozilla-inbound@4b69dc0eb786 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs881252
milestone24.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 881252 - Warn use of getUserData() or setUserData(). r=bz
content/base/public/nsDeprecatedOperationList.h
content/base/public/nsINode.h
content/base/src/nsINode.cpp
dom/locales/en-US/chrome/dom/dom.properties
--- a/content/base/public/nsDeprecatedOperationList.h
+++ b/content/base/public/nsDeprecatedOperationList.h
@@ -26,8 +26,9 @@ DEPRECATED_OPERATION(NoExposedProps)
 DEPRECATED_OPERATION(MutationEvent)
 DEPRECATED_OPERATION(MozSlice)
 DEPRECATED_OPERATION(Components)
 DEPRECATED_OPERATION(PrefixedVisibilityAPI)
 DEPRECATED_OPERATION(NodeIteratorDetach)
 DEPRECATED_OPERATION(MozAudioData)
 DEPRECATED_OPERATION(LenientThis)
 DEPRECATED_OPERATION(GetPreventDefault)
+DEPRECATED_OPERATION(GetSetUserData)
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -1106,25 +1106,17 @@ public:
   /**
    * Get the UserData object registered for a Key on this node, if any.
    * Should only be used to implement the DOM Level 3 UserData API.
    *
    * @param aKey the key to get UserData for
    * @return aResult the previously registered object for aKey on this node, if
    *                 any
    */
-  nsIVariant* GetUserData(const nsAString& aKey)
-  {
-    nsCOMPtr<nsIAtom> key = do_GetAtom(aKey);
-    if (!key) {
-      return nullptr;
-    }
-
-    return static_cast<nsIVariant*>(GetProperty(DOM_USER_DATA, key));
-  }
+  nsIVariant* GetUserData(const nsAString& aKey);
 
   nsresult GetUserData(const nsAString& aKey, nsIVariant** aResult)
   {
     NS_IF_ADDREF(*aResult = GetUserData(aKey));
   
     return NS_OK;
   }
 
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -632,16 +632,17 @@ SetUserDataProperty(uint16_t aCategory, 
 
   return NS_OK;
 }
 
 nsresult
 nsINode::SetUserData(const nsAString &aKey, nsIVariant *aData,
                      nsIDOMUserDataHandler *aHandler, nsIVariant **aResult)
 {
+  OwnerDoc()->WarnOnceAbout(nsIDocument::eGetSetUserData);
   *aResult = nullptr;
 
   nsCOMPtr<nsIAtom> key = do_GetAtom(aKey);
   if (!key) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   nsresult rv;
@@ -702,16 +703,28 @@ nsINode::SetUserData(JSContext* aCx, con
 
   JS::Rooted<JS::Value> result(aCx);
   JSAutoCompartment ac(aCx, GetWrapper());
   aError = nsContentUtils::XPConnect()->VariantToJS(aCx, GetWrapper(), oldData,
                                                     result.address());
   return result;
 }
 
+nsIVariant*
+nsINode::GetUserData(const nsAString& aKey)
+{
+  OwnerDoc()->WarnOnceAbout(nsIDocument::eGetSetUserData);
+  nsCOMPtr<nsIAtom> key = do_GetAtom(aKey);
+  if (!key) {
+    return nullptr;
+  }
+
+  return static_cast<nsIVariant*>(GetProperty(DOM_USER_DATA, key));
+}
+
 JS::Value
 nsINode::GetUserData(JSContext* aCx, const nsAString& aKey, ErrorResult& aError)
 {
   nsIVariant* data = GetUserData(aKey);
   if (!data) {
     return JS::NullValue();
   }
 
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -127,8 +127,10 @@ NodeIteratorDetachWarning=Calling detach
 # LOCALIZATION NOTE: Do not translate "Mozilla Audio Data API" and "Web Audio API".
 MozAudioDataWarning=The Mozilla Audio Data API is deprecated.  Please use the Web Audio API instead.
 # LOCALIZATION NOTE: Do not translate "LenientThis" and "this"
 LenientThisWarning=Ignoring get or set of property that has [LenientThis] because the "this" object is incorrect.
 # LOCALIZATION NOTE: Do not translate "nsIDOMWindowUtils", "getWindowWithOuterId", or "nsIWindowMediator"
 GetWindowWithOuterIdWarning=Use of nsIDOMWindowUtils.getOuterWindowWithId() is deprecated.  Instead, use the nsIWindowMediator method of the same name.
 # LOCALIZATION NOTE: Do not translate "getPreventDefault" or "defaultPrevented".
 GetPreventDefaultWarning=Use of getPreventDefault() is deprecated.  Use defaultPrevented instead.
+# LOCALIZATION NOTE: Do not translate "getUserData", "setUserData", "WeakMap", or "element.dataset".
+GetSetUserDataWarning=Use of getUserData() or setUserData() is deprecated.  Use WeakMap or element.dataset instead.