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

Changeset 239397 in webkit


Ignore:
Timestamp:
Dec 19, 2018, 3:17:31 PM (8 years ago)
Author:
Simon Fraser
Message:

Web Inspector: Timelines: correctly label Intersection Observer callbacks
​https://bugs.webkit.org/show_bug.cgi?id=192669
<rdar://problem/46702490>

Reviewed by Joseph Pecoraro.

Add InspectorInstrumentation::willFireObserverCallback() and use it to wrap calls
to Intersection Observer, Performance Observer and Mutation Observer callbacks so
that they get correctly labeled in the Inspector timeline.

Source/JavaScriptCore:

  • inspector/protocol/Timeline.json:

Source/WebCore:

  • dom/MutationObserver.cpp:

(WebCore::MutationObserver::deliver):

  • en.lproj/Localizable.strings:
  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::willFireObserverCallbackImpl):
(WebCore::InspectorInstrumentation::didFireObserverCallbackImpl):

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::willFireObserverCallback):
(WebCore::InspectorInstrumentation::didFireObserverCallback):

  • inspector/TimelineRecordFactory.cpp:

(WebCore::TimelineRecordFactory::createObserverCallbackData):

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

(WebCore::InspectorTimelineAgent::willFireObserverCallback):
(WebCore::InspectorTimelineAgent::didFireObserverCallback):
(WebCore::toProtocol):

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

(WebCore::IntersectionObserver::notify):

  • page/PerformanceObserver.cpp:

(WebCore::PerformanceObserver::deliver):

Source/WebInspectorUI:

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

(WI.TimelineManager.prototype._processRecord):

  • UserInterface/Models/ScriptTimelineRecord.js:

(WI.ScriptTimelineRecord.EventType.displayName):

  • UserInterface/Views/TimelineTabContentView.js:

(WI.TimelineTabContentView.iconClassNameForRecord):

