Changeset 181184 in webkit


Ignore:
Timestamp:
Mar 6, 2015 2:33:27 PM (9 years ago)
Author:
jonowells@apple.com
Message:

Web Inspector: Populate Debugger sidebar with all debuggable resources
https://bugs.webkit.org/show_bug.cgi?id=141232

Reviewed by Timothy Hatcher.

All debuggable resources now show in the debugger sidebar. The _resourceAdded handler now adds a script resource
to the sidebar regardless of whether it has any breakpoints set on it. The new function
_getTreeElementForSourceCodeAndAddToContentTreeOutline adds the element to the debugger sidebar before
_addBreakpointsForSourceCode is called. Removing all breakpoints from a resource no longer removes that
resource from the debugger sidebar. TreeOutline.prototype.removeChild has been updated so the disclosure
button will disappear and reappear correctly when removing/adding breakpoints.

  • UserInterface/Views/DebuggerSidebarPanel.js:

(WebInspector.DebuggerSidebarPanel.prototype._addBreakpoint): Expand resource if first breakpoint is added.
(WebInspector.DebuggerSidebarPanel.prototype._getTreeElementForSourceCodeAndAddToContentTreeOutline): Created.
(WebInspector.DebuggerSidebarPanel.prototype._resourceAdded): Checks resource type and adds scripts to sidebar.
(WebInspector.DebuggerSidebarPanel.prototype._mainResourceChanged):
(WebInspector.DebuggerSidebarPanel.prototype._scriptAdded):
(WebInspector.DebuggerSidebarPanel.prototype._removeBreakpointTreeElement): No longer removes empty parent.
(WebInspector.DebuggerSidebarPanel.prototype._treeElementSelected): Displays scripts without breakpoints now.

  • UserInterface/Views/GeneralTreeElement.js:

(WebInspector.GeneralTreeElement.prototype.get disclosureButton): Drive-by fix. Unused. Deleted.

  • UserInterface/Views/TreeOutline.js:

(TreeOutline.prototype.removeChild):
Remove parent class and set hasChildren to false if necessary to properly hide and reveal disclosure button
for elements whose children have been removed.

