/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// Store the information for the specialized ICs. struct SetDOMProxyInformation {
SetDOMProxyInformation() {
JS::SetDOMProxyInformation((constvoid*)&DOMProxyHandler::family,
DOMProxyShadows,
&RemoteObjectProxyBase::sCrossOriginProxyFamily);
}
};
// When we create an expando object in EnsureExpandoObject below, we preserve // the wrapper. The wrapper is released when the object is unlinked, but we // should never call these functions after that point.
nsISupports* native = UnwrapDOMObject<nsISupports>(proxy);
nsWrapperCache* cache; // QueryInterface to nsWrapperCache will not GC.
JS::AutoSuppressGCAnalysis suppress;
CallQueryInterface(native, &cache);
MOZ_ASSERT(cache->PreservingWrapper()); #endif
}
staticinlinevoid CheckExpandoAndGeneration(
JSObject* proxy, JS::ExpandoAndGeneration* expandoAndGeneration) { #ifdef DEBUG
JS::Value value = expandoAndGeneration->expando; if (!value.isUndefined()) CheckExpandoObject(proxy, value); #endif
}
staticinlinevoid CheckDOMProxy(JSObject* proxy) { #ifdef DEBUG
MOZ_ASSERT(IsDOMProxy(proxy), "expected a DOM proxy object");
MOZ_ASSERT(!js::gc::EdgeNeedsSweepUnbarriered(&proxy));
nsISupports* native = UnwrapDOMObject<nsISupports>(proxy);
nsWrapperCache* cache; // QI to nsWrapperCache cannot GC for very non-obvious reasons; see // https://searchfox.org/mozilla-central/rev/55da592d85c2baf8d8818010c41d9738c97013d2/js/xpconnect/src/XPCWrappedJSClass.cpp#521,545-548
JS::AutoSuppressGCAnalysis nogc;
CallQueryInterface(native, &cache);
MOZ_ASSERT(cache->GetWrapperPreserveColor() == proxy); #endif
}
bool DOMProxyHandler::set(JSContext* cx, Handle<JSObject*> proxy,
Handle<jsid> id, Handle<JS::Value> v,
Handle<JS::Value> receiver,
ObjectOpResult& result) const {
MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy), "Should not have a XrayWrapper here"); bool done; if (!setCustom(cx, proxy, id, v, &done)) { returnfalse;
} if (done) { return result.succeed();
}
// Make sure to ignore our named properties when checking for own // property descriptors for a set.
Rooted<Maybe<PropertyDescriptor>> ownDesc(cx); if (!getOwnPropDescriptor(cx, proxy, id, /* ignoreNamedProps = */ true,
&ownDesc)) { returnfalse;
}
MOZ_ASSERT(IsDOMProxy(proxy), "expected a DOM proxy object");
JS::Value v = js::GetProxyPrivate(proxy);
MOZ_ASSERT(!v.isObject(), "Should not have expando object directly!");
// The proxy's private slot is set when we allocate the proxy, // so it cannot be |undefined|.
MOZ_ASSERT(!v.isUndefined());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.