From a209826b2042ef9cb4b2b989512c54c3b4e36510 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 7 Nov 2012 08:27:23 -0800 Subject: [PATCH] Bug 808611 - Move valueOf to nsIDOMLocation. r=mrbkap --- dom/base/nsLocation.cpp | 8 ++++++++ dom/interfaces/base/nsIDOMLocation.idl | 3 ++- js/xpconnect/src/XPCJSRuntime.cpp | 1 - js/xpconnect/src/xpcprivate.h | 1 - js/xpconnect/wrappers/XrayWrapper.cpp | 24 ------------------------ 5 files changed, 10 insertions(+), 27 deletions(-) diff --git a/dom/base/nsLocation.cpp b/dom/base/nsLocation.cpp index 1bc67bbb25fe..23d19b3706e3 100644 --- a/dom/base/nsLocation.cpp +++ b/dom/base/nsLocation.cpp @@ -913,6 +913,14 @@ nsLocation::ToString(nsAString& aReturn) return GetHref(aReturn); } +NS_IMETHODIMP +nsLocation::ValueOf(nsIDOMLocation** aReturn) +{ + nsCOMPtr loc(this); + loc.forget(aReturn); + return NS_OK; +} + nsresult nsLocation::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL) { diff --git a/dom/interfaces/base/nsIDOMLocation.idl b/dom/interfaces/base/nsIDOMLocation.idl index 17c46265ef5c..a0ecf16f4526 100644 --- a/dom/interfaces/base/nsIDOMLocation.idl +++ b/dom/interfaces/base/nsIDOMLocation.idl @@ -5,7 +5,7 @@ #include "domstubs.idl" -[scriptable, uuid(a6cf906d-15b3-11d2-932e-00805f8add32)] +[scriptable, uuid(9472bf0f-2d1c-415c-90fd-f4260678b73b)] interface nsIDOMLocation : nsISupports { /** @@ -27,4 +27,5 @@ interface nsIDOMLocation : nsISupports void assign(in DOMString url); DOMString toString(); + nsIDOMLocation valueOf(); }; diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 840cf8d59bd3..bdaf4bae0ed6 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -48,7 +48,6 @@ const char* XPCJSRuntime::mStrings[] = { "constructor", // IDX_CONSTRUCTOR "toString", // IDX_TO_STRING "toSource", // IDX_TO_SOURCE - "valueOf", // IDX_VALUE_OF "lastResult", // IDX_LAST_RESULT "returnCode", // IDX_RETURN_CODE "value", // IDX_VALUE diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index f60d86d3eacf..1a7b3c6e9179 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -768,7 +768,6 @@ public: IDX_CONSTRUCTOR = 0 , IDX_TO_STRING , IDX_TO_SOURCE , - IDX_VALUE_OF , IDX_LAST_RESULT , IDX_RETURN_CODE , IDX_VALUE , diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index ad5debb062cf..556046869086 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -731,13 +731,6 @@ XPCWrappedNativeXrayTraits::preserveWrapper(JSObject *target) ci->PreserveWrapper(wn->Native()); } -static JSBool -IdentityValueOf(JSContext *cx, unsigned argc, jsval *vp) -{ - JS_SET_RVAL(cx, vp, JS_THIS(cx, vp)); - return true; -} - bool XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, JSObject *wrapper, JSObject *holder, jsid id, bool set, @@ -768,23 +761,6 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, JSObject *wrapp return true; } - // Explicitly make valueOf an identity operation so that it plays better - // with the rest of the Xray infrastructure. - if (id == rt->GetStringID(XPCJSRuntime::IDX_VALUE_OF) && - Is(wrapper)) - { - JSFunction *fun = JS_NewFunctionById(cx, &IdentityValueOf, 0, 0, NULL, id); - if (!fun) - return false; - desc->obj = wrapper; - desc->attrs = 0; - desc->getter = NULL; - desc->setter = NULL; - desc->shortid = 0; - desc->value = ObjectValue(*JS_GetFunctionObject(fun)); - return true; - } - desc->obj = NULL; // This will do verification and the method lookup for us.