Title: [193098] branches/safari-601-branch
Revision
193098
Author
[email protected]
Date
2015-12-03 10:46:38 -0800 (Thu, 03 Dec 2015)

Log Message

Merge r188407. rdar://problem/23221163

Modified Paths

Added Paths

Diff

Modified: branches/safari-601-branch/LayoutTests/ChangeLog (193097 => 193098)


--- branches/safari-601-branch/LayoutTests/ChangeLog	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/LayoutTests/ChangeLog	2015-12-03 18:46:38 UTC (rev 193098)
@@ -1,5 +1,19 @@
 2015-12-02  Timothy Hatcher  <[email protected]>
 
+        Merge r188407. rdar://problem/23221163
+
+    2015-08-13  Joseph Pecoraro  <[email protected]>
+
+            Web Inspector: Watch Expressions
+            https://bugs.webkit.org/show_bug.cgi?id=147904
+
+            Reviewed by Brian Burg.
+
+            * inspector/model/remote-object-fake-object-expected.txt: Added.
+            * inspector/model/remote-object-fake-object.html: Added.
+
+2015-12-02  Timothy Hatcher  <[email protected]>
+
         Merge r188403. rdar://problem/23221163
 
     2015-08-13  Joseph Pecoraro  <[email protected]>

Modified: branches/safari-601-branch/LayoutTests/inspector/dom/getOuterHTML.html (193097 => 193098)


