Diff
Modified: trunk/LayoutTests/ChangeLog (235388 => 235389)
--- trunk/LayoutTests/ChangeLog 2018-08-27 18:47:01 UTC (rev 235388)
+++ trunk/LayoutTests/ChangeLog 2018-08-27 18:49:42 UTC (rev 235389)
@@ -1,3 +1,13 @@
+2018-08-27 Devin Rousso <[email protected]>
+
+ Web Inspector: provide autocompletion for event breakpoints
+ https://bugs.webkit.org/show_bug.cgi?id=188717
+
+ Reviewed by Brian Burg.
+
+ * inspector/dom/getSupportedEventNames-expected.txt: Added.
+ * inspector/dom/getSupportedEventNames.html: Added.
+
2018-08-27 Youenn Fablet <[email protected]>
Update WPT tools to 87329a1
Added: trunk/LayoutTests/inspector/dom/getSupportedEventNames-expected.txt (0 => 235389)
--- trunk/LayoutTests/inspector/dom/getSupportedEventNames-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/dom/getSupportedEventNames-expected.txt 2018-08-27 18:49:42 UTC (rev 235389)
@@ -0,0 +1,4 @@
+PASS: Should have recieved at least two event names.
+PASS: Should have recieved the "click" event name.
+PASS: Should have recieved the "load" event name.
+
Added: trunk/LayoutTests/inspector/dom/getSupportedEventNames.html (0 => 235389)
--- trunk/LayoutTests/inspector/dom/getSupportedEventNames.html (rev 0)
+++ trunk/LayoutTests/inspector/dom/getSupportedEventNames.html 2018-08-27 18:49:42 UTC (rev 235389)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+ InspectorProtocol.sendCommand("DOM.getSupportedEventNames", {}, (messageObject) => {
+ if ("error" in messageObject)
+ ProtocolTest.log(messageObject.error.message);
+ else {
+ let eventNames = messageObject["result"]["eventNames"];
+ ProtocolTest.expectGreaterThan(eventNames.length, 2, "Should have recieved at least two event names.");
+ ProtocolTest.expectThat(eventNames.includes("click"), "Should have recieved the \"click\" event name.");
+ ProtocolTest.expectThat(eventNames.includes("load"), "Should have recieved the \"load\" event name.");
+ }
+
+ ProtocolTest.completeTest();
+ });
+}
+</script>
+</head>
+<body _onload_="runTest()">
+</body>
+</html>
Modified: trunk/Source/_javascript_Core/ChangeLog (235388 => 235389)
--- trunk/Source/_javascript_Core/ChangeLog 2018-08-27 18:47:01 UTC (rev 235388)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-08-27 18:49:42 UTC (rev 235389)
@@ -1,3 +1,13 @@
+2018-08-27 Devin Rousso <[email protected]>
+
+ Web Inspector: provide autocompletion for event breakpoints
+ https://bugs.webkit.org/show_bug.cgi?id=188717
+
+ Reviewed by Brian Burg.
+
+ * inspector/protocol/DOM.json:
+ Add `getSupportedEventNames` command.
+
2018-08-27 Keith Rollin <[email protected]>
Build system support for LTO
Modified: trunk/Source/_javascript_Core/inspector/protocol/DOM.json (235388 => 235389)
--- trunk/Source/_javascript_Core/inspector/protocol/DOM.json 2018-08-27 18:47:01 UTC (rev 235388)
+++ trunk/Source/_javascript_Core/inspector/protocol/DOM.json 2018-08-27 18:49:42 UTC (rev 235389)
@@ -256,6 +256,13 @@
]
},
{
+ "name": "getSupportedEventNames",
+ "description": "Gets the list of builtin DOM event names.",
+ "returns": [
+ { "name": "eventNames", "type": "array", "items": { "type": "string" } }
+ ]
+ },
+ {
"name": "getEventListenersForNode",
"description": "Returns event listeners relevant to the node.",
"parameters": [
Modified: trunk/Source/WebCore/ChangeLog (235388 => 235389)
--- trunk/Source/WebCore/ChangeLog 2018-08-27 18:47:01 UTC (rev 235388)
+++ trunk/Source/WebCore/ChangeLog 2018-08-27 18:49:42 UTC (rev 235389)
@@ -1,3 +1,16 @@
+2018-08-27 Devin Rousso <[email protected]>
+
+ Web Inspector: provide autocompletion for event breakpoints
+ https://bugs.webkit.org/show_bug.cgi?id=188717
+
+ Reviewed by Brian Burg.
+
+ Test: inspector/dom/getSupportedEventNames.html
+
+ * inspector/agents/InspectorDOMAgent.h:
+ * inspector/agents/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::getSupportedEventNames): Added.
+
2018-08-27 Keith Rollin <[email protected]>
Build system support for LTO
Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp (235388 => 235389)
--- trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp 2018-08-27 18:47:01 UTC (rev 235388)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp 2018-08-27 18:49:42 UTC (rev 235389)
@@ -56,6 +56,7 @@
#include "Element.h"
#include "Event.h"
#include "EventListener.h"
+#include "EventNames.h"
#include "Frame.h"
#include "FrameTree.h"
#include "HTMLElement.h"
@@ -829,6 +830,15 @@
m_domEditor->replaceWholeText(downcast<Text>(*node), value, errorString);
}
+void InspectorDOMAgent::getSupportedEventNames(ErrorString&, RefPtr<JSON::ArrayOf<String>>& eventNames)
+{
+ eventNames = JSON::ArrayOf<String>::create();
+
+#define DOM_EVENT_NAMES_ADD(name) eventNames->addItem(#name);
+ DOM_EVENT_NAMES_FOR_EACH(DOM_EVENT_NAMES_ADD)
+#undef DOM_EVENT_NAMES_ADD
+}
+
void InspectorDOMAgent::getEventListenersForNode(ErrorString& errorString, int nodeId, const String* objectGroup, RefPtr<JSON::ArrayOf<Inspector::Protocol::DOM::EventListener>>& listenersArray)
{
listenersArray = JSON::ArrayOf<Inspector::Protocol::DOM::EventListener>::create();
Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.h (235388 => 235389)
--- trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.h 2018-08-27 18:47:01 UTC (rev 235388)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.h 2018-08-27 18:49:42 UTC (rev 235389)
@@ -123,6 +123,7 @@
void setOuterHTML(ErrorString&, int nodeId, const String& outerHTML) override;
void insertAdjacentHTML(ErrorString&, int nodeId, const String& position, const String& html) override;
void setNodeValue(ErrorString&, int nodeId, const String& value) override;
+ void getSupportedEventNames(ErrorString&, RefPtr<JSON::ArrayOf<String>>& eventNames) override;
void getEventListenersForNode(ErrorString&, int nodeId, const WTF::String* objectGroup, RefPtr<JSON::ArrayOf<Inspector::Protocol::DOM::EventListener>>& listenersArray) override;
void setEventListenerDisabled(ErrorString&, int eventListenerId, bool disabled) override;
void setBreakpointForEventListener(ErrorString&, int eventListenerId) override;
Modified: trunk/Source/WebInspectorUI/ChangeLog (235388 => 235389)
--- trunk/Source/WebInspectorUI/ChangeLog 2018-08-27 18:47:01 UTC (rev 235388)
+++ trunk/Source/WebInspectorUI/ChangeLog 2018-08-27 18:49:42 UTC (rev 235389)
@@ -1,3 +1,22 @@
+2018-08-27 Devin Rousso <[email protected]>
+
+ Web Inspector: provide autocompletion for event breakpoints
+ https://bugs.webkit.org/show_bug.cgi?id=188717
+
+ Reviewed by Brian Burg.
+
+ * UserInterface/Controllers/DOMTreeManager.js:
+ (WI.DOMTreeManager):
+ (WI.DOMTreeManager.prototype.getSupportedEventNames): Added.
+
+ * UserInterface/Views/EventBreakpointPopover.js:
+ (WI.EventBreakpointPopover):
+ (WI.EventBreakpointPopover.prototype.show):
+ (WI.EventBreakpointPopover.prototype.dismiss): Added.
+ (WI.EventBreakpointPopover.prototype.completionSuggestionsClickedCompletion): Added.
+ (WI.EventBreakpointPopover.prototype._presentOverTargetElement):
+ (WI.EventBreakpointPopover.prototype._showSuggestionsView): Added.
+
2018-08-27 Keith Rollin <[email protected]>
Build system support for LTO
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js (235388 => 235389)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js 2018-08-27 18:47:01 UTC (rev 235388)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js 2018-08-27 18:49:42 UTC (rev 235389)
@@ -546,6 +546,19 @@
DOMAgent.setInspectedNode(node.id, callback);
}
+ getSupportedEventNames(callback)
+ {
+ if (!DOMAgent.getSupportedEventNames)
+ return Promise.resolve(new Set);
+
+ if (!this._getSupportedEventNamesPromise) {
+ this._getSupportedEventNamesPromise = DOMAgent.getSupportedEventNames()
+ .then(({eventNames}) => new Set(eventNames));
+ }
+
+ return this._getSupportedEventNamesPromise;
+ }
+
setEventListenerDisabled(eventListener, disabled)
{
DOMAgent.setEventListenerDisabled(eventListener.eventListenerId, disabled, (error) => {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/EventBreakpointPopover.js (235388 => 235389)
--- trunk/Source/WebInspectorUI/UserInterface/Views/EventBreakpointPopover.js 2018-08-27 18:47:01 UTC (rev 235388)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/EventBreakpointPopover.js 2018-08-27 18:49:42 UTC (rev 235389)
@@ -31,6 +31,9 @@
this._breakpoint = null;
+ this._currentCompletions = [];
+ this._suggestionsView = new WI.CompletionSuggestionsView(this, {preventBlur: true});
+
this._targetElement = null;
this._preferredEdges = null;
@@ -82,12 +85,41 @@
this._domEventNameInputElement.placeholder = WI.UIString("Example: ā%sā").format("click");
this._domEventNameInputElement.spellcheck = false;
this._domEventNameInputElement.addEventListener("keydown", (event) => {
- if (!isEnterKey(event))
- return;
+ if (isEnterKey(event) || event.key === "Tab") {
+ this._result = WI.InputPopover.Result.Committed;
- this.dismiss();
+ if (this._suggestionsView.visible && this._suggestionsView.selectedIndex < this._currentCompletions.length)
+ this._domEventNameInputElement.value = this._currentCompletions[this._suggestionsView.selectedIndex];
+
+ this.dismiss();
+ } else if ((event.key === "ArrowUp" || event.key === "ArrowDown") && this._suggestionsView.visible) {
+ event.stop();
+
+ if (event.key === "ArrowDown")
+ this._suggestionsView.selectNext();
+ else
+ this._suggestionsView.selectPrevious();
+ }
});
+ this._domEventNameInputElement.addEventListener("input", (event) => {
+ WI.domTreeManager.getSupportedEventNames()
+ .then((eventNames) => {
+ this._currentCompletions = [];
+ for (let eventName of eventNames) {
+ if (eventName.toLowerCase().startsWith(this._domEventNameInputElement.value))
+ this._currentCompletions.push(eventName);
+ }
+ if (!this._currentCompletions.length) {
+ this._suggestionsView.hide();
+ return;
+ }
+
+ this._suggestionsView.update(this._currentCompletions);
+ this._showSuggestionsView();
+ });
+ });
+
this.content = contentElement;
this._presentOverTargetElement();
@@ -116,8 +148,19 @@
this._breakpoint = new WI.EventBreakpoint(type, value);
super.dismiss();
+
+ this._suggestionsView.hide();
}
+ // CompletionSuggestionsView delegate
+
+ completionSuggestionsClickedCompletion(suggestionsView, selectedText)
+ {
+ this._domEventNameInputElement.value = selectedText;
+
+ this.dismiss();
+ }
+
// Private
_presentOverTargetElement()
@@ -131,8 +174,22 @@
_handleTypeSelectChange(event)
{
- this._domEventNameInputElement.hidden = this._typeSelectElement.value !== WI.EventBreakpoint.Type.Listener;
+ let listenerTypeSelected = this._typeSelectElement.value === WI.EventBreakpoint.Type.Listener;
+ this._domEventNameInputElement.hidden = !listenerTypeSelected;
this.update();
+
+ if (listenerTypeSelected) {
+ this._domEventNameInputElement.focus();
+
+ if (this._domEventNameInputElement.value)
+ this._showSuggestionsView();
+ } else
+ this._suggestionsView.hide();
}
+
+ _showSuggestionsView()
+ {
+ this._suggestionsView.show(WI.Rect.rectFromClientRect(this._domEventNameInputElement.getBoundingClientRect()));
+ }
};