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

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: 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._isFrameworkSupportSetup = Symbol("isFrameworkEventListenerSupportSetup ");
yurys 2015/08/14 17:24:21 _frameworkSupportInitializedSymbol
kozy 2015/08/14 18:15:45 Done.
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("Show framework user's listeners"), WebInspector.UIString("Show fr amework user event listeners"), widget._showFrameworkListenersSetting));
yurys 2015/08/14 17:24:21 Framework user listeners
kozy 2015/08/14 18:15:45 Done.
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
(...skipping 17 matching lines...) Expand all
83 var listenersView = this._eventListenersView; 90 var listenersView = this._eventListenersView;
84 promises.push(node.resolveToObjectPromise(WebInspector.EventListenersWid get._objectGroupName)); 91 promises.push(node.resolveToObjectPromise(WebInspector.EventListenersWid get._objectGroupName));
85 if (!selectedNodeOnly) { 92 if (!selectedNodeOnly) {
86 var currentNode = node.parentNode; 93 var currentNode = node.parentNode;
87 while (currentNode) { 94 while (currentNode) {
88 promises.push(currentNode.resolveToObjectPromise(WebInspector.Ev entListenersWidget._objectGroupName)); 95 promises.push(currentNode.resolveToObjectPromise(WebInspector.Ev entListenersWidget._objectGroupName));
89 currentNode = currentNode.parentNode; 96 currentNode = currentNode.parentNode;
90 } 97 }
91 promises.push(this._windowObjectInNodeContext(node)); 98 promises.push(this._windowObjectInNodeContext(node));
92 } 99 }
93 Promise.all(promises).then(this._eventListenersView.addObjects.bind(this ._eventListenersView)).then(finishCallback.bind(this, undefined)); 100 this._setupFrameworkSupport(node).then(addEventListeners.bind(this));
101
102 /**
103 * @this {!WebInspector.EventListenersWidget}
104 */
105 function addEventListeners()
106 {
107 Promise.all(promises).then(this._eventListenersView.addObjects.bind( this._eventListenersView)).then(showResolvedHandlers.bind(this));
108 }
109
110 /**
111 * @this {!WebInspector.EventListenersWidget}
112 */
113 function showResolvedHandlers()
114 {
115 this._showFrameworkUserListenersChanged();
116 finishCallback();
117 }
118 },
119
120 _showFrameworkUserListenersChanged: function()
121 {
122 this._eventListenersView.showFrameworkUserEventListeners(this._showFrame workListenersSetting.get());
94 }, 123 },
95 124
96 /** 125 /**
126 * @param {!WebInspector.DOMNode} node
127 * @return {?WebInspector.ExecutionContext}
128 */
129 _nodeExecutionContext: function(node)
130 {
131 var executionContexts = node.target().runtimeModel.executionContexts();
132 var context = null;
133 if (node.frameId()) {
134 for (var i = 0; i < executionContexts.length; ++i) {
135 var executionContext = executionContexts[i];
136 if (executionContext.frameId === node.frameId() && executionCont ext.isMainWorldContext)
137 context = executionContext;
138 }
139 } else {
140 context = executionContexts[0];
141 }
142 return context;
143 },
144
145 /**
97 * @param {!WebInspector.DOMNode} node 146 * @param {!WebInspector.DOMNode} node
98 * @return {!Promise<!WebInspector.RemoteObject>} 147 * @return {!Promise<!WebInspector.RemoteObject>}
99 */ 148 */
100 _windowObjectInNodeContext: function(node) 149 _windowObjectInNodeContext: function(node)
101 { 150 {
102 return new Promise(windowObjectInNodeContext); 151 return new Promise(windowObjectInNodeContext.bind(this));
103 152
104 /** 153 /**
105 * @param {function(?)} fulfill 154 * @param {function(?)} fulfill
106 * @param {function(*)} reject 155 * @param {function(*)} reject
156 * @this {!WebInspector.EventListenersWidget}
107 */ 157 */
108 function windowObjectInNodeContext(fulfill, reject) 158 function windowObjectInNodeContext(fulfill, reject)
109 { 159 {
110 var executionContexts = node.target().runtimeModel.executionContexts (); 160 var context = this._nodeExecutionContext(node);
111 var context = null; 161 if (context)
112 if (node.frameId()) { 162 context.evaluate("self", WebInspector.EventListenersWidget._obje ctGroupName, false, true, false, false, fulfill);
113 for (var i = 0; i < executionContexts.length; ++i) { 163 else
114 var executionContext = executionContexts[i]; 164 reject("Empty context");
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 } 165 }
123 }, 166 },
124 167
125 _eventListenersArrivedForTest: function() 168 /**
169 * @param {!WebInspector.DOMNode} node
170 * @return {!Promise<void>}
171 */
172 _setupFrameworkSupport: function(node)
126 { 173 {
174 return new Promise(setupFrameworksSupport.bind(this));
175
176 /**
177 * @param {function(?)} fulfill
178 * @param {function(*)} reject
179 * @this {!WebInspector.EventListenersWidget}
180 */
181 function setupFrameworksSupport(fulfill, reject)
182 {
183 var context = this._nodeExecutionContext(node);
184 var setupFunction = WebInspector.FrameworksSupport.eventListenersSet upFunction();
185 if (!context) {
186 reject("Empty context");
187 return;
188 }
189 if (this._isFrameworkSupportSetup in context) {
190 fulfill(undefined);
yurys 2015/08/14 17:24:21 fulfil()
kozy 2015/08/14 18:15:46 Acknowledged.
191 return;
192 }
193 context[this._isFrameworkSupportSetup] = true;
194 context.evaluate(setupFunction, WebInspector.EventListenersWidget._o bjectGroupName, false, false, true, false, fulfill);
195 }
127 }, 196 },
128 197
129 __proto__: WebInspector.ThrottledWidget.prototype 198 __proto__: WebInspector.ThrottledWidget.prototype
130 } 199 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698