| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #include "core/dom/MutationObserverInterestGroup.h" | 34 #include "core/dom/MutationObserverInterestGroup.h" |
| 35 #include "core/dom/MutationRecord.h" | 35 #include "core/dom/MutationRecord.h" |
| 36 #include "core/dom/StaticNodeList.h" | 36 #include "core/dom/StaticNodeList.h" |
| 37 #include "wtf/HashMap.h" | 37 #include "wtf/HashMap.h" |
| 38 #include "wtf/StdLibExtras.h" | 38 #include "wtf/StdLibExtras.h" |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 typedef HashMap<Node*, ChildListMutationAccumulator*> AccumulatorMap; | 42 typedef HashMap<Node*, ChildListMutationAccumulator*> AccumulatorMap; |
| 43 |
| 43 static AccumulatorMap& accumulatorMap() | 44 static AccumulatorMap& accumulatorMap() |
| 44 { | 45 { |
| 45 DEFINE_STATIC_LOCAL(AccumulatorMap, map, ()); | 46 DEFINE_STATIC_LOCAL(AccumulatorMap, map, ()); |
| 46 return map; | 47 return map; |
| 47 } | 48 } |
| 48 | 49 |
| 49 ChildListMutationAccumulator::ChildListMutationAccumulator(PassRefPtr<Node> targ
et, PassOwnPtr<MutationObserverInterestGroup> observers) | 50 ChildListMutationAccumulator::ChildListMutationAccumulator(PassRefPtr<Node> targ
et, PassOwnPtrWillBeRawPtr<MutationObserverInterestGroup> observers) |
| 50 : m_target(target) | 51 : m_target(target) |
| 51 , m_lastAdded(0) | 52 , m_lastAdded(0) |
| 52 , m_observers(observers) | 53 , m_observers(observers) |
| 53 { | 54 { |
| 54 } | 55 } |
| 55 | 56 |
| 56 ChildListMutationAccumulator::~ChildListMutationAccumulator() | 57 ChildListMutationAccumulator::~ChildListMutationAccumulator() |
| 57 { | 58 { |
| 58 if (!isEmpty()) | 59 if (!isEmpty()) |
| 59 enqueueMutationRecord(); | 60 enqueueMutationRecord(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 m_removedNodes.append(child.release()); | 121 m_removedNodes.append(child.release()); |
| 121 } | 122 } |
| 122 | 123 |
| 123 void ChildListMutationAccumulator::enqueueMutationRecord() | 124 void ChildListMutationAccumulator::enqueueMutationRecord() |
| 124 { | 125 { |
| 125 ASSERT(hasObservers()); | 126 ASSERT(hasObservers()); |
| 126 ASSERT(!isEmpty()); | 127 ASSERT(!isEmpty()); |
| 127 | 128 |
| 128 RefPtr<NodeList> addedNodes = StaticNodeList::adopt(m_addedNodes); | 129 RefPtr<NodeList> addedNodes = StaticNodeList::adopt(m_addedNodes); |
| 129 RefPtr<NodeList> removedNodes = StaticNodeList::adopt(m_removedNodes); | 130 RefPtr<NodeList> removedNodes = StaticNodeList::adopt(m_removedNodes); |
| 130 RefPtr<MutationRecord> record = MutationRecord::createChildList(m_target, ad
dedNodes.release(), removedNodes.release(), m_previousSibling.release(), m_nextS
ibling.release()); | 131 RefPtrWillBeRawPtr<MutationRecord> record = MutationRecord::createChildList(
m_target, addedNodes.release(), removedNodes.release(), m_previousSibling.releas
e(), m_nextSibling.release()); |
| 131 m_observers->enqueueMutationRecord(record.release()); | 132 m_observers->enqueueMutationRecord(record.release()); |
| 132 m_lastAdded = 0; | 133 m_lastAdded = 0; |
| 133 ASSERT(isEmpty()); | 134 ASSERT(isEmpty()); |
| 134 } | 135 } |
| 135 | 136 |
| 136 bool ChildListMutationAccumulator::isEmpty() | 137 bool ChildListMutationAccumulator::isEmpty() |
| 137 { | 138 { |
| 138 bool result = m_removedNodes.isEmpty() && m_addedNodes.isEmpty(); | 139 bool result = m_removedNodes.isEmpty() && m_addedNodes.isEmpty(); |
| 139 #ifndef NDEBUG | 140 #ifndef NDEBUG |
| 140 if (result) { | 141 if (result) { |
| 141 ASSERT(!m_previousSibling); | 142 ASSERT(!m_previousSibling); |
| 142 ASSERT(!m_nextSibling); | 143 ASSERT(!m_nextSibling); |
| 143 ASSERT(!m_lastAdded); | 144 ASSERT(!m_lastAdded); |
| 144 } | 145 } |
| 145 #endif | 146 #endif |
| 146 return result; | 147 return result; |
| 147 } | 148 } |
| 148 | 149 |
| 149 } // namespace WebCore | 150 } // namespace WebCore |
| OLD | NEW |