mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
Issue #2197 - Part 1b: Transferables should be arrays of objects
Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1336020
This commit is contained in:
parent
438cdbd913
commit
47147d58b0
24 changed files with 118 additions and 129 deletions
|
|
@ -9993,3 +9993,33 @@ nsContentUtils::GetClosestNonNativeAnonymousAncestor(Element* aElement)
|
|||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
nsContentUtils::CreateJSValueFromSequenceOfObject(JSContext* aCx,
|
||||
const Sequence<JSObject*>& aTransfer,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
if (aTransfer.IsEmpty()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, aTransfer.Length()));
|
||||
if (!array) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < aTransfer.Length(); ++i) {
|
||||
JS::Rooted<JSObject*> object(aCx, aTransfer[i]);
|
||||
if (!object) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!JS_DefineElement(aCx, array, i, object,
|
||||
JSPROP_ENUMERATE))) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
aValue.setObject(*array);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue