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

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

Issue 2863183003: DevTools: report adding mutation event listener as a violations. (Closed)
Patch Set: same Created 3 years, 7 months 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } else if (EventUtil::IsPointerEventType(event_type)) { 329 } else if (EventUtil::IsPointerEventType(event_type)) {
330 if (LocalDOMWindow* executing_window = this->ExecutingWindow()) { 330 if (LocalDOMWindow* executing_window = this->ExecutingWindow()) {
331 UseCounter::Count(executing_window->document(), 331 UseCounter::Count(executing_window->document(),
332 UseCounter::kPointerEventAddListenerCount); 332 UseCounter::kPointerEventAddListenerCount);
333 } 333 }
334 } else if (event_type == EventTypeNames::slotchange) { 334 } else if (event_type == EventTypeNames::slotchange) {
335 if (LocalDOMWindow* executing_window = this->ExecutingWindow()) { 335 if (LocalDOMWindow* executing_window = this->ExecutingWindow()) {
336 UseCounter::Count(executing_window->document(), 336 UseCounter::Count(executing_window->document(),
337 UseCounter::kSlotChangeEventAddListener); 337 UseCounter::kSlotChangeEventAddListener);
338 } 338 }
339 } else if (EventUtil::IsDOMMutationEventType(event_type)) {
340 if (ExecutionContext* context = GetExecutionContext()) {
341 String message_text = String::Format(
342 "Added synchronous DOM mutation listener to a '%s' event. "
343 "Consider using MutationObserver to make the page more responsive.",
344 event_type.GetString().Utf8().data());
345 PerformanceMonitor::ReportGenericViolation(
346 context, PerformanceMonitor::kDiscouragedAPIUse, message_text, 0,
347 nullptr);
348 }
339 } 349 }
340 } 350 }
341 351
342 bool EventTarget::removeEventListener(const AtomicString& event_type, 352 bool EventTarget::removeEventListener(const AtomicString& event_type,
343 const EventListener* listener, 353 const EventListener* listener,
344 bool use_capture) { 354 bool use_capture) {
345 EventListenerOptions options; 355 EventListenerOptions options;
346 options.setCapture(use_capture); 356 options.setCapture(use_capture);
347 return RemoveEventListenerInternal(event_type, listener, options); 357 return RemoveEventListenerInternal(event_type, listener, options);
348 } 358 }
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 // they have one less listener to invoke. 785 // they have one less listener to invoke.
776 if (d->firing_event_iterators) { 786 if (d->firing_event_iterators) {
777 for (const auto& iterator : *d->firing_event_iterators) { 787 for (const auto& iterator : *d->firing_event_iterators) {
778 iterator.iterator = 0; 788 iterator.iterator = 0;
779 iterator.end = 0; 789 iterator.end = 0;
780 } 790 }
781 } 791 }
782 } 792 }
783 793
784 } // namespace blink 794 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698