Diff
Modified: trunk/LayoutTests/ChangeLog (102510 => 102511)
--- trunk/LayoutTests/ChangeLog 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/LayoutTests/ChangeLog 2011-12-10 02:29:51 UTC (rev 102511)
@@ -1,3 +1,13 @@
+2011-12-09 Arko Saha <[email protected]>
+
+ NameNodeListCache should be invalidated when name attribute changes/modified.
+ https://bugs.webkit.org/show_bug.cgi?id=70810
+
+ Reviewed by Ryosuke Niwa.
+
+ * fast/dom/getelementsbyname-invalidation-cache-expected.txt: Added.
+ * fast/dom/getelementsbyname-invalidation-cache.html: Added.
+
2011-12-09 David Levin <[email protected]>
REGRESSION (r97496-r97499): 6 fast/workers tests failing on SnowLeopard Intel Release (Tests)
Added: trunk/LayoutTests/fast/dom/getelementsbyname-invalidation-cache-expected.txt (0 => 102511)
--- trunk/LayoutTests/fast/dom/getelementsbyname-invalidation-cache-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/getelementsbyname-invalidation-cache-expected.txt 2011-12-10 02:29:51 UTC (rev 102511)
@@ -0,0 +1,42 @@
+This test case ensures that nameNodeListCache should be invalidate when name attribute changes.
+
+PASS createTwoElements('a'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('a').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS createTwoElements('applet'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('applet').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS createTwoElements('embed'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('embed').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS createTwoElements('section'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('section').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS createTwoElements('frame'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('frame').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS createTwoElements('form'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('form').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS createTwoElements('iframe'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('iframe').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS createTwoElements('img'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('img').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS createTwoElements('map'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('map').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS createTwoElements('meta'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('meta').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS createTwoElements('object'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('object').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS createTwoElements('param'); document.getElementsByName('fullname').length is 2
+PASS document.querySelector('param').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length is 1
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/getelementsbyname-invalidation-cache.html (0 => 102511)
--- trunk/LayoutTests/fast/dom/getelementsbyname-invalidation-cache.html (rev 0)
+++ trunk/LayoutTests/fast/dom/getelementsbyname-invalidation-cache.html 2011-12-10 02:29:51 UTC (rev 102511)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<p>This test case ensures that nameNodeListCache should be invalidate when name attribute changes.</p>
+<div id="console"></div>
+<script>
+var element1;
+var element2;
+
+function createElement(type, properties)
+{
+ var element = document.createElement(type);
+
+ for (var i in properties)
+ if (properties.hasOwnProperty(i))
+ element.setAttribute(i,properties[i]);
+
+ document.body.appendChild(element);
+ return element;
+}
+
+function createTwoElements(tagName)
+{
+ element1 = createElement(tagName, {name: 'fullname'});
+ element2 = createElement(tagName, {name: 'fullname'});
+}
+
+function runTest(tagName)
+{
+ shouldBe("createTwoElements('" + tagName + "'); document.getElementsByName('fullname').length", "2");
+ shouldBe("document.querySelector('" + tagName + "').setAttribute('name', 'changed-name'); document.getElementsByName('fullname').length", "1");
+ document.body.removeChild(element1);
+ document.body.removeChild(element2);
+ debug('');
+}
+
+runTest('a');
+runTest('applet');
+runTest('embed');
+runTest('section');
+runTest('frame');
+runTest('form');
+runTest('iframe');
+runTest('img');
+runTest('map');
+runTest('meta');
+runTest('object');
+runTest('param');
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (102510 => 102511)
--- trunk/Source/WebCore/ChangeLog 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/ChangeLog 2011-12-10 02:29:51 UTC (rev 102511)
@@ -1,3 +1,37 @@
+2011-12-09 Arko Saha <[email protected]>
+
+ NameNodeListCache should be invalidated when name attribute changes/modified.
+ https://bugs.webkit.org/show_bug.cgi?id=70810
+
+ Reviewed by Ryosuke Niwa.
+
+ Test: fast/dom/getelementsbyname-invalidation-cache.html
+
+ * html/HTMLAnchorElement.cpp:
+ (WebCore::HTMLAnchorElement::parseMappedAttribute):
+ * html/HTMLAppletElement.cpp:
+ (WebCore::HTMLAppletElement::parseMappedAttribute):
+ * html/HTMLElement.cpp:
+ (WebCore::HTMLElement::parseMappedAttribute):
+ * html/HTMLEmbedElement.cpp:
+ (WebCore::HTMLEmbedElement::parseMappedAttribute):
+ * html/HTMLFormElement.cpp:
+ (WebCore::HTMLFormElement::parseMappedAttribute):
+ * html/HTMLFrameElementBase.cpp:
+ (WebCore::HTMLFrameElementBase::parseMappedAttribute):
+ * html/HTMLIFrameElement.cpp:
+ (WebCore::HTMLIFrameElement::parseMappedAttribute):
+ * html/HTMLImageElement.cpp:
+ (WebCore::HTMLImageElement::parseMappedAttribute):
+ * html/HTMLMapElement.cpp:
+ (WebCore::HTMLMapElement::parseMappedAttribute):
+ * html/HTMLMetaElement.cpp:
+ (WebCore::HTMLMetaElement::parseMappedAttribute):
+ * html/HTMLObjectElement.cpp:
+ (WebCore::HTMLObjectElement::parseMappedAttribute):
+ * html/HTMLParamElement.cpp:
+ (WebCore::HTMLParamElement::parseMappedAttribute):
+
2011-12-09 Anders Carlsson <[email protected]>
Fix Lion release build.
Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -221,8 +221,9 @@
attr->setValue(nullAtom);
}
}
- } else if (attr->name() == nameAttr ||
- attr->name() == titleAttr) {
+ } else if (attr->name() == nameAttr) {
+ invalidateNodeListsCacheAfterAttributeChanged();
+ } else if (attr->name() == titleAttr) {
// Do nothing.
} else if (attr->name() == relAttr)
setRel(attr->value());
Modified: trunk/Source/WebCore/html/HTMLAppletElement.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLAppletElement.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLAppletElement.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -64,6 +64,7 @@
document->addNamedItem(newName);
}
m_name = newName;
+ invalidateNodeListsCacheAfterAttributeChanged();
} else if (isIdAttributeName(attr->name())) {
const AtomicString& newId = attr->value();
if (inDocument() && document()->isHTMLDocument()) {
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -210,6 +210,8 @@
addCSSProperty(attr, CSSPropertyWebkitUserSelect, CSSValueNone);
} else if (equalIgnoringCase(value, "false"))
addCSSProperty(attr, CSSPropertyWebkitUserDrag, CSSValueNone);
+ } else if (attr->name() == nameAttr) {
+ invalidateNodeListsCacheAfterAttributeChanged();
#if ENABLE(MICRODATA)
} else if (attr->name() == itempropAttr) {
setItemProp(attr->value());
Modified: trunk/Source/WebCore/html/HTMLEmbedElement.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLEmbedElement.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLEmbedElement.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -118,6 +118,7 @@
document->addNamedItem(value);
}
m_name = value;
+ invalidateNodeListsCacheAfterAttributeChanged();
} else
HTMLPlugInImageElement::parseMappedAttribute(attr);
}
Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLFormElement.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -392,6 +392,7 @@
document->addNamedItem(newName);
}
m_name = newName;
+ invalidateNodeListsCacheAfterAttributeChanged();
} else
HTMLElement::parseMappedAttribute(attr);
}
Modified: trunk/Source/WebCore/html/HTMLFrameElementBase.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLFrameElementBase.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLFrameElementBase.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -141,6 +141,7 @@
m_frameName = attr->value();
} else if (attr->name() == nameAttr) {
m_frameName = attr->value();
+ invalidateNodeListsCacheAfterAttributeChanged();
// FIXME: If we are already attached, this doesn't actually change the frame's name.
// FIXME: If we are already attached, this doesn't check for frame name
// conflicts and generate a unique frame name.
Modified: trunk/Source/WebCore/html/HTMLIFrameElement.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLIFrameElement.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLIFrameElement.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -84,6 +84,7 @@
document->addExtraNamedItem(newName);
}
m_name = newName;
+ invalidateNodeListsCacheAfterAttributeChanged();
} else if (attr->name() == frameborderAttr) {
// Frame border doesn't really match the HTML4 spec definition for iframes. It simply adds
// a presentational hint that the border should be off if set to zero.
Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLImageElement.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -141,6 +141,7 @@
document->addNamedItem(newName);
}
m_name = newName;
+ invalidateNodeListsCacheAfterAttributeChanged();
} else if (isIdAttributeName(attr->name())) {
const AtomicString& newId = attr->value();
if (inDocument() && document()->isHTMLDocument()) {
Modified: trunk/Source/WebCore/html/HTMLMapElement.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLMapElement.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLMapElement.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -119,6 +119,9 @@
m_name = document()->isHTMLDocument() ? mapName.lower() : mapName;
if (inDocument())
treeScope()->addImageMap(this);
+
+ if (attrName == nameAttr)
+ invalidateNodeListsCacheAfterAttributeChanged();
return;
}
Modified: trunk/Source/WebCore/html/HTMLMetaElement.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLMetaElement.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLMetaElement.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -49,7 +49,7 @@
else if (attr->name() == contentAttr)
process();
else if (attr->name() == nameAttr) {
- // Do nothing.
+ invalidateNodeListsCacheAfterAttributeChanged();
} else
HTMLElement::parseMappedAttribute(attr);
}
Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLObjectElement.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -122,6 +122,7 @@
document->addNamedItem(newName);
}
m_name = newName;
+ invalidateNodeListsCacheAfterAttributeChanged();
} else if (attr->name() == borderAttr)
applyBorderAttribute(attr);
else if (isIdAttributeName(attr->name())) {
Modified: trunk/Source/WebCore/html/HTMLParamElement.cpp (102510 => 102511)
--- trunk/Source/WebCore/html/HTMLParamElement.cpp 2011-12-10 02:26:41 UTC (rev 102510)
+++ trunk/Source/WebCore/html/HTMLParamElement.cpp 2011-12-10 02:29:51 UTC (rev 102511)
@@ -57,6 +57,7 @@
m_name = attr->value();
} else if (attr->name() == nameAttr) {
m_name = attr->value();
+ invalidateNodeListsCacheAfterAttributeChanged();
} else if (attr->name() == valueAttr) {
m_value = attr->value();
} else