Bug 970764. Remove support for non-optional "any" arguments values, since "any" needs to be able to include undefined anyway. Have "any" arguments and dictionary entries default to undefined unless the IDL explicitly says "= null". r=khuey

This commit is contained in:
Boris Zbarsky 2014-02-19 10:13:38 -05:00
Родитель 75cee27b76
Коммит 7ee245a69d
33 изменённых файлов: 178 добавлений и 207 удалений

Просмотреть файл

@ -83,18 +83,15 @@ public:
JS::Handle<JS::Value> aContextOptions,
ErrorResult& aRv);
void ToDataURL(JSContext* aCx, const nsAString& aType,
const Optional<JS::Handle<JS::Value> >& aParams,
JS::Handle<JS::Value> aParams,
nsAString& aDataURL, ErrorResult& aRv)
{
JS::Handle<JS::Value> params = aParams.WasPassed()
? aParams.Value()
: JS::UndefinedHandleValue;
aRv = ToDataURL(aType, params, aCx, aDataURL);
aRv = ToDataURL(aType, aParams, aCx, aDataURL);
}
void ToBlob(JSContext* aCx,
FileCallback& aCallback,
const nsAString& aType,
const Optional<JS::Handle<JS::Value> >& aParams,
JS::Handle<JS::Value> aParams,
ErrorResult& aRv);
bool MozOpaque() const

Просмотреть файл

