From 4f88923cd858b08e3d3b67ea2aa0304c5ffefb1d Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 22 Feb 2013 09:56:29 -0500 Subject: [PATCH] Bug 842726. Kill off GetterShim and the classinfo support for chrome-only stuff on Document now that we can do that via WebIDL. r=peterv --- content/base/public/nsIDocument.h | 4 +++ dom/base/nsDOMClassInfo.cpp | 49 ------------------------------- dom/base/nsDOMClassInfo.h | 1 - dom/webidl/Document.webidl | 3 ++ 4 files changed, 7 insertions(+), 50 deletions(-) diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 91141453e02..25174df0c5a 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -1939,6 +1939,10 @@ public: void ReleaseCapture() const; virtual void MozSetImageElement(const nsAString& aImageElementId, Element* aElement) = 0; + nsIURI* GetDocumentURIObject() + { + return GetDocumentURI(); + } // Not const because all the full-screen goop is not const virtual bool MozFullScreenEnabled() = 0; virtual Element* GetMozFullScreenElement(mozilla::ErrorResult& rv) = 0; diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index e54982d5551..816a49a891e 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -6667,19 +6667,6 @@ nsNavigatorSH::PreCreate(nsISupports *nativeObj, JSContext *cx, // DOM Node helper -template -static JSBool -GetterShim(JSContext *cx, JSHandleObject obj, JSHandleId /* unused */, JSMutableHandleValue vp) -{ - nsresult rv = (*func)(cx, obj, vp.address()); - if (NS_FAILED(rv)) { - xpc::Throw(cx, rv); - return JS_FALSE; - } - - return JS_TRUE; -} - NS_IMETHODIMP nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj, JSObject **parentObj) @@ -7392,42 +7379,6 @@ nsNamedNodeMapSH::GetNamedItem(nsISupports *aNative, const nsAString& aName, return attr; } -// Can't be static so GetterShim will compile -nsresult -DocumentURIObjectGetter(JSContext *cx, JSObject *obj, jsval *vp) -{ - // This function duplicates some of the logic in XPC_WN_HelperGetProperty - XPCWrappedNative *wrapper = - XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj); - - // The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER - NS_ENSURE_TRUE(!wrapper || wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN); - - nsCOMPtr doc = do_QueryWrappedNative(wrapper, obj); - NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED); - - return WrapNative(cx, JS_GetGlobalForScopeChain(cx), doc->GetDocumentURI(), - &NS_GET_IID(nsIURI), true, vp); -} - -NS_IMETHODIMP -nsDocumentSH::PostCreatePrototype(JSContext * cx, JSObject * proto) -{ - // XXXbz when this goes away, kill GetterShim as well. - // set up our proto first - nsresult rv = nsNodeSH::PostCreatePrototype(cx, proto); - - if (xpc::AccessCheck::isChrome(js::GetObjectCompartment(proto))) { - // Stick a documentURIObject property on there - JS_DefinePropertyById(cx, proto, sDocumentURIObject_id, - JSVAL_VOID, GetterShim, - nullptr, - JSPROP_READONLY | JSPROP_SHARED); - } - - return rv; -} - NS_IMETHODIMP nsDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, JSObject *obj, jsid id, uint32_t flags, diff --git a/dom/base/nsDOMClassInfo.h b/dom/base/nsDOMClassInfo.h index cb8e5c62ff4..f98b0bed49d 100644 --- a/dom/base/nsDOMClassInfo.h +++ b/dom/base/nsDOMClassInfo.h @@ -634,7 +634,6 @@ public: } public: - NS_IMETHOD PostCreatePrototype(JSContext * cx, JSObject * proto); NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, JSObject *obj, jsid id, uint32_t flags, JSObject **objp, bool *_retval); diff --git a/dom/webidl/Document.webidl b/dom/webidl/Document.webidl index 003ef1d0c17..9e8ddb13e4b 100644 --- a/dom/webidl/Document.webidl +++ b/dom/webidl/Document.webidl @@ -204,6 +204,9 @@ partial interface Document { void mozSetImageElement(DOMString aImageElementId, Element? aImageElement); + [ChromeOnly] + readonly attribute URI? documentURIObject; + }; // http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#api