Title: [203731] trunk
Revision
203731
Author
[email protected]
Date
2016-07-26 12:09:53 -0700 (Tue, 26 Jul 2016)

Log Message

Align NamedNodeMap with the specification
https://bugs.webkit.org/show_bug.cgi?id=160204

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline W3C test now that more checks are passing.

* web-platform-tests/dom/interfaces-expected.txt:

Source/WebCore:

Align NamedNodeMap with the specification:
- https://dom.spec.whatwg.org/#interface-namednodemap

In particular, mark parameters as mandatory when they should be, and
use tighter "Attr" typing instead of Node.

Chrome and Firefox agree with the specification.

Test: fast/dom/NamedNodeMap-parameters.html

* dom/NamedNodeMap.cpp:
(WebCore::NamedNodeMap::getNamedItem):
(WebCore::NamedNodeMap::getNamedItemNS):
(WebCore::NamedNodeMap::removeNamedItem):
(WebCore::NamedNodeMap::removeNamedItemNS):
(WebCore::NamedNodeMap::setNamedItem):
(WebCore::NamedNodeMap::item):
* dom/NamedNodeMap.h:
* dom/NamedNodeMap.idl:

LayoutTests:

* dom/html/level2/core/hc_namednodemapinvalidtype1-expected.txt: Removed.
* dom/html/level2/core/hc_namednodemapinvalidtype1.html: Removed.
* dom/xhtml/level2/core/hc_namednodemapinvalidtype1-expected.txt: Removed.
* dom/xhtml/level2/core/hc_namednodemapinvalidtype1.xhtml: Removed.
Drop outdated DOM level 2 tests that expect the wrong exception type to
be thrown when passing a non-Attr node in.

* fast/dom/NamedNodeMap-parameters-expected.txt: Added.
* fast/dom/NamedNodeMap-parameters.html: Added.
Add layout test coverage. I have verified that this test is passing in
both Firefox and Chrome.

* fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt:
* fast/dom/non-numeric-values-numeric-parameters-expected.txt:
* fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
Update / rebaseline existing tests to reflect behavior change.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203730 => 203731)


--- trunk/LayoutTests/ChangeLog	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/LayoutTests/ChangeLog	2016-07-26 19:09:53 UTC (rev 203731)
@@ -1,3 +1,27 @@
+2016-07-26  Chris Dumez  <[email protected]>
+
+        Align NamedNodeMap with the specification
+        https://bugs.webkit.org/show_bug.cgi?id=160204
+
+        Reviewed by Darin Adler.
+
+        * dom/html/level2/core/hc_namednodemapinvalidtype1-expected.txt: Removed.
+        * dom/html/level2/core/hc_namednodemapinvalidtype1.html: Removed.
+        * dom/xhtml/level2/core/hc_namednodemapinvalidtype1-expected.txt: Removed.
+        * dom/xhtml/level2/core/hc_namednodemapinvalidtype1.xhtml: Removed.
+        Drop outdated DOM level 2 tests that expect the wrong exception type to
+        be thrown when passing a non-Attr node in.
+
+        * fast/dom/NamedNodeMap-parameters-expected.txt: Added.
+        * fast/dom/NamedNodeMap-parameters.html: Added.
+        Add layout test coverage. I have verified that this test is passing in
+        both Firefox and Chrome.
+
+        * fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt:
+        * fast/dom/non-numeric-values-numeric-parameters-expected.txt:
+        * fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
+        Update / rebaseline existing tests to reflect behavior change.
+
 2016-07-26  Said Abou-Hallawa  <[email protected]>
 
         Infinite Canvas context save() causes WebKit to crash

Deleted: trunk/LayoutTests/dom/html/level2/core/hc_namednodemapinvalidtype1-expected.txt (203730 => 203731)


--- trunk/LayoutTests/dom/html/level2/core/hc_namednodemapinvalidtype1-expected.txt	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/LayoutTests/dom/html/level2/core/hc_namednodemapinvalidtype1-expected.txt	2016-07-26 19:09:53 UTC (rev 203731)
@@ -1,2 +0,0 @@
-Test:	http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_namednodemapinvalidtype1
-Status:	Success

