Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: third_party/WebKit/Source/core/events/EventTarget.cpp

Issue 2474073005: DevTools: add the logging aspect into the PerformanceMonitor (Closed)
Patch Set: test fixed Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 6 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
7 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 7 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
(...skipping 24 matching lines...) Expand all
35 #include "bindings/core/v8/ScriptEventListener.h" 35 #include "bindings/core/v8/ScriptEventListener.h"
36 #include "bindings/core/v8/SourceLocation.h" 36 #include "bindings/core/v8/SourceLocation.h"
37 #include "bindings/core/v8/V8DOMActivityLogger.h" 37 #include "bindings/core/v8/V8DOMActivityLogger.h"
38 #include "core/dom/ExceptionCode.h" 38 #include "core/dom/ExceptionCode.h"
39 #include "core/editing/Editor.h" 39 #include "core/editing/Editor.h"
40 #include "core/events/Event.h" 40 #include "core/events/Event.h"
41 #include "core/events/EventUtil.h" 41 #include "core/events/EventUtil.h"
42 #include "core/events/PointerEvent.h" 42 #include "core/events/PointerEvent.h"
43 #include "core/frame/FrameHost.h" 43 #include "core/frame/FrameHost.h"
44 #include "core/frame/LocalDOMWindow.h" 44 #include "core/frame/LocalDOMWindow.h"
45 #include "core/frame/PerformanceMonitor.h"
45 #include "core/frame/Settings.h" 46 #include "core/frame/Settings.h"
46 #include "core/frame/UseCounter.h" 47 #include "core/frame/UseCounter.h"
47 #include "core/inspector/ConsoleMessage.h"
48 #include "core/inspector/InspectorInstrumentation.h" 48 #include "core/inspector/InspectorInstrumentation.h"
49 #include "platform/EventDispatchForbiddenScope.h" 49 #include "platform/EventDispatchForbiddenScope.h"
50 #include "platform/Histogram.h" 50 #include "platform/Histogram.h"
51 #include "wtf/PtrUtil.h" 51 #include "wtf/PtrUtil.h"
52 #include "wtf/StdLibExtras.h" 52 #include "wtf/StdLibExtras.h"
53 #include "wtf/Threading.h" 53 #include "wtf/Threading.h"
54 #include "wtf/Vector.h" 54 #include "wtf/Vector.h"
55 #include <memory> 55 #include <memory>
56 56
57 using namespace WTF; 57 using namespace WTF;
58 58
59 namespace blink { 59 namespace blink {
60 namespace { 60 namespace {
61 61
62 static const double kBlockedWarningThresholdMillis = 100.0;
63
62 enum PassiveForcedListenerResultType { 64 enum PassiveForcedListenerResultType {
63 PreventDefaultNotCalled, 65 PreventDefaultNotCalled,
64 DocumentLevelTouchPreventDefaultCalled, 66 DocumentLevelTouchPreventDefaultCalled,
65 PassiveForcedListenerResultTypeMax 67 PassiveForcedListenerResultTypeMax
66 }; 68 };
67 69
68 Event::PassiveMode eventPassiveMode( 70 Event::PassiveMode eventPassiveMode(
69 const RegisteredEventListener& eventListener) { 71 const RegisteredEventListener& eventListener) {
70 if (!eventListener.passive()) 72 if (!eventListener.passive())
71 return Event::PassiveMode::NotPassive; 73 return Event::PassiveMode::NotPassive;
(...skipping 15 matching lines...) Expand all
87 return eventType == EventTypeNames::touchstart || 89 return eventType == EventTypeNames::touchstart ||
88 eventType == EventTypeNames::touchmove; 90 eventType == EventTypeNames::touchmove;
89 } 91 }
90 92
91 bool isScrollBlockingEvent(const AtomicString& eventType) { 93 bool isScrollBlockingEvent(const AtomicString& eventType) {
92 return isTouchScrollBlockingEvent(eventType) || 94 return isTouchScrollBlockingEvent(eventType) ||
93 eventType == EventTypeNames::mousewheel || 95 eventType == EventTypeNames::mousewheel ||
94 eventType == EventTypeNames::wheel; 96 eventType == EventTypeNames::wheel;
95 } 97 }
96 98
97 double blockedEventsWarningThreshold(const ExecutionContext* context, 99 double blockedEventsWarningThreshold(ExecutionContext* context, Event* event) {
98 const Event* event) {
99 if (!event->cancelable()) 100 if (!event->cancelable())
100 return 0.0; 101 return 0.0;
101 if (!isScrollBlockingEvent(event->type())) 102 if (!isScrollBlockingEvent(event->type()))
102 return 0.0; 103 return 0.0;
103 104
104 if (!context->isDocument()) 105 return PerformanceMonitor::enabled(context)
105 return 0.0; 106 ? kBlockedWarningThresholdMillis / 1000
106 FrameHost* frameHost = toDocument(context)->frameHost(); 107 : 0;
107 if (!frameHost)
108 return 0.0;
109 return frameHost->settings().blockedMainThreadEventsWarningThreshold();
110 } 108 }
111 109
112 void reportBlockedEvent(ExecutionContext* context, 110 void reportBlockedEvent(ExecutionContext* context,
113 const Event* event, 111 const Event* event,
114 RegisteredEventListener* registeredListener, 112 RegisteredEventListener* registeredListener,
115 double delayedSeconds) { 113 double delayedSeconds) {
116 if (registeredListener->listener()->type() != 114 if (registeredListener->listener()->type() !=
117 EventListener::JSEventListenerType) 115 EventListener::JSEventListenerType)
118 return; 116 return;
119 117
(...skipping 10 matching lines...) Expand all
130 "Handling of '%s' input event was delayed for %ld ms due to main thread " 128 "Handling of '%s' input event was delayed for %ld ms due to main thread "
131 "being busy. " 129 "being busy. "
132 "Consider marking event handler as 'passive' to make the page more " 130 "Consider marking event handler as 'passive' to make the page more "
133 "responsive.", 131 "responsive.",
134 event->type().getString().utf8().data(), lround(delayedSeconds * 1000)); 132 event->type().getString().utf8().data(), lround(delayedSeconds * 1000));
135 133
136 v8::Local<v8::Function> function = 134 v8::Local<v8::Function> function =
137 eventListenerEffectiveFunction(v8Listener->isolate(), handler); 135 eventListenerEffectiveFunction(v8Listener->isolate(), handler);
138 std::unique_ptr<SourceLocation> location = 136 std::unique_ptr<SourceLocation> location =
139 SourceLocation::fromFunction(function); 137 SourceLocation::fromFunction(function);
140 ConsoleMessage* message = ConsoleMessage::create( 138 PerformanceMonitor::logViolation(WarningMessageLevel, context, messageText,
141 JSMessageSource, WarningMessageLevel, messageText, std::move(location)); 139 std::move(location));
142 context->addConsoleMessage(message);
143 registeredListener->setBlockedEventWarningEmitted(); 140 registeredListener->setBlockedEventWarningEmitted();
144 } 141 }
145 142
146 } // namespace 143 } // namespace
147 144
148 EventTargetData::EventTargetData() {} 145 EventTargetData::EventTargetData() {}
149 146
150 EventTargetData::~EventTargetData() {} 147 EventTargetData::~EventTargetData() {}
151 148
152 DEFINE_TRACE(EventTargetData) { 149 DEFINE_TRACE(EventTargetData) {
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 // they have one less listener to invoke. 756 // they have one less listener to invoke.
760 if (d->firingEventIterators) { 757 if (d->firingEventIterators) {
761 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { 758 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
762 d->firingEventIterators->at(i).iterator = 0; 759 d->firingEventIterators->at(i).iterator = 0;
763 d->firingEventIterators->at(i).end = 0; 760 d->firingEventIterators->at(i).end = 0;
764 } 761 }
765 } 762 }
766 } 763 }
767 764
768 } // namespace blink 765 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698