Changeset 46444 in webkit


Ignore:
Timestamp:
Jul 27, 2009 5:21:00 PM (15 years ago)
Author:
eric@webkit.org
Message:

2009-07-27 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

fix more obvious global object lookups
https://bugs.webkit.org/show_bug.cgi?id=27745

No new tests for these changes. I believe in many cases
testing to be impossible. Lack of testing justification next to
each change below. The remaining pieces of bug 27634 will all
need tests.

  • bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::updateDocument): not testable.
  • bindings/js/JSDataGridColumnListCustom.cpp: (WebCore::JSDataGridColumnList::nameGetter): no testing for this incomplete feature.
  • bindings/js/JSEventListener.cpp: (WebCore::JSEventListener::handleEvent): would require outer frame to trigger an event in the inner frame
  • bindings/js/JSEventTarget.cpp: (WebCore::toJS): covered by other tests, always correct to pass the globalObject through.
  • bindings/js/JSHTMLElementCustom.cpp: (WebCore::JSHTMLElement::pushEventHandlerScope): unclear when this could be triggered.
  • bindings/js/JSHTMLOptionsCollectionCustom.cpp: (WebCore::JSHTMLOptionsCollection::remove): toJS seems superfluous here to begin with.
  • bindings/js/JSLazyEventListener.cpp: (WebCore::JSLazyEventListener::parseCode): would require outer frame to trigger inner frame event.
  • bindings/js/ScriptController.cpp: (WebCore::ScriptController::jsObjectForPluginElement): only used for NPAPI binding, unclear how to test.
  • bindings/js/ScriptEventListener.cpp: (WebCore::createAttributeEventListener): unclear how to test.
  • bindings/js/ScriptObject.cpp: (WebCore::ScriptGlobalObject::set): unclear how to test/inspector only.
  • bindings/js/ScriptObjectQuarantine.cpp: (WebCore::getQuarantinedScriptObject): unclear how to test.
  • bindings/objc/DOMInternal.mm: (-[WebScriptObject _initializeScriptDOMNodeImp]): unclear how to test.
