3434
3535#include " mutation_observer.h"
3636#include " mutation_observer_options.h"
37- #include " node.h"
3837#include " mutation_observer_registration.h"
38+ #include " node.h"
3939
4040namespace webf {
4141
@@ -54,14 +54,14 @@ MutationObserver::MutationObserver(ExecutingContext* context, const std::shared_
5454
5555MutationObserver::~MutationObserver () = default ;
5656
57- void MutationObserver::observe (Node* node, const std::shared_ptr<MutationObserverInit>& observer_init, ExceptionState& exception_state) {
58-
57+ void MutationObserver::observe (Node* node,
58+ const std::shared_ptr<MutationObserverInit>& observer_init,
59+ ExceptionState& exception_state) {
5960 assert (node != nullptr );
6061
6162 MutationObserverOptions options = 0 ;
6263
63- if (observer_init->hasAttributeOldValue () &&
64- observer_init->attributeOldValue ())
64+ if (observer_init->hasAttributeOldValue () && observer_init->attributeOldValue ())
6565 options |= kAttributeOldValue ;
6666
6767 std::set<AtomicString> attribute_filter;
@@ -71,21 +71,16 @@ void MutationObserver::observe(Node* node, const std::shared_ptr<MutationObserve
7171 options |= kAttributeFilter ;
7272 }
7373
74- bool attributes =
75- observer_init->hasAttributes () && observer_init->attributes ();
74+ bool attributes = observer_init->hasAttributes () && observer_init->attributes ();
7675 if (attributes || (!observer_init->hasAttributes () &&
77- (observer_init->hasAttributeOldValue () ||
78- observer_init->hasAttributeFilter ())))
76+ (observer_init->hasAttributeOldValue () || observer_init->hasAttributeFilter ())))
7977 options |= kMutationTypeAttributes ;
8078
81- if (observer_init->hasCharacterDataOldValue () &&
82- observer_init->characterDataOldValue ())
79+ if (observer_init->hasCharacterDataOldValue () && observer_init->characterDataOldValue ())
8380 options |= kCharacterDataOldValue ;
8481
85- bool character_data =
86- observer_init->hasCharacterData () && observer_init->characterData ();
87- if (character_data || (!observer_init->hasCharacterData () &&
88- observer_init->hasCharacterDataOldValue ()))
82+ bool character_data = observer_init->hasCharacterData () && observer_init->characterData ();
83+ if (character_data || (!observer_init->hasCharacterData () && observer_init->hasCharacterDataOldValue ()))
8984 options |= kMutationTypeCharacterData ;
9085
9186 if (observer_init->childList ())
@@ -103,23 +98,22 @@ void MutationObserver::observe(Node* node, const std::shared_ptr<MutationObserve
10398 }
10499 if (options & kAttributeFilter ) {
105100 exception_state.ThrowException (ctx (), ErrorType::TypeError,
106- " The options object may only set 'attributeFilter' when 'attributes' "
107- " is true or not present." );
101+ " The options object may only set 'attributeFilter' when 'attributes' "
102+ " is true or not present." );
108103 return ;
109104 }
110105 }
111- if (!((options & kMutationTypeCharacterData ) ||
112- !(options & kCharacterDataOldValue ))) {
106+ if (!((options & kMutationTypeCharacterData ) || !(options & kCharacterDataOldValue ))) {
113107 exception_state.ThrowException (ctx (), ErrorType::TypeError,
114- " The options object may only set 'characterDataOldValue' to true when "
115- " 'characterData' is true or not present." );
108+ " The options object may only set 'characterDataOldValue' to true when "
109+ " 'characterData' is true or not present." );
116110 return ;
117111 }
118112
119113 if (!(options & kMutationTypeAll )) {
120114 exception_state.ThrowException (ctx (), ErrorType::TypeError,
121- " The options object must set at least one of 'attributes', "
122- " 'characterData', or 'childList' to true." );
115+ " The options object must set at least one of 'attributes', "
116+ " 'characterData', or 'childList' to true." );
123117 return ;
124118 }
125119
@@ -169,14 +163,13 @@ std::set<Member<Node>> MutationObserver::GetObservedNodes() const {
169163}
170164
171165void MutationObserver::Trace (GCVisitor* visitor) const {
172- for (auto & record : records_) {
166+ for (auto & record : records_) {
173167 visitor->TraceMember (record);
174168 }
175169
176- for (auto & re : registrations_) {
170+ for (auto & re : registrations_) {
177171 re->Trace (visitor);
178172 }
179173}
180174
181-
182175} // namespace webf
0 commit comments