OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 */ | 138 */ |
139 consume: function(preventDefault) | 139 consume: function(preventDefault) |
140 { | 140 { |
141 this.stopPropagation(); | 141 this.stopPropagation(); |
142 if (preventDefault) | 142 if (preventDefault) |
143 this.preventDefault(); | 143 this.preventDefault(); |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 /** | 147 /** |
| 148 * @constructor |
| 149 * @extends {WebInspector.Object} |
| 150 */ |
| 151 WebInspector.Lock = function() |
| 152 { |
| 153 this._count = 0; // Reentrant. |
| 154 } |
| 155 |
| 156 /** |
| 157 * @enum {string} |
| 158 */ |
| 159 WebInspector.Lock.Events = { |
| 160 StateChanged: "StateChanged" |
| 161 } |
| 162 |
| 163 WebInspector.Lock.prototype = { |
| 164 /** |
| 165 * @return {boolean} |
| 166 */ |
| 167 isAcquired: function() |
| 168 { |
| 169 return !!this._count; |
| 170 }, |
| 171 |
| 172 acquire: function() |
| 173 { |
| 174 if (++this._count === 1) |
| 175 this.dispatchEventToListeners(WebInspector.Lock.Events.StateChanged)
; |
| 176 }, |
| 177 |
| 178 release: function() |
| 179 { |
| 180 --this._count; |
| 181 if (this._count < 0) { |
| 182 console.error("WebInspector.Lock acquire/release calls are unbalance
d " + new Error().stack); |
| 183 return; |
| 184 } |
| 185 if (!this._count) |
| 186 this.dispatchEventToListeners(WebInspector.Lock.Events.StateChanged)
; |
| 187 }, |
| 188 |
| 189 __proto__: WebInspector.Object.prototype |
| 190 } |
| 191 |
| 192 /** |
148 * @interface | 193 * @interface |
149 */ | 194 */ |
150 WebInspector.EventTarget = function() | 195 WebInspector.EventTarget = function() |
151 { | 196 { |
152 } | 197 } |
153 | 198 |
154 WebInspector.EventTarget.prototype = { | 199 WebInspector.EventTarget.prototype = { |
155 /** | 200 /** |
156 * @param {string} eventType | 201 * @param {string} eventType |
157 * @param {function(!WebInspector.Event)} listener | 202 * @param {function(!WebInspector.Event)} listener |
(...skipping 16 matching lines...) Expand all Loading... |
174 */ | 219 */ |
175 hasEventListeners: function(eventType) { }, | 220 hasEventListeners: function(eventType) { }, |
176 | 221 |
177 /** | 222 /** |
178 * @param {string} eventType | 223 * @param {string} eventType |
179 * @param {*=} eventData | 224 * @param {*=} eventData |
180 * @return {boolean} | 225 * @return {boolean} |
181 */ | 226 */ |
182 dispatchEventToListeners: function(eventType, eventData) { }, | 227 dispatchEventToListeners: function(eventType, eventData) { }, |
183 } | 228 } |
OLD | NEW |