mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1044305: Remove Location classinfo r=bz
This commit is contained in:
parent
a8756989dc
commit
21dba40d04
@ -50,7 +50,6 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCxPusher.h"
|
||||
#include "nsIDOMGlobalPropertyInitializer.h"
|
||||
#include "nsLocation.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
||||
@ -261,11 +260,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
DEFAULT_SCRIPTABLE_FLAGS |
|
||||
WINDOW_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(Location, nsLocationSH,
|
||||
((DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_ADDPROPERTY) &
|
||||
~nsIXPCScriptable::ALLOW_PROP_MODS_TO_PROTOTYPE))
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(DOMPrototype, nsDOMConstructorSH,
|
||||
DOM_BASE_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_PRECREATE |
|
||||
@ -823,10 +817,6 @@ nsDOMClassInfo::Init()
|
||||
#endif
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Location, nsIDOMLocation)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMLocation)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMPrototype, nsIDOMDOMConstructor)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
@ -3277,62 +3267,6 @@ nsWindowSH::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLocationSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj)
|
||||
{
|
||||
// window.location can be held onto by both evil pages that want to track the
|
||||
// user's progress on the web and bookmarklets that want to use the location
|
||||
// object. Parent it to the outer window so that access checks do the Right
|
||||
// Thing.
|
||||
*parentObj = globalObj;
|
||||
|
||||
nsCOMPtr<nsIDOMLocation> safeLoc(do_QueryInterface(nativeObj));
|
||||
if (!safeLoc) {
|
||||
// Oops, this wasn't really a location object. This can happen if someone
|
||||
// tries to use our scriptable helper as a real object and tries to wrap
|
||||
// it, see bug 319296
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsLocation *loc = (nsLocation *)safeLoc.get();
|
||||
nsIDocShell *ds = loc->GetDocShell();
|
||||
if (!ds) {
|
||||
NS_WARNING("Refusing to create a location in the wrong scope");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(ds);
|
||||
if (!sgo) {
|
||||
NS_WARNING("Refusing to create a location in the wrong scope because the "
|
||||
"docshell is being destroyed");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
*parentObj = sgo->GetGlobalJSObject();
|
||||
return *parentObj ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLocationSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid aId, jsval *vp, bool *_retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> rootedObj(cx, obj);
|
||||
|
||||
// Shadowing protection. This will go away when nsLocation moves to the new
|
||||
// bindings.
|
||||
JS::Rooted<jsid> id(cx, aId);
|
||||
if (wrapper->HasNativeMember(id)) {
|
||||
JS_ReportError(cx, "Permission denied to shadow native property");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsLocation* location = static_cast<nsLocation*>(GetNative(wrapper, rootedObj));
|
||||
location->PreserveWrapper(location);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// EventTarget helper
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -277,31 +277,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// Location scriptable helper
|
||||
|
||||
class nsLocationSH : public nsDOMGenericSH
|
||||
{
|
||||
protected:
|
||||
nsLocationSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsLocationSH()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj) MOZ_OVERRIDE;
|
||||
NS_IMETHODIMP AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, JS::Value *vp, bool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsLocationSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Event handler 'this' translator class, this is called by XPConnect
|
||||
// when a "function interface" (nsIDOMEventListener) is called, this
|
||||
|
@ -5,7 +5,6 @@
|
||||
// IWYU pragma: private, include "nsDOMClassInfoID.h"
|
||||
|
||||
DOMCI_CLASS(Window)
|
||||
DOMCI_CLASS(Location)
|
||||
DOMCI_CLASS(DOMPrototype)
|
||||
DOMCI_CLASS(DOMConstructor)
|
||||
|
||||
|
@ -70,14 +70,11 @@ nsLocation::~nsLocation()
|
||||
{
|
||||
}
|
||||
|
||||
DOMCI_DATA(Location, nsLocation)
|
||||
|
||||
// QueryInterface implementation for nsLocation
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsLocation)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMLocation)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Location)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsLocation, mInnerWindow)
|
||||
|
@ -27,10 +27,6 @@ members = [
|
||||
#
|
||||
# (And nsIDOMModalContentWindow.returnValue is an attribute of type
|
||||
# nsIVariant, which qsgen.py can't handle.)
|
||||
#
|
||||
# nsLocationSH has ~ALLOW_PROP_MODS_TO_PROTOTYPE, so don't try.
|
||||
#'nsIDOMLocation.hostname',
|
||||
#'nsIDOMLocation.href',
|
||||
|
||||
# dom/interfaces/xpath
|
||||
'nsIDOMXPathNSResolver.lookupNamespaceURI',
|
||||
|
Loading…
Reference in New Issue
Block a user