| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 , m_priority(s_observerPriority++) | 67 , m_priority(s_observerPriority++) |
| 68 { | 68 { |
| 69 ScriptWrappable::init(this); | 69 ScriptWrappable::init(this); |
| 70 } | 70 } |
| 71 | 71 |
| 72 MutationObserver::~MutationObserver() | 72 MutationObserver::~MutationObserver() |
| 73 { | 73 { |
| 74 ASSERT(m_registrations.isEmpty()); | 74 ASSERT(m_registrations.isEmpty()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void MutationObserver::observe(Node* node, const Dictionary& optionsDictionary,
ExceptionState& es) | 77 void MutationObserver::observe(Node* node, const Dictionary& optionsDictionary,
ExceptionState& exceptionState) |
| 78 { | 78 { |
| 79 if (!node) { | 79 if (!node) { |
| 80 es.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute("
observe", "MutationObserver", "The provided node was null.")); | 80 exceptionState.throwDOMException(NotFoundError, ExceptionMessages::faile
dToExecute("observe", "MutationObserver", "The provided node was null.")); |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 | 83 |
| 84 MutationObserverOptions options = 0; | 84 MutationObserverOptions options = 0; |
| 85 | 85 |
| 86 bool attributeOldValue = false; | 86 bool attributeOldValue = false; |
| 87 bool attributeOldValuePresent = optionsDictionary.get("attributeOldValue", a
ttributeOldValue); | 87 bool attributeOldValuePresent = optionsDictionary.get("attributeOldValue", a
ttributeOldValue); |
| 88 if (attributeOldValue) | 88 if (attributeOldValue) |
| 89 options |= AttributeOldValue; | 89 options |= AttributeOldValue; |
| 90 | 90 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 111 bool childListValue = false; | 111 bool childListValue = false; |
| 112 if (optionsDictionary.get("childList", childListValue) && childListValue) | 112 if (optionsDictionary.get("childList", childListValue) && childListValue) |
| 113 options |= ChildList; | 113 options |= ChildList; |
| 114 | 114 |
| 115 bool subtreeValue = false; | 115 bool subtreeValue = false; |
| 116 if (optionsDictionary.get("subtree", subtreeValue) && subtreeValue) | 116 if (optionsDictionary.get("subtree", subtreeValue) && subtreeValue) |
| 117 options |= Subtree; | 117 options |= Subtree; |
| 118 | 118 |
| 119 if (!(options & Attributes)) { | 119 if (!(options & Attributes)) { |
| 120 if (options & AttributeOldValue) { | 120 if (options & AttributeOldValue) { |
| 121 es.throwDOMException(TypeError, ExceptionMessages::failedToExecute("
observe", "MutationObserver", "The options object may only set 'attributeOldValu
e' to true when 'attributes' is true or not present.")); | 121 exceptionState.throwDOMException(TypeError, ExceptionMessages::faile
dToExecute("observe", "MutationObserver", "The options object may only set 'attr
ibuteOldValue' to true when 'attributes' is true or not present.")); |
| 122 return; | 122 return; |
| 123 } | 123 } |
| 124 if (options & AttributeFilter) { | 124 if (options & AttributeFilter) { |
| 125 es.throwDOMException(TypeError, ExceptionMessages::failedToExecute("
observe", "MutationObserver", "The options object may only set 'attributeFilter'
when 'attributes' is true or not present.")); | 125 exceptionState.throwDOMException(TypeError, ExceptionMessages::faile
dToExecute("observe", "MutationObserver", "The options object may only set 'attr
ibuteFilter' when 'attributes' is true or not present.")); |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 if (!((options & CharacterData) || !(options & CharacterDataOldValue))) { | 129 if (!((options & CharacterData) || !(options & CharacterDataOldValue))) { |
| 130 es.throwDOMException(TypeError, ExceptionMessages::failedToExecute("obse
rve", "MutationObserver", "The options object may only set 'characterDataOldValu
e' to true when 'characterData' is true or not present.")); | 130 exceptionState.throwDOMException(TypeError, ExceptionMessages::failedToE
xecute("observe", "MutationObserver", "The options object may only set 'characte
rDataOldValue' to true when 'characterData' is true or not present.")); |
| 131 return; | 131 return; |
| 132 } | 132 } |
| 133 | 133 |
| 134 if (!(options & (Attributes | CharacterData | ChildList))) { | 134 if (!(options & (Attributes | CharacterData | ChildList))) { |
| 135 es.throwDOMException(TypeError, ExceptionMessages::failedToExecute("obse
rve", "MutationObserver", "The options object must set at least one of 'attribut
es', 'characterData', or 'childList' to true.")); | 135 exceptionState.throwDOMException(TypeError, ExceptionMessages::failedToE
xecute("observe", "MutationObserver", "The options object must set at least one
of 'attributes', 'characterData', or 'childList' to true.")); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 | 138 |
| 139 node->registerMutationObserver(this, options, attributeFilter); | 139 node->registerMutationObserver(this, options, attributeFilter); |
| 140 } | 140 } |
| 141 | 141 |
| 142 Vector<RefPtr<MutationRecord> > MutationObserver::takeRecords() | 142 Vector<RefPtr<MutationRecord> > MutationObserver::takeRecords() |
| 143 { | 143 { |
| 144 Vector<RefPtr<MutationRecord> > records; | 144 Vector<RefPtr<MutationRecord> > records; |
| 145 records.swap(m_records); | 145 records.swap(m_records); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 observers[i]->deliver(); | 259 observers[i]->deliver(); |
| 260 else | 260 else |
| 261 suspendedMutationObservers().add(observers[i]); | 261 suspendedMutationObservers().add(observers[i]); |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | 264 |
| 265 deliveryInProgress = false; | 265 deliveryInProgress = false; |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace WebCore | 268 } // namespace WebCore |
| OLD | NEW |