| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef SKY_ENGINE_CORE_DOM_MUTATIONOBSERVER_H_ | 31 #ifndef SKY_ENGINE_CORE_DOM_MUTATIONOBSERVER_H_ |
| 32 #define SKY_ENGINE_CORE_DOM_MUTATIONOBSERVER_H_ | 32 #define SKY_ENGINE_CORE_DOM_MUTATIONOBSERVER_H_ |
| 33 | 33 |
| 34 #include "sky/engine/bindings/core/v8/ScriptWrappable.h" | 34 #include "sky/engine/tonic/dart_wrappable.h" |
| 35 #include "sky/engine/platform/heap/Handle.h" | 35 #include "sky/engine/platform/heap/Handle.h" |
| 36 #include "sky/engine/wtf/HashSet.h" | 36 #include "sky/engine/wtf/HashSet.h" |
| 37 #include "sky/engine/wtf/PassOwnPtr.h" | 37 #include "sky/engine/wtf/PassOwnPtr.h" |
| 38 #include "sky/engine/wtf/PassRefPtr.h" | 38 #include "sky/engine/wtf/PassRefPtr.h" |
| 39 #include "sky/engine/wtf/RefCounted.h" | 39 #include "sky/engine/wtf/RefCounted.h" |
| 40 #include "sky/engine/wtf/RefPtr.h" | 40 #include "sky/engine/wtf/RefPtr.h" |
| 41 #include "sky/engine/wtf/Vector.h" | 41 #include "sky/engine/wtf/Vector.h" |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 class Dictionary; | |
| 46 class ExceptionState; | 45 class ExceptionState; |
| 47 class MutationCallback; | 46 class MutationCallback; |
| 48 class MutationObserver; | 47 class MutationObserver; |
| 49 class MutationObserverRegistration; | 48 class MutationObserverRegistration; |
| 50 class MutationRecord; | 49 class MutationRecord; |
| 51 class Node; | 50 class Node; |
| 52 | 51 |
| 53 typedef unsigned char MutationObserverOptions; | 52 typedef unsigned char MutationObserverOptions; |
| 54 typedef unsigned char MutationRecordDeliveryOptions; | 53 typedef unsigned char MutationRecordDeliveryOptions; |
| 55 | 54 |
| 56 typedef HashSet<RefPtr<MutationObserver> > MutationObserverSet; | 55 typedef HashSet<RefPtr<MutationObserver> > MutationObserverSet; |
| 57 typedef HashSet<RawPtr<MutationObserverRegistration> > MutationObserverRegistrat
ionSet; | 56 typedef HashSet<RawPtr<MutationObserverRegistration> > MutationObserverRegistrat
ionSet; |
| 58 typedef Vector<RefPtr<MutationObserver> > MutationObserverVector; | 57 typedef Vector<RefPtr<MutationObserver> > MutationObserverVector; |
| 59 typedef Vector<RefPtr<MutationRecord> > MutationRecordVector; | 58 typedef Vector<RefPtr<MutationRecord> > MutationRecordVector; |
| 60 | 59 |
| 61 class MutationObserver final : public RefCounted<MutationObserver>, public Scrip
tWrappable { | 60 class MutationObserver final : public RefCounted<MutationObserver>, public DartW
rappable { |
| 62 DEFINE_WRAPPERTYPEINFO(); | 61 DEFINE_WRAPPERTYPEINFO(); |
| 63 public: | 62 public: |
| 64 enum MutationType { | 63 enum MutationType { |
| 65 ChildList = 1 << 0, | 64 ChildList = 1 << 0, |
| 66 Attributes = 1 << 1, | 65 Attributes = 1 << 1, |
| 67 CharacterData = 1 << 2, | 66 CharacterData = 1 << 2, |
| 68 | 67 |
| 69 AllMutationTypes = ChildList | Attributes | CharacterData | 68 AllMutationTypes = ChildList | Attributes | CharacterData |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 enum ObservationFlags { | 71 enum ObservationFlags { |
| 73 Subtree = 1 << 3, | 72 Subtree = 1 << 3, |
| 74 AttributeFilter = 1 << 4 | 73 AttributeFilter = 1 << 4 |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 enum DeliveryFlags { | 76 enum DeliveryFlags { |
| 78 AttributeOldValue = 1 << 5, | 77 AttributeOldValue = 1 << 5, |
| 79 CharacterDataOldValue = 1 << 6, | 78 CharacterDataOldValue = 1 << 6, |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 static PassRefPtr<MutationObserver> create(PassOwnPtr<MutationCallback>); | 81 static PassRefPtr<MutationObserver> create(PassOwnPtr<MutationCallback>); |
| 83 static void resumeSuspendedObservers(); | 82 static void resumeSuspendedObservers(); |
| 84 static void deliverMutations(); | 83 static void deliverMutations(); |
| 85 | 84 |
| 86 ~MutationObserver(); | 85 ~MutationObserver(); |
| 87 | 86 |
| 88 void observe(Node*, const Dictionary&, ExceptionState&); | 87 void observe(Node*, ExceptionState&); |
| 89 Vector<RefPtr<MutationRecord> > takeRecords(); | 88 Vector<RefPtr<MutationRecord> > takeRecords(); |
| 90 void disconnect(); | 89 void disconnect(); |
| 91 void observationStarted(MutationObserverRegistration*); | 90 void observationStarted(MutationObserverRegistration*); |
| 92 void observationEnded(MutationObserverRegistration*); | 91 void observationEnded(MutationObserverRegistration*); |
| 93 void enqueueMutationRecord(PassRefPtr<MutationRecord>); | 92 void enqueueMutationRecord(PassRefPtr<MutationRecord>); |
| 94 void setHasTransientRegistration(); | 93 void setHasTransientRegistration(); |
| 95 bool canDeliver(); | 94 bool canDeliver(); |
| 96 | 95 |
| 97 HashSet<RawPtr<Node> > getObservedNodes() const; | 96 HashSet<RawPtr<Node> > getObservedNodes() const; |
| 98 | 97 |
| 99 private: | 98 private: |
| 100 struct ObserverLessThan; | 99 struct ObserverLessThan; |
| 101 | 100 |
| 102 explicit MutationObserver(PassOwnPtr<MutationCallback>); | 101 explicit MutationObserver(PassOwnPtr<MutationCallback>); |
| 103 void deliver(); | 102 void deliver(); |
| 104 | 103 |
| 105 OwnPtr<MutationCallback> m_callback; | 104 OwnPtr<MutationCallback> m_callback; |
| 106 MutationRecordVector m_records; | 105 MutationRecordVector m_records; |
| 107 MutationObserverRegistrationSet m_registrations; | 106 MutationObserverRegistrationSet m_registrations; |
| 108 unsigned m_priority; | 107 unsigned m_priority; |
| 109 }; | 108 }; |
| 110 | 109 |
| 111 } // namespace blink | 110 } // namespace blink |
| 112 | 111 |
| 113 #endif // SKY_ENGINE_CORE_DOM_MUTATIONOBSERVER_H_ | 112 #endif // SKY_ENGINE_CORE_DOM_MUTATIONOBSERVER_H_ |
| OLD | NEW |