Changeset 94480 in webkit


Ignore:
Timestamp:
Sep 2, 2011 11:04:21 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Implement a CustomEvent constructor for V8
https://bugs.webkit.org/show_bug.cgi?id=67527

Patch by Kentaro Hara <haraken@google.com> on 2011-09-02
Reviewed by Sam Weinig.

Source/WebCore:

Test: fast/events/constructors/custom-event-constructor.html

  • bindings/v8/OptionsObject.h:

(WebCore::OptionsObject::getKeyValue): Returns ScriptValue corresponding to a given key.

  • bindings/v8/custom/V8EventConstructors.cpp: Added the CustomEvent constructor.
  • dom/CustomEvent.idl: Added a 'V8CustomConstructor' attribute.

LayoutTests:

  • platform/chromium/fast/events/constructors/custom-event-constructor-expected.txt: Updated the result.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r94471 r94480  
     12011-09-02  Kentaro Hara  <haraken@google.com>
     2
     3        Implement a CustomEvent constructor for V8
     4        https://bugs.webkit.org/show_bug.cgi?id=67527
     5
     6        Reviewed by Sam Weinig.
     7
     8        * platform/chromium/fast/events/constructors/custom-event-constructor-expected.txt: Updated the result.
     9
    1102011-09-02  Chris Marrin  <cmarrin@apple.com>
    211
  • trunk/LayoutTests/platform/chromium/fast/events/constructors/custom-event-constructor-expected.txt

    r94151 r94480  
    77PASS new CustomEvent('eventType').cancelable is false
    88FAIL new CustomEvent('eventType').detail should be null (of type object). Was undefined (of type undefined).
    9 FAIL new CustomEvent('eventType', { bubbles: true, cancelable: true }).bubbles should be true. Was false.
    10 FAIL new CustomEvent('eventType', { bubbles: true, cancelable: true }).cancelable should be true. Was false.
     9PASS new CustomEvent('eventType', { bubbles: true, cancelable: true }).bubbles is true
     10PASS new CustomEvent('eventType', { bubbles: true, cancelable: true }).cancelable is true
    1111FAIL new CustomEvent('eventType', { bubbles: true, cancelable: true }).detail should be null (of type object). Was undefined (of type undefined).
    12 FAIL new CustomEvent('eventType', { detail: 10 }).detail should be 10 (of type number). Was undefined (of type undefined).
    13 FAIL new CustomEvent('eventType', { detail: 'string' }).detail should be string (of type string). Was undefined (of type undefined).
    14 FAIL new CustomEvent('eventType', { detail: detailObject }).detail should be [object Object] (of type object). Was undefined (of type undefined).
    15 FAIL new CustomEvent('eventType', { detail: document }).detail should be [object HTMLDocument] (of type object). Was undefined (of type undefined).
    16 FAIL new CustomEvent('eventType', { get detail() { return true; } }).detail should be true (of type boolean). Was undefined (of type undefined).
    17 FAIL new CustomEvent('eventType', { get detail() { throw 'Custom Error'; } }) should throw an exception. Was [object CustomEvent].
     12PASS new CustomEvent('eventType', { detail: 10 }).detail is 10
     13PASS new CustomEvent('eventType', { detail: 'string' }).detail is 'string'
     14PASS new CustomEvent('eventType', { detail: detailObject }).detail is detailObject
     15PASS new CustomEvent('eventType', { detail: document }).detail is document
     16PASS new CustomEvent('eventType', { get detail() { return true; } }).detail is true
     17PASS new CustomEvent('eventType', { get detail() { throw 'Custom Error'; } }) threw exception Custom Error.
    1818PASS successfullyParsed is true
    1919
  • trunk/Source/WebCore/ChangeLog

    r94474 r94480  
     12011-09-02  Kentaro Hara  <haraken@google.com>
     2
     3        Implement a CustomEvent constructor for V8
     4        https://bugs.webkit.org/show_bug.cgi?id=67527
     5
     6        Reviewed by Sam Weinig.
     7
     8        Test: fast/events/constructors/custom-event-constructor.html
     9
     10        * bindings/v8/OptionsObject.h:
     11        (WebCore::OptionsObject::getKeyValue): Returns ScriptValue corresponding to a given key.
     12        * bindings/v8/custom/V8EventConstructors.cpp: Added the CustomEvent constructor.
     13        * dom/CustomEvent.idl: Added a 'V8CustomConstructor' attribute.
     14
    1152011-09-02  Adrienne Walker  <enne@google.com>
    216
  • trunk/Source/WebCore/bindings/v8/OptionsObject.h

    r94424 r94480  
    2828
    2929#include "PlatformString.h"
     30#include "ScriptValue.h"
    3031#include <v8.h>
    3132
     
    6869        return getKeyString(key, value);
    6970    }
     71    bool getKeyValue(const String& key, ScriptValue& value) const
     72    {
     73        v8::Local<v8::Value> v8Value;
     74        if (!getKey(key, v8Value))
     75            return false;
     76
     77        value = ScriptValue(v8Value);
     78        return true;
     79    }
    7080
    7181private:
  • trunk/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp

    r94424 r94480  
    3232#include "EventConstructors.h"
    3333
     34#include "CustomEvent.h"
    3435#include "Document.h"
    3536#include "DocumentFragment.h"
     
    3940#include "V8Binding.h"
    4041#include "V8BindingMacros.h"
     42#include "V8CustomEvent.h"
    4143#include "V8Document.h"
    4244#include "V8Event.h"
     
    7779
    7880#define DICTIONARY_START(EventType) \
    79     static bool fill##EventType##Init(Event##Init& eventInit, const OptionsObject& options) \
     81    static bool fill##EventType##Init(EventType##Init& eventInit, const OptionsObject& options) \
    8082    {
    8183
     
    8688    v8::Handle<v8::Value> V8##EventType::constructorCallback(const v8::Arguments& args) \
    8789    { \
    88       return constructV8Event<EventType, EventType##Init>(args, fill##EventType##Init, &info); \
     90        return constructV8Event<EventType, EventType##Init>(args, fill##EventType##Init, &info); \
    8991    }
    9092
    9193#define FILL_PARENT_PROPERTIES(parentEventType) \
    92     if (!fill##parentEventType##Init(eventInit)) \
     94    if (!fill##parentEventType##Init(eventInit, options)) \
    9395        return false;
    9496
     
    9799
    98100INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY)
     101INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_CUSTOM_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY)
    99102
    100103
  • trunk/Source/WebCore/dom/CustomEvent.idl

    r94147 r94480  
    3030    interface [
    3131        CanBeConstructed,
    32         CustomConstructFunction
     32        CustomConstructFunction,
     33        V8CustomConstructor
    3334    ] CustomEvent : Event {
    3435
Note: See TracChangeset for help on using the changeset viewer.