Web Inspector: Clean up and audit TimelineRecordFactory records
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Oct 2015 17:20:42 +0000 (17:20 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Oct 2015 17:20:42 +0000 (17:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150660

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-10-29
Reviewed by Brian Burg.

Source/WebCore:

Cleanup included removing unused methods and payload data that the
frontend wasn't likely to use. Also added ASCIILiteral and removed
unnecessary includes.

* inspector/InspectorNetworkAgent.cpp:
* inspector/InspectorPageAgent.cpp:
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::willLayout):
* inspector/InspectorTimelineAgent.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::createGenericRecord):
(WebCore::TimelineRecordFactory::createFunctionCallData):
(WebCore::TimelineRecordFactory::createConsoleProfileData):
(WebCore::TimelineRecordFactory::createEventDispatchData):
(WebCore::TimelineRecordFactory::createGenericTimerData):
(WebCore::TimelineRecordFactory::createTimerInstallData):
(WebCore::TimelineRecordFactory::createEvaluateScriptData):
(WebCore::TimelineRecordFactory::createTimeStampData):
(WebCore::TimelineRecordFactory::createParseHTMLData):
(WebCore::TimelineRecordFactory::createAnimationFrameData):
(WebCore::TimelineRecordFactory::createPaintData):
(WebCore::TimelineRecordFactory::appendLayoutRoot):
(WebCore::TimelineRecordFactory::createBackgroundRecord): Deleted.
(WebCore::TimelineRecordFactory::createLayoutData): Deleted.
* inspector/TimelineRecordFactory.h:
(WebCore::TimelineRecordFactory::TimelineRecordFactory):

Source/WebInspectorUI:

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Controllers/TimelineManager.js:
(WebInspector.TimelineManager.prototype._processRecord):
(WebInspector.TimelineManager.prototype._processEvent):
Add FIXME for payload data which we are not yet using but could.
Fix typo in some rAF records where we were mistakenly using "timerId"
instead of "id" for the request identifier.

* UserInterface/Models/ScriptTimelineRecord.js:
(WebInspector.ScriptTimelineRecord.EventType.displayName):
Display the now correctly accessed rAF identifier in the Scripts timeline.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191732 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorNetworkAgent.cpp
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.h
Source/WebCore/inspector/TimelineRecordFactory.cpp
Source/WebCore/inspector/TimelineRecordFactory.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js
Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js

index 58e6dd1..8c43bbc 100644 (file)
@@ -1,3 +1,37 @@
+2015-10-29  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Clean up and audit TimelineRecordFactory records
+        https://bugs.webkit.org/show_bug.cgi?id=150660
+
+        Reviewed by Brian Burg.
+
+        Cleanup included removing unused methods and payload data that the
+        frontend wasn't likely to use. Also added ASCIILiteral and removed
+        unnecessary includes.
+
+        * inspector/InspectorNetworkAgent.cpp:
+        * inspector/InspectorPageAgent.cpp:
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::willLayout):
+        * inspector/InspectorTimelineAgent.h:
+        * inspector/TimelineRecordFactory.cpp:
+        (WebCore::TimelineRecordFactory::createGenericRecord):
+        (WebCore::TimelineRecordFactory::createFunctionCallData):
+        (WebCore::TimelineRecordFactory::createConsoleProfileData):
+        (WebCore::TimelineRecordFactory::createEventDispatchData):
+        (WebCore::TimelineRecordFactory::createGenericTimerData):
+        (WebCore::TimelineRecordFactory::createTimerInstallData):
+        (WebCore::TimelineRecordFactory::createEvaluateScriptData):
+        (WebCore::TimelineRecordFactory::createTimeStampData):
+        (WebCore::TimelineRecordFactory::createParseHTMLData):
+        (WebCore::TimelineRecordFactory::createAnimationFrameData):
+        (WebCore::TimelineRecordFactory::createPaintData):
+        (WebCore::TimelineRecordFactory::appendLayoutRoot):
+        (WebCore::TimelineRecordFactory::createBackgroundRecord): Deleted.
+        (WebCore::TimelineRecordFactory::createLayoutData): Deleted.
+        * inspector/TimelineRecordFactory.h:
+        (WebCore::TimelineRecordFactory::TimelineRecordFactory):
+
 2015-10-29  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Exploitable crash happens when an SVG contains an indirect resource inheritance cycle
