Changeset 182933 in webkit


Ignore:
Timestamp:
Apr 16, 2015, 6:00:21 PM (10 years ago)
Author:
Joseph Pecoraro
Message:

Web Inspector: Should include "Log Value" context menu item in Preview and Collapsed ObjectTree
https://bugs.webkit.org/show_bug.cgi?id=143845

Reviewed by Timothy Hatcher.

Give previews the same "Log Value" context menu so that if you just log
a bunch of objects to the console you can quickly turn that entire object
into a $n reference in the console to interact with.

  • UserInterface/Views/ObjectPreviewView.js:

(WebInspector.ObjectPreviewView.prototype.setOriginatingObjectInfo):
(WebInspector.ObjectPreviewView.prototype._contextMenuHandler):
Provide API to refer to a RemoteObject and optional PropertyPath
that can be used to give the preview a "Log Value" context menu.

  • UserInterface/Views/ConsoleMessageView.js:

(WebInspector.ConsoleMessageView.prototype._appendFormattedArguments):
Include the RemoteObject without a path for a preview context menu.

  • UserInterface/Views/ObjectTreeView.js:

(WebInspector.ObjectTreeView):
Include the RemoteObject with a path if we knew it for a preview context menu.

  • UserInterface/Views/ObjectTreeBaseTreeElement.js:

(WebInspector.ObjectTreeBaseTreeElement.prototype.createGetterElement):
The context menu can never be empty, since we always added at least one item above.

Location:
trunk/Source/WebInspectorUI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r182909 r182933  
     12015-04-16  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Should include "Log Value" context menu item in Preview and Collapsed ObjectTree
     4        https://bugs.webkit.org/show_bug.cgi?id=143845
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        Give previews the same "Log Value" context menu so that if you just log
     9        a bunch of objects to the console you can quickly turn that entire object
     10        into a $n reference in the console to interact with.
     11
     12        * UserInterface/Views/ObjectPreviewView.js:
     13        (WebInspector.ObjectPreviewView.prototype.setOriginatingObjectInfo):
     14        (WebInspector.ObjectPreviewView.prototype._contextMenuHandler):
     15        Provide API to refer to a RemoteObject and optional PropertyPath
     16        that can be used to give the preview a "Log Value" context menu.
     17
     18        * UserInterface/Views/ConsoleMessageView.js:
     19        (WebInspector.ConsoleMessageView.prototype._appendFormattedArguments):
     20        Include the RemoteObject without a path for a preview context menu.
     21
     22        * UserInterface/Views/ObjectTreeView.js:
     23        (WebInspector.ObjectTreeView):
     24        Include the RemoteObject with a path if we knew it for a preview context menu.
     25
     26        * UserInterface/Views/ObjectTreeBaseTreeElement.js:
     27        (WebInspector.ObjectTreeBaseTreeElement.prototype.createGetterElement):
     28        The context menu can never be empty, since we always added at least one item above.
     29
     30
    1312015-04-16  Joseph Pecoraro  <pecoraro@apple.com>
    232
  • trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js

    r182646 r182933  
    391391                var preview = WebInspector.FormattedValue.createObjectPreviewOrFormattedValueForRemoteObject(parameter, WebInspector.ObjectPreviewView.Mode.Brief);
    392392                var isPreviewView = preview instanceof WebInspector.ObjectPreviewView;
     393
     394                if (isPreviewView)
     395                    preview.setOriginatingObjectInfo(parameter, null);
     396
    393397                var previewElement = isPreviewView ? preview.element : preview;
    394398                previewContainer.appendChild(previewElement);
  • trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPreviewView.js

    r182055 r182933  
    9191    }
    9292
     93    setOriginatingObjectInfo(remoteObject, propertyPath)
     94    {
     95        console.assert(!this._remoteObject);
     96        console.assert(remoteObject instanceof WebInspector.RemoteObject);
     97        console.assert(!propertyPath || propertyPath instanceof WebInspector.PropertyPath);
     98
     99        this._remoteObject = remoteObject;
     100        this._propertyPath = propertyPath || null;
     101
     102        this.element.addEventListener("contextmenu", this._contextMenuHandler.bind(this));
     103    }
     104
    93105    // Private
    94106
     
    224236        return true;
    225237    }
     238
     239    _contextMenuHandler(event)
     240    {
     241        var contextMenu = new WebInspector.ContextMenu(event);
     242
     243        contextMenu.appendItem(WebInspector.UIString("Log Value"), function() {
     244            var remoteObject = this._remoteObject;
     245            var isImpossible = !this._propertyPath || this._propertyPath.isFullPathImpossible();
     246            var text = isImpossible ? WebInspector.UIString("Selected Value") : this._propertyPath.displayPath(WebInspector.PropertyPath.Type.Value);
     247
     248            if (!isImpossible)
     249                WebInspector.quickConsole.prompt.pushHistoryItem(text);
     250
     251            WebInspector.consoleLogViewController.appendImmediateExecutionWithResult(text, this._remoteObject);
     252        }.bind(this));
     253
     254        contextMenu.show();       
     255    }
    226256};
    227257
  • trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeBaseTreeElement.js

    r182909 r182933  
    205205        this._appendMenusItemsForObject(contextMenu, resolvedValue);
    206206
    207         if (!contextMenu.isEmpty())
    208             contextMenu.show();
     207        contextMenu.show();
    209208    }
    210209
  • trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js

    r182493 r182933  
    3333        console.assert(!propertyPath || propertyPath instanceof WebInspector.PropertyPath);
    3434
     35        var providedPropertyPath = propertyPath instanceof WebInspector.PropertyPath;
     36
    3537        this._object = object;
    3638        this._mode = mode || WebInspector.ObjectTreeView.defaultModeForObject(object);
     
    5355        if (this._object.preview) {
    5456            this._previewView = new WebInspector.ObjectPreviewView(this._object.preview);
     57            this._previewView.setOriginatingObjectInfo(this._object, providedPropertyPath ? propertyPath : null);
    5558            this._previewView.element.addEventListener("click", this._handlePreviewOrTitleElementClick.bind(this));
    5659            this._element.appendChild(this._previewView.element);
Note: See TracChangeset for help on using the changeset viewer.