| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 // TODO(kozyatinskiy): figure out how this should work for |wind
ow| when there is no DOMDebugger. | 552 // TODO(kozyatinskiy): figure out how this should work for |wind
ow| when there is no DOMDebugger. |
| 553 fulfill([]); | 553 fulfill([]); |
| 554 return; | 554 return; |
| 555 } | 555 } |
| 556 | 556 |
| 557 if (!this._objectId) { | 557 if (!this._objectId) { |
| 558 reject(null); | 558 reject(null); |
| 559 return; | 559 return; |
| 560 } | 560 } |
| 561 | 561 |
| 562 /** @type {?WebInspector.RemoteObject} */ | 562 this.target().domdebuggerAgent().getEventListeners(this._objectId, m
ycallback.bind(this)); |
| 563 var removeFunction = null; | |
| 564 | |
| 565 this.callFunctionPromise(nodeRemoveEventListener).then(storeRemoveFu
nction.bind(this)); | |
| 566 | |
| 567 /** | |
| 568 * @param {!WebInspector.CallFunctionResult} result | |
| 569 * @this {WebInspector.RemoteObject} | |
| 570 */ | |
| 571 function storeRemoveFunction(result) | |
| 572 { | |
| 573 if (!result.wasThrown && result.object) | |
| 574 removeFunction = result.object; | |
| 575 this.target().domdebuggerAgent().getEventListeners(this._objectI
d, mycallback.bind(this)); | |
| 576 } | |
| 577 | 563 |
| 578 /** | 564 /** |
| 579 * @this {!WebInspector.RemoteObject} | 565 * @this {!WebInspector.RemoteObject} |
| 580 * @param {?Protocol.Error} error | 566 * @param {?Protocol.Error} error |
| 581 * @param {!Array<!DOMDebuggerAgent.EventListener>} payloads | 567 * @param {!Array<!DOMDebuggerAgent.EventListener>} payloads |
| 582 */ | 568 */ |
| 583 function mycallback(error, payloads) | 569 function mycallback(error, payloads) |
| 584 { | 570 { |
| 585 if (error) { | 571 if (error) { |
| 586 reject(null); | 572 reject(null); |
| 587 return; | 573 return; |
| 588 } | 574 } |
| 589 fulfill(payloads.map(createEventListener.bind(this))); | 575 fulfill(payloads.map(createEventListener.bind(this))); |
| 590 } | 576 } |
| 591 | 577 |
| 592 /** | 578 /** |
| 593 * @suppressReceiverCheck | |
| 594 * @this {Node} | |
| 595 * @return {function(this:Node, string, function(), boolean=, boolea
n=): undefined} | |
| 596 */ | |
| 597 function nodeRemoveEventListener() | |
| 598 { | |
| 599 return removeEventListenerWrapper.bind(this); | |
| 600 /** | |
| 601 * @param {string} type | |
| 602 * @param {function()} handler | |
| 603 * @param {boolean=} useCapture | |
| 604 * @param {boolean=} passive | |
| 605 * @this {Node} | |
| 606 */ | |
| 607 function removeEventListenerWrapper(type, handler, useCapture, p
assive) | |
| 608 { | |
| 609 // TODO(dtapuska): Remove this one closure compiler is updat
ed | |
| 610 // to handle EventListenerOptions and passive event listener
s | |
| 611 // has shipped. Don't JSDoc these otherwise it will fail. | |
| 612 // @return {boolean|undefined|{capture: (boolean|undefined),
passive: boolean}} | |
| 613 function eventListenerOptions() | |
| 614 { | |
| 615 if (passive && useCapture) | |
| 616 return {"capture": useCapture, "passive": passive}; | |
| 617 else if (passive) | |
| 618 return {"passive": passive}; | |
| 619 else if (useCapture) | |
| 620 return {"capture": useCapture}; | |
| 621 else | |
| 622 return {}; | |
| 623 } | |
| 624 this.removeEventListener(type, handler, eventListenerOptions
()); | |
| 625 if (this["on" + type]) | |
| 626 this["on" + type] = null; | |
| 627 } | |
| 628 } | |
| 629 | |
| 630 /** | |
| 631 * @this {!WebInspector.RemoteObject} | 579 * @this {!WebInspector.RemoteObject} |
| 632 * @param {!DOMDebuggerAgent.EventListener} payload | 580 * @param {!DOMDebuggerAgent.EventListener} payload |
| 633 */ | 581 */ |
| 634 function createEventListener(payload) | 582 function createEventListener(payload) |
| 635 { | 583 { |
| 636 return new WebInspector.EventListener(this._target, | 584 return new WebInspector.EventListener(this._target, |
| 637 payload.type, | 585 payload.type, |
| 638 payload.useCapture, | 586 payload.useCapture, |
| 639 payload.passive, | 587 payload.passive, |
| 640 payload.handler ? this.tar
get().runtimeModel.createRemoteObject(payload.handler) : null, | 588 payload.handler ? this.tar
get().runtimeModel.createRemoteObject(payload.handler) : null, |
| 641 payload.originalHandler ?
this.target().runtimeModel.createRemoteObject(payload.originalHandler) : null, | 589 payload.originalHandler ?
this.target().runtimeModel.createRemoteObject(payload.originalHandler) : null, |
| 642 WebInspector.DebuggerModel
.Location.fromPayload(this._debuggerModel, payload.location), | 590 WebInspector.DebuggerModel
.Location.fromPayload(this._debuggerModel, payload.location), |
| 643 removeFunction); | 591 payload.removeFunction ? t
his.target().runtimeModel.createRemoteObject(payload.removeFunction) : null); |
| 644 } | 592 } |
| 645 } | 593 } |
| 646 }, | 594 }, |
| 647 | 595 |
| 648 /** | 596 /** |
| 649 * @param {!Array.<string>} propertyPath | 597 * @param {!Array.<string>} propertyPath |
| 650 * @param {function(?WebInspector.RemoteObject, boolean=)} callback | 598 * @param {function(?WebInspector.RemoteObject, boolean=)} callback |
| 651 */ | 599 */ |
| 652 getProperty: function(propertyPath, callback) | 600 getProperty: function(propertyPath, callback) |
| 653 { | 601 { |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 { | 1607 { |
| 1660 if (!this._cachedDescription) { | 1608 if (!this._cachedDescription) { |
| 1661 var children = this._children(); | 1609 var children = this._children(); |
| 1662 this._cachedDescription = "{" + this._formatValue(children[0].value)
+ " => " + this._formatValue(children[1].value) + "}"; | 1610 this._cachedDescription = "{" + this._formatValue(children[0].value)
+ " => " + this._formatValue(children[1].value) + "}"; |
| 1663 } | 1611 } |
| 1664 return this._cachedDescription; | 1612 return this._cachedDescription; |
| 1665 }, | 1613 }, |
| 1666 | 1614 |
| 1667 __proto__: WebInspector.LocalJSONObject.prototype | 1615 __proto__: WebInspector.LocalJSONObject.prototype |
| 1668 } | 1616 } |
| OLD | NEW |