Location:
trunk/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r46443 r46444  
     12009-07-27  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        fix more obvious global object lookups
     6        https://bugs.webkit.org/show_bug.cgi?id=27745
     7
     8        No new tests for these changes.  I believe in many cases
     9        testing to be impossible.  Lack of testing justification next to
     10        each change below.  The remaining pieces of bug 27634 will all
     11        need tests.
     12
     13        * bindings/js/JSDOMWindowBase.cpp:
     14        (WebCore::JSDOMWindowBase::updateDocument): not testable.
     15        * bindings/js/JSDataGridColumnListCustom.cpp:
     16        (WebCore::JSDataGridColumnList::nameGetter): no testing for this incomplete feature.
     17        * bindings/js/JSEventListener.cpp:
     18        (WebCore::JSEventListener::handleEvent): would require outer frame to trigger an event in the inner frame
     19        * bindings/js/JSEventTarget.cpp:
     20        (WebCore::toJS): covered by other tests, always correct to pass the globalObject through.
     21        * bindings/js/JSHTMLElementCustom.cpp:
     22        (WebCore::JSHTMLElement::pushEventHandlerScope): unclear when this could be triggered.
     23        * bindings/js/JSHTMLOptionsCollectionCustom.cpp:
     24        (WebCore::JSHTMLOptionsCollection::remove): toJS seems superfluous here to begin with.
     25        * bindings/js/JSLazyEventListener.cpp:
     26        (WebCore::JSLazyEventListener::parseCode): would require outer frame to trigger inner frame event.
     27        * bindings/js/ScriptController.cpp:
     28        (WebCore::ScriptController::jsObjectForPluginElement): only used for NPAPI binding, unclear how to test.
     29        * bindings/js/ScriptEventListener.cpp:
     30        (WebCore::createAttributeEventListener): unclear how to test.
     31        * bindings/js/ScriptObject.cpp:
     32        (WebCore::ScriptGlobalObject::set): unclear how to test/inspector only.
     33        * bindings/js/ScriptObjectQuarantine.cpp:
     34        (WebCore::getQuarantinedScriptObject): unclear how to test.
     35        * bindings/objc/DOMInternal.mm:
     36        (-[WebScriptObject _initializeScriptDOMNodeImp]): unclear how to test.
     37
    1382009-07-27  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
    239
  • trunk/WebCore/bindings/js/JSDOMWindowBase.cpp

    r46346 r46444  
    6464    ASSERT(d()->impl->document());
    6565    ExecState* exec = globalExec();
    66     symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, d()->impl->document()), DontDelete | ReadOnly);
     66    symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, this, d()->impl->document()), DontDelete | ReadOnly);
    6767}
    6868
  • trunk/WebCore/bindings/js/JSDataGridColumnListCustom.cpp

    r45338 r46444  
    4747{
    4848    JSDataGridColumnList* thisObj = static_cast<JSDataGridColumnList*>(asObject(slot.slotBase()));
    49     return toJS(exec, thisObj->impl()->itemWithName(propertyName));
     49    return toJS(exec, thisObj->globalObject(), thisObj->impl()->itemWithName(propertyName));
    5050}
    5151
  • trunk/WebCore/bindings/js/JSEventListener.cpp

    r46431 r46444  
    7272    // xmlhttprequest objects. See http://bugs.webkit.org/show_bug.cgi?id=13275
    7373    // FIXME: Is this check still necessary? Requests are supposed to be stopped before clearGlobalObject() is called.
     74    ASSERT(globalObject);
    7475    if (!globalObject)
    7576        return;
     
    108109
    109110        MarkedArgumentBuffer args;
    110         args.append(toJS(exec, event));
     111        args.append(toJS(exec, globalObject, event));
    111112
    112113        Event* savedEvent = globalObject->currentEvent();
     
    128129                thisValue = globalObject->toThisObject(exec);
    129130            else
    130                 thisValue = toJS(exec, event->currentTarget());
     131                thisValue = toJS(exec, globalObject, event->currentTarget());
    131132            globalObject->globalData()->timeoutChecker.start();
    132133            retval = call(exec, jsFunction, callType, callData, thisValue, args);
  • trunk/WebCore/bindings/js/JSEventTarget.cpp

    r46369 r46444  
    6666namespace WebCore {
    6767
    68 JSValue toJS(ExecState* exec, JSDOMGlobalObject*, EventTarget* target)
     68JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* target)
    6969{
    7070    if (!target)
     
    7474    // SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node.
    7575    if (SVGElementInstance* instance = target->toSVGElementInstance())
    76         return toJS(exec, instance);
     76        return toJS(exec, globalObject, instance);
    7777#endif
    7878   
    7979    if (Node* node = target->toNode())
    80         return toJS(exec, node);
     80        return toJS(exec, globalObject, node);
    8181
    8282    if (DOMWindow* domWindow = target->toDOMWindow())
    83         return toJS(exec, domWindow);
     83        return toJS(exec, globalObject, domWindow);
    8484
    8585    if (XMLHttpRequest* xhr = target->toXMLHttpRequest())
    86         return toJS(exec, xhr);
     86        return toJS(exec, globalObject, xhr);
    8787
    8888    if (XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload())
    89         return toJS(exec, upload);
     89        return toJS(exec, globalObject, upload);
    9090
    9191#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    9292    if (DOMApplicationCache* cache = target->toDOMApplicationCache())
    93         return toJS(exec, cache);
     93        return toJS(exec, globalObject, cache);
    9494#endif
    9595
    9696    if (MessagePort* messagePort = target->toMessagePort())
    97         return toJS(exec, messagePort);
     97        return toJS(exec, globalObject, messagePort);
    9898
    9999#if ENABLE(WORKERS)
    100100    if (Worker* worker = target->toWorker())
    101         return toJS(exec, worker);
     101        return toJS(exec, globalObject, worker);
    102102
    103103    if (DedicatedWorkerContext* workerContext = target->toDedicatedWorkerContext())
     
    107107#if ENABLE(SHARED_WORKERS)
    108108    if (SharedWorker* sharedWorker = target->toSharedWorker())
    109         return toJS(exec, sharedWorker);
     109        return toJS(exec, globalObject, sharedWorker);
    110110#endif
    111111
  • trunk/WebCore/bindings/js/JSHTMLElementCustom.cpp

    r37705 r46444  
    3939
    4040    // The document is put on first, fall back to searching it only after the element and form.
    41     scope.push(asObject(toJS(exec, element->ownerDocument())));
     41    scope.push(asObject(toJS(exec, globalObject(), element->ownerDocument())));
    4242
    4343    // The form is next, searched before the document, but after the element itself.
    4444    if (HTMLFormElement* form = element->form())
    45         scope.push(asObject(toJS(exec, form)));
     45        scope.push(asObject(toJS(exec, globalObject(), form)));
    4646
    4747    // The element is on top, searched first.
    48     scope.push(asObject(toJS(exec, element)));
     48    scope.push(asObject(toJS(exec, globalObject(), element)));
    4949}
    5050
  • trunk/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp

    r43122 r46444  
    9292{
    9393    HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
    94     JSHTMLSelectElement* base = static_cast<JSHTMLSelectElement*>(asObject(toJS(exec, imp->base())));
     94    JSHTMLSelectElement* base = static_cast<JSHTMLSelectElement*>(asObject(toJS(exec, globalObject(), imp->base())));
    9595    return base->remove(exec, args);
    9696}
  • trunk/WebCore/bindings/js/JSLazyEventListener.cpp

    r45383 r46444  
    118118        ScopeChain scope = listenerAsFunction->scope();
    119119
    120         JSValue thisObj = toJS(exec, m_originalNode);
     120        JSValue thisObj = toJS(exec, m_globalObject, m_originalNode);
    121121        if (thisObj.isObject()) {
    122122            static_cast<JSNode*>(asObject(thisObj))->pushEventHandlerScope(exec, scope);
  • trunk/WebCore/bindings/js/ScriptController.cpp

    r46431 r46444  
    328328    JSLock lock(SilenceAssertionsOnly);
    329329    ExecState* exec = globalObject()->globalExec();
    330     JSValue jsElementValue = toJS(exec, plugin);
     330    JSValue jsElementValue = toJS(exec, globalObject(), plugin);
    331331    if (!jsElementValue || !jsElementValue.isObject())
    332332        return 0;
  • trunk/WebCore/bindings/js/ScriptEventListener.cpp

    r46431 r46444  
    7373    {
    7474        JSLock lock(SilenceAssertionsOnly);
    75         toJS(globalObject->globalExec(), node);
     75        // FIXME: Should pass the global object associated with the node
     76        toJS(globalObject->globalExec(), globalObject, node);
    7677    }
    7778
  • trunk/WebCore/bindings/js/ScriptObject.cpp

    r46431 r46444  
    127127{
    128128    JSLock lock(SilenceAssertionsOnly);
    129     scriptState->lexicalGlobalObject()->putDirect(Identifier(scriptState, name), toJS(scriptState, value));
     129    JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject());
     130    globalObject->putDirect(Identifier(scriptState, name), toJS(scriptState, globalObject, value));
    130131    return handleException(scriptState);
    131132}
  • trunk/WebCore/bindings/js/ScriptObjectQuarantine.cpp

    r46431 r46444  
    7070        return false;
    7171
    72     ExecState* exec = toJSDOMWindow(frame)->globalExec();
     72    JSDOMGlobalObject* globalObject = toJSDOMWindow(frame);
     73    ExecState* exec = globalObject->globalExec();
    7374
    7475    JSLock lock(SilenceAssertionsOnly);
    75     quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, database))));
     76    quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, globalObject, database))));
    7677
    7778    return true;
     
    8586    ASSERT(storage);
    8687
    87     ExecState* exec = toJSDOMWindow(frame)->globalExec();
     88    JSDOMGlobalObject* globalObject = toJSDOMWindow(frame);
     89    ExecState* exec = globalObject->globalExec();
    8890
    8991    JSLock lock(SilenceAssertionsOnly);
    90     quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, storage))));
     92    quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, globalObject, storage))));
    9193
    9294    return true;
     
    101103
    102104    JSLock lock(SilenceAssertionsOnly);
    103     quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, node))));
     105    // FIXME: Should use some sort of globalObjectFromNode()
     106    quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, deprecatedGlobalObjectForPrototype(exec), node))));
    104107
    105108    return true;
  • trunk/WebCore/bindings/objc/DOMInternal.mm

    r42618 r46444  
    124124    if (!frame)
    125125        return;
    126        
    127     JSC::ExecState *exec = frame->script()->globalObject()->globalExec();
    128    
     126
     127    // The global object which should own this node.
     128    WebCore::JSDOMGlobalObject* globalObject = frame->script()->globalObject();
     129    JSC::ExecState *exec = globalObject->globalExec();
     130
    129131    // Get (or create) a cached JS object for the DOM node.
    130     JSC::JSObject *scriptImp = asObject(WebCore::toJS(exec, nodeImpl));
     132    JSC::JSObject *scriptImp = asObject(WebCore::toJS(exec, globalObject, nodeImpl));
    131133
    132134    JSC::Bindings::RootObject* rootObject = frame->script()->bindingRootObject();
Note: See TracChangeset for help on using the changeset viewer.