Changeset 93762 in webkit


Ignore:
Timestamp:
Aug 24, 2011 11:58:33 PM (13 years ago)
Author:
morrita@google.com
Message:

Implement an Event constructor.
https://bugs.webkit.org/show_bug.cgi?id=66756

Patch by Kentaro Hara <haraken@google.com> on 2011-08-24
Reviewed by Adam Barth.

The spec of the Event constructor is here:
http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-event-constructor.
This patch added the Event constructor to EventConstructors.h using
JavaScript implementation-independent macros. This patch also added the V8
implementation of these macros to V8EventConstructors.cpp.

Source/WebCore:

The bug 63878 has been implementing the Event constructors for JSC.
Our plan is to first implement all the Event constructors for V8
using EventConstructors.h proposed in the JSC patch, and then merge
the JSC patch with these V8 patches. In any case, we are going to split
the patches for V8 and those for JSC in order to avoid hard regression.

Test: fast/events/event-constructors.html

  • WebCore.gypi: Added V8EventConstructors.cpp.
  • WebCore.pro: Added V8EventConstructors.cpp.
  • bindings/generic/EventConstructors.h: Added. The Event constructor. This is written using JavaScript implementation-independent macros. The V8 implementation of these macros is written in bindings/v8/custom/V8EventConstructors.cpp.
  • bindings/v8/OptionsObject.cpp:

(WebCore::OptionsObject::getKeyDouble): Returns the value of a given key of type double.
(WebCore::OptionsObject::getKey): Returns true whenever the given key is found, even if the value is null or undefined.

  • bindings/v8/OptionsObject.h:

(WebCore::OptionsObject::getKeyValue): Returns the value of the given key. We need to overload getKeyValue() for all types required to EventConfiguration members.

  • bindings/v8/custom/V8EventConstructors.cpp: Added. Implemented macros used in EventConstructors.h.

(WebCore::constructV8Event): The Event constructor.

  • dom/Event.cpp:

(WebCore::EventConfiguration::EventConfiguration): A constructor of EventConfiguration.
(WebCore::Event::Event): A constructor of the Event class.

  • dom/Event.h: Added EventConfiguration, which manages attributes of the Event class.

(WebCore::Event::create): A factory method of the Event class with EventConfiguration.

  • dom/Event.idl: Added 'CanBeConstructed' and 'V8CustomConstructor'.

LayoutTests:

  • fast/events/event-constructors-expected.txt: Added.
  • fast/events/event-constructors.html: Added.
  • platform/gtk/Skipped: Skipped event-constructors.html, since Event constructors are not yet implemented in JSC.
  • platform/mac/Skipped: Ditto.
  • platform/qt/Skipped: Ditto.
  • platform/win/Skipped: Ditto.
  • platform/wk2/Skipped: Ditto.
