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

Side by Side Diff: Source/devtools/front_end/elements/EventListenersWidget.js

Issue 1268353005: [DevTools] Support JQuery event listeners (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 5 years, 4 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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 20 matching lines...) Expand all
31 * @constructor 31 * @constructor
32 * @extends {WebInspector.ThrottledWidget} 32 * @extends {WebInspector.ThrottledWidget}
33 */ 33 */
34 WebInspector.EventListenersWidget = function() 34 WebInspector.EventListenersWidget = function()
35 { 35 {
36 WebInspector.ThrottledWidget.call(this); 36 WebInspector.ThrottledWidget.call(this);
37 this.element.classList.add("events-pane"); 37 this.element.classList.add("events-pane");
38 38
39 this._showForAncestorsSetting = WebInspector.settings.createSetting("showEve ntListenersForAncestors", true); 39 this._showForAncestorsSetting = WebInspector.settings.createSetting("showEve ntListenersForAncestors", true);
40 this._showForAncestorsSetting.addChangeListener(this.update.bind(this)); 40 this._showForAncestorsSetting.addChangeListener(this.update.bind(this));
41
42 this._showFrameworkListenersSetting = WebInspector.settings.createSetting("_ showFrameworkListeners", true);
43 this._showFrameworkListenersSetting.addChangeListener(this._showFrameworkUse rListenersChanged.bind(this));
44
41 this._eventListenersView = new WebInspector.EventListenersView(this.element) ; 45 this._eventListenersView = new WebInspector.EventListenersView(this.element) ;
42 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this.upda te, this); 46 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this.upda te, this);
47
48 this._frameworkSupportInitializedSymbol = Symbol("frameworkSupportInitialize d");
43 } 49 }
44 50
45 /** 51 /**
46 * @return {!WebInspector.ElementsSidebarViewWrapperPane} 52 * @return {!WebInspector.ElementsSidebarViewWrapperPane}
47 */ 53 */
48 WebInspector.EventListenersWidget.createSidebarWrapper = function() 54 WebInspector.EventListenersWidget.createSidebarWrapper = function()
49 { 55 {
50 var widget = new WebInspector.EventListenersWidget(); 56 var widget = new WebInspector.EventListenersWidget();
51 var result = new WebInspector.ElementsSidebarViewWrapperPane(WebInspector.UI String("Event Listeners"), widget); 57 var result = new WebInspector.ElementsSidebarViewWrapperPane(WebInspector.UI String("Event Listeners"), widget);
52 var refreshButton = new WebInspector.ToolbarButton(WebInspector.UIString("Re fresh"), "refresh-toolbar-item"); 58 var refreshButton = new WebInspector.ToolbarButton(WebInspector.UIString("Re fresh"), "refresh-toolbar-item");
53 refreshButton.addEventListener("click", widget.update.bind(widget)); 59 refreshButton.addEventListener("click", widget.update.bind(widget));
54 result.toolbar().appendToolbarItem(refreshButton); 60 result.toolbar().appendToolbarItem(refreshButton);
55 result.toolbar().appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspe ctor.UIString("Ancestors"), WebInspector.UIString("Show listeners on the ancesto rs"), widget._showForAncestorsSetting)); 61 result.toolbar().appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspe ctor.UIString("Ancestors"), WebInspector.UIString("Show listeners on the ancesto rs"), widget._showForAncestorsSetting));
62 result.toolbar().appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspe ctor.UIString("Framework user's listeners"), WebInspector.UIString("Show framewo rk user event listeners"), widget._showFrameworkListenersSetting));
paulirish 2015/08/14 21:03:15 Checkbox: Framework listeners Tooltip: Resolve eve
56 return result; 63 return result;
57 } 64 }
58 65
59 WebInspector.EventListenersWidget._objectGroupName = "event-listeners-panel"; 66 WebInspector.EventListenersWidget._objectGroupName = "event-listeners-panel";
60 67
61 WebInspector.EventListenersWidget.prototype = { 68 WebInspector.EventListenersWidget.prototype = {
62 /** 69 /**
63 * @override 70 * @override
64 * @param {!WebInspector.Throttler.FinishCallback} finishCallback 71 * @param {!WebInspector.Throttler.FinishCallback} finishCallback
65 * @protected 72 * @protected
66 */ 73 */
67 doUpdate: function(finishCallback) 74 doUpdate: function(finishCallback)
68 { 75 {
69 if (this._lastRequestedNode) { 76 if (this._lastRequestedNode) {
70 this._lastRequestedNode.target().runtimeAgent().releaseObjectGroup(W ebInspector.EventListenersWidget._objectGroupName); 77 this._lastRequestedNode.target().runtimeAgent().releaseObjectGroup(W ebInspector.EventListenersWidget._objectGroupName);
71 delete this._lastRequestedNode; 78 delete this._lastRequestedNode;
72 } 79 }
73 var node = WebInspector.context.flavor(WebInspector.DOMNode); 80 var node = WebInspector.context.flavor(WebInspector.DOMNode);
74 if (!node) { 81 if (!node) {
75 this._eventListenersView.reset(); 82 this._eventListenersView.reset();
76 this._eventListenersView.addEmptyHolderIfNeeded(); 83 this._eventListenersView.addEmptyHolderIfNeeded();
77 finishCallback(); 84 finishCallback();
78 return; 85 return;
79 } 86 }
80 this._lastRequestedNode = node; 87 this._lastRequestedNode = node;
81 var selectedNodeOnly = !this._showForAncestorsSetting.get(); 88 var selectedNodeOnly = !this._showForAncestorsSetting.get();
89 var context = this._nodeExecutionContext(node);
82 var promises = []; 90 var promises = [];
83 var listenersView = this._eventListenersView; 91 var listenersView = this._eventListenersView;
84 promises.push(node.resolveToObjectPromise(WebInspector.EventListenersWid get._objectGroupName)); 92 promises.push(node.resolveToObjectPromise(WebInspector.EventListenersWid get._objectGroupName));
85 if (!selectedNodeOnly) { 93 if (!selectedNodeOnly) {
86 var currentNode = node.parentNode; 94 var currentNode = node.parentNode;
87 while (currentNode) { 95 while (currentNode) {
88 promises.push(currentNode.resolveToObjectPromise(WebInspector.Ev entListenersWidget._objectGroupName)); 96 promises.push(currentNode.resolveToObjectPromise(WebInspector.Ev entListenersWidget._objectGroupName));
89 currentNode = currentNode.parentNode; 97 currentNode = currentNode.parentNode;
90 } 98 }
91 promises.push(this._windowObjectInNodeContext(node)); 99 promises.push(this._windowObjectInContext(context));
92 } 100 }
93 Promise.all(promises).then(this._eventListenersView.addObjects.bind(this ._eventListenersView)).then(finishCallback.bind(this, undefined)); 101 WebInspector.EventListenersFrameworkSupport.initializeOnContext(context) .then(addEventListeners.bind(this));
102
103 /**
104 * @this {!WebInspector.EventListenersWidget}
105 */
106 function addEventListeners()
107 {
108 Promise.all(promises).then(this._eventListenersView.addObjects.bind( this._eventListenersView)).then(showResolvedHandlers.bind(this));
109 }
110
111 /**
112 * @this {!WebInspector.EventListenersWidget}
113 */
114 function showResolvedHandlers()
115 {
116 this._showFrameworkUserListenersChanged();
117 finishCallback();
118 }
119 },
120
121 _showFrameworkUserListenersChanged: function()
122 {
123 this._eventListenersView.showFrameworkUserEventListeners(this._showFrame workListenersSetting.get());
94 }, 124 },
95 125
96 /** 126 /**
97 * @param {!WebInspector.DOMNode} node 127 * @param {!WebInspector.DOMNode} node
128 * @return {?WebInspector.ExecutionContext}
129 */
130 _nodeExecutionContext: function(node)
131 {
132 var executionContexts = node.target().runtimeModel.executionContexts();
133 var context = null;
134 if (node.frameId()) {
135 for (var i = 0; i < executionContexts.length; ++i) {
136 var executionContext = executionContexts[i];
137 if (executionContext.frameId === node.frameId() && executionCont ext.isMainWorldContext)
138 context = executionContext;
139 }
140 } else {
141 context = executionContexts[0];
142 }
143 return context;
144 },
145
146 /**
147 * @param {?WebInspector.ExecutionContext} context
98 * @return {!Promise<!WebInspector.RemoteObject>} 148 * @return {!Promise<!WebInspector.RemoteObject>}
99 */ 149 */
100 _windowObjectInNodeContext: function(node) 150 _windowObjectInContext: function(context)
101 { 151 {
102 return new Promise(windowObjectInNodeContext); 152 return new Promise(windowObjectInNodeContext);
103 153
104 /** 154 /**
105 * @param {function(?)} fulfill 155 * @param {function(?)} fulfill
106 * @param {function(*)} reject 156 * @param {function(*)} reject
107 */ 157 */
108 function windowObjectInNodeContext(fulfill, reject) 158 function windowObjectInNodeContext(fulfill, reject)
109 { 159 {
110 var executionContexts = node.target().runtimeModel.executionContexts (); 160 if (context)
111 var context = null; 161 context.evaluate("self", WebInspector.EventListenersWidget._obje ctGroupName, false, true, false, false, fulfill);
112 if (node.frameId()) { 162 else
113 for (var i = 0; i < executionContexts.length; ++i) { 163 reject("Empty context");
114 var executionContext = executionContexts[i];
115 if (executionContext.frameId === node.frameId() && execution Context.isMainWorldContext)
116 context = executionContext;
117 }
118 } else {
119 context = executionContexts[0];
120 }
121 context.evaluate("self", WebInspector.EventListenersWidget._objectGr oupName, false, true, false, false, fulfill);
122 } 164 }
123 }, 165 },
124 166
125 _eventListenersArrivedForTest: function()
126 {
127 },
128
129 __proto__: WebInspector.ThrottledWidget.prototype 167 __proto__: WebInspector.ThrottledWidget.prototype
130 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698