Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js

Issue 2022503002: Add ability to toggle passive state on an individual event listener. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Limit Toggle Passive to touchstart, touchmove, mousewheel, wheel Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 /** @type {?WebInspector.RemoteObject} */
563 var removeFunction = null; 563 var removeFunction = null;
564 564
565 /** @type {?WebInspector.RemoteObject} */
566 var togglePassiveFunction = null;
567
565 this.callFunctionPromise(nodeRemoveEventListener).then(storeRemoveFu nction.bind(this)); 568 this.callFunctionPromise(nodeRemoveEventListener).then(storeRemoveFu nction.bind(this));
566 569
567 /** 570 /**
568 * @param {!WebInspector.CallFunctionResult} result 571 * @param {!WebInspector.CallFunctionResult} result
569 * @this {WebInspector.RemoteObject} 572 * @this {WebInspector.RemoteObject}
570 */ 573 */
571 function storeRemoveFunction(result) 574 function storeRemoveFunction(result)
572 { 575 {
573 if (!result.wasThrown && result.object) 576 if (!result.wasThrown && result.object)
574 removeFunction = result.object; 577 removeFunction = result.object;
578
579 this.callFunctionPromise(nodeTogglePassiveEventListener).then(st oreTogglePassiveFunction.bind(this));
caseq 2016/06/01 17:48:11 I think this is getting a bit too complicated. Act
dtapuska 2016/06/01 17:54:37 I completely agree. I tried passing back an array
kozy 2016/06/01 19:05:01 It was added here to align implementation for nati
dtapuska 2016/06/01 20:22:58 Do you mean just calling this from EventListenersV
580 }
581
582 /**
583 * @param {!WebInspector.CallFunctionResult} result
584 * @this {WebInspector.RemoteObject}
585 */
586 function storeTogglePassiveFunction(result)
587 {
588 if (!result.wasThrown && result.object)
589 togglePassiveFunction = result.object;
590
575 this.target().domdebuggerAgent().getEventListeners(this._objectI d, mycallback.bind(this)); 591 this.target().domdebuggerAgent().getEventListeners(this._objectI d, mycallback.bind(this));
576 } 592 }
577 593
578 /** 594 /**
579 * @this {!WebInspector.RemoteObject} 595 * @this {!WebInspector.RemoteObject}
580 * @param {?Protocol.Error} error 596 * @param {?Protocol.Error} error
581 * @param {!Array<!DOMDebuggerAgent.EventListener>} payloads 597 * @param {!Array<!DOMDebuggerAgent.EventListener>} payloads
582 */ 598 */
583 function mycallback(error, payloads) 599 function mycallback(error, payloads)
584 { 600 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 else 637 else
622 return {}; 638 return {};
623 } 639 }
624 this.removeEventListener(type, handler, eventListenerOptions ()); 640 this.removeEventListener(type, handler, eventListenerOptions ());
625 if (this["on" + type]) 641 if (this["on" + type])
626 this["on" + type] = null; 642 this["on" + type] = null;
627 } 643 }
628 } 644 }
629 645
630 /** 646 /**
647 * @suppressReceiverCheck
648 * @this {Node}
649 * @return {function(this:Node, string, function(), boolean, boolean ): undefined}
650 */
651 function nodeTogglePassiveEventListener()
652 {
653 return togglePassiveListenerWrapper.bind(this);
654 /**
655 * @param {string} type
656 * @param {function()} handler
657 * @param {boolean} useCapture
658 * @param {boolean} passive
659 * @this {Node}
660 */
661 function togglePassiveListenerWrapper(type, handler, useCapture, passive)
662 {
663 // TODO(dtapuska): Remove this one closure compiler is updat ed
664 // to handle EventListenerOptions and passive event listener s
665 // has shipped. Don't JSDoc these otherwise it will fail.
666 // @return {{capture: boolean, passive: boolean}}
667 function eventListenerOptions()
668 {
669 return {"capture": useCapture, "passive": passive};
670 }
671 this.removeEventListener(type, handler, eventListenerOptions ());
672 passive = !passive;
673 this.addEventListener(type, handler, eventListenerOptions()) ;
674 if (this["on" + type])
675 this["on" + type] = null;
caseq 2016/06/01 17:48:11 Not sure if this is something you want to do on to
dtapuska 2016/06/02 16:02:11 Acknowledged.
676 }
677 }
678
679 /**
631 * @this {!WebInspector.RemoteObject} 680 * @this {!WebInspector.RemoteObject}
632 * @param {!DOMDebuggerAgent.EventListener} payload 681 * @param {!DOMDebuggerAgent.EventListener} payload
633 */ 682 */
634 function createEventListener(payload) 683 function createEventListener(payload)
635 { 684 {
636 return new WebInspector.EventListener(this._target, 685 return new WebInspector.EventListener(this._target,
637 payload.type, 686 payload.type,
638 payload.useCapture, 687 payload.useCapture,
639 payload.passive, 688 payload.passive,
640 payload.handler ? this.tar get().runtimeModel.createRemoteObject(payload.handler) : null, 689 payload.handler ? this.tar get().runtimeModel.createRemoteObject(payload.handler) : null,
641 payload.originalHandler ? this.target().runtimeModel.createRemoteObject(payload.originalHandler) : null, 690 payload.originalHandler ? this.target().runtimeModel.createRemoteObject(payload.originalHandler) : null,
642 WebInspector.DebuggerModel .Location.fromPayload(this._debuggerModel, payload.location), 691 WebInspector.DebuggerModel .Location.fromPayload(this._debuggerModel, payload.location),
643 removeFunction); 692 removeFunction,
693 togglePassiveFunction);
644 } 694 }
645 } 695 }
646 }, 696 },
647 697
648 /** 698 /**
649 * @param {!Array.<string>} propertyPath 699 * @param {!Array.<string>} propertyPath
650 * @param {function(?WebInspector.RemoteObject, boolean=)} callback 700 * @param {function(?WebInspector.RemoteObject, boolean=)} callback
651 */ 701 */
652 getProperty: function(propertyPath, callback) 702 getProperty: function(propertyPath, callback)
653 { 703 {
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 { 1709 {
1660 if (!this._cachedDescription) { 1710 if (!this._cachedDescription) {
1661 var children = this._children(); 1711 var children = this._children();
1662 this._cachedDescription = "{" + this._formatValue(children[0].value) + " => " + this._formatValue(children[1].value) + "}"; 1712 this._cachedDescription = "{" + this._formatValue(children[0].value) + " => " + this._formatValue(children[1].value) + "}";
1663 } 1713 }
1664 return this._cachedDescription; 1714 return this._cachedDescription;
1665 }, 1715 },
1666 1716
1667 __proto__: WebInspector.LocalJSONObject.prototype 1717 __proto__: WebInspector.LocalJSONObject.prototype
1668 } 1718 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698