--- branches/safari-601-branch/LayoutTests/inspector/dom/getOuterHTML.html	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/LayoutTests/inspector/dom/getOuterHTML.html	2015-12-03 18:46:38 UTC (rev 193098)
@@ -5,7 +5,7 @@
 <script>
 function test()
 {
-    let suite = InspectorTest.createAsyncSuite("DOM.getOuterHTML");
+    var suite = InspectorTest.createAsyncSuite("DOM.getOuterHTML");
 
     suite.addTestCase({
         name: "GetOuterHTML",
@@ -13,7 +13,7 @@
         test: (resolve, reject) => {
             WebInspector.domTreeManager.requestDocument(function(documentNode) {
                 WebInspector.domTreeManager.querySelector(documentNode.id, "#x", function(nodeId) {
-                    let domNode = WebInspector.domTreeManager.nodeForId(nodeId);
+                    var domNode = WebInspector.domTreeManager.nodeForId(nodeId);
                     InspectorTest.assert(domNode, "DOMNode exists");
                     domNode.getOuterHTML(function(error, outerHTML) {
                         InspectorTest.expectNoError(error);

Modified: branches/safari-601-branch/LayoutTests/inspector/dom/highlightSelector-iframe.html (193097 => 193098)


--- branches/safari-601-branch/LayoutTests/inspector/dom/highlightSelector-iframe.html	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/LayoutTests/inspector/dom/highlightSelector-iframe.html	2015-12-03 18:46:38 UTC (rev 193098)
@@ -5,4 +5,4 @@
         <div id="id-one"></div>
         <div></div>
     </body>
-</html>
\ No newline at end of file
+</html>

Modified: branches/safari-601-branch/LayoutTests/inspector/dom/highlightSelector.html (193097 => 193098)


--- branches/safari-601-branch/LayoutTests/inspector/dom/highlightSelector.html	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/LayoutTests/inspector/dom/highlightSelector.html	2015-12-03 18:46:38 UTC (rev 193098)
@@ -83,4 +83,4 @@
         <iframe class="class-one" src=""
     </div>
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: branches/safari-601-branch/LayoutTests/inspector/dom/setOuterHTML.html (193097 => 193098)


--- branches/safari-601-branch/LayoutTests/inspector/dom/setOuterHTML.html	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/LayoutTests/inspector/dom/setOuterHTML.html	2015-12-03 18:46:38 UTC (rev 193098)
@@ -5,8 +5,8 @@
 <script>
 function test()
 {
-    let domNode;
-    let suite = InspectorTest.createAsyncSuite("DOM.setOuterHTML");
+    var domNode;
+    var suite = InspectorTest.createAsyncSuite("DOM.setOuterHTML");
 
     suite.addTestCase({
         name: "OuterHTMLBefore",
@@ -38,14 +38,14 @@
     </div>
 </div>`.trim();
 
-    let steps = [
+    var steps = [
         ["RemovingElements", emptyOuterHTML],
         ["AddingElements", newOuterHTML],
         ["ModifyingElements", modifiedOuterHTML],
     ];
 
     steps.forEach(function(tuple) {
-        let [title, replacementOuterHTML] = tuple;
+        var [title, replacementOuterHTML] = tuple;
         suite.addTestCase({
             name: `SetOuterHTML${title}`,
             description: "Change the outerHTML.",

Added: branches/safari-601-branch/LayoutTests/inspector/model/remote-object-fake-object-expected.txt (0 => 193098)


--- branches/safari-601-branch/LayoutTests/inspector/model/remote-object-fake-object-expected.txt	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/inspector/model/remote-object-fake-object-expected.txt	2015-12-03 18:46:38 UTC (rev 193098)
@@ -0,0 +1,5 @@
+PASS: A fake remote object should have object type.
+PASS: Each fake remote object instance should be unique.
+PASS: A fake remote object should have an empty list of own properties.
+PASS: A fake remote object should have an empty list of displayable properties.
+

Added: branches/safari-601-branch/LayoutTests/inspector/model/remote-object-fake-object.html (0 => 193098)


--- branches/safari-601-branch/LayoutTests/inspector/model/remote-object-fake-object.html	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/inspector/model/remote-object-fake-object.html	2015-12-03 18:46:38 UTC (rev 193098)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+    var fakeObject = WebInspector.RemoteObject.createFakeRemoteObject();
+
+    InspectorTest.assert(fakeObject instanceof WebInspector.RemoteObject);
+    InspectorTest.assert(fakeObject.objectId === WebInspector.RemoteObject.FakeRemoteObjectId);
+    InspectorTest.expectThat(fakeObject.type === "object" && !fakeObject.subtype, "A fake remote object should have object type.");
+    InspectorTest.expectThat(fakeObject !== WebInspector.RemoteObject.createFakeRemoteObject(), "Each fake remote object instance should be unique.");
+
+    fakeObject.getOwnPropertyDescriptors(function(properties) {
+        InspectorTest.expectThat(Array.isArray(properties) && !properties.length, "A fake remote object should have an empty list of own properties.");
+    });
+
+    fakeObject.getDisplayablePropertyDescriptors(function(properties) {
+        InspectorTest.expectThat(Array.isArray(properties) && !properties.length, "A fake remote object should have an empty list of displayable properties.");
+        InspectorTest.completeTest();
+    });
+}
+</script>
+</head>
+<body _onload_="runTest()">
+</body>
+</html>

Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193097 => 193098)


--- branches/safari-601-branch/Source/WebInspectorUI/ChangeLog	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/Source/WebInspectorUI/ChangeLog	2015-12-03 18:46:38 UTC (rev 193098)
@@ -1,5 +1,113 @@
 2015-12-02  Timothy Hatcher  <[email protected]>
 
+        Merge r188407. rdar://problem/23221163
+
+    2015-08-13  Joseph Pecoraro  <[email protected]>
+
+            Web Inspector: Watch Expressions
+            https://bugs.webkit.org/show_bug.cgi?id=147904
+
+            Reviewed by Brian Burg.
+
+            * UserInterface/Protocol/RemoteObject.js:
+            (WebInspector.RemoteObject):
+            A RemoteObject's description string is optional, but we always
+            assume it exists and is a string, so default to the empty string.
+
+            * UserInterface/Controllers/RuntimeManager.js:
+            (WebInspector.RuntimeManager.prototype.evaluateInInspectedWindow.evalCallback):
+            Include the object group in the DidEvaluate event.
+
+            (WebInspector.RemoteObject.fakeRemoteObject):
+            (WebInspector.RemoteObject.prototype.getDisplayablePropertyDescriptors):
+            (WebInspector.RemoteObject.prototype.deprecatedGetDisplayableProperties.get return):
+            (WebInspector.RemoteObject.prototype.deprecatedGetDisplayableProperties):
+            (WebInspector.RemoteObject.prototype._isFakeObject):
+            (WebInspector.RemoteObject.prototype._getPropertyDescriptors):
+            (WebInspector.RemoteObject.prototype._deprecatedGetProperties):
+            Support a fake RemoteObject. We use this fake RemoteObject to
+            back a ObjectTreeView where we add custom Properties which are of the form
+            "Expressions => RemoteObject" instead of "Object Property => RemoteObject".
+            Ensure a fake remote object is not used in unexpected ways.
+
+            * UserInterface/Views/Popover.js:
+            (WebInspector.Popover.prototype.update):
+            Default a popover update to animate, but allow not animating.
+
+            (WebInspector.Popover.prototype.handleEvent):
+            Vend a class that other content can use so that the Popover won't
+            dismiss if content with that class is scrolled. For example, a
+            completions list may be showing over a popover, if that scrolls
+            it should not dismiss the popover.
+
+            * UserInterface/Views/CompletionSuggestionsView.js:
+            (WebInspector.CompletionSuggestionsView):
+            Adopt the Popover ignore class so a popover won't dismiss if the
+            completion suggestions view is scrolled.
+
+            * UserInterface/Views/ObjectTreeBaseTreeElement.js:
+            (WebInspector.ObjectTreeBaseTreeElement.prototype.createGetterElement.get return):
+            (WebInspector.ObjectTreeBaseTreeElement.prototype.createGetterElement):
+            Allow modifying the context menu on an ObjectTreeView by looking for a delegate
+            on the TreeOutline.
+
+            * UserInterface/Views/ScopeChainDetailsSidebarPanel.css: Added.
+            (.details-section.watch-expressions .options > *):
+            (.details-section.watch-expressions .options > *:active):
+            (.details-section.watch-expressions .options > .watch-_expression_-add):
+            (.details-section.watch-expressions .options > .watch-_expression_-clear):
+            (.details-section.watch-expressions .options > .watch-_expression_-refresh):
+            (.popover .watch-_expression_):
+            (.watch-_expression_-editor):
+            (.watch-_expression_-editor > .CodeMirror):
+            (.watch-_expression_-editor > .CodeMirror-scroll):
+            Styles for the new Watch Expressions section, buttons, popover, and editor.
+
+            * UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
+            (WebInspector.ScopeChainDetailsSidebarPanel):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype.inspect):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype.refresh):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._generateWatchExpressionsSection):
+            Because we update the UI after a delay, to allow ObjectTreeView's to asynchronously
+            expand and fetch their list of properties, we convert updating the watch _expression_
+            and call frame sections asynchronously and return a promise. This lets us visually
+            update the UI after both sections have updated.
+
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._addWatchExpression):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._removeWatchExpression):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._clearAllWatchExpressions):
+            Modify the saved list of watch expressions.
+
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._addWatchExpressionButtonClicked.presentPopoverOverTargetElement):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._addWatchExpressionButtonClicked.this._codeMirror.addKeyMap):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._addWatchExpressionButtonClicked):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype.willDismissPopover):
+            Handle presenting and dismissing the add watch _expression_ popover.
+
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._refreshAllWatchExpressionsButtonClicked):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._clearAllWatchExpressionsButtonClicked):
+            Other button handlers.
+
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._mainResourceDidChange):
+            Refresh the sidebar on navigation, as the watch expressions may change value (`location.href`).
+
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._objectTreeElementAddContextMenuItems):
+            Add our own context menu items to watch _expression_ ObjectTreeView tree elements to
+            allow removing a watch _expression_.
+
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._propertyPathIdentifierForTreeElement):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._objectTreeAddHandler):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._objectTreeExpandHandler):
+            (WebInspector.ScopeChainDetailsSidebarPanel.prototype._objectTreeCollapseHandler):
+            Convert code to use `let`.
+
+            * Localizations/en.lproj/localizedStrings.js:
+            * UserInterface/Main.html:
+            Misc. changes.
+
+2015-12-02  Timothy Hatcher  <[email protected]>
+
         Merge r188403. rdar://problem/23221163
 
     2015-08-13  Joseph Pecoraro  <[email protected]>

Modified: branches/safari-601-branch/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (193097 => 193098)


--- branches/safari-601-branch/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2015-12-03 18:46:38 UTC (rev 193098)
@@ -45,6 +45,8 @@
 localizedStrings["Add Breakpoint"] = "Add Breakpoint";
 localizedStrings["Add New"] = "Add New";
 localizedStrings["Add New Probe _expression_"] = "Add New Probe _expression_";
+localizedStrings["Add New Watch _expression_"] = "Add New Watch _expression_";
+localizedStrings["Add Watch _expression_"] = "Add Watch _expression_";
 localizedStrings["Add new breakpoint action after this action"] = "Add new breakpoint action after this action";
 localizedStrings["Additions"] = "Additions";
 localizedStrings["All"] = "All";
@@ -91,6 +93,7 @@
 localizedStrings["Checked"] = "Checked";
 localizedStrings["Child Layers"] = "Child Layers";
 localizedStrings["Children"] = "Children";
+localizedStrings["Clear All Watch Expressions"] = "Clear All Watch Expressions";
 localizedStrings["Clear Log"] = "Clear Log";
 localizedStrings["Clear Log on Navigation"] = "Clear Log on Navigation";
 localizedStrings["Clear Timeline"] = "Clear Timeline";
@@ -359,6 +362,7 @@
 localizedStrings["No Results Found"] = "No Results Found";
 localizedStrings["No Search Results"] = "No Search Results";
 localizedStrings["No Units"] = "No Units";
+localizedStrings["No Watch Expressions"] = "No Watch Expressions";
 localizedStrings["No exact ARIA role match."] = "No exact ARIA role match.";
 localizedStrings["No message"] = "No message";
 localizedStrings["No properties."] = "No properties.";
@@ -408,10 +412,12 @@
 localizedStrings["Reference Issue"] = "Reference Issue";
 localizedStrings["Reflection"] = "Reflection";
 localizedStrings["Refresh"] = "Refresh";
+localizedStrings["Refresh All Watch Expressions"] = "Refresh All Watch Expressions";
 localizedStrings["Region Flow"] = "Region Flow";
 localizedStrings["Region announced in its entirety."] = "Region announced in its entirety.";
 localizedStrings["Reload page (%s)\nReload ignoring cache (%s)"] = "Reload page (%s)\nReload ignoring cache (%s)";
 localizedStrings["Removals"] = "Removals";
+localizedStrings["Remove Watch _expression_"] = "Remove Watch _expression_";
 localizedStrings["Remove this breakpoint action"] = "Remove this breakpoint action";
 localizedStrings["Rendering Frames"] = "Rendering Frames";
 localizedStrings["Repeating Linear Gradient"] = "Repeating Linear Gradient";
@@ -540,6 +546,7 @@
 localizedStrings["Value"] = "Value";
 localizedStrings["Warning: "] = "Warning: ";
 localizedStrings["Warnings"] = "Warnings";
+localizedStrings["Watch Expressions"] = "Watch Expressions";
 localizedStrings["Web Inspector"] = "Web Inspector";
 localizedStrings["Width"] = "Width";
 localizedStrings["With Object Properties"] = "With Object Properties";

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js (193097 => 193098)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js	2015-12-03 18:46:38 UTC (rev 193098)
@@ -47,7 +47,7 @@
 
         function evalCallback(error, result, wasThrown, savedResultIndex)
         {
-            this.dispatchEventToListeners(WebInspector.RuntimeManager.Event.DidEvaluate);
+            this.dispatchEventToListeners(WebInspector.RuntimeManager.Event.DidEvaluate, {objectGroup});
 
             if (error) {
                 console.error(error);

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Main.html (193097 => 193098)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Main.html	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Main.html	2015-12-03 18:46:38 UTC (rev 193098)
@@ -128,6 +128,7 @@
     <link rel="stylesheet" href=""
     <link rel="stylesheet" href=""
     <link rel="stylesheet" href=""
+    <link rel="stylesheet" href=""
     <link rel="stylesheet" href=""
     <link rel="stylesheet" href=""
     <link rel="stylesheet" href=""

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js (193097 => 193098)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js	2015-12-03 18:46:38 UTC (rev 193098)
@@ -46,7 +46,7 @@
             console.assert(!value);
 
             this._objectId = objectId;
-            this._description = description;
+            this._description = description || "";
             this._hasChildren = type !== "symbol";
             this._size = size;
             this._classPrototype = classPrototype;
@@ -69,6 +69,11 @@
 
     // Static
 
+    static createFakeRemoteObject()
+    {
+        return new WebInspector.RemoteObject(WebInspector.RemoteObject.FakeRemoteObjectId, "object");
+    }
+
     static fromPrimitiveValue(value)
     {
         return new WebInspector.RemoteObject(undefined, typeof value, undefined, value, undefined, undefined, undefined, undefined);
@@ -219,7 +224,7 @@
 
     getDisplayablePropertyDescriptors(callback)
     {
-        if (!this._objectId || this._isSymbol()) {
+        if (!this._objectId || this._isSymbol() || this._isFakeObject()) {
             callback([]);
             return;
         }
@@ -266,7 +271,7 @@
 
     deprecatedGetDisplayableProperties(callback)
     {
-        if (!this._objectId || this._isSymbol()) {
+        if (!this._objectId || this._isSymbol() || this._isFakeObject()) {
             callback([]);
             return;
         }
@@ -301,7 +306,7 @@
 
     setPropertyValue(name, value, callback)
     {
-        if (!this._objectId || this._isSymbol()) {
+        if (!this._objectId || this._isSymbol() || this._isFakeObject()) {
             callback("Can't set a property of non-object.");
             return;
         }
@@ -457,7 +462,7 @@
 
     release()
     {
-        if (this._objectId)
+        if (this._objectId && !this._isFakeObject())
             RuntimeAgent.releaseObject(this._objectId);
     }
 
@@ -510,6 +515,11 @@
 
     // Private
 
+    _isFakeObject()
+    {
+        return this._objectId === WebInspector.RemoteObject.FakeRemoteObjectId;
+    }
+
     _isSymbol()
     {
         return this._type === "symbol";
@@ -527,7 +537,7 @@
 
     _getPropertyDescriptors(ownProperties, callback)
     {
-        if (!this._objectId || this._isSymbol()) {
+        if (!this._objectId || this._isSymbol() || this._isFakeObject()) {
             callback([]);
             return;
         }
@@ -571,7 +581,7 @@
     // FIXME: Phase out these deprecated functions. They return DeprecatedRemoteObjectProperty instead of PropertyDescriptors.
     _deprecatedGetProperties(ownProperties, callback)
     {
-        if (!this._objectId || this._isSymbol()) {
+        if (!this._objectId || this._isSymbol() || this._isFakeObject()) {
             callback([]);
             return;
         }
@@ -612,6 +622,8 @@
     }
 };
 
+WebInspector.RemoteObject.FakeRemoteObjectId = "fake-remote-object";
+
 WebInspector.RemoteObject.SourceCodeLocationPromise = {
     NoSourceFound: "remote-object-source-code-location-promise-no-source-found",
     MissingObjectId: "remote-object-source-code-location-promise-missing-object-id"

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js (193097 => 193098)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js	2015-12-03 18:46:38 UTC (rev 193098)
@@ -34,10 +34,10 @@
         this._selectedIndex = NaN;
 
         this._element = document.createElement("div");
-        this._element.className = "completion-suggestions";
+        this._element.classList.add("completion-suggestions", WebInspector.Popover.IgnoreAutoDismissClassName);
 
         this._containerElement = document.createElement("div");
-        this._containerElement.className = "completion-suggestions-container";
+        this._containerElement.classList.add("completion-suggestions-container");
         this._containerElement.addEventListener("mousedown", this._mouseDown.bind(this));
         this._containerElement.addEventListener("mouseup", this._mouseUp.bind(this));
         this._containerElement.addEventListener("click", this._itemClicked.bind(this));

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ObjectTreeBaseTreeElement.js (193097 => 193098)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ObjectTreeBaseTreeElement.js	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ObjectTreeBaseTreeElement.js	2015-12-03 18:46:38 UTC (rev 193098)
@@ -182,12 +182,21 @@
 
     _contextMenuHandler(event)
     {
+        var contextMenu = new WebInspector.ContextMenu(event);
+
+        if (typeof this.treeOutline.objectTreeElementAddContextMenuItems === "function") {
+            this.treeOutline.objectTreeElementAddContextMenuItems(this, contextMenu);
+            if (!contextMenu.isEmpty())
+                contextMenu.appendSeparator();
+        }             
+
         var resolvedValue = this.resolvedValue();
-        if (!resolvedValue)
+        if (!resolvedValue) {
+            if (!contextMenu.isEmpty())
+                contextMenu.show();
             return;
+        }
 
-        var contextMenu = new WebInspector.ContextMenu(event);
-
         if (this._property && this._property.symbol)
             contextMenu.appendItem(WebInspector.UIString("Log Symbol"), this._logSymbolProperty.bind(this));
 

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/Popover.js (193097 => 193098)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/Popover.js	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/Popover.js	2015-12-03 18:46:38 UTC (rev 193098)
@@ -89,7 +89,7 @@
             this._update(true);
     }
 
-    update()
+    update(shouldAnimate = true)
     {
         if (!this.visible)
             return;
@@ -97,7 +97,7 @@
         var previouslyFocusedElement = document.activeElement;
 
         this._contentNeedsUpdate = true;
-        this._update(true);
+        this._update(shouldAnimate);
 
         if (previouslyFocusedElement)
             previouslyFocusedElement.focus();
@@ -151,7 +151,7 @@
         switch (event.type) {
         case "mousedown":
         case "scroll":
-            if (!this._element.contains(event.target))
+            if (!this._element.contains(event.target) && !event.target.enclosingNodeOrSelfWithClass(WebInspector.Popover.IgnoreAutoDismissClassName))
                 this.dismiss();
             break;
         case "transitionend":
@@ -555,3 +555,4 @@
 WebInspector.Popover.ContentPadding = 5;
 WebInspector.Popover.AnchorSize = new WebInspector.Size(22, 11);
 WebInspector.Popover.ShadowEdgeInsets = new WebInspector.EdgeInsets(WebInspector.Popover.ShadowPadding);
+WebInspector.Popover.IgnoreAutoDismissClassName = "popover-ignore-auto-dismiss";

Added: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.css (0 => 193098)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.css	                        (rev 0)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.css	2015-12-03 18:46:38 UTC (rev 193098)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+.details-section.watch-expressions .options > * {
+    float: right;
+    margin-top: 1px;
+    margin-left: 5px;
+    height: 13px;
+}
+
+.details-section.watch-expressions .options > *:active {
+    opacity: 0.7;
+}
+
+.details-section.watch-expressions .options > .watch-_expression_-add {
+    content: url(../Images/Plus.svg);
+}
+
+.details-section.watch-expressions .options > .watch-_expression_-clear {
+    content: url(../Images/NavigationItemTrash.svg);
+}
+
+.details-section.watch-expressions .options > .watch-_expression_-refresh {
+    content: url(../Images/ReloadFull.svg);
+}
+
+.popover .watch-_expression_ {
+    padding: 5px;
+    margin: 2px;
+}
+
+.watch-_expression_-editor {
+    width: 200px;
+    margin-top: 5px;
+    padding: 4px 0 2px 0;
+    -webkit-appearance: textfield;
+    border: 1px solid hsl(0, 0%, 78%);
+    background: white;
+}
+
+.watch-_expression_-editor > .CodeMirror {
+    width: calc(100% - 2px);
+    height: auto;
+}
+
+.watch-_expression_-editor > .CodeMirror-scroll {
+    width: calc(100% - 2px);
+    overflow: hidden;
+}

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js (193097 => 193098)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js	2015-12-03 18:46:26 UTC (rev 193097)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js	2015-12-03 18:46:38 UTC (rev 193098)
@@ -31,8 +31,40 @@
 
         this._callFrame = null;
 
+        this._watchExpressionsSetting = new WebInspector.Setting("watch-expressions", []);
+
+        this._watchExpressionOptionsElement = document.createElement("div");
+        this._watchExpressionOptionsElement.classList.add("options");
+
+        var refreshAllWatchExpressionButton = this._watchExpressionOptionsElement.appendChild(document.createElement("img"));
+        refreshAllWatchExpressionButton.classList.add("watch-_expression_-refresh");
+        refreshAllWatchExpressionButton.setAttribute("role", "button");
+        refreshAllWatchExpressionButton.title = WebInspector.UIString("Refresh All Watch Expressions");
+        refreshAllWatchExpressionButton.addEventListener("click", this._refreshAllWatchExpressionsButtonClicked.bind(this));
+
+        var clearAllWatchExpressionButton = this._watchExpressionOptionsElement.appendChild(document.createElement("img"));
+        clearAllWatchExpressionButton.classList.add("watch-_expression_-clear");
+        clearAllWatchExpressionButton.setAttribute("role", "button");
+        clearAllWatchExpressionButton.title = WebInspector.UIString("Clear All Watch Expressions");
+        clearAllWatchExpressionButton.addEventListener("click", this._clearAllWatchExpressionsButtonClicked.bind(this));
+
+        var addWatchExpressionButton = this._watchExpressionOptionsElement.appendChild(document.createElement("img"));
+        addWatchExpressionButton.classList.add("watch-_expression_-add");
+        addWatchExpressionButton.title = WebInspector.UIString("Add Watch _expression_");
+        addWatchExpressionButton.setAttribute("role", "button");
+        addWatchExpressionButton.addEventListener("click", this._addWatchExpressionButtonClicked.bind(this));
+
+        this._watchExpressionsSectionGroup = new WebInspector.DetailsSectionGroup;
+        this._watchExpressionsSection = new WebInspector.DetailsSection("watch-expressions", WebInspector.UIString("Watch Expressions"), [this._watchExpressionsSectionGroup], this._watchExpressionOptionsElement);
+        this.contentElement.appendChild(this._watchExpressionsSection.element);
+
+        this.needsRefresh();
+
         // Update on console prompt eval as objects in the scope chain may have changed.
-        WebInspector.runtimeManager.addEventListener(WebInspector.RuntimeManager.Event.DidEvaluate, this.needsRefresh, this);
+        WebInspector.runtimeManager.addEventListener(WebInspector.RuntimeManager.Event.DidEvaluate, this._didEvaluateExpression, this);
+
+        // Update watch expressions on navigations.
+        WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
     }
 
     // Public
@@ -55,7 +87,7 @@
 
         this.callFrame = callFrameToInspect;
 
-        return !!this.callFrame;
+        return true;
     }
 
     get callFrame()
@@ -75,9 +107,55 @@
 
     refresh()
     {
-        var callFrame = this.callFrame;
+        var callFrame = this._callFrame;
+
+        Promise.all([this._generateWatchExpressionsSection(), this._generateCallFramesSection()]).then(function(sections) {
+            var [watchExpressionsSection, callFrameSections] = sections;
+
+            function delayedWork()
+            {
+                // Clear the timeout so we don't update the interface twice.
+                clearTimeout(timeout);
+
+                if (watchExpressionsSection)
+                    this._watchExpressionsSectionGroup.rows = [watchExpressionsSection];
+                else {
+                    var emptyRow = new WebInspector.DetailsSectionRow(WebInspector.UIString("No Watch Expressions"));
+                    this._watchExpressionsSectionGroup.rows = [emptyRow];
+                    emptyRow.showEmptyMessage();
+                }
+
+                this.contentElement.removeChildren();
+                this.contentElement.appendChild(this._watchExpressionsSection.element);
+
+                // Bail if the call frame changed while we were waiting for the async response.
+                if (this._callFrame !== callFrame)
+                    return;
+
+                if (!callFrameSections)
+                    return;
+
+                for (let callFrameSection of callFrameSections)
+                    this.contentElement.appendChild(callFrameSection.element);
+            }
+
+            // We need a timeout in place in case there are long running, pending backend dispatches. This can happen
+            // if the debugger is paused in code that was executed from the console. The console will be waiting for
+            // the result of the execution and without a timeout we would never update the scope variables.
+            var delay = WebInspector.ScopeChainDetailsSidebarPanel._autoExpandProperties.size === 0 ? 50 : 250;
+            var timeout = setTimeout(delayedWork.bind(this), delay);
+
+            // Since ObjectTreeView populates asynchronously, we want to wait to replace the existing content
+            // until after all the pending asynchronous requests are completed. This prevents severe flashing while stepping.
+            InspectorBackend.runAfterPendingDispatches(delayedWork.bind(this));
+        }.bind(this)).catch(function(e) { console.error(e); });
+    }
+
+    _generateCallFramesSection()
+    {
+        var callFrame = this._callFrame;
         if (!callFrame)
-            return;
+            return Promise.resolve(null);
 
         var detailsSections = [];
         var foundLocalScope = false;
@@ -87,9 +165,7 @@
             sectionCountByType[WebInspector.ScopeChainNode.Type[type]] = 0;
 
         var scopeChain = callFrame.scopeChain;
-        for (var i = 0; i < scopeChain.length; ++i) {
-            var scope = scopeChain[i];
-
+        for (let scope of scopeChain) {
             var title = null;
             var extraPropertyDescriptor = null;
             var collapsedByDefault = false;
@@ -153,31 +229,186 @@
             detailsSections.push(detailsSection);
         }
 
-        function delayedWork()
+        return Promise.resolve(detailsSections);
+    }
+
+    _generateWatchExpressionsSection()
+    {
+        var watchExpressions = this._watchExpressionsSetting.value;
+        if (!watchExpressions.length) {
+            if (this._usedWatchExpressionsObjectGroup) {
+                this._usedWatchExpressionsObjectGroup = false;
+                RuntimeAgent.releaseObjectGroup(WebInspector.ScopeChainDetailsSidebarPanel.WatchExpressionsObjectGroupName);
+            }
+            return Promise.resolve(null);
+        }
+
+        RuntimeAgent.releaseObjectGroup(WebInspector.ScopeChainDetailsSidebarPanel.WatchExpressionsObjectGroupName);
+        this._usedWatchExpressionsObjectGroup = true;
+
+        var watchExpressionsRemoteObject = WebInspector.RemoteObject.createFakeRemoteObject();
+        var fakePropertyPath = WebInspector.PropertyPath.emptyPropertyPathForScope(watchExpressionsRemoteObject);
+        var objectTree = new WebInspector.ObjectTreeView(watchExpressionsRemoteObject, WebInspector.ObjectTreeView.Mode.Properties, fakePropertyPath);
+        objectTree.showOnlyProperties();
+
+        var treeOutline = objectTree.treeOutline;
+        const watchExpressionSectionIdentifier = "watch-expressions";
+        treeOutline._onadd_ = this._objectTreeAddHandler.bind(this, watchExpressionSectionIdentifier);
+        treeOutline._onexpand_ = this._objectTreeExpandHandler.bind(this, watchExpressionSectionIdentifier);
+        treeOutline._oncollapse_ = this._objectTreeCollapseHandler.bind(this, watchExpressionSectionIdentifier);
+        treeOutline.objectTreeElementAddContextMenuItems = this._objectTreeElementAddContextMenuItems.bind(this);
+
+        var promises = [];
+        for (let _expression_ of watchExpressions) {
+            promises.push(new Promise(function(resolve, reject) {
+                WebInspector.runtimeManager.evaluateInInspectedWindow(_expression_, WebInspector.ScopeChainDetailsSidebarPanel.WatchExpressionsObjectGroupName, false, true, false, true, false, function(object, wasThrown) {
+                    var propertyDescriptor = new WebInspector.PropertyDescriptor({name: _expression_, value: object}, undefined, undefined, wasThrown);
+                    objectTree.appendExtraPropertyDescriptor(propertyDescriptor);
+                    resolve(propertyDescriptor);
+                });
+            }));
+        }
+
+        return Promise.all(promises).then(function() {
+            return Promise.resolve(new WebInspector.DetailsSectionPropertiesRow(objectTree));
+        });
+    }
+
+    _addWatchExpression(_expression_)
+    {
+        var watchExpressions = this._watchExpressionsSetting.value.slice(0);
+        watchExpressions.push(_expression_);
+        this._watchExpressionsSetting.value = watchExpressions;
+
+        this.needsRefresh();
+    }
+
+    _removeWatchExpression(_expression_)
+    {
+        var watchExpressions = this._watchExpressionsSetting.value.slice(0);
+        watchExpressions.remove(_expression_, true);
+        this._watchExpressionsSetting.value = watchExpressions;
+
+        this.needsRefresh();
+    }
+
+    _clearAllWatchExpressions()
+    {
+        this._watchExpressionsSetting.value = [];
+
+        this.needsRefresh();
+    }
+
+    _addWatchExpressionButtonClicked(event)
+    {
+        function presentPopoverOverTargetElement()
         {
-            // Clear the timeout so we don't update the interface twice.
-            clearTimeout(timeout);
+            var target = WebInspector.Rect.rectFromClientRect(event.target.getBoundingClientRect());
+            popover.present(target, [WebInspector.RectEdge.MAX_Y, WebInspector.RectEdge.MIN_Y, WebInspector.RectEdge.MAX_X]);
+        }
 
-            // Bail if the call frame changed while we were waiting for the async response.
-            if (this.callFrame !== callFrame)
-                return;
+        var popover = new WebInspector.Popover(this);
+        var content = document.createElement("div");
+        content.classList.add("watch-_expression_");
+        content.appendChild(document.createElement("div")).textContent = WebInspector.UIString("Add New Watch _expression_");
 
-            this.contentElement.removeChildren();
-            for (var i = 0; i < detailsSections.length; ++i)
-                this.contentElement.appendChild(detailsSections[i].element);
+        var editorElement = content.appendChild(document.createElement("div"));
+        editorElement.classList.add("watch-_expression_-editor", WebInspector.SyntaxHighlightedStyleClassName);
+
+        this._codeMirror = CodeMirror(editorElement, {
+            lineWrapping: true,
+            mode: "text/_javascript_",
+            indentWithTabs: true,
+            indentUnit: 4,
+            matchBrackets: true,
+            value: "",
+        });
+
+        this._popoverCommitted = false;
+
+        this._codeMirror.addKeyMap({
+            "Enter": function() { this._popoverCommitted = true; popover.dismiss(); }.bind(this),
+        });
+
+        var completionController = new WebInspector.CodeMirrorCompletionController(this._codeMirror);
+        completionController.addExtendedCompletionProvider("_javascript_", WebInspector._javascript_RuntimeCompletionProvider);
+
+        // Resize the popover as best we can when the CodeMirror editor changes size.
+        var previousHeight = 0;
+        this._codeMirror.on("changes", function(cm, event) {
+            var height = cm.getScrollInfo().height;
+            if (previousHeight !== height) {
+                previousHeight = height;
+                popover.update(false);
+            }
+        });
+
+        // Reposition the popover when the window resizes.
+        this._windowResizeListener = presentPopoverOverTargetElement;
+        window.addEventListener("resize", this._windowResizeListener);
+
+        popover.content = content;
+        presentPopoverOverTargetElement();
+
+        // CodeMirror needs a refresh after the popover displays, to layout, otherwise it doesn't appear.
+        setTimeout(function() {
+            this._codeMirror.refresh();
+            this._codeMirror.focus();
+            popover.update();
+        }.bind(this), 0);
+    }
+
+    willDismissPopover(popover)
+    {
+        if (this._popoverCommitted) {
+            var _expression_ = this._codeMirror.getValue().trim();
+            if (_expression_)
+                this._addWatchExpression(_expression_);
         }
 
-        // We need a timeout in place in case there are long running, pending backend dispatches. This can happen
-        // if the debugger is paused in code that was executed from the console. The console will be waiting for
-        // the result of the execution and without a timeout we would never update the scope variables.
-        var delay = WebInspector.ScopeChainDetailsSidebarPanel._autoExpandProperties.size === 0 ? 50 : 250;
-        var timeout = setTimeout(delayedWork.bind(this), delay);
+        window.removeEventListener("resize", this._windowResizeListener);
+        this._windowResizeListener = null;
+        this._codeMirror = null;
+    }
 
-        // Since ObjectTreeView populates asynchronously, we want to wait to replace the existing content
-        // until after all the pending asynchronous requests are completed. This prevents severe flashing while stepping.
-        InspectorBackend.runAfterPendingDispatches(delayedWork.bind(this));
+    _refreshAllWatchExpressionsButtonClicked(event)
+    {
+        this.needsRefresh();
     }
 
+    _clearAllWatchExpressionsButtonClicked(event)
+    {
+        this._clearAllWatchExpressions();
+    }
+
+    _didEvaluateExpression(event)
+    {
+        if (event.data.objectGroup === WebInspector.ScopeChainDetailsSidebarPanel.WatchExpressionsObjectGroupName)
+            return;
+
+        this.needsRefresh();
+    }
+
+    _mainResourceDidChange(event)
+    {
+        if (!event.target.isMainFrame())
+            return;
+
+        this.needsRefresh();
+    }
+
+    _objectTreeElementAddContextMenuItems(objectTreeElement, contextMenu)
+    {
+        // Only add our watch _expression_ context menus to the top level ObjectTree elements.
+        if (objectTreeElement.parent !== objectTreeElement.treeOutline)
+            return;
+
+        contextMenu.appendItem(WebInspector.UIString("Remove Watch _expression_"), function() {
+            var _expression_ = objectTreeElement.property.name;
+            this._removeWatchExpression(_expression_);
+        }.bind(this));
+    }
+
     _propertyPathIdentifierForTreeElement(identifier, objectPropertyTreeElement)
     {
         if (!objectPropertyTreeElement.property)
@@ -220,3 +451,4 @@
 };
 
 WebInspector.ScopeChainDetailsSidebarPanel._autoExpandProperties = new Set;
+WebInspector.ScopeChainDetailsSidebarPanel.WatchExpressionsObjectGroupName = "watch-expressions";
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to