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: Source/core/events/EventTarget.cpp

Issue 656653003: Replace function static vector with atomically initialized vector (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 25 matching lines...) Expand all
36 #include "bindings/core/v8/V8DOMActivityLogger.h" 36 #include "bindings/core/v8/V8DOMActivityLogger.h"
37 #include "core/dom/ExceptionCode.h" 37 #include "core/dom/ExceptionCode.h"
38 #include "core/editing/Editor.h" 38 #include "core/editing/Editor.h"
39 #include "core/events/Event.h" 39 #include "core/events/Event.h"
40 #include "core/inspector/InspectorInstrumentation.h" 40 #include "core/inspector/InspectorInstrumentation.h"
41 #include "core/frame/LocalDOMWindow.h" 41 #include "core/frame/LocalDOMWindow.h"
42 #include "core/frame/UseCounter.h" 42 #include "core/frame/UseCounter.h"
43 #include "platform/EventDispatchForbiddenScope.h" 43 #include "platform/EventDispatchForbiddenScope.h"
44 #include "platform/RuntimeEnabledFeatures.h" 44 #include "platform/RuntimeEnabledFeatures.h"
45 #include "wtf/StdLibExtras.h" 45 #include "wtf/StdLibExtras.h"
46 #include "wtf/Threading.h"
46 #include "wtf/Vector.h" 47 #include "wtf/Vector.h"
47 48
48 using namespace WTF; 49 using namespace WTF;
49 50
50 namespace blink { 51 namespace blink {
51 52
52 EventTargetData::EventTargetData() 53 EventTargetData::EventTargetData()
53 { 54 {
54 } 55 }
55 56
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // To match Mozilla, the AT_TARGET phase fires both capturing and bubbli ng 350 // To match Mozilla, the AT_TARGET phase fires both capturing and bubbli ng
350 // event listeners, even though that violates some versions of the DOM s pec. 351 // event listeners, even though that violates some versions of the DOM s pec.
351 registeredListener.listener->handleEvent(context, event); 352 registeredListener.listener->handleEvent(context, event);
352 InspectorInstrumentation::didHandleEvent(cookie); 353 InspectorInstrumentation::didHandleEvent(cookie);
353 } 354 }
354 d->firingEventIterators->removeLast(); 355 d->firingEventIterators->removeLast();
355 } 356 }
356 357
357 const EventListenerVector& EventTarget::getEventListeners(const AtomicString& ev entType) 358 const EventListenerVector& EventTarget::getEventListeners(const AtomicString& ev entType)
358 { 359 {
359 DEFINE_STATIC_LOCAL(EventListenerVector, emptyVector, ()); 360 AtomicallyInitializedStatic(EventListenerVector*, emptyVector = new EventLis tenerVector);
360 361
361 EventTargetData* d = eventTargetData(); 362 EventTargetData* d = eventTargetData();
362 if (!d) 363 if (!d)
363 return emptyVector; 364 return *emptyVector;
364 365
365 EventListenerVector* listenerVector = d->eventListenerMap.find(eventType); 366 EventListenerVector* listenerVector = d->eventListenerMap.find(eventType);
366 if (!listenerVector) 367 if (!listenerVector)
367 return emptyVector; 368 return *emptyVector;
368 369
369 return *listenerVector; 370 return *listenerVector;
370 } 371 }
371 372
372 Vector<AtomicString> EventTarget::eventTypes() 373 Vector<AtomicString> EventTarget::eventTypes()
373 { 374 {
374 EventTargetData* d = eventTargetData(); 375 EventTargetData* d = eventTargetData();
375 return d ? d->eventListenerMap.eventTypes() : Vector<AtomicString>(); 376 return d ? d->eventListenerMap.eventTypes() : Vector<AtomicString>();
376 } 377 }
377 378
378 void EventTarget::removeAllEventListeners() 379 void EventTarget::removeAllEventListeners()
379 { 380 {
380 EventTargetData* d = eventTargetData(); 381 EventTargetData* d = eventTargetData();
381 if (!d) 382 if (!d)
382 return; 383 return;
383 d->eventListenerMap.clear(); 384 d->eventListenerMap.clear();
384 385
385 // Notify firing events planning to invoke the listener at 'index' that 386 // Notify firing events planning to invoke the listener at 'index' that
386 // they have one less listener to invoke. 387 // they have one less listener to invoke.
387 if (d->firingEventIterators) { 388 if (d->firingEventIterators) {
388 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { 389 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
389 d->firingEventIterators->at(i).iterator = 0; 390 d->firingEventIterators->at(i).iterator = 0;
390 d->firingEventIterators->at(i).end = 0; 391 d->firingEventIterators->at(i).end = 0;
391 } 392 }
392 } 393 }
393 } 394 }
394 395
395 } // namespace blink 396 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698