index 81fae3b..444fee3 100644 (file)
@@ -66,6 +66,7 @@
 #include <inspector/ScriptCallStack.h>
 #include <inspector/ScriptCallStackFactory.h>
 #include <wtf/RefPtr.h>
+#include <wtf/Stopwatch.h>
 #include <wtf/text/StringBuilder.h>
 
 using namespace Inspector;
index 77b5391..3e63cab 100644 (file)
@@ -72,6 +72,7 @@
 #include <inspector/IdentifiersFactory.h>
 #include <inspector/InspectorValues.h>
 #include <wtf/ListHashSet.h>
+#include <wtf/Stopwatch.h>
 #include <wtf/text/Base64.h>
 #include <wtf/text/StringBuilder.h>
 #include <yarr/RegularExpression.h>
index b1e71b8..1239e28 100644 (file)
 
 #include "Event.h"
 #include "Frame.h"
-#include "FrameView.h"
 #include "InspectorPageAgent.h"
 #include "InstrumentingAgents.h"
-#include "IntRect.h"
 #include "JSDOMWindow.h"
-#include "MainFrame.h"
 #include "PageScriptDebugServer.h"
-#include "RenderElement.h"
 #include "RenderView.h"
-#include "ResourceRequest.h"
-#include "ResourceResponse.h"
 #include "ScriptState.h"
 #include "TimelineRecordFactory.h"
-#include <inspector/IdentifiersFactory.h>
 #include <inspector/ScriptBreakpoint.h>
 #include <profiler/LegacyProfiler.h>
-#include <wtf/CurrentTime.h>
+#include <wtf/Stopwatch.h>
 
 #if PLATFORM(IOS)
 #include "RuntimeApplicationChecksIOS.h"
@@ -340,20 +333,7 @@ void InspectorTimelineAgent::didInvalidateLayout(Frame& frame)
 
 void InspectorTimelineAgent::willLayout(Frame& frame)
 {
-    auto* root = frame.view()->layoutRoot();
-    bool partialLayout = !!root;
-
-    if (!partialLayout)
-        root = frame.contentRenderer();
-
-    unsigned dirtyObjects = 0;
-    unsigned totalObjects = 0;
-    for (RenderObject* o = root; o; o = o->nextInPreOrder(root)) {
-        ++totalObjects;
-        if (o->needsLayout())
-            ++dirtyObjects;
-    }
-    pushCurrentRecord(TimelineRecordFactory::createLayoutData(dirtyObjects, totalObjects, partialLayout), TimelineRecordType::Layout, true, &frame);
+    pushCurrentRecord(InspectorObject::create(), TimelineRecordType::Layout, true, &frame);
 }
 
 void InspectorTimelineAgent::didLayout(RenderObject* root)
index d89bcf9..d3e4724 100644 (file)
@@ -39,9 +39,7 @@
 #include <inspector/InspectorFrontendDispatchers.h>
 #include <inspector/InspectorValues.h>
 #include <inspector/ScriptDebugListener.h>
-#include <wtf/Stopwatch.h>
 #include <wtf/Vector.h>
-#include <wtf/WeakPtr.h>
 
 namespace JSC {
 class Profile;
@@ -53,13 +51,8 @@ class Event;
 class FloatQuad;
 class Frame;
 class InspectorPageAgent;
-class IntRect;
-class URL;
-class Page;
 class PageScriptDebugServer;
 class RenderObject;
-class ResourceRequest;
-class ResourceResponse;
 class RunLoopObserver;
 
 typedef String ErrorString;
index a67ee26..e883b28 100644 (file)
 
 #include "Event.h"
 #include "FloatQuad.h"
-#include "IntRect.h"
 #include "JSMainThreadExecState.h"
-#include "LayoutRect.h"
-#include "ResourceRequest.h"
-#include "ResourceResponse.h"
 #include <inspector/InspectorProtocolObjects.h>
 #include <inspector/ScriptBreakpoint.h>
 #include <inspector/ScriptCallStack.h>
@@ -52,36 +48,28 @@ namespace WebCore {
 Ref<InspectorObject> TimelineRecordFactory::createGenericRecord(double startTime, int maxCallStackDepth)
 {
     Ref<InspectorObject> record = InspectorObject::create();
-    record->setDouble("startTime", startTime);
+    record->setDouble(ASCIILiteral("startTime"), startTime);
 
     if (maxCallStackDepth) {
         RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), maxCallStackDepth);
         if (stackTrace && stackTrace->size())
-            record->setValue("stackTrace", stackTrace->buildInspectorArray());
+            record->setValue(ASCIILiteral("stackTrace"), stackTrace->buildInspectorArray());
     }
     return WTF::move(record);
 }
 