@ -487,7 +487,7 @@ void
HTMLCanvasElement::ToBlob(JSContext* aCx,
FileCallback& aCallback,
const nsAString& aType,
const Optional<JS::Handle<JS::Value> >& aParams,
JS::Handle<JS::Value> aParams,
ErrorResult& aRv)
{
// do a trust check if this is a write-only canvas
@ -502,13 +502,9 @@ HTMLCanvasElement::ToBlob(JSContext* aCx,
return;
}
JS::Value encoderOptions = aParams.WasPassed()
? aParams.Value()
: JS::UndefinedValue();
nsAutoString params;
bool usingCustomParseOptions;
aRv = ParseParams(aCx, type, encoderOptions, params, &usingCustomParseOptions);
aRv = ParseParams(aCx, type, aParams, params, &usingCustomParseOptions);
if (aRv.Failed()) {
return;
}

Просмотреть файл

@ -8807,18 +8807,14 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument,
JS::Value
nsGlobalWindow::ShowModalDialog(JSContext* aCx, const nsAString& aUrl,
const Optional<JS::Handle<JS::Value> >& aArgument,
JS::Handle<JS::Value> aArgument,
const nsAString& aOptions,
ErrorResult& aError)
{
nsCOMPtr<nsIVariant> args;
if (aArgument.WasPassed()) {
aError = nsContentUtils::XPConnect()->JSToVariant(aCx,
aArgument.Value(),
getter_AddRefs(args));
} else {
args = CreateVoidVariant();
}
aError = nsContentUtils::XPConnect()->JSToVariant(aCx,
aArgument,
getter_AddRefs(args));
nsCOMPtr<nsIVariant> retVal = ShowModalDialog(aUrl, args, aOptions, aError);
if (aError.Failed()) {

Просмотреть файл

@ -824,7 +824,7 @@ public:
void Prompt(const nsAString& aMessage, const nsAString& aInitial,
nsAString& aReturn, mozilla::ErrorResult& aError);
void Print(mozilla::ErrorResult& aError);
JS::Value ShowModalDialog(JSContext* aCx, const nsAString& aUrl, const mozilla::dom::Optional<JS::Handle<JS::Value> >& aArgument, const nsAString& aOptions, mozilla::ErrorResult& aError);
JS::Value ShowModalDialog(JSContext* aCx, const nsAString& aUrl, JS::Handle<JS::Value> aArgument, const nsAString& aOptions, mozilla::ErrorResult& aError);
void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const nsAString& aTargetOrigin,
const mozilla::dom::Optional<mozilla::dom::Sequence<JS::Value > >& aTransfer,

Просмотреть файл

@ -241,32 +241,14 @@ public:
}
};
// A specialization of Optional for JS::Value to make sure that when someone
// calls Construct() on it we will pre-initialized the JS::Value to
// JS::UndefinedValue() so it can be traced safely.
// A specialization of Optional for JS::Value to make sure no one ever uses it.
template<>
class Optional<JS::Value> : public Optional_base<JS::Value, JS::Value>
class Optional<JS::Value>
{
public:
Optional() :
Optional_base<JS::Value, JS::Value>()
{}
private:
Optional() MOZ_DELETE;
explicit Optional(JS::Value aValue) :
Optional_base<JS::Value, JS::Value>(aValue)
{}
// Don't allow us to have an uninitialized JS::Value
void Construct()
{
Optional_base<JS::Value, JS::Value>::Construct(JS::UndefinedValue());
}
template <class T1>
void Construct(const T1& t1)
{
Optional_base<JS::Value, JS::Value>::Construct(t1);
}
explicit Optional(JS::Value aValue) MOZ_DELETE;
};
// A specialization of Optional for NonNull that lets us get a T& from Value()

Просмотреть файл

@ -11,7 +11,7 @@ import string
import math
import itertools
from WebIDL import BuiltinTypes, IDLBuiltinType, IDLNullValue, IDLSequenceType, IDLType, IDLAttribute
from WebIDL import BuiltinTypes, IDLBuiltinType, IDLNullValue, IDLSequenceType, IDLType, IDLAttribute, IDLUndefinedValue
from Configuration import NoSuchDescriptorError, getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback, Descriptor
AUTOGENERATED_WARNING_COMMENT = \
@ -3844,21 +3844,22 @@ for (uint32_t i = 0; i < length; ++i) {
declType = "JS::Value"
else:
assert not isMember
if isOptional:
# We have a specialization of Optional that will use a
# Rooted for the storage here.
declType = "JS::Handle<JS::Value>"
else:
declType = "JS::Rooted<JS::Value>"
declType = "JS::Rooted<JS::Value>"
declArgs = "cx"
assert not isOptional
templateBody = "${declName} = ${val};"
nullHandling = "${declName} = JS::NullValue()"
templateBody = handleDefaultNull(templateBody, nullHandling)
# We may not have a default value if we're being converted for
# a setter, say.
if defaultValue:
if isinstance(defaultValue, IDLNullValue):
defaultHandling = "${declName} = JS::NullValue()"
else:
assert isinstance(defaultValue, IDLUndefinedValue)
defaultHandling = "${declName} = JS::UndefinedValue()"
templateBody = handleDefault(templateBody, defaultHandling)
return JSToNativeConversionInfo(templateBody,
declType=CGGeneric(declType),
dealWithOptional=isOptional,
declArgs=declArgs)
if type.isObject():
@ -4142,6 +4143,8 @@ def instantiateJSToNativeConversion(info, replacements, checkForValue=False):
def convertConstIDLValueToJSVal(value):
if isinstance(value, IDLNullValue):
return "JS::NullValue()"
if isinstance(value, IDLUndefinedValue):
return "JS::UndefinedValue()"
tag = value.type.tag()
if tag in [IDLType.Tags.int8, IDLType.Tags.uint8, IDLType.Tags.int16,
IDLType.Tags.uint16, IDLType.Tags.int32]:

Просмотреть файл

@ -2531,7 +2531,24 @@ class IDLNullValue(IDLObject):
def _getDependentObjects(self):
return set()
class IDLUndefinedValue(IDLObject):
def __init__(self, location):
IDLObject.__init__(self, location)
self.type = None
self.value = None
def coerceToType(self, type, location):
if not type.isAny():
raise WebIDLError("Cannot coerce undefined value to type %s." % type,
[location])
undefinedValue = IDLUndefinedValue(self.location)
undefinedValue.type = type
return undefinedValue
def _getDependentObjects(self):
return set()
class IDLInterfaceMember(IDLObjectWithIdentifier):
@ -2909,6 +2926,22 @@ class IDLArgument(IDLObjectWithIdentifier):
# Default optional dictionaries to null, for simplicity,
# so the codegen doesn't have to special-case this.
self.defaultValue = IDLNullValue(self.location)
elif self.type.isAny():
assert (self.defaultValue is None or
isinstance(self.defaultValue, IDLNullValue))
if (self.optional and not self.variadic and
not self.dictionaryMember and not self.defaultValue):
raise WebIDLError("Arguments of type 'any' are always optional "
"and shouldn't have the 'optional' keyword "
"unless they're being given a default value "
"of 'null'",
[self.location])
# 'any' values are always optional.
self.optional = True
if not self.defaultValue and not self.variadic:
# Set the default value to undefined, for simplicity, so the
# codegen doesn't have to special-case this.
self.defaultValue = IDLUndefinedValue(self.location)
# Now do the coercing thing; this needs to happen after the
# above creation of a default value.
@ -4288,6 +4321,10 @@ class Parser(Tokenizer):
raise WebIDLError("Mandatory arguments can't have a default value.",
[self.getLocation(p, 6)])
# We can't test t.isAny() here and force optional to true, since at this
# point t is not a fully resolved type yet (e.g. it might be a typedef).
# We'll handle the 'any' case in IDLArgument.complete.
if variadic:
if optional:
raise WebIDLError("Variadic arguments should not be marked optional.",

Просмотреть файл

@ -112,7 +112,7 @@ def WebIDLTest(parser, harness):
checkMethod(methods[11], "::TestMethods::setAny",
"setAny",
[("Void",
[("::TestMethods::setAny::arg1", "arg1", "Any", False, False)])])
[("::TestMethods::setAny::arg1", "arg1", "Any", True, False)])])
checkMethod(methods[12], "::TestMethods::doFloats",
"doFloats",
[("Float",

Просмотреть файл

@ -146,11 +146,11 @@ public:
already_AddRefed<TestInterface> Test2(const GlobalObject&,
JSContext*,
const DictForConstructor&,
JS::Value,
JS::Handle<JS::Value>,
JS::Handle<JSObject*>,
JS::Handle<JSObject*>,
const Sequence<Dict>&,
const Optional<JS::Handle<JS::Value> >&,
JS::Handle<JS::Value>,
const Optional<JS::Handle<JSObject*> >&,
const Optional<JS::Handle<JSObject*> >&,
ErrorResult&);
@ -466,7 +466,6 @@ public:
// Any types
void PassAny(JSContext*, JS::Handle<JS::Value>);
void PassVariadicAny(JSContext*, const Sequence<JS::Value>&);
void PassOptionalAny(JSContext*, const Optional<JS::Handle<JS::Value> >&);
void PassAnyDefaultNull(JSContext*, JS::Handle<JS::Value>);
void PassSequenceOfAny(JSContext*, const Sequence<JS::Value>&);
void PassNullableSequenceOfAny(JSContext*, const Nullable<Sequence<JS::Value> >&);

Просмотреть файл

@ -110,7 +110,8 @@ interface OnlyForUseInConstructor {
NamedConstructor=Test,
NamedConstructor=Test(DOMString str),
NamedConstructor=Test2(DictForConstructor dict, any any1, object obj1,
object? obj2, sequence<Dict> seq, optional any any2,
object? obj2, sequence<Dict> seq,
optional any any2 = null,
optional object obj3, optional object? obj4)
]
interface TestInterface {
@ -428,7 +429,6 @@ interface TestInterface {
// Any types
void passAny(any arg);
void passVariadicAny(any... arg);
void passOptionalAny(optional any arg);
void passAnyDefaultNull(optional any arg = null);
void passSequenceOfAny(sequence<any> arg);
void passNullableSequenceOfAny(sequence<any>? arg);

Просмотреть файл

@ -12,7 +12,8 @@
NamedConstructor=Example,
NamedConstructor=Example(DOMString str),
NamedConstructor=Example2(DictForConstructor dict, any any1, object obj1,
object? obj2, sequence<Dict> seq, optional any any2,
object? obj2, sequence<Dict> seq,
optional any any2 = null,
optional object obj3, optional object? obj4)
]
interface TestExampleInterface {
@ -321,7 +322,6 @@ interface TestExampleInterface {
// Any types
void passAny(any arg);
void passVariadicAny(any... arg);
void passOptionalAny(optional any arg);
void passAnyDefaultNull(optional any arg = null);
void passSequenceOfAny(sequence<any> arg);
void passNullableSequenceOfAny(sequence<any>? arg);

Просмотреть файл

@ -23,7 +23,7 @@ enum MyTestEnum {
TestInterface? iface, long arg1,
DictForConstructor dict, any any1,
object obj1,
object? obj2, sequence<Dict> seq, optional any any2,
object? obj2, sequence<Dict> seq, optional any any2 = null,
optional object obj3,
optional object? obj4),
JSImplementation="@mozilla.org/test-js-impl-interface;1"]
@ -344,7 +344,6 @@ interface TestJSImplInterface {
// Any types
void passAny(any arg);
void passVariadicAny(any... arg);
void passOptionalAny(optional any arg);
void passAnyDefaultNull(optional any arg = null);
void passSequenceOfAny(sequence<any> arg);
void passNullableSequenceOfAny(sequence<any>? arg);

Просмотреть файл

@ -130,9 +130,7 @@ nsDOMMessageEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
bool trusted = event->Init(t);
event->SetTrusted(trusted);
if (aParam.mData.WasPassed()) {
event->mData = aParam.mData.Value();
}
event->mData = aParam.mData;
mozilla::HoldJSObjects(event.get());

Просмотреть файл

@ -79,7 +79,7 @@ dictionary EventInit {
interface CustomEvent : Event {
readonly attribute any detail;
void initCustomEvent(DOMString type, boolean bubbles, boolean cancelable, any details);
void initCustomEvent(DOMString type, boolean bubbles, boolean cancelable, optional any details);
};
dictionary CustomEventInit : EventInit {

Просмотреть файл

@ -697,16 +697,14 @@ IDBCursor::GetValue(JSContext* aCx, ErrorResult& aRv)
void
IDBCursor::Continue(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aKey,
JS::Handle<JS::Value> aKey,
ErrorResult &aRv)
{
MOZ_ASSERT(NS_IsMainThread());
Key key;
if (aKey.WasPassed()) {
aRv = key.SetFromJSVal(aCx, aKey.Value());
ENSURE_SUCCESS_VOID(aRv);
}
aRv = key.SetFromJSVal(aCx, aKey);
ENSURE_SUCCESS_VOID(aRv);
if (!key.IsUnset()) {
switch (mDirection) {
@ -809,9 +807,7 @@ IDBCursor::Update(JSContext* aCx, JS::Handle<JS::Value> aValue,
return nullptr;
}
JS::Rooted<JS::Value> value(aCx, aValue);
Optional<JS::Handle<JS::Value> > keyValue(aCx);
request = mObjectStore->Put(aCx, value, keyValue, aRv);
request = mObjectStore->Put(aCx, aValue, JS::UndefinedHandleValue, aRv);
if (aRv.Failed()) {
return nullptr;
}
@ -821,9 +817,7 @@ IDBCursor::Update(JSContext* aCx, JS::Handle<JS::Value> aValue,
aRv = objectKey.ToJSVal(aCx, &keyVal);
ENSURE_SUCCESS(aRv, nullptr);
JS::Rooted<JS::Value> value(aCx, aValue);
Optional<JS::Handle<JS::Value> > keyValue(aCx, keyVal);
request = mObjectStore->Put(aCx, value, keyValue, aRv);
request = mObjectStore->Put(aCx, aValue, keyVal, aRv);
if (aRv.Failed()) {
return nullptr;
}

Просмотреть файл

@ -197,8 +197,7 @@ public:
Advance(uint32_t aCount, ErrorResult& aRv);
void
Continue(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
ErrorResult& aRv);
Continue(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Delete(JSContext* aCx, ErrorResult& aRv);

Просмотреть файл

@ -896,7 +896,7 @@ IDBIndex::GetKey(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv)
}
already_AddRefed<IDBRequest>
IDBIndex::GetAll(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
IDBIndex::GetAll(JSContext* aCx, JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -908,10 +908,8 @@ IDBIndex::GetAll(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
}
nsRefPtr<IDBKeyRange> keyRange;
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
uint32_t limit = UINT32_MAX;
if (aLimit.WasPassed() && aLimit.Value() > 0) {
@ -923,7 +921,7 @@ IDBIndex::GetAll(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
already_AddRefed<IDBRequest>
IDBIndex::GetAllKeys(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aKey,
JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -935,10 +933,8 @@ IDBIndex::GetAllKeys(JSContext* aCx,
}
nsRefPtr<IDBKeyRange> keyRange;
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
uint32_t limit = UINT32_MAX;
if (aLimit.WasPassed() && aLimit.Value() > 0) {
@ -950,7 +946,7 @@ IDBIndex::GetAllKeys(JSContext* aCx,
already_AddRefed<IDBRequest>
IDBIndex::OpenCursor(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aRange,
JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -962,10 +958,8 @@ IDBIndex::OpenCursor(JSContext* aCx,
}
nsRefPtr<IDBKeyRange> keyRange;
if (aRange.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
aRv = IDBKeyRange::FromJSVal(aCx, aRange, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection);
@ -991,7 +985,7 @@ IDBIndex::OpenCursor(JSContext* aCx,
already_AddRefed<IDBRequest>
IDBIndex::OpenKeyCursor(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aRange,
JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -1003,10 +997,8 @@ IDBIndex::OpenKeyCursor(JSContext* aCx,
}
nsRefPtr<IDBKeyRange> keyRange;
if (aRange.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
aRv = IDBKeyRange::FromJSVal(aCx, aRange, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection);
@ -1014,7 +1006,7 @@ IDBIndex::OpenKeyCursor(JSContext* aCx,
}
already_AddRefed<IDBRequest>
IDBIndex::Count(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
IDBIndex::Count(JSContext* aCx, JS::Handle<JS::Value> aKey,
ErrorResult& aRv)
{
IDBTransaction* transaction = mObjectStore->Transaction();
@ -1024,10 +1016,8 @@ IDBIndex::Count(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
}
nsRefPtr<IDBKeyRange> keyRange;
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
return CountInternal(keyRange, aRv);
}

Просмотреть файл

@ -194,11 +194,11 @@ public:
}
already_AddRefed<IDBRequest>
OpenCursor(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aRange,
OpenCursor(JSContext* aCx, JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
already_AddRefed<IDBRequest>
OpenKeyCursor(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aRange,
OpenKeyCursor(JSContext* aCx, JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
already_AddRefed<IDBRequest>
@ -208,7 +208,7 @@ public:
GetKey(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Count(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
Count(JSContext* aCx, JS::Handle<JS::Value> aKey,
ErrorResult& aRv);
void
@ -219,11 +219,11 @@ public:
}
already_AddRefed<IDBRequest>
GetAll(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
GetAll(JSContext* aCx, JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv);
already_AddRefed<IDBRequest>
GetAllKeys(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
GetAllKeys(JSContext* aCx, JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv);
private:

Просмотреть файл

@ -1907,7 +1907,7 @@ IDBObjectStore::GetAddInfo(JSContext* aCx,
already_AddRefed<IDBRequest>
IDBObjectStore::AddOrPut(JSContext* aCx, JS::Handle<JS::Value> aValue,
const Optional<JS::Handle<JS::Value> >& aKey,
JS::Handle<JS::Value> aKey,
bool aOverwrite, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -1922,15 +1922,12 @@ IDBObjectStore::AddOrPut(JSContext* aCx, JS::Handle<JS::Value> aValue,
return nullptr;
}
JS::Rooted<JS::Value> keyval(aCx, aKey.WasPassed() ? aKey.Value()
: JSVAL_VOID);
StructuredCloneWriteInfo cloneWriteInfo;
Key key;
nsTArray<IndexUpdateInfo> updateInfo;
JS::Rooted<JS::Value> value(aCx, aValue);
aRv = GetAddInfo(aCx, value, keyval, cloneWriteInfo, key, updateInfo);
aRv = GetAddInfo(aCx, value, aKey, cloneWriteInfo, key, updateInfo);
if (aRv.Failed()) {
return nullptr;
}
@ -2700,7 +2697,7 @@ IDBObjectStore::Get(JSContext* aCx, JS::Handle<JS::Value> aKey,
already_AddRefed<IDBRequest>
IDBObjectStore::GetAll(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aKey,
JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -2711,10 +2708,8 @@ IDBObjectStore::GetAll(JSContext* aCx,
}
nsRefPtr<IDBKeyRange> keyRange;
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
uint32_t limit = UINT32_MAX;
if (aLimit.WasPassed() && aLimit.Value() != 0) {
@ -2755,7 +2750,7 @@ IDBObjectStore::Delete(JSContext* aCx, JS::Handle<JS::Value> aKey,
already_AddRefed<IDBRequest>
IDBObjectStore::OpenCursor(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aRange,
JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -2766,10 +2761,8 @@ IDBObjectStore::OpenCursor(JSContext* aCx,
}
nsRefPtr<IDBKeyRange> keyRange;
if (aRange.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
aRv = IDBKeyRange::FromJSVal(aCx, aRange, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection);
size_t argDirection = static_cast<size_t>(direction);
@ -2941,7 +2934,7 @@ IDBObjectStore::DeleteIndex(const nsAString& aName, ErrorResult& aRv)
already_AddRefed<IDBRequest>
IDBObjectStore::Count(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aKey,
JS::Handle<JS::Value> aKey,
ErrorResult& aRv)
{
if (!mTransaction->IsOpen()) {
@ -2950,17 +2943,15 @@ IDBObjectStore::Count(JSContext* aCx,
}
nsRefPtr<IDBKeyRange> keyRange;
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
return CountInternal(keyRange, aRv);
}
already_AddRefed<IDBRequest>
IDBObjectStore::GetAllKeys(JSContext* aCx,
const Optional<JS::Handle<JS::Value>>& aKey,
JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
@ -2971,10 +2962,8 @@ IDBObjectStore::GetAllKeys(JSContext* aCx,
}
nsRefPtr<IDBKeyRange> keyRange;
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
uint32_t limit = UINT32_MAX;
if (aLimit.WasPassed() && aLimit.Value() != 0) {
@ -2986,7 +2975,7 @@ IDBObjectStore::GetAllKeys(JSContext* aCx,
already_AddRefed<IDBRequest>
IDBObjectStore::OpenKeyCursor(JSContext* aCx,
const Optional<JS::Handle<JS::Value>>& aRange,
JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
@ -2997,10 +2986,8 @@ IDBObjectStore::OpenKeyCursor(JSContext* aCx,
}
nsRefPtr<IDBKeyRange> keyRange;
if (aRange.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
aRv = IDBKeyRange::FromJSVal(aCx, aRange, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection);

Просмотреть файл

@ -304,7 +304,7 @@ public:
already_AddRefed<IDBRequest>
Put(JSContext* aCx, JS::Handle<JS::Value> aValue,
const Optional<JS::Handle<JS::Value> >& aKey, ErrorResult& aRv)
JS::Handle<JS::Value> aKey, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return AddOrPut(aCx, aValue, aKey, true, aRv);
@ -312,7 +312,7 @@ public:
already_AddRefed<IDBRequest>
Add(JSContext* aCx, JS::Handle<JS::Value> aValue,
const Optional<JS::Handle<JS::Value> >& aKey, ErrorResult& aRv)
JS::Handle<JS::Value> aKey, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return AddOrPut(aCx, aValue, aKey, false, aRv);
@ -328,7 +328,7 @@ public:
Clear(ErrorResult& aRv);
already_AddRefed<IDBRequest>
OpenCursor(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aRange,
OpenCursor(JSContext* aCx, JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
already_AddRefed<IDBIndex>
@ -347,19 +347,19 @@ public:
DeleteIndex(const nsAString& aIndexName, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Count(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
Count(JSContext* aCx, JS::Handle<JS::Value> aKey,
ErrorResult& aRv);
already_AddRefed<IDBRequest>
GetAll(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
GetAll(JSContext* aCx, JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv);
already_AddRefed<IDBRequest>
GetAllKeys(JSContext* aCx, const Optional<JS::Handle<JS::Value>>& aKey,
GetAllKeys(JSContext* aCx, JS::Handle<JS::Value> aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv);
already_AddRefed<IDBRequest>
OpenKeyCursor(JSContext* aCx, const Optional<JS::Handle<JS::Value>>& aRange,
OpenKeyCursor(JSContext* aCx, JS::Handle<JS::Value> aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
protected:
@ -375,7 +375,7 @@ protected:
already_AddRefed<IDBRequest>
AddOrPut(JSContext* aCx, JS::Handle<JS::Value> aValue,
const Optional<JS::Handle<JS::Value> >& aKey, bool aOverwrite,
JS::Handle<JS::Value> aKey, bool aOverwrite,
ErrorResult& aRv);
already_AddRefed<IDBIndex>

Просмотреть файл

@ -500,13 +500,11 @@ Promise::Constructor(const GlobalObject& aGlobal,
/* static */ already_AddRefed<Promise>
Promise::Resolve(const GlobalObject& aGlobal, JSContext* aCx,
const Optional<JS::Handle<JS::Value>>& aValue, ErrorResult& aRv)
JS::Handle<JS::Value> aValue, ErrorResult& aRv)
{
// If a Promise was passed, just return it.
JS::Rooted<JS::Value> value(aCx, aValue.WasPassed() ? aValue.Value() :
JS::UndefinedValue());
if (value.isObject()) {
JS::Rooted<JSObject*> valueObj(aCx, &value.toObject());
if (aValue.isObject()) {
JS::Rooted<JSObject*> valueObj(aCx, &aValue.toObject());
Promise* nextPromise;
nsresult rv = UNWRAP_OBJECT(Promise, valueObj, nextPromise);
@ -525,7 +523,7 @@ Promise::Resolve(const GlobalObject& aGlobal, JSContext* aCx,
}
}
return Resolve(window, aCx, value, aRv);
return Resolve(window, aCx, aValue, aRv);
}
/* static */ already_AddRefed<Promise>
@ -541,7 +539,7 @@ Promise::Resolve(nsPIDOMWindow* aWindow, JSContext* aCx,
/* static */ already_AddRefed<Promise>
Promise::Reject(const GlobalObject& aGlobal, JSContext* aCx,
const Optional<JS::Handle<JS::Value>>& aValue, ErrorResult& aRv)
JS::Handle<JS::Value> aValue, ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window;
if (MOZ_LIKELY(NS_IsMainThread())) {
@ -552,9 +550,7 @@ Promise::Reject(const GlobalObject& aGlobal, JSContext* aCx,
}
}
return Reject(window, aCx,
aValue.WasPassed() ? aValue.Value() : JS::UndefinedHandleValue,
aRv);
return Reject(window, aCx, aValue, aRv);
}
/* static */ already_AddRefed<Promise>
@ -736,8 +732,8 @@ Promise::All(const GlobalObject& aGlobal, JSContext* aCx,
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
Optional<JS::Handle<JS::Value>> optValue(aCx, JS::ObjectValue(*empty));
return Promise::Resolve(aGlobal, aCx, optValue, aRv);
JS::Rooted<JS::Value> value(aCx, JS::ObjectValue(*empty));
return Promise::Resolve(aGlobal, aCx, value, aRv);
}
nsRefPtr<Promise> promise = new Promise(window);
@ -747,8 +743,8 @@ Promise::All(const GlobalObject& aGlobal, JSContext* aCx,
nsRefPtr<PromiseCallback> rejectCb = new RejectPromiseCallback(promise);
for (uint32_t i = 0; i < aIterable.Length(); ++i) {
Optional<JS::Handle<JS::Value>> optValue(aCx, aIterable.ElementAt(i));
nsRefPtr<Promise> nextPromise = Promise::Resolve(aGlobal, aCx, optValue, aRv);
JS::Rooted<JS::Value> value(aCx, aIterable.ElementAt(i));
nsRefPtr<Promise> nextPromise = Promise::Resolve(aGlobal, aCx, value, aRv);
MOZ_ASSERT(!aRv.Failed());
@ -783,8 +779,8 @@ Promise::Race(const GlobalObject& aGlobal, JSContext* aCx,
nsRefPtr<PromiseCallback> rejectCb = new RejectPromiseCallback(promise);
for (uint32_t i = 0; i < aIterable.Length(); ++i) {
Optional<JS::Handle<JS::Value>> optValue(aCx, aIterable.ElementAt(i));
nsRefPtr<Promise> nextPromise = Promise::Resolve(aGlobal, aCx, optValue, aRv);
JS::Rooted<JS::Value> value(aCx, aIterable.ElementAt(i));
nsRefPtr<Promise> nextPromise = Promise::Resolve(aGlobal, aCx, value, aRv);
// According to spec, Resolve can throw, but our implementation never does.
// Well it does when window isn't passed on the main thread, but that is an
// implementation detail which should never be reached since we are checking

Просмотреть файл

@ -66,7 +66,7 @@ public:
static already_AddRefed<Promise>
Resolve(const GlobalObject& aGlobal, JSContext* aCx,
const Optional<JS::Handle<JS::Value>>& aValue, ErrorResult& aRv);
JS::Handle<JS::Value> aValue, ErrorResult& aRv);
static already_AddRefed<Promise>
Resolve(nsPIDOMWindow* aWindow, JSContext* aCx,
@ -74,7 +74,7 @@ public:
static already_AddRefed<Promise>
Reject(const GlobalObject& aGlobal, JSContext* aCx,
const Optional<JS::Handle<JS::Value>>& aValue, ErrorResult& aRv);
JS::Handle<JS::Value> aValue, ErrorResult& aRv);
static already_AddRefed<Promise>
Reject(nsPIDOMWindow* aWindow, JSContext* aCx,

Просмотреть файл

@ -26,11 +26,11 @@ interface HTMLCanvasElement : HTMLElement {
[Throws]
DOMString toDataURL(optional DOMString type = "",
optional any encoderOptions);
any encoderOptions);
[Throws]
void toBlob(FileCallback _callback,
optional DOMString type = "",
optional any encoderOptions);
any encoderOptions);
};
// Mozilla specific bits

Просмотреть файл

@ -32,7 +32,7 @@ interface IDBCursor {
void advance ([EnforceRange] unsigned long count);
[Throws]
void continue (optional any key);
void continue (any key);
[Throws]
IDBRequest delete ();

Просмотреть файл

@ -23,10 +23,10 @@ interface IDBIndex {
readonly attribute boolean unique;
[Throws]
IDBRequest openCursor (optional any range, optional IDBCursorDirection direction = "next");
IDBRequest openCursor (any range, optional IDBCursorDirection direction = "next");
[Throws]
IDBRequest openKeyCursor (optional any range, optional IDBCursorDirection direction = "next");
IDBRequest openKeyCursor (any range, optional IDBCursorDirection direction = "next");
[Throws]
IDBRequest get (any key);
@ -35,15 +35,15 @@ interface IDBIndex {
IDBRequest getKey (any key);
[Throws]
IDBRequest count (optional any key);
IDBRequest count (any key);
};
partial interface IDBIndex {
readonly attribute DOMString storeName;
[Throws]
IDBRequest mozGetAll (optional any key, optional unsigned long limit);
IDBRequest mozGetAll (any key, optional unsigned long limit);
[Throws]
IDBRequest mozGetAllKeys (optional any key, optional unsigned long limit);
IDBRequest mozGetAllKeys (any key, optional unsigned long limit);
};

Просмотреть файл

@ -25,10 +25,10 @@ interface IDBObjectStore {
readonly attribute boolean autoIncrement;
[Throws]
IDBRequest put (any value, optional any key);
IDBRequest put (any value, any key);
[Throws]
IDBRequest add (any value, optional any key);
IDBRequest add (any value, any key);
[Throws]
IDBRequest delete (any key);
@ -40,7 +40,7 @@ interface IDBObjectStore {
IDBRequest clear ();
[Throws]
IDBRequest openCursor (optional any range, optional IDBCursorDirection direction = "next");
IDBRequest openCursor (any range, optional IDBCursorDirection direction = "next");
// Bug 899972
// IDBIndex createIndex (DOMString name, (DOMString or sequence<DOMString>) keyPath, optional IDBIndexParameters optionalParameters);
@ -58,20 +58,20 @@ interface IDBObjectStore {
void deleteIndex (DOMString indexName);
[Throws]
IDBRequest count (optional any key);
IDBRequest count (any key);
};
partial interface IDBObjectStore {
// Success fires IDBTransactionEvent, result == array of values for given keys
[Throws]
IDBRequest mozGetAll (optional any key, optional unsigned long limit);
IDBRequest mozGetAll (any key, optional unsigned long limit);
[Pref="dom.indexedDB.experimental", Throws]
IDBRequest getAll (optional any key, optional unsigned long limit);
IDBRequest getAll (any key, optional unsigned long limit);
[Pref="dom.indexedDB.experimental", Throws]
IDBRequest getAllKeys (optional any key, optional unsigned long limit);
IDBRequest getAllKeys (any key, optional unsigned long limit);
[Pref="dom.indexedDB.experimental", Throws]
IDBRequest openKeyCursor (optional any range, optional IDBCursorDirection direction = "next");
IDBRequest openKeyCursor (any range, optional IDBCursorDirection direction = "next");
};

Просмотреть файл

@ -26,9 +26,9 @@ interface Promise {
// Promise object in this scope without having resolved the interface object
// first.
[NewObject, Throws]
static Promise resolve(optional any value);
static Promise resolve(any value);
[NewObject, Throws]
static Promise reject(optional any value);
static Promise reject(any value);
// The [TreatNonCallableAsNull] annotation is required since then() should do
// nothing instead of throwing errors when non-callable arguments are passed.

Просмотреть файл

@ -146,7 +146,7 @@ dictionary RTCStatsReportInternal {
interface RTCStatsReport {
[ChromeOnly]
readonly attribute DOMString mozPcid;
void forEach(RTCStatsReportCallback callbackFn, optional any thisArg);
void forEach(RTCStatsReportCallback callbackFn, any thisArg);
object get(DOMString key);
boolean has(DOMString key);
};

Просмотреть файл

@ -6,7 +6,7 @@
[JSImplementation="@mozilla.org/dom/test-interface-js;1",
Pref="dom.expose_test_interfaces",
Constructor(optional any anyArg, optional object objectArg)]
Constructor(any anyArg, optional object objectArg)]
interface TestInterfaceJS {
readonly attribute any anyArg;
readonly attribute object objectArg;

Просмотреть файл

@ -74,7 +74,7 @@ typedef any Transferable;
[Throws] DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
[Throws] void print();
//[Throws] any showModalDialog(DOMString url, optional any argument);
[Throws] any showModalDialog(DOMString url, optional any argument, optional DOMString options = "");
[Throws] any showModalDialog(DOMString url, any argument, optional DOMString options = "");
[Throws, CrossOriginCallable] void postMessage(any message, DOMString targetOrigin, optional sequence<Transferable> transfer);

Просмотреть файл

@ -12,12 +12,12 @@ interface WorkerConsole {
void _exception(any... data);
void debug(any... data);
void trace();
void dir(optional any data);
void dir(any data);
void group(any... data);
void groupCollapsed(any... data);
void groupEnd(any... data);
void time(optional any time);
void timeEnd(optional any time);
void time(any time);
void timeEnd(any time);
void profile(any... data);
void profileEnd(any... data);
void assert(boolean condition, any... data);

Просмотреть файл

@ -492,14 +492,13 @@ WorkerConsole::Trace(JSContext* aCx)
}
void
WorkerConsole::Dir(JSContext* aCx,
const Optional<JS::Handle<JS::Value>>& aValue)
WorkerConsole::Dir(JSContext* aCx, JS::Handle<JS::Value> aValue)
{
Sequence<JS::Value> data;
SequenceRooter<JS::Value> rooter(aCx, &data);
if (aValue.WasPassed()) {
data.AppendElement(aValue.Value());
if (!aValue.isUndefined()) {
data.AppendElement(aValue);
}
Method(aCx, "dir", data, 1);
@ -510,14 +509,13 @@ METHOD(GroupCollapsed, "groupCollapsed")
METHOD(GroupEnd, "groupEnd")
void
WorkerConsole::Time(JSContext* aCx,
const Optional<JS::Handle<JS::Value>>& aTimer)
WorkerConsole::Time(JSContext* aCx, JS::Handle<JS::Value> aTimer)
{
Sequence<JS::Value> data;
SequenceRooter<JS::Value> rooter(aCx, &data);
if (aTimer.WasPassed()) {
data.AppendElement(aTimer.Value());
if (!aTimer.isUndefined()) {
data.AppendElement(aTimer);
}
Method(aCx, "time", data, 1);
@ -525,13 +523,13 @@ WorkerConsole::Time(JSContext* aCx,
void
WorkerConsole::TimeEnd(JSContext* aCx,
const Optional<JS::Handle<JS::Value>>& aTimer)
JS::Handle<JS::Value> aTimer)
{
Sequence<JS::Value> data;
SequenceRooter<JS::Value> rooter(aCx, &data);
if (aTimer.WasPassed()) {
data.AppendElement(aTimer.Value());
if (!aTimer.isUndefined()) {
data.AppendElement(aTimer);
}
Method(aCx, "timeEnd", data, 1);

Просмотреть файл

@ -70,7 +70,7 @@ public:
Trace(JSContext* aCx);
void
Dir(JSContext* aCx, const Optional<JS::Handle<JS::Value>>& aValue);
Dir(JSContext* aCx, JS::Handle<JS::Value> aValue);
void
Group(JSContext* aCx, const Sequence<JS::Value>& aData);
@ -82,10 +82,10 @@ public:
GroupEnd(JSContext* aCx, const Sequence<JS::Value>& aData);
void
Time(JSContext* aCx, const Optional<JS::Handle<JS::Value>>& aTimer);
Time(JSContext* aCx, JS::Handle<JS::Value> aTimer);
void
TimeEnd(JSContext* aCx, const Optional<JS::Handle<JS::Value>>& aTimer);
TimeEnd(JSContext* aCx, JS::Handle<JS::Value> aTimer);
void
Profile(JSContext* aCx, const Sequence<JS::Value>& aData);