Question about skip mode

Maciej Stachowiak mjs@apple.com
Tue, 21 Jan 2003 10:39:44 -0800


Hi folks,

I just committed the patch below to WebCore to fix a couple of sites, 
but I am wondering what the original motivation was for the if 
condition I removed. It seems wrong to me to avoid parsing the rest of 
the document if you come out of parsing a script with the parser in 
skip mode - if you did a document.write of a special tag like <iframe> 
without a close tag, you definitely want to parse what's after and let 
the parser skip stuff up til the </iframe> in the normal way. But I'm 
wondering if there was a reason for the way it is and if I am breaking 
anything.

The iframe problem I mentioned actually comes up on real-world sites 
like http://www.debka.com and http://www.cycleworld.com

Index: khtml/html/htmltokenizer.cpp
===================================================================
RCS file: 
/local/home/cvs/Labyrinth/WebCore/khtml/html/htmltokenizer.cpp,v
retrieving revision 1.29
diff -u -p -r1.29 khtml/html/htmltokenizer.cpp
--- khtml/html/htmltokenizer.cpp        2003/01/12 17:01:13     1.29
+++ khtml/html/htmltokenizer.cpp        2003/01/21 13:39:30
@@ -533,19 +533,17 @@ void HTMLTokenizer::scriptHandler()
      script = false;
      scriptCodeSize = scriptCodeResync = 0;

-    if ( !parser->skipMode() ) {
-        if ( !m_executingScript && !loadingExtScript ) {
-            // kdDebug( 6036 ) << "adding pending Output to parsed 
string" << endl;
+    if ( !m_executingScript && !loadingExtScript ) {
+       // kdDebug( 6036 ) << "adding pending Output to parsed string" 
<< endl;
  #if APPLE_CHANGES
-            pendingSrc.prepend(src.current(), src.length());
+       pendingSrc.prepend(src.current(), src.length());
  #else
-            pendingSrc.prepend(QString(src.current(), src.length());
+       pendingSrc.prepend(QString(src.current(), src.length()));
  #endif
-            setSrc(pendingSrc);
-            pendingSrc = QString::null;
-        }
-        else if ( !prependingSrc.isEmpty() )
-            write( prependingSrc, false );
+       setSrc(pendingSrc);
+       pendingSrc = QString::null;
+    } else if ( !prependingSrc.isEmpty() ) {
+       write( prependingSrc, false );
      }
  }