Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Unified Diff: Source/core/dom/MutationObserver.cpp

Issue 560003002: Add MutationObserverInit (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/MutationObserver.cpp
diff --git a/Source/core/dom/MutationObserver.cpp b/Source/core/dom/MutationObserver.cpp
index bccc8c9ed6d3c75913be715038c83e44016d237f..ac7c9c1bad6694650c6a4c18f9e6e55b2a9ffee7 100644
--- a/Source/core/dom/MutationObserver.cpp
+++ b/Source/core/dom/MutationObserver.cpp
@@ -31,11 +31,11 @@
#include "config.h"
#include "core/dom/MutationObserver.h"
-#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/Microtask.h"
#include "core/dom/MutationCallback.h"
+#include "core/dom/MutationObserverInit.h"
#include "core/dom/MutationObserverRegistration.h"
#include "core/dom/MutationRecord.h"
#include "core/dom/Node.h"
@@ -75,7 +75,7 @@ MutationObserver::~MutationObserver()
InspectorInstrumentation::didClearAllMutationRecords(m_callback->executionContext(), this);
}
-void MutationObserver::observe(Node* node, const Dictionary& optionsDictionary, ExceptionState& exceptionState)
+void MutationObserver::observe(Node* node, const MutationObserverInit* observerInit, ExceptionState& exceptionState)
{
if (!node) {
exceptionState.throwDOMException(NotFoundError, "The provided node was null.");
@@ -84,37 +84,32 @@ void MutationObserver::observe(Node* node, const Dictionary& optionsDictionary,
MutationObserverOptions options = 0;
- bool attributeOldValue = false;
- bool attributeOldValuePresent = DictionaryHelper::get(optionsDictionary, "attributeOldValue", attributeOldValue);
- if (attributeOldValue)
+ if (observerInit->hasAttributeOldValue() && observerInit->attributeOldValue())
options |= AttributeOldValue;
HashSet<AtomicString> attributeFilter;
- bool attributeFilterPresent = DictionaryHelper::get(optionsDictionary, "attributeFilter", attributeFilter);
- if (attributeFilterPresent)
+ if (observerInit->hasAttributeFilter()) {
+ const Vector<String>& sequence = observerInit->attributeFilter();
+ for (unsigned i = 0; i < sequence.size(); ++i)
+ attributeFilter.add(AtomicString(sequence[i]));
options |= AttributeFilter;
+ }
- bool attributes = false;
- bool attributesPresent = DictionaryHelper::get(optionsDictionary, "attributes", attributes);
- if (attributes || (!attributesPresent && (attributeOldValuePresent || attributeFilterPresent)))
+ bool attributes = observerInit->hasAttributes() && observerInit->attributes();
+ if (attributes || (!observerInit->hasAttributes() && (observerInit->hasAttributeOldValue() || observerInit->hasAttributeFilter())))
options |= Attributes;
- bool characterDataOldValue = false;
- bool characterDataOldValuePresent = DictionaryHelper::get(optionsDictionary, "characterDataOldValue", characterDataOldValue);
- if (characterDataOldValue)
+ if (observerInit->hasCharacterDataOldValue() && observerInit->characterDataOldValue())
options |= CharacterDataOldValue;
- bool characterData = false;
- bool characterDataPresent = DictionaryHelper::get(optionsDictionary, "characterData", characterData);
- if (characterData || (!characterDataPresent && characterDataOldValuePresent))
+ bool characterData = observerInit->hasCharacterData() && observerInit->characterData();
+ if (characterData || (!observerInit->hasCharacterData() && observerInit->hasCharacterDataOldValue()))
options |= CharacterData;
- bool childListValue = false;
- if (DictionaryHelper::get(optionsDictionary, "childList", childListValue) && childListValue)
+ if (observerInit->childList())
options |= ChildList;
- bool subtreeValue = false;
- if (DictionaryHelper::get(optionsDictionary, "subtree", subtreeValue) && subtreeValue)
+ if (observerInit->subtree())
options |= Subtree;
if (!(options & Attributes)) {

Powered by Google App Engine
This is Rietveld 408576698