Commit 1f0854bc authored by yurys@chromium.org's avatar yurys@chromium.org

DevTools: add ParseAuthorStyleSheet events to Timeline

The operation may take noticable time an may give the user additional information about his page performance.

BUG=424502

Review URL: https://codereview.chromium.org/717573003

git-svn-id: svn://svn.chromium.org/blink/trunk@185190 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6d3095b9
Tests that ParseAuthorStyleSheet trace event is recorded.
SUCCESS: found ParseAuthorStyleSheet record
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/timeline-test.js"></script>
<script src="../tracing-test.js"></script>
<script>
function importStyle(onComplete)
{
var link = document.createElement('link');
link.setAttribute('rel', 'stylesheet');
link.type = 'text/css';
link.href = 'resources/style.css';
document.head.appendChild(link);
link.onload = onComplete.bind(this, null);
}
function test()
{
InspectorTest.invokeWithTracing("importStyle", processTracingEvents);
function processTracingEvents()
{
var record = InspectorTest.findFirstTimelineRecord(WebInspector.TimelineModel.RecordType.ParseAuthorStyleSheet);
if (record)
InspectorTest.addResult("SUCCESS: found ParseAuthorStyleSheet record");
else
InspectorTest.addResult("FAIL: ParseAuthorStyleSheet record not found");
InspectorTest.completeTest();
}
}
</script>
</head>
<body onload="runTest()">
<p>
Tests that ParseAuthorStyleSheet trace event is recorded.
</p>
</body>
</html>
......@@ -37,6 +37,7 @@ Applications outside of WebKit depend on the stability of the mapping of these t
PaintImage : "PaintImage"
PaintInvalidationTracking : "PaintInvalidationTracking"
PaintSetup : "PaintSetup"
ParseAuthorStyleSheet : "ParseAuthorStyleSheet"
ParseHTML : "ParseHTML"
PictureSnapshot : "cc::Picture"
Program : "Program"
......
......@@ -32,6 +32,7 @@
#include "core/dom/StyleEngine.h"
#include "core/fetch/CSSStyleSheetResource.h"
#include "core/frame/UseCounter.h"
#include "core/inspector/InspectorTraceEvents.h"
#include "platform/TraceEvent.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "wtf/Deque.h"
......@@ -319,6 +320,7 @@ const AtomicString& StyleSheetContents::determineNamespace(const AtomicString& p
void StyleSheetContents::parseAuthorStyleSheet(const CSSStyleSheetResource* cachedStyleSheet, const SecurityOrigin* securityOrigin)
{
TRACE_EVENT0("blink", "StyleSheetContents::parseAuthorStyleSheet");
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ParseAuthorStyleSheet", "data", InspectorParseAuthorStyleSheetEvent::data(cachedStyleSheet));
bool quirksMode = isQuirksModeBehavior(m_parserContext.mode());
......
......@@ -11,6 +11,7 @@
#include "core/css/invalidation/DescendantInvalidationSet.h"
#include "core/dom/StyleChangeReason.h"
#include "core/events/Event.h"
#include "core/fetch/CSSStyleSheetResource.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/inspector/IdentifiersFactory.h"
......@@ -457,6 +458,13 @@ PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorParseHtmlEvent::beginD
return value.release();
}
PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorParseAuthorStyleSheetEvent::data(const CSSStyleSheetResource* cachedStyleSheet)
{
RefPtr<TracedValue> value = TracedValue::create();
value->setString("styleSheetUrl", cachedStyleSheet->url().string());
return value.release();
}
PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorXhrReadyStateChangeEvent::data(ExecutionContext* context, XMLHttpRequest* request)
{
RefPtr<TracedValue> value = TracedValue::create();
......
......@@ -14,6 +14,7 @@
namespace blink {
class CSSStyleSheetResource;
class DescendantInvalidationSet;
class Document;
class Element;
......@@ -169,6 +170,11 @@ public:
static PassRefPtr<TraceEvent::ConvertableToTraceFormat> beginData(Document*, unsigned startLine);
};
class InspectorParseAuthorStyleSheetEvent {
public:
static PassRefPtr<TraceEvent::ConvertableToTraceFormat> data(const CSSStyleSheetResource*);
};
class InspectorXhrReadyStateChangeEvent {
public:
static PassRefPtr<TraceEvent::ConvertableToTraceFormat> data(ExecutionContext*, XMLHttpRequest*);
......
......@@ -79,6 +79,7 @@ WebInspector.TimelineModel.RecordType = {
PaintInvalidationTracking: "PaintInvalidationTracking",
ParseHTML: "ParseHTML",
ParseAuthorStyleSheet: "ParseAuthorStyleSheet",
TimerInstall: "TimerInstall",
TimerRemove: "TimerRemove",
......
......@@ -77,6 +77,7 @@ WebInspector.TimelineUIUtils._initEventStyles = function()
eventStyles[recordTypes.ScrollLayer] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("Scroll"), categories["rendering"]);
eventStyles[recordTypes.CompositeLayers] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("Composite Layers"), categories["painting"]);
eventStyles[recordTypes.ParseHTML] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("Parse HTML"), categories["loading"]);
eventStyles[recordTypes.ParseAuthorStyleSheet] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("Parse Author Style Sheet"), categories["loading"]);
eventStyles[recordTypes.TimerInstall] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("Install Timer"), categories["scripting"]);
eventStyles[recordTypes.TimerRemove] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("Remove Timer"), categories["scripting"]);
eventStyles[recordTypes.TimerFire] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("Timer Fired"), categories["scripting"]);
......@@ -571,6 +572,11 @@ WebInspector.TimelineUIUtils._buildTraceEventDetailsSynchronously = function(eve
if (event.imageURL)
contentHelper.appendElementRow(WebInspector.UIString("Image URL"), WebInspector.linkifyResourceAsNode(event.imageURL));
break;
case recordTypes.ParseAuthorStyleSheet:
var url = eventData["styleSheetUrl"];
if (url)
contentHelper.appendElementRow(WebInspector.UIString("Stylesheet URL"), WebInspector.linkifyResourceAsNode(url));
break;
case recordTypes.RecalculateStyles: // We don't want to see default details.
contentHelper.appendTextRow(WebInspector.UIString("Elements affected"), event.args["elementCount"]);
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment