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 SynchronousMutationObserver_h | 5 #ifndef SynchronousMutationObserver_h |
6 #define SynchronousMutationObserver_h | 6 #define SynchronousMutationObserver_h |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
10 #include "platform/LifecycleObserver.h" | 10 #include "platform/LifecycleObserver.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class CharacterData; | 14 class CharacterData; |
15 class ContainerNode; | 15 class ContainerNode; |
16 class Document; | 16 class Document; |
17 class Element; | |
18 class NodeWithIndex; | 17 class NodeWithIndex; |
19 class Text; | 18 class Text; |
20 | 19 |
21 // This class is a base class for classes which observe DOM tree mutation | 20 // This class is a base class for classes which observe DOM tree mutation |
22 // synchronously. If you want to observe DOM tree mutation asynchronously see | 21 // synchronously. If you want to observe DOM tree mutation asynchronously see |
23 // MutationObserver Web API. | 22 // MutationObserver Web API. |
24 // | 23 // |
25 // TODO(yosin): Following classes should be derived from this class to | 24 // TODO(yosin): Following classes should be derived from this class to |
26 // simplify Document class. | 25 // simplify Document class. |
27 // - DragCaretController | 26 // - DragCaretController |
28 // - DocumentMarkerController | 27 // - DocumentMarkerController |
29 // - EventHandler | 28 // - EventHandler |
30 // - FrameCaret | 29 // - FrameCaret |
31 // - InputMethodController | 30 // - InputMethodController |
32 // - SelectionController | 31 // - SelectionController |
33 // - Range set | 32 // - Range set |
34 // - NodeIterator set | 33 // - NodeIterator set |
35 class CORE_EXPORT SynchronousMutationObserver | 34 class CORE_EXPORT SynchronousMutationObserver |
36 : public LifecycleObserver<Document, SynchronousMutationObserver> { | 35 : public LifecycleObserver<Document, SynchronousMutationObserver> { |
37 public: | 36 public: |
38 // TODO(yosin): We will have following member functions: | 37 // TODO(yosin): We will have following member functions: |
39 // - dataWillBeChanged(const CharacterData&); | 38 // - dataWillBeChanged(const CharacterData&); |
40 // - didMoveTreeToNewDocument(const Node& root); | 39 // - didMoveTreeToNewDocument(const Node& root); |
41 // - didInsertText(Node*, unsigned offset, unsigned length); | 40 // - didInsertText(Node*, unsigned offset, unsigned length); |
42 // - didRemoveText(Node*, unsigned offset, unsigned length); | 41 // - didRemoveText(Node*, unsigned offset, unsigned length); |
43 | 42 |
44 // Called just after attribute is changed. | |
45 virtual void didChangeAttribute(const Element&); | |
46 | |
47 // Called after child nodes changed. | 43 // Called after child nodes changed. |
48 virtual void didChangeChildren(const ContainerNode&); | 44 virtual void didChangeChildren(const ContainerNode&); |
49 | 45 |
50 // Called after characters in |nodeToBeRemoved| is appended into |mergedNode|. | 46 // Called after characters in |nodeToBeRemoved| is appended into |mergedNode|. |
51 // |oldLength| holds length of |mergedNode| before merge. | 47 // |oldLength| holds length of |mergedNode| before merge. |
52 virtual void didMergeTextNodes(const Text& mergedNode, | 48 virtual void didMergeTextNodes(const Text& mergedNode, |
53 const NodeWithIndex& nodeToBeRemovedWithIndex, | 49 const NodeWithIndex& nodeToBeRemovedWithIndex, |
54 unsigned oldLength); | 50 unsigned oldLength); |
55 | 51 |
56 // Called just after node tree |root| is moved to new document. | 52 // Called just after node tree |root| is moved to new document. |
(...skipping 23 matching lines...) Expand all Loading... |
80 protected: | 76 protected: |
81 SynchronousMutationObserver(); | 77 SynchronousMutationObserver(); |
82 | 78 |
83 private: | 79 private: |
84 DISALLOW_COPY_AND_ASSIGN(SynchronousMutationObserver); | 80 DISALLOW_COPY_AND_ASSIGN(SynchronousMutationObserver); |
85 }; | 81 }; |
86 | 82 |
87 } // namespace blink | 83 } // namespace blink |
88 | 84 |
89 #endif // SynchronousMutationObserver_h | 85 #endif // SynchronousMutationObserver_h |
OLD | NEW |