Location:
trunk/Source/WebInspectorUI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r181119 r181184  
     12015-03-06  Jono Wells  <jonowells@apple.com>
     2
     3        Web Inspector: Populate Debugger sidebar with all debuggable resources
     4        https://bugs.webkit.org/show_bug.cgi?id=141232
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        All debuggable resources now show in the debugger sidebar. The _resourceAdded handler now adds a script resource
     9        to the sidebar regardless of whether it has any breakpoints set on it. The new function
     10        _getTreeElementForSourceCodeAndAddToContentTreeOutline adds the element to the debugger sidebar before
     11        _addBreakpointsForSourceCode is called. Removing all breakpoints from a resource no longer removes that
     12        resource from the debugger sidebar. TreeOutline.prototype.removeChild has been updated so the disclosure
     13        button will disappear and reappear correctly when removing/adding breakpoints.
     14
     15        * UserInterface/Views/DebuggerSidebarPanel.js:
     16        (WebInspector.DebuggerSidebarPanel.prototype._addBreakpoint): Expand resource if first breakpoint is added.
     17        (WebInspector.DebuggerSidebarPanel.prototype._getTreeElementForSourceCodeAndAddToContentTreeOutline): Created.
     18        (WebInspector.DebuggerSidebarPanel.prototype._resourceAdded): Checks resource type and adds scripts to sidebar.
     19        (WebInspector.DebuggerSidebarPanel.prototype._mainResourceChanged):
     20        (WebInspector.DebuggerSidebarPanel.prototype._scriptAdded):
     21        (WebInspector.DebuggerSidebarPanel.prototype._removeBreakpointTreeElement): No longer removes empty parent.
     22        (WebInspector.DebuggerSidebarPanel.prototype._treeElementSelected): Displays scripts without breakpoints now.
     23
     24        * UserInterface/Views/GeneralTreeElement.js:
     25        (WebInspector.GeneralTreeElement.prototype.get disclosureButton): Drive-by fix. Unused. Deleted.
     26
     27        * UserInterface/Views/TreeOutline.js:
     28        (TreeOutline.prototype.removeChild):
     29        Remove parent class and set hasChildren to false if necessary to properly hide and reveal disclosure button
     30        for elements whose children have been removed.
     31
    1322015-03-05  Joseph Pecoraro  <pecoraro@apple.com>
    233
  • trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js

    r180004 r181184  
    154154WebInspector.DebuggerSidebarPanel.prototype = {
    155155    constructor: WebInspector.DebuggerSidebarPanel,
     156    __proto__: WebInspector.NavigationSidebarPanel.prototype,
    156157
    157158    // Public
     
    279280            return null;
    280281
    281         var parentTreeElement = this._breakpointsContentTreeOutline.getCachedTreeElement(sourceCode);
    282         if (!parentTreeElement) {
    283             if (sourceCode instanceof WebInspector.SourceMapResource)
    284                 parentTreeElement = new WebInspector.SourceMapResourceTreeElement(sourceCode);
    285             else if (sourceCode instanceof WebInspector.Resource)
    286                 parentTreeElement = new WebInspector.ResourceTreeElement(sourceCode);
    287             else if (sourceCode instanceof WebInspector.Script)
    288                 parentTreeElement = new WebInspector.ScriptTreeElement(sourceCode);
    289         }
    290 
    291         if (!parentTreeElement.parent) {
    292             parentTreeElement.hasChildren = true;
    293             parentTreeElement.expand();
    294 
    295             this._breakpointsContentTreeOutline.insertChild(parentTreeElement, insertionIndexForObjectInListSortedByFunction(parentTreeElement, this._breakpointsContentTreeOutline.children, this._compareTopLevelTreeElements.bind(this)));
    296         }
     282        var parentTreeElement = this._addTreeElementForSourceCodeToContentTreeOutline(sourceCode);
    297283
    298284        // Mark disabled breakpoints as resolved if there is source code loaded with that URL.
     
    305291        var breakpointTreeElement = new WebInspector.BreakpointTreeElement(breakpoint);
    306292        parentTreeElement.insertChild(breakpointTreeElement, insertionIndexForObjectInListSortedByFunction(breakpointTreeElement, parentTreeElement.children, this._compareBreakpointTreeElements));
     293        if (parentTreeElement.children.length === 1)
     294            parentTreeElement.expand();
    307295        return breakpointTreeElement;
    308296    },
     
    315303    },
    316304
     305    _addTreeElementForSourceCodeToContentTreeOutline: function(sourceCode)
     306    {
     307        var treeElement = this._breakpointsContentTreeOutline.getCachedTreeElement(sourceCode);
     308        if (!treeElement) {
     309            if (sourceCode instanceof WebInspector.SourceMapResource)
     310                treeElement = new WebInspector.SourceMapResourceTreeElement(sourceCode);
     311            else if (sourceCode instanceof WebInspector.Resource)
     312                treeElement = new WebInspector.ResourceTreeElement(sourceCode);
     313            else if (sourceCode instanceof WebInspector.Script)
     314                treeElement = new WebInspector.ScriptTreeElement(sourceCode);
     315        }
     316
     317        if (!treeElement.parent) {
     318            treeElement.hasChildren = false;
     319            treeElement.expand();
     320
     321            this._breakpointsContentTreeOutline.insertChild(treeElement, insertionIndexForObjectInListSortedByFunction(treeElement, this._breakpointsContentTreeOutline.children, this._compareTopLevelTreeElements.bind(this)));
     322        }
     323
     324        return treeElement;
     325    },
     326
    317327    _resourceAdded: function(event)
    318328    {
    319329        var resource = event.data.resource;
     330
     331        if (![WebInspector.Resource.Type.Document, WebInspector.Resource.Type.Script].contains(resource.type))
     332            return;
     333
     334        this._addTreeElementForSourceCodeToContentTreeOutline(resource);
    320335        this._addBreakpointsForSourceCode(resource);
    321336    },
     
    324339    {
    325340        var resource = event.target.mainResource;
     341        this._addTreeElementForSourceCodeToContentTreeOutline(resource);
    326342        this._addBreakpointsForSourceCode(resource);
    327343    },
     
    330346    {
    331347        var script = event.data.script;
     348
     349        // FIXME: Allow for scripts generated by eval statements to appear, but filter out JSC internals
     350        // and other WebInspector internals lacking __WebInspector in the url attribute.
     351        if (!script.url)
     352            return;
     353
     354        // Exclude inspector scripts.
     355        if (script.url && script.url.indexOf("__WebInspector") === 0)
     356            return;
    332357
    333358        // Don't add breakpoints if the script is represented by a Resource. They were
     
    336361            return;
    337362
     363        this._addTreeElementForSourceCodeToContentTreeOutline(script);
    338364        this._addBreakpointsForSourceCode(script);
    339365    },
     
    402428
    403429        console.assert(parentTreeElement.parent === this._breakpointsContentTreeOutline);
    404 
    405         if (!parentTreeElement.children.length)
    406             this._breakpointsContentTreeOutline.removeChild(parentTreeElement);
    407430    },
    408431
     
    561584
    562585        if (treeElement instanceof WebInspector.ResourceTreeElement || treeElement instanceof WebInspector.ScriptTreeElement) {
    563             // If the resource is being selected when it has no children it is in the process of being deleted, don't do anything.
    564             if (!treeElement.children.length)
    565                 return;
    566586            deselectCallStackContentTreeElements.call(this);
    567587            deselectPauseReasonContentTreeElements.call(this);
     
    646666    {
    647667        var pauseData = WebInspector.debuggerManager.pauseData;
    648        
     668
    649669        switch (WebInspector.debuggerManager.pauseReason) {
    650670        case WebInspector.DebuggerManager.PauseReason.Assertion:
     
    654674                this._pauseReasonTextRow.text = WebInspector.UIString("Assertion with message: %s").format(pauseData.message);
    655675                return true;
    656             }           
     676            }
    657677
    658678            this._pauseReasonTextRow.text = WebInspector.UIString("Assertion Failed");
     
    732752    }
    733753};
    734 
    735 WebInspector.DebuggerSidebarPanel.prototype.__proto__ = WebInspector.NavigationSidebarPanel.prototype;
  • trunk/Source/WebInspectorUI/UserInterface/Views/GeneralTreeElement.js

    r180486 r181184  
    6262    },
    6363
    64     get disclosureButton()
    65     {
    66         this._createElementsIfNeeded();
    67         return this._disclosureButton;
    68     },
    69 
    7064    get iconElement()
    7165    {
  • trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js

    r178544 r181184  
    193193
    194194    this.removeChildAtIndex(childIndex, suppressOnDeselect, suppressSelectSibling);
     195
     196    if (!this.children.length) {
     197        this._listItemNode.classList.remove("parent");
     198        this.hasChildren = false;
     199    }
    195200};
    196201
Note: See TracChangeset for help on using the changeset viewer.