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

Side by Side Diff: Source/core/dom/MutationObserver.cpp

Issue 373423002: Split Dictionary's get and convert into DictionaryHelper. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 void MutationObserver::observe(Node* node, const Dictionary& optionsDictionary, ExceptionState& exceptionState) 79 void MutationObserver::observe(Node* node, const Dictionary& optionsDictionary, ExceptionState& exceptionState)
80 { 80 {
81 if (!node) { 81 if (!node) {
82 exceptionState.throwDOMException(NotFoundError, "The provided node was n ull."); 82 exceptionState.throwDOMException(NotFoundError, "The provided node was n ull.");
83 return; 83 return;
84 } 84 }
85 85
86 MutationObserverOptions options = 0; 86 MutationObserverOptions options = 0;
87 87
88 bool attributeOldValue = false; 88 bool attributeOldValue = false;
89 bool attributeOldValuePresent = optionsDictionary.get("attributeOldValue", a ttributeOldValue); 89 bool attributeOldValuePresent = DictionaryHelper::get(optionsDictionary, "at tributeOldValue", attributeOldValue);
90 if (attributeOldValue) 90 if (attributeOldValue)
91 options |= AttributeOldValue; 91 options |= AttributeOldValue;
92 92
93 HashSet<AtomicString> attributeFilter; 93 HashSet<AtomicString> attributeFilter;
94 bool attributeFilterPresent = optionsDictionary.get("attributeFilter", attri buteFilter); 94 bool attributeFilterPresent = DictionaryHelper::get(optionsDictionary, "attr ibuteFilter", attributeFilter);
95 if (attributeFilterPresent) 95 if (attributeFilterPresent)
96 options |= AttributeFilter; 96 options |= AttributeFilter;
97 97
98 bool attributes = false; 98 bool attributes = false;
99 bool attributesPresent = optionsDictionary.get("attributes", attributes); 99 bool attributesPresent = DictionaryHelper::get(optionsDictionary, "attribute s", attributes);
100 if (attributes || (!attributesPresent && (attributeOldValuePresent || attrib uteFilterPresent))) 100 if (attributes || (!attributesPresent && (attributeOldValuePresent || attrib uteFilterPresent)))
101 options |= Attributes; 101 options |= Attributes;
102 102
103 bool characterDataOldValue = false; 103 bool characterDataOldValue = false;
104 bool characterDataOldValuePresent = optionsDictionary.get("characterDataOldV alue", characterDataOldValue); 104 bool characterDataOldValuePresent = DictionaryHelper::get(optionsDictionary, "characterDataOldValue", characterDataOldValue);
105 if (characterDataOldValue) 105 if (characterDataOldValue)
106 options |= CharacterDataOldValue; 106 options |= CharacterDataOldValue;
107 107
108 bool characterData = false; 108 bool characterData = false;
109 bool characterDataPresent = optionsDictionary.get("characterData", character Data); 109 bool characterDataPresent = DictionaryHelper::get(optionsDictionary, "charac terData", characterData);
110 if (characterData || (!characterDataPresent && characterDataOldValuePresent) ) 110 if (characterData || (!characterDataPresent && characterDataOldValuePresent) )
111 options |= CharacterData; 111 options |= CharacterData;
112 112
113 bool childListValue = false; 113 bool childListValue = false;
114 if (optionsDictionary.get("childList", childListValue) && childListValue) 114 if (DictionaryHelper::get(optionsDictionary, "childList", childListValue) && childListValue)
115 options |= ChildList; 115 options |= ChildList;
116 116
117 bool subtreeValue = false; 117 bool subtreeValue = false;
118 if (optionsDictionary.get("subtree", subtreeValue) && subtreeValue) 118 if (DictionaryHelper::get(optionsDictionary, "subtree", subtreeValue) && sub treeValue)
119 options |= Subtree; 119 options |= Subtree;
120 120
121 if (!(options & Attributes)) { 121 if (!(options & Attributes)) {
122 if (options & AttributeOldValue) { 122 if (options & AttributeOldValue) {
123 exceptionState.throwTypeError("The options object may only set 'attr ibuteOldValue' to true when 'attributes' is true or not present."); 123 exceptionState.throwTypeError("The options object may only set 'attr ibuteOldValue' to true when 'attributes' is true or not present.");
124 return; 124 return;
125 } 125 }
126 if (options & AttributeFilter) { 126 if (options & AttributeFilter) {
127 exceptionState.throwTypeError("The options object may only set 'attr ibuteFilter' when 'attributes' is true or not present."); 127 exceptionState.throwTypeError("The options object may only set 'attr ibuteFilter' when 'attributes' is true or not present.");
128 return; 128 return;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 274 }
275 } 275 }
276 276
277 void MutationObserver::trace(Visitor* visitor) 277 void MutationObserver::trace(Visitor* visitor)
278 { 278 {
279 visitor->trace(m_records); 279 visitor->trace(m_records);
280 visitor->trace(m_registrations); 280 visitor->trace(m_registrations);
281 } 281 }
282 282
283 } // namespace WebCore 283 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698