| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 class MutationCallback; | 46 class MutationCallback; |
| 47 class MutationObserver; | 47 class MutationObserver; |
| 48 class MutationObserverInit; | 48 class MutationObserverInit; |
| 49 class MutationObserverRegistration; | 49 class MutationObserverRegistration; |
| 50 class MutationRecord; | 50 class MutationRecord; |
| 51 class Node; | 51 class Node; |
| 52 | 52 |
| 53 typedef unsigned char MutationObserverOptions; | 53 typedef unsigned char MutationObserverOptions; |
| 54 typedef unsigned char MutationRecordDeliveryOptions; | 54 typedef unsigned char MutationRecordDeliveryOptions; |
| 55 | 55 |
| 56 using MutationObserverSet = WillBeHeapHashSet<RefPtrWillBeMember<MutationObserve
r>>; | 56 using MutationObserverSet = HeapHashSet<Member<MutationObserver>>; |
| 57 using MutationObserverRegistrationSet = WillBeHeapHashSet<RawPtrWillBeWeakMember
<MutationObserverRegistration>>; | 57 using MutationObserverRegistrationSet = HeapHashSet<WeakMember<MutationObserverR
egistration>>; |
| 58 using MutationObserverVector = WillBeHeapVector<RefPtrWillBeMember<MutationObser
ver>>; | 58 using MutationObserverVector = HeapVector<Member<MutationObserver>>; |
| 59 using MutationRecordVector = WillBeHeapVector<RefPtrWillBeMember<MutationRecord>
>; | 59 using MutationRecordVector = HeapVector<Member<MutationRecord>>; |
| 60 | 60 |
| 61 class MutationObserver final : public RefCountedWillBeGarbageCollectedFinalized<
MutationObserver>, public ScriptWrappable { | 61 class MutationObserver final : public GarbageCollectedFinalized<MutationObserver
>, public ScriptWrappable { |
| 62 DEFINE_WRAPPERTYPEINFO(); | 62 DEFINE_WRAPPERTYPEINFO(); |
| 63 public: | 63 public: |
| 64 enum MutationType { | 64 enum MutationType { |
| 65 ChildList = 1 << 0, | 65 ChildList = 1 << 0, |
| 66 Attributes = 1 << 1, | 66 Attributes = 1 << 1, |
| 67 CharacterData = 1 << 2, | 67 CharacterData = 1 << 2, |
| 68 | 68 |
| 69 AllMutationTypes = ChildList | Attributes | CharacterData | 69 AllMutationTypes = ChildList | Attributes | CharacterData |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 enum ObservationFlags { | 72 enum ObservationFlags { |
| 73 Subtree = 1 << 3, | 73 Subtree = 1 << 3, |
| 74 AttributeFilter = 1 << 4 | 74 AttributeFilter = 1 << 4 |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 enum DeliveryFlags { | 77 enum DeliveryFlags { |
| 78 AttributeOldValue = 1 << 5, | 78 AttributeOldValue = 1 << 5, |
| 79 CharacterDataOldValue = 1 << 6, | 79 CharacterDataOldValue = 1 << 6, |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 static PassRefPtrWillBeRawPtr<MutationObserver> create(PassOwnPtrWillBeRawPt
r<MutationCallback>); | 82 static RawPtr<MutationObserver> create(RawPtr<MutationCallback>); |
| 83 static void resumeSuspendedObservers(); | 83 static void resumeSuspendedObservers(); |
| 84 static void deliverMutations(); | 84 static void deliverMutations(); |
| 85 | 85 |
| 86 ~MutationObserver(); | 86 ~MutationObserver(); |
| 87 | 87 |
| 88 void observe(Node*, const MutationObserverInit&, ExceptionState&); | 88 void observe(Node*, const MutationObserverInit&, ExceptionState&); |
| 89 MutationRecordVector takeRecords(); | 89 MutationRecordVector takeRecords(); |
| 90 void disconnect(); | 90 void disconnect(); |
| 91 void observationStarted(MutationObserverRegistration*); | 91 void observationStarted(MutationObserverRegistration*); |
| 92 void observationEnded(MutationObserverRegistration*); | 92 void observationEnded(MutationObserverRegistration*); |
| 93 void enqueueMutationRecord(PassRefPtrWillBeRawPtr<MutationRecord>); | 93 void enqueueMutationRecord(RawPtr<MutationRecord>); |
| 94 void setHasTransientRegistration(); | 94 void setHasTransientRegistration(); |
| 95 | 95 |
| 96 WillBeHeapHashSet<RawPtrWillBeMember<Node>> getObservedNodes() const; | 96 HeapHashSet<Member<Node>> getObservedNodes() const; |
| 97 | 97 |
| 98 // Eagerly finalized as destructor accesses heap object members. | 98 // Eagerly finalized as destructor accesses heap object members. |
| 99 EAGERLY_FINALIZE(); | 99 EAGERLY_FINALIZE(); |
| 100 DECLARE_TRACE(); | 100 DECLARE_TRACE(); |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 struct ObserverLessThan; | 103 struct ObserverLessThan; |
| 104 | 104 |
| 105 explicit MutationObserver(PassOwnPtrWillBeRawPtr<MutationCallback>); | 105 explicit MutationObserver(RawPtr<MutationCallback>); |
| 106 void deliver(); | 106 void deliver(); |
| 107 bool shouldBeSuspended() const; | 107 bool shouldBeSuspended() const; |
| 108 | 108 |
| 109 OwnPtrWillBeMember<MutationCallback> m_callback; | 109 Member<MutationCallback> m_callback; |
| 110 MutationRecordVector m_records; | 110 MutationRecordVector m_records; |
| 111 MutationObserverRegistrationSet m_registrations; | 111 MutationObserverRegistrationSet m_registrations; |
| 112 unsigned m_priority; | 112 unsigned m_priority; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 } // namespace blink | 115 } // namespace blink |
| 116 | 116 |
| 117 #endif // MutationObserver_h | 117 #endif // MutationObserver_h |
| OLD | NEW |