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

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

Issue 1929843002: Events should have an initialized flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modified assert Created 4 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 bool EventTarget::clearAttributeEventListener(const AtomicString& eventType) 249 bool EventTarget::clearAttributeEventListener(const AtomicString& eventType)
250 { 250 {
251 EventListener* listener = getAttributeEventListener(eventType); 251 EventListener* listener = getAttributeEventListener(eventType);
252 if (!listener) 252 if (!listener)
253 return false; 253 return false;
254 return removeEventListener(eventType, listener, false); 254 return removeEventListener(eventType, listener, false);
255 } 255 }
256 256
257 bool EventTarget::dispatchEventForBindings(Event* event, ExceptionState& excepti onState) 257 bool EventTarget::dispatchEventForBindings(Event* event, ExceptionState& excepti onState)
258 { 258 {
259 if (event->type().isEmpty()) { 259 if (!event->initialized()) {
260 exceptionState.throwDOMException(InvalidStateError, "The event provided is uninitialized."); 260 exceptionState.throwDOMException(InvalidStateError, "The event provided is uninitialized.");
261 return false; 261 return false;
262 } 262 }
263 if (event->isBeingDispatched()) { 263 if (event->isBeingDispatched()) {
264 exceptionState.throwDOMException(InvalidStateError, "The event is alread y being dispatched."); 264 exceptionState.throwDOMException(InvalidStateError, "The event is alread y being dispatched.");
265 return false; 265 return false;
266 } 266 }
267 267
268 if (!getExecutionContext()) 268 if (!getExecutionContext())
269 return false; 269 return false;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 UseCounter::count(executingWindow->document(), prefixedFeature); 353 UseCounter::count(executingWindow->document(), prefixedFeature);
354 } else if (listenersVector) { 354 } else if (listenersVector) {
355 UseCounter::count(executingWindow->document(), unprefixedFeature); 355 UseCounter::count(executingWindow->document(), unprefixedFeature);
356 } 356 }
357 } 357 }
358 } 358 }
359 359
360 DispatchEventResult EventTarget::fireEventListeners(Event* event) 360 DispatchEventResult EventTarget::fireEventListeners(Event* event)
361 { 361 {
362 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 362 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
363 ASSERT(event && !event->type().isEmpty()); 363 ASSERT(event && event->initialized());
tkent 2016/05/02 00:19:27 nit: Split this into two. DCHECK(event); D
ramya.v 2016/05/02 05:31:44 Done.
364 364
365 EventTargetData* d = eventTargetData(); 365 EventTargetData* d = eventTargetData();
366 if (!d) 366 if (!d)
367 return DispatchEventResult::NotCanceled; 367 return DispatchEventResult::NotCanceled;
368 368
369 EventListenerVector* legacyListenersVector = nullptr; 369 EventListenerVector* legacyListenersVector = nullptr;
370 AtomicString legacyTypeName = legacyType(event); 370 AtomicString legacyTypeName = legacyType(event);
371 if (!legacyTypeName.isEmpty()) 371 if (!legacyTypeName.isEmpty())
372 legacyListenersVector = d->eventListenerMap.find(legacyTypeName); 372 legacyListenersVector = d->eventListenerMap.find(legacyTypeName);
373 373
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 // they have one less listener to invoke. 490 // they have one less listener to invoke.
491 if (d->firingEventIterators) { 491 if (d->firingEventIterators) {
492 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { 492 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
493 d->firingEventIterators->at(i).iterator = 0; 493 d->firingEventIterators->at(i).iterator = 0;
494 d->firingEventIterators->at(i).end = 0; 494 d->firingEventIterators->at(i).end = 0;
495 } 495 }
496 } 496 }
497 } 497 }
498 498
499 } // namespace blink 499 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698