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

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

Issue 2490563002: Revert of DevTools: add the logging aspect into the PerformanceMonitor (Closed)
Patch Set: 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"
46 #include "core/frame/Settings.h" 45 #include "core/frame/Settings.h"
47 #include "core/frame/UseCounter.h" 46 #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
64 enum PassiveForcedListenerResultType { 62 enum PassiveForcedListenerResultType {
65 PreventDefaultNotCalled, 63 PreventDefaultNotCalled,
66 DocumentLevelTouchPreventDefaultCalled, 64 DocumentLevelTouchPreventDefaultCalled,
67 PassiveForcedListenerResultTypeMax 65 PassiveForcedListenerResultTypeMax
68 }; 66 };
69 67
70 Event::PassiveMode eventPassiveMode( 68 Event::PassiveMode eventPassiveMode(
71 const RegisteredEventListener& eventListener) { 69 const RegisteredEventListener& eventListener) {
72 if (!eventListener.passive()) 70 if (!eventListener.passive())
73 return Event::PassiveMode::NotPassive; 71 return Event::PassiveMode::NotPassive;
(...skipping 15 matching lines...) Expand all
89 return eventType == EventTypeNames::touchstart || 87 return eventType == EventTypeNames::touchstart ||
90 eventType == EventTypeNames::touchmove; 88 eventType == EventTypeNames::touchmove;
91 } 89 }
92 90
93 bool isScrollBlockingEvent(const AtomicString& eventType) { 91 bool isScrollBlockingEvent(const AtomicString& eventType) {
94 return isTouchScrollBlockingEvent(eventType) || 92 return isTouchScrollBlockingEvent(eventType) ||
95 eventType == EventTypeNames::mousewheel || 93 eventType == EventTypeNames::mousewheel ||
96 eventType == EventTypeNames::wheel; 94 eventType == EventTypeNames::wheel;
97 } 95 }
98 96
99 double blockedEventsWarningThreshold(ExecutionContext* context, Event* event) { 97 double blockedEventsWarningThreshold(const ExecutionContext* context,
98 const Event* event) {
100 if (!event->cancelable()) 99 if (!event->cancelable())
101 return 0.0; 100 return 0.0;
102 if (!isScrollBlockingEvent(event->type())) 101 if (!isScrollBlockingEvent(event->type()))
103 return 0.0; 102 return 0.0;
104 103
105 return PerformanceMonitor::enabled(context) 104 if (!context->isDocument())
106 ? kBlockedWarningThresholdMillis / 1000 105 return 0.0;
107 : 0; 106 FrameHost* frameHost = toDocument(context)->frameHost();
107 if (!frameHost)
108 return 0.0;
109 return frameHost->settings().blockedMainThreadEventsWarningThreshold();
108 } 110 }
109 111
110 void reportBlockedEvent(ExecutionContext* context, 112 void reportBlockedEvent(ExecutionContext* context,
111 const Event* event, 113 const Event* event,
112 RegisteredEventListener* registeredListener, 114 RegisteredEventListener* registeredListener,
113 double delayedSeconds) { 115 double delayedSeconds) {
114 if (registeredListener->listener()->type() != 116 if (registeredListener->listener()->type() !=
115 EventListener::JSEventListenerType) 117 EventListener::JSEventListenerType)
116 return; 118 return;
117 119
(...skipping 10 matching lines...) Expand all
128 "Handling of '%s' input event was delayed for %ld ms due to main thread " 130 "Handling of '%s' input event was delayed for %ld ms due to main thread "
129 "being busy. " 131 "being busy. "
130 "Consider marking event handler as 'passive' to make the page more " 132 "Consider marking event handler as 'passive' to make the page more "
131 "responsive.", 133 "responsive.",
132 event->type().getString().utf8().data(), lround(delayedSeconds * 1000)); 134 event->type().getString().utf8().data(), lround(delayedSeconds * 1000));
133 135
134 v8::Local<v8::Function> function = 136 v8::Local<v8::Function> function =
135 eventListenerEffectiveFunction(v8Listener->isolate(), handler); 137 eventListenerEffectiveFunction(v8Listener->isolate(), handler);
136 std::unique_ptr<SourceLocation> location = 138 std::unique_ptr<SourceLocation> location =
137 SourceLocation::fromFunction(function); 139 SourceLocation::fromFunction(function);
138 PerformanceMonitor::logViolation(WarningMessageLevel, context, messageText, 140 ConsoleMessage* message = ConsoleMessage::create(
139 std::move(location)); 141 JSMessageSource, WarningMessageLevel, messageText, std::move(location));
142 context->addConsoleMessage(message);
140 registeredListener->setBlockedEventWarningEmitted(); 143 registeredListener->setBlockedEventWarningEmitted();
141 } 144 }
142 145
143 } // namespace 146 } // namespace
144 147
145 EventTargetData::EventTargetData() {} 148 EventTargetData::EventTargetData() {}
146 149
147 EventTargetData::~EventTargetData() {} 150 EventTargetData::~EventTargetData() {}
148 151
149 DEFINE_TRACE(EventTargetData) { 152 DEFINE_TRACE(EventTargetData) {
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 // they have one less listener to invoke. 759 // they have one less listener to invoke.
757 if (d->firingEventIterators) { 760 if (d->firingEventIterators) {
758 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { 761 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
759 d->firingEventIterators->at(i).iterator = 0; 762 d->firingEventIterators->at(i).iterator = 0;
760 d->firingEventIterators->at(i).end = 0; 763 d->firingEventIterators->at(i).end = 0;
761 } 764 }
762 } 765 }
763 } 766 }
764 767
765 } // namespace blink 768 } // 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