Location:
trunk
Files:
4 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r93759 r93762  
     12011-08-24  Kentaro Hara  <haraken@google.com>
     2
     3        Implement an Event constructor.
     4        https://bugs.webkit.org/show_bug.cgi?id=66756
     5
     6        Reviewed by Adam Barth.
     7
     8        The spec of the Event constructor is here:
     9        http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-event-constructor.
     10        This patch added the Event constructor to EventConstructors.h using
     11        JavaScript implementation-independent macros. This patch also added the V8
     12        implementation of these macros to V8EventConstructors.cpp.
     13
     14        * fast/events/event-constructors-expected.txt: Added.
     15        * fast/events/event-constructors.html: Added.
     16        * platform/gtk/Skipped: Skipped event-constructors.html, since Event constructors are not yet implemented in JSC.
     17        * platform/mac/Skipped: Ditto.
     18        * platform/qt/Skipped: Ditto.
     19        * platform/win/Skipped: Ditto.
     20        * platform/wk2/Skipped: Ditto.
     21
    1222011-08-24  Kentaro Hara  <haraken@google.com>
    223
  • trunk/LayoutTests/platform/gtk/Skipped

    r93628 r93762  
    492492fast/forms/select-script-onchange.html
    493493fast/html/tab-order.html
     494
     495# These tests require the implementation of Event constructors.
     496# https://bugs.webkit.org/show_bug.cgi?id=63878
     497fast/events/event-constructors.html
    494498
    495499# The box isn't empty after a test run with this test.
  • trunk/LayoutTests/platform/mac/Skipped

    r93359 r93762  
    8989fast/events/mouseover-button.html
    9090
     91# These tests require the JSC implementation of Event constructors.
     92# https://bugs.webkit.org/show_bug.cgi?id=63878
     93fast/events/event-constructors.html
     94
    9195# Skipped until https://bugs.webkit.org/show_bug.cgi?id=33923 is resolved.
    9296platform/mac/accessibility/change-notification-on-scroll.html
  • trunk/LayoutTests/platform/qt/Skipped

    r93628 r93762  
    202202# Font feature settings is not implemented.
    203203css3/font-feature-settings-rendering.html
     204
     205# These tests require the JSC implementation of Event constructors.
     206# https://bugs.webkit.org/show_bug.cgi?id=63878
     207fast/events/event-constructors.html
    204208
    205209# =========================================================================== #
  • trunk/LayoutTests/platform/win/Skipped

    r93529 r93762  
    148148# No button tracked
    149149fast/events/mouseover-button.html
     150
     151# These tests require the JSC implementation of Event constructors.
     152# https://bugs.webkit.org/show_bug.cgi?id=63878
     153fast/events/event-constructors.html
    150154
    151155# The eqqivalent of option-tab doesn not exist in Boomer <rdar://problem/5137230>
  • trunk/LayoutTests/platform/wk2/Skipped

    r93732 r93762  
    15961596platform/mac/fast/text/rounding-hacks-expansion.html
    15971597
     1598# These tests require the implementation of Event constructors.
     1599# https://bugs.webkit.org/show_bug.cgi?id=63878
     1600fast/events/event-constructors.html
     1601
    15981602# Sometimes fails
    15991603# http://webkit.org/b/58990
  • trunk/Source/WebCore/ChangeLog

    r93761 r93762  
     12011-08-24  Kentaro Hara  <haraken@google.com>
     2
     3        Implement an Event constructor.
     4        https://bugs.webkit.org/show_bug.cgi?id=66756
     5
     6        Reviewed by Adam Barth.
     7
     8        The spec of the Event constructor is here:
     9        http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-event-constructor.
     10        This patch added the Event constructor to EventConstructors.h using
     11        JavaScript implementation-independent macros. This patch also added the V8
     12        implementation of these macros to V8EventConstructors.cpp.
     13
     14        The bug 63878 has been implementing the Event constructors for JSC.
     15        Our plan is to first implement all the Event constructors for V8
     16        using EventConstructors.h proposed in the JSC patch, and then merge
     17        the JSC patch with these V8 patches. In any case, we are going to split
     18        the patches for V8 and those for JSC in order to avoid hard regression.
     19
     20        Test: fast/events/event-constructors.html
     21
     22        * WebCore.gypi: Added V8EventConstructors.cpp.
     23        * WebCore.pro: Added V8EventConstructors.cpp.
     24        * bindings/generic/EventConstructors.h: Added. The Event constructor. This is written using JavaScript implementation-independent macros. The V8 implementation of these macros is written in bindings/v8/custom/V8EventConstructors.cpp.
     25        * bindings/v8/OptionsObject.cpp:
     26        (WebCore::OptionsObject::getKeyDouble): Returns the value of a given key of type double.
     27        (WebCore::OptionsObject::getKey): Returns true whenever the given key is found, even if the value is null or undefined.
     28        * bindings/v8/OptionsObject.h:
     29        (WebCore::OptionsObject::getKeyValue): Returns the value of the given key. We need to overload getKeyValue() for all types required to EventConfiguration members.
     30        * bindings/v8/custom/V8EventConstructors.cpp: Added. Implemented macros used in EventConstructors.h.
     31        (WebCore::constructV8Event): The Event constructor.
     32        * dom/Event.cpp:
     33        (WebCore::EventConfiguration::EventConfiguration): A constructor of EventConfiguration.
     34        (WebCore::Event::Event): A constructor of the Event class.
     35        * dom/Event.h: Added EventConfiguration, which manages attributes of the Event class.
     36        (WebCore::Event::create): A factory method of the Event class with EventConfiguration.
     37        * dom/Event.idl: Added 'CanBeConstructed' and 'V8CustomConstructor'.
     38
    1392011-08-24  Philippe Normand  <pnormand@igalia.com>
    240
  • trunk/Source/WebCore/WebCore.gypi

    r93713 r93762  
    17301730            'bindings/generic/BindingSecurityBase.cpp',
    17311731            'bindings/generic/BindingSecurityBase.h',
     1732            'bindings/generic/EventConstructors.h',
    17321733            'bindings/generic/GenericBinding.h',
    17331734            'bindings/generic/RuntimeEnabledFeatures.cpp',
     
    21422143            'bindings/v8/custom/V8EntryCustom.cpp',
    21432144            'bindings/v8/custom/V8EntrySyncCustom.cpp',
     2145            'bindings/v8/custom/V8EventConstructors.cpp',
    21442146            'bindings/v8/custom/V8EventCustom.cpp',
    21452147            'bindings/v8/custom/V8EventSourceConstructor.cpp',
  • trunk/Source/WebCore/WebCore.pro

    r93713 r93762  
    165165        bindings/v8/custom/V8DocumentLocationCustom.cpp \
    166166        bindings/v8/custom/V8ElementCustom.cpp \
     167        bindings/v8/custom/V8EventConstructors.cpp \
    167168        bindings/v8/custom/V8EventCustom.cpp \
    168169        bindings/v8/custom/V8EventSourceConstructor.cpp \
  • trunk/Source/WebCore/bindings/v8/OptionsObject.cpp

    r93759 r93762  
    9090}
    9191
     92bool OptionsObject::getKeyDouble(const String& key, double& value) const
     93{
     94    v8::Local<v8::Value> v8Value;
     95    if (!getKey(key, v8Value))
     96        return false;
     97
     98    v8::Local<v8::Number> v8Number = v8Value->ToNumber();
     99    if (v8Number.IsEmpty())
     100        return false;
     101    value = v8Number->Value();
     102    return true;
     103}
     104
    92105bool OptionsObject::getKeyString(const String& key, String& value) const
    93106{
  • trunk/Source/WebCore/bindings/v8/OptionsObject.h

    r93759 r93762  
    4848    bool getKeyString(const String& key, String& value) const;
    4949    bool getKeyStringWithUndefinedOrNullCheck(const String& key, String& value) const;
     50    bool getKeyDouble(const String& key, double& value) const;
    5051    PassRefPtr<DOMStringList> getKeyDOMStringList(const String& key) const;
    5152    PassRefPtr<IDBKeyRange> getKeyKeyRange(const String& key) const;
     53
     54     bool getKeyValue(const String& key, bool& value) const
     55     {
     56         return getKeyBool(key, value);
     57     }
     58     bool getKeyValue(const String& key, int32_t& value) const
     59     {
     60         return getKeyInt32(key, value);
     61     }
     62     bool getKeyValue(const String& key, double& value) const
     63     {
     64         return getKeyDouble(key, value);
     65     }
     66     bool getKeyValue(const String& key, String& value) const
     67     {
     68         return getKeyString(key, value);
     69     }
    5270
    5371private:
  • trunk/Source/WebCore/dom/Event.cpp

    r93385 r93762  
    3232namespace WebCore {
    3333
     34EventConfiguration::EventConfiguration()
     35    : bubbles(false)
     36    , cancelable(false)
     37    , defaultPrevented(false)
     38    , timeStamp(0)
     39{
     40}
     41
    3442Event::Event()
    3543    : m_canBubble(false)
     
    6169}
    6270
     71Event::Event(const AtomicString& eventType, const EventConfiguration& eventConfiguration)
     72    : m_type(eventType)
     73    , m_canBubble(eventConfiguration.bubbles)
     74    , m_cancelable(eventConfiguration.cancelable)
     75    , m_propagationStopped(false)
     76    , m_immediatePropagationStopped(false)
     77    , m_defaultPrevented(eventConfiguration.defaultPrevented)
     78    , m_defaultHandled(false)
     79    , m_cancelBubble(false)
     80    , m_eventPhase(0)
     81    , m_currentTarget(0)
     82    , m_createTime(static_cast<DOMTimeStamp>(eventConfiguration.timeStamp))
     83{
     84}
     85
    6386Event::~Event()
    6487{
  • trunk/Source/WebCore/dom/Event.h

    r93385 r93762  
    3434    class EventTarget;
    3535    class EventDispatcher;
     36
     37    struct EventConfiguration {
     38        EventConfiguration();
     39
     40        bool bubbles;
     41        bool cancelable;
     42        bool defaultPrevented;
     43        double timeStamp;
     44    };
    3645
    3746    class Event : public RefCounted<Event> {
     
    6978        {
    7079            return adoptRef(new Event(type, canBubble, cancelable));
     80        }
     81        static PassRefPtr<Event> create(const AtomicString& type, const EventConfiguration& eventConfiguration)
     82        {
     83            return adoptRef(new Event(type, eventConfiguration));
    7184        }
    7285        virtual ~Event();
     
    177190        Event();
    178191        Event(const AtomicString& type, bool canBubble, bool cancelable);
     192        Event(const AtomicString&, const EventConfiguration&);
    179193
    180194        virtual void receivedTarget();
  • trunk/Source/WebCore/dom/Event.idl

    r91617 r93762  
    11/*
    2  * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2009, 2011 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    44 *
     
    2525        CustomToJS,
    2626        NoStaticTables,
    27         Polymorphic
     27        Polymorphic,
     28        CanBeConstructed,
     29        V8CustomConstructor
    2830    ] Event {
    2931
Note: See TracChangeset for help on using the changeset viewer.