Deleted: trunk/LayoutTests/dom/html/level2/core/hc_namednodemapinvalidtype1.html (203730 => 203731)


--- trunk/LayoutTests/dom/html/level2/core/hc_namednodemapinvalidtype1.html	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/LayoutTests/dom/html/level2/core/hc_namednodemapinvalidtype1.html	2016-07-26 19:09:53 UTC (rev 203731)
@@ -1,48 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" 
-    "http://www.w3.org/TR/html4/strict.dtd" >
-<!-- This is comment number 1.-->
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>hc_staff</title><script type="text/_javascript_" src="" charset="UTF-8" type="text/_javascript_" src="" type='text/_javascript_'>function loadComplete() { startTest(); }</script></head><body _onload_="loadComplete()">
- <p>
-  <em>EMP0001</em>
-  <strong>Margaret Martin</strong>
-  <code>Accountant</code>           
-  <sup>56,000</sup>
-  <var>Female</var>
-  <acronym title="Yes">1230 North Ave. Dallas, Texas 98551</acronym>
- </p>
- <p>
-  <em>EMP0002</em>
-  <strong>Martha RaynoldsThis is a CDATASection with EntityReference number 2 &amp;ent2;
-This is an adjacent CDATASection with a reference to a tab &amp;tab;</strong>
-  <code>Secretary</code>
-  <sup>35,000</sup>
-  <var>Female</var>
-  <acronym title="Yes" class="Yes">&beta; Dallas, &gamma;
- 98554</acronym>
- </p>
- <p>
-  <em>EMP0003</em>
-  <strong>Roger
- Jones</strong>
-  <code>Department Manager</code>
-  <sup>100,000</sup>
-  <var>&delta;</var>
-  <acronym title="Yes" class="No">PO Box 27 Irving, texas 98553</acronym>
- </p>
- <p>
-  <em>EMP0004</em>
-  <strong>Jeny Oconnor</strong>
-  <code>Personnel Director</code>
-  <sup>95,000</sup>
-  <var>Female</var>
-  <acronym title="Yes" class="Y&alpha;">27 South Road. Dallas, Texas 98556</acronym>
- </p>
- <p>
-  <em>EMP0005</em>
-  <strong>Robert Myers</strong>
-  <code>Computer Specialist</code>
-  <sup>90,000</sup>
-  <var>male</var>
-  <acronym title="Yes">1821 Nordic. Road, Irving Texas 98558</acronym>
- </p>
-</body></html>

Deleted: trunk/LayoutTests/dom/xhtml/level2/core/hc_namednodemapinvalidtype1-expected.txt (203730 => 203731)


--- trunk/LayoutTests/dom/xhtml/level2/core/hc_namednodemapinvalidtype1-expected.txt	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/LayoutTests/dom/xhtml/level2/core/hc_namednodemapinvalidtype1-expected.txt	2016-07-26 19:09:53 UTC (rev 203731)
@@ -1,2 +0,0 @@
-Test	http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_namednodemapinvalidtype1
-Status	Success

Deleted: trunk/LayoutTests/dom/xhtml/level2/core/hc_namednodemapinvalidtype1.xhtml (203730 => 203731)


