mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1492737 - Part 1: Support passing name length to JS_GetOwnUCPropertyDescriptor and add JS_GetUCPropertyDescriptor; r=Waldo
This commit is contained in:
parent
7c4a528627
commit
74ebd2ba1e
@ -984,7 +984,8 @@ nsXBLBinding::DoInitJSClass(JSContext *cx,
|
||||
// to create and define it.
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
JS::Rooted<JS::PropertyDescriptor> desc(cx);
|
||||
if (!JS_GetOwnUCPropertyDescriptor(cx, holder, aClassName.get(), &desc)) {
|
||||
if (!JS_GetOwnUCPropertyDescriptor(cx, holder, aClassName.get(),
|
||||
aClassName.Length(), &desc)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aNew = !desc.object();
|
||||
|
@ -96,11 +96,15 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
|
||||
// end up with a different content prototype, but we'll already have a property
|
||||
// holder called |foo| in the XBL scope. Check for that to avoid wasteful and
|
||||
// weird property holder duplication.
|
||||
const char16_t* className = aPrototypeBinding->ClassName().get();
|
||||
const nsString& className = aPrototypeBinding->ClassName();
|
||||
const char16_t* classNameChars = className.get();
|
||||
const size_t classNameLen = className.Length();
|
||||
|
||||
JS::Rooted<JSObject*> propertyHolder(cx);
|
||||
JS::Rooted<JS::PropertyDescriptor> existingHolder(cx);
|
||||
if (scopeObject != globalObject &&
|
||||
!JS_GetOwnUCPropertyDescriptor(cx, scopeObject, className, &existingHolder)) {
|
||||
!JS_GetOwnUCPropertyDescriptor(cx, scopeObject, classNameChars,
|
||||
classNameLen, &existingHolder)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
bool propertyHolderIsNew = !existingHolder.object() || !existingHolder.value().isObject();
|
||||
@ -115,8 +119,9 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
|
||||
|
||||
// Define it as a property on the scopeObject, using the same name used on
|
||||
// the content side.
|
||||
bool ok = JS_DefineUCProperty(cx, scopeObject, className, -1, propertyHolder,
|
||||
JSPROP_PERMANENT | JSPROP_READONLY);
|
||||
bool ok =
|
||||
JS_DefineUCProperty(cx, scopeObject, classNameChars, classNameLen,
|
||||
propertyHolder, JSPROP_PERMANENT | JSPROP_READONLY);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_UNEXPECTED);
|
||||
} else {
|
||||
propertyHolder = targetClassObject;
|
||||
|
@ -2077,10 +2077,10 @@ JS_GetOwnPropertyDescriptor(JSContext* cx, HandleObject obj, const char* name,
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_GetOwnUCPropertyDescriptor(JSContext* cx, HandleObject obj, const char16_t* name,
|
||||
JS_GetOwnUCPropertyDescriptor(JSContext* cx, HandleObject obj, const char16_t* name, size_t namelen,
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
JSAtom* atom = AtomizeChars(cx, name, js_strlen(name));
|
||||
JSAtom* atom = AtomizeChars(cx, name, namelen);
|
||||
if (!atom) {
|
||||
return false;
|
||||
}
|
||||
@ -2105,7 +2105,19 @@ JS_GetPropertyDescriptor(JSContext* cx, HandleObject obj, const char* name,
|
||||
return false;
|
||||
}
|
||||
RootedId id(cx, AtomToId(atom));
|
||||
return atom && JS_GetPropertyDescriptorById(cx, obj, id, desc);
|
||||
return JS_GetPropertyDescriptorById(cx, obj, id, desc);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_GetUCPropertyDescriptor(JSContext* cx, HandleObject obj, const char16_t* name, size_t namelen,
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
JSAtom* atom = AtomizeChars(cx, name, namelen);
|
||||
if (!atom) {
|
||||
return false;
|
||||
}
|
||||
RootedId id(cx, AtomToId(atom));
|
||||
return JS_GetPropertyDescriptorById(cx, obj, id, desc);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -2183,7 +2183,7 @@ JS_GetOwnPropertyDescriptor(JSContext* cx, JS::HandleObject obj, const char* nam
|
||||
JS::MutableHandle<JS::PropertyDescriptor> desc);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_GetOwnUCPropertyDescriptor(JSContext* cx, JS::HandleObject obj, const char16_t* name,
|
||||
JS_GetOwnUCPropertyDescriptor(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> desc);
|
||||
|
||||
/**
|
||||
@ -2200,6 +2200,10 @@ extern JS_PUBLIC_API(bool)
|
||||
JS_GetPropertyDescriptor(JSContext* cx, JS::HandleObject obj, const char* name,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> desc);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_GetUCPropertyDescriptor(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> desc);
|
||||
|
||||
/**
|
||||
* Define a property on obj.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user