Title: [183025] trunk
Revision
183025
Author
commit-qu...@webkit.org
Date
2015-04-20 13:25:56 -0700 (Mon, 20 Apr 2015)

Log Message

Web Inspector: Improve Support for WeakSet in Console
https://bugs.webkit.org/show_bug.cgi?id=143951

Patch by Joseph Pecoraro <pecor...@apple.com> on 2015-04-20
Reviewed by Darin Adler.

Source/_javascript_Core:

* inspector/InjectedScriptSource.js:
* inspector/JSInjectedScriptHost.cpp:
(Inspector::JSInjectedScriptHost::subtype):
(Inspector::JSInjectedScriptHost::weakSetSize):
(Inspector::JSInjectedScriptHost::weakSetEntries):
* inspector/JSInjectedScriptHost.h:
* inspector/JSInjectedScriptHostPrototype.cpp:
(Inspector::JSInjectedScriptHostPrototype::finishCreation):
(Inspector::jsInjectedScriptHostPrototypeFunctionWeakSetSize):
(Inspector::jsInjectedScriptHostPrototypeFunctionWeakSetEntries):
Treat WeakSets like special sets.

* inspector/protocol/Runtime.json:
Add a new object subtype, "weakset".

Source/WebInspectorUI:

* UserInterface/Models/NativeFunctionParameters.js:
WeakSet has the same APIs and parameters as Set for the functions it implements.

* UserInterface/Protocol/RemoteObject.js:
(WebInspector.RemoteObject.prototype.isCollectionType):
(WebInspector.RemoteObject.prototype.isWeakCollection):
(WebInspector.RemoteObject.prototype.getCollectionEntries):
(WebInspector.RemoteObject.prototype._weakCollectionObjectGroup):
WeakSet is a weak collection.

* UserInterface/Models/ObjectPreview.js:
(WebInspector.ObjectPreview.prototype.hasSize):
* UserInterface/Views/ConsoleMessageView.js:
(WebInspector.ConsoleMessageView.prototype._formatParameter):
* UserInterface/Views/FormattedValue.css:
(.formatted-object, .formatted-node, .formatted-error, .formatted-map, .formatted-set, .formatted-weakmap, .formatted-weakset):
(:matches(.formatted-array, .formatted-map, .formatted-set, .formatted-weakmap, .formatted-weakset) > .size):
(.formatted-object, .formatted-node, .formatted-error, .formatted-map, .formatted-set, .formatted-weakmap): Deleted.
(:matches(.formatted-array, .formatted-map, .formatted-set, .formatted-weakmap) > .size): Deleted.
* UserInterface/Views/FormattedValue.js:
(WebInspector.FormattedValue.createElementForTypesAndValue):
Treat a WeakSet like a set in more places.

LayoutTests:

* inspector/model/remote-object-expected.txt:
* inspector/model/remote-object.html:
Update the test to include a WeakSet example.
Also rebaseline for iterator changes that landed recently.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (183024 => 183025)


--- trunk/LayoutTests/ChangeLog	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/LayoutTests/ChangeLog	2015-04-20 20:25:56 UTC (rev 183025)
@@ -1,3 +1,15 @@
+2015-04-20  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Improve Support for WeakSet in Console
+        https://bugs.webkit.org/show_bug.cgi?id=143951
+
+        Reviewed by Darin Adler.
+
+        * inspector/model/remote-object-expected.txt:
+        * inspector/model/remote-object.html:
+        Update the test to include a WeakSet example.
+        Also rebaseline for iterator changes that landed recently.
+
 2015-04-20  Alex Christensen  <achristen...@webkit.org>
 
         Fix content extension test flakiness.

Modified: trunk/LayoutTests/inspector/model/remote-object-expected.txt (183024 => 183025)


--- trunk/LayoutTests/inspector/model/remote-object-expected.txt	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/LayoutTests/inspector/model/remote-object-expected.txt	2015-04-20 20:25:56 UTC (rev 183025)
@@ -3128,16 +3128,53 @@
 }
 
 -----------------------------------------------------