--- trunk/LayoutTests/dom/xhtml/level2/core/hc_namednodemapinvalidtype1.xhtml	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/LayoutTests/dom/xhtml/level2/core/hc_namednodemapinvalidtype1.xhtml	2016-07-26 19:09:53 UTC (rev 203731)
@@ -1,60 +0,0 @@
-<?xml version="1.0"?><?TEST-STYLE PIDATA?>
-<!DOCTYPE html
-   PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-   "xhtml1-strict.dtd" [
-   <!ENTITY alpha "&#945;">
-   <!ENTITY beta "&#946;">
-   <!ENTITY gamma "&#947;">
-   <!ENTITY delta "&#948;">
-   <!ENTITY epsilon "&#949;">
-   <!ENTITY alpha "&#950;">
-   <!NOTATION notation1 PUBLIC "notation1File">
-   <!NOTATION notation2 SYSTEM "notation2File">
-   <!ATTLIST acronym dir CDATA "ltr">
-]>
-<!-- This is comment number 1.-->
-<html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><title>hc_staff</title><script type="text/_javascript_" src="" charset="UTF-8" type="text/_javascript_" src="" type='text/_javascript_'>function loadComplete() { startTest(); }</script></head><body _onload_="loadComplete()">
- <p>
-  <em>EMP0001</em>
-  <strong>Margaret Martin</strong>
-  <code>Accountant</code>           
-  <sup>56,000</sup>
-  <var>Female</var>
-  <acronym title="Yes">1230 North Ave. Dallas, Texas 98551</acronym>
- </p>
- <p>
-  <em>EMP0002</em>
-  <strong>Martha RaynoldsThis is a CDATASection with EntityReference number 2 &amp;ent2;
-This is an adjacent CDATASection with a reference to a tab &amp;tab;</strong>
-  <code>Secretary</code>
-  <sup>35,000</sup>
-  <var>Female</var>
-  <acronym title="Yes" class="Yes">&beta; Dallas, &gamma;
- 98554</acronym>
- </p>
- <p>
-  <em>EMP0003</em>
-  <strong>Roger
- Jones</strong>
-  <code>Department Manager</code>
-  <sup>100,000</sup>
-  <var>&delta;</var>
-  <acronym title="Yes" class="No">PO Box 27 Irving, texas 98553</acronym>
- </p>
- <p>
-  <em>EMP0004</em>
-  <strong>Jeny Oconnor</strong>
-  <code>Personnel Director</code>
-  <sup>95,000</sup>
-  <var>Female</var>
-  <acronym title="Yes" class="Y&alpha;">27 South Road. Dallas, Texas 98556</acronym>
- </p>
- <p>
-  <em>EMP0005</em>
-  <strong>Robert Myers</strong>
-  <code>Computer Specialist</code>
-  <sup>90,000</sup>
-  <var>male</var>
-  <acronym title="Yes">1821 Nordic. Road, Irving Texas 98558</acronym>
- </p>
-</body></html>

Added: trunk/LayoutTests/fast/dom/NamedNodeMap-parameters-expected.txt (0 => 203731)


--- trunk/LayoutTests/fast/dom/NamedNodeMap-parameters-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/NamedNodeMap-parameters-expected.txt	2016-07-26 19:09:53 UTC (rev 203731)
@@ -0,0 +1,25 @@
+Tests related to parameters of the NamedNodeMap API
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS namedNodeMap.__proto__ is NamedNodeMap.prototype
+
+* Not enough parameters
+PASS namedNodeMap.getNamedItem() threw exception TypeError: Not enough arguments.
+PASS namedNodeMap.setNamedItem() threw exception TypeError: Not enough arguments.
+PASS namedNodeMap.removeNamedItem() threw exception TypeError: Not enough arguments.
+PASS namedNodeMap.item() threw exception TypeError: Not enough arguments.
+PASS namedNodeMap.getNamedItemNS() threw exception TypeError: Not enough arguments.
+PASS namedNodeMap.getNamedItemNS(null) threw exception TypeError: Not enough arguments.
+PASS namedNodeMap.setNamedItemNS() threw exception TypeError: Not enough arguments.
+PASS namedNodeMap.removeNamedItemNS() threw exception TypeError: Not enough arguments.
+PASS namedNodeMap.removeNamedItemNS(null) threw exception TypeError: Not enough arguments.
+
+* Wrong parameter type
+PASS namedNodeMap.setNamedItem(notAnAttr) threw exception TypeError: Argument 1 ('attr') to NamedNodeMap.setNamedItem must be an instance of Attr.
+PASS namedNodeMap.setNamedItemNS(notAnAttr) threw exception TypeError: Argument 1 ('attr') to NamedNodeMap.setNamedItemNS must be an instance of Attr.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/NamedNodeMap-parameters.html (0 => 203731)


