Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 87 return eventType == EventTypeNames::touchstart || | 87 return eventType == EventTypeNames::touchstart || |
| 88 eventType == EventTypeNames::touchmove; | 88 eventType == EventTypeNames::touchmove; |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool isScrollBlockingEvent(const AtomicString& eventType) { | 91 bool isScrollBlockingEvent(const AtomicString& eventType) { |
| 92 return isTouchScrollBlockingEvent(eventType) || | 92 return isTouchScrollBlockingEvent(eventType) || |
| 93 eventType == EventTypeNames::mousewheel || | 93 eventType == EventTypeNames::mousewheel || |
| 94 eventType == EventTypeNames::wheel; | 94 eventType == EventTypeNames::wheel; |
| 95 } | 95 } |
| 96 | 96 |
| 97 double blockedEventsWarningThreshold(const ExecutionContext* context, | 97 double blockedEventsWarningThreshold(ExecutionContext* context, Event* event) { |
| 98 const Event* event) { | |
| 99 if (!event->cancelable()) | 98 if (!event->cancelable()) |
| 100 return 0.0; | 99 return 0.0; |
| 101 if (!isScrollBlockingEvent(event->type())) | 100 if (!isScrollBlockingEvent(event->type())) |
| 102 return 0.0; | 101 return 0.0; |
| 103 | 102 |
| 104 if (!context->isDocument()) | 103 return PerformanceMonitor::enabled(context) ? 0.1 : 0; |
|
caseq
2016/11/05 00:14:35
Extract constant for 0.1
pfeldman
2016/11/05 00:16:02
Done.
| |
| 105 return 0.0; | |
| 106 FrameHost* frameHost = toDocument(context)->frameHost(); | |
| 107 if (!frameHost) | |
| 108 return 0.0; | |
| 109 return frameHost->settings().blockedMainThreadEventsWarningThreshold(); | |
| 110 } | 104 } |
| 111 | 105 |
| 112 void reportBlockedEvent(ExecutionContext* context, | 106 void reportBlockedEvent(ExecutionContext* context, |
| 113 const Event* event, | 107 const Event* event, |
| 114 RegisteredEventListener* registeredListener, | 108 RegisteredEventListener* registeredListener, |
| 115 double delayedSeconds) { | 109 double delayedSeconds) { |
| 116 if (registeredListener->listener()->type() != | 110 if (registeredListener->listener()->type() != |
| 117 EventListener::JSEventListenerType) | 111 EventListener::JSEventListenerType) |
| 118 return; | 112 return; |
| 119 | 113 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 130 "Handling of '%s' input event was delayed for %ld ms due to main thread " | 124 "Handling of '%s' input event was delayed for %ld ms due to main thread " |
| 131 "being busy. " | 125 "being busy. " |
| 132 "Consider marking event handler as 'passive' to make the page more " | 126 "Consider marking event handler as 'passive' to make the page more " |
| 133 "responsive.", | 127 "responsive.", |
| 134 event->type().getString().utf8().data(), lround(delayedSeconds * 1000)); | 128 event->type().getString().utf8().data(), lround(delayedSeconds * 1000)); |
| 135 | 129 |
| 136 v8::Local<v8::Function> function = | 130 v8::Local<v8::Function> function = |
| 137 eventListenerEffectiveFunction(v8Listener->isolate(), handler); | 131 eventListenerEffectiveFunction(v8Listener->isolate(), handler); |
| 138 std::unique_ptr<SourceLocation> location = | 132 std::unique_ptr<SourceLocation> location = |
| 139 SourceLocation::fromFunction(function); | 133 SourceLocation::fromFunction(function); |
| 140 ConsoleMessage* message = ConsoleMessage::create( | 134 PerformanceMonitor::logViolation(WarningMessageLevel, context, messageText, |
| 141 JSMessageSource, WarningMessageLevel, messageText, std::move(location)); | 135 std::move(location)); |
| 142 context->addConsoleMessage(message); | |
| 143 registeredListener->setBlockedEventWarningEmitted(); | 136 registeredListener->setBlockedEventWarningEmitted(); |
| 144 } | 137 } |
| 145 | 138 |
| 146 } // namespace | 139 } // namespace |
| 147 | 140 |
| 148 EventTargetData::EventTargetData() {} | 141 EventTargetData::EventTargetData() {} |
| 149 | 142 |
| 150 EventTargetData::~EventTargetData() {} | 143 EventTargetData::~EventTargetData() {} |
| 151 | 144 |
| 152 DEFINE_TRACE(EventTargetData) { | 145 DEFINE_TRACE(EventTargetData) { |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 759 // they have one less listener to invoke. | 752 // they have one less listener to invoke. |
| 760 if (d->firingEventIterators) { | 753 if (d->firingEventIterators) { |
| 761 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 754 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 762 d->firingEventIterators->at(i).iterator = 0; | 755 d->firingEventIterators->at(i).iterator = 0; |
| 763 d->firingEventIterators->at(i).end = 0; | 756 d->firingEventIterators->at(i).end = 0; |
| 764 } | 757 } |
| 765 } | 758 } |
| 766 } | 759 } |
| 767 | 760 |
| 768 } // namespace blink | 761 } // namespace blink |
| OLD | NEW |