Title: [203759] trunk
- Revision
- 203759
- Author
- [email protected]
- Date
- 2016-07-26 20:42:30 -0700 (Tue, 26 Jul 2016)
Log Message
Align Node.isEqualNode() with the specification
https://bugs.webkit.org/show_bug.cgi?id=160224
Reviewed by Sam Weinig.
LayoutTests/imported/w3c:
Rebaseline W3C test now that one more check is passing. We are now
passing all the checks in this test like Firefox and Chrome.
* web-platform-tests/dom/nodes/Node-isEqualNode-expected.txt:
Source/WebCore:
Align our implementation for Node.isEqualNode() to match more closely
the text of the specification:
- https://dom.spec.whatwg.org/#dom-node-isequalnode
- https://dom.spec.whatwg.org/#concept-node-equals
This also fixes a bug where isEqualNode() would sometimes return false
wrongly for elements because we were comparing the value returned by
nodeName() which returns the tagName of elements. The issue was that
the tagName's case may differ depending on the element being in an
HTMLDocument or not. We now compare Element::tagQName() instead which
ends up comparing namespace / namespace prefix and localName, as per
the specification. The new behavior matches Firefox and Chrome and
helps us pass an extra W3C test.
No new tests, rebaselined existing test.
* dom/Node.cpp:
(WebCore::Node::isEqualNode):
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (203758 => 203759)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2016-07-27 01:23:53 UTC (rev 203758)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2016-07-27 03:42:30 UTC (rev 203759)
@@ -1,5 +1,17 @@
2016-07-26 Chris Dumez <[email protected]>
+ Align Node.isEqualNode() with the specification
+ https://bugs.webkit.org/show_bug.cgi?id=160224
+
+ Reviewed by Sam Weinig.
+
+ Rebaseline W3C test now that one more check is passing. We are now
+ passing all the checks in this test like Firefox and Chrome.
+
+ * web-platform-tests/dom/nodes/Node-isEqualNode-expected.txt:
+
+2016-07-26 Chris Dumez <[email protected]>
+
Range.prototype.compareBoundaryPoints.length should be 2
https://bugs.webkit.org/show_bug.cgi?id=160217
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Node-isEqualNode-expected.txt (203758 => 203759)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Node-isEqualNode-expected.txt 2016-07-27 01:23:53 UTC (rev 203758)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Node-isEqualNode-expected.txt 2016-07-27 03:42:30 UTC (rev 203759)
@@ -6,6 +6,6 @@
PASS text nodes should be compared on data
PASS comments should be compared on data
PASS document fragments should not be compared based on properties
-FAIL documents should not be compared based on properties assert_true: default HTML documents, created different ways expected true got false
+PASS documents should not be compared based on properties
PASS node equality testing should test descendant equality too
Modified: trunk/Source/WebCore/ChangeLog (203758 => 203759)
--- trunk/Source/WebCore/ChangeLog 2016-07-27 01:23:53 UTC (rev 203758)
+++ trunk/Source/WebCore/ChangeLog 2016-07-27 03:42:30 UTC (rev 203759)
@@ -1,3 +1,29 @@
+2016-07-26 Chris Dumez <[email protected]>
+
+ Align Node.isEqualNode() with the specification
+ https://bugs.webkit.org/show_bug.cgi?id=160224
+
+ Reviewed by Sam Weinig.
+
+ Align our implementation for Node.isEqualNode() to match more closely
+ the text of the specification:
+ - https://dom.spec.whatwg.org/#dom-node-isequalnode
+ - https://dom.spec.whatwg.org/#concept-node-equals
+
+ This also fixes a bug where isEqualNode() would sometimes return false
+ wrongly for elements because we were comparing the value returned by
+ nodeName() which returns the tagName of elements. The issue was that
+ the tagName's case may differ depending on the element being in an
+ HTMLDocument or not. We now compare Element::tagQName() instead which
+ ends up comparing namespace / namespace prefix and localName, as per
+ the specification. The new behavior matches Firefox and Chrome and
+ helps us pass an extra W3C test.
+
+ No new tests, rebaselined existing test.
+
+ * dom/Node.cpp:
+ (WebCore::Node::isEqualNode):
+
2016-07-26 Simon Fraser <[email protected]>
Sort the project files.
Modified: trunk/Source/WebCore/dom/Node.cpp (203758 => 203759)
--- trunk/Source/WebCore/dom/Node.cpp 2016-07-27 01:23:53 UTC (rev 203758)
+++ trunk/Source/WebCore/dom/Node.cpp 2016-07-27 03:42:30 UTC (rev 203759)
@@ -1216,24 +1216,61 @@
if (nodeType != other->nodeType())
return false;
- if (nodeName() != other->nodeName())
- return false;
+ switch (nodeType) {
+ case Node::DOCUMENT_TYPE_NODE: {
+ auto& thisDocType = downcast<DocumentType>(*this);
+ auto& otherDocType = downcast<DocumentType>(*other);
+ if (thisDocType.name() != otherDocType.name())
+ return false;
+ if (thisDocType.publicId() != otherDocType.publicId())
+ return false;
+ if (thisDocType.systemId() != otherDocType.systemId())
+ return false;
+ if (thisDocType.internalSubset() != otherDocType.internalSubset())
+ return false;
+ break;
+ }
+ case Node::ELEMENT_NODE: {
+ auto& thisElement = downcast<Element>(*this);
+ auto& otherElement = downcast<Element>(*other);
+ if (thisElement.tagQName() != otherElement.tagQName())
+ return false;
+ if (!thisElement.hasEquivalentAttributes(&otherElement))
+ return false;
+ break;
+ }
+ case Node::PROCESSING_INSTRUCTION_NODE: {
+ auto& thisProcessingInstruction = downcast<ProcessingInstruction>(*this);
+ auto& otherProcessingInstruction = downcast<ProcessingInstruction>(*other);
+ if (thisProcessingInstruction.target() != otherProcessingInstruction.target())
+ return false;
+ if (thisProcessingInstruction.data() != otherProcessingInstruction.data())
+ return false;
+ break;
+ }
+ case Node::CDATA_SECTION_NODE:
+ case Node::TEXT_NODE:
+ case Node::COMMENT_NODE: {
+ auto& thisCharacterData = downcast<CharacterData>(*this);
+ auto& otherCharacterData = downcast<CharacterData>(*other);
+ if (thisCharacterData.data() != otherCharacterData.data())
+ return false;
+ break;
+ }
+ case Node::ATTRIBUTE_NODE: {
+ auto& thisAttribute = downcast<Attr>(*this);
+ auto& otherAttribute = downcast<Attr>(*other);
+ if (thisAttribute.qualifiedName() != otherAttribute.qualifiedName())
+ return false;
+ if (thisAttribute.value() != otherAttribute.value())
+ return false;
+ break;
+ }
+ case Node::DOCUMENT_NODE:
+ case Node::DOCUMENT_FRAGMENT_NODE:
+ break;
+ }
- if (localName() != other->localName())
- return false;
-
- if (namespaceURI() != other->namespaceURI())
- return false;
-
- if (prefix() != other->prefix())
- return false;
-
- if (nodeValue() != other->nodeValue())
- return false;
-
- if (is<Element>(*this) && !downcast<Element>(*this).hasEquivalentAttributes(downcast<Element>(other)))
- return false;
-
Node* child = firstChild();
Node* otherChild = other->firstChild();
@@ -1248,22 +1285,6 @@
if (otherChild)
return false;
- if (nodeType == DOCUMENT_TYPE_NODE) {
- const DocumentType* documentTypeThis = static_cast<const DocumentType*>(this);
- const DocumentType* documentTypeOther = static_cast<const DocumentType*>(other);
-
- if (documentTypeThis->publicId() != documentTypeOther->publicId())
- return false;
-
- if (documentTypeThis->systemId() != documentTypeOther->systemId())
- return false;
-
- if (documentTypeThis->internalSubset() != documentTypeOther->internalSubset())
- return false;
-
- // FIXME: We don't compare entities or notations because currently both are always empty.
- }
-
return true;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes