mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 07:01:19 +00:00
Bug 1477432 - Part 6: Stop using nsIJSID inside of WebIDL bindings, r=mccr8
Rather than adding a native type for nsID objects in WebIDL, this patch just takes the approach of switching consumers over to using 'any' and calling the APIs defined in Part 1. Differential Revision: https://phabricator.services.mozilla.com/D2283
This commit is contained in:
parent
7954235168
commit
d036b747e7
dom
base
MozQueryInterface.cppMozQueryInterface.hnsGlobalWindowInner.cppnsGlobalWindowInner.hnsGlobalWindowOuter.h
bindings
chrome-webidl
webidl
xhr
@ -80,14 +80,15 @@ MozQueryInterface::QueriesTo(const nsIID& aIID) const
|
||||
|
||||
void
|
||||
MozQueryInterface::LegacyCall(JSContext* cx, JS::Handle<JS::Value> thisv,
|
||||
nsIJSID* aIID,
|
||||
JS::Handle<JS::Value> aIID,
|
||||
JS::MutableHandle<JS::Value> aResult,
|
||||
ErrorResult& aRv) const
|
||||
{
|
||||
if (!QueriesTo(*aIID->GetID())) {
|
||||
aRv.Throw(NS_ERROR_NO_INTERFACE);
|
||||
} else {
|
||||
Maybe<nsID> id = xpc::JSValue2ID(cx, aIID);
|
||||
if (id && QueriesTo(*id)) {
|
||||
aResult.set(thisv);
|
||||
} else {
|
||||
aRv.Throw(NS_ERROR_NO_INTERFACE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,10 @@ public:
|
||||
|
||||
bool QueriesTo(const nsIID& aIID) const;
|
||||
|
||||
void LegacyCall(JSContext* cx, JS::Handle<JS::Value> thisv, nsIJSID* aIID, JS::MutableHandle<JS::Value> aResult, ErrorResult& aRv) const;
|
||||
void LegacyCall(JSContext* cx, JS::Handle<JS::Value> thisv,
|
||||
JS::Handle<JS::Value> aIID,
|
||||
JS::MutableHandle<JS::Value> aResult,
|
||||
ErrorResult& aRv) const;
|
||||
|
||||
nsISupports* GetParentObject() const { return nullptr; }
|
||||
|
||||
|
@ -5008,7 +5008,7 @@ nsGlobalWindowInner::GetInterface(const nsIID & aIID, void **aSink)
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindowInner::GetInterface(JSContext* aCx, nsIJSID* aIID,
|
||||
nsGlobalWindowInner::GetInterface(JSContext* aCx, JS::Handle<JS::Value> aIID,
|
||||
JS::MutableHandle<JS::Value> aRetval,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
|
@ -69,7 +69,6 @@ class nsIDOMWindowUtils;
|
||||
class nsDOMOfflineResourceList;
|
||||
class nsIScrollableFrame;
|
||||
class nsIControllers;
|
||||
class nsIJSID;
|
||||
class nsIScriptContext;
|
||||
class nsIScriptTimeoutHandler;
|
||||
class nsITabChild;
|
||||
@ -978,7 +977,7 @@ public:
|
||||
nsIPrincipal& aSubjectPrincipal,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
void GetInterface(JSContext* aCx, nsIJSID* aIID,
|
||||
void GetInterface(JSContext* aCx, JS::Handle<JS::Value> aIID,
|
||||
JS::MutableHandle<JS::Value> aRetval,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
|
@ -64,7 +64,6 @@ class nsIDocShellTreeOwner;
|
||||
class nsIDOMWindowUtils;
|
||||
class nsIScrollableFrame;
|
||||
class nsIControllers;
|
||||
class nsIJSID;
|
||||
class nsIScriptContext;
|
||||
class nsIScriptTimeoutHandler;
|
||||
class nsITabChild;
|
||||
|
@ -1397,18 +1397,12 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
return Throw(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
|
||||
}
|
||||
|
||||
if (!args[0].isObject()) {
|
||||
Maybe<nsIID> iid = xpc::JSValue2ID(cx, args[0]);
|
||||
if (!iid) {
|
||||
return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIJSID> iid;
|
||||
obj = &args[0].toObject();
|
||||
if (NS_FAILED(UnwrapArg<nsIJSID>(cx, obj, getter_AddRefs(iid)))) {
|
||||
return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
}
|
||||
MOZ_ASSERT(iid);
|
||||
|
||||
if (iid->GetID()->Equals(NS_GET_IID(nsIClassInfo))) {
|
||||
if (iid->Equals(NS_GET_IID(nsIClassInfo))) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIClassInfo> ci = do_QueryInterface(native, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -1419,7 +1413,7 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> unused;
|
||||
nsresult rv = native->QueryInterface(*iid->GetID(), getter_AddRefs(unused));
|
||||
nsresult rv = native->QueryInterface(*iid, getter_AddRefs(unused));
|
||||
if (NS_FAILED(rv)) {
|
||||
return Throw(cx, rv);
|
||||
}
|
||||
@ -1430,10 +1424,14 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
|
||||
void
|
||||
GetInterfaceImpl(JSContext* aCx, nsIInterfaceRequestor* aRequestor,
|
||||
nsWrapperCache* aCache, nsIJSID* aIID,
|
||||
nsWrapperCache* aCache, JS::Handle<JS::Value> aIID,
|
||||
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aError)
|
||||
{
|
||||
const nsID* iid = aIID->GetID();
|
||||
Maybe<nsIID> iid = xpc::JSValue2ID(aCx, aIID);
|
||||
if (!iid) {
|
||||
aError.Throw(NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<nsISupports> result;
|
||||
aError = aRequestor->GetInterface(*iid, getter_AddRefs(result));
|
||||
@ -1441,7 +1439,7 @@ GetInterfaceImpl(JSContext* aCx, nsIInterfaceRequestor* aRequestor,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!WrapObject(aCx, result, iid, aRetval)) {
|
||||
if (!WrapObject(aCx, result, iid.ptr(), aRetval)) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
|
||||
class nsGenericHTMLElement;
|
||||
class nsIJSID;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -1907,12 +1906,12 @@ WantsQueryInterface
|
||||
|
||||
void
|
||||
GetInterfaceImpl(JSContext* aCx, nsIInterfaceRequestor* aRequestor,
|
||||
nsWrapperCache* aCache, nsIJSID* aIID,
|
||||
nsWrapperCache* aCache, JS::Handle<JS::Value> aIID,
|
||||
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aError);
|
||||
|
||||
template<class T>
|
||||
void
|
||||
GetInterface(JSContext* aCx, T* aThis, nsIJSID* aIID,
|
||||
GetInterface(JSContext* aCx, T* aThis, JS::Handle<JS::Value> aIID,
|
||||
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aError)
|
||||
{
|
||||
GetInterfaceImpl(aCx, aThis, aThis, aIID, aRetval, aError);
|
||||
|
@ -459,11 +459,6 @@ DOMInterfaces = {
|
||||
'headerFile': 'IDBEvents.h',
|
||||
},
|
||||
|
||||
'IID': {
|
||||
'nativeType': 'nsIJSID',
|
||||
'headerFile': 'xpcjsid.h',
|
||||
},
|
||||
|
||||
'ImageCapture': {
|
||||
'binaryNames': { 'videoStreamTrack': 'GetVideoStreamTrack' }
|
||||
},
|
||||
|
@ -2288,10 +2288,9 @@ class MethodDefiner(PropertyDefiner):
|
||||
raise TypeError("Legacy QueryInterface member shouldn't be static")
|
||||
signatures = m.signatures()
|
||||
|
||||
def argTypeIsIID(arg):
|
||||
return arg.type.inner.isExternal() and arg.type.inner.identifier.name == 'IID'
|
||||
if len(signatures) > 1 or len(signatures[0][1]) > 1 or not argTypeIsIID(signatures[0][1][0]):
|
||||
raise TypeError("There should be only one QueryInterface method with 1 argument of type IID")
|
||||
if (len(signatures) > 1 or len(signatures[0][1]) > 1 or
|
||||
not signatures[0][1][0].type.isAny()):
|
||||
raise TypeError("There should be only one QueryInterface method with 1 argument of type any")
|
||||
|
||||
# Make sure to not stick QueryInterface on abstract interfaces.
|
||||
if (not self.descriptor.interface.hasInterfacePrototypeObject() or
|
||||
|
@ -17,7 +17,7 @@
|
||||
[ChromeOnly, Exposed=Window]
|
||||
interface MozQueryInterface {
|
||||
[Throws]
|
||||
legacycaller any (IID aIID);
|
||||
legacycaller any (any aIID);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
interface nsISupports;
|
||||
interface IID;
|
||||
|
||||
[NoInterfaceObject,
|
||||
// Need Exposed here, because this is a mixin onto things like Event
|
||||
@ -14,7 +13,7 @@ interface IID;
|
||||
interface LegacyQueryInterface {
|
||||
// Legacy QueryInterface, only exposed to chrome code on the main thread.
|
||||
[Exposed=Window, ChromeOnly]
|
||||
nsISupports QueryInterface(IID iid);
|
||||
nsISupports QueryInterface(any iid);
|
||||
};
|
||||
|
||||
DOMParser implements LegacyQueryInterface;
|
||||
|
@ -19,7 +19,6 @@
|
||||
* https://wicg.github.io/visual-viewport/#the-visualviewport-interface
|
||||
*/
|
||||
|
||||
interface IID;
|
||||
interface nsIBrowserDOMWindow;
|
||||
interface XULControllers;
|
||||
interface nsIDOMWindowUtils;
|
||||
@ -340,7 +339,7 @@ partial interface Window {
|
||||
NonEnumerable, Replaceable, Throws, NeedsCallerType]
|
||||
readonly attribute object? content;
|
||||
|
||||
[Throws, ChromeOnly] any getInterface(IID iid);
|
||||
[Throws, ChromeOnly] any getInterface(any iid);
|
||||
|
||||
/**
|
||||
* Same as nsIDOMWindow.windowRoot, useful for event listener targeting.
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
interface InputStream;
|
||||
interface MozChannel;
|
||||
interface IID;
|
||||
|
||||
enum XMLHttpRequestResponseType {
|
||||
"",
|
||||
@ -127,7 +126,7 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
||||
readonly attribute MozChannel? channel;
|
||||
|
||||
[Throws, ChromeOnly, Exposed=Window]
|
||||
any getInterface(IID iid);
|
||||
any getInterface(any iid);
|
||||
|
||||
[ChromeOnly, Exposed=Window]
|
||||
void setOriginAttributes(optional OriginAttributesDictionary originAttributes);
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include "mozilla/dom/XMLHttpRequestEventTarget.h"
|
||||
#include "mozilla/dom/XMLHttpRequestBinding.h"
|
||||
|
||||
class nsIJSID;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@ -134,7 +132,7 @@ public:
|
||||
|
||||
// We need a GetInterface callable from JS for chrome JS
|
||||
virtual void
|
||||
GetInterface(JSContext* aCx, nsIJSID* aIID,
|
||||
GetInterface(JSContext* aCx, JS::Handle<JS::Value> aIID,
|
||||
JS::MutableHandle<JS::Value> aRetval,
|
||||
ErrorResult& aRv) = 0;
|
||||
|
||||
|
@ -3508,7 +3508,7 @@ XMLHttpRequestMainThread::GetInterface(const nsIID & aIID, void **aResult)
|
||||
}
|
||||
|
||||
void
|
||||
XMLHttpRequestMainThread::GetInterface(JSContext* aCx, nsIJSID* aIID,
|
||||
XMLHttpRequestMainThread::GetInterface(JSContext* aCx, JS::Handle<JS::Value> aIID,
|
||||
JS::MutableHandle<JS::Value> aRetval,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
|
@ -58,7 +58,6 @@
|
||||
|
||||
class nsIJARChannel;
|
||||
class nsILoadGroup;
|
||||
class nsIJSID;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -442,7 +441,7 @@ public:
|
||||
|
||||
// We need a GetInterface callable from JS for chrome JS
|
||||
virtual void
|
||||
GetInterface(JSContext* aCx, nsIJSID* aIID,
|
||||
GetInterface(JSContext* aCx, JS::Handle<JS::Value> aIID,
|
||||
JS::MutableHandle<JS::Value> aRetval,
|
||||
ErrorResult& aRv) override;
|
||||
|
||||
|
@ -215,7 +215,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void
|
||||
GetInterface(JSContext* aCx, nsIJSID* aIID,
|
||||
GetInterface(JSContext* aCx, JS::Handle<JS::Value> aIID,
|
||||
JS::MutableHandle<JS::Value> aRetval,
|
||||
ErrorResult& aRv) override
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user