| 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 #include "core/dom/SynchronousMutationNotifier.h" | 5 #include "core/dom/SynchronousMutationNotifier.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/SynchronousMutationObserver.h" | 8 #include "core/dom/SynchronousMutationObserver.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 SynchronousMutationNotifier::SynchronousMutationNotifier() = default; | 12 SynchronousMutationNotifier::SynchronousMutationNotifier() = default; |
| 13 | 13 |
| 14 void SynchronousMutationNotifier::notifyChangeAttribute( |
| 15 const Element& element) { |
| 16 for (SynchronousMutationObserver* observer : m_observers) |
| 17 observer->didChangeAttribute(element); |
| 18 } |
| 19 |
| 14 void SynchronousMutationNotifier::notifyChangeChildren( | 20 void SynchronousMutationNotifier::notifyChangeChildren( |
| 15 const ContainerNode& container) { | 21 const ContainerNode& container) { |
| 16 for (SynchronousMutationObserver* observer : m_observers) | 22 for (SynchronousMutationObserver* observer : m_observers) |
| 17 observer->didChangeChildren(container); | 23 observer->didChangeChildren(container); |
| 18 } | 24 } |
| 19 | 25 |
| 20 void SynchronousMutationNotifier::notifyMergeTextNodes(Text& node, | 26 void SynchronousMutationNotifier::notifyMergeTextNodes( |
| 21 unsigned offset) { | 27 const Text& mergedNode, |
| 22 for (SynchronousMutationObserver* observer : m_observers) | 28 const NodeWithIndex& nodeToBeRemovedWithIndex, |
| 23 observer->didMergeTextNodes(node, offset); | 29 unsigned oldLength) { |
| 24 } | |
| 25 | |
| 26 void SynchronousMutationNotifier::notifySplitTextNode(const Text& node) { | |
| 27 for (SynchronousMutationObserver* observer : m_observers) | |
| 28 observer->didSplitTextNode(node); | |
| 29 } | |
| 30 | |
| 31 void SynchronousMutationNotifier::notifyUpdateCharacterData( | |
| 32 CharacterData* characterData, | |
| 33 unsigned offset, | |
| 34 unsigned oldLength, | |
| 35 unsigned newLength) { | |
| 36 for (SynchronousMutationObserver* observer : m_observers) { | 30 for (SynchronousMutationObserver* observer : m_observers) { |
| 37 observer->didUpdateCharacterData(characterData, offset, oldLength, | 31 observer->didMergeTextNodes(mergedNode, nodeToBeRemovedWithIndex, |
| 38 newLength); | 32 oldLength); |
| 39 } | 33 } |
| 40 } | 34 } |
| 41 | 35 |
| 36 void SynchronousMutationNotifier::notifyMoveTreeToNewDocument() { |
| 37 for (SynchronousMutationObserver* observer : m_observers) |
| 38 observer->didMoveTreeToNewDocument(); |
| 39 } |
| 40 |
| 42 void SynchronousMutationNotifier::notifyNodeChildrenWillBeRemoved( | 41 void SynchronousMutationNotifier::notifyNodeChildrenWillBeRemoved( |
| 43 ContainerNode& container) { | 42 ContainerNode& container) { |
| 44 for (SynchronousMutationObserver* observer : m_observers) | 43 for (SynchronousMutationObserver* observer : m_observers) |
| 45 observer->nodeChildrenWillBeRemoved(container); | 44 observer->nodeChildrenWillBeRemoved(container); |
| 46 } | 45 } |
| 47 | 46 |
| 48 void SynchronousMutationNotifier::notifyNodeWillBeRemoved(Node& node) { | 47 void SynchronousMutationNotifier::notifyNodeWillBeRemoved(Node& node) { |
| 49 for (SynchronousMutationObserver* observer : m_observers) | 48 for (SynchronousMutationObserver* observer : m_observers) |
| 50 observer->nodeWillBeRemoved(node); | 49 observer->nodeWillBeRemoved(node); |
| 51 } | 50 } |
| 52 | 51 |
| 52 void SynchronousMutationNotifier::notifySplitTextNode(const Text& splitNode) { |
| 53 for (SynchronousMutationObserver* observer : m_observers) |
| 54 observer->didSplitTextNode(splitNode); |
| 55 } |
| 56 |
| 57 void SynchronousMutationNotifier::notifyUpdateCharacterData( |
| 58 CharacterData* node, |
| 59 unsigned offset, |
| 60 unsigned oldLength, |
| 61 unsigned newLength) { |
| 62 for (SynchronousMutationObserver* observer : m_observers) |
| 63 observer->didUpdateCharacterData(node, offset, oldLength, newLength); |
| 64 } |
| 65 |
| 53 } // namespace blink | 66 } // namespace blink |
| OLD | NEW |