--- trunk/LayoutTests/fast/dom/NamedNodeMap-parameters.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/NamedNodeMap-parameters.html	2016-07-26 19:09:53 UTC (rev 203731)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests related to parameters of the NamedNodeMap API");
+
+var namedNodeMap = document.body.attributes;
+shouldBe("namedNodeMap.__proto__", "NamedNodeMap.prototype");
+
+debug("");
+debug("* Not enough parameters");
+shouldThrow("namedNodeMap.getNamedItem()", "'TypeError: Not enough arguments'");
+shouldThrow("namedNodeMap.setNamedItem()", "'TypeError: Not enough arguments'");
+shouldThrow("namedNodeMap.removeNamedItem()", "'TypeError: Not enough arguments'");
+shouldThrow("namedNodeMap.item()", "'TypeError: Not enough arguments'");
+shouldThrow("namedNodeMap.getNamedItemNS()", "'TypeError: Not enough arguments'");
+shouldThrow("namedNodeMap.getNamedItemNS(null)", "'TypeError: Not enough arguments'");
+shouldThrow("namedNodeMap.setNamedItemNS()", "'TypeError: Not enough arguments'");
+shouldThrow("namedNodeMap.removeNamedItemNS()", "'TypeError: Not enough arguments'");
+shouldThrow("namedNodeMap.removeNamedItemNS(null)", "'TypeError: Not enough arguments'");
+
+debug("");
+debug("* Wrong parameter type");
+var notAnAttr = document.body;
+shouldThrow("namedNodeMap.setNamedItem(notAnAttr)", "'TypeError: Argument 1 (\\'attr\\') to NamedNodeMap.setNamedItem must be an instance of Attr'");
+shouldThrow("namedNodeMap.setNamedItemNS(notAnAttr)", "'TypeError: Argument 1 (\\'attr\\') to NamedNodeMap.setNamedItemNS must be an instance of Attr'");
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt (203730 => 203731)


