⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243269 in webkit


Ignore:
Timestamp:
Mar 20, 2019, 5:55:40 PM (7 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Timeline should show when events preventDefault() was called on an event or not
https://bugs.webkit.org/show_bug.cgi?id=176824
<rdar://problem/34290931>

Reviewed by Timothy Hatcher.

Original patch by Joseph Pecoraro <Joseph Pecoraro>.

Source/WebCore:

Tests: inspector/timeline/timeline-event-CancelAnimationFrame.html

inspector/timeline/timeline-event-EventDispatch.html
inspector/timeline/timeline-event-FireAnimationFrame.html
inspector/timeline/timeline-event-RequestAnimationFrame.html
inspector/timeline/timeline-event-TimerFire.html
inspector/timeline/timeline-event-TimerInstall.html
inspector/timeline/timeline-event-TimerRemove.html

  • dom/EventTarget.cpp:

(WebCore::EventTarget::innerInvokeEventListeners):

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::dispatchEvent):
Include defaultPrevented when notifying inspector.

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::didDispatchEvent):
(WebCore::InspectorInstrumentation::didDispatchEventOnWindow):

  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::didDispatchEventImpl):
(WebCore::InspectorInstrumentation::didDispatchEventOnWindowImpl):
Pass defaultPrevented on to agent.

  • inspector/agents/InspectorTimelineAgent.h:
  • inspector/agents/InspectorTimelineAgent.cpp:

(WebCore::InspectorTimelineAgent::didDispatchEvent):
Append a boolean defaultPrevented property on the EventDispatch timeline record's data.

Source/WebInspectorUI:

  • Localizations/en.lproj/localizedStrings.js:

New string.

  • UserInterface/Controllers/TimelineManager.js:

(WI.TimelineManager.prototype._processRecord):
Include the whole data object as extra details.

  • UserInterface/Models/ScriptTimelineRecord.js:

(WI.ScriptTimelineRecord):
(WI.ScriptTimelineRecord.prototype.get eventType):
Wholesale copy of the extra data instead of just a single property.

  • UserInterface/Views/ScriptDetailsTimelineView.js:

(WI.ScriptDetailsTimelineView):
Give the name column more initial space, there is still extra space
after this adjustment but name is comfortably larger (and the most
likely to be expanded).

  • UserInterface/Views/ScriptTimelineDataGridNode.js:

(WI.ScriptTimelineDataGridNode.prototype.get subtitle):
Include "default prevented" as the event's subtitle if it was prevented.

LayoutTests:

  • inspector/timeline/resources/timeline-event-utilities.js: Added.

(finishRecording):
(TestPage.registerInitializer.InspectorTest.TimelineEvent.captureTimelineWithScript):
(TestPage.registerInitializer):
Helper code for creating a recording from a function.

  • inspector/timeline/timeline-event-CancelAnimationFrame.html: Added.
  • inspector/timeline/timeline-event-CancelAnimationFrame-expected.txt: Added.
  • inspector/timeline/timeline-event-EventDispatch.html: Added.
  • inspector/timeline/timeline-event-EventDispatch-expected.txt: Added.
  • inspector/timeline/timeline-event-FireAnimationFrame.html: Added.
  • inspector/timeline/timeline-event-FireAnimationFrame-expected.txt: Added.
  • inspector/timeline/timeline-event-RequestAnimationFrame.html: Added.
  • inspector/timeline/timeline-event-RequestAnimationFrame-expected.txt: Added.
  • inspector/timeline/timeline-event-TimerFire.html: Added.
  • inspector/timeline/timeline-event-TimerFire-expected.txt: Added.
  • inspector/timeline/timeline-event-TimerInstall.html: Added.
  • inspector/timeline/timeline-event-TimerInstall-expected.txt: Added.
  • inspector/timeline/timeline-event-TimerRemove.html: Added.
  • inspector/timeline/timeline-event-TimerRemove-expected.txt: Added.