Location:
trunk/Source
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r239392 r239397  
     12018-12-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Web Inspector: Timelines: correctly label Intersection Observer callbacks
     4        https://bugs.webkit.org/show_bug.cgi?id=192669
     5        <rdar://problem/46702490>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        Add InspectorInstrumentation::willFireObserverCallback() and use it to wrap calls
     10        to Intersection Observer, Performance Observer and Mutation Observer callbacks so
     11        that they get correctly labeled in the Inspector timeline.
     12
     13        * inspector/protocol/Timeline.json:
     14
    1152018-12-18  Mark Lam  <mark.lam@apple.com>
    216
  • trunk/Source/JavaScriptCore/inspector/protocol/Timeline.json

    r224634 r239397  
    2929                "RequestAnimationFrame",
    3030                "CancelAnimationFrame",
    31                 "FireAnimationFrame"
     31                "FireAnimationFrame",
     32                "ObserverCallback"
    3233            ]
    3334        },
  • trunk/Source/WebCore/ChangeLog

    r239395 r239397  
     12018-12-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Web Inspector: Timelines: correctly label Intersection Observer callbacks
     4        https://bugs.webkit.org/show_bug.cgi?id=192669
     5        <rdar://problem/46702490>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        Add InspectorInstrumentation::willFireObserverCallback() and use it to wrap calls
     10        to Intersection Observer, Performance Observer and Mutation Observer callbacks so
     11        that they get correctly labeled in the Inspector timeline.
     12
     13        * dom/MutationObserver.cpp:
     14        (WebCore::MutationObserver::deliver):
     15        * en.lproj/Localizable.strings:
     16        * inspector/InspectorInstrumentation.cpp:
     17        (WebCore::InspectorInstrumentation::willFireObserverCallbackImpl):
     18        (WebCore::InspectorInstrumentation::didFireObserverCallbackImpl):
     19        * inspector/InspectorInstrumentation.h:
     20        (WebCore::InspectorInstrumentation::willFireObserverCallback):
     21        (WebCore::InspectorInstrumentation::didFireObserverCallback):
     22        * inspector/TimelineRecordFactory.cpp:
     23        (WebCore::TimelineRecordFactory::createObserverCallbackData):
     24        * inspector/TimelineRecordFactory.h:
     25        * inspector/agents/InspectorTimelineAgent.cpp:
     26        (WebCore::InspectorTimelineAgent::willFireObserverCallback):
     27        (WebCore::InspectorTimelineAgent::didFireObserverCallback):
     28        (WebCore::toProtocol):
     29        * inspector/agents/InspectorTimelineAgent.h:
     30        * page/IntersectionObserver.cpp:
     31        (WebCore::IntersectionObserver::notify):
     32        * page/PerformanceObserver.cpp:
     33        (WebCore::PerformanceObserver::deliver):
     34
    1352018-12-19  Claudio Saavedra  <csaavedra@igalia.com>
    236
  • trunk/Source/WebCore/dom/MutationObserver.cpp

    r236825 r239397  
    3737#include "GCReachableRef.h"
    3838#include "HTMLSlotElement.h"
     39#include "InspectorInstrumentation.h"
    3940#include "Microtasks.h"
    4041#include "MutationCallback.h"
    … …  
    245246
    246247    // FIXME: Keep mutation observer callback as long as its observed nodes are alive. See https://webkit.org/b/179224.
    247     if (m_callback->hasCallback())
     248    if (m_callback->hasCallback()) {
     249        auto* context = m_callback->scriptExecutionContext();
     250        if (!context)
     251            return;
     252
     253        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireObserverCallback(*context, "MutationObserver"_s);
    248254        m_callback->handleEvent(*this, records, *this);
     255        InspectorInstrumentation::didFireObserverCallback(cookie);
     256    }
    249257}
    250258
  • trunk/Source/WebCore/en.lproj/Localizable.strings

    r239015 r239397  
    647647"Show Controls" = "Show Controls";
    648648
     649/* Action from safe browsing warning */
     650"Show Details" = "Show Details";
     651
    649652/* Show fonts context menu item */
    650653"Show Fonts" = "Show Fonts";
    … …  
    656659"Show Substitutions" = "Show Substitutions";
    657660
    658 /* Action from safe browsing warning */
    659 "Show Details" = "Show Details";
    660 
    661661/* Title of the context menu item to show when PDFPlugin was used instead of a blocked plugin */
    662662"Show in blocked plug-in" = "Show in blocked plug-in";
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r238570 r239397  
    11001100}
    11011101
     1102InspectorInstrumentationCookie InspectorInstrumentation::willFireObserverCallbackImpl(InstrumentingAgents& instrumentingAgents, const String& callbackType, ScriptExecutionContext& context)
     1103{
     1104    int timelineAgentId = 0;
     1105    if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent()) {
     1106        timelineAgent->willFireObserverCallback(callbackType, frameForScriptExecutionContext(&context));
     1107        timelineAgentId = timelineAgent->id();
     1108    }
     1109    return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
     1110}
     1111
     1112void InspectorInstrumentation::didFireObserverCallbackImpl(const InspectorInstrumentationCookie& cookie)
     1113{
     1114    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
     1115        timelineAgent->didFireObserverCallback();
     1116}
     1117
    11021118void InspectorInstrumentation::registerInstrumentingAgents(InstrumentingAgents& instrumentingAgents)
    11031119{
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r238771 r239397  
    236236    static void didFireAnimationFrame(const InspectorInstrumentationCookie&);
    237237
     238    static InspectorInstrumentationCookie willFireObserverCallback(ScriptExecutionContext&, const String& callbackType);
     239    static void didFireObserverCallback(const InspectorInstrumentationCookie&);
     240
    238241    static void didOpenDatabase(ScriptExecutionContext*, RefPtr<Database>&&, const String& domain, const String& name, const String& version);
    239242
    … …  
    408411    static void didFireAnimationFrameImpl(const InspectorInstrumentationCookie&);
    409412
     413    static InspectorInstrumentationCookie willFireObserverCallbackImpl(InstrumentingAgents&, const String&, ScriptExecutionContext&);
     414    static void didFireObserverCallbackImpl(const InspectorInstrumentationCookie&);
     415
    410416    static void didOpenDatabaseImpl(InstrumentingAgents&, RefPtr<Database>&&, const String& domain, const String& name, const String& version);
    411417
    … …  
    14111417inline InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrame(Document& document, int callbackId)
    14121418{
     1419    FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
    14131420    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
    14141421        return willFireAnimationFrameImpl(*instrumentingAgents, callbackId, document);
    … …  
    14211428    if (cookie.isValid())
    14221429        didFireAnimationFrameImpl(cookie);
     1430}
     1431
     1432inline InspectorInstrumentationCookie InspectorInstrumentation::willFireObserverCallback(ScriptExecutionContext& context, const String& callbackType)
     1433{
     1434    FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
     1435    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
     1436        return willFireObserverCallbackImpl(*instrumentingAgents, callbackType, context);
     1437    return InspectorInstrumentationCookie();
     1438}
     1439
     1440inline void InspectorInstrumentation::didFireObserverCallback(const InspectorInstrumentationCookie& cookie)
     1441{
     1442    FAST_RETURN_IF_NO_FRONTENDS(void());
     1443    if (cookie.isValid())
     1444        didFireObserverCallbackImpl(cookie);
    14231445}
    14241446
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp

    r234586 r239397  
    126126}
    127127
     128Ref<JSON::Object> TimelineRecordFactory::createObserverCallbackData(const String& callbackType)
     129{
     130    Ref<JSON::Object> data = JSON::Object::create();
     131    data->setString("type"_s, callbackType);
     132    return data;
     133}
     134
    128135static Ref<JSON::Array> createQuad(const FloatQuad& quad)
    129136{
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.h

    r225231 r239397  
    5959    static Ref<JSON::Object> createTimeStampData(const String&);
    6060    static Ref<JSON::Object> createAnimationFrameData(int callbackId);
     61    static Ref<JSON::Object> createObserverCallbackData(const String& callbackType);
    6162    static Ref<JSON::Object> createPaintData(const FloatQuad&);
    6263
  • trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp

    r239266 r239397  
    598598}
    599599
     600void InspectorTimelineAgent::willFireObserverCallback(const String& callbackType, Frame* frame)
     601{
     602    pushCurrentRecord(TimelineRecordFactory::createObserverCallbackData(callbackType), TimelineRecordType::ObserverCallback, false, frame);
     603}
     604
     605void InspectorTimelineAgent::didFireObserverCallback()
     606{
     607    didCompleteCurrentRecord(TimelineRecordType::ObserverCallback);
     608}
     609
    600610// ScriptDebugListener
    601611
    … …  
    655665    case TimelineRecordType::FireAnimationFrame:
    656666        return Inspector::Protocol::Timeline::EventType::FireAnimationFrame;
     667
     668    case TimelineRecordType::ObserverCallback:
     669        return Inspector::Protocol::Timeline::EventType::ObserverCallback;
    657670    }
    658671
  • trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.h

    r228600 r239397  
    8484    CancelAnimationFrame,
    8585    FireAnimationFrame,
     86   
     87    ObserverCallback,
    8688};
    8789
    … …  
    138140    void willFireAnimationFrame(int callbackId, Frame*);
    139141    void didFireAnimationFrame();
     142    void willFireObserverCallback(const String& callbackType, Frame*);
     143    void didFireObserverCallback();
    140144    void time(Frame&, const String&);
    141145    void timeEnd(Frame&, const String&);
  • trunk/Source/WebCore/page/IntersectionObserver.cpp

    r238610 r239397  
    3333#include "CSSTokenizer.h"
    3434#include "Element.h"
     35#include "InspectorInstrumentation.h"
    3536#include "IntersectionObserverCallback.h"
    3637#include "IntersectionObserverEntry.h"
    … …  
    257258    }
    258259
     260    auto* context = m_callback->scriptExecutionContext();
     261    if (!context)
     262        return;
     263
     264    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireObserverCallback(*context, "IntersectionObserver"_s);
     265
    259266    auto takenRecords = takeRecords();
    260267    m_callback->handleEvent(WTFMove(takenRecords.records), *this);
     268
     269    InspectorInstrumentation::didFireObserverCallback(cookie);
    261270}
    262271
  • trunk/Source/WebCore/page/PerformanceObserver.cpp

    r237228 r239397  
    2929#include "DOMWindow.h"
    3030#include "Document.h"
     31#include "InspectorInstrumentation.h"
    3132#include "Performance.h"
    3233#include "PerformanceObserverEntryList.h"
    … …  
    101102        return;
    102103
     104    auto* context = m_callback->scriptExecutionContext();
     105    if (!context)
     106        return;
     107
    103108    Vector<RefPtr<PerformanceEntry>> entries = WTFMove(m_entriesToDeliver);
    104109    auto list = PerformanceObserverEntryList::create(WTFMove(entries));
     110
     111    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireObserverCallback(*context, "PerformanceObserver"_s);
    105112    m_callback->handleEvent(list, *this);
     113    InspectorInstrumentation::didFireObserverCallback(cookie);
    106114}
    107115
  • trunk/Source/WebInspectorUI/ChangeLog

    r239394 r239397  
     12018-12-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Web Inspector: Timelines: correctly label Intersection Observer callbacks
     4        https://bugs.webkit.org/show_bug.cgi?id=192669
     5        <rdar://problem/46702490>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        Add InspectorInstrumentation::willFireObserverCallback() and use it to wrap calls
     10        to Intersection Observer, Performance Observer and Mutation Observer callbacks so
     11        that they get correctly labeled in the Inspector timeline.
     12
     13        * Localizations/en.lproj/localizedStrings.js:
     14        * UserInterface/Controllers/TimelineManager.js:
     15        (WI.TimelineManager.prototype._processRecord):
     16        * UserInterface/Models/ScriptTimelineRecord.js:
     17        (WI.ScriptTimelineRecord.EventType.displayName):
     18        * UserInterface/Views/TimelineTabContentView.js:
     19        (WI.TimelineTabContentView.iconClassNameForRecord):
     20
    1212018-12-19  Devin Rousso  <drousso@apple.com>
    222
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r239286 r239397  
    4646localizedStrings["%s (default)"] = "%s (default)";
    4747localizedStrings["%s (hidden)"] = "%s (hidden)";
     48localizedStrings["%s Callback"] = "%s Callback";
    4849localizedStrings["%s Event Dispatched"] = "%s Event Dispatched";
    4950localizedStrings["%s Fired"] = "%s Fired";
    … …  
    5455localizedStrings["%s cannot be modified"] = "%s cannot be modified";
    5556localizedStrings["%s delay"] = "%s delay";
     57localizedStrings["%s eval\n%s async"] = "%s eval\n%s async";
    5658localizedStrings["%s interval"] = "%s interval";
    5759localizedStrings["(Action %s)"] = "(Action %s)";
    … …  
    122124localizedStrings["Assertion with message: %s"] = "Assertion with message: %s";
    123125localizedStrings["Assertive"] = "Assertive";
     126localizedStrings["Async audits are not supported."] = "Async audits are not supported.";
    124127localizedStrings["Attribute"] = "Attribute";
    125128localizedStrings["Attribute Modified"] = "Attribute Modified";
    … …  
    631634localizedStrings["Object Graph"] = "Object Graph";
    632635localizedStrings["Object Store"] = "Object Store";
     636localizedStrings["Observer Callback"] = "Observer Callback";
    633637localizedStrings["Off"] = "Off";
    634638localizedStrings["Once"] = "Once";
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js

    r238864 r239397  
    547547                record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.TimerFired, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.timerId, profileData);
    548548                break;
     549            case TimelineAgent.EventType.ObserverCallback:
     550                record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.ObserverCallback, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.type, profileData);
     551                break;
     552            case TimelineAgent.EventType.FireAnimationFrame:
     553                record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.AnimationFrameFired, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.id, profileData);
     554                break;
    549555            default:
    550556                record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.ScriptEvaluated, startTime, endTime, callFrames, sourceCodeLocation, null, profileData);
    … …  
    564570        case TimelineAgent.EventType.EventDispatch:
    565571        case TimelineAgent.EventType.FireAnimationFrame:
    566             // These are handled when the parent of FunctionCall or EvaluateScript.
     572        case TimelineAgent.EventType.ObserverCallback:
     573            // These are handled when we see the child FunctionCall or EvaluateScript.
    567574            break;
    568575
    … …  
    596603            case TimelineAgent.EventType.EventDispatch:
    597604                record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.EventDispatched, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.type, profileData);
     605                break;
     606            case TimelineAgent.EventType.ObserverCallback:
     607                record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.ObserverCallback, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.type, profileData);
    598608                break;
    599609            case TimelineAgent.EventType.FireAnimationFrame:
  • trunk/Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js

    r238743 r239397  
    195195    AnimationFrameRequested: "script-timeline-record-animation-frame-requested",
    196196    AnimationFrameCanceled: "script-timeline-record-animation-frame-canceled",
     197    ObserverCallback: "script-timeline-record-observer-callback",
    197198    ConsoleProfileRecorded: "script-timeline-record-console-profile-recorded",
    198199    GarbageCollected: "script-timeline-record-garbage-collected",
    … …  
    401402            return WI.UIString("Animation Frame %d Fired").format(details);
    402403        return WI.UIString("Animation Frame Fired");
     404    case WI.ScriptTimelineRecord.EventType.ObserverCallback:
     405        if (details && (details instanceof String || typeof details === "string"))
     406            return WI.UIString("%s Callback").format(details);
     407        return WI.UIString("Observer Callback");
    403408    case WI.ScriptTimelineRecord.EventType.AnimationFrameRequested:
    404409        if (details && includeDetailsInMainTitle)
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js

    r238484 r239397  
    208208            case WI.ScriptTimelineRecord.EventType.MicrotaskDispatched:
    209209            case WI.ScriptTimelineRecord.EventType.EventDispatched:
     210            case WI.ScriptTimelineRecord.EventType.ObserverCallback:
    210211                return WI.TimelineRecordTreeElement.EventRecordIconStyleClass;
    211212            case WI.ScriptTimelineRecord.EventType.ProbeSampleRecorded:
Note: See TracChangeset for help on using the changeset viewer.