+_expression_: set = new WeakSet; strongKey = {id:1}; set.add(strongKey); set
+{
+  "_type": "object",
+  "_subtype": "weakset",
+  "_objectId": "<filtered>",
+  "_description": "WeakSet",
+  "_size": 1,
+  "_preview": {
+    "_type": "object",
+    "_subtype": "weakset",
+    "_description": "WeakSet",
+    "_lossless": true,
+    "_overflow": false,
+    "_size": 1,
+    "_properties": [],
+    "_entries": [
+      {
+        "_value": {
+          "_type": "object",
+          "_description": "Object",
+          "_lossless": true,
+          "_overflow": false,
+          "_properties": [
+            {
+              "_name": "id",
+              "_type": "number",
+              "_value": "1"
+            }
+          ],
+          "_entries": null
+        }
+      }
+    ]
+  }
+}
+
+-----------------------------------------------------
 _expression_: 'a'[Symbol.iterator]()
 {
   "_type": "object",
   "_subtype": "iterator",
   "_objectId": "<filtered>",
-  "_description": "StringIterator",
+  "_description": "String Iterator",
   "_preview": {
     "_type": "object",
     "_subtype": "iterator",
-    "_description": "StringIterator",
+    "_description": "String Iterator",
     "_lossless": true,
     "_overflow": false,
     "_properties": [
@@ -3169,11 +3206,11 @@
   "_type": "object",
   "_subtype": "iterator",
   "_objectId": "<filtered>",
-  "_description": "StringIterator",
+  "_description": "String Iterator",
   "_preview": {
     "_type": "object",
     "_subtype": "iterator",
-    "_description": "StringIterator",
+    "_description": "String Iterator",
     "_lossless": false,
     "_overflow": true,
     "_properties": [
@@ -3245,11 +3282,11 @@
   "_type": "object",
   "_subtype": "iterator",
   "_objectId": "<filtered>",
-  "_description": "ArrayIterator",
+  "_description": "Array Iterator",
   "_preview": {
     "_type": "object",
     "_subtype": "iterator",
-    "_description": "ArrayIterator",
+    "_description": "Array Iterator",
     "_lossless": true,
     "_overflow": false,
     "_properties": [
@@ -3286,11 +3323,11 @@
   "_type": "object",
   "_subtype": "iterator",
   "_objectId": "<filtered>",
-  "_description": "ArrayIterator",
+  "_description": "Array Iterator",
   "_preview": {
     "_type": "object",
     "_subtype": "iterator",
-    "_description": "ArrayIterator",
+    "_description": "Array Iterator",
     "_lossless": true,
     "_overflow": false,
     "_properties": [
@@ -3344,11 +3381,11 @@
   "_type": "object",
   "_subtype": "iterator",
   "_objectId": "<filtered>",
-  "_description": "ArrayIterator",
+  "_description": "Array Iterator",
   "_preview": {
     "_type": "object",
     "_subtype": "iterator",
-    "_description": "ArrayIterator",
+    "_description": "Array Iterator",
     "_lossless": false,
     "_overflow": true,
     "_properties": [
@@ -3427,11 +3464,11 @@
   "_type": "object",
   "_subtype": "iterator",
   "_objectId": "<filtered>",
-  "_description": "ArrayIterator",
+  "_description": "Array Iterator",
   "_preview": {
     "_type": "object",
     "_subtype": "iterator",
-    "_description": "ArrayIterator",
+    "_description": "Array Iterator",
     "_lossless": false,
     "_overflow": true,
     "_properties": [
@@ -3510,11 +3547,11 @@
   "_type": "object",
   "_subtype": "iterator",
   "_objectId": "<filtered>",
-  "_description": "ArrayIterator",
+  "_description": "Array Iterator",
   "_preview": {
     "_type": "object",
     "_subtype": "iterator",
-    "_description": "ArrayIterator",
+    "_description": "Array Iterator",
     "_lossless": false,
     "_overflow": true,
     "_properties": [
@@ -4005,16 +4042,16 @@
   "_type": "object",
   "_subtype": "iterator",
   "_objectId": "<filtered>",
-  "_description": "ArgumentsIterator",
+  "_description": "Array Iterator",
   "_preview": {
     "_type": "object",
     "_subtype": "iterator",
-    "_description": "ArgumentsIterator",
+    "_description": "Array Iterator",
     "_lossless": true,
     "_overflow": false,
     "_properties": [
       {
-        "_name": "arguments",
+        "_name": "array",
         "_type": "object",
         "_subtype": "array",
         "_valuePreview": {
@@ -4039,6 +4076,12 @@
           "_entries": null
         },
         "_internal": true
+      },
+      {
+        "_name": "kind",
+        "_type": "string",
+        "_value": "value",
+        "_internal": true
       }
     ],
     "_entries": [

Modified: trunk/LayoutTests/inspector/model/remote-object.html (183024 => 183025)


--- trunk/LayoutTests/inspector/model/remote-object.html	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/LayoutTests/inspector/model/remote-object.html	2015-04-20 20:25:56 UTC (rev 183025)
@@ -129,11 +129,12 @@
         {_expression_: "map = new Map; for (var i = 0; i <= 100; i++) map.set(i, i); map"},
         {_expression_: "map = new WeakMap; strongKey = {id:1}; map.set(strongKey, [1,2]); map"},
 
-        // Set
+        // Set / WeakSet
         {_expression_: "new Set"},
         {_expression_: "set = new Set; set.add(1); set.add(2); set.add('key'); set"},
         {_expression_: "set = new Set; set.add({a:1}); set.add(document.body); set.add([1,2]); set"},
         {_expression_: "set = new Set; for (var i = 0; i <= 100; i++) set.add(i); set"},
+        {_expression_: "set = new WeakSet; strongKey = {id:1}; set.add(strongKey); set"},
 
         // Iterators
         {_expression_: "'a'[Symbol.iterator]()"},

Modified: trunk/Source/_javascript_Core/ChangeLog (183024 => 183025)


--- trunk/Source/_javascript_Core/ChangeLog	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-04-20 20:25:56 UTC (rev 183025)
@@ -1,3 +1,25 @@
+2015-04-20  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Improve Support for WeakSet in Console
+        https://bugs.webkit.org/show_bug.cgi?id=143951
+
+        Reviewed by Darin Adler.
+
+        * inspector/InjectedScriptSource.js:
+        * inspector/JSInjectedScriptHost.cpp:
+        (Inspector::JSInjectedScriptHost::subtype):
+        (Inspector::JSInjectedScriptHost::weakSetSize):
+        (Inspector::JSInjectedScriptHost::weakSetEntries):
+        * inspector/JSInjectedScriptHost.h:
+        * inspector/JSInjectedScriptHostPrototype.cpp:
+        (Inspector::JSInjectedScriptHostPrototype::finishCreation):
+        (Inspector::jsInjectedScriptHostPrototypeFunctionWeakSetSize):
+        (Inspector::jsInjectedScriptHostPrototypeFunctionWeakSetEntries):
+        Treat WeakSets like special sets.
+
+        * inspector/protocol/Runtime.json:
+        Add a new object subtype, "weakset".
+
 2015-04-20  Yusuke Suzuki  <utatane....@gmail.com>
 
         HashMap storing PropertyKey StringImpl* need to use IdentifierRepHash to handle Symbols

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (183024 => 183025)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2015-04-20 20:25:56 UTC (rev 183025)
@@ -853,6 +853,11 @@
         return InjectedScriptHost.weakMapEntries(object, numberToFetch);
     },
 
+    _getWeakSetEntries: function(object, numberToFetch)
+    {
+        return InjectedScriptHost.weakSetEntries(object, numberToFetch);
+    },
+
     _getIteratorEntries: function(object, numberToFetch)
     {
         return InjectedScriptHost.iteratorEntries(object, numberToFetch);
@@ -866,6 +871,8 @@
             return this._getMapEntries(object, startIndex, numberToFetch);
         if (subtype === "weakmap")
             return this._getWeakMapEntries(object, numberToFetch);
+        if (subtype === "weakset")
+            return this._getWeakSetEntries(object, numberToFetch);
         if (subtype === "iterator")
             return this._getIteratorEntries(object, numberToFetch);
 
@@ -939,6 +946,8 @@
         this.size = object.size;
     else if (subtype === "weakmap")
         this.size = InjectedScriptHost.weakMapSize(object);
+    else if (subtype === "weakset")
+        this.size = InjectedScriptHost.weakSetSize(object);
     else if (subtype === "class")
         this.classPrototype = injectedScript._wrapObject(object.prototype, objectGroupName);
 
@@ -998,7 +1007,7 @@
 
         try {
             // Maps, Sets, and Iterators have entries.
-            if (this.subtype === "map" || this.subtype === "set" || this.subtype === "weakmap" || this.subtype === "iterator")
+            if (this.subtype === "map" || this.subtype === "set" || this.subtype === "weakmap" || this.subtype === "weakset" || this.subtype === "iterator")
                 this._appendEntryPreviews(object, preview);
 
             preview.properties = [];

Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp (183024 => 183025)


--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp	2015-04-20 20:25:56 UTC (rev 183025)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 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
@@ -43,6 +43,7 @@
 #include "JSStringIterator.h"
 #include "JSTypedArrays.h"
 #include "JSWeakMap.h"
+#include "JSWeakSet.h"
 #include "ObjectConstructor.h"
 #include "RegExpObject.h"
 #include "SourceCode.h"
@@ -158,6 +159,8 @@
         return jsNontrivialString(exec, ASCIILiteral("set"));
     if (value.inherits(JSWeakMap::info()))
         return jsNontrivialString(exec, ASCIILiteral("weakmap"));
+    if (value.inherits(JSWeakSet::info()))
+        return jsNontrivialString(exec, ASCIILiteral("weakset"));
 
     if (value.inherits(JSArrayIterator::info())
         || value.inherits(JSMapIterator::info())
@@ -382,6 +385,49 @@
     return array;
 }
 
+JSValue JSInjectedScriptHost::weakSetSize(ExecState* exec)
+{
+    if (exec->argumentCount() < 1)
+        return jsUndefined();
+
+    JSValue value = exec->uncheckedArgument(0);
+    JSWeakSet* weakSet = jsDynamicCast<JSWeakSet*>(value);
+    if (!weakSet)
+        return jsUndefined();
+
+    return jsNumber(weakSet->weakMapData()->size());
+}
+
+JSValue JSInjectedScriptHost::weakSetEntries(ExecState* exec)
+{
+    if (exec->argumentCount() < 1)
+        return jsUndefined();
+
+    JSValue value = exec->uncheckedArgument(0);
+    JSWeakSet* weakSet = jsDynamicCast<JSWeakSet*>(value);
+    if (!weakSet)
+        return jsUndefined();
+
+    unsigned fetched = 0;
+    unsigned numberToFetch = 100;
+
+    JSValue numberToFetchArg = exec->argument(1);
+    double fetchDouble = numberToFetchArg.toInteger(exec);
+    if (fetchDouble >= 0)
+        numberToFetch = static_cast<unsigned>(fetchDouble);
+
+    JSArray* array = constructEmptyArray(exec, nullptr);
+    for (auto it = weakSet->weakMapData()->begin(); it != weakSet->weakMapData()->end(); ++it) {
+        JSObject* entry = constructEmptyObject(exec);
+        entry->putDirect(exec->vm(), Identifier::fromString(exec, "value"), it->key);
+        array->putDirectIndex(exec, fetched++, entry);
+        if (numberToFetch && fetched >= numberToFetch)
+            break;
+    }
+
+    return array;
+}
+
 JSValue JSInjectedScriptHost::iteratorEntries(ExecState* exec)
 {
     if (exec->argumentCount() < 1)

Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.h (183024 => 183025)


--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.h	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.h	2015-04-20 20:25:56 UTC (rev 183025)
@@ -28,6 +28,10 @@
 
 #include "JSDestructibleObject.h"
 
+namespace JSC {
+class WeakMapData;
+}
+
 namespace Inspector {
 
 class InjectedScriptHost;
@@ -68,6 +72,8 @@
     JSC::JSValue getInternalProperties(JSC::ExecState*);
     JSC::JSValue weakMapSize(JSC::ExecState*);
     JSC::JSValue weakMapEntries(JSC::ExecState*);
+    JSC::JSValue weakSetSize(JSC::ExecState*);
+    JSC::JSValue weakSetEntries(JSC::ExecState*);
     JSC::JSValue iteratorEntries(JSC::ExecState*);
 
 protected:

Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp (183024 => 183025)


--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp	2015-04-20 20:25:56 UTC (rev 183025)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 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
@@ -45,6 +45,8 @@
 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection(ExecState*);
 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapSize(ExecState*);
 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapEntries(ExecState*);
+static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakSetSize(ExecState*);
+static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakSetEntries(ExecState*);
 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIteratorEntries(ExecState*);
 
 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeEvaluate(ExecState*);
@@ -64,6 +66,8 @@
     JSC_NATIVE_FUNCTION("isHTMLAllCollection", jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection, DontEnum, 1);
     JSC_NATIVE_FUNCTION("weakMapSize", jsInjectedScriptHostPrototypeFunctionWeakMapSize, DontEnum, 1);
     JSC_NATIVE_FUNCTION("weakMapEntries", jsInjectedScriptHostPrototypeFunctionWeakMapEntries, DontEnum, 1);
+    JSC_NATIVE_FUNCTION("weakSetSize", jsInjectedScriptHostPrototypeFunctionWeakSetSize, DontEnum, 1);
+    JSC_NATIVE_FUNCTION("weakSetEntries", jsInjectedScriptHostPrototypeFunctionWeakSetEntries, DontEnum, 1);
     JSC_NATIVE_FUNCTION("iteratorEntries", jsInjectedScriptHostPrototypeFunctionIteratorEntries, DontEnum, 1);
 
     Identifier evaluateIdentifier = Identifier::fromString(&vm, "evaluate");
@@ -128,6 +132,28 @@
     return JSValue::encode(castedThis->weakMapEntries(exec));
 }
 
+EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakSetSize(ExecState* exec)
+{
+    JSValue thisValue = exec->thisValue();
+    JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
+    if (!castedThis)
+        return throwVMTypeError(exec);
+
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
+    return JSValue::encode(castedThis->weakSetSize(exec));
+}
+
+EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakSetEntries(ExecState* exec)
+{
+    JSValue thisValue = exec->thisValue();
+    JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
+    if (!castedThis)
+        return throwVMTypeError(exec);
+
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
+    return JSValue::encode(castedThis->weakSetEntries(exec));
+}
+
 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIteratorEntries(ExecState* exec)
 {
     JSValue thisValue = exec->thisValue();

Modified: trunk/Source/_javascript_Core/inspector/protocol/Runtime.json (183024 => 183025)


--- trunk/Source/_javascript_Core/inspector/protocol/Runtime.json	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/_javascript_Core/inspector/protocol/Runtime.json	2015-04-20 20:25:56 UTC (rev 183025)
@@ -13,12 +13,12 @@
             "description": "Mirror object referencing original _javascript_ object.",
             "properties": [
                 { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." },
-                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "iterator", "class"], "description": "Object subtype hint. Specified for <code>object</code> <code>function</code> (for class) type values only." },
+                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "weakset", "iterator", "class"], "description": "Object subtype hint. Specified for <code>object</code> <code>function</code> (for class) type values only." },
                 { "name": "className", "type": "string", "optional": true, "description": "Object class (constructor) name. Specified for <code>object</code> type values only." },
                 { "name": "value", "type": "any", "optional": true, "description": "Remote object value (in case of primitive values or JSON values if it was requested)." },
                 { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." },
                 { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Unique object identifier (for non-primitive values)." },
-                { "name": "size", "type": "integer", "optional": true, "description": "Size of the array/collection. Specified for array/map/set/weakmap object type values only." },
+                { "name": "size", "type": "integer", "optional": true, "description": "Size of the array/collection. Specified for array/map/set/weakmap/weakset object type values only." },
                 { "name": "classPrototype", "$ref": "RemoteObject", "optional": true, "description": "Remote object for the class prototype. Specified for class object type values only." },
                 { "name": "preview", "$ref": "ObjectPreview", "optional": true, "description": "Preview containing abbreviated property values. Specified for <code>object</code> type values only." }
             ]
@@ -29,13 +29,13 @@
             "description": "Object containing abbreviated remote object value.",
             "properties": [
                 { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." },
-                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "iterator", "class"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
+                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "weakset", "iterator", "class"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
                 { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." },
                 { "name": "lossless", "type": "boolean", "description": "Determines whether preview is lossless (contains all information of the original object)." },
                 { "name": "overflow", "type": "boolean", "optional": true, "description": "True iff some of the properties of the original did not fit." },
                 { "name": "properties", "type": "array", "items": { "$ref": "PropertyPreview" }, "optional": true, "description": "List of the properties." },
                 { "name": "entries", "type": "array", "items": { "$ref": "EntryPreview" }, "optional": true, "description": "List of the entries. Specified for <code>map</code> and <code>set</code> subtype values only." },
-                { "name": "size", "type": "integer", "optional": true, "description": "Size of the array/collection. Specified for array/map/set/weakmap object type values only." }
+                { "name": "size", "type": "integer", "optional": true, "description": "Size of the array/collection. Specified for array/map/set/weakmap/weakset object type values only." }
             ]
         },
         {
@@ -44,7 +44,7 @@
             "properties": [
                 { "name": "name", "type": "string", "description": "Property name." },
                 { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol", "accessor"], "description": "Object type." },
-                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "iterator", "class"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
+                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "weakset", "iterator", "class"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
                 { "name": "value", "type": "string", "optional": true, "description": "User-friendly property value string." },
                 { "name": "valuePreview", "$ref": "ObjectPreview", "optional": true, "description": "Nested value preview." },
                 { "name": "internal", "type": "boolean", "optional": true, "description": "True if this is an internal property." }

Modified: trunk/Source/WebInspectorUI/ChangeLog (183024 => 183025)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-04-20 20:25:56 UTC (rev 183025)
@@ -1,3 +1,33 @@
+2015-04-20  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Improve Support for WeakSet in Console
+        https://bugs.webkit.org/show_bug.cgi?id=143951
+
+        Reviewed by Darin Adler.
+
+        * UserInterface/Models/NativeFunctionParameters.js:
+        WeakSet has the same APIs and parameters as Set for the functions it implements.
+
+        * UserInterface/Protocol/RemoteObject.js:
+        (WebInspector.RemoteObject.prototype.isCollectionType):
+        (WebInspector.RemoteObject.prototype.isWeakCollection):
+        (WebInspector.RemoteObject.prototype.getCollectionEntries):
+        (WebInspector.RemoteObject.prototype._weakCollectionObjectGroup):
+        WeakSet is a weak collection.
+
+        * UserInterface/Models/ObjectPreview.js:
+        (WebInspector.ObjectPreview.prototype.hasSize):
+        * UserInterface/Views/ConsoleMessageView.js:
+        (WebInspector.ConsoleMessageView.prototype._formatParameter):
+        * UserInterface/Views/FormattedValue.css:
+        (.formatted-object, .formatted-node, .formatted-error, .formatted-map, .formatted-set, .formatted-weakmap, .formatted-weakset):
+        (:matches(.formatted-array, .formatted-map, .formatted-set, .formatted-weakmap, .formatted-weakset) > .size):
+        (.formatted-object, .formatted-node, .formatted-error, .formatted-map, .formatted-set, .formatted-weakmap): Deleted.
+        (:matches(.formatted-array, .formatted-map, .formatted-set, .formatted-weakmap) > .size): Deleted.
+        * UserInterface/Views/FormattedValue.js:
+        (WebInspector.FormattedValue.createElementForTypesAndValue):
+        Treat a WeakSet like a set in more places.
+
 2015-04-18  Nikita Vasilyev  <nvasil...@apple.com>
 
         Web Inspector: Pass multiple arguments to classList.add and classList.remove

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js (183024 => 183025)


--- trunk/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js	2015-04-20 20:25:56 UTC (rev 183025)
@@ -2063,6 +2063,7 @@
 };
 
 WebInspector.NativePrototypeFunctionParameters.WeakMap = WebInspector.NativePrototypeFunctionParameters.Map;
+WebInspector.NativePrototypeFunctionParameters.WeakSet = WebInspector.NativePrototypeFunctionParameters.Set;
 
 (function() {
     function mixin(o, mixin) {

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/ObjectPreview.js (183024 => 183025)


--- trunk/Source/WebInspectorUI/UserInterface/Models/ObjectPreview.js	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/ObjectPreview.js	2015-04-20 20:25:56 UTC (rev 183025)
@@ -112,6 +112,6 @@
 
     hasSize()
     {
-        return this._size !== undefined && (this._subtype === "array" || this._subtype === "set" || this._subtype === "map" || this._subtype === "weakmap");
+        return this._size !== undefined && (this._subtype === "array" || this._subtype === "set" || this._subtype === "map" || this._subtype === "weakmap" || this._subtype === "weakset");
     }
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js (183024 => 183025)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js	2015-04-20 20:25:56 UTC (rev 183025)
@@ -342,12 +342,12 @@
 
     isCollectionType()
     {
-        return this._subtype === "map" || this._subtype === "set" || this._subtype === "weakmap";
+        return this._subtype === "map" || this._subtype === "set" || this._subtype === "weakmap" || this._subtype === "weakset";
     }
 
     isWeakCollection()
     {
-        return this._subtype === "weakmap";
+        return this._subtype === "weakmap" || this._subtype === "weakset";
     }
 
     getCollectionEntries(start, numberToFetch, callback)
@@ -359,8 +359,9 @@
         console.assert(numberToFetch >= 0);
         console.assert(this.isCollectionType());
 
-        // WeakMaps are not ordered. We should never send a non-zero start.
+        // WeakMaps and WeakSets are not ordered. We should never send a non-zero start.
         console.assert((this._subtype === "weakmap" && start === 0) || this._subtype !== "weakmap");
+        console.assert((this._subtype === "weakset" && start === 0) || this._subtype !== "weakset");
 
         var objectGroup = this.isWeakCollection() ? this._weakCollectionObjectGroup() : "";
 
@@ -476,7 +477,7 @@
 
     _weakCollectionObjectGroup()
     {
-        return JSON.stringify(this._objectId) + "-WeakMap";
+        return JSON.stringify(this._objectId) + "-" + this._subtype;
     }
 
     _getPropertyDescriptors(ownProperties, callback)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (183024 => 183025)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2015-04-20 20:25:56 UTC (rev 183025)
@@ -433,6 +433,7 @@
             "map": this._formatParameterAsObject,
             "set": this._formatParameterAsObject,
             "weakmap": this._formatParameterAsObject,
+            "weakset": this._formatParameterAsObject,
             "iterator": this._formatParameterAsObject,
             "class": this._formatParameterAsObject,
             "array": this._formatParameterAsArray,

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.css (183024 => 183025)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.css	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.css	2015-04-20 20:25:56 UTC (rev 183025)
@@ -23,13 +23,13 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-.formatted-object, .formatted-node, .formatted-error, .formatted-map, .formatted-set, .formatted-weakmap {
+.formatted-object, .formatted-node, .formatted-error, .formatted-map, .formatted-set, .formatted-weakmap, .formatted-weakset {
     position: relative;
     display: inline-block;
     color: black;
 }
 
-:matches(.formatted-array, .formatted-map, .formatted-set, .formatted-weakmap) > .size {
+:matches(.formatted-array, .formatted-map, .formatted-set, .formatted-weakmap, .formatted-weakset) > .size {
     font-style: normal;
     color: rgba(0, 0, 0, 0.33);
 }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js (183024 => 183025)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js	2015-04-20 19:40:03 UTC (rev 183024)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js	2015-04-20 20:25:56 UTC (rev 183025)
@@ -97,7 +97,7 @@
     span.textContent = displayString;
 
     // If there is a size, include it.
-    if (size !== undefined && (subtype === "array" || subtype === "set" || subtype === "map" || subtype === "weakmap")) {
+    if (size !== undefined && (subtype === "array" || subtype === "set" || subtype === "map" || subtype === "weakmap" || subtype === "weakset")) {
         var sizeElement = span.appendChild(document.createElement("span"));
         sizeElement.className = "size";
         sizeElement.textContent = " (" + size + ")";
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to