--- trunk/LayoutTests/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/LayoutTests/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt	2016-07-26 19:09:53 UTC (rev 203731)
@@ -1,2 +1,2 @@
-CONSOLE MESSAGE: line 7: TypeError: Argument 1 ('node') to NamedNodeMap.setNamedItem must be an instance of Node
+CONSOLE MESSAGE: line 7: TypeError: Argument 1 ('attr') to NamedNodeMap.setNamedItem must be an instance of Attr
 This passes if it does not crash. (see https://bugs.webkit.org/show_bug.cgi?id=18958)

Modified: trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt (203730 => 203731)


--- trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt	2016-07-26 19:09:53 UTC (rev 203731)
@@ -48,7 +48,7 @@
 PASS nonNumericPolicy('document.createEvent("MouseEvent").initMouseEvent("a", false, false, null, 0, 0, 0, x, 0, false, false, false, false, 0, null)') is 'any type allowed'
 PASS nonNumericPolicy('document.createEvent("MouseEvent").initMouseEvent("a", false, false, null, 0, 0, 0, 0, x, false, false, false, false, 0, null)') is 'any type allowed'
 PASS nonNumericPolicy('document.createEvent("MouseEvent").initMouseEvent("a", false, false, null, 0, 0, 0, 0, 0, false, false, false, false, x, null)') is 'any type allowed'
-PASS nonNumericPolicy('document.body.attributes.item(x)') is 'any type allowed'
+PASS nonNumericPolicy('document.body.attributes.item(x)') is 'any type allowed (but not omitted)'
 PASS nonNumericPolicy('document.createNodeIterator(document, x, null, false)') is 'any type allowed'
 PASS nonNumericPolicy('document.getElementsByTagName("div").item(x)') is 'any type allowed (but not omitted)'
 PASS nonNumericPolicy('document.createRange().setStart(document, x)') is 'any type allowed (but not omitted)'

Modified: trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js (203730 => 203731)


--- trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js	2016-07-26 19:09:53 UTC (rev 203731)
@@ -291,7 +291,7 @@
 
 // NamedNodeMap
 
-shouldBe("nonNumericPolicy('document.body.attributes.item(x)')", "'any type allowed'");
+shouldBe("nonNumericPolicy('document.body.attributes.item(x)')", "'any type allowed (but not omitted)'");
 
 // NodeIterator
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (203730 => 203731)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-26 19:09:53 UTC (rev 203731)
@@ -1,3 +1,14 @@
+2016-07-26  Chris Dumez  <[email protected]>
+
+        Align NamedNodeMap with the specification
+        https://bugs.webkit.org/show_bug.cgi?id=160204
+
+        Reviewed by Darin Adler.
+
+        Rebaseline W3C test now that more checks are passing.
+
+        * web-platform-tests/dom/interfaces-expected.txt:
+
 2016-07-26  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r203719.

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt (203730 => 203731)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2016-07-26 19:09:53 UTC (rev 203731)
@@ -939,13 +939,13 @@
 PASS NamedNodeMap interface: existence and properties of interface prototype object 
 PASS NamedNodeMap interface: existence and properties of interface prototype object's "constructor" property 
 PASS NamedNodeMap interface: attribute length 
-FAIL NamedNodeMap interface: operation item(unsigned long) assert_equals: property has wrong .length expected 1 but got 0
-FAIL NamedNodeMap interface: operation getNamedItem(DOMString) assert_equals: property has wrong .length expected 1 but got 0
-FAIL NamedNodeMap interface: operation getNamedItemNS(DOMString,DOMString) assert_equals: property has wrong .length expected 2 but got 0
+PASS NamedNodeMap interface: operation item(unsigned long) 
+PASS NamedNodeMap interface: operation getNamedItem(DOMString) 
+PASS NamedNodeMap interface: operation getNamedItemNS(DOMString,DOMString) 
 PASS NamedNodeMap interface: operation setNamedItem(Attr) 
 PASS NamedNodeMap interface: operation setNamedItemNS(Attr) 
-FAIL NamedNodeMap interface: operation removeNamedItem(DOMString) assert_equals: property has wrong .length expected 1 but got 0
-FAIL NamedNodeMap interface: operation removeNamedItemNS(DOMString,DOMString) assert_equals: property has wrong .length expected 2 but got 0
+PASS NamedNodeMap interface: operation removeNamedItem(DOMString) 
+PASS NamedNodeMap interface: operation removeNamedItemNS(DOMString,DOMString) 
 FAIL Attr interface: existence and properties of interface object assert_equals: prototype of self's property "Attr" is not Function.prototype expected function "function () {
     [native code]
 }" but got function "function Node() {

Modified: trunk/Source/WebCore/ChangeLog (203730 => 203731)


--- trunk/Source/WebCore/ChangeLog	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/Source/WebCore/ChangeLog	2016-07-26 19:09:53 UTC (rev 203731)
@@ -1,3 +1,30 @@
+2016-07-26  Chris Dumez  <[email protected]>
+
+        Align NamedNodeMap with the specification
+        https://bugs.webkit.org/show_bug.cgi?id=160204
+
+        Reviewed by Darin Adler.
+
+        Align NamedNodeMap with the specification:
+        - https://dom.spec.whatwg.org/#interface-namednodemap
+
+        In particular, mark parameters as mandatory when they should be, and
+        use tighter "Attr" typing instead of Node.
+
+        Chrome and Firefox agree with the specification.
+
+        Test: fast/dom/NamedNodeMap-parameters.html
+
+        * dom/NamedNodeMap.cpp:
+        (WebCore::NamedNodeMap::getNamedItem):
+        (WebCore::NamedNodeMap::getNamedItemNS):
+        (WebCore::NamedNodeMap::removeNamedItem):
+        (WebCore::NamedNodeMap::removeNamedItemNS):
+        (WebCore::NamedNodeMap::setNamedItem):
+        (WebCore::NamedNodeMap::item):
+        * dom/NamedNodeMap.h:
+        * dom/NamedNodeMap.idl:
+
 2016-07-26  Said Abou-Hallawa  <[email protected]>
 
         Infinite Canvas context save() causes WebKit to crash

Modified: trunk/Source/WebCore/dom/NamedNodeMap.cpp (203730 => 203731)


--- trunk/Source/WebCore/dom/NamedNodeMap.cpp	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/Source/WebCore/dom/NamedNodeMap.cpp	2016-07-26 19:09:53 UTC (rev 203731)
@@ -43,17 +43,17 @@
     m_element.deref();
 }
 
