Changeset 223321 in webkit for trunk/Source/JavaScriptCore


Ignore:
Timestamp:
Oct 14, 2017, 11:56:32 AM (8 years ago)
Author:
[email protected]
Message:

Web Inspector: provide a way to enable/disable event listeners
https://bugs.webkit.org/show_bug.cgi?id=177451

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

  • inspector/protocol/DOM.json:

Add setEventListenerDisabled command that enables/disables a specific event listener
during event dispatch. When a disabled event listener is fired, the listener's callback will
not be called.

Source/WebCore:

Test: inspector/dom/setEventListenerDisabled.html

  • dom/EventTarget.cpp:

(WebCore::EventTarget::fireEventListeners):
Add InspectorInstrumentation call to isEventListenerDisabled. If true, the event listener's
callback will not be called.

  • inspector/InspectorDOMAgent.h:
  • inspector/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::discardBindings):
(WebCore::InspectorDOMAgent::getEventListenersForNode):
(WebCore::InspectorDOMAgent::setEventListenerDisabled):
(WebCore::InspectorDOMAgent::buildObjectForEventListener):
(WebCore::InspectorDOMAgent::willRemoveEventListener):
(WebCore::InspectorDOMAgent::isEventListenerDisabled):
Introduce a mapping of EventListener* to InspectorEventListener, a struct for uniquely
identifying event listeners so they can be referenced from the frontend. We only add items
to this mapping when getEventListenersForNode is called, as that is when EventListener
data is sent to the frontend. This allows us to defer creating an Inspector "mirror" object
for each EventListener until it is needed. Items are removed whenever an event listener is
removed or when the document changes.

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::isEventListenerDisabled):

  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::willRemoveEventListenerImpl):
(WebCore::InspectorInstrumentation::isEventListenerDisabledImpl):
Pass additional parameters to InspectorDOMAgent so it can determine if the event listener
actually exists. If not, don't dispatch an event to the frontend as nothing will change.

Source/WebInspectorUI:

  • Localizations/en.lproj/localizedStrings.js:
  • UserInterface/Controllers/DOMTreeManager.js:

(WI.DOMTreeManager.prototype.setEventListenerDisabled):

  • UserInterface/Views/DOMNodeDetailsSidebarPanel.js:

(WI.DOMNodeDetailsSidebarPanel.prototype.attached):
(WI.DOMNodeDetailsSidebarPanel.prototype.detached):
(WI.DOMNodeDetailsSidebarPanel.prototype._eventListenersChanged):
(WI.DOMNodeDetailsSidebarPanel.prototype.addEventListeners): Deleted.
(WI.DOMNodeDetailsSidebarPanel.prototype.removeEventListeners): Deleted.
Listen for WI.DOMNode.Event.EventListenersChanged on all instances of WI.DOMNode, since we
will still want to refresh the event listeners section in the event that an event listener
is removed from a parent node.

  • UserInterface/Views/EventListenerSectionGroup.js:

(WI.EventListenerSectionGroup):
(WI.EventListenerSectionGroup.prototype._eventText):
(WI.EventListenerSectionGroup.prototype._nodeTextOrLink):
(WI.EventListenerSectionGroup.prototype._createDisabledToggleElement):
(WI.EventListenerSectionGroup.prototype._createDisabledToggleElement.updateTitle):

  • UserInterface/Views/EventListenerSectionGroup.css:

(.event-listener-section > .content input[type="checkbox"]):

  • UserInterface/Views/DetailsSectionSimpleRow.js:

(WI.DetailsSectionSimpleRow.prototype.get label):
(WI.DetailsSectionSimpleRow.prototype.set label):

LayoutTests:

  • inspector/dom/setEventListenerDisabled-expected.txt: Added.
  • inspector/dom/setEventListenerDisabled.html: Added.
Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r223318 r223321  
     12017-10-14  Devin Rousso  <[email protected]>
     2
     3        Web Inspector: provide a way to enable/disable event listeners
     4        https://bugs.webkit.org/show_bug.cgi?id=177451
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * inspector/protocol/DOM.json:
     9        Add `setEventListenerDisabled` command that enables/disables a specific event listener
     10        during event dispatch. When a disabled event listener is fired, the listener's callback will
     11        not be called.
     12
    1132017-10-14  Yusuke Suzuki  <[email protected]>
    214
  • trunk/Source/JavaScriptCore/inspector/protocol/DOM.json

    r222486 r223321  
    1313            "type": "integer",
    1414            "description": "Unique DOM node identifier used to reference a node that may not have been pushed to the front-end."
     15        },
     16        {
     17            "id": "EventListenerId",
     18            "type": "integer",
     19            "description": "Unique event listener identifier."
    1520        },
    1621        {
     
    7580            "description": "A structure holding event listener properties.",
    7681            "properties": [
     82                { "name": "eventListenerId", "$ref": "EventListenerId" },
    7783                { "name": "type", "type": "string", "description": "<code>EventListener</code>'s type." },
    7884                { "name": "useCapture", "type": "boolean", "description": "<code>EventListener</code>'s useCapture." },
     
    8490                { "name": "handler", "$ref": "Runtime.RemoteObject", "optional": true, "description": "Event handler function value." },
    8591                { "name": "passive", "type": "boolean", "optional": true, "description": "<code>EventListener</code>'s passive." },
    86                 { "name": "once", "type": "boolean", "optional": true, "description": "<code>EventListener</code>'s once." }
     92                { "name": "once", "type": "boolean", "optional": true, "description": "<code>EventListener</code>'s once." },
     93                { "name": "disabled", "type": "boolean", "optional": true }
    8794            ]
    8895        },
     
    260267        },
    261268        {
     269            "name": "setEventListenerDisabled",
     270            "description": "Enable/disable the given event listener. A disabled event listener will not fire.",
     271            "parameters": [
     272                { "name": "eventListenerId", "$ref": "EventListenerId" },
     273                { "name": "disabled", "type": "boolean" }
     274            ]
     275        },
     276        {
    262277            "name": "getAccessibilityPropertiesForNode",
    263278            "description": "Returns a dictionary of accessibility properties for the node.",
Note: See TracChangeset for help on using the changeset viewer.