OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EditingState_h | 5 #ifndef EditingState_h |
6 #define EditingState_h | 6 #define EditingState_h |
7 | 7 |
| 8 #include "core/CoreExport.h" |
8 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
9 #include "wtf/Assertions.h" | 10 #include "wtf/Assertions.h" |
10 #include "wtf/Noncopyable.h" | 11 #include "wtf/Noncopyable.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
14 // EditingState represents current editing command running state for propagating | 15 // EditingState represents current editing command running state for propagating |
15 // DOM tree mutation operation failure to callers. | 16 // DOM tree mutation operation failure to callers. |
16 // | 17 // |
17 // Example usage: | 18 // Example usage: |
18 // EditingState editingState; | 19 // EditingState editingState; |
19 // ... | 20 // ... |
20 // functionMutatesDOMTree(..., &editingState); | 21 // functionMutatesDOMTree(..., &editingState); |
21 // if (editingState.isAborted()) | 22 // if (editingState.isAborted()) |
22 // return; | 23 // return; |
23 // | 24 // |
24 class EditingState final { | 25 class CORE_EXPORT EditingState final { |
25 STACK_ALLOCATED(); | 26 STACK_ALLOCATED(); |
26 WTF_MAKE_NONCOPYABLE(EditingState); | 27 WTF_MAKE_NONCOPYABLE(EditingState); |
27 | 28 |
28 public: | 29 public: |
29 EditingState(); | 30 EditingState(); |
30 ~EditingState(); | 31 ~EditingState(); |
31 | 32 |
32 void abort(); | 33 void abort(); |
33 bool isAborted() const { return m_isAborted; } | 34 bool isAborted() const { return m_isAborted; } |
34 | 35 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // unexpectedly. | 87 // unexpectedly. |
87 #define ASSERT_NO_EDITING_ABORT \ | 88 #define ASSERT_NO_EDITING_ABORT \ |
88 (NoEditingAbortChecker(__FILE__, __LINE__).editingState()) | 89 (NoEditingAbortChecker(__FILE__, __LINE__).editingState()) |
89 #else | 90 #else |
90 #define ASSERT_NO_EDITING_ABORT (IgnorableEditingAbortState().editingState()) | 91 #define ASSERT_NO_EDITING_ABORT (IgnorableEditingAbortState().editingState()) |
91 #endif | 92 #endif |
92 | 93 |
93 } // namespace blink | 94 } // namespace blink |
94 | 95 |
95 #endif // EditingState_h | 96 #endif // EditingState_h |
OLD | NEW |