| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 { | 77 { |
| 78 return (options & (Attributes | CharacterData | ChildList)) | 78 return (options & (Attributes | CharacterData | ChildList)) |
| 79 && ((options & Attributes) || !(options & AttributeOldValue)) | 79 && ((options & Attributes) || !(options & AttributeOldValue)) |
| 80 && ((options & Attributes) || !(options & AttributeFilter)) | 80 && ((options & Attributes) || !(options & AttributeFilter)) |
| 81 && ((options & CharacterData) || !(options & CharacterDataOldValue)); | 81 && ((options & CharacterData) || !(options & CharacterDataOldValue)); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void MutationObserver::observe(Node* node, const Dictionary& optionsDictionary,
ExceptionState& es) | 84 void MutationObserver::observe(Node* node, const Dictionary& optionsDictionary,
ExceptionState& es) |
| 85 { | 85 { |
| 86 if (!node) { | 86 if (!node) { |
| 87 es.throwDOMException(NotFoundError); | 87 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 | 90 |
| 91 static const struct { | 91 static const struct { |
| 92 const char* name; | 92 const char* name; |
| 93 MutationObserverOptions value; | 93 MutationObserverOptions value; |
| 94 } booleanOptions[] = { | 94 } booleanOptions[] = { |
| 95 { "childList", ChildList }, | 95 { "childList", ChildList }, |
| 96 { "attributes", Attributes }, | 96 { "attributes", Attributes }, |
| 97 { "characterData", CharacterData }, | 97 { "characterData", CharacterData }, |
| 98 { "subtree", Subtree }, | 98 { "subtree", Subtree }, |
| 99 { "attributeOldValue", AttributeOldValue }, | 99 { "attributeOldValue", AttributeOldValue }, |
| 100 { "characterDataOldValue", CharacterDataOldValue } | 100 { "characterDataOldValue", CharacterDataOldValue } |
| 101 }; | 101 }; |
| 102 MutationObserverOptions options = 0; | 102 MutationObserverOptions options = 0; |
| 103 for (unsigned i = 0; i < sizeof(booleanOptions) / sizeof(booleanOptions[0]);
++i) { | 103 for (unsigned i = 0; i < sizeof(booleanOptions) / sizeof(booleanOptions[0]);
++i) { |
| 104 bool value = false; | 104 bool value = false; |
| 105 if (optionsDictionary.get(booleanOptions[i].name, value) && value) | 105 if (optionsDictionary.get(booleanOptions[i].name, value) && value) |
| 106 options |= booleanOptions[i].value; | 106 options |= booleanOptions[i].value; |
| 107 } | 107 } |
| 108 | 108 |
| 109 HashSet<AtomicString> attributeFilter; | 109 HashSet<AtomicString> attributeFilter; |
| 110 if (optionsDictionary.get("attributeFilter", attributeFilter)) | 110 if (optionsDictionary.get("attributeFilter", attributeFilter)) |
| 111 options |= AttributeFilter; | 111 options |= AttributeFilter; |
| 112 | 112 |
| 113 if (!validateOptions(options)) { | 113 if (!validateOptions(options)) { |
| 114 es.throwDOMException(SyntaxError); | 114 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 | 117 |
| 118 node->registerMutationObserver(this, options, attributeFilter); | 118 node->registerMutationObserver(this, options, attributeFilter); |
| 119 } | 119 } |
| 120 | 120 |
| 121 Vector<RefPtr<MutationRecord> > MutationObserver::takeRecords() | 121 Vector<RefPtr<MutationRecord> > MutationObserver::takeRecords() |
| 122 { | 122 { |
| 123 Vector<RefPtr<MutationRecord> > records; | 123 Vector<RefPtr<MutationRecord> > records; |
| 124 records.swap(m_records); | 124 records.swap(m_records); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 observers[i]->deliver(); | 238 observers[i]->deliver(); |
| 239 else | 239 else |
| 240 suspendedMutationObservers().add(observers[i]); | 240 suspendedMutationObservers().add(observers[i]); |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 | 243 |
| 244 deliveryInProgress = false; | 244 deliveryInProgress = false; |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace WebCore | 247 } // namespace WebCore |
| OLD | NEW |