LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 May 2006 14:59:18 +0000 (14:59 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 May 2006 14:59:18 +0000 (14:59 +0000)
        Reviewed by Darin.

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8563>

        Tests that the name, publicID and systemID are all read correctly
        and that the doctype object preserves the case of the
        components from the source html:
        * fast/doctypes/005-case-preserving.html: Added.
        * fast/doctypes/005-case-preserving-expected.txt: Added.

WebCore:

        Reviewed by Darin.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=8563

        The doctype object in the DOM is now usable by client code
        as opposed to always being exposed as nil. Now also ensures that
        the 'name' of the component preserves the case of the original html source.
        (i.e HtMl -> HtMl not HTML)

        * dom/Document.h:
        Changes comment by docType() to say it may return 0 for html
        * html/HTMLDocument.cpp:
        (WebCore::parseDocTypeDeclaration):
        (WebCore::HTMLDocument::determineParseMode):
        Preserves the case of the name component
        (WebCore::HTMLDocument::doctype):removed
        * html/HTMLDocument.h:
        (WebCore::HTMLDocument::doctype):removed

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14204 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/doctypes/005-case-preserving-expected.txt [new file with mode: 0644]
LayoutTests/fast/doctypes/005-case-preserving.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Document.h
WebCore/html/HTMLDocument.cpp
WebCore/html/HTMLDocument.h

index bd0e73ce2cd05bb4c54a872340c178c6fe3e4cfe..f2afd6dbc8aa8d9f38f08c8495e235be4271febe 100644 (file)
@@ -1,3 +1,15 @@
+2006-05-05  Matt Gough  <matt@softchaos.com>
+
+        Reviewed by Darin.
+
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8563>
+
+        Tests that the name, publicID and systemID are all read correctly
+        and that the doctype object preserves the case of the
+        components from the source html:
+        * fast/doctypes/005-case-preserving.html: Added.
+        * fast/doctypes/005-case-preserving-expected.txt: Added.
+
 2006-05-04  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by Darin.
         * fast/dom/prototype-chain-expected.txt: Fix up prototype chain now
         that Node is autogenerated.
 
+>>>>>>> .r14170
 2006-04-25  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by harrison
diff --git a/LayoutTests/fast/doctypes/005-case-preserving-expected.txt b/LayoutTests/fast/doctypes/005-case-preserving-expected.txt
new file mode 100644 (file)
index 0000000..36be0fb
--- /dev/null
@@ -0,0 +1,5 @@
+SUCCESS - This document has a doctype and each component has the correct case
+
+name = HtMl
+publicId = -//W3C//DTD HTML 4.01 Transitional//EN
+systemId = http://www.w3.org/TR/html4/loose.dtd
diff --git a/LayoutTests/fast/doctypes/005-case-preserving.html b/LayoutTests/fast/doctypes/005-case-preserving.html
new file mode 100644 (file)
index 0000000..f305018
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE HtMl PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+        "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8">
+    <title>DocType Case Insensitivity</title>
+</head>
+<body>
+<script type="text/javascript" language="javascript">
+<!--
+
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+if (document.doctype)
+    {
+    var output = document.doctype.name + ", " + document.doctype.publicId + ", " + document.doctype.systemId;
+                
+    var expected = "HtMl, -//W3C//DTD HTML 4.01 Transitional//EN, http://www.w3.org/TR/html4/loose.dtd";
+    
+    if (output == expected)
+        {
+        document.write("<span style='color:green'>");
+        document.write("SUCCESS - This document has a doctype and each component has the correct case<br><br>");
+        document.write("name = " + document.doctype.name + "<br>");
+        document.write("publicId = " + document.doctype.publicId + "<br>");
+        document.write("systemId = " + document.doctype.systemId);
+        }
+    else
+        {
+        document.write("<span style='color:red'>");
+        document.write("FAILED - This document has a doctype, but one or more components has the wrong case<br><br>");
+        document.write("name = " + document.doctype.name + " (should be HtMl)" + "<br>");
+        document.write("publicId = " + document.doctype.publicId + " (should be -//W3C//DTD HTML 4.01 Transitional//EN)" + "<br>");
+        document.write("systemId = " + document.doctype.systemId + " (should be http://www.w3.org/TR/html4/loose.dtd)");
+        }
+    }
+else
+    {
+    document.write("FAILED - doctype is null even though there is a &lt;!DOCTYPE ...&gt; declaration");
+    }
+//-->
+</script>
+
+</body>
+</html>
index dbce78a3baefb2341fb63174bcca596773377d25..50d4ddce5e0db4e654da28e1545da441808d0fff 100644 (file)
@@ -1,3 +1,24 @@
+2006-05-05  Matt Gough  <matt@softchaos.com>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=8563
+
+        The doctype object in the DOM is now usable by client code
+        as opposed to always being exposed as nil. Now also ensures that
+        the 'name' of the component preserves the case of the original html source.
+        (i.e HtMl -> HtMl not HTML)
+
+        * dom/Document.h:
+        Changes comment by docType() to say it may return 0 for html
+        * html/HTMLDocument.cpp:
+        (WebCore::parseDocTypeDeclaration):
+        (WebCore::HTMLDocument::determineParseMode):
+        Preserves the case of the name component
+        (WebCore::HTMLDocument::doctype):removed
+        * html/HTMLDocument.h:
+        (WebCore::HTMLDocument::doctype):removed
+
 2006-05-05  Rob Buis  <buis@kde.org>
 
         Reviewed by Darin.
index eb47a4cb7cf685c7eca71b4a38fa55208efa43a6..530249939653a1d5dc4eca9c54f8ecbb633b4419 100644 (file)
@@ -121,7 +121,7 @@ public:
 
     // DOM methods & attributes for Document
 
-    virtual DocumentType* doctype() const; // returns 0 for HTML documents
+    virtual DocumentType* doctype() const; // May return 0 for HTML documents
     DocumentType* realDocType() const { return m_docType.get(); }
 
     DOMImplementation* implementation() const;
index 55388bf2b76ddafbb18fc9616c87f21a273fff63..e577eaf66dfa2425b93edac59ce4ed625618bfb0 100644 (file)
@@ -244,6 +244,7 @@ static bool containsString(const char* str, const DeprecatedString& buffer, int
 
 static bool parseDocTypeDeclaration(const DeprecatedString& buffer,
                                     int* resultFlags,
+                                    DeprecatedString& name,
                                     DeprecatedString& publicID,
                                     DeprecatedString& systemID)
 {
@@ -279,6 +280,7 @@ static bool parseDocTypeDeclaration(const DeprecatedString& buffer,
     if (!containsString("html", buffer, index))
         return false;
     
+    name = buffer.mid(index, 4);
     index = parseDocTypePart(buffer, index+4);
     bool hasPublic = containsString("public", buffer, index);
     if (hasPublic) {
@@ -366,11 +368,11 @@ void HTMLDocument::determineParseMode( const DeprecatedString &str )
     // STRICT - no quirks apply.  Web pages will obey the specifications to
     // the letter.
 
-    DeprecatedString systemID, publicID;
+    DeprecatedString name, systemID, publicID;
     int resultFlags = 0;
-    if (parseDocTypeDeclaration(str, &resultFlags, publicID, systemID)) {
+    if (parseDocTypeDeclaration(str, &resultFlags, name, publicID, systemID)) {
         if (resultFlags & PARSEMODE_HAVE_DOCTYPE)
-            setDocType(new DocumentType(this, "HTML", publicID, systemID));
+            setDocType(new DocumentType(this, name, publicID, systemID));
         if (!(resultFlags & PARSEMODE_HAVE_DOCTYPE)) {
             // No doctype found at all.  Default to quirks mode and Html4.
             pMode = Compat;
@@ -429,10 +431,4 @@ void HTMLDocument::determineParseMode( const DeprecatedString &str )
  
 }
 
-DocumentType *HTMLDocument::doctype() const
-{
-    // According to a comment in dom_doc.cpp, doctype is null for HTML documents.
-    return 0;
-}
-
 }
index 1311c8534f11982eabc71baf6de0ab08429d1738..564d4a7c958445550096a434d2247eaa2223fbb1 100644 (file)
@@ -74,8 +74,6 @@ public:
         return 0;
     }
 
-    virtual DocumentType* doctype() const;
-
     typedef HashMap<StringImpl*, int> NameCountMap;
 
 protected: