Changeset 53430 in webkit


Ignore:
Timestamp:
Jan 18, 2010 2:12:12 PM (14 years ago)
Author:
ggaren@apple.com
Message:

2010-01-18 Geoffrey Garen <ggaren@apple.com>

Reviewed by Darin Adler.

Removed unnecessary use of scriptExecutionContext() when creating a JS event listener.
https://bugs.webkit.org/show_bug.cgi?id=33811

This change simplifies a bunch of code, and also reduces
the number of places that use the difficult-to-understand and possibly
crashy-null scriptExecutionContext() idiom.

  • bindings/js/JSDOMGlobalObject.cpp:
  • bindings/js/JSDOMGlobalObject.h:
  • bindings/js/JSEventListener.h: (WebCore::createJSAttributeEventListener):
  • bindings/scripts/CodeGeneratorJS.pm:
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53429 r53430  
     12010-01-18  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Removed unnecessary use of scriptExecutionContext() when creating a JS event listener.
     6        https://bugs.webkit.org/show_bug.cgi?id=33811
     7
     8        This change simplifies a bunch of code, and also reduces
     9        the number of places that use the difficult-to-understand and possibly
     10        crashy-null scriptExecutionContext() idiom.
     11
     12        * bindings/js/JSDOMGlobalObject.cpp:
     13        * bindings/js/JSDOMGlobalObject.h:
     14        * bindings/js/JSEventListener.h:
     15        (WebCore::createJSAttributeEventListener):
     16        * bindings/scripts/CodeGeneratorJS.pm:
     17
    1182010-01-18  Alexey Proskuryakov  <ap@apple.com>
    219
  • trunk/WebCore/bindings/js/JSDOMGlobalObject.cpp

    r53119 r53430  
    6060    if (d()->m_injectedScript)
    6161        markStack.append(d()->m_injectedScript);
    62 }
    63 
    64 PassRefPtr<JSEventListener> JSDOMGlobalObject::createJSAttributeEventListener(JSValue val)
    65 {
    66     if (!val.isObject())
    67         return 0;
    68 
    69     return JSEventListener::create(asObject(val), true, currentWorld(globalExec())).get();
    7062}
    7163
  • trunk/WebCore/bindings/js/JSDOMGlobalObject.h

    r53119 r53430  
    5454
    5555        virtual ScriptExecutionContext* scriptExecutionContext() const = 0;
    56 
    57         // Creates a JS EventListener for an "onXXX" event attribute. These
    58         // listeners cannot be removed through the removeEventListener API.
    59         PassRefPtr<JSEventListener> createJSAttributeEventListener(JSC::JSValue);
    6056
    6157        // Make binding code generation easier.
  • trunk/WebCore/bindings/js/JSEventListener.h

    r49963 r53430  
    6767    };
    6868
     69    // Creates a JS EventListener for an "onXXX" event attribute.
     70    inline PassRefPtr<JSEventListener> createJSAttributeEventListener(JSC::ExecState* exec, JSC::JSValue listener)
     71    {
     72        if (!listener.isObject())
     73            return 0;
     74
     75        return JSEventListener::create(asObject(listener), true, currentWorld(exec));
     76    }
     77
     78
    6979} // namespace WebCore
    7080
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r53170 r53430  
    14781478                            push(@implContent, "    UNUSED_PARAM(exec);\n");
    14791479                            push(@implContent, "    $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(thisObject)->impl());\n");
    1480                             if ($dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}) {
    1481                                 push(@implContent, "    JSDOMGlobalObject* globalObject = static_cast<$className*>(thisObject);\n");
    1482                             } else {
    1483                                 $implIncludes{"Frame.h"} = 1;
    1484                                 $implIncludes{"JSDOMGlobalObject.h"} = 1;
    1485                                 push(@implContent, "    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec);\n");
    1486                                 push(@implContent, "    if (!globalObject)\n");
    1487                                 push(@implContent, "        return;\n");
    1488                             }
    1489                             push(@implContent, "    imp->set$implSetterFunctionName(globalObject->createJSAttributeEventListener(value));\n");
     1480                            push(@implContent, "    imp->set$implSetterFunctionName(createJSAttributeEventListener(exec, value));\n");
    14901481                        } elsif ($attribute->signature->type =~ /Constructor$/) {
    14911482                            my $constructorType = $attribute->signature->type;
Note: See TracChangeset for help on using the changeset viewer.