Changeset 58166 in webkit


Ignore:
Timestamp:
Apr 23, 2010 8:02:02 AM (14 years ago)
Author:
yurys@chromium.org
Message:

2010-04-23 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: provide JSC implementation for scopeType method on
call frame and use same jsvascript code for JSC and v8 when collecting
scope chain data.

https://bugs.webkit.org/show_bug.cgi?id=37663

  • bindings/js/JSInjectedScriptHostCustom.cpp: (WebCore::JSInjectedScriptHost::currentCallFrame):
  • bindings/js/JSJavaScriptCallFrameCustom.cpp: (WebCore::JSJavaScriptCallFrame::scopeType):
  • bindings/v8/custom/V8InjectedScriptHostCustom.cpp: (WebCore::V8InjectedScriptHost::currentCallFrameCallback):
  • inspector/InjectedScriptHost.idl:
  • inspector/front-end/InjectedScript.js: (injectedScriptConstructor.):
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r58163 r58166  
     12010-04-23  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: provide JSC implementation for scopeType method on
     6        call frame and use same jsvascript code for JSC and v8 when collecting
     7        scope chain data.
     8
     9        https://bugs.webkit.org/show_bug.cgi?id=37663
     10
     11        * bindings/js/JSInjectedScriptHostCustom.cpp:
     12        (WebCore::JSInjectedScriptHost::currentCallFrame):
     13        * bindings/js/JSJavaScriptCallFrameCustom.cpp:
     14        (WebCore::JSJavaScriptCallFrame::scopeType):
     15        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
     16        (WebCore::V8InjectedScriptHost::currentCallFrameCallback):
     17        * inspector/InjectedScriptHost.idl:
     18        * inspector/front-end/InjectedScript.js:
     19        (injectedScriptConstructor.):
     20
    1212010-04-23  Alexander Pavlov  <apavlov@chromium.org>
    222
  • trunk/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp

    r57738 r58166  
    130130    return toJS(exec, callFrame);
    131131}
    132 
    133 JSValue JSInjectedScriptHost::isActivation(ExecState*, const ArgList& args)
    134 {
    135     JSObject* object = args.at(0).getObject();
    136     return jsBoolean(object && object->isActivationObject());
    137 }
    138132#endif
    139133
  • trunk/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp

    r57812 r58166  
    8686}
    8787
    88 JSValue JSJavaScriptCallFrame::scopeType(ExecState*, const ArgList&)
     88JSValue JSJavaScriptCallFrame::scopeType(ExecState* exec, const ArgList& args)
    8989{
    90     // FIXME(37663): implement this method the way it's done in the InjectedScipt.js
    91     return jsNull();
     90    if (!impl()->scopeChain())
     91        return jsUndefined();
     92
     93    if (!args.at(0).isInt32())
     94        return jsUndefined();
     95    int index = args.at(0).asInt32();
     96
     97    const ScopeChainNode* scopeChain = impl()->scopeChain();
     98    ScopeChainIterator end = scopeChain->end();
     99
     100    bool foundLocalScope = false;
     101    for (ScopeChainIterator iter = scopeChain->begin(); iter != end; ++iter) {
     102        JSObject* scope = *iter;
     103        if (scope->isActivationObject()) {
     104            if (!foundLocalScope) {
     105                // First activation object is local scope, each successive activation object is closure.
     106                if (!index)
     107                    return jsJavaScriptCallFrameLOCAL_SCOPE(exec, JSValue(), Identifier());
     108                foundLocalScope = true;
     109            } else if (!index)
     110                return jsJavaScriptCallFrameCLOSURE_SCOPE(exec, JSValue(), Identifier());
     111        }
     112
     113        if (!index) {
     114            // Last in the chain is global scope.
     115            if (++iter == end)
     116                return jsJavaScriptCallFrameGLOBAL_SCOPE(exec, JSValue(), Identifier());
     117            return jsJavaScriptCallFrameWITH_SCOPE(exec, JSValue(), Identifier());
     118        }
     119
     120        --index;
     121    }
     122    return jsUndefined();
    92123}
    93124
  • trunk/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp

    r57812 r58166  
    162162    return toV8(ScriptDebugServer::shared().currentCallFrame());
    163163}
    164 
    165 v8::Handle<v8::Value> V8InjectedScriptHost::isActivationCallback(const v8::Arguments& args)
    166 {
    167     INC_STATS("InjectedScriptHost.isActivation()");
    168     return v8::Boolean::New(true);
    169 }
    170164#endif
    171165
  • trunk/WebCore/inspector/InjectedScriptHost.idl

    r56404 r58166  
    4444#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
    4545        [Custom] DOMObject currentCallFrame();
    46         [Custom] boolean isActivation(in DOMObject object);
    4746#endif
    4847
  • trunk/WebCore/inspector/front-end/InjectedScript.js

    r57812 r58166  
    842842}
    843843
    844 // FIXME(37663): unify scope chain representation and remove this if.
    845 if (jsEngine === "v8") {
    846 
    847844InjectedScript.CallFrameProxy.prototype = {
    848845    _wrapScopeChain: function(callFrame)
     
    856853        var scopeChain = callFrame.scopeChain;
    857854        var scopeChainProxy = [];
     855        var foundLocalScope = false;
    858856        for (var i = 0; i < scopeChain.length; i++) {
    859857            var scopeType = callFrame.scopeType(i);
     
    861859            var scopeObjectProxy = InjectedScript.createProxyObject(scopeObject, { callFrame: this.id, chainIndex: i }, true);
    862860
    863             var foundLocalScope = false;
    864861            switch(scopeType) {
    865862                case LOCAL_SCOPE: {
     
    875872                case WITH_SCOPE:
    876873                case CATCH_SCOPE: {
    877                     scopeObjectProxy.isWithBlock = true;
     874                    if (foundLocalScope && scopeObject instanceof inspectedWindow.Element)
     875                        scopeObjectProxy.isElement = true;
     876                    else if (foundLocalScope && scopeObject instanceof inspectedWindow.Document)
     877                        scopeObjectProxy.isDocument = true;
     878                    else
     879                        scopeObjectProxy.isWithBlock = true;
    878880                    break;
    879881                }
    880882            }
    881 
    882             if (foundLocalScope) {
    883                 if (scopeObject instanceof inspectedWindow.Element)
    884                     scopeObjectProxy.isElement = true;
    885                 else if (scopeObject instanceof inspectedWindow.Document)
    886                     scopeObjectProxy.isDocument = true;
    887             }
    888  
    889883            scopeChainProxy.push(scopeObjectProxy);
    890884        }
    891885        return scopeChainProxy;
    892886    }
    893 }
    894 
    895 } else {
    896 
    897 InjectedScript.CallFrameProxy.prototype = {
    898     _wrapScopeChain: function(callFrame)
    899     {
    900         var foundLocalScope = false;
    901         var scopeChain = callFrame.scopeChain;
    902         var scopeChainProxy = [];
    903         for (var i = 0; i < scopeChain.length; ++i) {
    904             var scopeObject = scopeChain[i];
    905             var scopeObjectProxy = InjectedScript.createProxyObject(scopeObject, { callFrame: this.id, chainIndex: i }, true);
    906 
    907             if (InjectedScriptHost.isActivation(scopeObject)) {
    908                 if (!foundLocalScope)
    909                     scopeObjectProxy.thisObject = InjectedScript.createProxyObject(callFrame.thisObject, { callFrame: this.id, thisObject: true }, true);
    910                 else
    911                     scopeObjectProxy.isClosure = true;
    912                 foundLocalScope = true;
    913                 scopeObjectProxy.isLocal = true;
    914             } else if (foundLocalScope && scopeObject instanceof inspectedWindow.Element)
    915                 scopeObjectProxy.isElement = true;
    916             else if (foundLocalScope && scopeObject instanceof inspectedWindow.Document)
    917                 scopeObjectProxy.isDocument = true;
    918             else if (!foundLocalScope)
    919                 scopeObjectProxy.isWithBlock = true;
    920             scopeChainProxy.push(scopeObjectProxy);
    921         }
    922         return scopeChainProxy;
    923     }
    924 }
    925 
    926887}
    927888
Note: See TracChangeset for help on using the changeset viewer.