Location:
trunk
Files:
15 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r243264 r243269  
     12019-03-20  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Timeline should show when events preventDefault() was called on an event or not
     4        https://bugs.webkit.org/show_bug.cgi?id=176824
     5        <rdar://problem/34290931>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        Original patch by Joseph Pecoraro <pecoraro@apple.com>.
     10
     11        * inspector/timeline/resources/timeline-event-utilities.js: Added.
     12        (finishRecording):
     13        (TestPage.registerInitializer.InspectorTest.TimelineEvent.captureTimelineWithScript):
     14        (TestPage.registerInitializer):
     15        Helper code for creating a recording from a function.
     16
     17        * inspector/timeline/timeline-event-CancelAnimationFrame.html: Added.
     18        * inspector/timeline/timeline-event-CancelAnimationFrame-expected.txt: Added.
     19        * inspector/timeline/timeline-event-EventDispatch.html: Added.
     20        * inspector/timeline/timeline-event-EventDispatch-expected.txt: Added.
     21        * inspector/timeline/timeline-event-FireAnimationFrame.html: Added.
     22        * inspector/timeline/timeline-event-FireAnimationFrame-expected.txt: Added.
     23        * inspector/timeline/timeline-event-RequestAnimationFrame.html: Added.
     24        * inspector/timeline/timeline-event-RequestAnimationFrame-expected.txt: Added.
     25        * inspector/timeline/timeline-event-TimerFire.html: Added.
     26        * inspector/timeline/timeline-event-TimerFire-expected.txt: Added.
     27        * inspector/timeline/timeline-event-TimerInstall.html: Added.
     28        * inspector/timeline/timeline-event-TimerInstall-expected.txt: Added.
     29        * inspector/timeline/timeline-event-TimerRemove.html: Added.
     30        * inspector/timeline/timeline-event-TimerRemove-expected.txt: Added.
     31
    1322019-03-20  Devin Rousso  <drousso@apple.com>
    233
  • trunk/Source/WebCore/ChangeLog

    r243266 r243269  
     12019-03-20  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Timeline should show when events preventDefault() was called on an event or not
     4        https://bugs.webkit.org/show_bug.cgi?id=176824
     5        <rdar://problem/34290931>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        Original patch by Joseph Pecoraro <pecoraro@apple.com>.
     10
     11        Tests: inspector/timeline/timeline-event-CancelAnimationFrame.html
     12               inspector/timeline/timeline-event-EventDispatch.html
     13               inspector/timeline/timeline-event-FireAnimationFrame.html
     14               inspector/timeline/timeline-event-RequestAnimationFrame.html
     15               inspector/timeline/timeline-event-TimerFire.html
     16               inspector/timeline/timeline-event-TimerInstall.html
     17               inspector/timeline/timeline-event-TimerRemove.html
     18
     19        * dom/EventTarget.cpp:
     20        (WebCore::EventTarget::innerInvokeEventListeners):
     21        * page/DOMWindow.cpp:
     22        (WebCore::DOMWindow::dispatchEvent):
     23        Include `defaultPrevented` when notifying inspector.
     24
     25        * inspector/InspectorInstrumentation.h:
     26        (WebCore::InspectorInstrumentation::didDispatchEvent):
     27        (WebCore::InspectorInstrumentation::didDispatchEventOnWindow):
     28        * inspector/InspectorInstrumentation.cpp:
     29        (WebCore::InspectorInstrumentation::didDispatchEventImpl):
     30        (WebCore::InspectorInstrumentation::didDispatchEventOnWindowImpl):
     31        Pass `defaultPrevented` on to agent.
     32
     33        * inspector/agents/InspectorTimelineAgent.h:
     34        * inspector/agents/InspectorTimelineAgent.cpp:
     35        (WebCore::InspectorTimelineAgent::didDispatchEvent):
     36        Append a boolean `defaultPrevented` property on the `EventDispatch` timeline record's data.
     37
    1382019-03-20  Antoine Quint  <graouts@apple.com>
    239
  • trunk/Source/WebCore/dom/EventTarget.cpp

    r242940 r243269  
    317317
    318318    if (contextIsDocument)
    319         InspectorInstrumentation::didDispatchEvent(willDispatchEventCookie);
     319        InspectorInstrumentation::didDispatchEvent(willDispatchEventCookie, event.defaultPrevented());
    320320}
    321321
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r243219 r243269  
    414414}
    415415
    416 void InspectorInstrumentation::didDispatchEventImpl(const InspectorInstrumentationCookie& cookie)
     416void InspectorInstrumentation::didDispatchEventImpl(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
    417417{
    418418    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
    419         timelineAgent->didDispatchEvent();
     419        timelineAgent->didDispatchEvent(defaultPrevented);
    420420}
    421421
     
    432432}
    433433
    434 void InspectorInstrumentation::didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie& cookie)
     434void InspectorInstrumentation::didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
    435435{
    436436    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
    437         timelineAgent->didDispatchEvent();
     437        timelineAgent->didDispatchEvent(defaultPrevented);
    438438}
    439439
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r243219 r243269  
    153153    static bool isEventListenerDisabled(EventTarget&, const AtomicString& eventType, EventListener&, bool capture);
    154154    static InspectorInstrumentationCookie willDispatchEvent(Document&, const Event&, bool hasEventListeners);
    155     static void didDispatchEvent(const InspectorInstrumentationCookie&);
     155    static void didDispatchEvent(const InspectorInstrumentationCookie&, bool defaultPrevented);
    156156    static void willHandleEvent(ScriptExecutionContext&, Event&, const RegisteredEventListener&);
    157157    static void didHandleEvent(ScriptExecutionContext&);
    158158    static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event&, DOMWindow&);
    159     static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&);
     159    static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&, bool defaultPrevented);
    160160    static void eventDidResetAfterDispatch(const Event&);
    161161    static InspectorInstrumentationCookie willEvaluateScript(Frame&, const String& url, int lineNumber, int columnNumber);
     
    348348    static void willHandleEventImpl(InstrumentingAgents&, Event&, const RegisteredEventListener&);
    349349    static void didHandleEventImpl(InstrumentingAgents&);
    350     static void didDispatchEventImpl(const InspectorInstrumentationCookie&);
     350    static void didDispatchEventImpl(const InspectorInstrumentationCookie&, bool defaultPrevented);
    351351    static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InstrumentingAgents&, const Event&, DOMWindow&);
    352     static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&);
     352    static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&, bool defaultPrevented);
    353353    static void eventDidResetAfterDispatchImpl(InstrumentingAgents&, const Event&);
    354354    static InspectorInstrumentationCookie willEvaluateScriptImpl(InstrumentingAgents&, Frame&, const String& url, int lineNumber, int columnNumber);
     
    794794}
    795795
    796 inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrumentationCookie& cookie)
     796inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
    797797{
    798798    FAST_RETURN_IF_NO_FRONTENDS(void());
    799799    if (cookie.isValid())
    800         didDispatchEventImpl(cookie);
     800        didDispatchEventImpl(cookie, defaultPrevented);
    801801}
    802802
     
    823823}
    824824
    825 inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorInstrumentationCookie& cookie)
     825inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
    826826{
    827827    FAST_RETURN_IF_NO_FRONTENDS(void());
    828828    if (cookie.isValid())
    829         didDispatchEventOnWindowImpl(cookie);
     829        didDispatchEventOnWindowImpl(cookie, defaultPrevented);
    830830}
    831831
  • trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp

    r243119 r243269  
    307307}
    308308
    309 void InspectorTimelineAgent::didDispatchEvent()
    310 {
     309void InspectorTimelineAgent::didDispatchEvent(bool defaultPrevented)
     310{
     311    auto& entry = m_recordStack.last();
     312    ASSERT(entry.type == TimelineRecordType::EventDispatch);
     313    entry.data->setBoolean("defaultPrevented"_s, defaultPrevented);
     314
    311315    didCompleteCurrentRecord(TimelineRecordType::EventDispatch);
    312316}
  • trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.h

    r243119 r243269  
    116116    void didCallFunction(Frame*);
    117117    void willDispatchEvent(const Event&, Frame*);
    118     void didDispatchEvent();
     118    void didDispatchEvent(bool defaultPrevented);
    119119    void willEvaluateScript(const String&, int lineNumber, int columnNumber, Frame&);
    120120    void didEvaluateScript(Frame&);
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r243163 r243269  
    21102110    fireEventListeners(event, EventInvokePhase::Capturing);
    21112111    fireEventListeners(event, EventInvokePhase::Bubbling);
    2112     InspectorInstrumentation::didDispatchEventOnWindow(cookie);
     2112    InspectorInstrumentation::didDispatchEventOnWindow(cookie, event.defaultPrevented());
    21132113    event.resetAfterDispatch();
    21142114}
  • trunk/Source/WebInspectorUI/ChangeLog

    r243264 r243269  
     12019-03-20  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Timeline should show when events preventDefault() was called on an event or not
     4        https://bugs.webkit.org/show_bug.cgi?id=176824
     5        <rdar://problem/34290931>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        Original patch by Joseph Pecoraro <pecoraro@apple.com>.
     10
     11        * Localizations/en.lproj/localizedStrings.js:
     12        New string.
     13
     14        * UserInterface/Controllers/TimelineManager.js:
     15        (WI.TimelineManager.prototype._processRecord):
     16        Include the whole data object as extra details.
     17
     18        * UserInterface/Models/ScriptTimelineRecord.js:
     19        (WI.ScriptTimelineRecord):
     20        (WI.ScriptTimelineRecord.prototype.get eventType):
     21        Wholesale copy of the extra data instead of just a single property.
     22
     23        * UserInterface/Views/ScriptDetailsTimelineView.js:
     24        (WI.ScriptDetailsTimelineView):
     25        Give the name column more initial space, there is still extra space
     26        after this adjustment but name is comfortably larger (and the most
     27        likely to be expanded).
     28
     29        * UserInterface/Views/ScriptTimelineDataGridNode.js:
     30        (WI.ScriptTimelineDataGridNode.prototype.get subtitle):
     31        Include "default prevented" as the event's subtitle if it was prevented.
     32
    1332019-03-20  Devin Rousso  <drousso@apple.com>
    234
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r243260 r243269  
    11811181localizedStrings["computed"] = "computed";
    11821182localizedStrings["default"] = "default";
     1183localizedStrings["default prevented"] = "default prevented";
    11831184localizedStrings["for changes to take effect"] = "for changes to take effect";
    11841185localizedStrings["invalid HAR"] = "invalid HAR";
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js

    r243024 r243269  
    698698                break;
    699699            case TimelineAgent.EventType.EventDispatch:
    700                 record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.EventDispatched, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.type, profileData);
     700                record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.EventDispatched, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.type, profileData, parentRecordPayload.data);
    701701                break;
    702702            case TimelineAgent.EventType.ObserverCallback:
  • trunk/Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js

    r243024 r243269  
    2626WI.ScriptTimelineRecord = class ScriptTimelineRecord extends WI.TimelineRecord
    2727{
    28     constructor(eventType, startTime, endTime, callFrames, sourceCodeLocation, details, profilePayload)
     28    constructor(eventType, startTime, endTime, callFrames, sourceCodeLocation, details, profilePayload, extraDetails)
    2929    {
    3030        super(WI.TimelineRecord.Type.Script, startTime, endTime, callFrames, sourceCodeLocation);
     
    3939        this._profilePayload = profilePayload || null;
    4040        this._profile = null;
     41        this._extraDetails = extraDetails || null;
    4142
    4243        // COMPATIBILITY(iOS 9): Before the ScriptProfilerAgent we did not have sample data. Return NaN to match old behavior.
     
    7778    // Public
    7879
    79     get eventType()
    80     {
    81         return this._eventType;
    82     }
    83 
    84     get details()
    85     {
    86         return this._details;
    87     }
     80    get eventType() { return this._eventType; }
     81    get details() { return this._details; }
     82    get extraDetails() { return this._extraDetails; }
     83    get callCountOrSamples() { return this._callCountOrSamples; }
    8884
    8985    get profile()
     
    9187        this._initializeProfileFromPayload();
    9288        return this._profile;
    93     }
    94 
    95     get callCountOrSamples()
    96     {
    97         return this._callCountOrSamples;
    9889    }
    9990
  • trunk/Source/WebInspectorUI/UserInterface/Views/ScriptDetailsTimelineView.js

    r243213 r243269  
    3535
    3636        columns.name.title = WI.UIString("Name");
    37         columns.name.width = "10%";
     37        columns.name.width = "30%";
    3838        columns.name.icon = true;
    3939        columns.name.disclosure = true;
  • trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js

    r243213 r243269  
    8787            else
    8888                this._subtitle = WI.UIString("%s delay").format(timeoutString);
     89        } else if (this._record.eventType === WI.ScriptTimelineRecord.EventType.EventDispatched) {
     90            if (this._record.extraDetails && this._record.extraDetails.defaultPrevented)
     91                this._subtitle = WI.UIString("default prevented");
    8992        }
    9093
Note: See TracChangeset for help on using the changeset viewer.