Demo/bin/Debug/front_end/components/RemoteObjectPreviewFormatter.js

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * @constructor
 */
WebInspector.RemoteObjectPreviewFormatter = function()
{
}

WebInspector.RemoteObjectPreviewFormatter.prototype = {
    /**
     * @param {!Element} parentElement
     * @param {!RuntimeAgent.ObjectPreview} preview
     * @return {boolean} true iff preview captured all information.
     */
    appendObjectPreview: function(parentElement, preview)
    {
        var description = preview.description;
        if (preview.type !== "object" || preview.subtype === "null") {
            parentElement.appendChild(this.renderPropertyPreview(preview.type, preview.subtype, description));
            return true;
        }
        if (description && preview.subtype !== "array") {
            var text = preview.subtype ? description : this._abbreviateFullQualifiedClassName(description);
            parentElement.createTextChildren(text, " ");
        }
        if (preview.entries)
            return this._appendEntriesPreview(parentElement, preview);
        return this._appendPropertiesPreview(parentElement, preview);
    },

    /**
     * @param {string} description
     * @return {string}
     */
    _abbreviateFullQualifiedClassName: function(description)
    {
        var abbreviatedDescription = description.split(".");
        for (var i = 0; i < abbreviatedDescription.length - 1; ++i)
            abbreviatedDescription[i] = abbreviatedDescription[i].trimMiddle(3);
        return abbreviatedDescription.join(".");
    },

    /**
     * @param {!Element} parentElement
     * @param {!RuntimeAgent.ObjectPreview} preview
     * @return {boolean} true iff preview captured all information.
     */
    _appendPropertiesPreview: function(parentElement, preview)
    {
        var isArray = preview.subtype === "array";
        var arrayLength = WebInspector.RemoteObject.arrayLength(preview);
        var properties = preview.properties;
        if (isArray)
            properties = properties.slice().stableSort(compareIndexesFirst);

        /**
         * @param {!RuntimeAgent.PropertyPreview} a
后面还有 120 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。