| Differences between
and this patch
- Source/WebCore/ChangeLog +34 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2020-09-30  Sam Weinig  <weinig@apple.com>
2
3
        [WebIDL] Add support for non-nullable optional wrapper type arguments to operations
4
        https://bugs.webkit.org/show_bug.cgi?id=217162
5
6
        Reviewed by NOBODY (OOPS!).
7
        
8
        The bindings currently treat both nullable and optional wrapper types as
9
        having type WrapperType*, whereas non-nullable, non-optional wrapper types
10
        are treated as having type WrapperType&. This parallels non wrapper types
11
        which use Optional<Type> for both nullable and optional vs Type for the
12
        non-nullable non-optional variant. In both these cases, there is possibility
13
        for ambiguity, should we ever need to disambiguate between nullable and 
14
        optional, but thus far it hasn't come up.
15
        
16
        This change adds a missing case where we weren't supporting non-nullable 
17
        optional wrapper type arguments to operations. We solve this by expecting
18
        the wrapped implementation to take the optional wrapper type argument the
19
        same way it would take an optional wrapper type argument, with a WrapperType*,
20
        that gets passed a nullptr if the parameter was ommited.
21
        
22
        Adopt this in Geolocation.idl, which has had a FIXME for this for a long
23
        time.
24
25
        * Modules/geolocation/Geolocation.idl:
26
        * bindings/scripts/CodeGeneratorJS.pm:
27
        (PassArgumentExpression):
28
        (GenerateParametersCheck):
29
        * bindings/scripts/test/JS/JSTestObj.cpp:
30
        (WebCore::JSTestObjConstructor::construct):
31
        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalWrapperBody):
32
        (WebCore::JSC_DEFINE_HOST_FUNCTION):
33
        * bindings/scripts/test/TestObj.idl:
34
1
2020-09-30  Sam Weinig  <weinig@apple.com>
35
2020-09-30  Sam Weinig  <weinig@apple.com>
2
36
3
        [WebIDL] Make Exposed mandatory for IDL interfaces
37
        [WebIDL] Make Exposed mandatory for IDL interfaces
- Source/WebCore/Modules/geolocation/Geolocation.idl -4 / +2 lines
Lines 30-43 Source/WebCore/Modules/geolocation/Geolocation.idl_sec1
30
    GenerateIsReachable=ReachableFromNavigator,
30
    GenerateIsReachable=ReachableFromNavigator,
31
    Exposed=Window
31
    Exposed=Window
32
] interface Geolocation {
32
] interface Geolocation {
33
    // FIXME: PositionErrorCallback should not be nullable
34
    undefined getCurrentPosition(PositionCallback successCallback,
33
    undefined getCurrentPosition(PositionCallback successCallback,
35
                            optional PositionErrorCallback? errorCallback,
34
                            optional PositionErrorCallback errorCallback,
36
                            optional PositionOptions options);
35
                            optional PositionOptions options);
37
36
38
    // FIXME: PositionErrorCallback should not be nullable
39
    long watchPosition(PositionCallback successCallback,
37
    long watchPosition(PositionCallback successCallback,
40
                       optional PositionErrorCallback? errorCallback,
38
                       optional PositionErrorCallback errorCallback,
41
                       optional PositionOptions options);
39
                       optional PositionOptions options);
42
40
43
    undefined clearWatch(long watchId);
41
    undefined clearWatch(long watchId);
- Source/WebCore/bindings/scripts/CodeGeneratorJS.pm -5 / +10 lines
Lines 1824-1831 sub PassArgumentExpression Source/WebCore/bindings/scripts/CodeGeneratorJS.pm_sec1
1824
        return "${name}.releaseNonNull()";
1824
        return "${name}.releaseNonNull()";
1825
    }
1825
    }
1826
1826
1827
    return "${name}.releaseNonNull()" if $codeGenerator->IsCallbackInterface($type) || $codeGenerator->IsCallbackFunction($type) || ($codeGenerator->IsPromiseType($type) && (ref($context) ne "IDLArgument" || !$context->isOptional));
1827
    if ($codeGenerator->IsCallbackInterface($type) || $codeGenerator->IsCallbackFunction($type) || ($codeGenerator->IsPromiseType($type) && (ref($context) ne "IDLArgument" || !$context->isOptional))) {
1828
    return "*${name}" if $codeGenerator->IsWrapperType($type);
1828
        return "${name}.releaseNonNull()";
1829
    }
1830
1831
    if ($codeGenerator->IsWrapperType($type)) {
1832
        return "${name}" if ref($context) eq "IDLArgument" && $context->isOptional;
1833
        return "*${name}";
1834
    }
1835
1829
    return "WTFMove(${name})";
1836
    return "WTFMove(${name})";
