Changeset 93951 in webkit


Ignore:
Timestamp:
Aug 28, 2011 4:58:25 PM (13 years ago)
Author:
weinig@apple.com
Message:

Add support for constructor syntax for Events
https://bugs.webkit.org/show_bug.cgi?id=63878

Reviewed by Oliver Hunt.

Source/WebCore:

Add basic support for Event constructors, starting with just supporting
the constructor for the base Event class and just JSC support. This lays
the infrastructure for the other events as well.

Test: fast/events/event-constructors.html

  • GNUmakefile.list.am:
  • UseJSC.cmake:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSBindingsAllInOne.cpp:

Add files.

  • bindings/generic/EventConstructors.h: Added.

Add binding agnostic header that defines the Event initializers
using a macro based DSL.

  • bindings/js/JSEventConstructors.cpp: Added.

(WebCore::convertValue):
(WebCore::tryGetProperty):
(WebCore::constructJSEventWithInitializer):
Add JSC implementation of Event initializer DSL.

  • dom/Event.cpp:

(WebCore::EventInit::EventInit):
(WebCore::Event::Event):

  • dom/Event.h:

(WebCore::Event::create):
Add Event initializer interface for base Event.

  • dom/Event.idl:

Mark Event as having a custom constructor function.

LayoutTests:

Add basic test for Event constructors.

  • fast/events/constructors/event-constructors-expected.txt: Added.
  • fast/events/constructors/event-constructors.html: Added.
