#include "third_party/blink/renderer/core/inspector/inspector_trace_events.h"
#include <inttypes.h>
#include <memory>
#include "cc/layers/picture_layer.h"
#include "third_party/blink/public/mojom/loader/request_context_frame_type.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/capture_source_location.h"
#include "third_party/blink/renderer/core/animation/animation.h"
#include "third_party/blink/renderer/core/animation/keyframe_effect.h"
#include "third_party/blink/renderer/core/css/invalidation/invalidation_set.h"
#include "third_party/blink/renderer/core/css/style_change_reason.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/events/keyboard_event.h"
#include "third_party/blink/renderer/core/events/message_event.h"
#include "third_party/blink/renderer/core/events/wheel_event.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/html/parser/html_document_parser.h"
#include "third_party/blink/renderer/core/inspector/identifiers_factory.h"
#include "third_party/blink/renderer/core/inspector/inspector_animation_agent.h"
#include "third_party/blink/renderer/core/inspector/inspector_network_agent.h"
#include "third_party/blink/renderer/core/inspector/inspector_page_agent.h"
#include "third_party/blink/renderer/core/inspector/invalidation_set_to_selector_map.h"
#include "third_party/blink/renderer/core/layout/hit_test_location.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/layout/layout_image.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/resource/css_style_sheet_resource.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/core/workers/worker_thread.h"
#include "third_party/blink/renderer/core/xmlhttprequest/xml_http_request.h"
#include "third_party/blink/renderer/platform/bindings/source_location.h"
#include "third_party/blink/renderer/platform/instrumentation/instance_counters.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/traced_value.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_load_priority.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_load_timing.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_request.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_response.h"
#include "third_party/blink/renderer/platform/loader/fetch/service_worker_router_info.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/dynamic_annotations.h"
#include "third_party/blink/renderer/platform/wtf/text/text_position.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "v8/include/v8-profiler.h"
#include "v8/include/v8.h"
namespace blink {
namespace {
const unsigned kMaxLayoutRoots = …;
const unsigned kMaxQuads = …;
void InspectorParseHtmlBeginData(perfetto::TracedValue context,
Document* document,
int start_line) { … }
void InspectorParseHtmlEndData(perfetto::TracedValue context, int end_line) { … }
void GetNavigationTracingData(perfetto::TracedValue context,
Document* document) { … }
int GetModifierFromEvent(const UIEventWithKeyState& event) { … }
}
String ToHexString(const void* p) { … }
void SetCallStack(v8::Isolate* isolate, perfetto::TracedDictionary& dict) { … }
void InspectorTraceEvents::WillSendRequest(
ExecutionContext* execution_context,
DocumentLoader* loader,
const KURL& fetch_context_url,
const ResourceRequest& request,
const ResourceResponse& redirect_response,
const ResourceLoaderOptions& resource_loader_options,
ResourceType resource_type,
RenderBlockingBehavior render_blocking_behavior,
base::TimeTicks timestamp) { … }
void InspectorTraceEvents::WillSendNavigationRequest(
uint64_t identifier,
DocumentLoader* loader,
const KURL& url,
const AtomicString& http_method,
EncodedFormData*) { … }
void InspectorTraceEvents::DidReceiveResourceResponse(
uint64_t identifier,
DocumentLoader* loader,
const ResourceResponse& response,
const Resource*) { … }
void InspectorTraceEvents::DidReceiveData(uint64_t identifier,
DocumentLoader* loader,
const char* data,
uint64_t encoded_data_length) { … }
void InspectorTraceEvents::DidFinishLoading(uint64_t identifier,
DocumentLoader* loader,
base::TimeTicks finish_time,
int64_t encoded_data_length,
int64_t decoded_body_length) { … }
void InspectorTraceEvents::DidFailLoading(
CoreProbeSink* sink,
uint64_t identifier,
DocumentLoader* loader,
const ResourceError&,
const base::UnguessableToken& devtools_frame_or_worker_token) { … }
void InspectorTraceEvents::MarkResourceAsCached(DocumentLoader* loader,
uint64_t identifier) { … }
void InspectorTraceEvents::Will(const probe::ExecuteScript&) { … }
void InspectorTraceEvents::Did(const probe::ExecuteScript& probe) { … }
void InspectorTraceEvents::Will(const probe::ParseHTML& probe) { … }
void InspectorTraceEvents::Did(const probe::ParseHTML& probe) { … }
void InspectorTraceEvents::Will(const probe::CallFunction& probe) { … }
void InspectorTraceEvents::Did(const probe::CallFunction& probe) { … }
void InspectorTraceEvents::PaintTiming(Document* document,
const char* name,
double timestamp) { … }
void InspectorTraceEvents::FrameStartedLoading(LocalFrame* frame) { … }
namespace {
void SetNodeInfo(perfetto::TracedDictionary& dict,
Node* node,
perfetto::StaticString id_field_name,
perfetto::StaticString name_field_name = nullptr) { … }
const char* PseudoTypeToString(CSSSelector::PseudoType pseudo_type) { … }
String UrlForFrame(LocalFrame* frame) { … }
const char* NotStreamedReasonString(ScriptStreamer::NotStreamingReason reason) { … }
}
namespace inspector_schedule_style_invalidation_tracking_event {
void FillCommonPart(perfetto::TracedDictionary& dict,
ContainerNode& node,
const InvalidationSet& invalidation_set,
const char* invalidated_selector) { … }
}
const char inspector_schedule_style_invalidation_tracking_event::kAttribute[] = …;
const char inspector_schedule_style_invalidation_tracking_event::kClass[] = …;
const char inspector_schedule_style_invalidation_tracking_event::kId[] = …;
const char inspector_schedule_style_invalidation_tracking_event::kPseudo[] = …;
const char inspector_schedule_style_invalidation_tracking_event::kRuleSet[] = …;
const char* ResourcePriorityString(ResourceLoadPriority priority) { … }
const char* FetchPriorityString(
mojom::blink::FetchPriorityHint fetch_priority) { … }
void inspector_schedule_style_invalidation_tracking_event::IdChange(
perfetto::TracedValue context,
Element& element,
const InvalidationSet& invalidation_set,
const AtomicString& id) { … }
void inspector_schedule_style_invalidation_tracking_event::ClassChange(
perfetto::TracedValue context,
Element& element,
const InvalidationSet& invalidation_set,
const AtomicString& class_name) { … }
void inspector_schedule_style_invalidation_tracking_event::AttributeChange(
perfetto::TracedValue context,
Element& element,
const InvalidationSet& invalidation_set,
const QualifiedName& attribute_name) { … }
void inspector_schedule_style_invalidation_tracking_event::PseudoChange(
perfetto::TracedValue context,
Element& element,
const InvalidationSet& invalidation_set,
CSSSelector::PseudoType pseudo_type) { … }
String DescendantInvalidationSetToIdString(const InvalidationSet& set) { … }
const char inspector_style_invalidator_invalidate_event::
kElementHasPendingInvalidationList[] = …;
const char
inspector_style_invalidator_invalidate_event::kInvalidateCustomPseudo[] = …;
const char inspector_style_invalidator_invalidate_event::
kInvalidationSetInvalidatesSelf[] = …;
const char inspector_style_invalidator_invalidate_event::
kInvalidationSetInvalidatesSubtree[] = …;
const char inspector_style_invalidator_invalidate_event::
kInvalidationSetMatchedAttribute[] = …;
const char inspector_style_invalidator_invalidate_event::
kInvalidationSetMatchedClass[] = …;
const char
inspector_style_invalidator_invalidate_event::kInvalidationSetMatchedId[] = …;
const char inspector_style_invalidator_invalidate_event::
kInvalidationSetMatchedTagName[] = …;
const char inspector_style_invalidator_invalidate_event::
kInvalidationSetMatchedPart[] = …;
namespace inspector_style_invalidator_invalidate_event {
void FillCommonPart(perfetto::TracedDictionary& dict,
ContainerNode& node,
const char* reason) { … }
void FillSelectors(
perfetto::TracedDictionary& dict,
const InvalidationSet& invalidation_set,
InvalidationSetToSelectorMap::SelectorFeatureType feature_type,
const AtomicString& feature_value) { … }
}
void inspector_style_invalidator_invalidate_event::Data(
perfetto::TracedValue context,
Element& element,
const char* reason) { … }
void inspector_style_invalidator_invalidate_event::SelectorPart(
perfetto::TracedValue context,
Element& element,
const char* reason,
const InvalidationSet& invalidation_set,
const AtomicString& selector_part) { … }
void inspector_style_invalidator_invalidate_event::InvalidationList(
perfetto::TracedValue context,
ContainerNode& node,
const Vector<scoped_refptr<InvalidationSet>>& invalidation_list) { … }
void inspector_style_recalc_invalidation_tracking_event::Data(
perfetto::TracedValue context,
Node* node,
StyleChangeType change_type,
const StyleChangeReasonForTracing& reason) { … }
void inspector_layout_event::BeginData(perfetto::TracedValue context,
LocalFrameView* frame_view) { … }
static void CreateQuad(perfetto::TracedValue context, const gfx::QuadF& quad) { … }
static void SetGeneratingNodeInfo(
perfetto::TracedDictionary& dict,
const LayoutObject* layout_object,
perfetto::StaticString id_field_name,
perfetto::StaticString name_field_name = nullptr) { … }
static void CreateLayoutRoot(perfetto::TracedValue context,
const LayoutObjectWithDepth& layout_root) { … }
static void SetHeaders(perfetto::TracedValue context,
const HTTPHeaderMap& headers) { … }
void inspector_layout_event::EndData(
perfetto::TracedValue context,
const HeapVector<LayoutObjectWithDepth>& layout_roots) { … }
namespace layout_invalidation_reason {
const char kUnknown[] = …;
const char kSizeChanged[] = …;
const char kAncestorMoved[] = …;
const char kStyleChange[] = …;
const char kDomChanged[] = …;
const char kTextChanged[] = …;
const char kPrintingChanged[] = …;
const char kPaintPreview[] = …;
const char kAttributeChanged[] = …;
const char kColumnsChanged[] = …;
const char kChildAnonymousBlockChanged[] = …;
const char kAnonymousBlockChange[] = …;
const char kFontsChanged[] = …;
const char kFullscreen[] = …;
const char kChildChanged[] = …;
const char kListValueChange[] = …;
const char kListStyleTypeChange[] = …;
const char kCounterStyleChange[] = …;
const char kImageChanged[] = …;
const char kSliderValueChanged[] = …;
const char kAncestorMarginCollapsing[] = …;
const char kFieldsetChanged[] = …;
const char kTextAutosizing[] = …;
const char kSvgResourceInvalidated[] = …;
const char kFloatDescendantChanged[] = …;
const char kCountersChanged[] = …;
const char kGridChanged[] = …;
const char kMenuOptionsChanged[] = …;
const char kRemovedFromLayout[] = …;
const char kAddedToLayout[] = …;
const char kTableChanged[] = …;
const char kPaddingChanged[] = …;
const char kTextControlChanged[] = …;
const char kSvgChanged[] = …;
const char kScrollbarChanged[] = …;
const char kDisplayLock[] = …;
const char kDevtools[] = …;
const char kAnchorPositioning[] = …;
}
void inspector_layout_invalidation_tracking_event::Data(
perfetto::TracedValue context,
const LayoutObject* layout_object,
LayoutInvalidationReasonForTracing reason) { … }
void inspector_change_resource_priority_event::Data(
perfetto::TracedValue context,
DocumentLoader* loader,
uint64_t identifier,
const ResourceLoadPriority& load_priority) { … }
namespace {
String GetRenderBlockingStringFromBehavior(
RenderBlockingBehavior render_blocking_behavior) { … }
}
void SetInitiator(Document* document,
FetchInitiatorInfo initiator_info,
perfetto::TracedDictionary& dict) { … }
void inspector_send_request_event::Data(
perfetto::TracedValue context,
ExecutionContext* execution_context,
DocumentLoader* loader,
uint64_t identifier,
LocalFrame* frame,
const ResourceRequest& request,
ResourceType resource_type,
RenderBlockingBehavior render_blocking_behavior,
const ResourceLoaderOptions& resource_loader_options) { … }
void inspector_change_render_blocking_behavior_event::Data(
perfetto::TracedValue context,
DocumentLoader* loader,
uint64_t identifier,
const ResourceRequestHead& request,
RenderBlockingBehavior render_blocking_behavior) { … }
void inspector_send_navigation_request_event::Data(
perfetto::TracedValue context,
DocumentLoader* loader,
uint64_t identifier,
LocalFrame* frame,
const KURL& url,
const AtomicString& http_method) { … }
namespace {
void RecordTiming(perfetto::TracedValue context,
const ResourceLoadTiming& timing) { … }
}
void inspector_receive_response_event::Data(perfetto::TracedValue context,
DocumentLoader* loader,
uint64_t identifier,
LocalFrame* frame,
const ResourceResponse& response) { … }
void inspector_receive_data_event::Data(perfetto::TracedValue context,
DocumentLoader* loader,
uint64_t identifier,
LocalFrame* frame,
uint64_t encoded_data_length) { … }
void inspector_resource_finish_event::Data(perfetto::TracedValue context,
DocumentLoader* loader,
uint64_t identifier,
base::TimeTicks finish_time,
bool did_fail,
int64_t encoded_data_length,
int64_t decoded_body_length) { … }
void inspector_mark_resource_cached_event::Data(perfetto::TracedValue context,
DocumentLoader* loader,
uint64_t identifier) { … }
static LocalFrame* FrameForExecutionContext(ExecutionContext* context) { … }
static void GenericTimerData(perfetto::TracedDictionary& dict,
ExecutionContext* context,
int timer_id) { … }
void inspector_timer_install_event::Data(perfetto::TracedValue trace_context,
ExecutionContext* context,
int timer_id,
base::TimeDelta timeout,
bool single_shot) { … }
void inspector_timer_remove_event::Data(perfetto::TracedValue trace_context,
ExecutionContext* context,
int timer_id) { … }
void inspector_timer_fire_event::Data(perfetto::TracedValue trace_context,
ExecutionContext* context,
int timer_id) { … }
void inspector_animation_frame_event::Data(perfetto::TracedValue trace_context,
ExecutionContext* context,
int callback_id) { … }
void GenericIdleCallbackEvent(perfetto::TracedDictionary& dict,
ExecutionContext* context,
int id) { … }
void inspector_idle_callback_request_event::Data(
perfetto::TracedValue trace_context,
ExecutionContext* context,
int id,
double timeout) { … }
void inspector_idle_callback_cancel_event::Data(
perfetto::TracedValue trace_context,
ExecutionContext* context,
int id) { … }
void inspector_idle_callback_fire_event::Data(
perfetto::TracedValue trace_context,
ExecutionContext* context,
int id,
double allotted_milliseconds,
bool timed_out) { … }
void inspector_parse_author_style_sheet_event::Data(
perfetto::TracedValue context,
const CSSStyleSheetResource* cached_style_sheet) { … }
void inspector_xhr_ready_state_change_event::Data(
perfetto::TracedValue trace_context,
ExecutionContext* context,
XMLHttpRequest* request) { … }
void inspector_xhr_load_event::Data(perfetto::TracedValue trace_context,
ExecutionContext* context,
XMLHttpRequest* request) { … }
void inspector_paint_event::Data(perfetto::TracedValue context,
LocalFrame* frame,
const LayoutObject* layout_object,
const gfx::QuadF& quad,
int layer_id) { … }
void FrameEventData(perfetto::TracedDictionary& dict, LocalFrame* frame) { … }
void FillCommonFrameData(perfetto::TracedDictionary& dict, LocalFrame* frame) { … }
void inspector_commit_load_event::Data(perfetto::TracedValue context,
LocalFrame* frame) { … }
void inspector_layerize_event::Data(perfetto::TracedValue context,
LocalFrame* frame) { … }
void inspector_mark_load_event::Data(perfetto::TracedValue context,
LocalFrame* frame) { … }
void inspector_pre_paint_event::Data(perfetto::TracedValue context,
LocalFrame* frame) { … }
void inspector_scroll_layer_event::Data(perfetto::TracedValue context,
LayoutObject* layout_object) { … }
namespace {
void FillLocation(perfetto::TracedDictionary& dict,
const String& url,
const TextPosition& text_position) { … }
}
void inspector_evaluate_script_event::Data(perfetto::TracedValue context,
v8::Isolate* isolate,
LocalFrame* frame,
const String& url,
const TextPosition& text_position) { … }
void inspector_target_rundown_event::Data(perfetto::TracedValue context,
ExecutionContext* execution_context,
v8::Isolate* isolate,
ScriptState* scriptState,
int scriptId) { … }
void inspector_parse_script_event::Data(perfetto::TracedValue context,
uint64_t identifier,
const String& url) { … }
void inspector_deserialize_script_event::Data(perfetto::TracedValue context,
uint64_t identifier,
const String& url) { … }
inspector_compile_script_event::V8ConsumeCacheResult::V8ConsumeCacheResult(
int cache_size,
bool rejected,
bool full)
: … { … }
void inspector_compile_script_event::Data(
perfetto::TracedValue context,
const String& url,
const TextPosition& text_position,
std::optional<V8ConsumeCacheResult> consume_cache_result,
bool eager,
bool streamed,
ScriptStreamer::NotStreamingReason not_streaming_reason) { … }
void inspector_produce_script_cache_event::Data(
perfetto::TracedValue context,
const String& url,
const TextPosition& text_position,
int cache_size) { … }
void inspector_handle_post_message_event::Data(
perfetto::TracedValue context,
ExecutionContext* execution_context,
const MessageEvent& message_event) { … }
void inspector_schedule_post_message_event::Data(
perfetto::TracedValue context,
ExecutionContext* execution_context,
uint64_t trace_id) { … }
void inspector_function_call_event::Data(
perfetto::TracedValue trace_context,
ExecutionContext* context,
const v8::Local<v8::Function>& function) { … }
void inspector_paint_image_event::Data(perfetto::TracedValue context,
const LayoutImage& layout_image,
const gfx::RectF& src_rect,
const gfx::RectF& dest_rect) { … }
void inspector_paint_image_event::Data(perfetto::TracedValue context,
const LayoutObject& owning_layout_object,
const StyleImage& style_image) { … }
void inspector_paint_image_event::Data(perfetto::TracedValue context,
Node* node,
const StyleImage& style_image,
const gfx::RectF& src_rect,
const gfx::RectF& dest_rect) { … }
void inspector_paint_image_event::Data(
perfetto::TracedValue context,
const LayoutObject* owning_layout_object,
const ImageResourceContent& image_content) { … }
static size_t UsedHeapSize(v8::Isolate* isolate) { … }
void inspector_update_counters_event::Data(perfetto::TracedValue context,
v8::Isolate* isolate) { … }
void inspector_invalidate_layout_event::Data(perfetto::TracedValue context,
LocalFrame* frame,
DOMNodeId nodeId) { … }
void inspector_recalculate_styles_event::Data(perfetto::TracedValue context,
LocalFrame* frame) { … }
void inspector_event_dispatch_event::Data(perfetto::TracedValue context,
const Event& event,
v8::Isolate* isolate) { … }
void inspector_time_stamp_event::Data(perfetto::TracedValue trace_context,
ExecutionContext* context,
const String& message) { … }
void inspector_tracing_session_id_for_worker_event::Data(
perfetto::TracedValue context,
const base::UnguessableToken& worker_devtools_token,
const base::UnguessableToken& parent_devtools_token,
const KURL& url,
PlatformThreadId worker_thread_id) { … }
void inspector_tracing_started_in_frame::Data(perfetto::TracedValue context,
const String& session_id,
LocalFrame* frame) { … }
void inspector_set_layer_tree_id::Data(perfetto::TracedValue context,
LocalFrame* frame) { … }
void inspector_animation_event::Data(perfetto::TracedValue context,
const Animation& animation) { … }
void inspector_animation_state_event::Data(perfetto::TracedValue context,
const Animation& animation) { … }
void inspector_animation_compositor_event::Data(
perfetto::TracedValue context,
CompositorAnimations::FailureReasons failure_reasons,
const PropertyHandleSet& unsupported_properties) { … }
void inspector_hit_test_event::EndData(perfetto::TracedValue context,
const HitTestRequest& request,
const HitTestLocation& location,
const HitTestResult& result) { … }
void inspector_async_task::Data(perfetto::TracedValue context,
const StringView& name) { … }
}