<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[46418] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/46418">46418</a></dd>
<dt>Author</dt> <dd>zimmermann@webkit.org</dd>
<dt>Date</dt> <dd>2009-07-27 10:04:35 -0700 (Mon, 27 Jul 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WML] History handling / page cache / loading is buggy and depends on several hacks
https://bugs.webkit.org/show_bug.cgi?id=27707

Redesign WML history/loading handling. See ChangeLog for details.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestswmlresourcesWMLTestCasejs">trunk/LayoutTests/wml/resources/WMLTestCase.js</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoredomDocumentcpp">trunk/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkWebCoredomDocumenth">trunk/WebCore/dom/Document.h</a></li>
<li><a href="#trunkWebCorehistoryBackForwardListcpp">trunk/WebCore/history/BackForwardList.cpp</a></li>
<li><a href="#trunkWebCorehistoryBackForwardListh">trunk/WebCore/history/BackForwardList.h</a></li>
<li><a href="#trunkWebCoreloaderFrameLoadercpp">trunk/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkWebCoreloaderFrameLoaderh">trunk/WebCore/loader/FrameLoader.h</a></li>
<li><a href="#trunkWebCorewmlWMLCardElementcpp">trunk/WebCore/wml/WMLCardElement.cpp</a></li>
<li><a href="#trunkWebCorewmlWMLGoElementcpp">trunk/WebCore/wml/WMLGoElement.cpp</a></li>
<li><a href="#trunkWebCorewmlWMLPageStatecpp">trunk/WebCore/wml/WMLPageState.cpp</a></li>
<li><a href="#trunkWebCorewmlWMLPageStateh">trunk/WebCore/wml/WMLPageState.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestswmlentercardwitheventsexpectedtxt">trunk/LayoutTests/wml/enter-card-with-events-expected.txt</a></li>
<li><a href="#trunkLayoutTestswmlentercardwitheventshtml">trunk/LayoutTests/wml/enter-card-with-events.html</a></li>
<li><a href="#trunkLayoutTestswmlenterfirstcardwitheventsexpectedtxt">trunk/LayoutTests/wml/enter-first-card-with-events-expected.txt</a></li>
<li><a href="#trunkLayoutTestswmlenterfirstcardwitheventshtml">trunk/LayoutTests/wml/enter-first-card-with-events.html</a></li>
<li><a href="#trunkLayoutTestswmlresourcesentercardwitheventsjs">trunk/LayoutTests/wml/resources/enter-card-with-events.js</a></li>
<li><a href="#trunkLayoutTestswmlresourcesentercardwitheventswml">trunk/LayoutTests/wml/resources/enter-card-with-events.wml</a></li>
<li><a href="#trunkLayoutTestswmlresourcesenterfirstcardwitheventsjs">trunk/LayoutTests/wml/resources/enter-first-card-with-events.js</a></li>
<li><a href="#trunkLayoutTestswmlresourcesenterfirstcardwitheventswml">trunk/LayoutTests/wml/resources/enter-first-card-with-events.wml</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/LayoutTests/ChangeLog        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2009-07-27  Nikolas Zimmermann  &lt;nikolas.zimmermann@torchmobile.com&gt;
+
+        Reviewed by George Staikos.
+
+        [WML] History handling / page cache / loading is buggy and depends on several hacks
+        https://bugs.webkit.org/show_bug.cgi?id=27707
+
+        Add two new WML layout tests after redesigning WML history/loading handling.
+
+        * wml/enter-card-with-events-expected.txt: Added.
+        * wml/enter-card-with-events.html: Added.
+        * wml/enter-first-card-with-events-expected.txt: Added.
+        * wml/enter-first-card-with-events.html: Added.
+        * wml/resources/WMLTestCase.js:
+        * wml/resources/enter-card-with-events.js: Added.
+        (setupTestDocument):
+        (prepareTest):
+        (executeTest):
+        * wml/resources/enter-card-with-events.wml: Added.
+        * wml/resources/enter-first-card-with-events.js: Added.
+        (setupTestDocument):
+        (prepareTest):
+        (executeTest):
+        * wml/resources/enter-first-card-with-events.wml: Added.
+
</ins><span class="cx"> 2009-07-27  Jan Michael Alonzo  &lt;jmalonzo@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Add fast/canvas/image-pattern-rotate.html to Skipped as it needs
</span></span></pre></div>
<a id="trunkLayoutTestswmlentercardwitheventsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/wml/enter-card-with-events-expected.txt (0 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/wml/enter-card-with-events-expected.txt                                (rev 0)
+++ trunk/LayoutTests/wml/enter-card-with-events-expected.txt        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+WML layout tests - using XHTML scripting
+
+
+Tests entering cards in forward and backward directions that have intrinsic events set
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '&lt;!--framePath //&lt;!--frame0--&gt;--&gt;'
+--------
+Test 2/2 PASSED.
</ins></span></pre></div>
<a id="trunkLayoutTestswmlentercardwitheventshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/wml/enter-card-with-events.html (0 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/wml/enter-card-with-events.html                                (rev 0)
+++ trunk/LayoutTests/wml/enter-card-with-events.html        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;link rel=&quot;stylesheet&quot; href=&quot;../fast/js/resources/js-test-style.css&quot;&gt;
+&lt;script&gt;var relativePathToLayoutTests = &quot;..&quot;;&lt;/script&gt;
+&lt;script src=&quot;resources/WMLTestCase.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../fast/js/resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;h1&gt;WML layout tests - using XHTML scripting&lt;/h1&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;script src=&quot;resources/enter-card-with-events.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestswmlenterfirstcardwitheventsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/wml/enter-first-card-with-events-expected.txt (0 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/wml/enter-first-card-with-events-expected.txt                                (rev 0)
+++ trunk/LayoutTests/wml/enter-first-card-with-events-expected.txt        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+WML layout tests - using XHTML scripting
+
+
+Tests entering first card backwards that has intrinsic events set
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '&lt;!--framePath //&lt;!--frame0--&gt;--&gt;'
+--------
+Test 2/2 PASSED.
</ins></span></pre></div>
<a id="trunkLayoutTestswmlenterfirstcardwitheventshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/wml/enter-first-card-with-events.html (0 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/wml/enter-first-card-with-events.html                                (rev 0)
+++ trunk/LayoutTests/wml/enter-first-card-with-events.html        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;link rel=&quot;stylesheet&quot; href=&quot;../fast/js/resources/js-test-style.css&quot;&gt;
+&lt;script&gt;var relativePathToLayoutTests = &quot;..&quot;;&lt;/script&gt;
+&lt;script src=&quot;resources/WMLTestCase.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../fast/js/resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;h1&gt;WML layout tests - using XHTML scripting&lt;/h1&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;script src=&quot;resources/enter-first-card-with-events.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestswmlresourcesWMLTestCasejs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/wml/resources/WMLTestCase.js (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/wml/resources/WMLTestCase.js        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/LayoutTests/wml/resources/WMLTestCase.js        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -9,7 +9,7 @@
</span><span class="cx">     return testDocument.createElementNS(wmlNS, &quot;wml:&quot; + name);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function createWMLTestCase(testDescription, substitutesVariables, testName, executeImmediately) {
</del><ins>+function createWMLTestCase(testDescription, substitutesVariables, testName, executeImmediately, needsReset) {
</ins><span class="cx">     // Setup default test options
</span><span class="cx">     if (substitutesVariables == null) {
</span><span class="cx">         substitutesVariables = true;
</span><span class="lines">@@ -23,12 +23,18 @@
</span><span class="cx">         executeImmediately = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // Some tests may want to handle resetting the page state themselves
+    if (needsReset == null) {
+        needsReset = true;
+    }
+
</ins><span class="cx">     // Initialize JS test
</span><span class="cx">     description(testDescription);
</span><span class="cx">     bodyElement = document.getElementsByTagName(&quot;body&quot;)[0];
</span><span class="cx"> 
</span><span class="cx">     // Clear variable state &amp; history
</span><del>-    document.resetWMLPageState();
</del><ins>+    if (needsReset)
+        document.resetWMLPageState();
</ins><span class="cx"> 
</span><span class="cx">     // Setup DRT specific settings
</span><span class="cx">     if (window.layoutTestController) {
</span></span></pre></div>
<a id="trunkLayoutTestswmlresourcesentercardwitheventsjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/wml/resources/enter-card-with-events.js (0 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/wml/resources/enter-card-with-events.js                                (rev 0)
+++ trunk/LayoutTests/wml/resources/enter-card-with-events.js        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/// [Name] enter-card-with-events.js
+
+createWMLTestCase(&quot;Tests entering cards in forward and backward directions that have intrinsic events set&quot;, false, &quot;resources/enter-card-with-events.wml&quot;, false);
+
+var ranOnce = false;
+
+function setupTestDocument() {
+    // no-op
+}
+
+function prepareTest() {
+    startTest(25, 15);
+}
+
+function executeTest() {
+    if (ranOnce)
+        completeTest();
+    else {
+        ranOnce = true;
+        startTest(25, 15);
+    }
+}
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestswmlresourcesentercardwitheventswml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/wml/resources/enter-card-with-events.wml (0 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/wml/resources/enter-card-with-events.wml                                (rev 0)
+++ trunk/LayoutTests/wml/resources/enter-card-with-events.wml        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;!DOCTYPE wml PUBLIC &quot;-//WAPFORUM//DTD WML 1.3//EN&quot; &quot;http://www.wapforum.org/DTD/wml13.dtd&quot;&gt;
+&lt;wml&gt;
+    &lt;card id=&quot;card1&quot;&gt;
+        &lt;a href=&quot;#card2&quot;&gt;Next Card&lt;/a&gt;
+    &lt;/card&gt;
+
+    &lt;card id=&quot;card2&quot; onenterbackward=&quot;#card4&quot;&gt;
+        &lt;onevent type=&quot;onenterforward&quot;&gt;
+            &lt;go href=&quot;#card3&quot;/&gt;
+        &lt;/onevent&gt;
+        Test FAILED. (This card is NEVER visible to the user)
+    &lt;/card&gt;
+
+    &lt;card id=&quot;card3&quot;&gt;
+        &lt;anchor&gt;
+            &lt;prev/&gt;
+            Next Test
+        &lt;/anchor&gt;
+        Test 1/2 PASSED.
+    &lt;/card&gt;
+
+    &lt;card id=&quot;card4&quot;&gt;
+        Test 2/2 PASSED.
+    &lt;/card&gt;
+&lt;/wml&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestswmlresourcesenterfirstcardwitheventsjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/wml/resources/enter-first-card-with-events.js (0 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/wml/resources/enter-first-card-with-events.js                                (rev 0)
+++ trunk/LayoutTests/wml/resources/enter-first-card-with-events.js        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+/// [Name] enter-first-card-with-events.js
+
+createWMLTestCase(&quot;Tests entering first card backwards that has intrinsic events set&quot;, false, &quot;resources/enter-first-card-with-events.wml&quot;, false, false);
+
+var ranOnce = false;
+var resultIndicatorElement;
+
+function setupTestDocument() {
+    resultIndicatorElement = testDocument.getElementById(&quot;resultIndicator&quot;);
+}
+
+function prepareTest() {
+    if (resultIndicatorElement.textContent == &quot;DONE&quot;)
+        completeTest();
+    else
+        executeTest();
+}
+
+function executeTest() {
+    startTest(25, 15);
+}
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestswmlresourcesenterfirstcardwitheventswml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/wml/resources/enter-first-card-with-events.wml (0 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/wml/resources/enter-first-card-with-events.wml                                (rev 0)
+++ trunk/LayoutTests/wml/resources/enter-first-card-with-events.wml        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;!DOCTYPE wml PUBLIC &quot;-//WAPFORUM//DTD WML 1.3//EN&quot; &quot;http://www.wapforum.org/DTD/wml13.dtd&quot;&gt;
+&lt;wml&gt;
+    &lt;card id=&quot;card1&quot;&gt;
+        &lt;onevent type=&quot;onenterbackward&quot;&gt;
+            &lt;go href=&quot;#card3&quot;&gt;
+                &lt;setvar name=&quot;result&quot; value=&quot;DONE&quot;/&gt;
+            &lt;/go&gt;
+        &lt;/onevent&gt;
+        &lt;a href=&quot;#card2&quot;&gt;Next Test&lt;/a&gt;
+    &lt;/card&gt;
+
+    &lt;card id=&quot;card2&quot;&gt;
+        &lt;anchor&gt;
+            &lt;prev/&gt;
+            Next Test
+        &lt;/anchor&gt;
+        Test 1/2 PASSED.
+    &lt;/card&gt;
+
+    &lt;card id=&quot;card3&quot;&gt;
+        Test 2/2 PASSED.
+        &lt;p style=&quot;display: none&quot; id=&quot;resultIndicator&quot;&gt;$result&lt;/p&gt;
+    &lt;/card&gt;
+&lt;/wml&gt;
</ins></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/WebCore/ChangeLog        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -1,3 +1,68 @@
</span><ins>+2009-07-27  Nikolas Zimmermann  &lt;nikolas.zimmermann@torchmobile.com&gt;
+
+        Reviewed by George Staikos.
+
+        [WML] History handling / page cache / loading is buggy and depends on several hacks
+        https://bugs.webkit.org/show_bug.cgi?id=27707
+
+        Redesign WML history/loading handling. In detail:
+
+        - Remove FrameLoader::setForceReloadWmlDeck(). WML used to force a special loading behaviour
+          by calling this method from WMLGoElement &amp; friends - instead teach FrameLoader to detect
+          WML content itself.
+
+          WML content is usually a standalone WML document (isWMLDocument()=true) or as special case
+          an XHTML document which embeds a WML document (that's the way the WML layout tests work).
+          Force WML loading behaviour even for XHTML document which embed WML documents. This only
+          applies to our layout tests, not for any real world site. Though it gives us a perfect
+          way to test the WML loading code even when we're not operating on a standalone WML document.
+
+          Whenever a WMLCardElement is inserted into the document it will check wheter it's inserted
+          in a standalone WML document or wheter the main frame document is different. If it differs
+          the main frame documents' &quot;containsWMLContent&quot; property is set to true.
+
+          -&gt; Make FrameLoader::shouldReload() use the new frameContainsWMLContent() method, which
+             checks if the associated frame document is a WML document or wheter it contains WML content.
+
+        - Change FrameLoader::loadItem() to use the new frameContainsWMLContent() method for 'shouldScroll'
+          detection. WML documents (or those containing WML content) always want new loads even for in-page
+          navigation. No &quot;scroll to anchor&quot; mechanism should apply.
+
+        - Modify FrameLoader::canCachePageContainingThisFrame() to check for !frameContainsWMLContent().
+          WML pages should never be cached, potential security problem due the use of variables (per spec).
+
+        Add two new WML tests which were broken before, testing onenterforward/onenterbackward event handling
+        and history navigation (&lt;prev/&gt; task).
+
+        Tests: wml/enter-card-with-events.html
+               wml/enter-first-card-with-events.html
+
+        * dom/Document.cpp: Initialize new 'm_containsWMLContent' property.
+        (WebCore::Document::Document):
+        * dom/Document.h: Add new helper methods and 'm_containsWMLContent&quot; variable (explained above).
+        (WebCore::Document::setContainsWMLContent):
+        (WebCore::Document::containsWMLContent):
+        * history/BackForwardList.cpp:
+        (WebCore::BackForwardList::clearWMLPageHistory): Renamed from clearWmlPageHistory() &amp; slight cleanup.
+        * history/BackForwardList.h:
+        * loader/FrameLoader.cpp: Rework WML loading behaviour (explained above).
+        (WebCore::FrameLoader::FrameLoader):
+        (WebCore::frameContainsWMLContent):
+        (WebCore::FrameLoader::canCachePageContainingThisFrame):
+        (WebCore::FrameLoader::shouldReload):
+        (WebCore::FrameLoader::loadItem):
+        * loader/FrameLoader.h:
+        * wml/WMLCardElement.cpp: 
+        (WebCore::WMLCardElement::handleIntrinsicEventIfNeeded): No need anymore to manually track history length.
+        (WebCore::WMLCardElement::insertedIntoDocument): Handle setting containsWMLContent on the main frame document.
+        * wml/WMLGoElement.cpp: 
+        (WebCore::WMLGoElement::executeTask): Remove call to FrameLoader::setForceReloadWmlDeck()
+        * wml/WMLPageState.cpp: Remove 'm_historyLength' - no need anymore to track history length on our own.
+        (WebCore::WMLPageState::WMLPageState):
+        (WebCore::WMLPageState::dump):
+        (WebCore::WMLPageState::reset):
+        * wml/WMLPageState.h:
+
</ins><span class="cx"> 2009-07-27  Pavel Feldman  &lt;pfeldman@chromium.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Adam Roben.
</span></span></pre></div>
<a id="trunkWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/Document.cpp (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/Document.cpp        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/WebCore/dom/Document.cpp        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -335,6 +335,9 @@
</span><span class="cx">     , m_hasOpenDatabases(false)
</span><span class="cx"> #endif
</span><span class="cx">     , m_usingGeolocation(false)
</span><ins>+#if ENABLE(WML)
+    , m_containsWMLContent(false)
+#endif
</ins><span class="cx"> {
</span><span class="cx">     m_document.resetSkippingRef(this);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/Document.h (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/Document.h        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/WebCore/dom/Document.h        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -1034,6 +1034,9 @@
</span><span class="cx">     bool usingGeolocation() const { return m_usingGeolocation; };
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WML)
</span><ins>+    void setContainsWMLContent(bool value) { m_containsWMLContent = value; }
+    bool containsWMLContent() const { return m_containsWMLContent; }
+
</ins><span class="cx">     void resetWMLPageState();
</span><span class="cx">     void initializeWMLPageState();
</span><span class="cx"> #endif
</span><span class="lines">@@ -1116,6 +1119,10 @@
</span><span class="cx"> #endif
</span><span class="cx">     
</span><span class="cx">     bool m_usingGeolocation;
</span><ins>+
+#if ENABLE(WML)
+    bool m_containsWMLContent;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline bool Document::hasElementWithId(AtomicStringImpl* id) const
</span></span></pre></div>
<a id="trunkWebCorehistoryBackForwardListcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/history/BackForwardList.cpp (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/history/BackForwardList.cpp        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/WebCore/history/BackForwardList.cpp        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -266,11 +266,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WML)
</span><del>-void BackForwardList::clearWmlPageHistory()
</del><ins>+void BackForwardList::clearWMLPageHistory()
</ins><span class="cx"> {
</span><del>-    PassRefPtr&lt;HistoryItem&gt; cur = currentItem();
-
-    for (unsigned i = 0; i &lt; m_entries.size(); ++i)
</del><ins>+    int size = m_entries.size();
+    for (int i = 0; i &lt; size; ++i)
</ins><span class="cx">         pageCache()-&gt;remove(m_entries[i].get());
</span><span class="cx"> 
</span><span class="cx">     m_entries.clear();
</span></span></pre></div>
<a id="trunkWebCorehistoryBackForwardListh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/history/BackForwardList.h (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/history/BackForwardList.h        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/WebCore/history/BackForwardList.h        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -97,7 +97,7 @@
</span><span class="cx">     HistoryItemVector&amp; entries();
</span><span class="cx">     
</span><span class="cx"> #if ENABLE(WML)
</span><del>-    void clearWmlPageHistory();
</del><ins>+    void clearWMLPageHistory();
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/loader/FrameLoader.cpp (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/loader/FrameLoader.cpp        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/WebCore/loader/FrameLoader.cpp        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -271,9 +271,6 @@
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     , m_didDispatchDidCommitLoad(false)
</span><span class="cx"> #endif
</span><del>-#if ENABLE(WML)
-    , m_forceReloadWmlDeck(false)
-#endif
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1783,6 +1780,17 @@
</span><span class="cx">     write(bytes, length);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(WML)
+static inline bool frameContainsWMLContent(Frame* frame)
+{
+    Document* document = frame ? frame-&gt;document() : 0;
+    if (!document)
+        return false;
+
+    return document-&gt;containsWMLContent() || document-&gt;isWMLDocument();
+}
+#endif
+
</ins><span class="cx"> bool FrameLoader::canCachePageContainingThisFrame()
</span><span class="cx"> {
</span><span class="cx">     return m_documentLoader
</span><span class="lines">@@ -1811,6 +1819,9 @@
</span><span class="cx">         &amp;&amp; !m_documentLoader-&gt;applicationCache()
</span><span class="cx">         &amp;&amp; !m_documentLoader-&gt;candidateApplicationCacheGroup()
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(WML)
+        &amp;&amp; !frameContainsWMLContent(m_frame)
+#endif
</ins><span class="cx">         &amp;&amp; m_client-&gt;canCachePage()
</span><span class="cx">         ;
</span><span class="cx"> }
</span><span class="lines">@@ -2963,18 +2974,11 @@
</span><span class="cx">     m_quickRedirectComing = lockBackForwardList &amp;&amp; m_documentLoader &amp;&amp; !m_isExecutingJavaScriptFormAction;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if ENABLE(WML)
-void FrameLoader::setForceReloadWmlDeck(bool reload)
-{
-    m_forceReloadWmlDeck = reload;
-}
-#endif
-
</del><span class="cx"> bool FrameLoader::shouldReload(const KURL&amp; currentURL, const KURL&amp; destinationURL)
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(WML)
</span><del>-    // As for WML deck, sometimes it's supposed to be reloaded even if the same URL with fragment
-    if (m_forceReloadWmlDeck)
</del><ins>+    // All WML decks are supposed to be reloaded, even within the same URL fragment
+    if (frameContainsWMLContent(m_frame))
</ins><span class="cx">         return true;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -4429,7 +4433,8 @@
</span><span class="cx">     bool shouldScroll = !formData &amp;&amp; !(m_currentHistoryItem &amp;&amp; m_currentHistoryItem-&gt;formData()) &amp;&amp; urlsMatchItem(item);
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WML)
</span><del>-    if (m_frame-&gt;document()-&gt;isWMLDocument())
</del><ins>+    // All WML decks should go through the real load mechanism, not the scroll-to-anchor code
+    if (frameContainsWMLContent(m_frame))
</ins><span class="cx">         shouldScroll = false;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCoreloaderFrameLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/loader/FrameLoader.h (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/loader/FrameLoader.h        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/WebCore/loader/FrameLoader.h        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
</span><del>- * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
</del><ins>+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -236,10 +236,6 @@
</span><span class="cx"> 
</span><span class="cx">         void didFirstVisuallyNonEmptyLayout();
</span><span class="cx"> 
</span><del>-#if ENABLE(WML)
-        void setForceReloadWmlDeck(bool);
-#endif
-
</del><span class="cx">         void loadedResourceFromMemoryCache(const CachedResource*);
</span><span class="cx">         void tellClientAboutPastMemoryCacheLoads();
</span><span class="cx"> 
</span><span class="lines">@@ -625,10 +621,6 @@
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">         bool m_didDispatchDidCommitLoad;
</span><span class="cx"> #endif
</span><del>-
-#if ENABLE(WML)
-        bool m_forceReloadWmlDeck;
-#endif
</del><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkWebCorewmlWMLCardElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/wml/WMLCardElement.cpp (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/wml/WMLCardElement.cpp        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/WebCore/wml/WMLCardElement.cpp        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;MappedAttribute.h&quot;
</span><span class="cx"> #include &quot;NodeList.h&quot;
</span><ins>+#include &quot;Page.h&quot;
</ins><span class="cx"> #include &quot;RenderStyle.h&quot;
</span><span class="cx"> #include &quot;WMLDocument.h&quot;
</span><span class="cx"> #include &quot;WMLDoElement.h&quot;
</span><span class="lines">@@ -131,20 +132,21 @@
</span><span class="cx">     FrameLoader* loader = frame-&gt;loader();
</span><span class="cx">     if (!loader)
</span><span class="cx">         return;
</span><del>-    
-    int currentHistoryLength = loader-&gt;getHistoryLength();
-    int lastHistoryLength = pageState-&gt;historyLength();
</del><span class="cx"> 
</span><span class="cx">     // Calculate the entry method of current card 
</span><span class="cx">     WMLIntrinsicEventType eventType = WMLIntrinsicEventUnknown;
</span><del>-    if (lastHistoryLength &gt; currentHistoryLength)
</del><ins>+
+    switch (loader-&gt;loadType()) {
+    case FrameLoadTypeReload:
+        break;
+    case FrameLoadTypeBack:
</ins><span class="cx">         eventType = WMLIntrinsicEventOnEnterBackward;
</span><del>-    else if (lastHistoryLength &lt; currentHistoryLength)
</del><ins>+        break;
+    default:
</ins><span class="cx">         eventType = WMLIntrinsicEventOnEnterForward;
</span><ins>+        break;
+    }
</ins><span class="cx"> 
</span><del>-    // Synchronize history length with WMLPageState
-    pageState-&gt;setHistoryLength(currentHistoryLength);

</del><span class="cx">     // Figure out target event handler
</span><span class="cx">     WMLIntrinsicEventHandler* eventHandler = this-&gt;eventHandler();
</span><span class="cx">     bool hasIntrinsicEvent = false;
</span><span class="lines">@@ -241,13 +243,25 @@
</span><span class="cx"> void WMLCardElement::insertedIntoDocument()
</span><span class="cx"> {
</span><span class="cx">     WMLElement::insertedIntoDocument();
</span><ins>+    Document* document = this-&gt;document();
</ins><span class="cx"> 
</span><span class="cx">     // The first card inserted into a document, is visible by default.
</span><span class="cx">     if (!m_isVisible) {
</span><del>-        RefPtr&lt;NodeList&gt; nodeList = document()-&gt;getElementsByTagName(&quot;card&quot;);
</del><ins>+        RefPtr&lt;NodeList&gt; nodeList = document-&gt;getElementsByTagName(&quot;card&quot;);
</ins><span class="cx">         if (nodeList &amp;&amp; nodeList-&gt;length() == 1 &amp;&amp; nodeList-&gt;item(0) == this)
</span><span class="cx">             m_isVisible = true;
</span><span class="cx">     }
</span><ins>+
+    // For the WML layout tests we embed WML content in a XHTML document. Navigating to different cards
+    // within the same deck has a different behaviour in HTML than in WML. HTML wants to &quot;scroll to anchor&quot;
+    // (see FrameLoader) but WML wants a reload. Notify the root document of the layout test that we want
+    // to mimic WML behaviour. This is rather tricky, but has been tested extensively. Usually it's not possible
+    // at all to embed WML in HTML, it's not designed that way, we're just &quot;abusing&quot; it for dynamically created layout tests.
+    if (document-&gt;page() &amp;&amp; document-&gt;page()-&gt;mainFrame()) {
+        Document* rootDocument = document-&gt;page()-&gt;mainFrame()-&gt;document();
+        if (rootDocument &amp;&amp; rootDocument != document)
+            rootDocument-&gt;setContainsWMLContent(true);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RenderObject* WMLCardElement::createRenderer(RenderArena* arena, RenderStyle* style) 
</span></span></pre></div>
<a id="trunkWebCorewmlWMLGoElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/wml/WMLGoElement.cpp (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/wml/WMLGoElement.cpp        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/WebCore/wml/WMLGoElement.cpp        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /**
</span><del>- * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
</del><ins>+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
</ins><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="cx">  * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -102,9 +102,6 @@
</span><span class="cx">     // FIXME: 'newcontext' handling not implemented for external cards
</span><span class="cx">     bool inSameDeck = doc-&gt;url().path() == url.path();
</span><span class="cx">     if (inSameDeck &amp;&amp; url.hasRef()) {
</span><del>-        // Force frame loader to load the URL with fragment identifier
-        loader-&gt;setForceReloadWmlDeck(true);
-
</del><span class="cx">         if (WMLCardElement* card = WMLCardElement::findNamedCardInDocument(doc, url.ref())) {
</span><span class="cx">             if (card-&gt;isNewContext())
</span><span class="cx">                 pageState-&gt;reset();
</span></span></pre></div>
<a id="trunkWebCorewmlWMLPageStatecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/wml/WMLPageState.cpp (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/wml/WMLPageState.cpp        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/WebCore/wml/WMLPageState.cpp        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -1,6 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
- *
</del><ins>+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
</ins><span class="cx">  * Copyright (C) 2004-2007 Apple Inc. All rights reserved.
</span><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="lines">@@ -25,6 +24,7 @@
</span><span class="cx"> #if ENABLE(WML)
</span><span class="cx"> #include &quot;WMLPageState.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CString.h&quot;
</ins><span class="cx"> #include &quot;HistoryItem.h&quot;
</span><span class="cx"> #include &quot;KURL.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="lines">@@ -33,7 +33,6 @@
</span><span class="cx"> 
</span><span class="cx"> WMLPageState::WMLPageState(Page* page)
</span><span class="cx">     : m_page(page)
</span><del>-    , m_historyLength(0)
</del><span class="cx">     , m_activeCard(0)
</span><span class="cx">     , m_hasDeckAccess(false)
</span><span class="cx"> {
</span><span class="lines">@@ -44,17 +43,27 @@
</span><span class="cx">     m_variables.clear();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#ifndef NDEBUG
+// Debugging helper for use within gdb
+void WMLPageState::dump()
+{
+    WMLVariableMap::iterator it = m_variables.begin();
+    WMLVariableMap::iterator end = m_variables.end();
+
+    fprintf(stderr, &quot;Dumping WMLPageState (this=%p) associated with Page (page=%p)...\n&quot;, this, m_page);
+    for (; it != end; ++it)
+        fprintf(stderr, &quot;\t-&gt; name: '%s'\tvalue: '%s'\n&quot;, (*it).first.latin1().data(), (*it).second.latin1().data());
+}
+#endif
+
</ins><span class="cx"> void WMLPageState::reset()
</span><span class="cx"> {
</span><del>-    // remove all the variables in the current browser context
</del><ins>+    // Remove all the variables
</ins><span class="cx">     m_variables.clear();
</span><span class="cx"> 
</span><del>-    // clear the navigation history state 
-    if (m_page)
-        m_page-&gt;backForwardList()-&gt;clearWmlPageHistory();
-
-    // reset implementation-specfic state if UA has
-    m_historyLength = 0;
</del><ins>+    // Clear the navigation history state 
+    if (BackForwardList* list = m_page ? m_page-&gt;backForwardList() : 0)
+        list-&gt;clearWMLPageHistory();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WMLPageState::setNeedCheckDeckAccess(bool need)
</span></span></pre></div>
<a id="trunkWebCorewmlWMLPageStateh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/wml/WMLPageState.h (46417 => 46418)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/wml/WMLPageState.h        2009-07-27 15:09:17 UTC (rev 46417)
+++ trunk/WebCore/wml/WMLPageState.h        2009-07-27 17:04:35 UTC (rev 46418)
</span><span class="lines">@@ -39,6 +39,10 @@
</span><span class="cx">     WMLPageState(Page*);
</span><span class="cx">     virtual ~WMLPageState();
</span><span class="cx"> 
</span><ins>+#ifndef NDEBUG
+    void dump();
+#endif
+
</ins><span class="cx">     // reset the browser context when 'newcontext' attribute
</span><span class="cx">     // of card element is performed as part of go task
</span><span class="cx">     void reset();
</span></span></pre>
</div>
</div>

</body>
</html>