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