Diff
Modified: trunk/LayoutTests/ChangeLog (102099 => 102100)
--- trunk/LayoutTests/ChangeLog 2011-12-06 07:24:07 UTC (rev 102099)
+++ trunk/LayoutTests/ChangeLog 2011-12-06 07:37:07 UTC (rev 102100)
@@ -1,3 +1,13 @@
+2011-12-05 Rafael Weinstein <[email protected]>
+
+ [MutationObservers] Support 'attributes' mutation records for element.removeAttribute
+ https://bugs.webkit.org/show_bug.cgi?id=73880
+
+ Reviewed by Ojan Vafai.
+
+ * fast/mutation/observe-attributes-expected.txt:
+ * fast/mutation/observe-attributes.html:
+
2011-12-05 Florin Malita <[email protected]>
Heap-buffer-overflow in WebCore::HTMLTreeBuilder::processEndTag
Modified: trunk/LayoutTests/fast/mutation/observe-attributes-expected.txt (102099 => 102100)
--- trunk/LayoutTests/fast/mutation/observe-attributes-expected.txt 2011-12-06 07:24:07 UTC (rev 102099)
+++ trunk/LayoutTests/fast/mutation/observe-attributes-expected.txt 2011-12-06 07:37:07 UTC (rev 102100)
@@ -5,10 +5,13 @@
Testing basic aspects of attribute observation.
...can attribute changes be observed at all
-PASS mutations.length is 1
+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
...observer.disconnect() should prevent further delivery of mutations.
PASS mutations is null
...re-observing after disconnect works with the same observer.
@@ -59,13 +62,16 @@
PASS mutations[1].attributeName is "baz"
Testing basic oldValue delivery.
-PASS mutations.length is 2
+PASS mutations.length is 3
PASS mutations[0].type is "attributes"
PASS mutations[0].attributeName is "foo"
PASS mutations[0].oldValue is null
PASS mutations[1].type is "attributes"
PASS mutations[1].attributeName is "foo"
PASS mutations[1].oldValue is "bar"
+PASS mutations[2].type is "attributes"
+PASS mutations[2].attributeName is "bar"
+PASS mutations[2].oldValue is "boo"
Testing that oldValue is delivered as requested (or not).
PASS mutationsWithOldValue.length is 1
Modified: trunk/LayoutTests/fast/mutation/observe-attributes.html (102099 => 102100)
--- trunk/LayoutTests/fast/mutation/observe-attributes.html 2011-12-06 07:24:07 UTC (rev 102099)
+++ trunk/LayoutTests/fast/mutation/observe-attributes.html 2011-12-06 07:37:07 UTC (rev 102100)
@@ -22,22 +22,28 @@
mutations = null;
div = document.createElement('div');
+ div.setAttribute('bar', 'foo');
+
observer = new WebKitMutationObserver(function(m) {
mutations = m;
});
observer.observe(div, { attributes: true, characterData: true });
div.setAttribute('foo', 'bar');
+ div.removeAttribute('bar');
setTimeout(checkDisconnectAndMutate, 0);
}
function checkDisconnectAndMutate() {
debug('...can attribute changes be observed at all');
- shouldBe('mutations.length', '1');
+ 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');
mutations = null;
observer.disconnect();
@@ -303,23 +309,30 @@
debug('Testing basic oldValue delivery.');
mutations = null;
div = document.createElement('div');
+ div.setAttribute('bar', 'boo');
+
observer = new WebKitMutationObserver(function(mutations) {
window.mutations = mutations;
});
observer.observe(div, { attributes: true, attributeOldValue: true });
div.setAttribute('foo', 'bar');
div.setAttribute('foo', 'baz');
+ div.removeAttribute('bar');
+ div.removeAttribute('non-existant');
setTimeout(finish, 0);
}
function finish() {
- shouldBe('mutations.length', '2');
+ shouldBe('mutations.length', '3');
shouldBe('mutations[0].type', '"attributes"');
shouldBe('mutations[0].attributeName', '"foo"');
shouldBe('mutations[0].oldValue', 'null');
shouldBe('mutations[1].type', '"attributes"');
shouldBe('mutations[1].attributeName', '"foo"');
shouldBe('mutations[1].oldValue', '"bar"');
+ shouldBe('mutations[2].type', '"attributes"');
+ shouldBe('mutations[2].attributeName', '"bar"');
+ shouldBe('mutations[2].oldValue', '"boo"');
observer.disconnect();
debug('');
runNextTest();
Modified: trunk/Source/WebCore/ChangeLog (102099 => 102100)
--- trunk/Source/WebCore/ChangeLog 2011-12-06 07:24:07 UTC (rev 102099)
+++ trunk/Source/WebCore/ChangeLog 2011-12-06 07:37:07 UTC (rev 102100)
@@ -1,3 +1,14 @@
+2011-12-05 Rafael Weinstein <[email protected]>
+
+ [MutationObservers] Support 'attributes' mutation records for element.removeAttribute
+ https://bugs.webkit.org/show_bug.cgi?id=73880
+
+ Reviewed by Ojan Vafai.
+
+ * dom/Element.cpp:
+ (WebCore::enqueueAttributesMutationRecord):
+ (WebCore::Element::removeAttribute):
+
2011-12-05 Dana Jansens <[email protected]>
Set opaque flag for WebGLLayerChromium
Modified: trunk/Source/WebCore/dom/Element.cpp (102099 => 102100)
--- trunk/Source/WebCore/dom/Element.cpp 2011-12-06 07:24:07 UTC (rev 102099)
+++ trunk/Source/WebCore/dom/Element.cpp 2011-12-06 07:37:07 UTC (rev 102100)
@@ -180,13 +180,25 @@
{
}
+#if ENABLE(MUTATION_OBSERVERS)
+static void enqueueAttributesMutationRecord(Element* target, const QualifiedName& attributeName, const AtomicString& oldValue)
+{
+ OwnPtr<MutationObserverInterestGroup> mutationRecipients = MutationObserverInterestGroup::createForAttributesMutation(target, attributeName);
+ mutationRecipients->enqueueMutationRecord(MutationRecord::createAttributes(target, attributeName, oldValue));
+}
+#endif
+
void Element::removeAttribute(const QualifiedName& name, ExceptionCode& ec)
{
if (m_attributeMap) {
ec = 0;
- m_attributeMap->removeNamedItem(name, ec);
+ RefPtr<Node> attrNode = m_attributeMap->removeNamedItem(name, ec);
if (ec == NOT_FOUND_ERR)
ec = 0;
+#if ENABLE(MUTATION_OBSERVERS)
+ else
+ enqueueAttributesMutationRecord(this, name, attrNode->nodeValue());
+#endif
}
}
@@ -616,14 +628,6 @@
return getAttribute(QualifiedName(nullAtom, localName, namespaceURI));
}
-#if ENABLE(MUTATION_OBSERVERS)
-static void enqueueAttributesMutationRecord(Element* target, const QualifiedName& attributeName, const AtomicString& oldValue)
-{
- OwnPtr<MutationObserverInterestGroup> mutationRecipients = MutationObserverInterestGroup::createForAttributesMutation(target, attributeName);
- mutationRecipients->enqueueMutationRecord(MutationRecord::createAttributes(target, attributeName, oldValue));
-}
-#endif
-
void Element::setAttribute(const AtomicString& name, const AtomicString& value, ExceptionCode& ec)
{
if (!Document::isValidName(name)) {
@@ -1542,9 +1546,13 @@
if (m_attributeMap) {
ec = 0;
- m_attributeMap->removeNamedItem(localName, ec);
+ RefPtr<Node> attrNode = m_attributeMap->removeNamedItem(localName, ec);
if (ec == NOT_FOUND_ERR)
ec = 0;
+#if ENABLE(MUTATION_OBSERVERS)
+ else
+ enqueueAttributesMutationRecord(this, QualifiedName(nullAtom, localName, nullAtom), attrNode->nodeValue());
+#endif
}
InspectorInstrumentation::didRemoveDOMAttr(document(), this, name);