-Ref<InspectorObject> TimelineRecordFactory::createBackgroundRecord(double startTime, const String& threadName)
-{
-    Ref<InspectorObject> record = InspectorObject::create();
-    record->setDouble("startTime", startTime);
-    record->setString("thread", threadName);
-    return WTF::move(record);
-}
-
 Ref<InspectorObject> TimelineRecordFactory::createFunctionCallData(const String& scriptName, int scriptLine)
 {
     Ref<InspectorObject> data = InspectorObject::create();
-    data->setString("scriptName", scriptName);
-    data->setInteger("scriptLine", scriptLine);
+    data->setString(ASCIILiteral("scriptName"), scriptName);
+    data->setInteger(ASCIILiteral("scriptLine"), scriptLine);
     return WTF::move(data);
 }
 
 Ref<InspectorObject> TimelineRecordFactory::createConsoleProfileData(const String& title)
 {
     Ref<InspectorObject> data = InspectorObject::create();
-    data->setString("title", title);
+    data->setString(ASCIILiteral("title"), title);
     return WTF::move(data);
 }
 
@@ -96,61 +84,52 @@ Ref<InspectorObject> TimelineRecordFactory::createProbeSampleData(const ScriptBr
 Ref<InspectorObject> TimelineRecordFactory::createEventDispatchData(const Event& event)
 {
     Ref<InspectorObject> data = InspectorObject::create();
-    data->setString("type", event.type().string());
+    data->setString(ASCIILiteral("type"), event.type().string());
     return WTF::move(data);
 }
 
 Ref<InspectorObject> TimelineRecordFactory::createGenericTimerData(int timerId)
 {
     Ref<InspectorObject> data = InspectorObject::create();
-    data->setInteger("timerId", timerId);
+    data->setInteger(ASCIILiteral("timerId"), timerId);
     return WTF::move(data);
 }
 
 Ref<InspectorObject> TimelineRecordFactory::createTimerInstallData(int timerId, int timeout, bool singleShot)
 {
     Ref<InspectorObject> data = InspectorObject::create();
-    data->setInteger("timerId", timerId);
-    data->setInteger("timeout", timeout);
-    data->setBoolean("singleShot", singleShot);
+    data->setInteger(ASCIILiteral("timerId"), timerId);
+    data->setInteger(ASCIILiteral("timeout"), timeout);
+    data->setBoolean(ASCIILiteral("singleShot"), singleShot);
     return WTF::move(data);
 }
 
 Ref<InspectorObject> TimelineRecordFactory::createEvaluateScriptData(const String& url, double lineNumber)
 {
     Ref<InspectorObject> data = InspectorObject::create();
-    data->setString("url", url);
-    data->setInteger("lineNumber", lineNumber);
+    data->setString(ASCIILiteral("url"), url);
+    data->setInteger(ASCIILiteral("lineNumber"), lineNumber);
     return WTF::move(data);
 }
 
 Ref<InspectorObject> TimelineRecordFactory::createTimeStampData(const String& message)
 {
     Ref<InspectorObject> data = InspectorObject::create();
-    data->setString("message", message);
-    return WTF::move(data);
-}
-
-Ref<InspectorObject> TimelineRecordFactory::createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout)
-{
-    Ref<InspectorObject> data = InspectorObject::create();
-    data->setInteger("dirtyObjects", dirtyObjects);
-    data->setInteger("totalObjects", totalObjects);
-    data->setBoolean("partialLayout", partialLayout);
+    data->setString(ASCIILiteral("message"), message);
     return WTF::move(data);
 }
 
 Ref<InspectorObject> TimelineRecordFactory::createParseHTMLData(unsigned startLine)
 {
     Ref<InspectorObject> data = InspectorObject::create();
-    data->setInteger("startLine", startLine);
+    data->setInteger(ASCIILiteral("startLine"), startLine);
     return WTF::move(data);
 }
 
 Ref<InspectorObject> TimelineRecordFactory::createAnimationFrameData(int callbackId)
 {
     Ref<InspectorObject> data = InspectorObject::create();
-    data->setInteger("id", callbackId);
+    data->setInteger(ASCIILiteral("id"), callbackId);
     return WTF::move(data);
 }
 
