Changeset 202551 in webkit


Ignore:
Timestamp:
Jun 28, 2016 12:04:55 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Binding generator should generate accessors for constructors safely accessed from JS builtin
https://bugs.webkit.org/show_bug.cgi?id=159087

Patch by Youenn Fablet <youenn@apple.com> on 2016-06-28
Reviewed by Alex Christensen.

Removed constructor private slots direct additions in JSDOMGlobalObject.
Added support for generating the code that will do that.
Advantage of the implementation:

  • Private slots will expose constructors that are also publically visible (previously workers had some private slots filled with WebRTC constructors).
  • Private slots no longer require the creation of the constructors at window creation time.

Although PublicIdentifier and PrivateIdentifier are both added where needed, the binding generator does not
support the case of a constructor accessible only privately.

Covered by existing test set and adding binding test.

  • Modules/mediastream/MediaStream.idl: Marked as PublicIdentifier/PrivateIdentifier.
  • Modules/mediastream/MediaStreamTrack.idl: Ditto.
  • Modules/mediastream/RTCIceCandidate.idl: Ditto.
  • Modules/mediastream/RTCSessionDescription.idl: Ditto.
  • Modules/streams/ReadableStream.idl: Ditto.
  • bindings/js/JSDOMGlobalObject.cpp:

(WebCore::JSDOMGlobalObject::addBuiltinGlobals): Removed unneeded additions.

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateImplementation): Added support for private slots for interface constructors marked as
PrivateIdentifier.

  • bindings/scripts/preprocess-idls.pl:

(GenerateConstructorAttribute): Make PublicIdentifier/PrivateIdentifier copied interface attributes.

  • bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.cpp:

(webkit_dom_test_global_object_set_property):
(webkit_dom_test_global_object_get_property):
(webkit_dom_test_global_object_class_init):
(webkit_dom_test_global_object_get_public_and_private_attribute):
(webkit_dom_test_global_object_set_public_and_private_attribute):

  • bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.h:
  • bindings/scripts/test/JS/JSTestGlobalObject.cpp:

(WebCore::JSTestGlobalObject::finishCreation):
(WebCore::jsTestGlobalObjectPublicAndPrivateAttribute):
(WebCore::setJSTestGlobalObjectPublicAndPrivateAttribute):

  • bindings/scripts/test/ObjC/DOMTestGlobalObject.h:
  • bindings/scripts/test/ObjC/DOMTestGlobalObject.mm:

(-[DOMTestGlobalObject publicAndPrivateAttribute]):
(-[DOMTestGlobalObject setPublicAndPrivateAttribute:]):

  • bindings/scripts/test/TestGlobalObject.idl:
