[MutationObservers] attributeFilter should be case sensitive at all times
authorrafaelw@chromium.org <rafaelw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Mar 2012 00:58:06 +0000 (00:58 +0000)
committerrafaelw@chromium.org <rafaelw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Mar 2012 00:58:06 +0000 (00:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81822

Reviewed by Ryosuke Niwa.

Source/WebCore:

This removes the behavior in MutationObserverRegistration which treats
attributeFilter as case insensitive for HTML elements in HTML documents.

Relevant tests have been updated.

* dom/MutationObserverRegistration.cpp:
(WebCore::MutationObserverRegistration::resetObservation):
(WebCore::MutationObserverRegistration::shouldReceiveMutationFrom):
* dom/MutationObserverRegistration.h:
(MutationObserverRegistration):

LayoutTests:

* fast/mutation/observe-attributes-expected.txt:
* fast/mutation/observe-attributes.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111950 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/mutation/observe-attributes-expected.txt
LayoutTests/fast/mutation/observe-attributes.html
Source/WebCore/ChangeLog
Source/WebCore/dom/MutationObserverRegistration.cpp
Source/WebCore/dom/MutationObserverRegistration.h

index 228ba2fcbfa378517898c469ede9d1b6a72bc0c8..9aa3d1ac6469b80b8fdc1598f2407424baf5f7ca 100644 (file)
@@ -1,3 +1,13 @@
+2012-03-23  Rafael Weinstein  <rafaelw@chromium.org>
+
+        [MutationObservers] attributeFilter should be case sensitive at all times
+        https://bugs.webkit.org/show_bug.cgi?id=81822
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/mutation/observe-attributes-expected.txt:
+        * fast/mutation/observe-attributes.html:
+
 2012-03-23  Parag Radke  <parag@motorola.com>
 
         REGRESSION: can select text of an input button
index 83eb7bae2d320a823dbf50fb321e8f4e40a7d1a3..1736d221781bcd705c3dd002582851336a16bd66 100644 (file)
@@ -101,18 +101,15 @@ PASS mutations[2].type is "attributes"
 PASS mutations[2].attributeName is "id"
 PASS mutations[2].oldValue is "bar"
 
-Testing that attributeFilter works as expected and ignores case with HTML elements.
-...only foo, bar & boom should be received.
-PASS mutations.length is 3
+Testing that attributeFilter works as expected and observes case with HTML elements.
+...only foo and bar should be received.
+PASS mutations.length is 2
 PASS mutations[0].type is "attributes"
 PASS mutations[0].attributeName is "foo"
 PASS mutations[0].attributeNamespace is null
 PASS mutations[1].type is "attributes"
 PASS mutations[1].attributeName is "bar"
 PASS mutations[1].attributeNamespace is null
-PASS mutations[2].type is "attributes"
-PASS mutations[2].attributeName is "boom"
-PASS mutations[2].attributeNamespace is null
 
 Testing the behavior of attributeFilter when the same observer observes at multiple nodes in a subtree with different filter options.
 ...only foo, bar & bat should be received.
index 867c4b35ac8037042789d97f2ec5fc80fd56b5bc..f8d32c6473d5eb4a148402b95556e55f71bd9e9e 100644 (file)
@@ -451,7 +451,7 @@ function testAttributeFilter() {
     var observer;
 
     function start() {
-        debug('Testing that attributeFilter works as expected and ignores case with HTML elements.');
+        debug('Testing that attributeFilter works as expected and observes case with HTML elements.');
 
         mutations = null;
         observer = new WebKitMutationObserver(function(m) {
@@ -469,18 +469,15 @@ function testAttributeFilter() {
     }
 
     function finish() {
-        debug('...only foo, bar & boom should be received.');
+        debug('...only foo and bar should be received.');
 
-        shouldBe('mutations.length', '3');
+        shouldBe('mutations.length', '2');
         shouldBe('mutations[0].type', '"attributes"');
         shouldBe('mutations[0].attributeName', '"foo"');
         shouldBe('mutations[0].attributeNamespace', 'null');
         shouldBe('mutations[1].type', '"attributes"');
         shouldBe('mutations[1].attributeName', '"bar"');
         shouldBe('mutations[1].attributeNamespace', 'null');
-        shouldBe('mutations[2].type', '"attributes"');
-        shouldBe('mutations[2].attributeName', '"boom"');
-        shouldBe('mutations[2].attributeNamespace', 'null');
         observer.disconnect();
         debug('');
         runNextTest();
index af78dc60430b7bc4ca39898fd75aaddd8ae567cc..7dca8c5d5570baf314fceddf804d71a8cea46dfc 100644 (file)
@@ -1,3 +1,21 @@
+2012-03-23  Rafael Weinstein  <rafaelw@chromium.org>
+
+        [MutationObservers] attributeFilter should be case sensitive at all times
+        https://bugs.webkit.org/show_bug.cgi?id=81822
+
+        Reviewed by Ryosuke Niwa.
+
+        This removes the behavior in MutationObserverRegistration which treats
+        attributeFilter as case insensitive for HTML elements in HTML documents.
+
+        Relevant tests have been updated.
+
+        * dom/MutationObserverRegistration.cpp:
+        (WebCore::MutationObserverRegistration::resetObservation):
+        (WebCore::MutationObserverRegistration::shouldReceiveMutationFrom):
+        * dom/MutationObserverRegistration.h:
+        (MutationObserverRegistration):
+
 2012-03-23  Kentaro Hara  <haraken@chromium.org>
 
         Move WebSocket APIs from WorkerContext.idl to WorkerContextWebSocket.idl
index b8eb59487470aa89cae94f5c69bb0d2a75a29414..9bd61c99710db856f83992fdee661ef9d07273ad 100644 (file)
@@ -63,7 +63,6 @@ void MutationObserverRegistration::resetObservation(MutationObserverOptions opti
     clearTransientRegistrations();
     m_options = options;
     m_attributeFilter = attributeFilter;
-    m_caseInsensitiveAttributeFilter.clear();
 }
 
 void MutationObserverRegistration::observedSubtreeNodeWillDetach(PassRefPtr<Node> node)
@@ -115,28 +114,7 @@ bool MutationObserverRegistration::shouldReceiveMutationFrom(Node* node, WebKitM
     if (type != WebKitMutationObserver::Attributes || !(m_options & WebKitMutationObserver::AttributeFilter))
         return true;
 
-    if (m_attributeFilter.contains(attributeName))
-        return true;
-
-    if (node->document()->isHTMLDocument() && node->isHTMLElement())
-        return caseInsensitiveAttributeFilter().contains(attributeName);
-
-    return false;
-}
-
-const HashSet<AtomicString>& MutationObserverRegistration::caseInsensitiveAttributeFilter()
-{
-    if (m_caseInsensitiveAttributeFilter)
-        return *m_caseInsensitiveAttributeFilter;
-
-    m_caseInsensitiveAttributeFilter = adoptPtr(new HashSet<AtomicString>());
-    for (HashSet<AtomicString>::const_iterator iter = m_attributeFilter.begin(); iter != m_attributeFilter.end(); ++iter) {
-        AtomicString attributeNameLower = iter->lower();
-        if ((*iter) != attributeNameLower)
-             m_caseInsensitiveAttributeFilter->add(attributeNameLower);
-    }
-
-    return *m_caseInsensitiveAttributeFilter;
+    return m_attributeFilter.contains(attributeName);
 }
 
 } // namespace WebCore
index 6362e6aafeaf6478766964b483a615cdee672469..bc3236d8d644d5986817c088fd4ca26cef7bfcd3 100644 (file)
@@ -72,7 +72,6 @@ private:
 
     MutationObserverOptions m_options;
     HashSet<AtomicString> m_attributeFilter;
-    OwnPtr<HashSet<AtomicString> > m_caseInsensitiveAttributeFilter;
 };
 
 } // namespace WebCore