@@ -171,13 +150,13 @@ static Ref<InspectorArray> createQuad(const FloatQuad& quad)
 Ref<InspectorObject> TimelineRecordFactory::createPaintData(const FloatQuad& quad)
 {
     Ref<InspectorObject> data = InspectorObject::create();
-    data->setArray("clip", createQuad(quad));
+    data->setArray(ASCIILiteral("clip"), createQuad(quad));
     return WTF::move(data);
 }
 
 void TimelineRecordFactory::appendLayoutRoot(InspectorObject* data, const FloatQuad& quad)
 {
-    data->setArray("root", createQuad(quad));
+    data->setArray(ASCIILiteral("root"), createQuad(quad));
 }
 
 static Ref<Protocol::Timeline::CPUProfileNodeAggregateCallInfo> buildAggregateCallInfoInspectorObject(const JSC::ProfileNode* node)
index e3e0bf9..9acae7e 100644 (file)
@@ -32,7 +32,6 @@
 #ifndef TimelineRecordFactory_h
 #define TimelineRecordFactory_h
 
-#include "URL.h"
 #include <inspector/InspectorValues.h>
 #include <wtf/Forward.h>
 #include <wtf/text/WTFString.h>
@@ -47,47 +46,31 @@ struct ScriptBreakpointAction;
 
 namespace WebCore {
 
-    class Event;
-    class FloatQuad;
-    class ResourceRequest;
-    class ResourceResponse;
-    class ScriptProfile;
-
-    class TimelineRecordFactory {
-    public:
-        static Ref<Inspector::InspectorObject> createGenericRecord(double startTime, int maxCallStackDepth);
-        static Ref<Inspector::InspectorObject> createBackgroundRecord(double startTime, const String& thread);
-
-        static Ref<Inspector::InspectorObject> createFunctionCallData(const String& scriptName, int scriptLine);
-        static Ref<Inspector::InspectorObject> createConsoleProfileData(const String& title);
-
-        static Ref<Inspector::InspectorObject> createProbeSampleData(const Inspector::ScriptBreakpointAction&, unsigned sampleId);
-
-        static Ref<Inspector::InspectorObject> createEventDispatchData(const Event&);
-
-        static Ref<Inspector::InspectorObject> createGenericTimerData(int timerId);
-
-        static Ref<Inspector::InspectorObject> createTimerInstallData(int timerId, int timeout, bool singleShot);
-
-        static Ref<Inspector::InspectorObject> createEvaluateScriptData(const String&, double lineNumber);
-
-        static Ref<Inspector::InspectorObject> createTimeStampData(const String&);
-
-        static Ref<Inspector::InspectorObject> createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout);
-
-        static Ref<Inspector::InspectorObject> createParseHTMLData(unsigned startLine);
-
-        static Ref<Inspector::InspectorObject> createAnimationFrameData(int callbackId);
-
-        static Ref<Inspector::InspectorObject> createPaintData(const FloatQuad&);
-
-        static void appendLayoutRoot(Inspector::InspectorObject* data, const FloatQuad&);
-
-        static void appendProfile(Inspector::InspectorObject*, RefPtr<JSC::Profile>&&);
-
-    private:
-        TimelineRecordFactory() { }
-    };
+class Event;
+class FloatQuad;
+
+class TimelineRecordFactory {
+public:
+    static Ref<Inspector::InspectorObject> createGenericRecord(double startTime, int maxCallStackDepth);
+
+    static Ref<Inspector::InspectorObject> createFunctionCallData(const String& scriptName, int scriptLine);
+    static Ref<Inspector::InspectorObject> createConsoleProfileData(const String& title);
+    static Ref<Inspector::InspectorObject> createProbeSampleData(const Inspector::ScriptBreakpointAction&, unsigned sampleId);
+    static Ref<Inspector::InspectorObject> createEventDispatchData(const Event&);
+    static Ref<Inspector::InspectorObject> createGenericTimerData(int timerId);
+    static Ref<Inspector::InspectorObject> createTimerInstallData(int timerId, int timeout, bool singleShot);
+    static Ref<Inspector::InspectorObject> createEvaluateScriptData(const String&, double lineNumber);
+    static Ref<Inspector::InspectorObject> createTimeStampData(const String&);
+    static Ref<Inspector::InspectorObject> createParseHTMLData(unsigned startLine);
+    static Ref<Inspector::InspectorObject> createAnimationFrameData(int callbackId);
+    static Ref<Inspector::InspectorObject> createPaintData(const FloatQuad&);
+
+    static void appendLayoutRoot(Inspector::InspectorObject* data, const FloatQuad&);
+    static void appendProfile(Inspector::InspectorObject*, RefPtr<JSC::Profile>&&);
+
+private:
+    TimelineRecordFactory() { }
+};
 
 } // namespace WebCore
 