-RefPtr<Node> NamedNodeMap::getNamedItem(const AtomicString& name) const
+RefPtr<Attr> NamedNodeMap::getNamedItem(const AtomicString& name) const
 {
     return m_element.getAttributeNode(name);
 }
 
-RefPtr<Node> NamedNodeMap::getNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName) const
+RefPtr<Attr> NamedNodeMap::getNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName) const
 {
     return m_element.getAttributeNodeNS(namespaceURI, localName);
 }
 
-RefPtr<Node> NamedNodeMap::removeNamedItem(const AtomicString& name, ExceptionCode& ec)
+RefPtr<Attr> NamedNodeMap::removeNamedItem(const AtomicString& name, ExceptionCode& ec)
 {
     unsigned index = m_element.hasAttributes() ? m_element.findAttributeIndexByName(name, shouldIgnoreAttributeCase(m_element)) : ElementData::attributeNotFound;
     if (index == ElementData::attributeNotFound) {
@@ -69,7 +69,7 @@
     return Vector<AtomicString>();
 }
 
-RefPtr<Node> NamedNodeMap::removeNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionCode& ec)
+RefPtr<Attr> NamedNodeMap::removeNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionCode& ec)
 {
     unsigned index = m_element.hasAttributes() ? m_element.findAttributeIndexByName(QualifiedName(nullAtom, localName, namespaceURI)) : ElementData::attributeNotFound;
     if (index == ElementData::attributeNotFound) {
@@ -79,24 +79,22 @@
     return m_element.detachAttribute(index);
 }
 
-RefPtr<Node> NamedNodeMap::setNamedItem(Node& node, ExceptionCode& ec)
+RefPtr<Attr> NamedNodeMap::setNamedItem(Attr& attr, ExceptionCode& ec)
 {
-    // Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes in a non-attribute node
+    return m_element.setAttributeNode(attr, ec);
+}
+
+RefPtr<Attr> NamedNodeMap::setNamedItem(Node& node, ExceptionCode& ec)
+{
     if (!is<Attr>(node)) {
-        ec = HIERARCHY_REQUEST_ERR;
+        ec = TypeError;
         return nullptr;
     }
-
-    return m_element.setAttributeNode(downcast<Attr>(node), ec);
+    return setNamedItem(downcast<Attr>(node), ec);
 }
 
-RefPtr<Node> NamedNodeMap::setNamedItemNS(Node& node, ExceptionCode& ec)
+RefPtr<Attr> NamedNodeMap::item(unsigned index) const
 {
-    return setNamedItem(node, ec);
-}
-
-RefPtr<Node> NamedNodeMap::item(unsigned index) const
-{
     if (index >= length())
         return 0;
     return m_element.ensureAttr(m_element.attributeAt(index).name());

Modified: trunk/Source/WebCore/dom/NamedNodeMap.h (203730 => 203731)


--- trunk/Source/WebCore/dom/NamedNodeMap.h	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/Source/WebCore/dom/NamedNodeMap.h	2016-07-26 19:09:53 UTC (rev 203731)
@@ -25,6 +25,7 @@
 #ifndef NamedNodeMap_h
 #define NamedNodeMap_h
 
+#include "Attr.h"
 #include "ScriptWrappable.h"
 #include <wtf/RefPtr.h>
 #include <wtf/text/AtomicString.h>
@@ -31,7 +32,6 @@
 
 namespace WebCore {
 
-class Node;
 class Element;
 
 typedef int ExceptionCode;
@@ -51,17 +51,17 @@
 
     // Public DOM interface.
 
-    RefPtr<Node> getNamedItem(const AtomicString&) const;
-    RefPtr<Node> removeNamedItem(const AtomicString& name, ExceptionCode&);
+    RefPtr<Attr> getNamedItem(const AtomicString&) const;
+    RefPtr<Attr> removeNamedItem(const AtomicString& name, ExceptionCode&);
     Vector<AtomicString> supportedPropertyNames();
 
-    RefPtr<Node> getNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName) const;
-    RefPtr<Node> removeNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionCode&);
+    RefPtr<Attr> getNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName) const;
+    RefPtr<Attr> removeNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionCode&);
 
