Changeset 150276 in webkit


Ignore:
Timestamp:
May 17, 2013 11:16:41 AM (11 years ago)
Author:
Christophe Dumez
Message:

Add [EnabledAtRuntime] extended attribute support for global constructors
https://bugs.webkit.org/show_bug.cgi?id=116147

Reviewed by Geoffrey Garen.

Add [EnabledAtRuntime] extended attribute support for global constructors.
This patch adds [EnabledAtRuntime] extended attribute to SharedWorker and
WebSocket IDL interfaces so that their global constructors on the global
Window object can now be automatically generated.

The behavior on JavaScript side is unchanged. We simply leverage
RuntimeEnabledFeatures class and the new [EnabledAtRuntime] IDL extended
attribute to generate the code for global constructors getters instead
of using custom code.

No new tests, no behavior change for layout tests.

  • GNUmakefile.list.am:
  • Modules/websockets/WebSocket.cpp: Enable WebSockets at runtime by default.
  • Modules/websockets/WebSocket.idl:
  • Target.pri:
  • UseJSC.cmake:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.vcxproj/WebCore.vcxproj.filters:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSBindingsAllInOne.cpp:
  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore):

  • bindings/js/JSDOMWindowWebSocketCustom.cpp: Removed.
  • bindings/scripts/CodeGeneratorJS.pm:

(ToMethodName):
(GetRuntimeEnableFunctionName):
(GenerateImplementation):

  • bindings/scripts/IDLAttributes.txt:
  • page/DOMWindow.idl:
  • workers/SharedWorker.idl:
Location:
trunk/Source/WebCore
Files:
1 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150268 r150276  
     12013-05-17  Christophe Dumez  <ch.dumez@sisa.samsung.com>
     2
     3        Add [EnabledAtRuntime] extended attribute support for global constructors
     4        https://bugs.webkit.org/show_bug.cgi?id=116147
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Add [EnabledAtRuntime] extended attribute support for global constructors.
     9        This patch adds [EnabledAtRuntime] extended attribute to SharedWorker and
     10        WebSocket IDL interfaces so that their global constructors on the global
     11        Window object can now be automatically generated.
     12
     13        The behavior on JavaScript side is unchanged. We simply leverage
     14        RuntimeEnabledFeatures class and the new [EnabledAtRuntime] IDL extended
     15        attribute to generate the code for global constructors getters instead
     16        of using custom code.
     17
     18        No new tests, no behavior change for layout tests.
     19
     20        * GNUmakefile.list.am:
     21        * Modules/websockets/WebSocket.cpp: Enable WebSockets at runtime by default.
     22        * Modules/websockets/WebSocket.idl:
     23        * Target.pri:
     24        * UseJSC.cmake:
     25        * WebCore.vcproj/WebCore.vcproj:
     26        * WebCore.vcxproj/WebCore.vcxproj:
     27        * WebCore.vcxproj/WebCore.vcxproj.filters:
     28        * WebCore.xcodeproj/project.pbxproj:
     29        * bindings/js/JSBindingsAllInOne.cpp:
     30        * bindings/js/JSDOMWindowCustom.cpp:
     31        (WebCore):
     32        * bindings/js/JSDOMWindowWebSocketCustom.cpp: Removed.
     33        * bindings/scripts/CodeGeneratorJS.pm:
     34        (ToMethodName):
     35        (GetRuntimeEnableFunctionName):
     36        (GenerateImplementation):
     37        * bindings/scripts/IDLAttributes.txt:
     38        * page/DOMWindow.idl:
     39        * workers/SharedWorker.idl:
     40
    1412013-05-17  Darin Adler  <darin@apple.com>
    242
  • trunk/Source/WebCore/GNUmakefile.list.am

    r150216 r150276  
    23952395        Source/WebCore/bindings/js/JSDOMWindowShell.h \
    23962396        Source/WebCore/bindings/js/JSDOMWindowWebAudioCustom.cpp \
    2397         Source/WebCore/bindings/js/JSDOMWindowWebSocketCustom.cpp \
    23982397        Source/WebCore/bindings/js/JSDOMWrapper.cpp \
    23992398        Source/WebCore/bindings/js/JSDOMWrapper.h \
  • trunk/Source/WebCore/Modules/websockets/WebSocket.cpp

    r148968 r150276  
    127127}
    128128
    129 static bool webSocketsAvailable = false;
     129static bool webSocketsAvailable = true;
    130130
    131131void WebSocket::setIsAvailable(bool available)
  • trunk/Source/WebCore/Modules/websockets/WebSocket.idl

    r149796 r150276  
    3131
    3232[
    33     NoInterfaceObject,
     33    EnabledAtRuntime,
    3434    Conditional=WEB_SOCKETS,
    3535    ActiveDOMObject,
  • trunk/Source/WebCore/Target.pri

    r150240 r150276  
    115115     bindings/js/JSDOMWindowShell.cpp \
    116116     bindings/js/JSDOMWindowWebAudioCustom.cpp \
    117      bindings/js/JSDOMWindowWebSocketCustom.cpp \
    118117     bindings/js/JSDOMWrapper.cpp \
    119118     bindings/js/JSDataViewCustom.cpp \
  • trunk/Source/WebCore/UseJSC.cmake

    r149796 r150276  
    6767    bindings/js/JSDOMWindowShell.cpp
    6868    bindings/js/JSDOMWindowWebAudioCustom.cpp
    69     bindings/js/JSDOMWindowWebSocketCustom.cpp
    7069    bindings/js/JSDOMWrapper.cpp
    7170    bindings/js/JSDeviceMotionEventCustom.cpp
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r150216 r150276  
    6829568295                                </File>
    6829668296                                <File
    68297                                         RelativePath="..\bindings\js\JSDOMWindowWebSocketCustom.cpp"
    68298                                         >
    68299                                         <FileConfiguration
    68300                                                 Name="Debug|Win32"
    68301                                                 ExcludedFromBuild="true"
    68302                                                 >
    68303                                                 <Tool
    68304                                                         Name="VCCLCompilerTool"
    68305                                                 />
    68306                                         </FileConfiguration>
    68307                                         <FileConfiguration
    68308                                                 Name="Release|Win32"
    68309                                                 ExcludedFromBuild="true"
    68310                                                 >
    68311                                                 <Tool
    68312                                                         Name="VCCLCompilerTool"
    68313                                                 />
    68314                                         </FileConfiguration>
    68315                                         <FileConfiguration
    68316                                                 Name="Debug_Cairo_CFLite|Win32"
    68317                                                 ExcludedFromBuild="true"
    68318                                                 >
    68319                                                 <Tool
    68320                                                         Name="VCCLCompilerTool"
    68321                                                 />
    68322                                         </FileConfiguration>
    68323                                         <FileConfiguration
    68324                                                 Name="Release_Cairo_CFLite|Win32"
    68325                                                 ExcludedFromBuild="true"
    68326                                                 >
    68327                                                 <Tool
    68328                                                         Name="VCCLCompilerTool"
    68329                                                 />
    68330                                         </FileConfiguration>
    68331                                         <FileConfiguration
    68332                                                 Name="Debug_All|Win32"
    68333                                                 ExcludedFromBuild="true"
    68334                                                 >
    68335                                                 <Tool
    68336                                                         Name="VCCLCompilerTool"
    68337                                                 />
    68338                                         </FileConfiguration>
    68339                                         <FileConfiguration
    68340                                                 Name="Production|Win32"
    68341                                                 ExcludedFromBuild="true"
    68342                                                 >
    68343                                                 <Tool
    68344                                                         Name="VCCLCompilerTool"
    68345                                                 />
    68346                                         </FileConfiguration>
    68347                                 </File>
    68348                                 <File
    6834968297                                        RelativePath="..\bindings\js\JSDOMWrapper.cpp"
    6835068298                                        >
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r150216 r150276  
    94319431    </ClCompile>
    94329432    <ClCompile Include="..\bindings\js\JSDOMWindowWebAudioCustom.cpp">
    9433       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
    9434       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
    9435       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
    9436       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
    9437       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
    9438       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
    9439     </ClCompile>
    9440     <ClCompile Include="..\bindings\js\JSDOMWindowWebSocketCustom.cpp">
    94419433      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
    94429434      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r150216 r150276  
    53475347      <Filter>bindings\js</Filter>
    53485348    </ClCompile>
    5349     <ClCompile Include="..\bindings\js\JSDOMWindowWebSocketCustom.cpp">
    5350       <Filter>bindings\js</Filter>
    5351     </ClCompile>
    53525349    <ClCompile Include="..\bindings\js\JSDOMWrapper.cpp">
    53535350      <Filter>bindings\js</Filter>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r150216 r150276  
    34953495                A80A38FE0E50CC8200A25EBC /* PatternCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A80A38FD0E50CC8200A25EBC /* PatternCG.cpp */; };
    34963496                A80A9423149F225E00989291 /* JSDOMWindowWebAudioCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A80A9422149F225E00989291 /* JSDOMWindowWebAudioCustom.cpp */; };
    3497                 A80A9425149F227100989291 /* JSDOMWindowWebSocketCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A80A9424149F227100989291 /* JSDOMWindowWebSocketCustom.cpp */; };
    34983497                A80D67080E9E9DEB00E420F0 /* GraphicsContextPlatformPrivateCG.h in Headers */ = {isa = PBXBuildFile; fileRef = A80D67070E9E9DEB00E420F0 /* GraphicsContextPlatformPrivateCG.h */; };
    34993498                A80E6CE40A1989CA007FB8C5 /* CSSValueList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A80E6CBA0A1989CA007FB8C5 /* CSSValueList.cpp */; };
     
    99979996                A80A38FD0E50CC8200A25EBC /* PatternCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PatternCG.cpp; sourceTree = "<group>"; };
    99989997                A80A9422149F225E00989291 /* JSDOMWindowWebAudioCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMWindowWebAudioCustom.cpp; sourceTree = "<group>"; };
    9999                 A80A9424149F227100989291 /* JSDOMWindowWebSocketCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMWindowWebSocketCustom.cpp; sourceTree = "<group>"; };
    100009998                A80D67070E9E9DEB00E420F0 /* GraphicsContextPlatformPrivateCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextPlatformPrivateCG.h; sourceTree = "<group>"; };
    100019999                A80E6CBA0A1989CA007FB8C5 /* CSSValueList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSSValueList.cpp; sourceTree = "<group>"; };
     
    1888918887                                652FBBBB0DE27CB60001D386 /* JSDOMWindowCustom.h */,
    1889018888                                A80A9422149F225E00989291 /* JSDOMWindowWebAudioCustom.cpp */,
    18891                                 A80A9424149F227100989291 /* JSDOMWindowWebSocketCustom.cpp */,
    1889218889                                BC2ED5540C6B9BD300920BFF /* JSElementCustom.cpp */,
    1889318890                                BCEFAF4D0C317E6900FA81F6 /* JSEventCustom.cpp */,
     
    2552625523                                BCBFB53C0DCD29CF0019B3E5 /* JSDOMWindowShell.cpp in Sources */,
    2552725524                                A80A9423149F225E00989291 /* JSDOMWindowWebAudioCustom.cpp in Sources */,
    25528                                 A80A9425149F227100989291 /* JSDOMWindowWebSocketCustom.cpp in Sources */,
    2552925525                                CDDE691F171DFAD000A44D89 /* JSAudioBufferCustom.cpp in Sources */,
    2553025526                                FD7868B9136B999200D403DF /* JSDynamicsCompressorNode.cpp in Sources */,
  • trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp

    r148785 r150276  
    7171#include "JSDOMWindowShell.cpp"
    7272#include "JSDOMWindowWebAudioCustom.cpp"
    73 #include "JSDOMWindowWebSocketCustom.cpp"
    7473#include "JSDOMWrapper.cpp"
    7574#include "JSDataViewCustom.cpp"
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r149652 r150276  
    548548#endif
    549549
    550 #if ENABLE(SHARED_WORKERS)
    551 JSValue JSDOMWindow::sharedWorker(ExecState* exec) const
    552 {
    553     if (SharedWorkerRepository::isAvailable())
    554         return getDOMConstructor<JSSharedWorkerConstructor>(exec, this);
    555     return jsUndefined();
    556 }
    557 #endif
    558 
    559550// Custom functions
    560551
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r150249 r150276  
    15111511}
    15121512
     1513# URL becomes url, but SetURL becomes setURL.
     1514sub ToMethodName
     1515{
     1516    my $param = shift;
     1517    my $ret = lcfirst($param);
     1518    $ret =~ s/hTML/html/ if $ret =~ /^hTML/;
     1519    $ret =~ s/uRL/url/ if $ret =~ /^uRL/;
     1520    $ret =~ s/jS/js/ if $ret =~ /^jS/;
     1521    $ret =~ s/xML/xml/ if $ret =~ /^xML/;
     1522    $ret =~ s/xSLT/xslt/ if $ret =~ /^xSLT/;
     1523    $ret =~ s/cSS/css/ if $ret =~ /^cSS/;
     1524
     1525    # For HTML5 FileSystem API Flags attributes.
     1526    # (create is widely used to instantiate an object and must be avoided.)
     1527    $ret =~ s/^create/isCreate/ if $ret =~ /^create$/;
     1528    $ret =~ s/^exclusive/isExclusive/ if $ret =~ /^exclusive$/;
     1529
     1530    return $ret;
     1531}
     1532
     1533# Returns the RuntimeEnabledFeatures function name that is hooked up to check if a method/attribute is enabled.
     1534sub GetRuntimeEnableFunctionName
     1535{
     1536    my $signature = shift;
     1537
     1538    # If a parameter is given (e.g. "EnabledAtRuntime=FeatureName") return the RuntimeEnabledFeatures::{FeatureName}Enabled() method.
     1539    return "RuntimeEnabledFeatures::" . ToMethodName($signature->extendedAttributes->{"EnabledAtRuntime"}) . "Enabled" if ($signature->extendedAttributes->{"EnabledAtRuntime"} && $signature->extendedAttributes->{"EnabledAtRuntime"} ne "VALUE_IS_MISSING");
     1540
     1541    # Otherwise return a function named RuntimeEnabledFeatures::{methodName}Enabled().
     1542    return "RuntimeEnabledFeatures::" . ToMethodName($signature->name) . "Enabled";
     1543}
    15131544
    15141545sub GenerateImplementation
     
    19471978                push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, JSValue slotBase, PropertyName)\n");
    19481979                push(@implContent, "{\n");
     1980
     1981                # Global constructors can be disabled at runtime.
     1982                if ($attribute->signature->extendedAttributes->{"EnabledAtRuntime"} && $attribute->signature->type =~ /Constructor$/) {
     1983                    AddToImplIncludes("RuntimeEnabledFeatures.h");
     1984                    my $enable_function = GetRuntimeEnableFunctionName($attribute->signature);
     1985                    push(@implContent, "    if (!${enable_function}())\n");
     1986                    push(@implContent, "        return jsUndefined();\n");
     1987                }
    19491988
    19501989                if (!$attribute->isStatic || $attribute->signature->type =~ /Constructor$/) {
  • trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt

    r149796 r150276  
    5353DoNotCheckSecurityOnGetter
    5454DoNotCheckSecurityOnSetter
     55EnabledAtRuntime=*
    5556EnforceRange
    5657EventTarget
  • trunk/Source/WebCore/page/DOMWindow.idl

    r150045 r150276  
    327327    [CustomGetter, Conditional=VIDEO] attribute HTMLAudioElementConstructorConstructor Audio; // Usable with the new operator
    328328    [Conditional=VIDEO] attribute HTMLAudioElementConstructor HTMLAudioElement;
    329     [Conditional=WEB_SOCKETS, CustomGetter] attribute WebSocketConstructor WebSocket;
    330     [Conditional=SHARED_WORKERS, CustomGetter] attribute SharedWorkerConstructor SharedWorker; // Usable with the new operator
    331329    // Mozilla has a separate XMLDocument object for XML documents.
    332330    // We just use Document for this.
  • trunk/Source/WebCore/workers/SharedWorker.idl

    r149796 r150276  
    3131
    3232[
    33     NoInterfaceObject,
     33    EnabledAtRuntime,
    3434    Conditional=SHARED_WORKERS,
    3535    CustomConstructor,
Note: See TracChangeset for help on using the changeset viewer.