Changeset 181061 in webkit


Ignore:
Timestamp:
Mar 4, 2015 6:27:23 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: Array/Collection Sizes should be visible and distinct
https://bugs.webkit.org/show_bug.cgi?id=142254

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2015-03-04
Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

  • runtime/WeakMapData.h:

(JSC::WeakMapData::size):

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::weakMapSize):

  • inspector/JSInjectedScriptHost.h:
  • inspector/JSInjectedScriptHostPrototype.cpp:

(Inspector::JSInjectedScriptHostPrototype::finishCreation):
(Inspector::jsInjectedScriptHostPrototypeFunctionWeakMapSize):
Add a way to get a WeakMap's size.

  • inspector/protocol/Runtime.json:

Include size in RemoteObject and ObjectPreview.

  • inspector/InjectedScriptSource.js:

Set the size of RemoteObjects and previews if they
are array/collection types.

Source/WebInspectorUI:

  • UserInterface/Models/ObjectPreview.js:

(WebInspector.ObjectPreview):
(WebInspector.ObjectPreview.fromPayload):
(WebInspector.ObjectPreview.prototype.get size):
(WebInspector.ObjectPreview.prototype.hasSize):

  • UserInterface/Protocol/RemoteObject.js:

(WebInspector.RemoteObject):
(WebInspector.RemoteObject.fromPrimitiveValue):
(WebInspector.RemoteObject.fromPayload):
(WebInspector.RemoteObject.prototype.get size):
(WebInspector.RemoteObject.prototype.hasSize):
Check if this type has a size and get the size.
Gracefully handle construction for legacy protocols.

  • UserInterface/Views/ObjectPreviewView.css:

(.object-preview > .size):

  • UserInterface/Views/FormattedValue.css:

(:matches(.formatted-array, .formatted-map, .formatted-set, .formatted-weakmap) > .size):
Style the array/collection size.

  • UserInterface/Views/ObjectPreviewView.js:

(WebInspector.ObjectPreviewView):

  • UserInterface/Views/FormattedValue.js:

(WebInspector.FormattedValue.createElementForTypesAndValue):
(WebInspector.FormattedValue.createElementForRemoteObject):
(WebInspector.FormattedValue.createElementForObjectPreview):
(WebInspector.FormattedValue.createElementForPropertyPreview):
Add an element showing the array/collection size.

  • UserInterface/Views/ObjectTreePropertyTreeElement.js:

(WebInspector.ObjectTreePropertyTreeElement.prototype):
Remove special handling for Array sizes now that this is handled earlier.

  • UserInterface/Controllers/StorageManager.js:

(WebInspector.StorageManager.prototype.processData):
(WebInspector.StorageManager.prototype.requestIndexedDatabaseData):
Fix what looks like broken RemoteObject construction.

LayoutTests:

  • inspector-protocol/runtime/getProperties-expected.txt:
  • inspector/model/remote-object-expected.txt:
  • inspector/model/remote-object.html:

