kdelibs/khtml/html

Dirk Mueller mueller@kde.org
Mon, 13 Jan 2003 11:31:01 +0100 (CET)


CVS commit by mueller: 

document type parsing improvements. More testing required. 
CCMAIL: khtml-devel@kde.org


  M +17 -16    html_documentimpl.cpp   1.145


--- kdelibs/khtml/html/html_documentimpl.cpp  #1.144:1.145
@@ -275,5 +275,4 @@ static bool isTransitional(const QString
        (spec.find("SYMBOLS", start, false ) != -1 ) ||
        (spec.find("SPECIAL", start, false ) != -1 ) ) {
-        //kdDebug() << "isTransitional" << endl;
         return true;
     }
@@ -376,5 +375,4 @@ void HTMLDocumentImpl::determineParseMod
                             tagPos = val.find(QRegExp("[0-9]"), tagPos );
                             int version = val.mid( tagPos, 1 ).toInt();
-                            //kdDebug() << "DocumentImpl::determineParseMode tagPos = " << tagPos << " version=" << version << endl;
                             if( version > 3 ) {
                                 hMode = Html4;
@@ -388,24 +386,27 @@ void HTMLDocumentImpl::determineParseMod
         }
 
-        if( systemId == publicId )
+        if( systemId && systemId == publicId ) { // not unknown and both agree
             pMode = publicId;
+        }
         else if ( systemId == Unknown )
-            pMode = hMode == Html4 ? Compat : publicId;
-        else if ( publicId == Transitional && systemId == Strict ) {
-            pMode = hMode == Html3 ? Compat : Strict;
-        } else
+            pMode = hMode == Html3 ? Compat : publicId;
+        else if ( ( publicId == Transitional && systemId == Strict ) ||
+                  ( publicId == Strict && systemId == Transitional ) ) {
+            pMode = hMode == Html3 ? Compat : kMin( publicId, systemId );
+        } else {
             pMode = Compat;
+        }
 
         if ( hMode == XHtml )
             pMode = Strict;
     }
-//     kdDebug() << "DocumentImpl::determineParseMode: publicId =" << publicId << " systemId = " << systemId << endl;
-//     kdDebug() << "DocumentImpl::determineParseMode: htmlMode = " << hMode<< endl;
-//     if( pMode == Strict )
-//         kdDebug(6020) << " using strict parseMode" << endl;
-//     else if (pMode == Compat )
-//         kdDebug(6020) << " using compatibility parseMode" << endl;
-//     else
-//         kdDebug(6020) << " using transitional parseMode" << endl;
+    // kdDebug() << "DocumentImpl::determineParseMode: publicId =" << publicId << " systemId = " << systemId << endl;
+    // kdDebug() << "DocumentImpl::determineParseMode: htmlMode = " << hMode<< endl;
+    if( pMode == Strict )
+        kdDebug(6020) << " using strict parseMode" << endl;
+    else if (pMode == Compat )
+        kdDebug(6020) << " using compatibility parseMode" << endl;
+    else
+        kdDebug(6020) << " using transitional parseMode" << endl;
 
     if ( pMode != oldPMode && styleSelector() )