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

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: Updated as per review comments 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
« no previous file with comments | « third_party/WebKit/Source/core/events/Event.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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->wasInitialized()) {
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 DCHECK(event);
364 DCHECK(event->wasInitialized());
364 365
365 EventTargetData* d = eventTargetData(); 366 EventTargetData* d = eventTargetData();
366 if (!d) 367 if (!d)
367 return DispatchEventResult::NotCanceled; 368 return DispatchEventResult::NotCanceled;
368 369
369 EventListenerVector* legacyListenersVector = nullptr; 370 EventListenerVector* legacyListenersVector = nullptr;
370 AtomicString legacyTypeName = legacyType(event); 371 AtomicString legacyTypeName = legacyType(event);
371 if (!legacyTypeName.isEmpty()) 372 if (!legacyTypeName.isEmpty())
372 legacyListenersVector = d->eventListenerMap.find(legacyTypeName); 373 legacyListenersVector = d->eventListenerMap.find(legacyTypeName);
373 374
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 // they have one less listener to invoke. 491 // they have one less listener to invoke.
491 if (d->firingEventIterators) { 492 if (d->firingEventIterators) {
492 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { 493 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
493 d->firingEventIterators->at(i).iterator = 0; 494 d->firingEventIterators->at(i).iterator = 0;
494 d->firingEventIterators->at(i).end = 0; 495 d->firingEventIterators->at(i).end = 0;
495 } 496 }
496 } 497 }
497 } 498 }
498 499
499 } // namespace blink 500 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/Event.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698