Make the view source document properly handle <script>. We don't syntax
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jun 2006 20:43:18 +0000 (20:43 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jun 2006 20:43:18 +0000 (20:43 +0000)
        highlight the JS yet, but it shows up properly now.

        Reviewed by john

        * WebCore.xcodeproj/project.pbxproj:
        * html/HTMLTokenizer.cpp:
        (WebCore::HTMLTokenizer::scriptHandler):

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

WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/html/HTMLTokenizer.cpp

index 5ca99ecd25276c669cfb7a59eb2e60f0d9e6c7de..fde8b61743618551ae0db7da7771ec45cee8f6dc 100644 (file)
@@ -1,3 +1,14 @@
+2006-06-28  David Hyatt  <hyatt@apple.com>
+
+        Make the view source document properly handle <script>.  We don't syntax
+        highlight the JS yet, but it shows up properly now.
+
+        Reviewed by john
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/HTMLTokenizer.cpp:
+        (WebCore::HTMLTokenizer::scriptHandler):
+
 2006-06-28  Timothy Hatcher  <timothy@apple.com>
 
         Prefer the Stabs debugging symbols format until DWARF bugs are fixed.
index 1c5d28f99d538da58000ac1370bc4563aa5e79df..007b17ef6c05f32f38ca7605583258b326106256 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildStyle section */
+               BCEED0480A530A0A00443D9A /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               BCEED0490A530A0A00443D9A /* Deployment */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                       };
+                       name = Deployment;
+               };
+/* End PBXBuildStyle section */
+
 /* Begin PBXContainerItemProxy section */
                DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+                       buildSettings = {
+                       };
+                       buildStyles = (
+                               BCEED0480A530A0A00443D9A /* Development */,
+                               BCEED0490A530A0A00443D9A /* Deployment */,
+                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index 37df2c63a19e899a7a9a513a19077fa453699e54..093b9c909ab711459581325824501f21d3b78807 100644 (file)
@@ -355,31 +355,34 @@ HTMLTokenizer::State HTMLTokenizer::scriptHandler(State state)
   
     CachedScript* cs = 0;
     // don't load external scripts for standalone documents (for now)
-    if (!scriptSrc.isEmpty() && m_doc->frame()) {
-        // forget what we just got; load from src url instead
-        if (!parser->skipMode() && !followingFrameset) {
-#if INSTRUMENT_LAYOUT_SCHEDULING
-            if (!m_doc->ownerElement())
-                printf("Requesting script at time %d\n", m_doc->elapsedTime());
-#endif
-            if ( (cs = m_doc->docLoader()->requestScript(scriptSrc, scriptSrcCharset) ))
-                pendingScripts.enqueue(cs);
-            else
+    if (!inViewSourceMode()) {
+        if (!scriptSrc.isEmpty() && m_doc->frame()) {
+            // forget what we just got; load from src url instead
+            if (!parser->skipMode() && !followingFrameset) {
+    #if INSTRUMENT_LAYOUT_SCHEDULING
+                if (!m_doc->ownerElement())
+                    printf("Requesting script at time %d\n", m_doc->elapsedTime());
+    #endif
+                if ( (cs = m_doc->docLoader()->requestScript(scriptSrc, scriptSrcCharset) ))
+                    pendingScripts.enqueue(cs);
+                else
+                    scriptNode = 0;
+            } else
                 scriptNode = 0;
-        } else
+            scriptSrc=DeprecatedString::null;
+        }
+        else {
+    #ifdef TOKEN_DEBUG
+            kdDebug( 6036 ) << "---START SCRIPT---" << endl;
+            kdDebug( 6036 ) << DeprecatedString(scriptCode, scriptCodeSize) << endl;
+            kdDebug( 6036 ) << "---END SCRIPT---" << endl;
+    #endif
             scriptNode = 0;
-        scriptSrc=DeprecatedString::null;
-    }
-    else {
-#ifdef TOKEN_DEBUG
-        kdDebug( 6036 ) << "---START SCRIPT---" << endl;
-        kdDebug( 6036 ) << DeprecatedString(scriptCode, scriptCodeSize) << endl;
-        kdDebug( 6036 ) << "---END SCRIPT---" << endl;
-#endif
-        scriptNode = 0;
-        // Parse scriptCode containing <script> info
-        doScriptExec = true;
+            // Parse scriptCode containing <script> info
+            doScriptExec = true;
+        }
     }
+
     state = processListing(SegmentedString(scriptCode, scriptCodeSize), state);
     DeprecatedString exScript(reinterpret_cast<QChar*>(buffer), dest - buffer);
     processToken();
@@ -387,10 +390,15 @@ HTMLTokenizer::State HTMLTokenizer::scriptHandler(State state)
     currToken.beginTag = false;
     processToken();
 
+    state.setInScript(false);
+    
+    // FIXME: The script should be syntax highlighted.
+    if (inViewSourceMode())
+        return state;
+
     SegmentedString *savedPrependingSrc = currentPrependingSrc;
     SegmentedString prependingSrc;
     currentPrependingSrc = &prependingSrc;
-    state.setInScript(false);
     scriptCodeSize = scriptCodeResync = 0;
 
     if (!parser->skipMode() && !followingFrameset) {