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

This commit is contained in:
Boris Zbarsky 2013-02-22 09:56:29 -05:00
parent 30ff6fd171
commit 719d8ce284
4 changed files with 7 additions and 50 deletions

View File

@ -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;

View File

@ -6667,19 +6667,6 @@ nsNavigatorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
// DOM Node helper
template<nsresult (*func)(JSContext *cx, JSObject *obj, jsval *vp)>
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<nsIDocument> 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<DocumentURIObjectGetter>,
nullptr,
JSPROP_READONLY | JSPROP_SHARED);
}
return rv;
}
NS_IMETHODIMP
nsDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, uint32_t flags,

View File

@ -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);

View File

@ -203,6 +203,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