OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * |
| 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions |
| 6 * are met: |
| 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. |
| 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ |
| 25 |
| 26 WebInspector.ScopeChainSidebarPane = function() |
| 27 { |
| 28 WebInspector.SidebarPane.call(this, WebInspector.UIString("Scope Variables")
); |
| 29 this._expandedProperties = []; |
| 30 } |
| 31 |
| 32 WebInspector.ScopeChainSidebarPane.prototype = { |
| 33 update: function(callFrame) |
| 34 { |
| 35 this.bodyElement.removeChildren(); |
| 36 |
| 37 this.sections = []; |
| 38 this.callFrame = callFrame; |
| 39 |
| 40 if (!callFrame) { |
| 41 var infoElement = document.createElement("div"); |
| 42 infoElement.className = "info"; |
| 43 infoElement.textContent = WebInspector.UIString("Not Paused"); |
| 44 this.bodyElement.appendChild(infoElement); |
| 45 return; |
| 46 } |
| 47 |
| 48 var foundLocalScope = false; |
| 49 var scopeChain = callFrame.scopeChain; |
| 50 for (var i = 0; i < scopeChain.length; ++i) { |
| 51 var scopeObjectProxy = scopeChain[i]; |
| 52 var title = null; |
| 53 var subtitle = scopeObjectProxy.description; |
| 54 var emptyPlaceholder = null; |
| 55 var extraProperties = null; |
| 56 |
| 57 if (scopeObjectProxy.isLocal) { |
| 58 foundLocalScope = true; |
| 59 title = WebInspector.UIString("Local"); |
| 60 emptyPlaceholder = WebInspector.UIString("No Variables"); |
| 61 subtitle = null; |
| 62 if (scopeObjectProxy.thisObject) |
| 63 extraProperties = [ new WebInspector.ObjectPropertyProxy("th
is", scopeObjectProxy.thisObject) ]; |
| 64 } else if (scopeObjectProxy.isClosure) { |
| 65 title = WebInspector.UIString("Closure"); |
| 66 emptyPlaceholder = WebInspector.UIString("No Variables"); |
| 67 subtitle = null; |
| 68 } else if (i === (scopeChain.length - 1)) |
| 69 title = WebInspector.UIString("Global"); |
| 70 else if (scopeObjectProxy.isElement) |
| 71 title = WebInspector.UIString("Event Target"); |
| 72 else if (scopeObjectProxy.isDocument) |
| 73 title = WebInspector.UIString("Event Document"); |
| 74 else if (scopeObjectProxy.isWithBlock) |
| 75 title = WebInspector.UIString("With Block"); |
| 76 |
| 77 if (!title || title === subtitle) |
| 78 subtitle = null; |
| 79 |
| 80 var section = new WebInspector.ObjectPropertiesSection(scopeObjectPr
oxy, title, subtitle, emptyPlaceholder, true, extraProperties, WebInspector.Scop
eVariableTreeElement); |
| 81 section.editInSelectedCallFrameWhenPaused = true; |
| 82 section.pane = this; |
| 83 |
| 84 if (!foundLocalScope || scopeObjectProxy.isLocal) |
| 85 section.expanded = true; |
| 86 |
| 87 this.sections.push(section); |
| 88 this.bodyElement.appendChild(section.element); |
| 89 } |
| 90 } |
| 91 } |
| 92 |
| 93 WebInspector.ScopeChainSidebarPane.prototype.__proto__ = WebInspector.SidebarPan
e.prototype; |
| 94 |
| 95 WebInspector.ScopeVariableTreeElement = function(property) |
| 96 { |
| 97 WebInspector.ObjectPropertyTreeElement.call(this, property); |
| 98 } |
| 99 |
| 100 WebInspector.ScopeVariableTreeElement.prototype = { |
| 101 onattach: function() |
| 102 { |
| 103 WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this); |
| 104 if (this.hasChildren && this.propertyIdentifier in this.treeOutline.sect
ion.pane._expandedProperties) |
| 105 this.expand(); |
| 106 }, |
| 107 |
| 108 onexpand: function() |
| 109 { |
| 110 this.treeOutline.section.pane._expandedProperties[this.propertyIdentifie
r] = true; |
| 111 }, |
| 112 |
| 113 oncollapse: function() |
| 114 { |
| 115 delete this.treeOutline.section.pane._expandedProperties[this.propertyId
entifier]; |
| 116 }, |
| 117 |
| 118 get propertyIdentifier() |
| 119 { |
| 120 if ("_propertyIdentifier" in this) |
| 121 return this._propertyIdentifier; |
| 122 var section = this.treeOutline.section; |
| 123 this._propertyIdentifier = section.title + ":" + (section.subtitle ? sec
tion.subtitle + ":" : "") + this.propertyPath; |
| 124 return this._propertyIdentifier; |
| 125 }, |
| 126 |
| 127 get propertyPath() |
| 128 { |
| 129 if ("_propertyPath" in this) |
| 130 return this._propertyPath; |
| 131 |
| 132 var current = this; |
| 133 var result; |
| 134 |
| 135 do { |
| 136 if (result) |
| 137 result = current.property.name + "." + result; |
| 138 else |
| 139 result = current.property.name; |
| 140 current = current.parent; |
| 141 } while (current && !current.root); |
| 142 |
| 143 this._propertyPath = result; |
| 144 return result; |
| 145 } |
| 146 } |
| 147 |
| 148 WebInspector.ScopeVariableTreeElement.prototype.__proto__ = WebInspector.ObjectP
ropertyTreeElement.prototype; |
OLD | NEW |