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