1830
}
1837
}
1831
1838
Lines 6191-6198 sub GenerateParametersCheck Source/WebCore/bindings/scripts/CodeGeneratorJS.pm_sec2
6191
    foreach my $argument (@{$operation->arguments}) {
6198
    foreach my $argument (@{$operation->arguments}) {
6192
        my $type = $argument->type;
6199
        my $type = $argument->type;
6193
6200
6194
        assert "Optional arguments of non-nullable wrapper types are not supported (" . $operation->name . ")" if $argument->isOptional && !$type->isNullable && $codeGenerator->IsWrapperType($type);
6195
6196
        if ($argument->isOptional && !defined($argument->default)) {
6201
        if ($argument->isOptional && !defined($argument->default)) {
6197
            # As per Web IDL, optional dictionary arguments are always considered to have a default value of an empty dictionary, unless otherwise specified.
6202
            # As per Web IDL, optional dictionary arguments are always considered to have a default value of an empty dictionary, unless otherwise specified.
6198
            $argument->default("[]") if $codeGenerator->IsDictionaryType($type);
6203
            $argument->default("[]") if $codeGenerator->IsDictionaryType($type);
Lines 6246-6252 sub GenerateParametersCheck Source/WebCore/bindings/scripts/CodeGeneratorJS.pm_sec3
6246
                    my $argumentIDLType = GetIDLType($interface, $argument->type);
6251
                    my $argumentIDLType = GetIDLType($interface, $argument->type);
6247
6252
6248
                    my $defaultValue;
6253
                    my $defaultValue;
6249
                    if ($codeGenerator->IsPromiseType($argument->type)) {
6254
                    if ($codeGenerator->IsPromiseType($argument->type) || $codeGenerator->IsWrapperType($type)) {
6250
                        $defaultValue = "nullptr";
6255
                        $defaultValue = "nullptr";
6251
                    } else {
6256
                    } else {
6252
                        $defaultValue = "Optional<Converter<$argumentIDLType>::ReturnType>()";
6257
                        $defaultValue = "Optional<Converter<$argumentIDLType>::ReturnType>()";
- Source/WebCore/bindings/scripts/test/TestObj.idl +1 lines
Lines 241-246 enum TestConfidence { "high", "kinda-low Source/WebCore/bindings/scripts/test/TestObj.idl_sec1
241
    undefined    methodWithOptionalBooleanIsFalse(optional boolean b = false);
241
    undefined    methodWithOptionalBooleanIsFalse(optional boolean b = false);
242
    undefined    methodWithOptionalAny(optional any a);
242
    undefined    methodWithOptionalAny(optional any a);
243
    undefined    methodWithOptionalObject(optional object a);
243
    undefined    methodWithOptionalObject(optional object a);
244
    undefined    methodWithOptionalWrapper(optional TestObj obj);
244
    undefined    methodWithOptionalNullableWrapper(optional TestObj? obj);
245
    undefined    methodWithOptionalNullableWrapper(optional TestObj? obj);
245
    undefined    methodWithOptionalNullableWrapperIsNull(optional TestObj? obj = null);
246
    undefined    methodWithOptionalNullableWrapperIsNull(optional TestObj? obj = null);
246
    undefined    methodWithOptionalXPathNSResolver(optional XPathNSResolver? resolver);
247
    undefined    methodWithOptionalXPathNSResolver(optional XPathNSResolver? resolver);
- Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +22 lines
Lines 1510-1515 JSC_DECLARE_HOST_FUNCTION(jsTestObjProto Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp_sec1
1510
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalBooleanIsFalse);
1510
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalBooleanIsFalse);
1511
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalAny);
1511
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalAny);
1512
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalObject);
1512
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalObject);
1513
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalWrapper);
1513
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapper);
1514
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapper);
1514
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperIsNull);
1515
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperIsNull);
1515
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver);
1516
JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver);
Lines 2220-2225 static const HashTableValue JSTestObjPro Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp_sec2
2220
    { "methodWithOptionalBooleanIsFalse", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalBooleanIsFalse), (intptr_t) (0) } },
2221
    { "methodWithOptionalBooleanIsFalse", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalBooleanIsFalse), (intptr_t) (0) } },
2221
    { "methodWithOptionalAny", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalAny), (intptr_t) (0) } },
2222
    { "methodWithOptionalAny", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalAny), (intptr_t) (0) } },
2222
    { "methodWithOptionalObject", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalObject), (intptr_t) (0) } },
2223
    { "methodWithOptionalObject", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalObject), (intptr_t) (0) } },
2224
    { "methodWithOptionalWrapper", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalWrapper), (intptr_t) (0) } },
2223
    { "methodWithOptionalNullableWrapper", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapper), (intptr_t) (0) } },
2225
    { "methodWithOptionalNullableWrapper", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapper), (intptr_t) (0) } },
2224
    { "methodWithOptionalNullableWrapperIsNull", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperIsNull), (intptr_t) (0) } },
2226
    { "methodWithOptionalNullableWrapperIsNull", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperIsNull), (intptr_t) (0) } },
2225
    { "methodWithOptionalXPathNSResolver", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver), (intptr_t) (0) } },
