| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 | 111 |
| 112 void reportBlockedEvent(ExecutionContext* context, | 112 void reportBlockedEvent(ExecutionContext* context, |
| 113 const Event* event, | 113 const Event* event, |
| 114 RegisteredEventListener* registeredListener, | 114 RegisteredEventListener* registeredListener, |
| 115 double delayedSeconds) { | 115 double delayedSeconds) { |
| 116 if (registeredListener->listener()->type() != | 116 if (registeredListener->listener()->type() != |
| 117 EventListener::JSEventListenerType) | 117 EventListener::JSEventListenerType) |
| 118 return; | 118 return; |
| 119 | 119 |
| 120 V8AbstractEventListener* v8Listener = | |
| 121 V8AbstractEventListener::cast(registeredListener->listener()); | |
| 122 v8::HandleScope handles(v8Listener->isolate()); | |
| 123 v8::Local<v8::Context> v8Context = toV8Context(context, v8Listener->world()); | |
| 124 if (v8Context.IsEmpty()) | |
| 125 return; | |
| 126 v8::Context::Scope contextScope(v8Context); | |
| 127 v8::Local<v8::Object> handler = v8Listener->getListenerObject(context); | |
| 128 | |
| 129 String messageText = String::format( | 120 String messageText = String::format( |
| 130 "Handling of '%s' input event was delayed for %ld ms due to main thread " | 121 "Handling of '%s' input event was delayed for %ld ms due to main thread " |
| 131 "being busy. " | 122 "being busy. " |
| 132 "Consider marking event handler as 'passive' to make the page more " | 123 "Consider marking event handler as 'passive' to make the page more " |
| 133 "responsive.", | 124 "responsive.", |
| 134 event->type().getString().utf8().data(), lround(delayedSeconds * 1000)); | 125 event->type().getString().utf8().data(), lround(delayedSeconds * 1000)); |
| 135 | 126 |
| 136 v8::Local<v8::Function> function = | |
| 137 eventListenerEffectiveFunction(v8Listener->isolate(), handler); | |
| 138 std::unique_ptr<SourceLocation> location = | |
| 139 SourceLocation::fromFunction(function); | |
| 140 | |
| 141 PerformanceMonitor::reportGenericViolation( | 127 PerformanceMonitor::reportGenericViolation( |
| 142 context, PerformanceMonitor::kBlockedEvent, messageText, delayedSeconds, | 128 context, PerformanceMonitor::kBlockedEvent, messageText, delayedSeconds, |
| 143 location.get()); | 129 getFunctionLocation(context, registeredListener->listener()).get()); |
| 144 registeredListener->setBlockedEventWarningEmitted(); | 130 registeredListener->setBlockedEventWarningEmitted(); |
| 145 } | 131 } |
| 146 | 132 |
| 147 } // namespace | 133 } // namespace |
| 148 | 134 |
| 149 EventTargetData::EventTargetData() {} | 135 EventTargetData::EventTargetData() {} |
| 150 | 136 |
| 151 EventTargetData::~EventTargetData() {} | 137 EventTargetData::~EventTargetData() {} |
| 152 | 138 |
| 153 DEFINE_TRACE(EventTargetData) { | 139 DEFINE_TRACE(EventTargetData) { |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 // If stopImmediatePropagation has been called, we just break out | 677 // If stopImmediatePropagation has been called, we just break out |
| 692 // immediately, without handling any more events on this target. | 678 // immediately, without handling any more events on this target. |
| 693 if (event->immediatePropagationStopped()) | 679 if (event->immediatePropagationStopped()) |
| 694 break; | 680 break; |
| 695 | 681 |
| 696 event->setHandlingPassive(eventPassiveMode(registeredListener)); | 682 event->setHandlingPassive(eventPassiveMode(registeredListener)); |
| 697 bool passiveForced = registeredListener.passiveForcedForDocumentTarget(); | 683 bool passiveForced = registeredListener.passiveForcedForDocumentTarget(); |
| 698 | 684 |
| 699 InspectorInstrumentation::NativeBreakpoint nativeBreakpoint(context, this, | 685 InspectorInstrumentation::NativeBreakpoint nativeBreakpoint(context, this, |
| 700 event); | 686 event); |
| 687 PerformanceMonitor::HandlerCall handlerCall(context, listener); |
| 701 | 688 |
| 702 // To match Mozilla, the AT_TARGET phase fires both capturing and bubbling | 689 // To match Mozilla, the AT_TARGET phase fires both capturing and bubbling |
| 703 // event listeners, even though that violates some versions of the DOM spec. | 690 // event listeners, even though that violates some versions of the DOM spec. |
| 704 listener->handleEvent(context, event); | 691 listener->handleEvent(context, event); |
| 705 firedListener = true; | 692 firedListener = true; |
| 706 | 693 |
| 707 // If we're about to report this event listener as blocking, make sure it | 694 // If we're about to report this event listener as blocking, make sure it |
| 708 // wasn't removed while handling the event. | 695 // wasn't removed while handling the event. |
| 709 if (shouldReportBlockedEvent && i > 0 && | 696 if (shouldReportBlockedEvent && i > 0 && |
| 710 entry[i - 1].listener() == listener && !entry[i - 1].passive() && | 697 entry[i - 1].listener() == listener && !entry[i - 1].passive() && |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 // they have one less listener to invoke. | 751 // they have one less listener to invoke. |
| 765 if (d->firingEventIterators) { | 752 if (d->firingEventIterators) { |
| 766 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 753 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 767 d->firingEventIterators->at(i).iterator = 0; | 754 d->firingEventIterators->at(i).iterator = 0; |
| 768 d->firingEventIterators->at(i).end = 0; | 755 d->firingEventIterators->at(i).end = 0; |
| 769 } | 756 } |
| 770 } | 757 } |
| 771 } | 758 } |
| 772 | 759 |
| 773 } // namespace blink | 760 } // namespace blink |
| OLD | NEW |