2 * Copyright (C) 2015 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 WebInspector.ObjectTreeArrayIndexTreeElement = function(property, propertyPath)
28 console.assert(property.isIndexProperty(), "ArrayIndexTreeElement expects numeric property names");
30 WebInspector.ObjectTreeBaseTreeElement.call(this, property, propertyPath, property);
32 this.mainTitle = this._titleFragment();
33 this.addClassName("object-tree-property");
34 this.addClassName("object-tree-array-index");
36 if (!this.property.hasValue())
37 this.addClassName("accessor");
40 WebInspector.ObjectTreeArrayIndexTreeElement.prototype = {
41 constructor: WebInspector.ObjectTreeArrayIndexTreeElement,
42 __proto__: WebInspector.ObjectTreeBaseTreeElement.prototype,
46 invokedGetter: function()
48 this.mainTitle = this._titleFragment();
50 this.removeClassName("accessor");
55 _titleFragment: function()
57 var container = document.createDocumentFragment();
60 var nameElement = container.appendChild(document.createElement("span"));
61 nameElement.className = "index-name";
62 nameElement.textContent = this.property.name;
63 nameElement.title = this.propertyPathString(this.thisPropertyPath());
66 var valueElement = container.appendChild(document.createElement("span"));
67 valueElement.className = "index-value";
69 var resolvedValue = this.resolvedValue();
71 valueElement.appendChild(WebInspector.FormattedValue.createObjectTreeOrFormattedValueForRemoteObject(resolvedValue, this.resolvedValuePropertyPath()));
73 if (this.property.hasGetter())
74 container.appendChild(this.createInteractiveGetterElement());
75 if (!this.property.hasSetter())
76 container.appendChild(this.createReadOnlyIconElement());
77 // FIXME: What if just a setter?
80 valueElement.classList.add("value");
82 valueElement.classList.add("error");