mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1248478 - Remove some obsolete code in XrayWrapper.cpp. r=bholley.
This commit is contained in:
parent
993ec91c0e
commit
4f5d92624b
@ -8,8 +8,6 @@
|
||||
#include "AccessCheck.h"
|
||||
#include "WrapperFactory.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsDependentString.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
@ -1256,17 +1254,10 @@ IsXPCWNHolderClass(const JSClass* clasp)
|
||||
static nsGlobalWindow*
|
||||
AsWindow(JSContext* cx, JSObject* wrapper)
|
||||
{
|
||||
nsGlobalWindow* win;
|
||||
// We want to use our target object here, since we don't want to be
|
||||
// doing a security check while unwrapping.
|
||||
JSObject* target = XrayTraits::getTargetObject(wrapper);
|
||||
nsresult rv = UNWRAP_OBJECT(Window, target, win);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return win;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> piWin = do_QueryInterface(
|
||||
nsContentUtils::XPConnect()->GetNativeOfWrapper(cx, target));
|
||||
return nsGlobalWindow::Cast(piWin);
|
||||
return WindowOrNull(target);
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -1306,53 +1297,6 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext* cx, HandleObject wr
|
||||
if (!JSID_IS_STRING(id))
|
||||
return true;
|
||||
|
||||
// The |controllers| property is accessible as a [ChromeOnly] property on
|
||||
// Window.WebIDL, and [noscript] in XPIDL. Chrome needs to see this over
|
||||
// Xray, so we need to special-case it until we move |Window| to WebIDL.
|
||||
nsGlobalWindow* win = nullptr;
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_CONTROLLERS) &&
|
||||
AccessCheck::isChrome(wrapper) &&
|
||||
(win = AsWindow(cx, wrapper)))
|
||||
{
|
||||
nsCOMPtr<nsIControllers> c;
|
||||
nsresult rv = win->GetControllers(getter_AddRefs(c));
|
||||
if (NS_SUCCEEDED(rv) && c) {
|
||||
rv = nsXPConnect::XPConnect()->WrapNativeToJSVal(cx, CurrentGlobalOrNull(cx),
|
||||
c, nullptr, nullptr, true,
|
||||
desc.value());
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) || !c) {
|
||||
JS_ReportError(cx, "Failed to invoke GetControllers via Xrays");
|
||||
return false;
|
||||
}
|
||||
|
||||
desc.object().set(wrapper);
|
||||
return true;
|
||||
}
|
||||
|
||||
// The |realFrameElement| property is accessible as a [ChromeOnly] property
|
||||
// on Window.WebIDL, and [noscript] in XPIDL. Chrome needs to see this over
|
||||
// Xray, so we need to special-case it until we move |Window| to WebIDL.
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_REALFRAMEELEMENT) &&
|
||||
AccessCheck::isChrome(wrapper) &&
|
||||
(win = AsWindow(cx, wrapper)))
|
||||
{
|
||||
ErrorResult rv;
|
||||
Element* f = win->GetRealFrameElement(rv);
|
||||
if (!f) {
|
||||
desc.object().set(nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!GetOrCreateDOMReflector(cx, f, desc.value())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
desc.object().set(wrapper);
|
||||
return true;
|
||||
}
|
||||
|
||||
XPCNativeInterface* iface;
|
||||
XPCNativeMember* member;
|
||||
XPCWrappedNative* wn = getWN(wrapper);
|
||||
@ -1533,28 +1477,6 @@ XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext* cx, const Wrapper& jsW
|
||||
if (!ok || desc.object())
|
||||
return ok;
|
||||
|
||||
// Check for indexed access on a window.
|
||||
int32_t index = GetArrayIndexFromId(cx, id);
|
||||
if (IsArrayIndex(index)) {
|
||||
nsGlobalWindow* win = AsWindow(cx, wrapper);
|
||||
// Note: As() unwraps outer windows to get to the inner window.
|
||||
if (win) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> subframe = win->IndexedGetter(index);
|
||||
if (subframe) {
|
||||
subframe->EnsureInnerWindow();
|
||||
nsGlobalWindow* global = nsGlobalWindow::Cast(subframe);
|
||||
JSObject* obj = global->FastGetGlobalJSObject();
|
||||
if (MOZ_UNLIKELY(!obj)) {
|
||||
// It's gone?
|
||||
return xpc::Throw(cx, NS_ERROR_FAILURE);
|
||||
}
|
||||
desc.value().setObject(*obj);
|
||||
FillPropertyDescriptor(desc, wrapper, true);
|
||||
return JS_WrapPropertyDescriptor(cx, desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Xray wrappers don't use the regular wrapper hierarchy, so we should be
|
||||
// in the wrapper's compartment here, not the wrappee.
|
||||
MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
|
||||
@ -1562,26 +1484,6 @@ XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext* cx, const Wrapper& jsW
|
||||
return JS_GetOwnPropertyDescriptorById(cx, holder, id, desc);
|
||||
}
|
||||
|
||||
bool
|
||||
XPCWrappedNativeXrayTraits::defineProperty(JSContext* cx, HandleObject wrapper, HandleId id,
|
||||
Handle<PropertyDescriptor> desc,
|
||||
Handle<PropertyDescriptor> existingDesc,
|
||||
JS::ObjectOpResult& result, bool* defined)
|
||||
{
|
||||
*defined = false;
|
||||
RootedObject holder(cx, singleton.ensureHolder(cx, wrapper));
|
||||
|
||||
// Check for an indexed property on a Window. If that's happening, do
|
||||
// nothing but claim we defined it so it won't get added as an expando.
|
||||
int32_t index = GetArrayIndexFromId(cx, id);
|
||||
if (IsArrayIndex(index) && IsWindow(cx, wrapper)) {
|
||||
*defined = true;
|
||||
return result.succeed();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
XPCWrappedNativeXrayTraits::enumerateNames(JSContext* cx, HandleObject wrapper, unsigned flags,
|
||||
AutoIdVector& props)
|
||||
|
@ -135,7 +135,11 @@ public:
|
||||
bool defineProperty(JSContext* cx, JS::HandleObject wrapper, JS::HandleId id,
|
||||
JS::Handle<JS::PropertyDescriptor> desc,
|
||||
JS::Handle<JS::PropertyDescriptor> existingDesc,
|
||||
JS::ObjectOpResult& result, bool* defined);
|
||||
JS::ObjectOpResult& result, bool* defined)
|
||||
{
|
||||
*defined = false;
|
||||
return true;
|
||||
}
|
||||
virtual bool enumerateNames(JSContext* cx, JS::HandleObject wrapper, unsigned flags,
|
||||
JS::AutoIdVector& props);
|
||||
static bool call(JSContext* cx, JS::HandleObject wrapper,
|
||||
@ -143,10 +147,6 @@ public:
|
||||
static bool construct(JSContext* cx, JS::HandleObject wrapper,
|
||||
const JS::CallArgs& args, const js::Wrapper& baseInstance);
|
||||
|
||||
static bool resolveDOMCollectionProperty(JSContext* cx, JS::HandleObject wrapper,
|
||||
JS::HandleObject holder, JS::HandleId id,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> desc);
|
||||
|
||||
static XPCWrappedNative* getWN(JSObject* wrapper);
|
||||
|
||||
virtual void preserveWrapper(JSObject* target) override;
|
||||
|
Loading…
Reference in New Issue
Block a user