Title: [195091] trunk
Revision
195091
Author
[email protected]
Date
2016-01-14 22:12:56 -0800 (Thu, 14 Jan 2016)

Log Message

createElement should not lowercase non-ASCII characters
https://bugs.webkit.org/show_bug.cgi?id=153114

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaselined the tests for document.createElement now that more test cases are passing.

* web-platform-tests/dom/nodes/Document-createElement-expected.txt:
* web-platform-tests/dom/nodes/Document-getElementsByTagName-expected.txt:
* web-platform-tests/dom/nodes/Element-getElementsByTagName-expected.txt:
* web-platform-tests/dom/nodes/case-expected.txt:

Source/WebCore:

According to step 2 in https://dom.spec.whatwg.org/#dom-document-createelement, document.createElement should not
lowercase non-ASCII letters, and this is also what Firefox does. Match that behavior by lowercasing the tag name
by convertToASCIILowercase() instead of lower() in createElement.

Also merged HTMLDocument::createElement into Document::createElement for simplicity and avoid duplicating
the call to isValidName and setting a DOM exception.

No new tests since the behavior change is covered by the existing W3C tests.

* dom/Document.cpp:
(WebCore::Document::createElement): Create a HTML element with ASCII-lowercased tag name inside a HTML document.
* dom/Document.h:
* html/HTMLDocument.cpp:
(WebCore::addLocalNameToSet):
(WebCore::HTMLDocument::createElement): Merged into Document::createElement.
* html/HTMLDocument.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (195090 => 195091)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-01-15 05:40:39 UTC (rev 195090)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-01-15 06:12:56 UTC (rev 195091)
@@ -1,3 +1,17 @@
+2016-01-14  Ryosuke Niwa  <[email protected]>
+
+        createElement should not lowercase non-ASCII characters
+        https://bugs.webkit.org/show_bug.cgi?id=153114
+
+        Reviewed by Alex Christensen.
+
+        Rebaselined the tests for document.createElement now that more test cases are passing.
+
+        * web-platform-tests/dom/nodes/Document-createElement-expected.txt:
+        * web-platform-tests/dom/nodes/Document-getElementsByTagName-expected.txt:
+        * web-platform-tests/dom/nodes/Element-getElementsByTagName-expected.txt:
+        * web-platform-tests/dom/nodes/case-expected.txt:
+
 2016-01-14  Youenn Fablet  <[email protected]>
 
         Fix problems with cross-origin redirects

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-expected.txt (195090 => 195091)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-expected.txt	2016-01-15 05:40:39 UTC (rev 195090)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-expected.txt	2016-01-15 06:12:56 UTC (rev 195091)
@@ -19,8 +19,8 @@
 PASS createElement("svg") 
 PASS createElement("math") 
 PASS createElement("FOO") 
-FAIL createElement("marK") assert_equals: expected "marK" but got "mark"
-FAIL createElement("İnput") assert_equals: expected "İnput" but got "i̇nput"
+PASS createElement("marK") 
+PASS createElement("İnput") 
 FAIL createElement("ınput") assert_equals: expected "ıNPUT" but got "INPUT"
 PASS createElement("") 
 PASS createElement("1foo") 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-getElementsByTagName-expected.txt (195090 => 195091)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-getElementsByTagName-expected.txt	2016-01-15 05:40:39 UTC (rev 195090)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-getElementsByTagName-expected.txt	2016-01-15 06:12:56 UTC (rev 195091)
@@ -14,7 +14,7 @@
 PASS Element in non-HTML namespace, no prefix, uppercase name 
 PASS Element in non-HTML namespace, prefix, lowercase name 
 PASS Element in non-HTML namespace, prefix, uppercase name 
-FAIL Element in HTML namespace, no prefix, non-ascii characters in name assert_equals: expected "aÇ" but got "aç"
+PASS Element in HTML namespace, no prefix, non-ascii characters in name 
 PASS Element in non-HTML namespace, non-ascii characters in name 
 PASS Element in HTML namespace, prefix, non-ascii characters in name 
 PASS Element in non-HTML namespace, prefix, non-ascii characters in name 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-getElementsByTagName-expected.txt (195090 => 195091)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-getElementsByTagName-expected.txt	2016-01-15 05:40:39 UTC (rev 195090)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-getElementsByTagName-expected.txt	2016-01-15 06:12:56 UTC (rev 195091)
@@ -14,7 +14,7 @@
 PASS Element in non-HTML namespace, no prefix, uppercase name 
 PASS Element in non-HTML namespace, prefix, lowercase name 
 PASS Element in non-HTML namespace, prefix, uppercase name 
-FAIL Element in HTML namespace, no prefix, non-ascii characters in name assert_equals: expected "aÇ" but got "aç"
+PASS Element in HTML namespace, no prefix, non-ascii characters in name 
 PASS Element in non-HTML namespace, non-ascii characters in name 
 PASS Element in HTML namespace, prefix, non-ascii characters in name 
 PASS Element in non-HTML namespace, prefix, non-ascii characters in name 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/case-expected.txt (195090 => 195091)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/case-expected.txt	2016-01-15 05:40:39 UTC (rev 195090)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/case-expected.txt	2016-01-15 06:12:56 UTC (rev 195091)
