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.BreakpointsSidebarPane = function() |
| 27 { |
| 28 WebInspector.SidebarPane.call(this, WebInspector.UIString("Breakpoints")); |
| 29 |
| 30 this.breakpoints = {}; |
| 31 |
| 32 this.listElement = document.createElement("ol"); |
| 33 this.listElement.className = "breakpoint-list"; |
| 34 |
| 35 this.emptyElement = document.createElement("div"); |
| 36 this.emptyElement.className = "info"; |
| 37 this.emptyElement.textContent = WebInspector.UIString("No Breakpoints"); |
| 38 |
| 39 this.bodyElement.appendChild(this.emptyElement); |
| 40 } |
| 41 |
| 42 WebInspector.BreakpointsSidebarPane.prototype = { |
| 43 addBreakpoint: function(breakpoint) |
| 44 { |
| 45 if (this.breakpoints[breakpoint.id]) |
| 46 return; |
| 47 |
| 48 this.breakpoints[breakpoint.id] = breakpoint; |
| 49 |
| 50 breakpoint.addEventListener("enabled", this._breakpointEnableChanged, th
is); |
| 51 breakpoint.addEventListener("disabled", this._breakpointEnableChanged, t
his); |
| 52 breakpoint.addEventListener("text-changed", this._breakpointTextChanged,
this); |
| 53 |
| 54 this._appendBreakpointElement(breakpoint); |
| 55 |
| 56 if (this.emptyElement.parentElement) { |
| 57 this.bodyElement.removeChild(this.emptyElement); |
| 58 this.bodyElement.appendChild(this.listElement); |
| 59 } |
| 60 |
| 61 if (!InspectorController.debuggerEnabled() || !breakpoint.sourceID) |
| 62 return; |
| 63 |
| 64 if (breakpoint.enabled) |
| 65 InspectorController.addBreakpoint(breakpoint.sourceID, breakpoint.li
ne, breakpoint.condition); |
| 66 }, |
| 67 |
| 68 _appendBreakpointElement: function(breakpoint) |
| 69 { |
| 70 function checkboxClicked() |
| 71 { |
| 72 breakpoint.enabled = !breakpoint.enabled; |
| 73 } |
| 74 |
| 75 function labelClicked() |
| 76 { |
| 77 var script = WebInspector.panels.scripts.scriptOrResourceForID(break
point.sourceID); |
| 78 if (script) |
| 79 WebInspector.panels.scripts.showScript(script, breakpoint.line); |
| 80 } |
| 81 |
| 82 var breakpointElement = document.createElement("li"); |
| 83 breakpoint._breakpointListElement = breakpointElement; |
| 84 breakpointElement._breakpointObject = breakpoint; |
| 85 |
| 86 var checkboxElement = document.createElement("input"); |
| 87 checkboxElement.className = "checkbox-elem"; |
| 88 checkboxElement.type = "checkbox"; |
| 89 checkboxElement.checked = breakpoint.enabled; |
| 90 checkboxElement.addEventListener("click", checkboxClicked, false); |
| 91 breakpointElement.appendChild(checkboxElement); |
| 92 |
| 93 var labelElement = document.createElement("a"); |
| 94 labelElement.textContent = breakpoint.label; |
| 95 labelElement.addEventListener("click", labelClicked, false); |
| 96 breakpointElement.appendChild(labelElement); |
| 97 |
| 98 var sourceTextElement = document.createElement("div"); |
| 99 sourceTextElement.textContent = breakpoint.sourceText; |
| 100 sourceTextElement.className = "source-text"; |
| 101 breakpointElement.appendChild(sourceTextElement); |
| 102 |
| 103 var currentElement = this.listElement.firstChild; |
| 104 while (currentElement) { |
| 105 var currentBreak = currentElement._breakpointObject; |
| 106 if (currentBreak.url > breakpoint.url) { |
| 107 this.listElement.insertBefore(breakpointElement, currentElement)
; |
| 108 return; |
| 109 } else if (currentBreak.url == breakpoint.url && currentBreak.line >
breakpoint.line) { |
| 110 this.listElement.insertBefore(breakpointElement, currentElement)
; |
| 111 return; |
| 112 } |
| 113 currentElement = currentElement.nextSibling; |
| 114 } |
| 115 this.listElement.appendChild(breakpointElement); |
| 116 }, |
| 117 |
| 118 removeBreakpoint: function(breakpoint) |
| 119 { |
| 120 if (!this.breakpoints[breakpoint.id]) |
| 121 return; |
| 122 delete this.breakpoints[breakpoint.id]; |
| 123 |
| 124 breakpoint.removeEventListener("enabled", null, this); |
| 125 breakpoint.removeEventListener("disabled", null, this); |
| 126 breakpoint.removeEventListener("text-changed", null, this); |
| 127 |
| 128 var element = breakpoint._breakpointListElement; |
| 129 element.parentElement.removeChild(element); |
| 130 |
| 131 if (!this.listElement.firstChild) { |
| 132 this.bodyElement.removeChild(this.listElement); |
| 133 this.bodyElement.appendChild(this.emptyElement); |
| 134 } |
| 135 |
| 136 if (!InspectorController.debuggerEnabled() || !breakpoint.sourceID) |
| 137 return; |
| 138 |
| 139 InspectorController.removeBreakpoint(breakpoint.sourceID, breakpoint.lin
e); |
| 140 }, |
| 141 |
| 142 _breakpointEnableChanged: function(event) |
| 143 { |
| 144 var breakpoint = event.target; |
| 145 |
| 146 var checkbox = breakpoint._breakpointListElement.firstChild; |
| 147 checkbox.checked = breakpoint.enabled; |
| 148 |
| 149 if (!InspectorController.debuggerEnabled() || !breakpoint.sourceID) |
| 150 return; |
| 151 |
| 152 if (breakpoint.enabled) |
| 153 InspectorController.addBreakpoint(breakpoint.sourceID, breakpoint.li
ne, breakpoint.condition); |
| 154 else |
| 155 InspectorController.removeBreakpoint(breakpoint.sourceID, breakpoint
.line); |
| 156 }, |
| 157 |
| 158 _breakpointTextChanged: function(event) |
| 159 { |
| 160 var breakpoint = event.target; |
| 161 |
| 162 var sourceTextElement = breakpoint._breakpointListElement.firstChild.nex
tSibling.nextSibling; |
| 163 sourceTextElement.textContent = breakpoint.sourceText; |
| 164 } |
| 165 } |
| 166 |
| 167 WebInspector.BreakpointsSidebarPane.prototype.__proto__ = WebInspector.SidebarPa
ne.prototype; |
OLD | NEW |