Changeset 152466 in webkit


Ignore:
Timestamp:
Jul 8, 2013 2:24:33 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

NamedFlowCollection getters should return undefined when there's no NamedFlow
https://bugs.webkit.org/show_bug.cgi?id=118463

Patch by Radu Stavila <stavila@adobe.com> on 2013-07-08
Reviewed by Christophe Dumez.

Source/WebCore:

Added new TreatReturnedNullObjectAs attribute for generated methods and set it to Undefined
for the item and namedItem methods of DOMNamedFlowCollection.

Test: fast/regions/webkit-named-flow-collection-undefined.html

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateImplementationFunctionCall):

  • bindings/scripts/IDLAttributes.txt:
  • bindings/scripts/test/CPP/WebDOMTestObj.cpp:

(WebDOMTestObj::treatReturnedNullObjectAsUndefined):

  • bindings/scripts/test/CPP/WebDOMTestObj.h:
  • bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:

(webkit_dom_test_obj_treat_returned_null_object_as_undefined):

  • bindings/scripts/test/GObject/WebKitDOMTestObj.h:
  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::jsTestObjPrototypeFunctionTreatReturnedNullObjectAsUndefined):

  • bindings/scripts/test/JS/JSTestObj.h:
  • bindings/scripts/test/ObjC/DOMTestObj.h:
  • bindings/scripts/test/ObjC/DOMTestObj.mm:

(-[DOMTestObj treatReturnedNullObjectAsUndefined]):

  • bindings/scripts/test/TestObj.idl:
  • dom/DOMNamedFlowCollection.idl:

LayoutTests:

Added test that validates that NamedFlowCollection getters return undefined
when no named flows exist.

  • fast/regions/webkit-named-flow-collection-undefined-expected.txt: Added.
  • fast/regions/webkit-named-flow-collection-undefined.html: Added.