@@ -19,7 +19,7 @@
 PASS getAttribute ä 
 PASS getElementsByTagName a:ä 
 PASS getElementsByTagName ä 
-FAIL createElement Ä assert_equals: expected "Ä" but got "ä"
+PASS createElement Ä 
 PASS setAttribute Ä 
 PASS getAttribute Ä 
 PASS getElementsByTagName a:Ä 

Modified: trunk/Source/WebCore/ChangeLog (195090 => 195091)


--- trunk/Source/WebCore/ChangeLog	2016-01-15 05:40:39 UTC (rev 195090)
+++ trunk/Source/WebCore/ChangeLog	2016-01-15 06:12:56 UTC (rev 195091)
@@ -1,3 +1,27 @@
+2016-01-14  Ryosuke Niwa  <[email protected]>
+
+        createElement should not lowercase non-ASCII characters
+        https://bugs.webkit.org/show_bug.cgi?id=153114
+
+        Reviewed by Alex Christensen.
+
+        According to step 2 in https://dom.spec.whatwg.org/#dom-document-createelement, document.createElement should not
+        lowercase non-ASCII letters, and this is also what Firefox does. Match that behavior by lowercasing the tag name
+        by convertToASCIILowercase() instead of lower() in createElement.
+
+        Also merged HTMLDocument::createElement into Document::createElement for simplicity and avoid duplicating
+        the call to isValidName and setting a DOM exception.
+
+        No new tests since the behavior change is covered by the existing W3C tests.
+
+        * dom/Document.cpp:
+        (WebCore::Document::createElement): Create a HTML element with ASCII-lowercased tag name inside a HTML document.
+        * dom/Document.h:
+        * html/HTMLDocument.cpp:
+        (WebCore::addLocalNameToSet):
+        (WebCore::HTMLDocument::createElement): Merged into Document::createElement.
+        * html/HTMLDocument.h:
+
 2016-01-14  Brady Eidson  <[email protected]>
 
         Modern IDB: Support opening and deleting SQLite databases on disk.

Modified: trunk/Source/WebCore/dom/Document.cpp (195090 => 195091)


--- trunk/Source/WebCore/dom/Document.cpp	2016-01-15 05:40:39 UTC (rev 195090)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-01-15 06:12:56 UTC (rev 195091)
@@ -888,6 +888,9 @@
         return nullptr;
     }
 
+    if (isHTMLDocument())
+        return HTMLElementFactory::createElement(QualifiedName(nullAtom, name.convertToASCIILowercase(), xhtmlNamespaceURI), *this);
+
     if (isXHTMLDocument())
         return HTMLElementFactory::createElement(QualifiedName(nullAtom, name, xhtmlNamespaceURI), *this);
 

Modified: trunk/Source/WebCore/dom/Document.h (195090 => 195091)


--- trunk/Source/WebCore/dom/Document.h	2016-01-15 05:40:39 UTC (rev 195090)
+++ trunk/Source/WebCore/dom/Document.h	2016-01-15 06:12:56 UTC (rev 195091)
@@ -385,7 +385,7 @@
 
     bool hasManifest() const;
     
-    virtual RefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
+    WEBCORE_EXPORT RefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
     WEBCORE_EXPORT Ref<DocumentFragment> createDocumentFragment();
     WEBCORE_EXPORT Ref<Text> createTextNode(const String& data);
     Ref<Comment> createComment(const String& data);

Modified: trunk/Source/WebCore/html/HTMLDocument.cpp (195090 => 195091)


--- trunk/Source/WebCore/html/HTMLDocument.cpp	2016-01-15 05:40:39 UTC (rev 195090)
+++ trunk/Source/WebCore/html/HTMLDocument.cpp	2016-01-15 06:12:56 UTC (rev 195091)
@@ -226,15 +226,6 @@
 // not part of the DOM
 // --------------------------------------------------------------------------
 
-RefPtr<Element> HTMLDocument::createElement(const AtomicString& name, ExceptionCode& ec)
-{
-    if (!isValidName(name)) {
-        ec = INVALID_CHARACTER_ERR;
-        return 0;
-    }
-    return HTMLElementFactory::createElement(QualifiedName(nullAtom, name.lower(), xhtmlNamespaceURI), *this);
-}
-
 static void addLocalNameToSet(HashSet<AtomicStringImpl*>* set, const QualifiedName& qName)
 {
     set->add(qName.localName().impl());

Modified: trunk/Source/WebCore/html/HTMLDocument.h (195090 => 195091)


--- trunk/Source/WebCore/html/HTMLDocument.h	2016-01-15 05:40:39 UTC (rev 195090)
+++ trunk/Source/WebCore/html/HTMLDocument.h	2016-01-15 06:12:56 UTC (rev 195091)
@@ -86,8 +86,6 @@
     HTMLDocument(Frame*, const URL&, DocumentClassFlags = 0, unsigned constructionFlags = 0);
 
 private:
-    virtual RefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&) override;
-
     virtual bool isFrameSet() const override;
     virtual Ref<DocumentParser> createParser() override;
     virtual Ref<Document> cloneDocumentWithoutChildren() const override final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to