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

Side by Side Diff: Source/core/dom/NoEventDispatchAssertion.h

Issue 301173006: Move NoEventDispatchAssertion class to its own file (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add missing include Created 6 years, 6 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 | « Source/core/dom/Element.cpp ('k') | Source/core/dom/Node.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NoEventDispatchAssertion_h
6 #define NoEventDispatchAssertion_h
7
8 #include "wtf/MainThread.h"
9 #include "wtf/TemporaryChange.h"
10
11 namespace WebCore {
12
13 #ifndef NDEBUG
14
15 class NoEventDispatchAssertion {
16 public:
17 NoEventDispatchAssertion()
18 {
19 if (!isMainThread())
20 return;
21 ++s_count;
22 }
23
24 ~NoEventDispatchAssertion()
25 {
26 if (!isMainThread())
27 return;
28 ASSERT(s_count);
29 --s_count;
30 }
31
32 static bool isEventDispatchForbidden()
33 {
34 if (!isMainThread())
35 return false;
36 return s_count;
37 }
38
39 // It's safe to dispatch events in SVGImage since there can't be any script
40 // listeners.
41 class AllowSVGImageEvents {
42 public:
43 AllowSVGImageEvents()
44 : m_change(s_count, 0)
45 {
46 }
47
48 ~AllowSVGImageEvents()
49 {
50 ASSERT(!s_count);
51 }
52
53 TemporaryChange<unsigned> m_change;
54 };
55
56 private:
57 static unsigned s_count;
58 };
59
60 #else
61
62 class NoEventDispatchAssertion {
63 public:
64 NoEventDispatchAssertion() { }
65
66 class AllowSVGImageEvents {
67 public:
68 AllowSVGImageEvents() { }
69 };
70 };
71
72 #endif // NDEBUG
73
74 } // namespace WebCore
75
76 #endif // NoEventDispatchAssertion_h
OLDNEW
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698