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 if (scopeObjectProxy.thisObject) { |
| 59 extraProperties = [ new WebInspector.ObjectPropertyProxy("th
is", scopeObjectProxy.thisObject) ]; |
| 60 title = WebInspector.UIString("Local"); |
| 61 } else |
| 62 title = WebInspector.UIString("Closure"); |
| 63 emptyPlaceholder = WebInspector.UIString("No Variables"); |
| 64 subtitle = null; |
| 65 foundLocalScope = true; |
| 66 } else if (i === (scopeChain.length - 1)) |
| 67 title = WebInspector.UIString("Global"); |
| 68 else if (scopeObjectProxy.isElement) |
| 69 title = WebInspector.UIString("Event Target"); |
| 70 else if (scopeObjectProxy.isDocument) |
| 71 title = WebInspector.UIString("Event Document"); |
| 72 else if (scopeObjectProxy.isWithBlock) |
| 73 title = WebInspector.UIString("With Block"); |
| 74 |
| 75 if (!title || title === subtitle) |
| 76 subtitle = null; |
| 77 |
| 78 var section = new WebInspector.ObjectPropertiesSection(scopeObjectPr
oxy, title, subtitle, emptyPlaceholder, true, extraProperties, WebInspector.Scop
eVariableTreeElement); |
| 79 section.editInSelectedCallFrameWhenPaused = true; |
| 80 section.pane = this; |
| 81 |
| 82 if (!foundLocalScope || scopeObjectProxy.isLocal) |
| 83 section.expanded = true; |
| 84 |
| 85 this.sections.push(section); |
| 86 this.bodyElement.appendChild(section.element); |
| 87 } |
| 88 } |
| 89 } |
| 90 |
| 91 WebInspector.ScopeChainSidebarPane.prototype.__proto__ = WebInspector.SidebarPan
e.prototype; |
| 92 |
| 93 WebInspector.ScopeVariableTreeElement = function(property) |
| 94 { |
| 95 WebInspector.ObjectPropertyTreeElement.call(this, property); |
| 96 } |
| 97 |
| 98 WebInspector.ScopeVariableTreeElement.prototype = { |
| 99 onattach: function() |
| 100 { |
| 101 WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this); |
| 102 if (this.hasChildren && this.propertyIdentifier in this.treeOutline.sect
ion.pane._expandedProperties) |
| 103 this.expand(); |
| 104 }, |
| 105 |
| 106 onexpand: function() |
| 107 { |
| 108 this.treeOutline.section.pane._expandedProperties[this.propertyIdentifie
r] = true; |
| 109 }, |
| 110 |
| 111 oncollapse: function() |
| 112 { |
| 113 delete this.treeOutline.section.pane._expandedProperties[this.propertyId
entifier]; |
| 114 }, |
| 115 |
| 116 get propertyIdentifier() |
| 117 { |
| 118 if ("_propertyIdentifier" in this) |
| 119 return this._propertyIdentifier; |
| 120 var section = this.treeOutline.section; |
| 121 this._propertyIdentifier = section.title + ":" + (section.subtitle ? sec
tion.subtitle + ":" : "") + this.propertyPath; |
| 122 return this._propertyIdentifier; |
| 123 }, |
| 124 |
| 125 get propertyPath() |
| 126 { |
| 127 if ("_propertyPath" in this) |
| 128 return this._propertyPath; |
| 129 |
| 130 var current = this; |
| 131 var result; |
| 132 |
| 133 do { |
| 134 if (result) |
| 135 result = current.property.name + "." + result; |
| 136 else |
| 137 result = current.property.name; |
| 138 current = current.parent; |
| 139 } while (current && !current.root); |
| 140 |
| 141 this._propertyPath = result; |
| 142 return result; |
| 143 } |
| 144 } |
| 145 |
| 146 WebInspector.ScopeVariableTreeElement.prototype.__proto__ = WebInspector.ObjectP
ropertyTreeElement.prototype; |
OLD | NEW |