| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/inspector/InspectorTraceEvents.h" | 5 #include "platform/instrumentation/inspector/PlatformInspectorTraceEvents.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptSourceCode.h" | |
| 8 #include "bindings/core/v8/SourceLocation.h" | |
| 9 #include "core/animation/Animation.h" | |
| 10 #include "core/animation/KeyframeEffectReadOnly.h" | |
| 11 #include "core/css/invalidation/InvalidationSet.h" | |
| 12 #include "core/dom/DOMNodeIds.h" | |
| 13 #include "core/dom/StyleChangeReason.h" | |
| 14 #include "core/events/Event.h" | |
| 15 #include "core/frame/FrameView.h" | |
| 16 #include "core/frame/LocalFrame.h" | |
| 17 #include "core/html/HTMLFrameOwnerElement.h" | |
| 18 #include "core/inspector/IdentifiersFactory.h" | |
| 19 #include "core/layout/HitTestResult.h" | |
| 20 #include "core/layout/LayoutImage.h" | |
| 21 #include "core/layout/LayoutObject.h" | |
| 22 #include "core/loader/resource/CSSStyleSheetResource.h" | |
| 23 #include "core/page/Page.h" | |
| 24 #include "core/paint/PaintLayer.h" | |
| 25 #include "core/workers/WorkerGlobalScope.h" | |
| 26 #include "core/workers/WorkerThread.h" | |
| 27 #include "core/xmlhttprequest/XMLHttpRequest.h" | |
| 28 #include "platform/InstanceCounters.h" | |
| 29 #include "platform/graphics/GraphicsLayer.h" | |
| 30 #include "platform/instrumentation/tracing/TracedValue.h" | |
| 31 #include "platform/network/ResourceLoadPriority.h" | |
| 32 #include "platform/network/ResourceRequest.h" | |
| 33 #include "platform/network/ResourceResponse.h" | 7 #include "platform/network/ResourceResponse.h" |
| 34 #include "platform/weborigin/KURL.h" | |
| 35 #include "wtf/Vector.h" | |
| 36 #include "wtf/text/TextPosition.h" | |
| 37 #include <inttypes.h> | |
| 38 #include <memory> | |
| 39 #include <v8-profiler.h> | |
| 40 #include <v8.h> | |
| 41 | 8 |
| 42 namespace blink { | 9 namespace blink { |
| 43 | 10 |
| 44 String toHexString(const void* p) { | |
| 45 return String::format("0x%" PRIx64, | |
| 46 static_cast<uint64_t>(reinterpret_cast<uintptr_t>(p))); | |
| 47 } | |
| 48 | |
| 49 void setCallStack(TracedValue* value) { | |
| 50 static const unsigned char* traceCategoryEnabled = 0; | |
| 51 WTF_ANNOTATE_BENIGN_RACE(&traceCategoryEnabled, "trace_event category"); | |
| 52 if (!traceCategoryEnabled) | |
| 53 traceCategoryEnabled = TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( | |
| 54 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack")); | |
| 55 if (!*traceCategoryEnabled) | |
| 56 return; | |
| 57 // The CPU profiler stack trace does not include call site line numbers. | |
| 58 // So we collect the top frame with SourceLocation::capture() to get the | |
| 59 // binding call site info. | |
| 60 SourceLocation::capture()->toTracedValue(value, "stackTrace"); | |
| 61 v8::Isolate::GetCurrent()->GetCpuProfiler()->CollectSample(); | |
| 62 } | |
| 63 | |
| 64 namespace { | |
| 65 | |
| 66 void setNodeInfo(TracedValue* value, | |
| 67 Node* node, | |
| 68 const char* idFieldName, | |
| 69 const char* nameFieldName = nullptr) { | |
| 70 value->setInteger(idFieldName, DOMNodeIds::idForNode(node)); | |
| 71 if (nameFieldName) | |
| 72 value->setString(nameFieldName, node->debugName()); | |
| 73 } | |
| 74 | |
| 75 const char* pseudoTypeToString(CSSSelector::PseudoType pseudoType) { | |
| 76 switch (pseudoType) { | |
| 77 #define DEFINE_STRING_MAPPING(pseudoType) \ | |
| 78 case CSSSelector::pseudoType: \ | |
| 79 return #pseudoType; | |
| 80 DEFINE_STRING_MAPPING(PseudoUnknown) | |
| 81 DEFINE_STRING_MAPPING(PseudoEmpty) | |
| 82 DEFINE_STRING_MAPPING(PseudoFirstChild) | |
| 83 DEFINE_STRING_MAPPING(PseudoFirstOfType) | |
| 84 DEFINE_STRING_MAPPING(PseudoLastChild) | |
| 85 DEFINE_STRING_MAPPING(PseudoLastOfType) | |
| 86 DEFINE_STRING_MAPPING(PseudoOnlyChild) | |
| 87 DEFINE_STRING_MAPPING(PseudoOnlyOfType) | |
| 88 DEFINE_STRING_MAPPING(PseudoFirstLine) | |
| 89 DEFINE_STRING_MAPPING(PseudoFirstLetter) | |
| 90 DEFINE_STRING_MAPPING(PseudoNthChild) | |
| 91 DEFINE_STRING_MAPPING(PseudoNthOfType) | |
| 92 DEFINE_STRING_MAPPING(PseudoNthLastChild) | |
| 93 DEFINE_STRING_MAPPING(PseudoNthLastOfType) | |
| 94 DEFINE_STRING_MAPPING(PseudoLink) | |
| 95 DEFINE_STRING_MAPPING(PseudoVisited) | |
| 96 DEFINE_STRING_MAPPING(PseudoAny) | |
| 97 DEFINE_STRING_MAPPING(PseudoAnyLink) | |
| 98 DEFINE_STRING_MAPPING(PseudoAutofill) | |
| 99 DEFINE_STRING_MAPPING(PseudoHover) | |
| 100 DEFINE_STRING_MAPPING(PseudoDrag) | |
| 101 DEFINE_STRING_MAPPING(PseudoFocus) | |
| 102 DEFINE_STRING_MAPPING(PseudoActive) | |
| 103 DEFINE_STRING_MAPPING(PseudoChecked) | |
| 104 DEFINE_STRING_MAPPING(PseudoEnabled) | |
| 105 DEFINE_STRING_MAPPING(PseudoFullPageMedia) | |
| 106 DEFINE_STRING_MAPPING(PseudoDefault) | |
| 107 DEFINE_STRING_MAPPING(PseudoDisabled) | |
| 108 DEFINE_STRING_MAPPING(PseudoOptional) | |
| 109 DEFINE_STRING_MAPPING(PseudoPlaceholderShown) | |
| 110 DEFINE_STRING_MAPPING(PseudoRequired) | |
| 111 DEFINE_STRING_MAPPING(PseudoReadOnly) | |
| 112 DEFINE_STRING_MAPPING(PseudoReadWrite) | |
| 113 DEFINE_STRING_MAPPING(PseudoValid) | |
| 114 DEFINE_STRING_MAPPING(PseudoInvalid) | |
| 115 DEFINE_STRING_MAPPING(PseudoIndeterminate) | |
| 116 DEFINE_STRING_MAPPING(PseudoTarget) | |
| 117 DEFINE_STRING_MAPPING(PseudoBefore) | |
| 118 DEFINE_STRING_MAPPING(PseudoAfter) | |
| 119 DEFINE_STRING_MAPPING(PseudoBackdrop) | |
| 120 DEFINE_STRING_MAPPING(PseudoLang) | |
| 121 DEFINE_STRING_MAPPING(PseudoNot) | |
| 122 DEFINE_STRING_MAPPING(PseudoPlaceholder) | |
| 123 DEFINE_STRING_MAPPING(PseudoResizer) | |
| 124 DEFINE_STRING_MAPPING(PseudoRoot) | |
| 125 DEFINE_STRING_MAPPING(PseudoScope) | |
| 126 DEFINE_STRING_MAPPING(PseudoScrollbar) | |
| 127 DEFINE_STRING_MAPPING(PseudoScrollbarButton) | |
| 128 DEFINE_STRING_MAPPING(PseudoScrollbarCorner) | |
| 129 DEFINE_STRING_MAPPING(PseudoScrollbarThumb) | |
| 130 DEFINE_STRING_MAPPING(PseudoScrollbarTrack) | |
| 131 DEFINE_STRING_MAPPING(PseudoScrollbarTrackPiece) | |
| 132 DEFINE_STRING_MAPPING(PseudoWindowInactive) | |
| 133 DEFINE_STRING_MAPPING(PseudoCornerPresent) | |
| 134 DEFINE_STRING_MAPPING(PseudoDecrement) | |
| 135 DEFINE_STRING_MAPPING(PseudoIncrement) | |
| 136 DEFINE_STRING_MAPPING(PseudoHorizontal) | |
| 137 DEFINE_STRING_MAPPING(PseudoVertical) | |
| 138 DEFINE_STRING_MAPPING(PseudoStart) | |
| 139 DEFINE_STRING_MAPPING(PseudoEnd) | |
| 140 DEFINE_STRING_MAPPING(PseudoDoubleButton) | |
| 141 DEFINE_STRING_MAPPING(PseudoSingleButton) | |
| 142 DEFINE_STRING_MAPPING(PseudoNoButton) | |
| 143 DEFINE_STRING_MAPPING(PseudoSelection) | |
| 144 DEFINE_STRING_MAPPING(PseudoLeftPage) | |
| 145 DEFINE_STRING_MAPPING(PseudoRightPage) | |
| 146 DEFINE_STRING_MAPPING(PseudoFirstPage) | |
| 147 DEFINE_STRING_MAPPING(PseudoFullScreen) | |
| 148 DEFINE_STRING_MAPPING(PseudoFullScreenAncestor) | |
| 149 DEFINE_STRING_MAPPING(PseudoInRange) | |
| 150 DEFINE_STRING_MAPPING(PseudoOutOfRange) | |
| 151 DEFINE_STRING_MAPPING(PseudoWebKitCustomElement) | |
| 152 DEFINE_STRING_MAPPING(PseudoBlinkInternalElement) | |
| 153 DEFINE_STRING_MAPPING(PseudoCue) | |
| 154 DEFINE_STRING_MAPPING(PseudoFutureCue) | |
| 155 DEFINE_STRING_MAPPING(PseudoPastCue) | |
| 156 DEFINE_STRING_MAPPING(PseudoUnresolved) | |
| 157 DEFINE_STRING_MAPPING(PseudoDefined) | |
| 158 DEFINE_STRING_MAPPING(PseudoContent) | |
| 159 DEFINE_STRING_MAPPING(PseudoHost) | |
| 160 DEFINE_STRING_MAPPING(PseudoHostContext) | |
| 161 DEFINE_STRING_MAPPING(PseudoShadow) | |
| 162 DEFINE_STRING_MAPPING(PseudoSlotted) | |
| 163 DEFINE_STRING_MAPPING(PseudoSpatialNavigationFocus) | |
| 164 DEFINE_STRING_MAPPING(PseudoListBox) | |
| 165 DEFINE_STRING_MAPPING(PseudoHostHasAppearance) | |
| 166 #undef DEFINE_STRING_MAPPING | |
| 167 } | |
| 168 | |
| 169 ASSERT_NOT_REACHED(); | |
| 170 return ""; | |
| 171 } | |
| 172 | |
| 173 String urlForFrame(LocalFrame* frame) { | |
| 174 KURL url = frame->document()->url(); | |
| 175 url.removeFragmentIdentifier(); | |
| 176 return url.getString(); | |
| 177 } | |
| 178 | |
| 179 } // namespace | |
| 180 | |
| 181 namespace InspectorScheduleStyleInvalidationTrackingEvent { | |
| 182 std::unique_ptr<TracedValue> fillCommonPart( | |
| 183 ContainerNode& node, | |
| 184 const InvalidationSet& invalidationSet, | |
| 185 const char* invalidatedSelector) { | |
| 186 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 187 value->setString("frame", toHexString(node.document().frame())); | |
| 188 setNodeInfo(value.get(), &node, "nodeId", "nodeName"); | |
| 189 value->setString("invalidationSet", | |
| 190 descendantInvalidationSetToIdString(invalidationSet)); | |
| 191 value->setString("invalidatedSelectorId", invalidatedSelector); | |
| 192 SourceLocation::capture()->toTracedValue(value.get(), "stackTrace"); | |
| 193 return value; | |
| 194 } | |
| 195 } // namespace InspectorScheduleStyleInvalidationTrackingEvent | |
| 196 | |
| 197 const char InspectorScheduleStyleInvalidationTrackingEvent::Attribute[] = | |
| 198 "attribute"; | |
| 199 const char InspectorScheduleStyleInvalidationTrackingEvent::Class[] = "class"; | |
| 200 const char InspectorScheduleStyleInvalidationTrackingEvent::Id[] = "id"; | |
| 201 const char InspectorScheduleStyleInvalidationTrackingEvent::Pseudo[] = "pseudo"; | |
| 202 const char InspectorScheduleStyleInvalidationTrackingEvent::RuleSet[] = | |
| 203 "ruleset"; | |
| 204 | |
| 205 const char* resourcePriorityString(ResourceLoadPriority priority) { | |
| 206 const char* priorityString = 0; | |
| 207 switch (priority) { | |
| 208 case ResourceLoadPriorityVeryLow: | |
| 209 priorityString = "VeryLow"; | |
| 210 break; | |
| 211 case ResourceLoadPriorityLow: | |
| 212 priorityString = "Low"; | |
| 213 break; | |
| 214 case ResourceLoadPriorityMedium: | |
| 215 priorityString = "Medium"; | |
| 216 break; | |
| 217 case ResourceLoadPriorityHigh: | |
| 218 priorityString = "High"; | |
| 219 break; | |
| 220 case ResourceLoadPriorityVeryHigh: | |
| 221 priorityString = "VeryHigh"; | |
| 222 break; | |
| 223 case ResourceLoadPriorityUnresolved: | |
| 224 break; | |
| 225 } | |
| 226 return priorityString; | |
| 227 } | |
| 228 | |
| 229 std::unique_ptr<TracedValue> | |
| 230 InspectorScheduleStyleInvalidationTrackingEvent::idChange( | |
| 231 Element& element, | |
| 232 const InvalidationSet& invalidationSet, | |
| 233 const AtomicString& id) { | |
| 234 std::unique_ptr<TracedValue> value = | |
| 235 fillCommonPart(element, invalidationSet, Id); | |
| 236 value->setString("changedId", id); | |
| 237 return value; | |
| 238 } | |
| 239 | |
| 240 std::unique_ptr<TracedValue> | |
| 241 InspectorScheduleStyleInvalidationTrackingEvent::classChange( | |
| 242 Element& element, | |
| 243 const InvalidationSet& invalidationSet, | |
| 244 const AtomicString& className) { | |
| 245 std::unique_ptr<TracedValue> value = | |
| 246 fillCommonPart(element, invalidationSet, Class); | |
| 247 value->setString("changedClass", className); | |
| 248 return value; | |
| 249 } | |
| 250 | |
| 251 std::unique_ptr<TracedValue> | |
| 252 InspectorScheduleStyleInvalidationTrackingEvent::attributeChange( | |
| 253 Element& element, | |
| 254 const InvalidationSet& invalidationSet, | |
| 255 const QualifiedName& attributeName) { | |
| 256 std::unique_ptr<TracedValue> value = | |
| 257 fillCommonPart(element, invalidationSet, Attribute); | |
| 258 value->setString("changedAttribute", attributeName.toString()); | |
| 259 return value; | |
| 260 } | |
| 261 | |
| 262 std::unique_ptr<TracedValue> | |
| 263 InspectorScheduleStyleInvalidationTrackingEvent::pseudoChange( | |
| 264 Element& element, | |
| 265 const InvalidationSet& invalidationSet, | |
| 266 CSSSelector::PseudoType pseudoType) { | |
| 267 std::unique_ptr<TracedValue> value = | |
| 268 fillCommonPart(element, invalidationSet, Attribute); | |
| 269 value->setString("changedPseudo", pseudoTypeToString(pseudoType)); | |
| 270 return value; | |
| 271 } | |
| 272 | |
| 273 std::unique_ptr<TracedValue> | |
| 274 InspectorScheduleStyleInvalidationTrackingEvent::ruleSetInvalidation( | |
| 275 ContainerNode& rootNode, | |
| 276 const InvalidationSet& invalidationSet) { | |
| 277 std::unique_ptr<TracedValue> value = | |
| 278 fillCommonPart(rootNode, invalidationSet, RuleSet); | |
| 279 return value; | |
| 280 } | |
| 281 | |
| 282 String descendantInvalidationSetToIdString(const InvalidationSet& set) { | |
| 283 return toHexString(&set); | |
| 284 } | |
| 285 | |
| 286 const char InspectorStyleInvalidatorInvalidateEvent:: | |
| 287 ElementHasPendingInvalidationList[] = | |
| 288 "Element has pending invalidation list"; | |
| 289 const char InspectorStyleInvalidatorInvalidateEvent::InvalidateCustomPseudo[] = | |
| 290 "Invalidate custom pseudo element"; | |
| 291 const char InspectorStyleInvalidatorInvalidateEvent:: | |
| 292 InvalidationSetMatchedAttribute[] = "Invalidation set matched attribute"; | |
| 293 const char | |
| 294 InspectorStyleInvalidatorInvalidateEvent::InvalidationSetMatchedClass[] = | |
| 295 "Invalidation set matched class"; | |
| 296 const char | |
| 297 InspectorStyleInvalidatorInvalidateEvent::InvalidationSetMatchedId[] = | |
| 298 "Invalidation set matched id"; | |
| 299 const char | |
| 300 InspectorStyleInvalidatorInvalidateEvent::InvalidationSetMatchedTagName[] = | |
| 301 "Invalidation set matched tagName"; | |
| 302 const char | |
| 303 InspectorStyleInvalidatorInvalidateEvent::PreventStyleSharingForParent[] = | |
| 304 "Prevent style sharing for parent"; | |
| 305 | |
| 306 namespace InspectorStyleInvalidatorInvalidateEvent { | |
| 307 std::unique_ptr<TracedValue> fillCommonPart(ContainerNode& node, | |
| 308 const char* reason) { | |
| 309 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 310 value->setString("frame", toHexString(node.document().frame())); | |
| 311 setNodeInfo(value.get(), &node, "nodeId", "nodeName"); | |
| 312 value->setString("reason", reason); | |
| 313 return value; | |
| 314 } | |
| 315 } // namespace InspectorStyleInvalidatorInvalidateEvent | |
| 316 | |
| 317 std::unique_ptr<TracedValue> InspectorStyleInvalidatorInvalidateEvent::data( | |
| 318 Element& element, | |
| 319 const char* reason) { | |
| 320 return fillCommonPart(element, reason); | |
| 321 } | |
| 322 | |
| 323 std::unique_ptr<TracedValue> | |
| 324 InspectorStyleInvalidatorInvalidateEvent::selectorPart( | |
| 325 Element& element, | |
| 326 const char* reason, | |
| 327 const InvalidationSet& invalidationSet, | |
| 328 const String& selectorPart) { | |
| 329 std::unique_ptr<TracedValue> value = fillCommonPart(element, reason); | |
| 330 value->beginArray("invalidationList"); | |
| 331 invalidationSet.toTracedValue(value.get()); | |
| 332 value->endArray(); | |
| 333 value->setString("selectorPart", selectorPart); | |
| 334 return value; | |
| 335 } | |
| 336 | |
| 337 std::unique_ptr<TracedValue> | |
| 338 InspectorStyleInvalidatorInvalidateEvent::invalidationList( | |
| 339 ContainerNode& node, | |
| 340 const Vector<RefPtr<InvalidationSet>>& invalidationList) { | |
| 341 std::unique_ptr<TracedValue> value = | |
| 342 fillCommonPart(node, ElementHasPendingInvalidationList); | |
| 343 value->beginArray("invalidationList"); | |
| 344 for (const auto& invalidationSet : invalidationList) | |
| 345 invalidationSet->toTracedValue(value.get()); | |
| 346 value->endArray(); | |
| 347 return value; | |
| 348 } | |
| 349 | |
| 350 std::unique_ptr<TracedValue> | |
| 351 InspectorStyleRecalcInvalidationTrackingEvent::data( | |
| 352 Node* node, | |
| 353 const StyleChangeReasonForTracing& reason) { | |
| 354 ASSERT(node); | |
| 355 | |
| 356 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 357 value->setString("frame", toHexString(node->document().frame())); | |
| 358 setNodeInfo(value.get(), node, "nodeId", "nodeName"); | |
| 359 value->setString("reason", reason.reasonString()); | |
| 360 value->setString("extraData", reason.getExtraData()); | |
| 361 SourceLocation::capture()->toTracedValue(value.get(), "stackTrace"); | |
| 362 return value; | |
| 363 } | |
| 364 | |
| 365 std::unique_ptr<TracedValue> InspectorLayoutEvent::beginData( | |
| 366 FrameView* frameView) { | |
| 367 bool isPartial; | |
| 368 unsigned needsLayoutObjects; | |
| 369 unsigned totalObjects; | |
| 370 LocalFrame& frame = frameView->frame(); | |
| 371 frame.view()->countObjectsNeedingLayout(needsLayoutObjects, totalObjects, | |
| 372 isPartial); | |
| 373 | |
| 374 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 375 value->setInteger("dirtyObjects", needsLayoutObjects); | |
| 376 value->setInteger("totalObjects", totalObjects); | |
| 377 value->setBoolean("partialLayout", isPartial); | |
| 378 value->setString("frame", toHexString(&frame)); | |
| 379 setCallStack(value.get()); | |
| 380 return value; | |
| 381 } | |
| 382 | |
| 383 static void createQuad(TracedValue* value, | |
| 384 const char* name, | |
| 385 const FloatQuad& quad) { | |
| 386 value->beginArray(name); | |
| 387 value->pushDouble(quad.p1().x()); | |
| 388 value->pushDouble(quad.p1().y()); | |
| 389 value->pushDouble(quad.p2().x()); | |
| 390 value->pushDouble(quad.p2().y()); | |
| 391 value->pushDouble(quad.p3().x()); | |
| 392 value->pushDouble(quad.p3().y()); | |
| 393 value->pushDouble(quad.p4().x()); | |
| 394 value->pushDouble(quad.p4().y()); | |
| 395 value->endArray(); | |
| 396 } | |
| 397 | |
| 398 static void setGeneratingNodeInfo(TracedValue* value, | |
| 399 const LayoutObject* layoutObject, | |
| 400 const char* idFieldName, | |
| 401 const char* nameFieldName = nullptr) { | |
| 402 Node* node = nullptr; | |
| 403 for (; layoutObject && !node; layoutObject = layoutObject->parent()) | |
| 404 node = layoutObject->generatingNode(); | |
| 405 if (!node) | |
| 406 return; | |
| 407 | |
| 408 setNodeInfo(value, node, idFieldName, nameFieldName); | |
| 409 } | |
| 410 | |
| 411 std::unique_ptr<TracedValue> InspectorLayoutEvent::endData( | |
| 412 LayoutObject* rootForThisLayout) { | |
| 413 Vector<FloatQuad> quads; | |
| 414 rootForThisLayout->absoluteQuads(quads); | |
| 415 | |
| 416 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 417 if (quads.size() >= 1) { | |
| 418 createQuad(value.get(), "root", quads[0]); | |
| 419 setGeneratingNodeInfo(value.get(), rootForThisLayout, "rootNode"); | |
| 420 } else { | |
| 421 ASSERT_NOT_REACHED(); | |
| 422 } | |
| 423 return value; | |
| 424 } | |
| 425 | |
| 426 namespace LayoutInvalidationReason { | |
| 427 const char Unknown[] = "Unknown"; | |
| 428 const char SizeChanged[] = "Size changed"; | |
| 429 const char AncestorMoved[] = "Ancestor moved"; | |
| 430 const char StyleChange[] = "Style changed"; | |
| 431 const char DomChanged[] = "DOM changed"; | |
| 432 const char TextChanged[] = "Text changed"; | |
| 433 const char PrintingChanged[] = "Printing changed"; | |
| 434 const char AttributeChanged[] = "Attribute changed"; | |
| 435 const char ColumnsChanged[] = "Attribute changed"; | |
| 436 const char ChildAnonymousBlockChanged[] = "Child anonymous block changed"; | |
| 437 const char AnonymousBlockChange[] = "Anonymous block change"; | |
| 438 const char Fullscreen[] = "Fullscreen change"; | |
| 439 const char ChildChanged[] = "Child changed"; | |
| 440 const char ListValueChange[] = "List value change"; | |
| 441 const char ImageChanged[] = "Image changed"; | |
| 442 const char LineBoxesChanged[] = "Line boxes changed"; | |
| 443 const char SliderValueChanged[] = "Slider value changed"; | |
| 444 const char AncestorMarginCollapsing[] = "Ancestor margin collapsing"; | |
| 445 const char FieldsetChanged[] = "Fieldset changed"; | |
| 446 const char TextAutosizing[] = "Text autosizing (font boosting)"; | |
| 447 const char SvgResourceInvalidated[] = "SVG resource invalidated"; | |
| 448 const char FloatDescendantChanged[] = "Floating descendant changed"; | |
| 449 const char CountersChanged[] = "Counters changed"; | |
| 450 const char GridChanged[] = "Grid changed"; | |
| 451 const char MenuOptionsChanged[] = "Menu options changed"; | |
| 452 const char RemovedFromLayout[] = "Removed from layout"; | |
| 453 const char AddedToLayout[] = "Added to layout"; | |
| 454 const char TableChanged[] = "Table changed"; | |
| 455 const char PaddingChanged[] = "Padding changed"; | |
| 456 const char TextControlChanged[] = "Text control changed"; | |
| 457 const char SvgChanged[] = "SVG changed"; | |
| 458 const char ScrollbarChanged[] = "Scrollbar changed"; | |
| 459 } // namespace LayoutInvalidationReason | |
| 460 | |
| 461 std::unique_ptr<TracedValue> InspectorLayoutInvalidationTrackingEvent::data( | |
| 462 const LayoutObject* layoutObject, | |
| 463 LayoutInvalidationReasonForTracing reason) { | |
| 464 ASSERT(layoutObject); | |
| 465 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 466 value->setString("frame", toHexString(layoutObject->frame())); | |
| 467 setGeneratingNodeInfo(value.get(), layoutObject, "nodeId", "nodeName"); | |
| 468 value->setString("reason", reason); | |
| 469 SourceLocation::capture()->toTracedValue(value.get(), "stackTrace"); | |
| 470 return value; | |
| 471 } | |
| 472 | |
| 473 std::unique_ptr<TracedValue> InspectorPaintInvalidationTrackingEvent::data( | |
| 474 const LayoutObject* layoutObject, | |
| 475 const LayoutObject& paintContainer) { | |
| 476 ASSERT(layoutObject); | |
| 477 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 478 value->setString("frame", toHexString(layoutObject->frame())); | |
| 479 setGeneratingNodeInfo(value.get(), &paintContainer, "paintId"); | |
| 480 setGeneratingNodeInfo(value.get(), layoutObject, "nodeId", "nodeName"); | |
| 481 return value; | |
| 482 } | |
| 483 | |
| 484 std::unique_ptr<TracedValue> InspectorScrollInvalidationTrackingEvent::data( | |
| 485 const LayoutObject& layoutObject) { | |
| 486 static const char ScrollInvalidationReason[] = | |
| 487 "Scroll with viewport-constrained element"; | |
| 488 | |
| 489 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 490 value->setString("frame", toHexString(layoutObject.frame())); | |
| 491 value->setString("reason", ScrollInvalidationReason); | |
| 492 setGeneratingNodeInfo(value.get(), &layoutObject, "nodeId", "nodeName"); | |
| 493 SourceLocation::capture()->toTracedValue(value.get(), "stackTrace"); | |
| 494 return value; | |
| 495 } | |
| 496 | |
| 497 std::unique_ptr<TracedValue> InspectorChangeResourcePriorityEvent::data( | |
| 498 unsigned long identifier, | |
| 499 const ResourceLoadPriority& loadPriority) { | |
| 500 String requestId = IdentifiersFactory::requestId(identifier); | |
| 501 | |
| 502 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 503 value->setString("requestId", requestId); | |
| 504 value->setString("priority", resourcePriorityString(loadPriority)); | |
| 505 return value; | |
| 506 } | |
| 507 | |
| 508 std::unique_ptr<TracedValue> InspectorSendRequestEvent::data( | |
| 509 unsigned long identifier, | |
| 510 LocalFrame* frame, | |
| 511 const ResourceRequest& request) { | |
| 512 String requestId = IdentifiersFactory::requestId(identifier); | |
| 513 | |
| 514 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 515 value->setString("requestId", requestId); | |
| 516 value->setString("frame", toHexString(frame)); | |
| 517 value->setString("url", request.url().getString()); | |
| 518 value->setString("requestMethod", request.httpMethod()); | |
| 519 const char* priority = resourcePriorityString(request.priority()); | |
| 520 if (priority) | |
| 521 value->setString("priority", priority); | |
| 522 setCallStack(value.get()); | |
| 523 return value; | |
| 524 } | |
| 525 | |
| 526 namespace { | 11 namespace { |
| 527 void recordTiming(const ResourceLoadTiming& timing, TracedValue* value) { | 12 void recordTiming(const ResourceLoadTiming& timing, TracedValue* value) { |
| 528 value->setDouble("requestTime", timing.requestTime()); | 13 value->setDouble("requestTime", timing.requestTime()); |
| 529 value->setDouble("proxyStart", | 14 value->setDouble("proxyStart", |
| 530 timing.calculateMillisecondDelta(timing.proxyStart())); | 15 timing.calculateMillisecondDelta(timing.proxyStart())); |
| 531 value->setDouble("proxyEnd", | 16 value->setDouble("proxyEnd", |
| 532 timing.calculateMillisecondDelta(timing.proxyEnd())); | 17 timing.calculateMillisecondDelta(timing.proxyEnd())); |
| 533 value->setDouble("dnsStart", | 18 value->setDouble("dnsStart", |
| 534 timing.calculateMillisecondDelta(timing.dnsStart())); | 19 timing.calculateMillisecondDelta(timing.dnsStart())); |
| 535 value->setDouble("dnsEnd", timing.calculateMillisecondDelta(timing.dnsEnd())); | 20 value->setDouble("dnsEnd", timing.calculateMillisecondDelta(timing.dnsEnd())); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 550 timing.calculateMillisecondDelta(timing.sendEnd())); | 35 timing.calculateMillisecondDelta(timing.sendEnd())); |
| 551 value->setDouble("receiveHeadersEnd", timing.calculateMillisecondDelta( | 36 value->setDouble("receiveHeadersEnd", timing.calculateMillisecondDelta( |
| 552 timing.receiveHeadersEnd())); | 37 timing.receiveHeadersEnd())); |
| 553 value->setDouble("pushStart", timing.pushStart()); | 38 value->setDouble("pushStart", timing.pushStart()); |
| 554 value->setDouble("pushEnd", timing.pushEnd()); | 39 value->setDouble("pushEnd", timing.pushEnd()); |
| 555 } | 40 } |
| 556 } // namespace | 41 } // namespace |
| 557 | 42 |
| 558 std::unique_ptr<TracedValue> InspectorReceiveResponseEvent::data( | 43 std::unique_ptr<TracedValue> InspectorReceiveResponseEvent::data( |
| 559 unsigned long identifier, | 44 unsigned long identifier, |
| 560 LocalFrame* frame, | |
| 561 const ResourceResponse& response) { | 45 const ResourceResponse& response) { |
| 562 String requestId = IdentifiersFactory::requestId(identifier); | |
| 563 | |
| 564 std::unique_ptr<TracedValue> value = TracedValue::create(); | 46 std::unique_ptr<TracedValue> value = TracedValue::create(); |
| 565 value->setString("requestId", requestId); | 47 value->setString("requestId", String::number(identifier)); |
| 566 value->setString("frame", toHexString(frame)); | |
| 567 value->setInteger("statusCode", response.httpStatusCode()); | 48 value->setInteger("statusCode", response.httpStatusCode()); |
| 568 value->setString("mimeType", response.mimeType().getString().isolatedCopy()); | 49 value->setString("mimeType", response.mimeType().getString().isolatedCopy()); |
| 569 value->setDouble("encodedDataLength", response.encodedDataLength()); | 50 value->setDouble("encodedDataLength", response.encodedDataLength()); |
| 570 value->setBoolean("fromCache", response.wasCached()); | 51 value->setBoolean("fromCache", response.wasCached()); |
| 571 value->setBoolean("fromServiceWorker", response.wasFetchedViaServiceWorker()); | 52 value->setBoolean("fromServiceWorker", response.wasFetchedViaServiceWorker()); |
| 572 if (response.resourceLoadTiming()) { | 53 if (response.resourceLoadTiming()) { |
| 573 value->beginDictionary("timing"); | 54 value->beginDictionary("timing"); |
| 574 recordTiming(*response.resourceLoadTiming(), value.get()); | 55 recordTiming(*response.resourceLoadTiming(), value.get()); |
| 575 value->endDictionary(); | 56 value->endDictionary(); |
| 576 } | 57 } |
| 577 if (response.wasFetchedViaServiceWorker()) | 58 if (response.wasFetchedViaServiceWorker()) |
| 578 value->setBoolean("fromServiceWorker", true); | 59 value->setBoolean("fromServiceWorker", true); |
| 579 return value; | 60 return value; |
| 580 } | 61 } |
| 581 | 62 |
| 582 std::unique_ptr<TracedValue> InspectorReceiveDataEvent::data( | 63 std::unique_ptr<TracedValue> InspectorReceiveDataEvent::data( |
| 583 unsigned long identifier, | 64 unsigned long identifier, |
| 584 LocalFrame* frame, | |
| 585 int encodedDataLength) { | 65 int encodedDataLength) { |
| 586 String requestId = IdentifiersFactory::requestId(identifier); | |
| 587 | |
| 588 std::unique_ptr<TracedValue> value = TracedValue::create(); | 66 std::unique_ptr<TracedValue> value = TracedValue::create(); |
| 589 value->setString("requestId", requestId); | 67 value->setString("requestId", String::number(identifier)); |
| 590 value->setString("frame", toHexString(frame)); | |
| 591 value->setInteger("encodedDataLength", encodedDataLength); | 68 value->setInteger("encodedDataLength", encodedDataLength); |
| 592 return value; | 69 return value; |
| 593 } | 70 } |
| 594 | 71 |
| 595 std::unique_ptr<TracedValue> InspectorResourceFinishEvent::data( | 72 std::unique_ptr<TracedValue> InspectorResourceFinishEvent::data( |
| 596 unsigned long identifier, | 73 unsigned long identifier, |
| 597 double finishTime, | 74 double finishTime, |
| 598 bool didFail, | 75 bool didFail, |
| 599 int64_t encodedDataLength) { | 76 int64_t encodedDataLength) { |
| 600 String requestId = IdentifiersFactory::requestId(identifier); | |
| 601 | |
| 602 std::unique_ptr<TracedValue> value = TracedValue::create(); | 77 std::unique_ptr<TracedValue> value = TracedValue::create(); |
| 603 value->setString("requestId", requestId); | 78 value->setString("requestId", String::number(identifier)); |
| 604 value->setBoolean("didFail", didFail); | 79 value->setBoolean("didFail", didFail); |
| 605 value->setDouble("encodedDataLength", encodedDataLength); | 80 value->setDouble("encodedDataLength", encodedDataLength); |
| 606 if (finishTime) | 81 if (finishTime) |
| 607 value->setDouble("finishTime", finishTime); | 82 value->setDouble("finishTime", finishTime); |
| 608 return value; | 83 return value; |
| 609 } | 84 } |
| 610 | 85 |
| 611 static LocalFrame* frameForExecutionContext(ExecutionContext* context) { | |
| 612 LocalFrame* frame = nullptr; | |
| 613 if (context->isDocument()) | |
| 614 frame = toDocument(context)->frame(); | |
| 615 return frame; | |
| 616 } | |
| 617 | |
| 618 static std::unique_ptr<TracedValue> genericTimerData(ExecutionContext* context, | |
| 619 int timerId) { | |
| 620 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 621 value->setInteger("timerId", timerId); | |
| 622 if (LocalFrame* frame = frameForExecutionContext(context)) | |
| 623 value->setString("frame", toHexString(frame)); | |
| 624 return value; | |
| 625 } | |
| 626 | |
| 627 std::unique_ptr<TracedValue> InspectorTimerInstallEvent::data( | |
| 628 ExecutionContext* context, | |
| 629 int timerId, | |
| 630 int timeout, | |
| 631 bool singleShot) { | |
| 632 std::unique_ptr<TracedValue> value = genericTimerData(context, timerId); | |
| 633 value->setInteger("timeout", timeout); | |
| 634 value->setBoolean("singleShot", singleShot); | |
| 635 setCallStack(value.get()); | |
| 636 return value; | |
| 637 } | |
| 638 | |
| 639 std::unique_ptr<TracedValue> InspectorTimerRemoveEvent::data( | |
| 640 ExecutionContext* context, | |
| 641 int timerId) { | |
| 642 std::unique_ptr<TracedValue> value = genericTimerData(context, timerId); | |
| 643 setCallStack(value.get()); | |
| 644 return value; | |
| 645 } | |
| 646 | |
| 647 std::unique_ptr<TracedValue> InspectorTimerFireEvent::data( | |
| 648 ExecutionContext* context, | |
| 649 int timerId) { | |
| 650 return genericTimerData(context, timerId); | |
| 651 } | |
| 652 | |
| 653 std::unique_ptr<TracedValue> InspectorAnimationFrameEvent::data( | |
| 654 ExecutionContext* context, | |
| 655 int callbackId) { | |
| 656 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 657 value->setInteger("id", callbackId); | |
| 658 if (context->isDocument()) | |
| 659 value->setString("frame", toHexString(toDocument(context)->frame())); | |
| 660 else if (context->isWorkerGlobalScope()) | |
| 661 value->setString("worker", toHexString(toWorkerGlobalScope(context))); | |
| 662 setCallStack(value.get()); | |
| 663 return value; | |
| 664 } | |
| 665 | |
| 666 std::unique_ptr<TracedValue> genericIdleCallbackEvent(ExecutionContext* context, | |
| 667 int id) { | |
| 668 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 669 value->setInteger("id", id); | |
| 670 if (LocalFrame* frame = frameForExecutionContext(context)) | |
| 671 value->setString("frame", toHexString(frame)); | |
| 672 setCallStack(value.get()); | |
| 673 return value; | |
| 674 } | |
| 675 | |
| 676 std::unique_ptr<TracedValue> InspectorIdleCallbackRequestEvent::data( | |
| 677 ExecutionContext* context, | |
| 678 int id, | |
| 679 double timeout) { | |
| 680 std::unique_ptr<TracedValue> value = genericIdleCallbackEvent(context, id); | |
| 681 value->setInteger("timeout", timeout); | |
| 682 return value; | |
| 683 } | |
| 684 | |
| 685 std::unique_ptr<TracedValue> InspectorIdleCallbackCancelEvent::data( | |
| 686 ExecutionContext* context, | |
| 687 int id) { | |
| 688 return genericIdleCallbackEvent(context, id); | |
| 689 } | |
| 690 | |
| 691 std::unique_ptr<TracedValue> InspectorIdleCallbackFireEvent::data( | |
| 692 ExecutionContext* context, | |
| 693 int id, | |
| 694 double allottedMilliseconds, | |
| 695 bool timedOut) { | |
| 696 std::unique_ptr<TracedValue> value = genericIdleCallbackEvent(context, id); | |
| 697 value->setDouble("allottedMilliseconds", allottedMilliseconds); | |
| 698 value->setBoolean("timedOut", timedOut); | |
| 699 return value; | |
| 700 } | |
| 701 | |
| 702 std::unique_ptr<TracedValue> InspectorParseHtmlEvent::beginData( | |
| 703 Document* document, | |
| 704 unsigned startLine) { | |
| 705 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 706 value->setInteger("startLine", startLine); | |
| 707 value->setString("frame", toHexString(document->frame())); | |
| 708 value->setString("url", document->url().getString()); | |
| 709 setCallStack(value.get()); | |
| 710 return value; | |
| 711 } | |
| 712 | |
| 713 std::unique_ptr<TracedValue> InspectorParseHtmlEvent::endData( | |
| 714 unsigned endLine) { | |
| 715 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 716 value->setInteger("endLine", endLine); | |
| 717 return value; | |
| 718 } | |
| 719 | |
| 720 std::unique_ptr<TracedValue> InspectorParseAuthorStyleSheetEvent::data( | |
| 721 const CSSStyleSheetResource* cachedStyleSheet) { | |
| 722 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 723 value->setString("styleSheetUrl", cachedStyleSheet->url().getString()); | |
| 724 return value; | |
| 725 } | |
| 726 | |
| 727 std::unique_ptr<TracedValue> InspectorXhrReadyStateChangeEvent::data( | |
| 728 ExecutionContext* context, | |
| 729 XMLHttpRequest* request) { | |
| 730 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 731 value->setString("url", request->url().getString()); | |
| 732 value->setInteger("readyState", request->readyState()); | |
| 733 if (LocalFrame* frame = frameForExecutionContext(context)) | |
| 734 value->setString("frame", toHexString(frame)); | |
| 735 setCallStack(value.get()); | |
| 736 return value; | |
| 737 } | |
| 738 | |
| 739 std::unique_ptr<TracedValue> InspectorXhrLoadEvent::data( | |
| 740 ExecutionContext* context, | |
| 741 XMLHttpRequest* request) { | |
| 742 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 743 value->setString("url", request->url().getString()); | |
| 744 if (LocalFrame* frame = frameForExecutionContext(context)) | |
| 745 value->setString("frame", toHexString(frame)); | |
| 746 setCallStack(value.get()); | |
| 747 return value; | |
| 748 } | |
| 749 | |
| 750 static void localToPageQuad(const LayoutObject& layoutObject, | |
| 751 const LayoutRect& rect, | |
| 752 FloatQuad* quad) { | |
| 753 LocalFrame* frame = layoutObject.frame(); | |
| 754 FrameView* view = frame->view(); | |
| 755 FloatQuad absolute = | |
| 756 layoutObject.localToAbsoluteQuad(FloatQuad(FloatRect(rect))); | |
| 757 quad->setP1(view->contentsToRootFrame(roundedIntPoint(absolute.p1()))); | |
| 758 quad->setP2(view->contentsToRootFrame(roundedIntPoint(absolute.p2()))); | |
| 759 quad->setP3(view->contentsToRootFrame(roundedIntPoint(absolute.p3()))); | |
| 760 quad->setP4(view->contentsToRootFrame(roundedIntPoint(absolute.p4()))); | |
| 761 } | |
| 762 | |
| 763 const char InspectorLayerInvalidationTrackingEvent:: | |
| 764 SquashingLayerGeometryWasUpdated[] = "Squashing layer geometry was updated"; | |
| 765 const char InspectorLayerInvalidationTrackingEvent::AddedToSquashingLayer[] = | |
| 766 "The layer may have been added to an already-existing squashing layer"; | |
| 767 const char | |
| 768 InspectorLayerInvalidationTrackingEvent::RemovedFromSquashingLayer[] = | |
| 769 "Removed the layer from a squashing layer"; | |
| 770 const char InspectorLayerInvalidationTrackingEvent::ReflectionLayerChanged[] = | |
| 771 "Reflection layer change"; | |
| 772 const char InspectorLayerInvalidationTrackingEvent::NewCompositedLayer[] = | |
| 773 "Assigned a new composited layer"; | |
| 774 | |
| 775 std::unique_ptr<TracedValue> InspectorLayerInvalidationTrackingEvent::data( | |
| 776 const PaintLayer* layer, | |
| 777 const char* reason) { | |
| 778 const LayoutObject& paintInvalidationContainer = | |
| 779 layer->layoutObject().containerForPaintInvalidation(); | |
| 780 | |
| 781 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 782 value->setString("frame", toHexString(paintInvalidationContainer.frame())); | |
| 783 setGeneratingNodeInfo(value.get(), &paintInvalidationContainer, "paintId"); | |
| 784 value->setString("reason", reason); | |
| 785 return value; | |
| 786 } | |
| 787 | |
| 788 std::unique_ptr<TracedValue> InspectorPaintEvent::data( | |
| 789 LayoutObject* layoutObject, | |
| 790 const LayoutRect& clipRect, | |
| 791 const GraphicsLayer* graphicsLayer) { | |
| 792 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 793 value->setString("frame", toHexString(layoutObject->frame())); | |
| 794 FloatQuad quad; | |
| 795 localToPageQuad(*layoutObject, clipRect, &quad); | |
| 796 createQuad(value.get(), "clip", quad); | |
| 797 setGeneratingNodeInfo(value.get(), layoutObject, "nodeId"); | |
| 798 int graphicsLayerId = | |
| 799 graphicsLayer ? graphicsLayer->platformLayer()->id() : 0; | |
| 800 value->setInteger("layerId", graphicsLayerId); | |
| 801 setCallStack(value.get()); | |
| 802 return value; | |
| 803 } | |
| 804 | |
| 805 std::unique_ptr<TracedValue> frameEventData(LocalFrame* frame) { | |
| 806 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 807 bool isMainFrame = frame && frame->isMainFrame(); | |
| 808 value->setBoolean("isMainFrame", isMainFrame); | |
| 809 value->setString("page", toHexString(frame->localFrameRoot())); | |
| 810 return value; | |
| 811 } | |
| 812 | |
| 813 void fillCommonFrameData(TracedValue* frameData, LocalFrame* frame) { | |
| 814 frameData->setString("frame", toHexString(frame)); | |
| 815 frameData->setString("url", urlForFrame(frame)); | |
| 816 frameData->setString("name", frame->tree().name()); | |
| 817 | |
| 818 FrameOwner* owner = frame->owner(); | |
| 819 if (owner && owner->isLocal()) { | |
| 820 frameData->setInteger( | |
| 821 "nodeId", DOMNodeIds::idForNode(toHTMLFrameOwnerElement(owner))); | |
| 822 } | |
| 823 Frame* parent = frame->tree().parent(); | |
| 824 if (parent && parent->isLocalFrame()) | |
| 825 frameData->setString("parent", toHexString(parent)); | |
| 826 } | |
| 827 | |
| 828 std::unique_ptr<TracedValue> InspectorCommitLoadEvent::data(LocalFrame* frame) { | |
| 829 std::unique_ptr<TracedValue> frameData = frameEventData(frame); | |
| 830 fillCommonFrameData(frameData.get(), frame); | |
| 831 return frameData; | |
| 832 } | |
| 833 | |
| 834 std::unique_ptr<TracedValue> InspectorMarkLoadEvent::data(LocalFrame* frame) { | |
| 835 std::unique_ptr<TracedValue> frameData = frameEventData(frame); | |
| 836 frameData->setString("frame", toHexString(frame)); | |
| 837 return frameData; | |
| 838 } | |
| 839 | |
| 840 std::unique_ptr<TracedValue> InspectorScrollLayerEvent::data( | |
| 841 LayoutObject* layoutObject) { | |
| 842 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 843 value->setString("frame", toHexString(layoutObject->frame())); | |
| 844 setGeneratingNodeInfo(value.get(), layoutObject, "nodeId"); | |
| 845 return value; | |
| 846 } | |
| 847 | |
| 848 std::unique_ptr<TracedValue> InspectorUpdateLayerTreeEvent::data( | |
| 849 LocalFrame* frame) { | |
| 850 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 851 value->setString("frame", toHexString(frame)); | |
| 852 return value; | |
| 853 } | |
| 854 | |
| 855 namespace { | |
| 856 std::unique_ptr<TracedValue> fillLocation(const String& url, | |
| 857 const TextPosition& textPosition) { | |
| 858 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 859 value->setString("url", url); | |
| 860 value->setInteger("lineNumber", textPosition.m_line.oneBasedInt()); | |
| 861 value->setInteger("columnNumber", textPosition.m_column.oneBasedInt()); | |
| 862 return value; | |
| 863 } | |
| 864 } | |
| 865 | |
| 866 std::unique_ptr<TracedValue> InspectorEvaluateScriptEvent::data( | |
| 867 LocalFrame* frame, | |
| 868 const String& url, | |
| 869 const TextPosition& textPosition) { | |
| 870 std::unique_ptr<TracedValue> value = fillLocation(url, textPosition); | |
| 871 value->setString("frame", toHexString(frame)); | |
| 872 setCallStack(value.get()); | |
| 873 return value; | |
| 874 } | |
| 875 | |
| 876 std::unique_ptr<TracedValue> InspectorParseScriptEvent::data( | |
| 877 unsigned long identifier, | |
| 878 const String& url) { | |
| 879 String requestId = IdentifiersFactory::requestId(identifier); | |
| 880 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 881 value->setString("requestId", requestId); | |
| 882 value->setString("url", url); | |
| 883 return value; | |
| 884 } | |
| 885 | |
| 886 std::unique_ptr<TracedValue> InspectorCompileScriptEvent::data( | |
| 887 const String& url, | |
| 888 const TextPosition& textPosition) { | |
| 889 return fillLocation(url, textPosition); | |
| 890 } | |
| 891 | |
| 892 std::unique_ptr<TracedValue> InspectorFunctionCallEvent::data( | |
| 893 ExecutionContext* context, | |
| 894 const v8::Local<v8::Function>& function) { | |
| 895 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 896 if (LocalFrame* frame = frameForExecutionContext(context)) | |
| 897 value->setString("frame", toHexString(frame)); | |
| 898 | |
| 899 if (function.IsEmpty()) | |
| 900 return value; | |
| 901 | |
| 902 v8::Local<v8::Function> originalFunction = getBoundFunction(function); | |
| 903 v8::Local<v8::Value> functionName = originalFunction->GetDebugName(); | |
| 904 if (!functionName.IsEmpty() && functionName->IsString()) | |
| 905 value->setString("functionName", | |
| 906 toCoreString(functionName.As<v8::String>())); | |
| 907 std::unique_ptr<SourceLocation> location = | |
| 908 SourceLocation::fromFunction(originalFunction); | |
| 909 value->setString("scriptId", String::number(location->scriptId())); | |
| 910 value->setString("url", location->url()); | |
| 911 value->setInteger("lineNumber", location->lineNumber()); | |
| 912 return value; | |
| 913 } | |
| 914 | |
| 915 std::unique_ptr<TracedValue> InspectorPaintImageEvent::data( | |
| 916 const LayoutImage& layoutImage) { | |
| 917 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 918 setGeneratingNodeInfo(value.get(), &layoutImage, "nodeId"); | |
| 919 if (const ImageResourceContent* resource = layoutImage.cachedImage()) | |
| 920 value->setString("url", resource->url().getString()); | |
| 921 return value; | |
| 922 } | |
| 923 | |
| 924 std::unique_ptr<TracedValue> InspectorPaintImageEvent::data( | |
| 925 const LayoutObject& owningLayoutObject, | |
| 926 const StyleImage& styleImage) { | |
| 927 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 928 setGeneratingNodeInfo(value.get(), &owningLayoutObject, "nodeId"); | |
| 929 if (const ImageResourceContent* resource = styleImage.cachedImage()) | |
| 930 value->setString("url", resource->url().getString()); | |
| 931 return value; | |
| 932 } | |
| 933 | |
| 934 std::unique_ptr<TracedValue> InspectorPaintImageEvent::data( | |
| 935 const LayoutObject* owningLayoutObject, | |
| 936 const ImageResourceContent& imageResource) { | |
| 937 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 938 setGeneratingNodeInfo(value.get(), owningLayoutObject, "nodeId"); | |
| 939 value->setString("url", imageResource.url().getString()); | |
| 940 return value; | |
| 941 } | |
| 942 | |
| 943 static size_t usedHeapSize() { | |
| 944 v8::HeapStatistics heapStatistics; | |
| 945 v8::Isolate::GetCurrent()->GetHeapStatistics(&heapStatistics); | |
| 946 return heapStatistics.used_heap_size(); | |
| 947 } | |
| 948 | |
| 949 std::unique_ptr<TracedValue> InspectorUpdateCountersEvent::data() { | |
| 950 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 951 if (isMainThread()) { | |
| 952 value->setInteger("documents", InstanceCounters::counterValue( | |
| 953 InstanceCounters::DocumentCounter)); | |
| 954 value->setInteger( | |
| 955 "nodes", InstanceCounters::counterValue(InstanceCounters::NodeCounter)); | |
| 956 value->setInteger("jsEventListeners", | |
| 957 InstanceCounters::counterValue( | |
| 958 InstanceCounters::JSEventListenerCounter)); | |
| 959 } | |
| 960 value->setDouble("jsHeapSizeUsed", static_cast<double>(usedHeapSize())); | |
| 961 return value; | |
| 962 } | |
| 963 | |
| 964 std::unique_ptr<TracedValue> InspectorInvalidateLayoutEvent::data( | |
| 965 LocalFrame* frame) { | |
| 966 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 967 value->setString("frame", toHexString(frame)); | |
| 968 setCallStack(value.get()); | |
| 969 return value; | |
| 970 } | |
| 971 | |
| 972 std::unique_ptr<TracedValue> InspectorRecalculateStylesEvent::data( | |
| 973 LocalFrame* frame) { | |
| 974 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 975 value->setString("frame", toHexString(frame)); | |
| 976 setCallStack(value.get()); | |
| 977 return value; | |
| 978 } | |
| 979 | |
| 980 std::unique_ptr<TracedValue> InspectorEventDispatchEvent::data( | |
| 981 const Event& event) { | |
| 982 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 983 value->setString("type", event.type()); | |
| 984 setCallStack(value.get()); | |
| 985 return value; | |
| 986 } | |
| 987 | |
| 988 std::unique_ptr<TracedValue> InspectorTimeStampEvent::data( | |
| 989 ExecutionContext* context, | |
| 990 const String& message) { | |
| 991 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 992 value->setString("message", message); | |
| 993 if (LocalFrame* frame = frameForExecutionContext(context)) | |
| 994 value->setString("frame", toHexString(frame)); | |
| 995 return value; | |
| 996 } | |
| 997 | |
| 998 std::unique_ptr<TracedValue> InspectorTracingSessionIdForWorkerEvent::data( | |
| 999 const String& sessionId, | |
| 1000 const String& workerId, | |
| 1001 WorkerThread* workerThread) { | |
| 1002 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 1003 value->setString("sessionId", sessionId); | |
| 1004 value->setString("workerId", workerId); | |
| 1005 value->setDouble("workerThreadId", workerThread->platformThreadId()); | |
| 1006 return value; | |
| 1007 } | |
| 1008 | |
| 1009 std::unique_ptr<TracedValue> InspectorTracingStartedInFrame::data( | |
| 1010 const String& sessionId, | |
| 1011 LocalFrame* frame) { | |
| 1012 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 1013 value->setString("sessionId", sessionId); | |
| 1014 value->setString("page", toHexString(frame->localFrameRoot())); | |
| 1015 value->beginArray("frames"); | |
| 1016 for (Frame* f = frame; f; f = f->tree().traverseNext(frame)) { | |
| 1017 if (!f->isLocalFrame()) | |
| 1018 continue; | |
| 1019 value->beginDictionary(); | |
| 1020 fillCommonFrameData(value.get(), toLocalFrame(f)); | |
| 1021 value->endDictionary(); | |
| 1022 } | |
| 1023 value->endArray(); | |
| 1024 return value; | |
| 1025 } | |
| 1026 | |
| 1027 std::unique_ptr<TracedValue> InspectorSetLayerTreeId::data( | |
| 1028 const String& sessionId, | |
| 1029 int layerTreeId) { | |
| 1030 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 1031 value->setString("sessionId", sessionId); | |
| 1032 value->setInteger("layerTreeId", layerTreeId); | |
| 1033 return value; | |
| 1034 } | |
| 1035 | |
| 1036 std::unique_ptr<TracedValue> InspectorAnimationEvent::data( | |
| 1037 const Animation& animation) { | |
| 1038 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 1039 value->setString("id", String::number(animation.sequenceNumber())); | |
| 1040 value->setString("state", animation.playState()); | |
| 1041 if (const AnimationEffectReadOnly* effect = animation.effect()) { | |
| 1042 value->setString("name", animation.id()); | |
| 1043 if (effect->isKeyframeEffectReadOnly()) { | |
| 1044 if (Element* target = toKeyframeEffectReadOnly(effect)->target()) | |
| 1045 setNodeInfo(value.get(), target, "nodeId", "nodeName"); | |
| 1046 } | |
| 1047 } | |
| 1048 return value; | |
| 1049 } | |
| 1050 | |
| 1051 std::unique_ptr<TracedValue> InspectorAnimationStateEvent::data( | |
| 1052 const Animation& animation) { | |
| 1053 std::unique_ptr<TracedValue> value = TracedValue::create(); | |
| 1054 value->setString("state", animation.playState()); | |
| 1055 return value; | |
| 1056 } | |
| 1057 | |
| 1058 std::unique_ptr<TracedValue> InspectorHitTestEvent::endData( | |
| 1059 const HitTestRequest& request, | |
| 1060 const HitTestLocation& location, | |
| 1061 const HitTestResult& result) { | |
| 1062 std::unique_ptr<TracedValue> value(TracedValue::create()); | |
| 1063 value->setInteger("x", location.roundedPoint().x()); | |
| 1064 value->setInteger("y", location.roundedPoint().y()); | |
| 1065 if (location.isRectBasedTest()) | |
| 1066 value->setBoolean("rect", true); | |
| 1067 if (location.isRectilinear()) | |
| 1068 value->setBoolean("rectilinear", true); | |
| 1069 if (request.touchEvent()) | |
| 1070 value->setBoolean("touch", true); | |
| 1071 if (request.move()) | |
| 1072 value->setBoolean("move", true); | |
| 1073 if (request.listBased()) | |
| 1074 value->setBoolean("listBased", true); | |
| 1075 else if (Node* node = result.innerNode()) | |
| 1076 setNodeInfo(value.get(), node, "nodeId", "nodeName"); | |
| 1077 return value; | |
| 1078 } | |
| 1079 | |
| 1080 } // namespace blink | 86 } // namespace blink |
| OLD | NEW |