Changeset 48491 in webkit


Ignore:
Timestamp:
Sep 17, 2009 1:54:57 PM (15 years ago)
Author:
eric@webkit.org
Message:

2009-09-17 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Timothy Hatcher.

Wrap primitive values (as objects) in InspectorController::wrap.

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

  • inspector/InspectorController.cpp: (WebCore::InspectorController::wrapObject): objects of any type will be wrapped into proxies, only object proxies will have objectId.
  • inspector/front-end/ConsoleView.js: (WebInspector.ConsoleView.prototype.completions): there is InjectedScript.getCompletionsi that accepts an expression and returns possible completions. This way we don't need to wrap and unwrap the completions result into a proxy object.
  • inspector/front-end/InjectedScript.js: (InjectedScript.getCompletions): (InjectedScript.evaluate): (InjectedScript._evaluateOn): (InjectedScript.createProxyObject):
  • inspector/front-end/InjectedScriptAccess.js:
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r48490 r48491  
     12009-09-17  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Wrap primitive values (as objects) in InspectorController::wrap.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=28983
     8
     9        * inspector/InspectorController.cpp:
     10        (WebCore::InspectorController::wrapObject): objects of any type will be wrapped into proxies,
     11         only object proxies will have objectId.
     12        * inspector/front-end/ConsoleView.js:
     13        (WebInspector.ConsoleView.prototype.completions): there is InjectedScript.getCompletionsi
     14         that accepts an expression and returns possible completions. This way we don't need to wrap
     15         and unwrap the completions result into a proxy object.
     16        * inspector/front-end/InjectedScript.js:
     17        (InjectedScript.getCompletions):
     18        (InjectedScript.evaluate):
     19        (InjectedScript._evaluateOn):
     20        (InjectedScript.createProxyObject):
     21        * inspector/front-end/InjectedScriptAccess.js:
     22
    1232009-09-17  Nate Chapin  <japhet@chromium.org>
    224
  • trunk/WebCore/inspector/InspectorController.cpp

    r48430 r48491  
    15321532ScriptValue InspectorController::wrapObject(const ScriptValue& quarantinedObject)
    15331533{
     1534    ScriptFunctionCall function(m_scriptState, m_injectedScriptObj, "createProxyObject");
     1535    function.appendArgument(quarantinedObject);
    15341536    if (quarantinedObject.isObject()) {
    15351537        long id = m_lastBoundObjectId++;
     
    15371539        m_idToConsoleObject.set(objectId, quarantinedObject);
    15381540
    1539         ScriptFunctionCall function(m_scriptState, m_injectedScriptObj, "createProxyObject");
    1540         function.appendArgument(quarantinedObject);
    15411541        function.appendArgument(objectId);
    1542         ScriptValue wrapper = function.call();
    1543         return wrapper;
    1544     }
    1545     return quarantinedObject;
     1542    }
     1543    ScriptValue wrapper = function.call();
     1544    return wrapper;
    15461545}
    15471546
  • trunk/WebCore/inspector/front-end/ConsoleView.js

    r48431 r48491  
    292292        }
    293293
    294         function parsingCallback(result, isException)
    295         {
    296             if (!isException)
    297                 result = JSON.parse(result);
    298             reportCompletions(result, isException);
    299         }
    300 
    301         this.evalInInspectedWindow(
    302             "(function() {" +
    303                 "var props = {};" +
    304                 "for (var prop in (" + expressionString + ")) props[prop] = true;" +
    305                 ((!dotNotation && !bracketNotation) ?
    306                 "for (var prop in window._inspectorCommandLineAPI)" +
    307                     "if (prop.charAt(0) !== '_') props[prop] = true;"
    308                 : "") +
    309                 "return JSON.stringify(props);" +
    310             "})()",
    311             parsingCallback);
     294        var includeInspectorCommandLineAPI = (!dotNotation && !bracketNotation);
     295        InjectedScriptAccess.getCompletions(expressionString, includeInspectorCommandLineAPI, reportCompletions);
    312296    },
    313297
  • trunk/WebCore/inspector/front-end/InjectedScript.js

    r48437 r48491  
    499499}
    500500
     501
     502InjectedScript.getCompletions = function(expression, includeInspectorCommandLineAPI)
     503{
     504    var props = {};
     505    try {
     506        var expressionResult = InjectedScript._evaluateOn(InjectedScript._window().eval, InjectedScript._window(), expression);
     507        for (var prop in expressionResult)
     508            props[prop] = true;
     509        if (includeInspectorCommandLineAPI)
     510            for (var prop in InjectedScript._window()._inspectorCommandLineAPI)
     511                if (prop.charAt(0) !== '_')
     512                    props[prop] = true;
     513    } catch(e) {
     514    }
     515    return props;
     516}
     517
     518
    501519InjectedScript.evaluate = function(expression)
    502520{
    503     return InjectedScript._evaluateOn(InjectedScript._window().eval, InjectedScript._window(), expression);
    504 }
    505 
    506 InjectedScript._evaluateOn = function(evalFunction, object, expression)
    507 {
    508     InjectedScript._ensureCommandLineAPIInstalled();
    509     // Surround the expression in with statements to inject our command line API so that
    510     // the window object properties still take more precedent than our API functions.
    511     expression = "with (window._inspectorCommandLineAPI) { with (window) { " + expression + " } }";
    512 
    513521    var result = {};
    514522    try {
    515         var value = evalFunction.call(object, expression);
     523        var value = InjectedScript._evaluateOn(InjectedScript._window().eval, InjectedScript._window(), expression);
    516524        if (value === null)
    517525            return { value: null };
     
    534542    }
    535543    return result;
     544}
     545
     546InjectedScript._evaluateOn = function(evalFunction, object, expression)
     547{
     548    InjectedScript._ensureCommandLineAPIInstalled();
     549    // Surround the expression in with statements to inject our command line API so that
     550    // the window object properties still take more precedent than our API functions.
     551    expression = "with (window._inspectorCommandLineAPI) { with (window) { " + expression + " } }";
     552    return evalFunction.call(object, expression);
    536553}
    537554
     
    951968
    952969    var type = typeof object;
    953     if (type === "object" || type === "function") {
     970    if ((type === "object" && object !== null) || type === "function") {
    954971        for (var subPropertyName in object) {
    955972            result.hasChildren = true;
  • trunk/WebCore/inspector/front-end/InjectedScriptAccess.js

    r48046 r48491  
    6464InjectedScriptAccess._installHandler("getProperties");
    6565InjectedScriptAccess._installHandler("setPropertyValue");
     66InjectedScriptAccess._installHandler("getCompletions");
    6667InjectedScriptAccess._installHandler("evaluate");
    6768InjectedScriptAccess._installHandler("addInspectedNode");
Note: See TracChangeset for help on using the changeset viewer.