Changeset 193001 in webkit


Ignore:
Timestamp:
Dec 3, 2015, 10:29:28 AM (10 years ago)
Author:
timothy@apple.com
Message:

Merge r186695. rdar://problem/23221163

Location:
branches/safari-601-branch/Source/WebInspectorUI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-601-branch/Source/WebInspectorUI/ChangeLog

    r192523 r193001  
     12015-12-01  Timothy Hatcher  <timothy@apple.com>
     2
     3        Merge r186695. rdar://problem/23221163
     4
     5    2015-07-10  Devin Rousso  <drousso@apple.com>
     6
     7            Web Inspector: Add source links to functions logged in the console
     8            https://bugs.webkit.org/show_bug.cgi?id=146377
     9
     10            Reviewed by Timothy Hatcher.
     11
     12            * UserInterface/Protocol/RemoteObject.js:
     13            (WebInspector.RemoteObject.prototype.findFunctionSourceCodeLocation):
     14            Returns a promise that contains the sourceCodeLocation if the object represents a function and has an objectId.
     15            (WebInspector.RemoteObject.prototype._isFunction):
     16            * UserInterface/Views/ConsoleMessageView.css:
     17            (.console-message .console-message-location):
     18            Added specified values for font sizing and family to ensure that all location links have the same styling.
     19            * UserInterface/Views/ConsoleMessageView.js:
     20            (WebInspector.ConsoleMessageView):
     21            Now creates a link to the source code of the entered text if the message is of the type "result".
     22            (WebInspector.ConsoleMessageView.prototype._appendLocationLink):
     23            (WebInspector.ConsoleMessageView.prototype._createRemoteObjectIfNeeded):
     24            (WebInspector.ConsoleMessageView.prototype._appendFormattedArguments):
     25            (WebInspector.ConsoleMessageView.prototype._linkifyLocation):
     26            (WebInspector.ConsoleMessageView.prototype._linkifyCallFrameLocation):
     27            (WebInspector.ConsoleMessageView.prototype._linkifyCallFrame):
     28
    1292015-11-17  Babak Shafiei  <bshafiei@apple.com>
    230
  • branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js

    r185638 r193001  
    479479    }
    480480
     481    findFunctionSourceCodeLocation()
     482    {
     483        var result = new WebInspector.WrappedPromise;
     484
     485        if (!this._isFunction() || !this._objectId) {
     486            result.resolve(WebInspector.RemoteObject.SourceCodeLocationPromise.MissingObjectId);
     487            return result.promise;
     488        }
     489
     490        DebuggerAgent.getFunctionDetails(this._objectId, function(error, response) {
     491            if (error) {
     492                result.reject(error);
     493                return;
     494            }
     495
     496            var location = response.location;
     497            var sourceCode = WebInspector.debuggerManager.scriptForIdentifier(location.scriptId);
     498
     499            if (!sourceCode || sourceCode.url.startsWith("__WebInspector")) {
     500                result.resolve(WebInspector.RemoteObject.SourceCodeLocationPromise.NoSourceFound);
     501                return;
     502            }
     503
     504            var sourceCodeLocation = sourceCode.createSourceCodeLocation(location.lineNumber, location.columnNumber || 0);
     505            result.resolve(sourceCodeLocation);
     506        });
     507
     508        return result.promise;
     509    }
     510
    481511    // Private
    482512
     
    484514    {
    485515        return this._type === "symbol";
     516    }
     517
     518    _isFunction()
     519    {
     520        return this._type === "function";
    486521    }
    487522
     
    565600};
    566601
     602WebInspector.RemoteObject.SourceCodeLocationPromise = {
     603    NoSourceFound: "remote-object-source-code-location-promise-no-source-found",
     604    MissingObjectId: "remote-object-source-code-location-promise-missing-object-id"
     605}
     606
    567607// FIXME: Phase out this deprecated class.
    568608WebInspector.DeprecatedRemoteObjectProperty = class DeprecatedRemoteObjectProperty
  • branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.css

    r186634 r193001  
    231231.console-message .console-message-location {
    232232    float: right;
     233    font-family: -webkit-system-font, sans-serif;
     234    font-size: 12px;
    233235    font-weight: normal;
     236    -webkit-user-select: text;
    234237}
    235238
  • branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js

    r190742 r193001  
    319319        }
    320320
    321         if (!callFrame)
    322             return;
    323 
    324         var locationElement = new WebInspector.CallFrameView(callFrame);
    325         locationElement.classList.add("console-message-location");
    326         this._element.appendChild(locationElement);
     321        if (callFrame) {
     322            var locationElement = new WebInspector.CallFrameView(callFrame);
     323            locationElement.classList.add("console-message-location");
     324            this._element.appendChild(locationElement);
     325
     326            return;
     327        }
     328
     329        if (this._message.parameters.length === 1) {
     330            var parameter = this._createRemoteObjectIfNeeded(this._message.parameters[0]);
     331
     332            parameter.findFunctionSourceCodeLocation().then(function(result) {
     333                if (result === WebInspector.RemoteObject.SourceCodeLocationPromise.NoSourceFound || result === WebInspector.RemoteObject.SourceCodeLocationPromise.MissingObjectId)
     334                    return;
     335
     336                var link = this._linkifyLocation(result.sourceCode.url, result.lineNumber, result.columnNumber);
     337                link.classList.add("console-message-location");
     338
     339                if (this._element.hasChildNodes())
     340                    this._element.insertBefore(link, this._element.firstChild);
     341                else
     342                    this._element.appendChild(link);
     343            }.bind(this));
     344        }
    327345    }
    328346
     
    374392    }
    375393
     394    _createRemoteObjectIfNeeded(parameter)
     395    {
     396        // FIXME: Only pass RemoteObjects here so we can avoid this work.
     397        if (parameter instanceof WebInspector.RemoteObject)
     398            return parameter;
     399
     400        if (typeof parameter === "object")
     401            return WebInspector.RemoteObject.fromPayload(parameter);
     402
     403        return WebInspector.RemoteObject.fromPrimitiveValue(parameter);
     404    }
     405
    376406    _appendFormattedArguments(element, parameters)
    377407    {
     
    379409            return;
    380410
    381         // FIXME: Only pass RemoteObjects here so we can avoid this work.
    382         for (var i = 0; i < parameters.length; ++i) {
    383             if (parameters[i] instanceof WebInspector.RemoteObject)
    384                 continue;
    385 
    386             if (typeof parameters[i] === "object")
    387                 parameters[i] = WebInspector.RemoteObject.fromPayload(parameters[i]);
    388             else
    389                 parameters[i] = WebInspector.RemoteObject.fromPrimitiveValue(parameters[i]);
    390         }
     411        for (var i = 0; i < parameters.length; ++i)
     412            parameters[i] = this._createRemoteObjectIfNeeded(parameters[i]);
    391413
    392414        var builderElement = element.appendChild(document.createElement("span"));
     
    624646    _linkifyLocation(url, lineNumber, columnNumber)
    625647    {
     648        return WebInspector.linkifyLocation(url, lineNumber, columnNumber, "console-message-url");
     649    }
     650
     651    _linkifyCallFrameLocation(url, lineNumber, columnNumber)
     652    {
    626653        // ConsoleMessage stack trace line numbers are one-based.
    627654        lineNumber = lineNumber ? lineNumber - 1 : 0;
    628655        columnNumber = columnNumber ? columnNumber - 1 : 0;
    629         return WebInspector.linkifyLocation(url, lineNumber, columnNumber, "console-message-url");
     656        return this._linkifyLocation(url, lineNumber, columnNumber);
    630657    }
    631658
     
    643670        }
    644671
    645         return this._linkifyLocation(url, lineNumber, columnNumber);
     672        return this._linkifyCallFrameLocation(url, lineNumber, columnNumber);
    646673    }
    647674
Note: See TracChangeset for help on using the changeset viewer.