Location:
trunk
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r152463 r152466  
     12013-07-08  Radu Stavila  <stavila@adobe.com>
     2
     3        NamedFlowCollection getters should return undefined when there's no NamedFlow
     4        https://bugs.webkit.org/show_bug.cgi?id=118463
     5
     6        Reviewed by Christophe Dumez.
     7
     8        Added test that validates that NamedFlowCollection getters return undefined
     9        when no named flows exist.
     10
     11        * fast/regions/webkit-named-flow-collection-undefined-expected.txt: Added.
     12        * fast/regions/webkit-named-flow-collection-undefined.html: Added.
     13
    1142013-07-08  David Farler  <dfarler@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r152465 r152466  
     12013-07-08  Radu Stavila  <stavila@adobe.com>
     2
     3        NamedFlowCollection getters should return undefined when there's no NamedFlow
     4        https://bugs.webkit.org/show_bug.cgi?id=118463
     5
     6        Reviewed by Christophe Dumez.
     7
     8        Added new TreatReturnedNullObjectAs attribute for generated methods and set it to Undefined
     9        for the item and namedItem methods of DOMNamedFlowCollection.
     10
     11        Test: fast/regions/webkit-named-flow-collection-undefined.html
     12
     13        * bindings/scripts/CodeGeneratorJS.pm:
     14        (GenerateImplementationFunctionCall):
     15        * bindings/scripts/IDLAttributes.txt:
     16        * bindings/scripts/test/CPP/WebDOMTestObj.cpp:
     17        (WebDOMTestObj::treatReturnedNullObjectAsUndefined):
     18        * bindings/scripts/test/CPP/WebDOMTestObj.h:
     19        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
     20        (webkit_dom_test_obj_treat_returned_null_object_as_undefined):
     21        * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
     22        * bindings/scripts/test/JS/JSTestObj.cpp:
     23        (WebCore::jsTestObjPrototypeFunctionTreatReturnedNullObjectAsUndefined):
     24        * bindings/scripts/test/JS/JSTestObj.h:
     25        * bindings/scripts/test/ObjC/DOMTestObj.h:
     26        * bindings/scripts/test/ObjC/DOMTestObj.mm:
     27        (-[DOMTestObj treatReturnedNullObjectAsUndefined]):
     28        * bindings/scripts/test/TestObj.idl:
     29        * dom/DOMNamedFlowCollection.idl:
     30
    1312013-07-06 Changhun Kang <temoochin@company100.net>
    232
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r152435 r152466  
    33453345        }
    33463346
     3347        if ($function->signature->extendedAttributes->{"TreatReturnedNullObjectAs"} and $function->signature->extendedAttributes->{"TreatReturnedNullObjectAs"} eq "Undefined") {
     3348            push(@implContent, $indent . "if (result == jsNull())\n");
     3349            push(@implContent, $indent . "    result = jsUndefined();\n\n");
     3350        }
     3351
    33473352        push(@implContent, $indent . "return JSValue::encode(result);\n");
    33483353    }
  • trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt

    r152168 r152466  
    103103SuppressToJSObject
    104104TreatNullAs=NullString
     105TreatReturnedNullObjectAs=Undefined
    105106TreatReturnedNullStringAs=Null|Undefined
    106107TreatUndefinedAs=NullString
  • trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp

    r151563 r152466  
    991991#endif
    992992
     993WebDOMTestObj WebDOMTestObj::treatReturnedNullObjectAsUndefined()
     994{
     995    if (!impl())
     996        return WebDOMTestObj();
     997
     998    return toWebKit(WTF::getPtr(impl()->treatReturnedNullObjectAsUndefined()));
     999}
     1000
    9931001void WebDOMTestObj::classMethod()
    9941002{
  • trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h

    r151563 r152466  
    189189    void conditionalMethod3();
    190190#endif
     191    WebDOMTestObj treatReturnedNullObjectAsUndefined();
    191192    void classMethod();
    192193    int classMethodWithOptional(int arg);
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp

    r151563 r152466  
    14141414}
    14151415
     1416WebKitDOMTestObj*
     1417webkit_dom_test_obj_treat_returned_null_object_as_undefined(WebKitDOMTestObj* self)
     1418{
     1419    WebCore::JSMainThreadNullState state;
     1420    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
     1421    WebCore::TestObj* item = WebKit::core(self);
     1422    RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->treatReturnedNullObjectAsUndefined());
     1423    return WebKit::kit(gobjectResult.get());
     1424}
     1425
    14161426void
    14171427webkit_dom_test_obj_class_method(WebKitDOMTestObj* self)
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h

    r151563 r152466  
    406406
    407407/**
     408 * webkit_dom_test_obj_treat_returned_null_object_as_undefined:
     409 * @self: A #WebKitDOMTestObj
     410 *
     411 * Returns: (transfer none):
     412 *
     413**/
     414WEBKIT_API WebKitDOMTestObj*
     415webkit_dom_test_obj_treat_returned_null_object_as_undefined(WebKitDOMTestObj* self);
     416
     417/**
    408418 * webkit_dom_test_obj_class_method:
    409419 * @self: A #WebKitDOMTestObj
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r151978 r152466  
    320320    { "conditionalMethod3", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionConditionalMethod3), (intptr_t)0, NoIntrinsic },
    321321#endif
     322    { "treatReturnedNullObjectAsUndefined", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTreatReturnedNullObjectAsUndefined), (intptr_t)0, NoIntrinsic },
    322323    { "overloadedMethod", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t)2, NoIntrinsic },
    323324    { "classMethodWithClamp", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethodWithClamp), (intptr_t)2, NoIntrinsic },
     
    25042505
    25052506#endif
     2507
     2508EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTreatReturnedNullObjectAsUndefined(ExecState* exec)
     2509{
     2510    JSValue thisValue = exec->hostThisValue();
     2511    if (!thisValue.inherits(&JSTestObj::s_info))
     2512        return throwVMTypeError(exec);
     2513    JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));
     2514    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
     2515    TestObj* impl = static_cast<TestObj*>(castedThis->impl());
     2516
     2517    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->treatReturnedNullObjectAsUndefined()));
     2518    if (result == jsNull())
     2519        result = jsUndefined();
     2520
     2521    return JSValue::encode(result);
     2522}
    25062523
    25072524static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1(ExecState* exec)
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h

    r151832 r152466  
    210210JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConditionalMethod3(JSC::ExecState*);
    211211#endif
     212JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTreatReturnedNullObjectAsUndefined(JSC::ExecState*);
    212213JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(JSC::ExecState*);
    213214JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod(JSC::ExecState*);
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h

    r151832 r152466  
    168168- (void)conditionalMethod3;
    169169#endif
     170- (DOMTestObj *)treatReturnedNullObjectAsUndefined;
    170171- (void)classMethod;
    171172- (int)classMethodWithOptional:(int)arg;
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm

    r151832 r152466  
    10531053#endif
    10541054
     1055- (DOMTestObj *)treatReturnedNullObjectAsUndefined
     1056{
     1057    WebCore::JSMainThreadNullState state;
     1058    return kit(WTF::getPtr(IMPL->treatReturnedNullObjectAsUndefined()));
     1059}
     1060
    10551061- (void)classMethod
    10561062{
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r152154 r152466  
    168168    [Conditional=Condition1] const unsigned short CONDITIONAL_CONST = 0;
    169169
     170    // 'TreatReturnedNullObjectAs' extended method
     171    [TreatReturnedNullObjectAs=Undefined] TestObj treatReturnedNullObjectAsUndefined();
     172
    170173#if defined(TESTING_JS)
    171174    [CachedAttribute] readonly attribute any cachedAttribute1;
  • trunk/Source/WebCore/dom/DOMNamedFlowCollection.idl

    r151499 r152466  
    3636] interface DOMNamedFlowCollection {
    3737    readonly attribute unsigned long length;
    38     getter WebKitNamedFlow item(unsigned long index);
    39     getter WebKitNamedFlow namedItem(DOMString name);
     38    [TreatReturnedNullObjectAs=Undefined] getter WebKitNamedFlow item(unsigned long index);
     39    [TreatReturnedNullObjectAs=Undefined] getter WebKitNamedFlow namedItem(DOMString name);
    4040};
Note: See TracChangeset for help on using the changeset viewer.