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 /** | |
193 * @interface | 148 * @interface |
194 */ | 149 */ |
195 WebInspector.EventTarget = function() | 150 WebInspector.EventTarget = function() |
196 { | 151 { |
197 } | 152 } |
198 | 153 |
199 WebInspector.EventTarget.prototype = { | 154 WebInspector.EventTarget.prototype = { |
200 /** | 155 /** |
201 * @param {string} eventType | 156 * @param {string} eventType |
202 * @param {function(!WebInspector.Event)} listener | 157 * @param {function(!WebInspector.Event)} listener |
(...skipping 16 matching lines...) Expand all Loading... |
219 */ | 174 */ |
220 hasEventListeners: function(eventType) { }, | 175 hasEventListeners: function(eventType) { }, |
221 | 176 |
222 /** | 177 /** |
223 * @param {string} eventType | 178 * @param {string} eventType |
224 * @param {*=} eventData | 179 * @param {*=} eventData |
225 * @return {boolean} | 180 * @return {boolean} |
226 */ | 181 */ |
227 dispatchEventToListeners: function(eventType, eventData) { }, | 182 dispatchEventToListeners: function(eventType, eventData) { }, |
228 } | 183 } |
OLD | NEW |