<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[20677] trunk/WebCore</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/20677">20677</a></dd>
<dt>Author</dt> <dd>bdash</dd>
<dt>Date</dt> <dd>2007-04-03 05:51:55 -0700 (Tue, 03 Apr 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>2007-04-03  Mitz Pettel  &lt;mitz@webkit.org&gt;

        Reviewed by Darin.

        - fix http://bugs.webkit.org/show_bug.cgi?id=13218
          &lt;rdar://problem/5095977&gt;
          Reproducible crash after call to window.close()

        * manual-tests/stale-currentEvent.html: Added.
        * page/EventHandler.cpp:
        (WebCore::EventHandler::hoverTimerFired): Instead of faking a mouse event,
        just hit-test the last mouse event coordinates and update for hover state
        changes. This eliminates the use of currentEvent, which can be a non-mouse
        event or even a stale event.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorepageEventHandlercpp">trunk/WebCore/page/EventHandler.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkWebCoremanualtestsstalecurrentEventhtml">trunk/WebCore/manual-tests/stale-currentEvent.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (20676 => 20677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-04-03 11:24:41 UTC (rev 20676)
+++ trunk/WebCore/ChangeLog        2007-04-03 12:51:55 UTC (rev 20677)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2007-04-03  Mitz Pettel  &lt;mitz@webkit.org&gt;
+
+        Reviewed by Darin.
+
+        - fix http://bugs.webkit.org/show_bug.cgi?id=13218
+          &lt;rdar://problem/5095977&gt;
+          Reproducible crash after call to window.close()
+
+        * manual-tests/stale-currentEvent.html: Added.
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::hoverTimerFired): Instead of faking a mouse event,
+        just hit-test the last mouse event coordinates and update for hover state
+        changes. This eliminates the use of currentEvent, which can be a non-mouse
+        event or even a stale event.
+
</ins><span class="cx"> 2007-04-02  Adele Peterson  &lt;adele@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Maciej.
</span></span></pre></div>
<a id="trunkWebCoremanualtestsstalecurrentEventhtml"></a>
<div class="addfile"><h4>Added: trunk/WebCore/manual-tests/stale-currentEvent.html (0 => 20677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/manual-tests/stale-currentEvent.html                                (rev 0)
+++ trunk/WebCore/manual-tests/stale-currentEvent.html        2007-04-03 12:51:55 UTC (rev 20677)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot;
+        &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
+&lt;html lang=&quot;en&quot;&gt;
+&lt;head&gt;
+    &lt;script type=&quot;text/javascript&quot;&gt;
+        var inner_win;
+
+        function open_inner()
+        {
+            var src = 'data:text/html,&lt;title&gt;Pop up&lt;/title&gt;&lt;input type=&quot;button&quot; value=&quot;Close&quot; onclick=&quot;opener.closeChild()&quot;&gt;';
+            var tp = document.getElementById(&quot;theparent&quot;);
+            inner_win = window.open(src, 'inner', 'width=200, height=200, left=' + (screenLeft + tp.offsetLeft) + ', top=' + (screenTop + outerHeight - innerHeight + tp.offsetTop));
+        }
+
+        function removeHoverNode()
+        {
+            var tp = document.getElementById(&quot;theparent&quot;);
+            tp.parentNode.removeChild(tp);
+            setTimeout(reportSuccess, 500);
+        }
+
+        function reportSuccess()
+        {
+            document.body.appendChild(document.createTextNode(&quot;SUCCESS&quot;));
+        }
+
+        function closeChild()
+        {
+            inner_win.close();
+            document.body.offsetTop;
+            setTimeout(removeHoverNode, 100);
+        }
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;&lt;b&gt;BUG ID:&lt;/b&gt; &lt;a href=&quot;rdar://problem/5095977&quot;&gt;5095997&lt;/a&gt; (&lt;a href=&quot;http://bugs.webkit.org/show_bug.cgi?id=13218&quot;&gt;13218&lt;/a&gt;) Reproducible crash after call to window.close()&lt;/p&gt;
+
+&lt;p id=&quot;test&quot; style=&quot;background-color:skyblue; padding:3px;&quot;&gt;&lt;b&gt;STEPS TO TEST:&lt;/b&gt;&lt;br&gt;
+    1. Click the Open button below. A pop up window will open.&lt;br&gt;
+    2. In the pop up window, click the Close button, being careful not to
+    move the mouse during and shortly after clicking.
+&lt;/p&gt;
+
+&lt;p id=&quot;success&quot; style=&quot;background-color:palegreen; padding:3px;&quot;&gt;&lt;b&gt;TEST PASS:&lt;/b&gt; 
+    The black square will be replaced by the word &amp;ldquo;SUCCESS&amp;rdquo; and Safari will not crash.
+&lt;/p&gt;
+
+&lt;p id=&quot;failure&quot; style=&quot;background-color:#FF3300; padding:3px;&quot;&gt;&lt;b&gt;TEST FAIL:&lt;/b&gt;  
+    Safari will crash (the word &amp;ldquo;SUCCESS&amp;rdquo; may appear before the crash).
+&lt;/p&gt;
+    &lt;div id='theparent'&gt;
+        &lt;input type=&quot;button&quot; value=&quot;Open&quot; onclick=&quot;open_inner()&quot;&gt;
+        &lt;div style=&quot;background: black; width: 200px; height:200px&quot;&gt;
+        &lt;/div&gt;
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkWebCorepageEventHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/page/EventHandler.cpp (20676 => 20677)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/page/EventHandler.cpp        2007-04-03 11:24:41 UTC (rev 20676)
+++ trunk/WebCore/page/EventHandler.cpp        2007-04-03 12:51:55 UTC (rev 20677)
</span><span class="lines">@@ -1243,7 +1243,16 @@
</span><span class="cx"> void EventHandler::hoverTimerFired(Timer&lt;EventHandler&gt;*)
</span><span class="cx"> {
</span><span class="cx">     m_hoverTimer.stop();
</span><del>-    prepareMouseEvent(HitTestRequest(false, false, true), PlatformMouseEvent(PlatformMouseEvent::currentEvent));
</del><ins>+
+    ASSERT(m_frame);
+    ASSERT(m_frame-&gt;document());
+
+    if (RenderObject* renderer = m_frame-&gt;renderer()) {
+        IntPoint documentPoint = m_frame-&gt;view()-&gt;windowToContents(m_currentMousePosition);
+        HitTestResult result(documentPoint);
+        renderer-&gt;layer()-&gt;hitTest(HitTestRequest(false, false, true), result);
+        m_frame-&gt;document()-&gt;updateRendering();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static EventTargetNode* eventTargetNodeForDocument(Document* doc)
</span></span></pre>
</div>
</div>

</body>
</html>