⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181704 in webkit


Ignore:
Timestamp:
Mar 18, 2015, 11:30:47 AM (11 years ago)
Author:
Joseph Pecoraro
Message:

Web Inspector: Scopes sidebar should use new ObjectTreeView and not ObjectPropertiesSection
https://bugs.webkit.org/show_bug.cgi?id=142808

Reviewed by Timothy Hatcher.

  • UserInterface/Models/PropertyPath.js:

(WebInspector.PropertyPath):
(WebInspector.PropertyPath.emptyPropertyPathForScope):
Allow a special property empty path for "Scopes". This way for a
"<scopeObject>.property" we can show just the tooltip "property".

  • UserInterface/Views/ObjectTreeView.css:

(.object-tree.properties-only > :matches(.title, .object-preview)):
(.object-tree.properties-only .object-tree-outline):
(.object-tree.properties-only .object-tree-property .property-name):
Tweak styles for only properties view, which won't have a top-level
preview and doesn't fade out enumerable properties.

  • UserInterface/Views/ObjectTreeView.js:

(WebInspector.ObjectTreeView.prototype.get treeOutline):
Access the TreeOutline.

(WebInspector.ObjectTreeView.prototype.showOnlyProperties):
Properties only view modifies the display slightly.

(WebInspector.ObjectTreeView.prototype.appendExtraPropertyDescriptor):
(WebInspector.ObjectTreeView.prototype._updateProperties):
Allow the client to add its own property descriptors to display
as a property in this ObjectTreeView.

  • UserInterface/Views/ScopeChainDetailsSidebarPanel.js:

(WebInspector.ScopeChainDetailsSidebarPanel.prototype.refresh):
Switch to using an ObjectTreeView.

(WebInspector.ScopeChainDetailsSidebarPanel.prototype._propertyPathIdentifierForTreeElement):
(WebInspector.ScopeChainDetailsSidebarPanel.prototype._objectTreeAddHandler):
(WebInspector.ScopeChainDetailsSidebarPanel.prototype._objectTreeExpandHandler):
(WebInspector.ScopeChainDetailsSidebarPanel.prototype._objectTreeCollapseHandler):
Keep track of what properties were expanded so we can auto-expand
them again when the sidebar refreshes.

  • UserInterface/Main.html:
  • UserInterface/Views/ScopeVariableTreeElement.js: Removed.
  • WebInspectorUI.vcxproj/WebInspectorUI.vcxproj:
  • WebInspectorUI.vcxproj/WebInspectorUI.vcxproj.filters:

Remove the now unused ScopeVariableTreeElement.js.

