Changeset 102100 in webkit
- Timestamp:
- Dec 5, 2011 11:37:07 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r102089 r102100 1 2011-12-05 Rafael Weinstein <rafaelw@chromium.org> 2 3 [MutationObservers] Support 'attributes' mutation records for element.removeAttribute 4 https://bugs.webkit.org/show_bug.cgi?id=73880 5 6 Reviewed by Ojan Vafai. 7 8 * fast/mutation/observe-attributes-expected.txt: 9 * fast/mutation/observe-attributes.html: 10 1 11 2011-12-05 Florin Malita <fmalita@google.com> 2 12 -
trunk/LayoutTests/fast/mutation/observe-attributes-expected.txt
r101101 r102100 6 6 Testing basic aspects of attribute observation. 7 7 ...can attribute changes be observed at all 8 PASS mutations.length is 18 PASS mutations.length is 2 9 9 PASS mutations[0].type is "attributes" 10 10 PASS mutations[0].attributeName is "foo" 11 11 PASS mutations[0].attributeNamespace is null 12 PASS mutations[1].type is "attributes" 13 PASS mutations[1].attributeName is "bar" 14 PASS mutations[1].attributeNamespace is null 12 15 ...observer.disconnect() should prevent further delivery of mutations. 13 16 PASS mutations is null … … 60 63 61 64 Testing basic oldValue delivery. 62 PASS mutations.length is 265 PASS mutations.length is 3 63 66 PASS mutations[0].type is "attributes" 64 67 PASS mutations[0].attributeName is "foo" … … 67 70 PASS mutations[1].attributeName is "foo" 68 71 PASS mutations[1].oldValue is "bar" 72 PASS mutations[2].type is "attributes" 73 PASS mutations[2].attributeName is "bar" 74 PASS mutations[2].oldValue is "boo" 69 75 70 76 Testing that oldValue is delivered as requested (or not). -
trunk/LayoutTests/fast/mutation/observe-attributes.html
r101101 r102100 23 23 mutations = null; 24 24 div = document.createElement('div'); 25 div.setAttribute('bar', 'foo'); 26 25 27 observer = new WebKitMutationObserver(function(m) { 26 28 mutations = m; … … 29 31 observer.observe(div, { attributes: true, characterData: true }); 30 32 div.setAttribute('foo', 'bar'); 33 div.removeAttribute('bar'); 31 34 setTimeout(checkDisconnectAndMutate, 0); 32 35 } … … 35 38 debug('...can attribute changes be observed at all'); 36 39 37 shouldBe('mutations.length', ' 1');40 shouldBe('mutations.length', '2'); 38 41 shouldBe('mutations[0].type', '"attributes"'); 39 42 shouldBe('mutations[0].attributeName', '"foo"'); 40 43 shouldBe('mutations[0].attributeNamespace', 'null'); 44 shouldBe('mutations[1].type', '"attributes"'); 45 shouldBe('mutations[1].attributeName', '"bar"'); 46 shouldBe('mutations[1].attributeNamespace', 'null'); 41 47 42 48 mutations = null; … … 304 310 mutations = null; 305 311 div = document.createElement('div'); 312 div.setAttribute('bar', 'boo'); 313 306 314 observer = new WebKitMutationObserver(function(mutations) { 307 315 window.mutations = mutations; … … 310 318 div.setAttribute('foo', 'bar'); 311 319 div.setAttribute('foo', 'baz'); 312 setTimeout(finish, 0); 313 } 314 315 function finish() { 316 shouldBe('mutations.length', '2'); 320 div.removeAttribute('bar'); 321 div.removeAttribute('non-existant'); 322 setTimeout(finish, 0); 323 } 324 325 function finish() { 326 shouldBe('mutations.length', '3'); 317 327 shouldBe('mutations[0].type', '"attributes"'); 318 328 shouldBe('mutations[0].attributeName', '"foo"'); … … 321 331 shouldBe('mutations[1].attributeName', '"foo"'); 322 332 shouldBe('mutations[1].oldValue', '"bar"'); 333 shouldBe('mutations[2].type', '"attributes"'); 334 shouldBe('mutations[2].attributeName', '"bar"'); 335 shouldBe('mutations[2].oldValue', '"boo"'); 323 336 observer.disconnect(); 324 337 debug(''); -
trunk/Source/WebCore/ChangeLog
r102098 r102100 1 2011-12-05 Rafael Weinstein <rafaelw@chromium.org> 2 3 [MutationObservers] Support 'attributes' mutation records for element.removeAttribute 4 https://bugs.webkit.org/show_bug.cgi?id=73880 5 6 Reviewed by Ojan Vafai. 7 8 * dom/Element.cpp: 9 (WebCore::enqueueAttributesMutationRecord): 10 (WebCore::Element::removeAttribute): 11 1 12 2011-12-05 Dana Jansens <danakj@chromium.org> 2 13 -
trunk/Source/WebCore/dom/Element.cpp
r101855 r102100 181 181 } 182 182 183 #if ENABLE(MUTATION_OBSERVERS) 184 static void enqueueAttributesMutationRecord(Element* target, const QualifiedName& attributeName, const AtomicString& oldValue) 185 { 186 OwnPtr<MutationObserverInterestGroup> mutationRecipients = MutationObserverInterestGroup::createForAttributesMutation(target, attributeName); 187 mutationRecipients->enqueueMutationRecord(MutationRecord::createAttributes(target, attributeName, oldValue)); 188 } 189 #endif 190 183 191 void Element::removeAttribute(const QualifiedName& name, ExceptionCode& ec) 184 192 { 185 193 if (m_attributeMap) { 186 194 ec = 0; 187 m_attributeMap->removeNamedItem(name, ec);195 RefPtr<Node> attrNode = m_attributeMap->removeNamedItem(name, ec); 188 196 if (ec == NOT_FOUND_ERR) 189 197 ec = 0; 198 #if ENABLE(MUTATION_OBSERVERS) 199 else 200 enqueueAttributesMutationRecord(this, name, attrNode->nodeValue()); 201 #endif 190 202 } 191 203 } … … 616 628 return getAttribute(QualifiedName(nullAtom, localName, namespaceURI)); 617 629 } 618 619 #if ENABLE(MUTATION_OBSERVERS)620 static void enqueueAttributesMutationRecord(Element* target, const QualifiedName& attributeName, const AtomicString& oldValue)621 {622 OwnPtr<MutationObserverInterestGroup> mutationRecipients = MutationObserverInterestGroup::createForAttributesMutation(target, attributeName);623 mutationRecipients->enqueueMutationRecord(MutationRecord::createAttributes(target, attributeName, oldValue));624 }625 #endif626 630 627 631 void Element::setAttribute(const AtomicString& name, const AtomicString& value, ExceptionCode& ec) … … 1543 1547 if (m_attributeMap) { 1544 1548 ec = 0; 1545 m_attributeMap->removeNamedItem(localName, ec);1549 RefPtr<Node> attrNode = m_attributeMap->removeNamedItem(localName, ec); 1546 1550 if (ec == NOT_FOUND_ERR) 1547 1551 ec = 0; 1552 #if ENABLE(MUTATION_OBSERVERS) 1553 else 1554 enqueueAttributesMutationRecord(this, QualifiedName(nullAtom, localName, nullAtom), attrNode->nodeValue()); 1555 #endif 1548 1556 } 1549 1557
Note: See TracChangeset
for help on using the changeset viewer.