Location:
trunk
Files:
5 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r93948 r93951  
     12011-08-28  Sam Weinig  <sam@webkit.org>
     2
     3        Add support for constructor syntax for Events
     4        https://bugs.webkit.org/show_bug.cgi?id=63878
     5
     6        Reviewed by Oliver Hunt.
     7
     8        Add basic test for Event constructors.
     9
     10        * fast/events/constructors/event-constructors-expected.txt: Added.
     11        * fast/events/constructors/event-constructors.html: Added.
     12
    1132011-08-27  Robert Hogan  <robert@webkit.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r93945 r93951  
     12011-08-28  Sam Weinig  <sam@webkit.org>
     2
     3        Add support for constructor syntax for Events
     4        https://bugs.webkit.org/show_bug.cgi?id=63878
     5
     6        Reviewed by Oliver Hunt.
     7
     8        Add basic support for Event constructors, starting with just supporting
     9        the constructor for the base Event class and just JSC support.  This lays
     10        the infrastructure for the other events as well.
     11
     12        Test: fast/events/event-constructors.html
     13
     14        * GNUmakefile.list.am:
     15        * UseJSC.cmake:
     16        * WebCore.gypi:
     17        * WebCore.pro:
     18        * WebCore.vcproj/WebCore.vcproj:
     19        * WebCore.xcodeproj/project.pbxproj:
     20        * bindings/js/JSBindingsAllInOne.cpp:
     21        Add files.
     22
     23        * bindings/generic/EventConstructors.h: Added.
     24        Add binding agnostic header that defines the Event initializers
     25        using a macro based DSL.
     26
     27        * bindings/js/JSEventConstructors.cpp: Added.
     28        (WebCore::convertValue):
     29        (WebCore::tryGetProperty):
     30        (WebCore::constructJSEventWithInitializer):
     31        Add JSC implementation of Event initializer DSL.
     32
     33        * dom/Event.cpp:
     34        (WebCore::EventInit::EventInit):
     35        (WebCore::Event::Event):
     36        * dom/Event.h:
     37        (WebCore::Event::create):
     38        Add Event initializer interface for base Event.
     39
     40        * dom/Event.idl:
     41        Mark Event as having a custom constructor function.
     42
    1432011-08-27  Andreas Kling  <kling@webkit.org>
    244
  • trunk/Source/WebCore/GNUmakefile.list.am

    r93811 r93951  
    646646        Source/WebCore/bindings/generic/BindingSecurityBase.h \
    647647        Source/WebCore/bindings/generic/BindingSecurity.h \
     648        Source/WebCore/bindings/generic/EventConstructors.h \
    648649        Source/WebCore/bindings/generic/GenericBinding.h \
    649650        Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp \
     
    719720        Source/WebCore/bindings/js/JSEntrySyncCustom.cpp \
    720721        Source/WebCore/bindings/js/JSEventCustom.cpp \
     722        Source/WebCore/bindings/js/JSEventConstructors.cpp \
    721723        Source/WebCore/bindings/js/JSEventListener.cpp \
    722724        Source/WebCore/bindings/js/JSEventListener.h \
  • trunk/Source/WebCore/UseJSC.cmake

    r93086 r93951  
    5151    bindings/js/JSElementCustom.cpp
    5252    bindings/js/JSErrorHandler.cpp
     53    bindings/js/JSEventConstructors.cpp
    5354    bindings/js/JSEventCustom.cpp
    5455    bindings/js/JSEventListener.cpp
  • trunk/Source/WebCore/WebCore.gypi

    r93811 r93951  
    17311731            'bindings/generic/BindingSecurityBase.cpp',
    17321732            'bindings/generic/BindingSecurityBase.h',
     1733            'bindings/generic/EventConstructors.h',
    17331734            'bindings/generic/GenericBinding.h',
    17341735            'bindings/generic/RuntimeEnabledFeatures.cpp',
     
    18191820            'bindings/js/JSErrorHandler.cpp',
    18201821            'bindings/js/JSErrorHandler.h',
     1822            'bindings/js/JSEventConstructors.cpp',
    18211823            'bindings/js/JSEventCustom.cpp',
    18221824            'bindings/js/JSEventListener.cpp',
  • trunk/Source/WebCore/WebCore.pro

    r93764 r93951  
    275275        bindings/js/JSElementCustom.cpp \
    276276        bindings/js/JSErrorHandler.cpp \
     277        bindings/js/JSEventConstructors.cpp \
    277278        bindings/js/JSEventCustom.cpp \
    278279        bindings/js/JSEventListener.cpp \
     
    12361237    bindings/ScriptControllerBase.h \
    12371238    bindings/generic/ActiveDOMCallback.h \
     1239    bindings/generic/EventConstructors.h \
    12381240    bindings/generic/RuntimeEnabledFeatures.h
    12391241
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r93811 r93951  
    5839858398                                </File>
    5839958399                                <File
     58400                                        RelativePath="..\bindings\generic\EventConstructors.h"
     58401                                        >
     58402                                </File>
     58403                                <File
    5840058404                                        RelativePath="..\bindings\generic\GenericBinding.h"
    5840158405                                        >
     
    6100861012                                        RelativePath="..\bindings\js\JSErrorHandler.h"
    6100961013                                        >
     61014                                </File>
     61015                                <File
     61016                                        RelativePath="..\bindings\js\JSEventConstructors.cpp"
     61017                                        >
     61018                                        <FileConfiguration
     61019                                                Name="Debug|Win32"
     61020                                                ExcludedFromBuild="true"
     61021                                                >
     61022                                                <Tool
     61023                                                        Name="VCCLCompilerTool"
     61024                                                />
     61025                                        </FileConfiguration>
     61026                                        <FileConfiguration
     61027                                                Name="Release|Win32"
     61028                                                ExcludedFromBuild="true"
     61029                                                >
     61030                                                <Tool
     61031                                                        Name="VCCLCompilerTool"
     61032                                                />
     61033                                        </FileConfiguration>
     61034                                        <FileConfiguration
     61035                                                Name="Debug_Cairo_CFLite|Win32"
     61036                                                ExcludedFromBuild="true"
     61037                                                >
     61038                                                <Tool
     61039                                                        Name="VCCLCompilerTool"
     61040                                                />
     61041                                        </FileConfiguration>
     61042                                        <FileConfiguration
     61043                                                Name="Release_Cairo_CFLite|Win32"
     61044                                                ExcludedFromBuild="true"
     61045                                                >
     61046                                                <Tool
     61047                                                        Name="VCCLCompilerTool"
     61048                                                />
     61049                                        </FileConfiguration>
     61050                                        <FileConfiguration
     61051                                                Name="Debug_All|Win32"
     61052                                                ExcludedFromBuild="true"
     61053                                                >
     61054                                                <Tool
     61055                                                        Name="VCCLCompilerTool"
     61056                                                />
     61057                                        </FileConfiguration>
     61058                                        <FileConfiguration
     61059                                                Name="Production|Win32"
     61060                                                ExcludedFromBuild="true"
     61061                                                >
     61062                                                <Tool
     61063                                                        Name="VCCLCompilerTool"
     61064                                                />
     61065                                        </FileConfiguration>
    6101061066                                </File>
    6101161067                                <File
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r93811 r93951  
    52445244                BCE3BEC20D222B1D007E06E4 /* TagNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE3BEC00D222B1D007E06E4 /* TagNodeList.cpp */; };
    52455245                BCE3BEC30D222B1D007E06E4 /* TagNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE3BEC10D222B1D007E06E4 /* TagNodeList.h */; };
     5246                BCE43897140B0051005E437E /* EventConstructors.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE43896140B0051005E437E /* EventConstructors.h */; };
     5247                BCE4389A140B0073005E437E /* JSEventConstructors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE43899140B0073005E437E /* JSEventConstructors.cpp */; };
    52465248                BCE4413312F748E2009B84B8 /* RenderCombineText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE4413112F748E2009B84B8 /* RenderCombineText.cpp */; };
    52475249                BCE4413412F748E2009B84B8 /* RenderCombineText.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE4413212F748E2009B84B8 /* RenderCombineText.h */; };
     
    1196111963                BCE3BEC00D222B1D007E06E4 /* TagNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagNodeList.cpp; sourceTree = "<group>"; };
    1196211964                BCE3BEC10D222B1D007E06E4 /* TagNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagNodeList.h; sourceTree = "<group>"; };
     11965                BCE43896140B0051005E437E /* EventConstructors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EventConstructors.h; path = generic/EventConstructors.h; sourceTree = "<group>"; };
     11966                BCE43899140B0073005E437E /* JSEventConstructors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEventConstructors.cpp; sourceTree = "<group>"; };
    1196311967                BCE4413112F748E2009B84B8 /* RenderCombineText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCombineText.cpp; sourceTree = "<group>"; };
    1196411968                BCE4413212F748E2009B84B8 /* RenderCombineText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCombineText.h; sourceTree = "<group>"; };
     
    1846418468                                A622A8F6122C44A600A785B3 /* BindingSecurityBase.cpp */,
    1846518469                                A622A8F7122C44A600A785B3 /* BindingSecurityBase.h */,
     18470                                BCE43896140B0051005E437E /* EventConstructors.h */,
    1846618471                                A622A8F9122C44A600A785B3 /* GenericBinding.h */,
    1846718472                        );
     
    1853018535                                F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */,
    1853118536                                F3D461471161D53200CA0D09 /* JSErrorHandler.h */,
     18537                                BCE43899140B0073005E437E /* JSEventConstructors.cpp */,
    1853218538                                BC60901E0E91B8EC000C68B5 /* JSEventTarget.cpp */,
    1853318539                                BC60901D0E91B8EC000C68B5 /* JSEventTarget.h */,
     
    2341023416                                93500F3213FDE3BE0099EC24 /* NSScrollerImpDetails.h in Headers */,
    2341123417                                D0A3A7311405A39800FB8ED3 /* ResourceLoaderOptions.h in Headers */,
     23418                                BCE43897140B0051005E437E /* EventConstructors.h in Headers */,
    2341223419                        );
    2341323420                        runOnlyForDeploymentPostprocessing = 0;
     
    2621526222                                1A1414B513A0F0500019996C /* WebKitFontFamilyNames.cpp in Sources */,
    2621626223                                DF9AFD7313FC31D80015FEB7 /* MediaPlayerPrivateAVFoundationObjC.mm in Sources */,
     26224                                BCE4389A140B0073005E437E /* JSEventConstructors.cpp in Sources */,
    2621726225                        );
    2621826226                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp

    r92304 r93951  
    7373#include "JSElementCustom.cpp"
    7474#include "JSErrorHandler.cpp"
     75#include "JSEventConstructors.cpp"
    7576#include "JSEventCustom.cpp"
    7677#include "JSEventListener.cpp"
  • trunk/Source/WebCore/dom/Event.cpp

    r93764 r93951  
    2323#include "config.h"
    2424#include "Event.h"
     25
    2526#include "EventDispatcher.h"
    2627#include "EventTarget.h"
    27 
    2828#include "UserGestureIndicator.h"
    2929#include <wtf/CurrentTime.h>
     
    3131
    3232namespace WebCore {
     33
     34EventInit::EventInit()
     35    : bubbles(false)
     36    , cancelable(false)
     37{
     38}
     39
    3340
    3441Event::Event()
     
    6168}
    6269
     70Event::Event(const AtomicString& eventType, const EventInit& initializer)
     71    : m_type(eventType)
     72    , m_canBubble(initializer.bubbles)
     73    , m_cancelable(initializer.cancelable)
     74    , m_propagationStopped(false)
     75    , m_immediatePropagationStopped(false)
     76    , m_defaultPrevented(false)
     77    , m_defaultHandled(false)
     78    , m_cancelBubble(false)
     79    , m_eventPhase(0)
     80    , m_currentTarget(0)
     81    , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
     82{
     83}
     84
    6385Event::~Event()
    6486{
  • trunk/Source/WebCore/dom/Event.h

    r93764 r93951  
    3434    class EventTarget;
    3535    class EventDispatcher;
     36
     37    struct EventInit {
     38        EventInit();
     39       
     40        bool bubbles;
     41        bool cancelable;
     42    };
    3643
    3744    class Event : public RefCounted<Event> {
     
    7077            return adoptRef(new Event(type, canBubble, cancelable));
    7178        }
     79
     80        static PassRefPtr<Event> create(const AtomicString& type, const EventInit& initializer)
     81        {
     82            return adoptRef(new Event(type, initializer));
     83        }
     84
    7285        virtual ~Event();
    7386
     
    177190        Event();
    178191        Event(const AtomicString& type, bool canBubble, bool cancelable);
     192        Event(const AtomicString& type, const EventInit&);
    179193
    180194        virtual void receivedTarget();
  • trunk/Source/WebCore/dom/Event.idl

    r93764 r93951  
    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 *
     
    2424    interface [
    2525        CustomToJS,
     26        CanBeConstructed,
     27        CustomConstructFunction,
    2628        NoStaticTables,
    2729        Polymorphic
Note: See TracChangeset for help on using the changeset viewer.