Update tests now that RemoteObjects and Previews may have an explicit size.

Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181056 r181061  
     12015-03-04  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Array/Collection Sizes should be visible and distinct
     4        https://bugs.webkit.org/show_bug.cgi?id=142254
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * inspector-protocol/runtime/getProperties-expected.txt:
     9        * inspector/model/remote-object-expected.txt:
     10        * inspector/model/remote-object.html:
     11        Update tests now that RemoteObjects and Previews may have an explicit size.
     12
    1132015-03-04  Timothy Horton  <timothy_horton@apple.com>
    214
  • trunk/LayoutTests/inspector-protocol/runtime/getProperties-expected.txt

    r180236 r181061  
    33  foo string cat
    44Properties of array
    5   __proto__ object Array[0]
     5  __proto__ object Array
    66  0 string red
    77  1 string green
     
    1717  name string Number
    1818Internal properties
    19   boundArgs object Array[1]
     19  boundArgs object Array
    2020  boundThis object Object
    2121  targetFunction function function Number() {
  • trunk/LayoutTests/inspector/model/remote-object-expected.txt

    r180356 r181061  
    518518  "_subtype": "array",
    519519  "_objectId": "<filtered>",
    520   "_description": "Array[0]",
     520  "_description": "Array",
     521  "_size": 0,
    521522  "_preview": {
    522523    "_type": "object",
    523524    "_subtype": "array",
    524     "_description": "Array[0]",
    525     "_lossless": true,
    526     "_overflow": false,
     525    "_description": "Array",
     526    "_lossless": true,
     527    "_overflow": false,
     528    "_size": 0,
    527529    "_properties": [],
    528530    "_entries": null
     
    536538  "_subtype": "array",
    537539  "_objectId": "<filtered>",
    538   "_description": "Array[2]",
     540  "_description": "Array",
     541  "_size": 2,
    539542  "_preview": {
    540543    "_type": "object",
    541544    "_subtype": "array",
    542     "_description": "Array[2]",
    543     "_lossless": true,
    544     "_overflow": false,
     545    "_description": "Array",
     546    "_lossless": true,
     547    "_overflow": false,
     548    "_size": 2,
    545549    "_properties": [
    546550      {
     
    565569  "_subtype": "array",
    566570  "_objectId": "<filtered>",
    567   "_description": "Array[3]",
     571  "_description": "Array",
     572  "_size": 3,
    568573  "_preview": {
    569574    "_type": "object",
    570575    "_subtype": "array",
    571     "_description": "Array[3]",
     576    "_description": "Array",
    572577    "_lossless": false,
    573578    "_overflow": false,
     579    "_size": 3,
    574580    "_properties": [
    575581      {
     
    577583        "_type": "object",
    578584        "_subtype": "array",
    579         "_value": "Array[1]"
     585        "_value": "Array"
    580586      },
    581587      {
     
    583589        "_type": "object",
    584590        "_subtype": "array",
    585         "_value": "Array[1]"
     591        "_value": "Array"
    586592      },
    587593      {
     
    589595        "_type": "object",
    590596        "_subtype": "array",
    591         "_value": "Array[1]"
     597        "_value": "Array"
    592598      }
    593599    ],
     
    602608  "_subtype": "array",
    603609  "_objectId": "<filtered>",
    604   "_description": "Array[5]",
     610  "_description": "Array",
     611  "_size": 5,
    605612  "_preview": {
    606613    "_type": "object",
    607614    "_subtype": "array",
    608     "_description": "Array[5]",
     615    "_description": "Array",
    609616    "_lossless": false,
    610617    "_overflow": false,
     618    "_size": 5,
    611619    "_properties": [
    612620      {
     
    647655  "_subtype": "array",
    648656  "_objectId": "<filtered>",
    649   "_description": "Array[3]",
     657  "_description": "Array",
     658  "_size": 3,
    650659  "_preview": {
    651660    "_type": "object",
    652661    "_subtype": "array",
    653     "_description": "Array[3]",
     662    "_description": "Array",
    654663    "_lossless": false,
    655664    "_overflow": false,
     665    "_size": 3,
    656666    "_properties": [
    657667      {
     
    681691  "_subtype": "array",
    682692  "_objectId": "<filtered>",
    683   "_description": "Array[1]",
     693  "_description": "Array",
     694  "_size": 1,
    684695  "_preview": {
    685696    "_type": "object",
    686697    "_subtype": "array",
    687     "_description": "Array[1]",
     698    "_description": "Array",
    688699    "_lossless": false,
    689700    "_overflow": false,
     701    "_size": 1,
    690702    "_properties": [
    691703      {
     
    693705        "_type": "object",
    694706        "_subtype": "array",
    695         "_value": "Array[3]"
     707        "_value": "Array"
    696708      }
    697709    ],
     
    706718  "_subtype": "array",
    707719  "_objectId": "<filtered>",
    708   "_description": "Array[100]",
     720  "_description": "Array",
     721  "_size": 100,
    709722  "_preview": {
    710723    "_type": "object",
    711724    "_subtype": "array",
    712     "_description": "Array[100]",
    713     "_lossless": true,
    714     "_overflow": false,
     725    "_description": "Array",
     726    "_lossless": true,
     727    "_overflow": false,
     728    "_size": 100,
    715729    "_properties": [],
    716730    "_entries": null
     
    724738  "_subtype": "array",
    725739  "_objectId": "<filtered>",
    726   "_description": "Array[100]",
     740  "_description": "Array",
     741  "_size": 100,
    727742  "_preview": {
    728743    "_type": "object",
    729744    "_subtype": "array",
    730     "_description": "Array[100]",
    731     "_lossless": true,
    732     "_overflow": false,
     745    "_description": "Array",
     746    "_lossless": true,
     747    "_overflow": false,
     748    "_size": 100,
    733749    "_properties": [
    734750      {
     
    12431259  "_subtype": "array",
    12441260  "_objectId": "<filtered>",
    1245   "_description": "Array[100]",
     1261  "_description": "Array",
     1262  "_size": 100,
    12461263  "_preview": {
    12471264    "_type": "object",
    12481265    "_subtype": "array",
    1249     "_description": "Array[100]",
    1250     "_lossless": true,
    1251     "_overflow": false,
     1266    "_description": "Array",
     1267    "_lossless": true,
     1268    "_overflow": false,
     1269    "_size": 100,
    12521270    "_properties": [
    12531271      {
     
    12671285  "_subtype": "array",
    12681286  "_objectId": "<filtered>",
    1269   "_description": "Arguments[3]",
     1287  "_description": "Arguments",
     1288  "_size": 3,
    12701289  "_preview": {
    12711290    "_type": "object",
    12721291    "_subtype": "array",
    1273     "_description": "Arguments[3]",
     1292    "_description": "Arguments",
    12741293    "_lossless": false,
    12751294    "_overflow": false,
     1295    "_size": 3,
    12761296    "_properties": [
    12771297      {
     
    13021322  "_subtype": "array",
    13031323  "_objectId": "<filtered>",
    1304   "_description": "Int32Array[4]",
     1324  "_description": "Int32Array",
     1325  "_size": 4,
    13051326  "_preview": {
    13061327    "_type": "object",
    13071328    "_subtype": "array",
    1308     "_description": "Int32Array[4]",
     1329    "_description": "Int32Array",
    13091330    "_lossless": false,
    13101331    "_overflow": false,
     1332    "_size": 4,
    13111333    "_properties": [
    13121334      {
     
    13561378  "_subtype": "array",
    13571379  "_objectId": "<filtered>",
    1358   "_description": "Int32Array[4]",
     1380  "_description": "Int32Array",
     1381  "_size": 4,
    13591382  "_preview": {
    13601383    "_type": "object",
    13611384    "_subtype": "array",
    1362     "_description": "Int32Array[4]",
     1385    "_description": "Int32Array",
    13631386    "_lossless": false,
    13641387    "_overflow": false,
     1388    "_size": 4,
    13651389    "_properties": [
    13661390      {
     
    18951919  "_subtype": "array",
    18961920  "_objectId": "<filtered>",
    1897   "_description": "HTMLCollection[3]",
     1921  "_description": "HTMLCollection",
     1922  "_size": 3,
    18981923  "_preview": {
    18991924    "_type": "object",
    19001925    "_subtype": "array",
    1901     "_description": "HTMLCollection[3]",
     1926    "_description": "HTMLCollection",
    19021927    "_lossless": false,
    19031928    "_overflow": false,
     1929    "_size": 3,
    19041930    "_properties": [
    19051931      {
     
    19421968  "_subtype": "array",
    19431969  "_objectId": "<filtered>",
    1944   "_description": "NodeList[3]",
     1970  "_description": "NodeList",
     1971  "_size": 3,
    19451972  "_preview": {
    19461973    "_type": "object",
    19471974    "_subtype": "array",
    1948     "_description": "NodeList[3]",
     1975    "_description": "NodeList",
    19491976    "_lossless": false,
    19501977    "_overflow": false,
     1978    "_size": 3,
    19511979    "_properties": [
    19521980      {
     
    19892017  "_subtype": "array",
    19902018  "_objectId": "<filtered>",
    1991   "_description": "NodeList[3]",
     2019  "_description": "NodeList",
     2020  "_size": 3,
    19922021  "_preview": {
    19932022    "_type": "object",
    19942023    "_subtype": "array",
    1995     "_description": "NodeList[3]",
     2024    "_description": "NodeList",
    19962025    "_lossless": false,
    19972026    "_overflow": false,
     2027    "_size": 3,
    19982028    "_properties": [
    19992029      {
     
    21532183
    21542184-----------------------------------------------------
    2155 EXPRESSION: Object.seal({})
    2156 {
    2157   "_type": "object",
    2158   "_objectId": "<filtered>",
    2159   "_description": "Object",
    2160   "_preview": {
    2161     "_type": "object",
    2162     "_description": "Object",
    2163     "_lossless": true,
    2164     "_overflow": false,
    2165     "_properties": [],
    2166     "_entries": null
    2167   }
    2168 }
    2169 
    2170 -----------------------------------------------------
    2171 EXPRESSION: Object.freeze({})
    2172 {
    2173   "_type": "object",
    2174   "_objectId": "<filtered>",
    2175   "_description": "Object",
    2176   "_preview": {
    2177     "_type": "object",
    2178     "_description": "Object",
    2179     "_lossless": true,
    2180     "_overflow": false,
    2181     "_properties": [],
    2182     "_entries": null
    2183   }
    2184 }
    2185 
    2186 -----------------------------------------------------
    21872185EXPRESSION: new Map
    21882186{
     
    21912189  "_objectId": "<filtered>",
    21922190  "_description": "Map",
     2191  "_size": 0,
    21932192  "_preview": {
    21942193    "_type": "object",
     
    21972196    "_lossless": true,
    21982197    "_overflow": false,
     2198    "_size": 0,
    21992199    "_properties": [],
    22002200    "_entries": []
     
    22092209  "_objectId": "<filtered>",
    22102210  "_description": "Map",
     2211  "_size": 2,
    22112212  "_preview": {
    22122213    "_type": "object",
     
    22152216    "_lossless": true,
    22162217    "_overflow": false,
     2218    "_size": 2,
    22172219    "_properties": [],
    22182220    "_entries": [
     
    22642266  "_objectId": "<filtered>",
    22652267  "_description": "Map",
     2268  "_size": 2,
    22662269  "_preview": {
    22672270    "_type": "object",
     
    22702273    "_lossless": true,
    22712274    "_overflow": false,
     2275    "_size": 2,
    22722276    "_properties": [],
    22732277    "_entries": [
     
    23412345          "_type": "object",
    23422346          "_subtype": "array",
    2343           "_description": "Array[2]",
     2347          "_description": "Array",
    23442348          "_lossless": true,
    23452349          "_overflow": false,
     2350          "_size": 2,
    23462351          "_properties": [
    23472352            {
     
    23702375  "_objectId": "<filtered>",
    23712376  "_description": "Map",
     2377  "_size": 101,
    23722378  "_preview": {
    23732379    "_type": "object",
     
    23762382    "_lossless": false,
    23772383    "_overflow": true,
     2384    "_size": 101,
    23782385    "_properties": [],
    23792386    "_entries": [
     
    24792486  "_objectId": "<filtered>",
    24802487  "_description": "WeakMap",
     2488  "_size": 1,
    24812489  "_preview": {
    24822490    "_type": "object",
     
    24852493    "_lossless": true,
    24862494    "_overflow": false,
     2495    "_size": 1,
    24872496    "_properties": [],
    24882497    "_entries": [
     
    25052514          "_type": "object",
    25062515          "_subtype": "array",
    2507           "_description": "Array[2]",
     2516          "_description": "Array",
    25082517          "_lossless": true,
    25092518          "_overflow": false,
     2519          "_size": 2,
    25102520          "_properties": [
    25112521            {
     
    25342544  "_objectId": "<filtered>",
    25352545  "_description": "Set",
     2546  "_size": 0,
    25362547  "_preview": {
    25372548    "_type": "object",
     
    25402551    "_lossless": true,
    25412552    "_overflow": false,
     2553    "_size": 0,
    25422554    "_properties": [],
    25432555    "_entries": []
     
    25522564  "_objectId": "<filtered>",
    25532565  "_description": "Set",
     2566  "_size": 3,
    25542567  "_preview": {
    25552568    "_type": "object",
     
    25582571    "_lossless": true,
    25592572    "_overflow": false,
     2573    "_size": 3,
    25602574    "_properties": [],
    25612575    "_entries": [
     
    26012615  "_objectId": "<filtered>",
    26022616  "_description": "Set",
     2617  "_size": 3,
    26032618  "_preview": {
    26042619    "_type": "object",
     
    26072622    "_lossless": true,
    26082623    "_overflow": false,
     2624    "_size": 3,
    26092625    "_properties": [],
    26102626    "_entries": [
     
    26662682          "_type": "object",
    26672683          "_subtype": "array",
    2668           "_description": "Array[2]",
     2684          "_description": "Array",
    26692685          "_lossless": true,
    26702686          "_overflow": false,
     2687          "_size": 2,
    26712688          "_properties": [
    26722689            {
     
    26952712  "_objectId": "<filtered>",
    26962713  "_description": "Set",
     2714  "_size": 101,
    26972715  "_preview": {
    26982716    "_type": "object",
     
    27012719    "_lossless": false,
    27022720    "_overflow": true,
     2721    "_size": 101,
    27032722    "_properties": [],
    27042723    "_entries": [
     
    28962915}
    28972916
     2917-----------------------------------------------------
     2918EXPRESSION: Object.seal({})
     2919{
     2920  "_type": "object",
     2921  "_objectId": "<filtered>",
     2922  "_description": "Object",
     2923  "_preview": {
     2924    "_type": "object",
     2925    "_description": "Object",
     2926    "_lossless": true,
     2927    "_overflow": false,
     2928    "_properties": [],
     2929    "_entries": null
     2930  }
     2931}
     2932
     2933-----------------------------------------------------
     2934EXPRESSION: Object.freeze({})
     2935{
     2936  "_type": "object",
     2937  "_objectId": "<filtered>",
     2938  "_description": "Object",
     2939  "_preview": {
     2940    "_type": "object",
     2941    "_description": "Object",
     2942    "_lossless": true,
     2943    "_overflow": false,
     2944    "_properties": [],
     2945    "_entries": null
     2946  }
     2947}
     2948
  • trunk/LayoutTests/inspector/model/remote-object.html

    r180715 r181061  
    117117        {expression: "error = null; try { document.createTextNode('').splitText(100); } catch (e) { error = e; }; error"},
    118118
    119     // Improveable:
    120 
    121         // Sealed / Frozen objects.
    122         {expression: "Object.seal({})"},
    123         {expression: "Object.freeze({})"},
    124 
    125119        // Map / WeakMap
    126120        {expression: "new Map"},
     
    143137        {expression: "Promise.resolve({result:1})"},
    144138
     139    // Improveable:
     140
     141        // Sealed / Frozen objects.
     142        {expression: "Object.seal({})"},
     143        {expression: "Object.freeze({})"},
    145144    ];
    146145
  • trunk/Source/JavaScriptCore/ChangeLog

    r181060 r181061  
     12015-03-04  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Array/Collection Sizes should be visible and distinct
     4        https://bugs.webkit.org/show_bug.cgi?id=142254
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * runtime/WeakMapData.h:
     9        (JSC::WeakMapData::size):
     10        * inspector/JSInjectedScriptHost.cpp:
     11        (Inspector::JSInjectedScriptHost::weakMapSize):
     12        * inspector/JSInjectedScriptHost.h:
     13        * inspector/JSInjectedScriptHostPrototype.cpp:
     14        (Inspector::JSInjectedScriptHostPrototype::finishCreation):
     15        (Inspector::jsInjectedScriptHostPrototypeFunctionWeakMapSize):
     16        Add a way to get a WeakMap's size.
     17
     18        * inspector/protocol/Runtime.json:
     19        Include size in RemoteObject and ObjectPreview.
     20
     21        * inspector/InjectedScriptSource.js:
     22        Set the size of RemoteObjects and previews if they
     23        are array/collection types.
     24
    1252015-03-04  Andreas Kling  <akling@apple.com>
    226
  • trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js

    r180913 r181061  
    769769
    770770        var className = InjectedScriptHost.internalConstructorName(obj);
    771         if (subtype === "array") {
    772             if (typeof obj.length === "number")
    773                 className += "[" + obj.length + "]";
     771        if (subtype === "array")
    774772            return className;
    775         }
    776773
    777774        // NodeList in JSC is a function, check for array prior to this.
     
    905902    this.description = injectedScript._describe(object);
    906903
     904    if (subtype === "array")
     905        this.size = typeof object.length === "number" ? object.length : 0;
     906    else if (subtype === "set" || subtype === "map")
     907        this.size = object.size;
     908    else if (subtype === "weakmap")
     909        this.size = InjectedScriptHost.weakMapSize(object);
     910
    907911    if (generatePreview && this.type === "object")
    908912        this.preview = this._generatePreview(object, undefined, columnNames);
     
    925929            }
    926930        }
     931
     932        if ("size" in this)
     933            preview.size = this.size;
    927934
    928935        return preview;
  • trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp

    r180891 r181061  
    254254}
    255255
     256JSValue JSInjectedScriptHost::weakMapSize(ExecState* exec)
     257{
     258    if (exec->argumentCount() < 1)
     259        return jsUndefined();
     260
     261    JSValue value = exec->uncheckedArgument(0);
     262    JSWeakMap* weakMap = jsDynamicCast<JSWeakMap*>(value);
     263    if (!weakMap)
     264        return jsUndefined();
     265
     266    return jsNumber(weakMap->weakMapData()->size());
     267}
     268
    256269JSValue JSInjectedScriptHost::weakMapEntries(ExecState* exec)
    257270{
  • trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h

    r179349 r181061  
    6666    JSC::JSValue functionDetails(JSC::ExecState*);
    6767    JSC::JSValue getInternalProperties(JSC::ExecState*);
     68    JSC::JSValue weakMapSize(JSC::ExecState*);
    6869    JSC::JSValue weakMapEntries(JSC::ExecState*);
    6970
  • trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp

    r179349 r181061  
    4444static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionInternalConstructorName(ExecState*);
    4545static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection(ExecState*);
     46static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapSize(ExecState*);
    4647static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapEntries(ExecState*);
    4748
     
    6162    JSC_NATIVE_FUNCTION("internalConstructorName", jsInjectedScriptHostPrototypeFunctionInternalConstructorName, DontEnum, 1);
    6263    JSC_NATIVE_FUNCTION("isHTMLAllCollection", jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection, DontEnum, 1);
     64    JSC_NATIVE_FUNCTION("weakMapSize", jsInjectedScriptHostPrototypeFunctionWeakMapSize, DontEnum, 1);
    6365    JSC_NATIVE_FUNCTION("weakMapEntries", jsInjectedScriptHostPrototypeFunctionWeakMapEntries, DontEnum, 1);
    6466
     
    101103    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
    102104    return JSValue::encode(castedThis->isHTMLAllCollection(exec));
     105}
     106
     107EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapSize(ExecState* exec)
     108{
     109    JSValue thisValue = exec->thisValue();
     110    JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
     111    if (!castedThis)
     112        return throwVMTypeError(exec);
     113
     114    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
     115    return JSValue::encode(castedThis->weakMapSize(exec));
    103116}
    104117
  • trunk/Source/JavaScriptCore/inspector/protocol/Runtime.json

    r180913 r181061  
    1919                { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." },
    2020                { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Unique object identifier (for non-primitive values)." },
     21                { "name": "size", "type": "integer", "optional": true, "description": "Size of the array/collection. Specified for array/map/set/weakmap object type values only." },
    2122                { "name": "preview", "$ref": "ObjectPreview", "optional": true, "description": "Preview containing abbreviated property values. Specified for <code>object</code> type values only." }
    2223            ]
     
    3334                { "name": "overflow", "type": "boolean", "optional": true, "description": "True iff some of the properties of the original did not fit." },
    3435                { "name": "properties", "type": "array", "items": { "$ref": "PropertyPreview" }, "optional": true, "description": "List of the properties." },
    35                 { "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." }
     36                { "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." },
     37                { "name": "size", "type": "integer", "optional": true, "description": "Size of the array/collection. Specified for array/map/set/weakmap object type values only." }
    3638            ]
    3739        },
  • trunk/Source/JavaScriptCore/runtime/WeakMapData.h

    r179349 r181061  
    6868    MapType::const_iterator end() const { return m_map.end(); }
    6969
     70    int size() const { return m_map.size(); }
     71
    7072private:
    7173    WeakMapData(VM&);
  • trunk/Source/WebInspectorUI/ChangeLog

    r181011 r181061  
     12015-03-04  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Array/Collection Sizes should be visible and distinct
     4        https://bugs.webkit.org/show_bug.cgi?id=142254
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Models/ObjectPreview.js:
     9        (WebInspector.ObjectPreview):
     10        (WebInspector.ObjectPreview.fromPayload):
     11        (WebInspector.ObjectPreview.prototype.get size):
     12        (WebInspector.ObjectPreview.prototype.hasSize):
     13        * UserInterface/Protocol/RemoteObject.js:
     14        (WebInspector.RemoteObject):
     15        (WebInspector.RemoteObject.fromPrimitiveValue):
     16        (WebInspector.RemoteObject.fromPayload):
     17        (WebInspector.RemoteObject.prototype.get size):
     18        (WebInspector.RemoteObject.prototype.hasSize):
     19        Check if this type has a size and get the size.
     20        Gracefully handle construction for legacy protocols.
     21
     22        * UserInterface/Views/ObjectPreviewView.css:
     23        (.object-preview > .size):
     24        * UserInterface/Views/FormattedValue.css:
     25        (:matches(.formatted-array, .formatted-map, .formatted-set, .formatted-weakmap) > .size):
     26        Style the array/collection size.
     27
     28        * UserInterface/Views/ObjectPreviewView.js:
     29        (WebInspector.ObjectPreviewView):
     30        * UserInterface/Views/FormattedValue.js:
     31        (WebInspector.FormattedValue.createElementForTypesAndValue):
     32        (WebInspector.FormattedValue.createElementForRemoteObject):
     33        (WebInspector.FormattedValue.createElementForObjectPreview):
     34        (WebInspector.FormattedValue.createElementForPropertyPreview):
     35        Add an element showing the array/collection size.
     36
     37        * UserInterface/Views/ObjectTreePropertyTreeElement.js:
     38        (WebInspector.ObjectTreePropertyTreeElement.prototype):
     39        Remove special handling for Array sizes now that this is handled earlier.
     40
     41        * UserInterface/Controllers/StorageManager.js:
     42        (WebInspector.StorageManager.prototype.processData):
     43        (WebInspector.StorageManager.prototype.requestIndexedDatabaseData):
     44        Fix what looks like broken RemoteObject construction.
     45
    1462015-03-04  Brian J. Burg  <burg@cs.washington.edu>
    247
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/StorageManager.js

    r176049 r181061  
    151151            for (var entryPayload of entryPayloads) {
    152152                var entry = {};
    153                 entry.primaryKey = new WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
    154                 entry.key = new WebInspector.RemoteObject.fromPayload(entryPayload.key);
    155                 entry.value = new WebInspector.RemoteObject.fromPayload(entryPayload.value);
     153                entry.primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
     154                entry.key = WebInspector.RemoteObject.fromPayload(entryPayload.key);
     155                entry.value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
    156156                entries.push(entry);
    157157            }
  • trunk/Source/WebInspectorUI/UserInterface/Models/ObjectPreview.js

    r180356 r181061  
    2424 */
    2525
    26 WebInspector.ObjectPreview = function(type, subtype, description, lossless, overflow, properties, entries)
     26WebInspector.ObjectPreview = function(type, subtype, description, lossless, overflow, properties, entries, size)
    2727{
    2828    WebInspector.Object.call(this);
     
    3838    this._lossless = lossless;
    3939    this._overflow = overflow || false;
     40    this._size = size;
    4041
    4142    this._properties = properties || null;
     
    5152        payload.entries = payload.entries.map(function(entry) { return WebInspector.CollectionEntryPreview.fromPayload(entry); });
    5253
    53     return new WebInspector.ObjectPreview(payload.type, payload.subtype, payload.description, payload.lossless, payload.overflow, payload.properties, payload.entries);
     54    if (payload.subtype === "array") {
     55        // COMPATIBILITY (iOS 8): Runtime.ObjectPreview did not have size property,
     56        // instead it was tacked onto the end of the description, like "Array[#]".
     57        var match = payload.description.match(/\[(\d+)\]$/);
     58        if (match) {
     59            payload.size = parseInt(match[1]);
     60            payload.description = payload.description.replace(/\[\d+\]$/, "");
     61        }
     62    }
     63
     64    return new WebInspector.ObjectPreview(payload.type, payload.subtype, payload.description, payload.lossless, payload.overflow, payload.properties, payload.entries, payload.size);
    5465};
    5566
     
    93104    {
    94105        return this._entries;
     106    },
     107
     108    get size()
     109    {
     110        return this._size;
     111    },
     112
     113    hasSize: function()
     114    {
     115        return this._size !== undefined && (this._subtype === "array" || this._subtype === "set" || this._subtype === "map" || this._subtype === "weakmap");
    95116    }
    96117};
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js

    r180913 r181061  
    2929 */
    3030
    31 WebInspector.RemoteObject = function(objectId, type, subtype, value, description, preview)
     31WebInspector.RemoteObject = function(objectId, type, subtype, value, description, size, preview)
    3232{
    3333    // No superclass.
     
    4848        this._description = description;
    4949        this._hasChildren = type !== "symbol";
     50        this._size = size;
    5051        this._preview = preview;
    5152    } else {
     
    6263WebInspector.RemoteObject.fromPrimitiveValue = function(value)
    6364{
    64     return new WebInspector.RemoteObject(undefined, typeof value, undefined, value);
     65    return new WebInspector.RemoteObject(undefined, typeof value, undefined, undefined, value);
    6566};
    6667
     
    6869{
    6970    console.assert(typeof payload === "object", "Remote object payload should only be an object");
     71
     72    if (payload.subtype === "array") {
     73        // COMPATIBILITY (iOS 8): Runtime.RemoteObject did not have size property,
     74        // instead it was tacked onto the end of the description, like "Array[#]".
     75        var match = payload.description.match(/\[(\d+)\]$/);
     76        if (match) {
     77            payload.size = parseInt(match[1]);
     78            payload.description = payload.description.replace(/\[\d+\]$/, "");
     79        }
     80    }
    7081
    7182    if (payload.preview) {
     
    7687            payload.preview.subtype = payload.subtype;
    7788            payload.preview.description = payload.description;
     89            payload.preview.size = payload.size;
    7890        }
    7991        payload.preview = WebInspector.ObjectPreview.fromPayload(payload.preview);
    8092    }
    8193
    82     return new WebInspector.RemoteObject(payload.objectId, payload.type, payload.subtype, payload.value, payload.description, payload.preview);
     94    return new WebInspector.RemoteObject(payload.objectId, payload.type, payload.subtype, payload.value, payload.description, payload.size, payload.preview);
    8395};
    8496
     
    152164    },
    153165
     166    get size()
     167    {
     168        return this._size || 0;
     169    },
     170
    154171    get preview()
    155172    {
    156173        return this._preview;
     174    },
     175
     176    hasSize: function()
     177    {
     178        return this.isArray() || this.isCollectionType();
    157179    },
    158180
  • trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.css

    r180713 r181061  
    2929    vertical-align: top;
    3030    color: black;
     31}
     32
     33:matches(.formatted-array, .formatted-map, .formatted-set, .formatted-weakmap) > .size {
     34    font-style: normal;
     35    color: hsl(0, 0%, 67%);
    3136}
    3237
  • trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js

    r180713 r181061  
    7070};
    7171
    72 WebInspector.FormattedValue.createElementForTypesAndValue = function(type, subtype, displayString, isPreview, hadException)
     72WebInspector.FormattedValue.createElementForTypesAndValue = function(type, subtype, displayString, size, isPreview, hadException)
    7373{
    7474    var span = document.createElement("span");
     
    9595    // Everything else, the description/value string.
    9696    span.textContent = displayString;
     97
     98    // If there is a size, include it.
     99    if (size !== undefined && (subtype === "array" || subtype === "set" || subtype === "map" || subtype === "weakmap")) {
     100        var sizeElement = span.appendChild(document.createElement("span"));
     101        sizeElement.className = "size";
     102        sizeElement.textContent = " (" + size + ")";
     103    }
     104
    97105    return span;
    98106};
     
    100108WebInspector.FormattedValue.createElementForRemoteObject = function(object, hadException)
    101109{
    102     return WebInspector.FormattedValue.createElementForTypesAndValue(object.type, object.subtype, object.description, false, hadException);
     110    return WebInspector.FormattedValue.createElementForTypesAndValue(object.type, object.subtype, object.description, object.size, false, hadException);
    103111};
    104112
    105113WebInspector.FormattedValue.createElementForObjectPreview = function(objectPreview)
    106114{
    107     return WebInspector.FormattedValue.createElementForTypesAndValue(objectPreview.type, objectPreview.subtype, objectPreview.description, true, false);
     115    return WebInspector.FormattedValue.createElementForTypesAndValue(objectPreview.type, objectPreview.subtype, objectPreview.description, objectPreview.size, true, false);
    108116};
    109117
    110118WebInspector.FormattedValue.createElementForPropertyPreview = function(propertyPreview)
    111119{
    112     return WebInspector.FormattedValue.createElementForTypesAndValue(propertyPreview.type, propertyPreview.subtype, propertyPreview.value, true, false);
     120    return WebInspector.FormattedValue.createElementForTypesAndValue(propertyPreview.type, propertyPreview.subtype, propertyPreview.value, undefined, true, false);
    113121};
    114122
  • trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPreviewView.css

    r180722 r181061  
    3939    color: rgb(136, 19, 145);
    4040}
     41
     42.object-preview > .size {
     43    font-style: normal;
     44    color: hsl(0, 0%, 67%);
     45}
  • trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPreviewView.js

    r180714 r181061  
    4545    this._initTitleElement();
    4646
     47    if (this._preview.hasSize()) {
     48        var sizeElement = this._element.appendChild(document.createElement("span"));
     49        sizeElement.className = "size";
     50        sizeElement.textContent = " (" + this._preview.size + ")";
     51    }
     52
    4753    if (this._lossless)
    4854        this._element.classList.add("lossless");
  • trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js

    r180913 r181061  
    376376            return "RegExp";
    377377
    378         return value.description.replace(/\[\d+\]$/, "").replace(/Prototype$/, "");
     378        return value.description.replace(/Prototype$/, "");
    379379    },
    380380
Note: See TracChangeset for help on using the changeset viewer.