index c398615..7516a29 100644 (file)
@@ -1,3 +1,22 @@
+2015-10-29  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Clean up and audit TimelineRecordFactory records
+        https://bugs.webkit.org/show_bug.cgi?id=150660
+
+        Reviewed by Brian Burg.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        * UserInterface/Controllers/TimelineManager.js:
+        (WebInspector.TimelineManager.prototype._processRecord):
+        (WebInspector.TimelineManager.prototype._processEvent):
+        Add FIXME for payload data which we are not yet using but could.
+        Fix typo in some rAF records where we were mistakenly using "timerId"
+        instead of "id" for the request identifier.
+
+        * UserInterface/Models/ScriptTimelineRecord.js:
+        (WebInspector.ScriptTimelineRecord.EventType.displayName):
+        Display the now correctly accessed rAF identifier in the Scripts timeline.
+
 2015-10-28  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Add "revert" to CSS value autocompletion
index 35f571a..352ee01 100644 (file)
Binary files a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js and b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js differ
index 4b9eca5..364a664 100644 (file)
@@ -384,6 +384,7 @@ WebInspector.TimelineManager = class TimelineManager extends WebInspector.Object
             console.assert(isNaN(endTime));
 
             // Pass the startTime as the endTime since this record type has no duration.
+            // FIXME: Make use of "timeout" and "singleShot" payload properties.
             return new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.TimerInstalled, startTime, startTime, callFrames, sourceCodeLocation, recordPayload.data.timerId);
 
         case TimelineAgent.EventType.TimerRemove:
@@ -396,13 +397,13 @@ WebInspector.TimelineManager = class TimelineManager extends WebInspector.Object
             console.assert(isNaN(endTime));
 
             // Pass the startTime as the endTime since this record type has no duration.
-            return new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.AnimationFrameRequested, startTime, startTime, callFrames, sourceCodeLocation, recordPayload.data.timerId);
+            return new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.AnimationFrameRequested, startTime, startTime, callFrames, sourceCodeLocation, recordPayload.data.id);
 
         case TimelineAgent.EventType.CancelAnimationFrame:
             console.assert(isNaN(endTime));
 
             // Pass the startTime as the endTime since this record type has no duration.
-            return new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.AnimationFrameCanceled, startTime, startTime, callFrames, sourceCodeLocation, recordPayload.data.timerId);
+            return new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.AnimationFrameCanceled, startTime, startTime, callFrames, sourceCodeLocation, recordPayload.data.id);
         }
 
         return null;
@@ -412,6 +413,7 @@ WebInspector.TimelineManager = class TimelineManager extends WebInspector.Object
     {
         switch (recordPayload.type) {
         case TimelineAgent.EventType.TimeStamp:
+            // FIXME: Make use of "message" payload properties.
             var timestamp = this.activeRecording.computeElapsedTime(recordPayload.startTime);
             var eventMarker = new WebInspector.TimelineMarker(timestamp, WebInspector.TimelineMarker.Type.TimeStamp);
             this._activeRecording.addEventMarker(eventMarker);
index 95267f4..0bc497e 100644 (file)
@@ -365,10 +365,16 @@ WebInspector.ScriptTimelineRecord.EventType.displayName = function(eventType, de
             return WebInspector.UIString("Timer %s Removed").format(details);
         return WebInspector.UIString("Timer Removed");
     case WebInspector.ScriptTimelineRecord.EventType.AnimationFrameFired:
+        if (details && includeDetailsInMainTitle)
+            return WebInspector.UIString("Animation Frame %s Fired").format(details);
         return WebInspector.UIString("Animation Frame Fired");
     case WebInspector.ScriptTimelineRecord.EventType.AnimationFrameRequested:
+        if (details && includeDetailsInMainTitle)
+            return WebInspector.UIString("Animation Frame %s Requested").format(details);
         return WebInspector.UIString("Animation Frame Requested");
     case WebInspector.ScriptTimelineRecord.EventType.AnimationFrameCanceled:
+        if (details && includeDetailsInMainTitle)
+            return WebInspector.UIString("Animation Frame %s Canceled").format(details);
         return WebInspector.UIString("Animation Frame Canceled");
     }
 };