Reviewed by John.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Jul 2004 22:45:51 +0000 (22:45 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Jul 2004 22:45:51 +0000 (22:45 +0000)
<rdar://problem/3740855> REGRESSION: Flash incorrectly positioned at macromedia.com

        * khtml/html/htmltokenizer.cpp:
        (khtml::HTMLTokenizer::scriptExecution): Do the prepending-src
trick as for inline script execution.

Added new layout tests covering this and other recent tokenizer
bugs.

        * layout-tests/fast/tokenizer/001-expected.txt: Added.
        * layout-tests/fast/tokenizer/001.html: Added.
        * layout-tests/fast/tokenizer/002-expected.txt: Added.
        * layout-tests/fast/tokenizer/002.html: Added.
        * layout-tests/fast/tokenizer/003-expected.txt: Added.
        * layout-tests/fast/tokenizer/003.html: Added.
        * layout-tests/fast/tokenizer/resources/003-script.js: Added.

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

LayoutTests/fast/tokenizer/001-expected.txt [new file with mode: 0644]
LayoutTests/fast/tokenizer/001.html [new file with mode: 0644]
LayoutTests/fast/tokenizer/002-expected.txt [new file with mode: 0644]
LayoutTests/fast/tokenizer/002.html [new file with mode: 0644]
LayoutTests/fast/tokenizer/003-expected.txt [new file with mode: 0644]
LayoutTests/fast/tokenizer/003.html [new file with mode: 0644]
LayoutTests/fast/tokenizer/resources/003-script.js [new file with mode: 0644]
WebCore/ChangeLog-2005-08-23
WebCore/khtml/html/htmltokenizer.cpp

diff --git a/LayoutTests/fast/tokenizer/001-expected.txt b/LayoutTests/fast/tokenizer/001-expected.txt
new file mode 100644 (file)
index 0000000..4c0654f
--- /dev/null
@@ -0,0 +1,9 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#FF0000]
+      RenderBlock {P} at (0,116) size 784x18
+        RenderText {TEXT} at (0,0) size 254x18
+          text run at (0,0) width 254: "there should be a red box above this text"
diff --git a/LayoutTests/fast/tokenizer/001.html b/LayoutTests/fast/tokenizer/001.html
new file mode 100644 (file)
index 0000000..d863966
--- /dev/null
@@ -0,0 +1,6 @@
+<script>
+document.write ('<script src="nonexistent.js"></scr' + 'ipt><div ');
+document.write ('style="width: 100; height: 100; background-color: red"></div>');
+</script>
+<p>there should be a red box above this text</p>
+
diff --git a/LayoutTests/fast/tokenizer/002-expected.txt b/LayoutTests/fast/tokenizer/002-expected.txt
new file mode 100644 (file)
index 0000000..5536e4d
--- /dev/null
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x34
+  RenderBlock {HTML} at (0,0) size 800x34
+    RenderBody {BODY} at (8,8) size 784x18
+      RenderText {TEXT} at (0,0) size 315x18
+        text run at (0,0) width 315: "you shouldn't see a random chinese character here"
diff --git a/LayoutTests/fast/tokenizer/002.html b/LayoutTests/fast/tokenizer/002.html
new file mode 100644 (file)
index 0000000..7394ebb
--- /dev/null
@@ -0,0 +1,5 @@
+<script>
+document.write("<script src>");
+document.writeln("</scr" + "ipt>");
+</script>
+you shouldn't see a random chinese character here
diff --git a/LayoutTests/fast/tokenizer/003-expected.txt b/LayoutTests/fast/tokenizer/003-expected.txt
new file mode 100644 (file)
index 0000000..6abca62
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#FF0000]
+      RenderBlock {DIV} at (0,100) size 784x18
+        RenderBlock (anonymous) at (0,0) size 784x18
+          RenderText {TEXT} at (0,0) size 211x18
+            text run at (0,0) width 211: "This should be below the red box"
+        RenderBlock {DIV} at (0,18) size 784x0
diff --git a/LayoutTests/fast/tokenizer/003.html b/LayoutTests/fast/tokenizer/003.html
new file mode 100644 (file)
index 0000000..4619a3b
--- /dev/null
@@ -0,0 +1,7 @@
+<body>
+
+<script type="text/javascript" language="JavaScript" src="resources/003-script.js"></script>
+
+<div>This should be below the red box<div>
+
+</body>
diff --git a/LayoutTests/fast/tokenizer/resources/003-script.js b/LayoutTests/fast/tokenizer/resources/003-script.js
new file mode 100644 (file)
index 0000000..46f216d
--- /dev/null
@@ -0,0 +1 @@
+document.writeln('<div style="width: 100; height: 100; background-color: red"></div>');
index 21382e8740ee98ed4283b5b560c76424c9a0553b..2ef72dab82ef1d504317ba0b4a5688b1bed49303 100644 (file)
@@ -1,3 +1,24 @@
+2004-07-26  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by John.
+
+       <rdar://problem/3740855> REGRESSION: Flash incorrectly positioned at macromedia.com
+        
+        * khtml/html/htmltokenizer.cpp:
+        (khtml::HTMLTokenizer::scriptExecution): Do the prepending-src
+       trick as for inline script execution.
+
+       Added new layout tests covering this and other recent tokenizer
+       bugs.
+       
+        * layout-tests/fast/tokenizer/001-expected.txt: Added.
+        * layout-tests/fast/tokenizer/001.html: Added.
+        * layout-tests/fast/tokenizer/002-expected.txt: Added.
+        * layout-tests/fast/tokenizer/002.html: Added.
+        * layout-tests/fast/tokenizer/003-expected.txt: Added.
+        * layout-tests/fast/tokenizer/003.html: Added.
+        * layout-tests/fast/tokenizer/resources/003-script.js: Added.
+
 2004-07-23  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Trey
index 6c0748de6b9cd32250512f135b9eea23be7d9588..e6241e752ef5cb09b2e18f5a027a6d20fe494d91 100644 (file)
@@ -580,9 +580,39 @@ void HTMLTokenizer::scriptExecution( const QString& str, QString scriptURL,
     else
       url = scriptURL;
 
+    TokenizerString *savedPrependingSrc = currentPrependingSrc;
+    TokenizerString prependingSrc;
+    currentPrependingSrc = &prependingSrc;
+
     view->part()->executeScript(url,baseLine,Node(),str);
+
     m_executingScript--;
     script = oldscript;
+
+    if ( !m_executingScript && !loadingExtScript ) {
+       // kdDebug( 6036 ) << "adding pending Output to parsed string" << endl;
+       src.append(pendingSrc);
+       pendingSrc.clear();
+    } else if (!prependingSrc.isEmpty()) {
+       // restore first so that the write appends in the right place
+       // (does not hurt to do it again below)
+       currentPrependingSrc = savedPrependingSrc;
+
+       // we need to do this slightly modified bit of one of the write() cases
+       // because we want to prepend to pendingSrc rather than appending
+       // if there's no previous prependingSrc
+       if (loadingExtScript) {
+           if (currentPrependingSrc) {
+               currentPrependingSrc->append(prependingSrc);
+           } else {
+               pendingSrc.prepend(prependingSrc);
+           }
+       } else {
+           write(prependingSrc, false);
+       }
+    }
+
+    currentPrependingSrc = savedPrependingSrc;
 }
 
 void HTMLTokenizer::parseComment(TokenizerString &src)