Location:
trunk/Source/WebInspectorUI
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r181675 r181704  
     12015-03-18  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Scopes sidebar should use new ObjectTreeView and not ObjectPropertiesSection
     4        https://bugs.webkit.org/show_bug.cgi?id=142808
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Models/PropertyPath.js:
     9        (WebInspector.PropertyPath):
     10        (WebInspector.PropertyPath.emptyPropertyPathForScope):
     11        Allow a special property empty path for "Scopes". This way for a
     12        "<scopeObject>.property" we can show just the tooltip "property".
     13
     14        * UserInterface/Views/ObjectTreeView.css:
     15        (.object-tree.properties-only > :matches(.title, .object-preview)):
     16        (.object-tree.properties-only .object-tree-outline):
     17        (.object-tree.properties-only .object-tree-property .property-name):
     18        Tweak styles for only properties view, which won't have a top-level
     19        preview and doesn't fade out enumerable properties.
     20
     21        * UserInterface/Views/ObjectTreeView.js:
     22        (WebInspector.ObjectTreeView.prototype.get treeOutline):
     23        Access the TreeOutline.
     24
     25        (WebInspector.ObjectTreeView.prototype.showOnlyProperties):
     26        Properties only view modifies the display slightly.
     27
     28        (WebInspector.ObjectTreeView.prototype.appendExtraPropertyDescriptor):
     29        (WebInspector.ObjectTreeView.prototype._updateProperties):
     30        Allow the client to add its own property descriptors to display
     31        as a property in this ObjectTreeView.
     32
     33        * UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
     34        (WebInspector.ScopeChainDetailsSidebarPanel.prototype.refresh):
     35        Switch to using an ObjectTreeView.
     36
     37        (WebInspector.ScopeChainDetailsSidebarPanel.prototype._propertyPathIdentifierForTreeElement):
     38        (WebInspector.ScopeChainDetailsSidebarPanel.prototype._objectTreeAddHandler):
     39        (WebInspector.ScopeChainDetailsSidebarPanel.prototype._objectTreeExpandHandler):
     40        (WebInspector.ScopeChainDetailsSidebarPanel.prototype._objectTreeCollapseHandler):
     41        Keep track of what properties were expanded so we can auto-expand
     42        them again when the sidebar refreshes.
     43
     44        * UserInterface/Main.html:
     45        * UserInterface/Views/ScopeVariableTreeElement.js: Removed.
     46        * WebInspectorUI.vcxproj/WebInspectorUI.vcxproj:
     47        * WebInspectorUI.vcxproj/WebInspectorUI.vcxproj.filters:
     48        Remove the now unused ScopeVariableTreeElement.js.
     49
    1502015-03-17  Joseph Pecoraro  <pecoraro@apple.com>
    251
  • trunk/Source/WebInspectorUI/UserInterface/Main.html

    r181626 r181704  
    456456    <script src="Views/ScopeBarItem.js"></script>
    457457    <script src="Views/ScopeChainDetailsSidebarPanel.js"></script>
    458     <script src="Views/ScopeVariableTreeElement.js"></script>
    459458    <script src="Views/ScriptContentView.js"></script>
    460459    <script src="Views/ScriptTimelineDataGrid.js"></script>
  • trunk/Source/WebInspectorUI/UserInterface/Models/PropertyPath.js

    r181186 r181704  
    3939
    4040    this._object = object;
    41     this._pathComponent = pathComponent || null;
     41    this._pathComponent = typeof pathComponent === "string" ? pathComponent : null;
    4242    this._parent = parent || null;
    4343    this._isPrototype = isPrototype || false;
     
    5050    MapValue: "@mapvalue",
    5151    SetIndex: "@setindex",
     52    EmptyPathComponentForScope: "",
    5253};
    5354
     
    5758    Setter: "setter",
    5859};
     60
     61WebInspector.PropertyPath.emptyPropertyPathForScope = function(object)
     62{
     63    return new WebInspector.PropertyPath(object, WebInspector.PropertyPath.SpecialPathComponent.EmptyPathComponentForScope);
     64}
    5965
    6066WebInspector.PropertyPath.prototype = {
     
    149155    },
    150156
     157    isScope()
     158    {
     159        return this._pathComponent === WebInspector.PropertyPath.SpecialPathComponent.EmptyPathComponentForScope;
     160    },
     161
    151162    isPathComponentImpossible()
    152163    {
     
    168179    {
    169180        var isPrototype = propertyName === "__proto__";
     181
     182        if (this.isScope())
     183            return new WebInspector.PropertyPath(object, propertyName, this, isPrototype);
     184
    170185        var component = this._canPropertyNameBeDotAccess(propertyName) ? "." + propertyName : "[" + doubleQuotedString(propertyName) + "]";
    171186        return new WebInspector.PropertyPath(object, component, this, isPrototype);
  • trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.css

    r180722 r181704  
    5757}
    5858
     59.object-tree.properties-only > :matches(.title, .object-preview) {
     60    display: none;
     61}
     62
    5963.object-tree.expanded .object-preview {
    6064    font-style: normal;
     
    8084    min-height: 18px;
    8185    outline: none;
     86}
     87
     88.object-tree.properties-only .object-tree-outline {
     89    padding-left: 0;
     90}
     91
     92.object-tree.properties-only .object-tree-property .property-name {
     93    opacity: 1;
    8294}
    8395
  • trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js

    r181612 r181704  
    152152    },
    153153
     154    get treeOutline()
     155    {
     156        return this._outline;
     157    },
     158
    154159    get expanded()
    155160    {
     
    185190
    186191        this._untrackWeakEntries();
     192    },
     193
     194    showOnlyProperties()
     195    {
     196        this._inConsole = false;
     197
     198        this._element.classList.add("properties-only");
    187199    },
    188200
     
    193205        else
    194206            this._titleElement.appendChild(suffixElement);
     207    },
     208
     209    appendExtraPropertyDescriptor(propertyDescriptor)
     210    {
     211        if (!this._extraProperties)
     212            this._extraProperties = [];
     213
     214        this._extraProperties.push(propertyDescriptor);
    195215    },
    196216
     
    244264    _updateProperties(properties, propertyPath)
    245265    {
     266        if (this._extraProperties)
     267            properties = properties.concat(this._extraProperties);
     268
    246269        properties.sort(WebInspector.ObjectTreeView.ComparePropertyDescriptors);
    247270
  • trunk/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js

    r175767 r181704  
    3434};
    3535
     36WebInspector.ScopeChainDetailsSidebarPanel.autoExpandProperties = new Set;
     37
    3638WebInspector.ScopeChainDetailsSidebarPanel.prototype = {
    3739    constructor: WebInspector.ScopeChainDetailsSidebarPanel,
     
    4042    // Public
    4143
    42     inspect: function(objects)
     44    inspect(objects)
    4345    {
    4446        // Convert to a single item array if needed.
     
    7678    },
    7779
    78     refresh: function()
     80    refresh()
    7981    {
    8082        var callFrame = this.callFrame;
     
    9496
    9597            var title = null;
    96             var extraProperties = null;
     98            var extraPropertyDescriptor = null;
    9799            var collapsedByDefault = false;
    98100            var dontHighlightNonEnumerableProperties = true;
     
    109111
    110112                    if (callFrame.thisObject)
    111                         extraProperties = [new WebInspector.RemoteObjectProperty("this", callFrame.thisObject)];
     113                        extraPropertyDescriptor = new WebInspector.PropertyDescriptor({name: "this", value: callFrame.thisObject});
    112114                    break;
    113115
     
    145147            var detailsSectionIdentifier = scope.type + "-" + sectionCountByType[scope.type];
    146148
    147             var section = new WebInspector.ObjectPropertiesSection(scope.object, null, null, null, true, extraProperties, WebInspector.ScopeVariableTreeElement);
    148             section.dontHighlightNonEnumerablePropertiesAtTopLevel = dontHighlightNonEnumerableProperties;
    149             section.__propertyIdentifierPrefix = detailsSectionIdentifier;
     149            var scopePropertyPath = WebInspector.PropertyPath.emptyPropertyPathForScope(scope.object);
     150            var objectTree = new WebInspector.ObjectTreeView(scope.object, WebInspector.ObjectTreeView.Mode.Properties, scopePropertyPath);
     151
     152            objectTree.showOnlyProperties();
     153
     154            if (extraPropertyDescriptor)
     155                objectTree.appendExtraPropertyDescriptor(extraPropertyDescriptor);
     156
     157            var treeOutline = objectTree.treeOutline;
     158            treeOutline.onadd = this._objectTreeAddHandler.bind(this, detailsSectionIdentifier);
     159            treeOutline.onexpand = this._objectTreeExpandHandler.bind(this, detailsSectionIdentifier);
     160            treeOutline.oncollapse = this._objectTreeCollapseHandler.bind(this, detailsSectionIdentifier);
    150161
    151162            var detailsSection = new WebInspector.DetailsSection(detailsSectionIdentifier, title, null, null, collapsedByDefault);
    152             detailsSection.groups[0].rows = [new WebInspector.DetailsSectionPropertiesRow(section)];
     163            detailsSection.groups[0].rows = [new WebInspector.DetailsSectionPropertiesRow(objectTree)];
    153164            detailsSections.push(detailsSection);
    154165        }
     
    171182        // if the debugger is paused in code that was executed from the console. The console will be waiting for
    172183        // the result of the execution and without a timeout we would never update the scope variables.
    173         var timeout = setTimeout(delayedWork.bind(this), 50);
    174 
    175         // Since ObjectPropertiesSection populates asynchronously, we want to wait to replace the existing content
     184        var delay = WebInspector.ScopeChainDetailsSidebarPanel.autoExpandProperties.size === 0 ? 50 : 250;
     185        var timeout = setTimeout(delayedWork.bind(this), delay);
     186
     187        // Since ObjectTreeView populates asynchronously, we want to wait to replace the existing content
    176188        // until after all the pending asynchronous requests are completed. This prevents severe flashing while stepping.
    177189        InspectorBackend.runAfterPendingDispatches(delayedWork.bind(this));
     190    },
     191
     192    _propertyPathIdentifierForTreeElement(identifier, objectPropertyTreeElement)
     193    {
     194        if (!objectPropertyTreeElement.property)
     195            return null;
     196
     197        var propertyPath = objectPropertyTreeElement.thisPropertyPath();
     198        if (propertyPath.isFullPathImpossible())
     199            return null;
     200
     201        return identifier + "-" + propertyPath.fullPath;
     202    },
     203
     204    _objectTreeAddHandler(identifier, treeElement)
     205    {
     206        var propertyPathIdentifier = this._propertyPathIdentifierForTreeElement(identifier, treeElement);
     207        if (!propertyPathIdentifier)
     208            return;
     209
     210        if (WebInspector.ScopeChainDetailsSidebarPanel.autoExpandProperties.has(propertyPathIdentifier))
     211            treeElement.expand();
     212    },
     213
     214    _objectTreeExpandHandler(identifier, treeElement)
     215    {
     216        var propertyPathIdentifier = this._propertyPathIdentifierForTreeElement(identifier, treeElement);
     217        if (!propertyPathIdentifier)
     218            return;
     219
     220        WebInspector.ScopeChainDetailsSidebarPanel.autoExpandProperties.add(propertyPathIdentifier);
     221    },
     222
     223    _objectTreeCollapseHandler(identifier, treeElement)
     224    {
     225        var propertyPathIdentifier = this._propertyPathIdentifierForTreeElement(identifier, treeElement);
     226        if (!propertyPathIdentifier)
     227            return;
     228
     229        WebInspector.ScopeChainDetailsSidebarPanel.autoExpandProperties.delete(propertyPathIdentifier);
    178230    }
    179231};
  • trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj

    r181626 r181704  
    761761    <None Include="..\UserInterface\ScopeChainDetailsSidebarPanel.js" />
    762762    <None Include="..\UserInterface\ScopeChainNode.js" />
    763     <None Include="..\UserInterface\ScopeVariableTreeElement.js" />
    764763    <None Include="..\UserInterface\Script.js" />
    765764    <None Include="..\UserInterface\ScriptContentView.css" />
  • trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj.filters

    r181626 r181704  
    853853      <Filter>UserInterface</Filter>
    854854    </None>
    855     <None Include="..\UserInterface\ScopeVariableTreeElement.js">
    856       <Filter>UserInterface</Filter>
    857     </None>
    858855    <None Include="..\UserInterface\Script.js">
    859856      <Filter>UserInterface</Filter>
Note: See TracChangeset for help on using the changeset viewer.