Web Inspector: ES6: Show Symbol properties on Objects
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / TypePropertiesSection.js
index a4880cd..02af481 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-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
@@ -27,6 +27,7 @@ WebInspector.TypePropertiesSection = function(types, title, subtitle)
 {
     this.emptyPlaceholder = WebInspector.UIString("No Properties");
     this.types = types;
+    this._typeSet = WebInspector.TypeSet.fromPayload(this.types);
 
     WebInspector.PropertiesSection.call(this, title, subtitle);
 };
@@ -39,8 +40,8 @@ WebInspector.TypePropertiesSection.prototype = {
     {
         this.propertiesTreeOutline.removeChildren();
 
-        var primitiveTypeNames = this.types.globalPrimitiveTypeNames || this.types.localPrimitiveTypeNames;
-        var structures = this.types.globalStructures || this.types.localStructures;
+        var primitiveTypeNames = this._typeSet.primitiveTypeNames;
+        var structures = this.types.structures;
         var properties = [];
         for (var struct of structures) {
             properties.push({
@@ -56,6 +57,10 @@ WebInspector.TypePropertiesSection.prototype = {
         }
 
         properties.sort(WebInspector.TypePropertiesSection.PropertyComparator);
+
+        if (this.types.isTruncated)
+            properties.push({name: "\u2026", structure: null});
+
         for (var property of properties)
             this.propertiesTreeOutline.appendChild(new WebInspector.TypePropertyTreeElement(property));
 
@@ -63,7 +68,7 @@ WebInspector.TypePropertiesSection.prototype = {
             var title = document.createElement("div");
             title.className = "info";
             title.textContent = this.emptyPlaceholder;
-            var infoElement = new TreeElement(title, null, false);
+            var infoElement = new WebInspector.TreeElement(title, null, false);
             this.propertiesTreeOutline.appendChild(infoElement);
         }
 
@@ -74,7 +79,7 @@ WebInspector.TypePropertiesSection.prototype = {
     }
 };
 
-// This is mostly identical to ObjectPropertiesSection.compareProperties.
+// This is mostly identical to ObjectTreeView.compareProperties.
 // But this checks for equality because we can have two objects named the same thing.
 WebInspector.TypePropertiesSection.PropertyComparator = function(propertyA, propertyB)
 {
@@ -85,7 +90,7 @@ WebInspector.TypePropertiesSection.PropertyComparator = function(propertyA, prop
     if (b.indexOf("__proto__") !== -1)
         return -1;
     if (a === b)
-        return 1;
+        return 0;
 
     var diff = 0;
     var chunk = /^\d+|^\D+/;
@@ -120,25 +125,23 @@ WebInspector.TypePropertiesSection.PropertyComparator = function(propertyA, prop
     return diff;
 };
 
-WebInspector.TypePropertyTreeElement = function(property)
+WebInspector.TypePropertyTreeElement = class TypePropertyTreeElement extends WebInspector.TreeElement
 {
-    this.property = property;
-
-    this.nameElement = document.createElement("span");
-    this.nameElement.className = "name";
-    this.nameElement.textContent = this.property.name;
+    constructor(property)
+    {
+        var titleElement = document.createElement("span");
+        super(titleElement, null, false);
 
-    TreeElement.call(this, this.nameElement, null, false);
+        this.property = property;
 
-    this.toggleOnClick = true;
-    this.hasChildren = !!this.property.structure;
-};
+        titleElement.className = "name";
+        titleElement.textContent = this.property.name;
 
-WebInspector.TypePropertyTreeElement.prototype = {
-    constructor: WebInspector.TypePropertyTreeElement,
-    __proto__: TreeElement.prototype,
+        this.toggleOnClick = true;
+        this.hasChildren = !!this.property.structure;
+    }
 
-    onpopulate: function()
+    onpopulate()
     {
         this.removeChildren();
 
@@ -152,6 +155,22 @@ WebInspector.TypePropertyTreeElement.prototype = {
 
         properties.sort(WebInspector.TypePropertiesSection.PropertyComparator);
 
+        for (var property of properties)
+            this.appendChild(new WebInspector.TypePropertyTreeElement(property));
+
+        properties = [];
+        for (var fieldName of this.property.structure.optionalFields) {
+            properties.push({
+                name: fieldName + "?",
+                structure: null
+            });
+        }
+
+        properties.sort(WebInspector.TypePropertiesSection.PropertyComparator);
+
+        if (this.property.structure.isImprecise)
+            properties.push({name: "\u2026", structure: null});
+
         if (this.property.structure.prototypeStructure) {
             properties.push({
                 name: this.property.structure.prototypeStructure.constructorName + " (" + WebInspector.UIString("Prototype") + ")",
@@ -163,4 +182,3 @@ WebInspector.TypePropertyTreeElement.prototype = {
             this.appendChild(new WebInspector.TypePropertyTreeElement(property));
     }
 };
-