-    RefPtr<Node> setNamedItem(Node&, ExceptionCode&);
-    RefPtr<Node> setNamedItemNS(Node&, ExceptionCode&);
+    RefPtr<Attr> setNamedItem(Attr&, ExceptionCode&);
+    RefPtr<Attr> setNamedItem(Node&, ExceptionCode&); // for legacy bindings.
 
-    RefPtr<Node> item(unsigned index) const;
+    RefPtr<Attr> item(unsigned index) const;
     unsigned length() const;
 
     Element& element() const { return m_element; }

Modified: trunk/Source/WebCore/dom/NamedNodeMap.idl (203730 => 203731)


--- trunk/Source/WebCore/dom/NamedNodeMap.idl	2016-07-26 18:58:41 UTC (rev 203730)
+++ trunk/Source/WebCore/dom/NamedNodeMap.idl	2016-07-26 19:09:53 UTC (rev 203731)
@@ -22,18 +22,23 @@
     GenerateIsReachable=ImplElementRoot,
     ImplementationLacksVTable,
 ] interface NamedNodeMap {
-
-    // FIXME: Using "undefined" as default parameter value is wrong.
-    getter Node getNamedItem(optional DOMString name = "undefined");
-    [RaisesException] Node setNamedItem(Node node);
-    [RaisesException] Node removeNamedItem(optional DOMString name = "undefined");
-    getter Node item(optional unsigned long index = 0);
     readonly attribute unsigned long length;
 
-    // Introduced in DOM Level 2:
-
-    // FIXME: Using "undefined" as default parameter value is wrong.
-    [ObjCLegacyUnnamedParameters] Node getNamedItemNS(optional DOMString? namespaceURI = null, optional DOMString localName = "undefined");
-    [RaisesException] Node setNamedItemNS(Node node);
-    [ObjCLegacyUnnamedParameters, RaisesException] Node removeNamedItemNS(optional DOMString? namespaceURI = null, optional DOMString localName = "undefined");
+#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
+    getter Attr? getNamedItem(DOMString name);
+    [RaisesException] Attr? setNamedItem(Attr attr);
+    [RaisesException] Attr removeNamedItem(DOMString name);
+    getter Attr? item(unsigned long index);
+    Attr? getNamedItemNS(DOMString? namespaceURI, DOMString localName);
+    [RaisesException, ImplementedAs=setNamedItem] Attr? setNamedItemNS(Attr attr);
+    [RaisesException] Attr removeNamedItemNS(DOMString? namespaceURI, DOMString localName);
+#else
+    getter Node? getNamedItem(DOMString name);
+    [RaisesException] Node? setNamedItem(Node node);
+    [RaisesException] Node removeNamedItem(DOMString name);
+    getter Node? item(unsigned long index);
+    [ObjCLegacyUnnamedParameters] Node? getNamedItemNS(DOMString? namespaceURI, DOMString localName);
+    [RaisesException, ImplementedAs=setNamedItem] Node? setNamedItemNS(Node node);
+    [ObjCLegacyUnnamedParameters, RaisesException] Node removeNamedItemNS(DOMString? namespaceURI, DOMString localName);
+#endif
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to