Location:
trunk/Source/WebCore
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r202546 r202551  
     12016-06-28  Youenn Fablet  <youenn@apple.com>
     2
     3        Binding generator should generate accessors for constructors safely accessed from JS builtin
     4        https://bugs.webkit.org/show_bug.cgi?id=159087
     5
     6        Reviewed by Alex Christensen.
     7
     8        Removed constructor private slots direct additions in JSDOMGlobalObject.
     9        Added support for generating the code that will do that.
     10        Advantage of the implementation:
     11        - Private slots will expose constructors that are also publically visible (previously workers had some private slots filled with WebRTC constructors).
     12        - Private slots no longer require the creation of the constructors at window creation time.
     13
     14        Although PublicIdentifier and PrivateIdentifier are both added where needed, the binding generator does not
     15        support the case of a constructor accessible only privately.
     16
     17        Covered by existing test set and adding binding test.
     18
     19        * Modules/mediastream/MediaStream.idl: Marked as PublicIdentifier/PrivateIdentifier.
     20        * Modules/mediastream/MediaStreamTrack.idl: Ditto.
     21        * Modules/mediastream/RTCIceCandidate.idl: Ditto.
     22        * Modules/mediastream/RTCSessionDescription.idl: Ditto.
     23        * Modules/streams/ReadableStream.idl: Ditto.
     24        * bindings/js/JSDOMGlobalObject.cpp:
     25        (WebCore::JSDOMGlobalObject::addBuiltinGlobals): Removed unneeded additions.
     26        * bindings/scripts/CodeGeneratorJS.pm:
     27        (GenerateImplementation): Added support for private slots for interface constructors marked as
     28        PrivateIdentifier.
     29        * bindings/scripts/preprocess-idls.pl:
     30        (GenerateConstructorAttribute): Make PublicIdentifier/PrivateIdentifier copied interface attributes.
     31        * bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.cpp:
     32        (webkit_dom_test_global_object_set_property):
     33        (webkit_dom_test_global_object_get_property):
     34        (webkit_dom_test_global_object_class_init):
     35        (webkit_dom_test_global_object_get_public_and_private_attribute):
     36        (webkit_dom_test_global_object_set_public_and_private_attribute):
     37        * bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.h:
     38        * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
     39        (WebCore::JSTestGlobalObject::finishCreation):
     40        (WebCore::jsTestGlobalObjectPublicAndPrivateAttribute):
     41        (WebCore::setJSTestGlobalObjectPublicAndPrivateAttribute):
     42        * bindings/scripts/test/ObjC/DOMTestGlobalObject.h:
     43        * bindings/scripts/test/ObjC/DOMTestGlobalObject.mm:
     44        (-[DOMTestGlobalObject publicAndPrivateAttribute]):
     45        (-[DOMTestGlobalObject setPublicAndPrivateAttribute:]):
     46        * bindings/scripts/test/TestGlobalObject.idl:
     47
     48
    1492016-06-27  Jer Noble  <jer.noble@apple.com>
    250
  • trunk/Source/WebCore/Modules/mediastream/MediaStream.idl

    r202376 r202551  
    2929    Constructor(MediaStreamTrack[] tracks),
    3030    ConstructorCallWith=ScriptExecutionContext,
     31    PrivateIdentifier,
     32    PublicIdentifier
    3133] interface MediaStream : EventTarget {
    3234
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl

    r196568 r202551  
    3030    ActiveDOMObject,
    3131    SkipVTableValidation,
     32    PrivateIdentifier,
     33    PublicIdentifier
    3234] interface MediaStreamTrack : EventTarget {
    3335    readonly attribute DOMString kind;
  • trunk/Source/WebCore/Modules/mediastream/RTCIceCandidate.idl

    r201350 r202551  
    3333    Conditional=WEB_RTC,
    3434    Constructor(Dictionary dictionary),
    35     ConstructorRaisesException
     35    ConstructorRaisesException,
     36    PrivateIdentifier,
     37    PublicIdentifier
    3638] interface RTCIceCandidate {
    3739    readonly attribute DOMString candidate;
  • trunk/Source/WebCore/Modules/mediastream/RTCSessionDescription.idl

    r201420 r202551  
    3333    Conditional=WEB_RTC,
    3434    Constructor(Dictionary dictionary),
    35     ConstructorRaisesException
     35    ConstructorRaisesException,
     36    PrivateIdentifier,
     37    PublicIdentifier
    3638] interface RTCSessionDescription {
    3739    [SetterRaisesException] readonly attribute RTCSdpType type;
  • trunk/Source/WebCore/Modules/streams/ReadableStream.idl

    r199587 r202551  
    3232    Constructor,
    3333    Exposed=(Window,Worker),
    34     JSBuiltin
     34    JSBuiltin,
     35    PrivateIdentifier,
     36    PublicIdentifier
    3537] interface ReadableStream {
    3638    Promise cancel(optional any reason);
  • trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp

    r202376 r202551  
    8484        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamWaitingPrivateName(), jsNumber(5), DontDelete | ReadOnly),
    8585        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamWritablePrivateName(), jsNumber(6), DontDelete | ReadOnly),
    86 #if ENABLE(MEDIA_STREAM)
    87         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().MediaStreamPrivateName(), JSMediaStream::getConstructor(vm, this), DontDelete | ReadOnly),
    88         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().MediaStreamTrackPrivateName(), JSMediaStreamTrack::getConstructor(vm, this), DontDelete | ReadOnly),
    89 #endif
    90 #if ENABLE(STREAMS_API)
    91         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().ReadableStreamPrivateName(), JSReadableStream::getConstructor(vm, this), DontDelete | ReadOnly),
    92 #endif
    9386        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().ReadableStreamControllerPrivateName(), privateReadableStreamControllerConstructor, DontDelete | ReadOnly),
    9487        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().ReadableStreamReaderPrivateName(), privateReadableStreamReaderConstructor, DontDelete | ReadOnly),
    95 #if ENABLE(WEB_RTC)
    96         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().RTCIceCandidatePrivateName(), JSRTCIceCandidate::getConstructor(vm, this), DontDelete | ReadOnly),
    97         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().RTCSessionDescriptionPrivateName(), JSRTCSessionDescription::getConstructor(vm, this), DontDelete | ReadOnly),
    98 #endif
    9988    };
    10089    addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r202394 r202551  
    23942394            push(@implContent, "#endif\n") if $conditionalString;
    23952395        }
     2396
     2397        # Support PrivateIdentifier attributes on global objects
     2398        foreach my $attribute (@{$interface->attributes}) {
     2399            next unless $attribute->signature->extendedAttributes->{"PrivateIdentifier"};
     2400
     2401            AddToImplIncludes("WebCoreJSClientData.h");
     2402            my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature);
     2403            my $attributeName = $attribute->signature->name;
     2404            my $getter = GetAttributeGetterName($interface, $className, $attribute);
     2405
     2406            push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
     2407            push(@implContent, "    putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames()." . $attributeName . "PrivateName(), CustomGetterSetter::create(vm, $getter, nullptr), attributesForStructure(DontDelete | ReadOnly));\n");
     2408            push(@implContent, "#endif\n") if $conditionalString;
     2409        }
     2410
    23962411        # Support for RuntimeEnabled operations on global objects.
    23972412        foreach my $function (@{$interface->functions}) {
  • trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl

    r200689 r202551  
    239239    my @extendedAttributesList;
    240240    foreach my $attributeName (sort keys %{$extendedAttributes}) {
    241       next unless ($attributeName eq "Conditional" || $attributeName eq "EnabledAtRuntime" || $attributeName eq "EnabledBySetting");
     241      next unless ($attributeName eq "Conditional" || $attributeName eq "EnabledAtRuntime" || $attributeName eq "EnabledBySetting" || $attributeName eq "PrivateIdentifier" || $attributeName eq "PublicIdentifier");
    242242      my $extendedAttribute = $attributeName;
    243243      $extendedAttribute .= "=" . $extendedAttributes->{$attributeName} unless $extendedAttributes->{$attributeName} eq "VALUE_IS_MISSING";
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.cpp

    r199103 r202551  
    7171    PROP_0,
    7272    PROP_REGULAR_ATTRIBUTE,
     73    PROP_PUBLIC_AND_PRIVATE_ATTRIBUTE,
     74    PROP_PUBLIC_AND_PRIVATE_CONDITIONAL_ATTRIBUTE,
    7375    PROP_ENABLED_AT_RUNTIME_ATTRIBUTE,
    7476};
     
    9294        webkit_dom_test_global_object_set_regular_attribute(self, g_value_get_string(value));
    9395        break;
     96    case PROP_PUBLIC_AND_PRIVATE_ATTRIBUTE:
     97        webkit_dom_test_global_object_set_public_and_private_attribute(self, g_value_get_string(value));
     98        break;
     99    case PROP_PUBLIC_AND_PRIVATE_CONDITIONAL_ATTRIBUTE:
     100        webkit_dom_test_global_object_set_public_and_private_conditional_attribute(self, g_value_get_string(value));
     101        break;
    94102    case PROP_ENABLED_AT_RUNTIME_ATTRIBUTE:
    95103        webkit_dom_test_global_object_set_enabled_at_runtime_attribute(self, g_value_get_string(value));
     
    108116    case PROP_REGULAR_ATTRIBUTE:
    109117        g_value_take_string(value, webkit_dom_test_global_object_get_regular_attribute(self));
     118        break;
     119    case PROP_PUBLIC_AND_PRIVATE_ATTRIBUTE:
     120        g_value_take_string(value, webkit_dom_test_global_object_get_public_and_private_attribute(self));
     121        break;
     122    case PROP_PUBLIC_AND_PRIVATE_CONDITIONAL_ATTRIBUTE:
     123        g_value_take_string(value, webkit_dom_test_global_object_get_public_and_private_conditional_attribute(self));
    110124        break;
    111125    case PROP_ENABLED_AT_RUNTIME_ATTRIBUTE:
     
    150164    g_object_class_install_property(
    151165        gobjectClass,
     166        PROP_PUBLIC_AND_PRIVATE_ATTRIBUTE,
     167        g_param_spec_string(
     168            "public-and-private-attribute",
     169            "TestGlobalObject:public-and-private-attribute",
     170            "read-write gchar* TestGlobalObject:public-and-private-attribute",
     171            "",
     172            WEBKIT_PARAM_READWRITE));
     173
     174    g_object_class_install_property(
     175        gobjectClass,
     176        PROP_PUBLIC_AND_PRIVATE_CONDITIONAL_ATTRIBUTE,
     177        g_param_spec_string(
     178            "public-and-private-conditional-attribute",
     179            "TestGlobalObject:public-and-private-conditional-attribute",
     180            "read-write gchar* TestGlobalObject:public-and-private-conditional-attribute",
     181            "",
     182            WEBKIT_PARAM_READWRITE));
     183
     184    g_object_class_install_property(
     185        gobjectClass,
    152186        PROP_ENABLED_AT_RUNTIME_ATTRIBUTE,
    153187        g_param_spec_string(
     
    225259}
    226260
     261gchar* webkit_dom_test_global_object_get_public_and_private_attribute(WebKitDOMTestGlobalObject* self)
     262{
     263    WebCore::JSMainThreadNullState state;
     264    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_GLOBAL_OBJECT(self), 0);
     265    WebCore::TestGlobalObject* item = WebKit::core(self);
     266    gchar* result = convertToUTF8String(item->publicAndPrivateAttribute());
     267    return result;
     268}
     269
     270void webkit_dom_test_global_object_set_public_and_private_attribute(WebKitDOMTestGlobalObject* self, const gchar* value)
     271{
     272    WebCore::JSMainThreadNullState state;
     273    g_return_if_fail(WEBKIT_DOM_IS_TEST_GLOBAL_OBJECT(self));
     274    g_return_if_fail(value);
     275    WebCore::TestGlobalObject* item = WebKit::core(self);
     276    WTF::String convertedValue = WTF::String::fromUTF8(value);
     277    item->setPublicAndPrivateAttribute(convertedValue);
     278}
     279
     280gchar* webkit_dom_test_global_object_get_public_and_private_conditional_attribute(WebKitDOMTestGlobalObject* self)
     281{
     282#if ENABLE(TEST_FEATURE)
     283    WebCore::JSMainThreadNullState state;
     284    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_GLOBAL_OBJECT(self), 0);
     285    WebCore::TestGlobalObject* item = WebKit::core(self);
     286    gchar* result = convertToUTF8String(item->publicAndPrivateConditionalAttribute());
     287    return result;
     288#else
     289    UNUSED_PARAM(self);
     290    WEBKIT_WARN_FEATURE_NOT_PRESENT("Test Feature")
     291    return 0;
     292#endif /* ENABLE(TEST_FEATURE) */
     293}
     294
     295void webkit_dom_test_global_object_set_public_and_private_conditional_attribute(WebKitDOMTestGlobalObject* self, const gchar* value)
     296{
     297#if ENABLE(TEST_FEATURE)
     298    WebCore::JSMainThreadNullState state;
     299    g_return_if_fail(WEBKIT_DOM_IS_TEST_GLOBAL_OBJECT(self));
     300    g_return_if_fail(value);
     301    WebCore::TestGlobalObject* item = WebKit::core(self);
     302    WTF::String convertedValue = WTF::String::fromUTF8(value);
     303    item->setPublicAndPrivateConditionalAttribute(convertedValue);
     304#else
     305    UNUSED_PARAM(self);
     306    UNUSED_PARAM(value);
     307    WEBKIT_WARN_FEATURE_NOT_PRESENT("Test Feature")
     308#endif /* ENABLE(TEST_FEATURE) */
     309}
     310
    227311gchar* webkit_dom_test_global_object_get_enabled_at_runtime_attribute(WebKitDOMTestGlobalObject* self)
    228312{
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.h

    r199103 r202551  
    100100
    101101/**
     102 * webkit_dom_test_global_object_get_public_and_private_attribute:
     103 * @self: A #WebKitDOMTestGlobalObject
     104 *
     105 * Returns: A #gchar
     106 *
     107 * Stability: Unstable
     108**/
     109WEBKIT_API gchar*
     110webkit_dom_test_global_object_get_public_and_private_attribute(WebKitDOMTestGlobalObject* self);
     111
     112/**
     113 * webkit_dom_test_global_object_set_public_and_private_attribute:
     114 * @self: A #WebKitDOMTestGlobalObject
     115 * @value: A #gchar
     116 *
     117 * Stability: Unstable
     118**/
     119WEBKIT_API void
     120webkit_dom_test_global_object_set_public_and_private_attribute(WebKitDOMTestGlobalObject* self, const gchar* value);
     121
     122/**
     123 * webkit_dom_test_global_object_get_public_and_private_conditional_attribute:
     124 * @self: A #WebKitDOMTestGlobalObject
     125 *
     126 * Returns: A #gchar
     127 *
     128 * Stability: Unstable
     129**/
     130WEBKIT_API gchar*
     131webkit_dom_test_global_object_get_public_and_private_conditional_attribute(WebKitDOMTestGlobalObject* self);
     132
     133/**
     134 * webkit_dom_test_global_object_set_public_and_private_conditional_attribute:
     135 * @self: A #WebKitDOMTestGlobalObject
     136 * @value: A #gchar
     137 *
     138 * Stability: Unstable
     139**/
     140WEBKIT_API void
     141webkit_dom_test_global_object_set_public_and_private_conditional_attribute(WebKitDOMTestGlobalObject* self, const gchar* value);
     142
     143/**
    102144 * webkit_dom_test_global_object_get_enabled_at_runtime_attribute:
    103145 * @self: A #WebKitDOMTestGlobalObject
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp

    r201816 r202551  
    2828#include "RuntimeEnabledFeatures.h"
    2929#include "URL.h"
     30#include "WebCoreJSClientData.h"
    3031#include <runtime/Error.h>
    3132#include <runtime/FunctionPrototype.h>
     
    4849JSC::EncodedJSValue jsTestGlobalObjectRegularAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
    4950bool setJSTestGlobalObjectRegularAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
     51JSC::EncodedJSValue jsTestGlobalObjectPublicAndPrivateAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
     52bool setJSTestGlobalObjectPublicAndPrivateAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
     53#if ENABLE(TEST_FEATURE)
     54JSC::EncodedJSValue jsTestGlobalObjectPublicAndPrivateConditionalAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
     55bool setJSTestGlobalObjectPublicAndPrivateConditionalAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
     56#endif
    5057#if ENABLE(TEST_FEATURE)
    5158JSC::EncodedJSValue jsTestGlobalObjectEnabledAtRuntimeAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
     
    5966/* Hash table */
    6067
    61 static const struct CompactHashIndex JSTestGlobalObjectTableIndex[8] = {
     68static const struct CompactHashIndex JSTestGlobalObjectTableIndex[16] = {
     69    { -1, -1 },
     70    { -1, -1 },
     71    { 2, -1 },
     72    { 0, -1 },
     73    { -1, -1 },
     74    { -1, -1 },
     75    { -1, -1 },
     76    { -1, -1 },
     77    { -1, -1 },
     78    { 3, -1 },
     79    { -1, -1 },
     80    { -1, -1 },
     81    { -1, -1 },
    6282    { -1, -1 },
    6383    { 1, -1 },
    6484    { -1, -1 },
    65     { 0, -1 },
    66     { -1, -1 },
    67     { -1, -1 },
    68     { -1, -1 },
    69     { -1, -1 },
    7085};
    7186
     
    7489{
    7590    { "regularAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectRegularAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectRegularAttribute) } },
     91    { "publicAndPrivateAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectPublicAndPrivateAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectPublicAndPrivateAttribute) } },
     92#if ENABLE(TEST_FEATURE)
     93    { "publicAndPrivateConditionalAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectPublicAndPrivateConditionalAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectPublicAndPrivateConditionalAttribute) } },
     94#else
     95    { 0, 0, NoIntrinsic, { 0, 0 } },
     96#endif
    7697    { "regularOperation", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestGlobalObjectInstanceFunctionRegularOperation), (intptr_t) (1) } },
    7798};
    7899
    79 static const HashTable JSTestGlobalObjectTable = { 2, 7, true, JSTestGlobalObjectTableValues, JSTestGlobalObjectTableIndex };
     100static const HashTable JSTestGlobalObjectTable = { 4, 15, true, JSTestGlobalObjectTableValues, JSTestGlobalObjectTableIndex };
    80101template<> JSValue JSTestGlobalObjectConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
    81102{
     
    126147    }
    127148#endif
     149    putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().publicAndPrivateAttributePrivateName(), CustomGetterSetter::create(vm, jsTestGlobalObjectPublicAndPrivateAttribute, nullptr), attributesForStructure(DontDelete | ReadOnly));
     150#if ENABLE(TEST_FEATURE)
     151    putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().publicAndPrivateConditionalAttributePrivateName(), CustomGetterSetter::create(vm, jsTestGlobalObjectPublicAndPrivateConditionalAttribute, nullptr), attributesForStructure(DontDelete | ReadOnly));
     152#endif
    128153#if ENABLE(TEST_FEATURE)
    129154    if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
     
    152177}
    153178
     179
     180EncodedJSValue jsTestGlobalObjectPublicAndPrivateAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
     181{
     182    UNUSED_PARAM(state);
     183    UNUSED_PARAM(thisValue);
     184    JSValue decodedThisValue = JSValue::decode(thisValue);
     185    auto* castedThis = jsDynamicCast<JSTestGlobalObject*>(decodedThisValue);
     186    if (UNLIKELY(!castedThis)) {
     187        return throwGetterTypeError(*state, "TestGlobalObject", "publicAndPrivateAttribute");
     188    }
     189    auto& impl = castedThis->wrapped();
     190    JSValue result = jsStringWithCache(state, impl.publicAndPrivateAttribute());
     191    return JSValue::encode(result);
     192}
     193
     194
     195#if ENABLE(TEST_FEATURE)
     196EncodedJSValue jsTestGlobalObjectPublicAndPrivateConditionalAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
     197{
     198    UNUSED_PARAM(state);
     199    UNUSED_PARAM(thisValue);
     200    JSValue decodedThisValue = JSValue::decode(thisValue);
     201    auto* castedThis = jsDynamicCast<JSTestGlobalObject*>(decodedThisValue);
     202    if (UNLIKELY(!castedThis)) {
     203        return throwGetterTypeError(*state, "TestGlobalObject", "publicAndPrivateConditionalAttribute");
     204    }
     205    auto& impl = castedThis->wrapped();
     206    JSValue result = jsStringWithCache(state, impl.publicAndPrivateConditionalAttribute());
     207    return JSValue::encode(result);
     208}
     209
     210#endif
    154211
    155212#if ENABLE(TEST_FEATURE)
     
    206263}
    207264
     265
     266bool setJSTestGlobalObjectPublicAndPrivateAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
     267{
     268    JSValue value = JSValue::decode(encodedValue);
     269    UNUSED_PARAM(thisValue);
     270    JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
     271    if (UNLIKELY(!castedThis)) {
     272        return throwSetterTypeError(*state, "TestGlobalObject", "publicAndPrivateAttribute");
     273    }
     274    auto& impl = castedThis->wrapped();
     275    auto nativeValue = value.toWTFString(state);
     276    if (UNLIKELY(state->hadException()))
     277        return false;
     278    impl.setPublicAndPrivateAttribute(WTFMove(nativeValue));
     279    return true;
     280}
     281
     282
     283#if ENABLE(TEST_FEATURE)
     284bool setJSTestGlobalObjectPublicAndPrivateConditionalAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
     285{
     286    JSValue value = JSValue::decode(encodedValue);
     287    UNUSED_PARAM(thisValue);
     288    JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
     289    if (UNLIKELY(!castedThis)) {
     290        return throwSetterTypeError(*state, "TestGlobalObject", "publicAndPrivateConditionalAttribute");
     291    }
     292    auto& impl = castedThis->wrapped();
     293    auto nativeValue = value.toWTFString(state);
     294    if (UNLIKELY(state->hadException()))
     295        return false;
     296    impl.setPublicAndPrivateConditionalAttribute(WTFMove(nativeValue));
     297    return true;
     298}
     299
     300#endif
    208301
    209302#if ENABLE(TEST_FEATURE)
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.h

    r199103 r202551  
    3232WEBCORE_EXPORT @interface DOMTestGlobalObject : DOMObject
    3333@property (copy) NSString *regularAttribute;
     34@property (copy) NSString *publicAndPrivateAttribute;
     35@property (copy) NSString *publicAndPrivateConditionalAttribute;
    3436@property (copy) NSString *enabledAtRuntimeAttribute;
    3537
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.mm

    r199103 r202551  
    6767}
    6868
     69- (NSString *)publicAndPrivateAttribute
     70{
     71    WebCore::JSMainThreadNullState state;
     72    return IMPL->publicAndPrivateAttribute();
     73}
     74
     75- (void)setPublicAndPrivateAttribute:(NSString *)newPublicAndPrivateAttribute
     76{
     77    WebCore::JSMainThreadNullState state;
     78    IMPL->setPublicAndPrivateAttribute(newPublicAndPrivateAttribute);
     79}
     80
     81#if ENABLE(TEST_FEATURE)
     82- (NSString *)publicAndPrivateConditionalAttribute
     83{
     84    WebCore::JSMainThreadNullState state;
     85    return IMPL->publicAndPrivateConditionalAttribute();
     86}
     87
     88- (void)setPublicAndPrivateConditionalAttribute:(NSString *)newPublicAndPrivateConditionalAttribute
     89{
     90    WebCore::JSMainThreadNullState state;
     91    IMPL->setPublicAndPrivateConditionalAttribute(newPublicAndPrivateConditionalAttribute);
     92}
     93#endif
     94
    6995#if ENABLE(TEST_FEATURE)
    7096- (NSString *)enabledAtRuntimeAttribute
  • trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl

    r199103 r202551  
    2727interface TestGlobalObject {
    2828    attribute DOMString regularAttribute;
     29    [PrivateIdentifier, PublicIdentifier] attribute DOMString publicAndPrivateAttribute;
     30    [Conditional=TEST_FEATURE, PrivateIdentifier, PublicIdentifier] attribute DOMString publicAndPrivateConditionalAttribute;
    2931    [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] attribute DOMString enabledAtRuntimeAttribute;
    3032    void regularOperation(DOMString testParam);
Note: See TracChangeset for help on using the changeset viewer.