2227
    { "methodWithOptionalXPathNSResolver", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver), (intptr_t) (0) } },
Lines 7026-7031 JSC_DEFINE_HOST_FUNCTION(jsTestObjProtot Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp_sec3
7026
    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithOptionalObjectBody>(*lexicalGlobalObject, *callFrame, "methodWithOptionalObject");
7028
    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithOptionalObjectBody>(*lexicalGlobalObject, *callFrame, "methodWithOptionalObject");
7027
}
7029
}
7028
7030
7031
static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalWrapperBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
7032
{
7033
    auto& vm = JSC::getVM(lexicalGlobalObject);
7034
    auto throwScope = DECLARE_THROW_SCOPE(vm);
7035
    UNUSED_PARAM(throwScope);
7036
    UNUSED_PARAM(callFrame);
7037
    auto& impl = castedThis->wrapped();
7038
    EnsureStillAliveScope argument0 = callFrame->argument(0);
7039
    auto obj = argument0.value().isUndefined() ? nullptr : convert<IDLInterface<TestObj>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "obj", "TestObject", "methodWithOptionalWrapper", "TestObj"); });
7040
    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
7041
    throwScope.release();
7042
    impl.methodWithOptionalWrapper(obj);
7043
    return JSValue::encode(jsUndefined());
7044
}
7045
7046
JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalWrapper, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
7047
{
7048
    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithOptionalWrapperBody>(*lexicalGlobalObject, *callFrame, "methodWithOptionalWrapper");
7049
}
7050
7029
static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
7051
static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
7030
{
7052
{
7031
    auto& vm = JSC::getVM(lexicalGlobalObject);
7053
    auto& vm = JSC::getVM(lexicalGlobalObject);
- LayoutTests/ChangeLog +24 lines
Lines 1-3 LayoutTests/ChangeLog_sec1
1
2020-09-30  Sam Weinig  <weinig@apple.com>
2
3
        [WebIDL] Add support for non-nullable optional wrapper type arguments to operations
4
        https://bugs.webkit.org/show_bug.cgi?id=217162
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * fast/dom/Geolocation/argument-types.html:
9
        Update tests now that the second argument to Geolocation.getCurrentPosition
10
        and Geolocation.watchPosition are non-nullable.
11
12
2020-09-30  Sam Weinig  <weinig@apple.com>
13
14
        Remove code behind ENABLE(MEDIA_SESSION), no ports enable it
15
        https://bugs.webkit.org/show_bug.cgi?id=216831
16
17
        Reviewed by Alex Christensen.
18
19
        Remove always skipped Media Session tests.
20
21
        * TestExpectations:
22
        * gpu-process/TestExpectations:
23
        * media/session: Removed.
24
1
2020-09-30  Ross Kirsling  <ross.kirsling@sony.com>
25
2020-09-30  Ross Kirsling  <ross.kirsling@sony.com>
2
26
3
        [JSC] Implement item method proposal
27
        [JSC] Implement item method proposal
- LayoutTests/fast/dom/Geolocation/argument-types.html -1 / +1 lines
Lines 56-62 test('navigator.geolocation.getCurrentPo LayoutTests/fast/dom/Geolocation/argument-types.html_sec1
56
test('navigator.geolocation.getCurrentPosition("string")', true, "TypeError: Argument 1 ('successCallback') to Geolocation.getCurrentPosition must be a function");
56
test('navigator.geolocation.getCurrentPosition("string")', true, "TypeError: Argument 1 ('successCallback') to Geolocation.getCurrentPosition must be a function");
57
57
58
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined)', false);
58
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined)', false);
59
test('navigator.geolocation.getCurrentPosition(emptyFunction, null)', false);
59
test('navigator.geolocation.getCurrentPosition(emptyFunction, null)', true, "TypeError: Argument 2 ('errorCallback') to Geolocation.getCurrentPosition must be a function");
60
test('navigator.geolocation.getCurrentPosition(emptyFunction, {})', true, "TypeError: Argument 2 ('errorCallback') to Geolocation.getCurrentPosition must be a function");
60
test('navigator.geolocation.getCurrentPosition(emptyFunction, {})', true, "TypeError: Argument 2 ('errorCallback') to Geolocation.getCurrentPosition must be a function");
61
test('navigator.geolocation.getCurrentPosition(emptyFunction, objectThrowingException)', true, "TypeError: Argument 2 ('errorCallback') to Geolocation.getCurrentPosition must be a function");
61
test('navigator.geolocation.getCurrentPosition(emptyFunction, objectThrowingException)', true, "TypeError: Argument 2 ('errorCallback') to Geolocation.getCurrentPosition must be a function");
62
test('navigator.geolocation.getCurrentPosition(emptyFunction, emptyFunction)', false);
62
test('navigator.geolocation.getCurrentPosition(emptyFunction, emptyFunction)', false);

Return to Bug 217162