Changeset 99992 in webkit
- Timestamp:
- Nov 11, 2011 10:56:02 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r99990 r99992 1 2011-11-11 Rafael Weinstein <rafaelw@chromium.org> 2 3 [MutationObservers] Support attributeFilter for attribute mutations 4 https://bugs.webkit.org/show_bug.cgi?id=70860 5 6 Reviewed by Dimitri Glazkov. 7 8 * fast/mutation/observe-attributes-expected.txt: 9 * fast/mutation/observe-attributes.html: 10 1 11 2011-11-11 Sadrul Habib Chowdhury <sadrul@chromium.org> 2 12 -
trunk/LayoutTests/fast/mutation/observe-attributes-expected.txt
r98791 r99992 93 93 PASS mutations[1].oldValue is "foo" 94 94 95 Testing that attributeFilter works as expected and ignores case with HTML elements. 96 ...only foo, bar & boom should be received. 97 PASS mutations.length is 3 98 PASS mutations[0].type is "attributes" 99 PASS mutations[0].attributeName is "foo" 100 PASS mutations[0].attributeNamespace is null 101 PASS mutations[1].type is "attributes" 102 PASS mutations[1].attributeName is "bar" 103 PASS mutations[1].attributeNamespace is null 104 PASS mutations[2].type is "attributes" 105 PASS mutations[2].attributeName is "boom" 106 PASS mutations[2].attributeNamespace is null 107 108 Testing the behavior of attributeFilter when the same observer observes at multiple nodes in a subtree with different filter options. 109 ...only foo, bar & bat should be received. 110 PASS mutations.length is 3 111 PASS mutations[0].type is "attributes" 112 PASS mutations[0].attributeName is "foo" 113 PASS mutations[0].attributeNamespace is null 114 PASS mutations[1].type is "attributes" 115 PASS mutations[1].attributeName is "bar" 116 PASS mutations[1].attributeNamespace is null 117 PASS mutations[2].type is "attributes" 118 PASS mutations[2].attributeName is "bat" 119 PASS mutations[2].attributeNamespace is null 120 ...bar, bat & baz should all be received. 121 PASS mutations.length is 3 122 PASS mutations[0].type is "attributes" 123 PASS mutations[0].attributeName is "bar" 124 PASS mutations[0].attributeNamespace is null 125 PASS mutations[1].type is "attributes" 126 PASS mutations[1].attributeName is "bat" 127 PASS mutations[1].attributeNamespace is null 128 PASS mutations[2].type is "attributes" 129 PASS mutations[2].attributeName is "baz" 130 PASS mutations[2].attributeNamespace is null 131 132 Testing that attributeFilter respects case with non-HTML elements. 133 ...pathLength should be received. 134 PASS mutations.length is 1 135 PASS mutations[0].type is "attributes" 136 PASS mutations[0].attributeName is "pathLength" 137 PASS mutations[0].attributeNamespace is "http://www.w3.org/2000/svg" 138 139 Testing that attributeFilter respects case with non-HTML elements. 140 ...only ID, id, booM, pathLength should be received. 141 PASS mutations.length is 4 142 PASS mutations[0].type is "attributes" 143 PASS mutations[0].attributeName is "ID" 144 PASS mutations[0].attributeNamespace is null 145 PASS mutations[1].type is "attributes" 146 PASS mutations[1].attributeName is "id" 147 PASS mutations[1].attributeNamespace is null 148 PASS mutations[2].type is "attributes" 149 PASS mutations[2].attributeName is "booM" 150 PASS mutations[2].attributeNamespace is null 151 PASS mutations[3].type is "attributes" 152 PASS mutations[3].attributeName is "pathLength" 153 PASS mutations[3].attributeNamespace is "http://www.w3.org/2000/svg" 154 95 155 PASS successfullyParsed is true 96 156 -
trunk/LayoutTests/fast/mutation/observe-attributes.html
r98791 r99992 108 108 function start() { 109 109 debug('Testing that re-observing the same node with the same observer has the effect of resetting the options.'); 110 110 111 111 calls = 0; 112 112 mutations = null; … … 428 428 shouldBe('mutations[1].attributeName', '"id"'); 429 429 shouldBe('mutations[1].oldValue', '"foo"'); 430 observer.disconnect(); 431 debug(''); 432 runNextTest(); 433 } 434 435 start(); 436 } 437 438 function testAttributeFilter() { 439 var div, path; 440 var observer; 441 442 function start() { 443 debug('Testing that attributeFilter works as expected and ignores case with HTML elements.'); 444 445 mutations = null; 446 observer = new WebKitMutationObserver(function(m) { 447 mutations = m; 448 }); 449 450 div = document.createElement('div'); 451 observer.observe(div, { attributes: true, attributeFilter: ['foo', 'bar', 'booM'] }); 452 div.setAttribute('foo', 'foo'); 453 div.setAttribute('bar', 'bar'); 454 div.setAttribute('baz', 'baz'); 455 div.setAttribute('BOOm', 'boom'); 456 457 setTimeout(finish, 0); 458 } 459 460 function finish() { 461 debug('...only foo, bar & boom should be received.'); 462 463 shouldBe('mutations.length', '3'); 464 shouldBe('mutations[0].type', '"attributes"'); 465 shouldBe('mutations[0].attributeName', '"foo"'); 466 shouldBe('mutations[0].attributeNamespace', 'null'); 467 shouldBe('mutations[1].type', '"attributes"'); 468 shouldBe('mutations[1].attributeName', '"bar"'); 469 shouldBe('mutations[1].attributeNamespace', 'null'); 470 shouldBe('mutations[2].type', '"attributes"'); 471 shouldBe('mutations[2].attributeName', '"boom"'); 472 shouldBe('mutations[2].attributeNamespace', 'null'); 473 observer.disconnect(); 474 debug(''); 475 runNextTest(); 476 } 477 478 start(); 479 } 480 481 function testAttributeFilterSubtree() { 482 var div, div2, div3; 483 var observer; 484 485 function start() { 486 debug('Testing the behavior of attributeFilter when the same observer observes at multiple nodes in a subtree with different filter options.'); 487 488 mutations = null; 489 observer = new WebKitMutationObserver(function(m) { 490 mutations = m; 491 }); 492 493 div = document.createElement('div'); 494 div2 = div.appendChild(document.createElement('div')); 495 div3 = div2.appendChild(document.createElement('div')); 496 497 observer.observe(div, { attributes: true, subtree: true, attributeFilter: ['foo', 'bar'] }); 498 observer.observe(div2, { attributes: true, subtree: true, attributeFilter: ['bar', 'bat'] }); 499 500 div3.setAttribute('foo', 'foo'); 501 div3.setAttribute('bar', 'bar'); 502 div3.setAttribute('bat', 'bat'); 503 div3.setAttribute('baz', 'baz'); 504 505 setTimeout(checkAndObserveAll, 0); 506 } 507 508 function checkAndObserveAll() { 509 debug('...only foo, bar & bat should be received.'); 510 511 shouldBe('mutations.length', '3'); 512 shouldBe('mutations[0].type', '"attributes"'); 513 shouldBe('mutations[0].attributeName', '"foo"'); 514 shouldBe('mutations[0].attributeNamespace', 'null'); 515 shouldBe('mutations[1].type', '"attributes"'); 516 shouldBe('mutations[1].attributeName', '"bar"'); 517 shouldBe('mutations[1].attributeNamespace', 'null'); 518 shouldBe('mutations[2].type', '"attributes"'); 519 shouldBe('mutations[2].attributeName', '"bat"'); 520 shouldBe('mutations[2].attributeNamespace', 'null'); 521 522 observer.observe(div2, { attributes: true, subtree: true }); 523 div3.setAttribute('bar', 'bar'); 524 div3.setAttribute('bat', 'bat'); 525 div3.setAttribute('baz', 'baz'); 526 527 setTimeout(finish, 0); 528 } 529 530 function finish() { 531 debug('...bar, bat & baz should all be received.'); 532 533 shouldBe('mutations.length', '3'); 534 shouldBe('mutations[0].type', '"attributes"'); 535 shouldBe('mutations[0].attributeName', '"bar"'); 536 shouldBe('mutations[0].attributeNamespace', 'null'); 537 shouldBe('mutations[1].type', '"attributes"'); 538 shouldBe('mutations[1].attributeName', '"bat"'); 539 shouldBe('mutations[1].attributeNamespace', 'null'); 540 shouldBe('mutations[2].type', '"attributes"'); 541 shouldBe('mutations[2].attributeName', '"baz"'); 542 shouldBe('mutations[2].attributeNamespace', 'null'); 543 544 observer.disconnect(); 545 debug(''); 546 runNextTest(); 547 } 548 549 start(); 550 } 551 552 function testAttributeFilterNonHTMLElement() { 553 var path; 554 var observer; 555 556 function start() { 557 debug('Testing that attributeFilter respects case with non-HTML elements.'); 558 559 mutations = null; 560 observer = new WebKitMutationObserver(function(m) { 561 mutations = m; 562 }); 563 564 path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); 565 observer.observe(path, { attributes: true, attributeFilter: ['pathLength'] }); 566 path.setAttributeNS('http://www.w3.org/2000/svg', 'pathLength', '200'); 567 path.setAttributeNS('http://www.w3.org/2000/svg', 'pathlength', '200'); 568 569 setTimeout(finish, 0); 570 } 571 572 function finish() { 573 debug('...pathLength should be received.'); 574 575 shouldBe('mutations.length', '1'); 576 shouldBe('mutations[0].type', '"attributes"'); 577 shouldBe('mutations[0].attributeName', '"pathLength"'); 578 shouldBe('mutations[0].attributeNamespace', '"http://www.w3.org/2000/svg"'); 579 observer.disconnect(); 580 debug(''); 581 runNextTest(); 582 } 583 584 start(); 585 } 586 587 function testAttributeFilterNonHTMLDocument() { 588 var svgDoc, div, path; 589 var observer; 590 591 function start() { 592 debug('Testing that attributeFilter respects case with non-HTML elements.'); 593 594 svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', 'svg'); 595 mutations = null; 596 observer = new WebKitMutationObserver(function(m) { 597 mutations = m; 598 }); 599 600 div = svgDoc.createElement('div'); 601 observer.observe(div, { attributes: true, attributeFilter: ['ID', 'id', 'booM'] }); 602 div.setAttribute('ID', 'ID'); 603 div.setAttribute('id', 'id'); 604 div.setAttribute('baz', 'baz'); 605 div.setAttribute('booM', 'boom'); 606 div.setAttribute('BOOm', 'boom'); 607 608 path = svgDoc.createElementNS('http://www.w3.org/2000/svg', 'path'); 609 observer.observe(path, { attributes: true, attributeFilter: ['pathLength'] }); 610 path.setAttributeNS('http://www.w3.org/2000/svg', 'pathLength', '200'); 611 path.setAttributeNS('http://www.w3.org/2000/svg', 'pathlength', '200'); 612 613 setTimeout(finish, 0); 614 } 615 616 function finish() { 617 debug('...only ID, id, booM, pathLength should be received.'); 618 619 shouldBe('mutations.length', '4'); 620 shouldBe('mutations[0].type', '"attributes"'); 621 shouldBe('mutations[0].attributeName', '"ID"'); 622 shouldBe('mutations[0].attributeNamespace', 'null'); 623 shouldBe('mutations[1].type', '"attributes"'); 624 shouldBe('mutations[1].attributeName', '"id"'); 625 shouldBe('mutations[1].attributeNamespace', 'null'); 626 shouldBe('mutations[2].type', '"attributes"'); 627 shouldBe('mutations[2].attributeName', '"booM"'); 628 shouldBe('mutations[2].attributeNamespace', 'null'); 629 shouldBe('mutations[3].type', '"attributes"'); 630 shouldBe('mutations[3].attributeName', '"pathLength"'); 631 shouldBe('mutations[3].attributeNamespace', '"http://www.w3.org/2000/svg"'); 632 430 633 observer.disconnect(); 431 634 debug(''); … … 447 650 testOldValueAsRequested, 448 651 testOldValueUnionMultipleObservations, 449 testIDLAttribute 652 testIDLAttribute, 653 testAttributeFilter, 654 testAttributeFilterSubtree, 655 testAttributeFilterNonHTMLElement, 656 testAttributeFilterNonHTMLDocument 450 657 ]; 451 658 var testIndex = 0; -
trunk/LayoutTests/fast/mutation/observe-exceptions-expected.txt
r99611 r99992 15 15 PASS observer.observe(document.body, {childList: true, attributeOldValue: true}) threw exception Error: SYNTAX_ERR: DOM Exception 12. 16 16 PASS observer.observe(document.body, {attributes: true, characterDataOldValue: true}) threw exception Error: SYNTAX_ERR: DOM Exception 12. 17 PASS observer.observe(document.body, {characterData: true, attributeFilter: ["id"]}) threw exception Error: SYNTAX_ERR: DOM Exception 12. 17 18 PASS successfullyParsed is true 18 19 -
trunk/LayoutTests/fast/mutation/observe-exceptions.html
r99611 r99992 24 24 shouldThrow('observer.observe(document.body, {childList: true, attributeOldValue: true})'); 25 25 shouldThrow('observer.observe(document.body, {attributes: true, characterDataOldValue: true})'); 26 // FIXME: Uncomment the below when attributeFilter is supported. 27 //shouldThrow('observer.observe(document.body, {characterData: true, attributeFilter: ["id"]})'); 26 shouldThrow('observer.observe(document.body, {characterData: true, attributeFilter: ["id"]})'); 28 27 } 29 28 -
trunk/Source/WebCore/ChangeLog
r99988 r99992 1 2011-11-11 Rafael Weinstein <rafaelw@chromium.org> 2 3 [MutationObservers] Support attributeFilter for attribute mutations 4 https://bugs.webkit.org/show_bug.cgi?id=70860 5 6 Reviewed by Dimitri Glazkov. 7 8 This patch adds an attributeFilter to the MutationObserverRegistration and 9 adds support for only observing attributes whose name are in the provided 10 filter set (array of strings). 11 12 Test: fast/mutation/observe-attributes.html. 13 14 * bindings/js/JSWebKitMutationObserverCustom.cpp: 15 (WebCore::JSWebKitMutationObserver::observe): 16 * bindings/v8/OptionsObject.cpp: 17 (WebCore::OptionsObject::get): 18 * bindings/v8/OptionsObject.h: 19 * bindings/v8/custom/V8WebKitMutationObserverCustom.cpp: 20 (WebCore::V8WebKitMutationObserver::observeCallback): 21 * dom/Element.cpp: 22 (WebCore::enqueueAttributesMutationRecord): 23 * dom/MutationObserverRegistration.cpp: 24 (WebCore::MutationObserverRegistration::resetObservation): 25 (WebCore::MutationObserverRegistration::shouldReceiveMutationFrom): 26 (WebCore::MutationObserverRegistration::caseInsensitiveAttributeFilter): 27 * dom/MutationObserverRegistration.h: 28 * dom/Node.cpp: 29 (WebCore::Node::collectMatchingObserversForMutation): 30 (WebCore::Node::getRegisteredMutationObserversOfType): 31 * dom/Node.h: 32 * dom/WebKitMutationObserver.cpp: 33 (WebCore::WebKitMutationObserver::observe): 34 * dom/WebKitMutationObserver.h: 35 1 36 2011-11-11 Vsevolod Vlasov <vsevik@chromium.org> 2 37 -
trunk/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp
r99611 r99992 79 79 JSDictionary dictionary(exec, optionsObject); 80 80 MutationObserverOptions options = 0; 81 // FIXME: Add support for parsing of the attributeFilter option. 81 82 bool option; 82 83 if (dictionary.tryGetProperty("childList", option) && option) -
trunk/Source/WebCore/bindings/v8/OptionsObject.cpp
r99261 r99992 216 216 } 217 217 218 bool OptionsObject::get(const String& key, HashSet<AtomicString>& value) const 219 { 220 v8::Local<v8::Value> v8Value; 221 if (!getKey(key, v8Value)) 222 return false; 223 224 // FIXME: Support array-like objects 225 if (!v8Value->IsArray()) 226 return false; 227 228 v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value); 229 for (size_t i = 0; i < v8Array->Length(); ++i) { 230 v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Integer::New(i)); 231 value.add(v8ValueToWebCoreString(indexedValue)); 232 } 233 234 return true; 235 } 236 218 237 bool OptionsObject::getWithUndefinedOrNullCheck(const String& key, String& value) const 219 238 { -
trunk/Source/WebCore/bindings/v8/OptionsObject.h
r99261 r99992 31 31 #include "ScriptValue.h" 32 32 #include <v8.h> 33 #include <wtf/HashSet.h> 34 #include <wtf/text/AtomicString.h> 33 35 34 36 namespace WebCore { … … 62 64 bool get(const String&, RefPtr<TrackBase>&) const; 63 65 #endif 66 bool get(const String&, HashSet<AtomicString>&) const; 64 67 65 68 bool getWithUndefinedOrNullCheck(const String&, String&) const; -
trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp
r99611 r99992 44 44 #include "V8Proxy.h" 45 45 #include "V8Utilities.h" 46 #include "WebKitMutationObserver.h" 47 48 #include <wtf/HashSet.h> 49 #include <wtf/text/AtomicString.h> 46 50 47 51 namespace WebCore { … … 90 94 OptionsObject optionsObject(args[1]); 91 95 unsigned options = 0; 96 HashSet<AtomicString> attributeFilter; 92 97 bool option; 93 98 if (optionsObject.get("childList", option) && option) … … 95 100 if (optionsObject.get("attributes", option) && option) 96 101 options |= WebKitMutationObserver::Attributes; 102 if (optionsObject.get("attributeFilter", attributeFilter)) 103 options |= WebKitMutationObserver::AttributeFilter; 97 104 if (optionsObject.get("characterData", option) && option) 98 105 options |= WebKitMutationObserver::CharacterData; … … 105 112 106 113 ExceptionCode ec = 0; 107 imp->observe(target, options, ec);114 imp->observe(target, options, attributeFilter, ec); 108 115 if (ec) 109 116 V8Proxy::setDOMException(ec); -
trunk/Source/WebCore/dom/Element.cpp
r99778 r99992 635 635 { 636 636 HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions> observers; 637 element->getRegisteredMutationObserversOfType(observers, WebKitMutationObserver::Attributes );637 element->getRegisteredMutationObserversOfType(observers, WebKitMutationObserver::Attributes, name.localName()); 638 638 if (observers.isEmpty()) 639 639 return; -
trunk/Source/WebCore/dom/MutationObserverRegistration.cpp
r99338 r99992 59 59 } 60 60 61 void MutationObserverRegistration::resetObservation(MutationObserverOptions options )61 void MutationObserverRegistration::resetObservation(MutationObserverOptions options, const HashSet<AtomicString>& attributeFilter) 62 62 { 63 63 clearTransientRegistrations(); 64 64 m_options = options; 65 m_attributeFilter = attributeFilter; 66 m_caseInsensitiveAttributeFilter.clear(); 65 67 } 66 68 67 69 void MutationObserverRegistration::observedSubtreeNodeWillDetach(PassRefPtr<Node> node) 68 70 { 69 if (! (m_options & WebKitMutationObserver::Subtree))71 if (!isSubtree()) 70 72 return; 71 73 … … 103 105 } 104 106 105 bool MutationObserverRegistration::shouldReceiveMutationFrom(Node* node, WebKitMutationObserver::MutationType type )107 bool MutationObserverRegistration::shouldReceiveMutationFrom(Node* node, WebKitMutationObserver::MutationType type, const AtomicString& attributeName) 106 108 { 107 109 if (!(m_options & type)) 108 110 return false; 109 111 110 if (m_registrationNode != node && ! (m_options & WebKitMutationObserver::Subtree))112 if (m_registrationNode != node && !isSubtree()) 111 113 return false; 112 114 113 return true; 115 if (type != WebKitMutationObserver::Attributes || !(m_options & WebKitMutationObserver::AttributeFilter)) 116 return true; 117 118 if (m_attributeFilter.contains(attributeName)) 119 return true; 120 121 if (node->document()->isHTMLDocument() && node->isHTMLElement()) 122 return caseInsensitiveAttributeFilter().contains(attributeName); 123 124 return false; 125 } 126 127 const HashSet<AtomicString>& MutationObserverRegistration::caseInsensitiveAttributeFilter() 128 { 129 if (m_caseInsensitiveAttributeFilter) 130 return *m_caseInsensitiveAttributeFilter; 131 132 m_caseInsensitiveAttributeFilter = adoptPtr(new HashSet<AtomicString>()); 133 for (HashSet<AtomicString>::const_iterator iter = m_attributeFilter.begin(); iter != m_attributeFilter.end(); ++iter) { 134 AtomicString attributeNameLower = iter->lower(); 135 if ((*iter) != attributeNameLower) 136 m_caseInsensitiveAttributeFilter->add(attributeNameLower); 137 } 138 139 return *m_caseInsensitiveAttributeFilter; 114 140 } 115 141 -
trunk/Source/WebCore/dom/MutationObserverRegistration.h
r99593 r99992 48 48 ~MutationObserverRegistration(); 49 49 50 void resetObservation(MutationObserverOptions );50 void resetObservation(MutationObserverOptions, const HashSet<AtomicString>& attributeFilter); 51 51 void observedSubtreeNodeWillDetach(PassRefPtr<Node>); 52 52 void clearTransientRegistrations(); 53 53 void unregister(); 54 54 55 bool shouldReceiveMutationFrom(Node*, WebKitMutationObserver::MutationType );56 bool i sSubtree() const { return m_options & WebKitMutationObserver::Subtree; }55 bool shouldReceiveMutationFrom(Node*, WebKitMutationObserver::MutationType, const AtomicString& attributeName); 56 bool inline isSubtree() const { return m_options & WebKitMutationObserver::Subtree; } 57 57 58 58 WebKitMutationObserver* observer() { return m_observer.get(); } … … 63 63 MutationObserverRegistration(PassRefPtr<WebKitMutationObserver>, Node*); 64 64 65 const HashSet<AtomicString>& caseInsensitiveAttributeFilter(); 66 65 67 RefPtr<WebKitMutationObserver> m_observer; 66 68 Node* m_registrationNode; … … 70 72 71 73 MutationObserverOptions m_options; 74 HashSet<AtomicString> m_attributeFilter; 75 OwnPtr<HashSet<AtomicString> > m_caseInsensitiveAttributeFilter; 72 76 }; 73 77 -
trunk/Source/WebCore/dom/Node.cpp
r99593 r99992 2722 2722 } 2723 2723 2724 void Node::collectMatchingObserversForMutation(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>& observers, Node* fromNode, WebKitMutationObserver::MutationType type )2724 void Node::collectMatchingObserversForMutation(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>& observers, Node* fromNode, WebKitMutationObserver::MutationType type, const AtomicString& attributeName) 2725 2725 { 2726 2726 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = fromNode->mutationObserverRegistry()) { … … 2728 2728 for (size_t i = 0; i < size; ++i) { 2729 2729 MutationObserverRegistration* registration = registry->at(i).get(); 2730 if (registration->shouldReceiveMutationFrom(this, type )) {2730 if (registration->shouldReceiveMutationFrom(this, type, attributeName)) { 2731 2731 MutationRecordDeliveryOptions deliveryOptions = registration->deliveryOptions(); 2732 2732 pair<HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>::iterator, bool> result = observers.add(registration->observer(), deliveryOptions); … … 2741 2741 for (HashSet<MutationObserverRegistration*>::iterator iter = transientRegistry->begin(); iter != transientRegistry->end(); ++iter) { 2742 2742 MutationObserverRegistration* registration = *iter; 2743 if (registration->shouldReceiveMutationFrom(this, type )) {2743 if (registration->shouldReceiveMutationFrom(this, type, attributeName)) { 2744 2744 MutationRecordDeliveryOptions deliveryOptions = registration->deliveryOptions(); 2745 2745 pair<HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>::iterator, bool> result = observers.add(registration->observer(), deliveryOptions); … … 2751 2751 } 2752 2752 2753 void Node::getRegisteredMutationObserversOfType(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>& observers, WebKitMutationObserver::MutationType type )2754 { 2755 collectMatchingObserversForMutation(observers, this, type );2753 void Node::getRegisteredMutationObserversOfType(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>& observers, WebKitMutationObserver::MutationType type, const AtomicString& attributeName) 2754 { 2755 collectMatchingObserversForMutation(observers, this, type, attributeName); 2756 2756 2757 2757 if (!document()->hasSubtreeMutationObserverOfType(type)) … … 2759 2759 2760 2760 for (Node* node = parentNode(); node; node = node->parentNode()) 2761 collectMatchingObserversForMutation(observers, node, type );2761 collectMatchingObserversForMutation(observers, node, type, attributeName); 2762 2762 } 2763 2763 -
trunk/Source/WebCore/dom/Node.h
r99484 r99992 590 590 591 591 #if ENABLE(MUTATION_OBSERVERS) 592 void getRegisteredMutationObserversOfType(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>&, WebKitMutationObserver::MutationType );592 void getRegisteredMutationObserversOfType(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>&, WebKitMutationObserver::MutationType, const AtomicString& attributeName = nullAtom); 593 593 MutationObserverRegistration* registerMutationObserver(PassRefPtr<WebKitMutationObserver>); 594 594 void unregisterMutationObserver(MutationObserverRegistration*); … … 724 724 Vector<OwnPtr<MutationObserverRegistration> >* mutationObserverRegistry(); 725 725 HashSet<MutationObserverRegistration*>* transientMutationObserverRegistry(); 726 void collectMatchingObserversForMutation(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>&, Node* fromNode, WebKitMutationObserver::MutationType );726 void collectMatchingObserversForMutation(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>&, Node* fromNode, WebKitMutationObserver::MutationType, const AtomicString& attributeName); 727 727 #endif 728 728 -
trunk/Source/WebCore/dom/WebKitMutationObserver.cpp
r99611 r99992 64 64 return (options & (Attributes | CharacterData | ChildList)) 65 65 && ((options & Attributes) || !(options & AttributeOldValue)) 66 // FIXME: Uncomment the line below once attributeFilter is supported. 67 // && ((options & Attributes) || !(options & AttributeFilter)) 66 && ((options & Attributes) || !(options & AttributeFilter)) 68 67 && ((options & CharacterData) || !(options & CharacterDataOldValue)); 69 68 } 70 69 71 void WebKitMutationObserver::observe(Node* node, MutationObserverOptions options, ExceptionCode& ec)70 void WebKitMutationObserver::observe(Node* node, MutationObserverOptions options, const HashSet<AtomicString>& attributeFilter, ExceptionCode& ec) 72 71 { 73 72 if (!node) { … … 83 82 84 83 MutationObserverRegistration* registration = node->registerMutationObserver(this); 85 registration->resetObservation(options );84 registration->resetObservation(options, attributeFilter); 86 85 87 86 if (registration->isSubtree()) -
trunk/Source/WebCore/dom/WebKitMutationObserver.h
r99645 r99992 78 78 ~WebKitMutationObserver(); 79 79 80 void observe(Node*, MutationObserverOptions, ExceptionCode&);80 void observe(Node*, MutationObserverOptions, const HashSet<AtomicString>& attributeFilter, ExceptionCode&); 81 81 void disconnect(); 82 82 void observationStarted(MutationObserverRegistration*);
Note: See TracChangeset
for help on using the changeset viewer.