WebKit Bugzilla
Attachment 347430 Details for
Bug 188717
: Web Inspector: provide autocompletion for event breakpoints
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188717-20180817221703.patch (text/plain), 13.89 KB, created by
Devin Rousso
on 2018-08-17 22:17:04 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2018-08-17 22:17:04 PDT
Size:
13.89 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 48a6aae498a895d896aa5503ed2a0da9aa093022..16aa00b34e14089d12f19b02d820282b3a416b26 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,13 @@ >+2018-08-17 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: provide autocompletion for event breakpoints >+ https://bugs.webkit.org/show_bug.cgi?id=188717 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * inspector/protocol/DOM.json: >+ Add `getSupportedEventNames` command. >+ > 2018-08-17 Yusuke Suzuki <yusukesuzuki@slowstart.org> and Fujii Hironori <Hironori.Fujii@sony.com> > > [JSC] Add GPRReg::InvalidGPRReg and FPRReg::InvalidFPRReg >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 40a21a5d39fcd9359254c1122ccdad8c0c3021c4..39f9f5886fa424cf5a4c20860425e4dfb3a2e30f 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,16 @@ >+2018-08-17 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: provide autocompletion for event breakpoints >+ https://bugs.webkit.org/show_bug.cgi?id=188717 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: inspector/dom/getSupportedEventNames.html >+ >+ * inspector/agents/InspectorDOMAgent.h: >+ * inspector/agents/InspectorDOMAgent.cpp: >+ (WebCore::InspectorDOMAgent::getSupportedEventNames): Added. >+ > 2018-08-16 Ryosuke Niwa <rniwa@webkit.org> > > Replace canBubble and cancelable booleans in Event by enum classes >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 1d0a6261761057810a38ccd216ac3007a8d8ce7a..5e6bd623df2796b3731ba53188c57b19d822bb78 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,22 @@ >+2018-08-17 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: provide autocompletion for event breakpoints >+ https://bugs.webkit.org/show_bug.cgi?id=188717 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * 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-16 Devin Rousso <drousso@apple.com> > > Web Inspector: support breakpoints for arbitrary event names >diff --git a/Source/JavaScriptCore/inspector/protocol/DOM.json b/Source/JavaScriptCore/inspector/protocol/DOM.json >index bdd988d81325e5cc45b9554157f568498c3ae60e..9011cc9054c05008eaf2abc169c4047bcfb47904 100644 >--- a/Source/JavaScriptCore/inspector/protocol/DOM.json >+++ b/Source/JavaScriptCore/inspector/protocol/DOM.json >@@ -254,6 +254,13 @@ > { "name": "name", "type": "string", "description": "Name of the attribute to remove." } > ] > }, >+ { >+ "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.", >diff --git a/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp b/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp >index 9869b63871aa14d097a49ebf7e06c955715d39f1..06fa87a5c8cf4f07b41238a25d5ce88fc1209fc3 100644 >--- a/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp >+++ b/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp >@@ -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 @@ void InspectorDOMAgent::setNodeValue(ErrorString& errorString, int nodeId, const > 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(); >diff --git a/Source/WebCore/inspector/agents/InspectorDOMAgent.h b/Source/WebCore/inspector/agents/InspectorDOMAgent.h >index 89bd9d1832b59199c261b81c5c35f1a8228ba0b9..50ff95e45764f963c145c30b5989a7efba83ef91 100644 >--- a/Source/WebCore/inspector/agents/InspectorDOMAgent.h >+++ b/Source/WebCore/inspector/agents/InspectorDOMAgent.h >@@ -123,6 +123,7 @@ public: > 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 getAccessibilityPropertiesForNode(ErrorString&, int nodeId, RefPtr<Inspector::Protocol::DOM::AccessibilityProperties>& axProperties) override; >diff --git a/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js b/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js >index dc56f939409ba61983f1572ccdaf168dff0d7306..bf359006ae81dc5fa660362edc4da33207e32ef7 100644 >--- a/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js >+++ b/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js >@@ -36,6 +36,8 @@ WI.DOMTreeManager = class DOMTreeManager extends WI.Object > { > super(); > >+ this._supportedEventNames = new Set; >+ > this._idToDOMNode = {}; > this._document = null; > this._attributeLoadNodeIds = {}; >@@ -538,6 +540,29 @@ WI.DOMTreeManager = class DOMTreeManager extends WI.Object > DOMAgent.setInspectedNode(node.id, callback); > } > >+ getSupportedEventNames(callback) >+ { >+ if (this._supportedEventNames.size || !DOMAgent.getSupportedEventNames) { >+ callback(this._supportedEventNames); >+ return; >+ } >+ >+ if (this._getSupportedEventNamesPromise) { >+ this._getSupportedEventNamesPromise.then(() => { >+ callback(this._supportedEventNames); >+ }); >+ return; >+ } >+ >+ this._getSupportedEventNamesPromise = DOMAgent.getSupportedEventNames().then(({eventNames}) => { >+ this._getSupportedEventNamesPromise = null; >+ >+ this._supportedEventNames = new Set(eventNames); >+ >+ callback(this._supportedEventNames); >+ }); >+ } >+ > setEventListenerDisabled(eventListenerId, disabled) > { > DOMAgent.setEventListenerDisabled(eventListenerId, disabled); >diff --git a/Source/WebInspectorUI/UserInterface/Views/EventBreakpointPopover.js b/Source/WebInspectorUI/UserInterface/Views/EventBreakpointPopover.js >index 5f75b513d3d6b1f4c0dea9b29699dbdbe189e069..8eec2ca94bdcf77eae167789899861616282db82 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/EventBreakpointPopover.js >+++ b/Source/WebInspectorUI/UserInterface/Views/EventBreakpointPopover.js >@@ -32,7 +32,9 @@ WI.EventBreakpointPopover = class EventBreakpointPopover extends WI.Popover > this._result = WI.InputPopover.Result.None; > this._value = null; > >- this._codeMirror = null; >+ this._currentCompletions = []; >+ this._suggestionsView = new WI.CompletionSuggestionsView(this, {preventBlur: true}); >+ > this._targetElement = null; > this._preferredEdges = null; > >@@ -60,13 +62,38 @@ WI.EventBreakpointPopover = class EventBreakpointPopover extends WI.Popover > this._inputElement.placeholder = "click"; > this._inputElement.spellcheck = false; > this._inputElement.addEventListener("keydown", (event) => { >- if (!isEnterKey(event)) >- return; >- >- this._result = WI.InputPopover.Result.Committed; >- this._value = event.target.value.trim(); >- >- this.dismiss(); >+ if (isEnterKey(event) || event.key === "Tab") { >+ this._result = WI.InputPopover.Result.Committed; >+ >+ if (this._suggestionsView.visible && this._suggestionsView.selectedIndex < this._currentCompletions.length) >+ this._value = this._currentCompletions[this._suggestionsView.selectedIndex]; >+ else >+ this._value = this._inputElement.value; >+ >+ 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._inputElement.addEventListener("input", (event) => { >+ WI.domTreeManager.getSupportedEventNames((eventNames) => { >+ this._currentCompletions = []; >+ for (let eventName of eventNames) { >+ if (eventName.toLowerCase().startsWith(this._inputElement.value)) >+ this._currentCompletions.push(eventName); >+ } >+ >+ if (this._currentCompletions.length) { >+ this._suggestionsView.update(this._currentCompletions); >+ this._showSuggestionsView(); >+ } else >+ this._suggestionsView.hide(); >+ }); > }); > > this.content = contentElement; >@@ -74,6 +101,23 @@ WI.EventBreakpointPopover = class EventBreakpointPopover extends WI.Popover > this._presentOverTargetElement(); > } > >+ dismiss() >+ { >+ super.dismiss(); >+ >+ this._suggestionsView.hide(); >+ } >+ >+ // CompletionSuggestionsView delegate >+ >+ completionSuggestionsClickedCompletion(suggestionsView, selectedText) >+ { >+ this._result = WI.InputPopover.Result.Committed; >+ this._value = selectedText; >+ >+ this.dismiss(); >+ } >+ > // Private > > _presentOverTargetElement() >@@ -84,6 +128,14 @@ WI.EventBreakpointPopover = class EventBreakpointPopover extends WI.Popover > let targetFrame = WI.Rect.rectFromClientRect(this._targetElement.getBoundingClientRect()); > this.present(targetFrame, this._preferredEdges); > >- this._inputElement.select(); >+ this._inputElement.focus(); >+ >+ if (this._inputElement.value) >+ this._showSuggestionsView(); > } >+ >+ _showSuggestionsView() >+ { >+ this._suggestionsView.show(WI.Rect.rectFromClientRect(this._inputElement.getBoundingClientRect())); >+ } > }; >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 106b4fba6f7b10464a51b0365490509e86040805..82536edad80a49a79b9b6d53e64243b95ead1fae 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+2018-08-17 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: provide autocompletion for event breakpoints >+ https://bugs.webkit.org/show_bug.cgi?id=188717 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * inspector/dom/getSupportedEventNames-expected.txt: Added. >+ * inspector/dom/getSupportedEventNames.html: Added. >+ > 2018-08-17 Devin Rousso <drousso@apple.com> > > Marked inspector/dom-debugger/event-breakpoint-with-navigation.html as flaky. >diff --git a/LayoutTests/inspector/dom/getSupportedEventNames-expected.txt b/LayoutTests/inspector/dom/getSupportedEventNames-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..2cb8771a50c1a42b7929a80abf42b1ae0f7a2181 >--- /dev/null >+++ b/LayoutTests/inspector/dom/getSupportedEventNames-expected.txt >@@ -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. >+ >diff --git a/LayoutTests/inspector/dom/getSupportedEventNames.html b/LayoutTests/inspector/dom/getSupportedEventNames.html >new file mode 100644 >index 0000000000000000000000000000000000000000..4ddcae22a01e448025550b13512b42252d7f247e >--- /dev/null >+++ b/LayoutTests/inspector/dom/getSupportedEventNames.html >@@ -0,0 +1,25 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../http/tests/inspector/resources/protocol-test.js"></script> >+<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>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188717
:
347426
|
347427
|
347430
|
348174