<!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>[42373] trunk/WebCore</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/42373">42373</a></dd>
<dt>Author</dt> <dd>dimich@chromium.org</dd>
<dt>Date</dt> <dd>2009-04-09 15:42:10 -0700 (Thu, 09 Apr 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>2009-04-09  Jian Li  &lt;jianli@chromium.org&gt;

        Reviewed by Dimitri Glazkov.

        https://bugs.webkit.org/show_bug.cgi?id=25084
        Upstream changes to V8 bindings for XHR so that it can work under either DOMWindow or WorkerContext.

        * bindings/v8/WorkerContextExecutionProxy.cpp:
        (WebCore::WorkerContextExecutionProxy::dispose):
        (WebCore::WorkerContextExecutionProxy::retrieve):
        (WebCore::WorkerContextExecutionProxy::initContextIfNeeded):
        (WebCore::WorkerContextExecutionProxy::findOrCreateEventListenerHelper):
        (WebCore::WorkerContextExecutionProxy::FindOrCreateEventListener):
        (WebCore::WorkerContextExecutionProxy::findOrCreateObjectEventListener):
        * bindings/v8/WorkerContextExecutionProxy.h:
        * bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
        (WebCore::CALLBACK_FUNC_DECL):
        * bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
        (WebCore::getEventListener):
        (WebCore::ACCESSOR_SETTER):
        (WebCore::CALLBACK_FUNC_DECL):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorebindingsv8WorkerContextExecutionProxycpp">trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp</a></li>
<li><a href="#trunkWebCorebindingsv8WorkerContextExecutionProxyh">trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.h</a></li>
<li><a href="#trunkWebCorebindingsv8customV8XMLHttpRequestConstructorcpp">trunk/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp</a></li>
<li><a href="#trunkWebCorebindingsv8customV8XMLHttpRequestCustomcpp">trunk/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (42372 => 42373)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2009-04-09 22:40:05 UTC (rev 42372)
+++ trunk/WebCore/ChangeLog        2009-04-09 22:42:10 UTC (rev 42373)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2009-04-09  Jian Li  &lt;jianli@chromium.org&gt;
+
+        Reviewed by Dimitri Glazkov.
+
+        https://bugs.webkit.org/show_bug.cgi?id=25084
+        Upstream changes to V8 bindings for XHR so that it can work under either DOMWindow or WorkerContext.
+
+        * bindings/v8/WorkerContextExecutionProxy.cpp:
+        (WebCore::WorkerContextExecutionProxy::dispose):
+        (WebCore::WorkerContextExecutionProxy::retrieve):
+        (WebCore::WorkerContextExecutionProxy::initContextIfNeeded):
+        (WebCore::WorkerContextExecutionProxy::findOrCreateEventListenerHelper):
+        (WebCore::WorkerContextExecutionProxy::FindOrCreateEventListener):
+        (WebCore::WorkerContextExecutionProxy::findOrCreateObjectEventListener):
+        * bindings/v8/WorkerContextExecutionProxy.h:
+        * bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
+        (WebCore::CALLBACK_FUNC_DECL):
+        * bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
+        (WebCore::getEventListener):
+        (WebCore::ACCESSOR_SETTER):
+        (WebCore::CALLBACK_FUNC_DECL):
+
</ins><span class="cx"> 2009-04-09  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Anders Carlsson and Sam Weinig.
</span></span></pre></div>
<a id="trunkWebCorebindingsv8WorkerContextExecutionProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp (42372 => 42373)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp        2009-04-09 22:40:05 UTC (rev 42372)
+++ trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp        2009-04-09 22:42:10 UTC (rev 42373)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> #include &quot;V8Proxy.h&quot;
</span><span class="cx"> #include &quot;Event.h&quot;
</span><span class="cx"> #include &quot;V8WorkerContextEventListener.h&quot;
</span><ins>+#include &quot;V8WorkerContextObjectEventListener.h&quot;
</ins><span class="cx"> #include &quot;WorkerContext.h&quot;
</span><span class="cx"> #include &quot;WorkerLocation.h&quot;
</span><span class="cx"> #include &quot;WorkerNavigator.h&quot;
</span><span class="lines">@@ -106,7 +107,7 @@
</span><span class="cx">     v8::HandleScope scope;
</span><span class="cx">     v8::Persistent&lt;v8::Object&gt; wrapper = domObjectMap().get(m_workerContext);
</span><span class="cx">     if (!wrapper.IsEmpty())
</span><del>-        V8Proxy::SetDOMWrapper(wrapper, V8ClassIndex::INVALID_CLASS_INDEX, NULL);
</del><ins>+        V8Proxy::SetDOMWrapper(wrapper, V8ClassIndex::INVALID_CLASS_INDEX, 0);
</ins><span class="cx">     domObjectMap().forget(m_workerContext);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -115,7 +116,9 @@
</span><span class="cx">     v8::Handle&lt;v8::Context&gt; context = v8::Context::GetCurrent();
</span><span class="cx">     v8::Handle&lt;v8::Object&gt; global = context-&gt;Global();
</span><span class="cx">     global = V8Proxy::LookupDOMWrapper(V8ClassIndex::WORKERCONTEXT, global);
</span><del>-    ASSERT(!global.IsEmpty());
</del><ins>+    // Return 0 if the current executing context is not the worker context.
+    if (global.IsEmpty())
+        return 0;
</ins><span class="cx">     WorkerContext* workerContext = V8Proxy::ToNativeObject&lt;WorkerContext&gt;(V8ClassIndex::WORKERCONTEXT, global);
</span><span class="cx">     return workerContext-&gt;script()-&gt;proxy();
</span><span class="cx"> }
</span><span class="lines">@@ -128,7 +131,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Create a new environment
</span><span class="cx">     v8::Persistent&lt;v8::ObjectTemplate&gt; globalTemplate;
</span><del>-    m_context = v8::Context::New(NULL, globalTemplate);
</del><ins>+    m_context = v8::Context::New(0, globalTemplate);
</ins><span class="cx"> 
</span><span class="cx">     // Starting from now, use local context only.
</span><span class="cx">     v8::Local&lt;v8::Context&gt; context = v8::Local&lt;v8::Context&gt;::New(m_context);
</span><span class="lines">@@ -330,7 +333,7 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;V8EventListener&gt; WorkerContextExecutionProxy::FindOrCreateEventListener(v8::Local&lt;v8::Value&gt; object, bool isInline, bool findOnly)
</del><ins>+PassRefPtr&lt;V8EventListener&gt; WorkerContextExecutionProxy::findOrCreateEventListenerHelper(v8::Local&lt;v8::Value&gt; object, bool isInline, bool findOnly, bool createObjectEventListener)
</ins><span class="cx"> {
</span><span class="cx">     if (!object-&gt;IsObject())
</span><span class="cx">         return 0;
</span><span class="lines">@@ -340,7 +343,11 @@
</span><span class="cx">         return listener;
</span><span class="cx"> 
</span><span class="cx">     // Create a new one, and add to cache.
</span><del>-    RefPtr&lt;V8WorkerContextEventListener&gt; newListener = V8WorkerContextEventListener::create(this, v8::Local&lt;v8::Object&gt;::Cast(object), isInline);
</del><ins>+    RefPtr&lt;V8EventListener&gt; newListener;
+    if (createObjectEventListener)
+        newListener = V8WorkerContextObjectEventListener::create(this, v8::Local&lt;v8::Object&gt;::Cast(object), isInline);
+    else
+        newListener = V8WorkerContextEventListener::create(this, v8::Local&lt;v8::Object&gt;::Cast(object), isInline);
</ins><span class="cx">     {
</span><span class="cx">         // Need to use lock since V8EventListenerList::add() creates HandleScope.
</span><span class="cx">         v8::Locker locker;
</span><span class="lines">@@ -350,6 +357,16 @@
</span><span class="cx">     return newListener.release();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+PassRefPtr&lt;V8EventListener&gt; WorkerContextExecutionProxy::FindOrCreateEventListener(v8::Local&lt;v8::Value&gt; object, bool isInline, bool findOnly)
+{
+    return findOrCreateEventListenerHelper(object, isInline, findOnly, false);
+}
+
+PassRefPtr&lt;V8EventListener&gt; WorkerContextExecutionProxy::findOrCreateObjectEventListener(v8::Local&lt;v8::Value&gt; object, bool isInline, bool findOnly)
+{
+    return findOrCreateEventListenerHelper(object, isInline, findOnly, true);
+}
+
</ins><span class="cx"> void WorkerContextExecutionProxy::RemoveEventListener(V8EventListener* listener)
</span><span class="cx"> {
</span><span class="cx">     // Need to use lock since V8EventListenerList::remove() creates HandleScope.
</span></span></pre></div>
<a id="trunkWebCorebindingsv8WorkerContextExecutionProxyh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.h (42372 => 42373)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.h        2009-04-09 22:40:05 UTC (rev 42372)
+++ trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.h        2009-04-09 22:42:10 UTC (rev 42373)
</span><span class="lines">@@ -64,6 +64,9 @@
</span><span class="cx">         static v8::Handle&lt;v8::Value&gt; EventTargetToV8Object(EventTarget* target);
</span><span class="cx">         static v8::Handle&lt;v8::Value&gt; WorkerContextToV8Object(WorkerContext* wc);
</span><span class="cx"> 
</span><ins>+        // Finds/creates event listener wrappers.
+        PassRefPtr&lt;V8EventListener&gt; findOrCreateObjectEventListener(v8::Local&lt;v8::Value&gt; object, bool isInline, bool findOnly);
+
</ins><span class="cx">         // Track the event so that we can detach it from the JS wrapper when a worker
</span><span class="cx">         // terminates. This is needed because we need to be able to dispose these
</span><span class="cx">         // events and releases references to their event targets: WorkerContext.
</span><span class="lines">@@ -75,7 +78,7 @@
</span><span class="cx">         // Returns WorkerContext object.
</span><span class="cx">         WorkerContext* workerContext() { return m_workerContext; }
</span><span class="cx"> 
</span><del>-        // Returns WorkerContextExecutionProxy object of the currently executing context.
</del><ins>+        // Returns WorkerContextExecutionProxy object of the currently executing context. 0 will be returned if the current executing context is not the worker context.
</ins><span class="cx">         static WorkerContextExecutionProxy* retrieve();
</span><span class="cx"> 
</span><span class="cx">         // Enables HTML5 worker support.
</span><span class="lines">@@ -85,6 +88,7 @@
</span><span class="cx">     private:
</span><span class="cx">         void initContextIfNeeded();
</span><span class="cx">         void dispose();
</span><ins>+        PassRefPtr&lt;V8EventListener&gt; findOrCreateEventListenerHelper(v8::Local&lt;v8::Value&gt; object, bool isInline, bool findOnly, bool createObjectEventListener);
</ins><span class="cx"> 
</span><span class="cx">         // Run an already compiled script.
</span><span class="cx">         v8::Local&lt;v8::Value&gt; runScript(v8::Handle&lt;v8::Script&gt;);
</span></span></pre></div>
<a id="trunkWebCorebindingsv8customV8XMLHttpRequestConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp (42372 => 42373)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp        2009-04-09 22:40:05 UTC (rev 42372)
+++ trunk/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp        2009-04-09 22:42:10 UTC (rev 42373)
</span><span class="lines">@@ -36,6 +36,8 @@
</span><span class="cx"> #include &quot;V8ObjectEventListener.h&quot;
</span><span class="cx"> #include &quot;V8Proxy.h&quot;
</span><span class="cx"> #include &quot;XMLHttpRequest.h&quot;
</span><ins>+#include &quot;WorkerContext.h&quot;
+#include &quot;WorkerContextExecutionProxy.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -48,8 +50,15 @@
</span><span class="cx"> 
</span><span class="cx">     // Expect no parameters.
</span><span class="cx">     // Allocate a XMLHttpRequest object as its internal field.
</span><del>-    Document* doc = V8Proxy::retrieveFrame()-&gt;document();
-    RefPtr&lt;XMLHttpRequest&gt; xmlHttpRequest = XMLHttpRequest::create(doc);
</del><ins>+    ScriptExecutionContext* context = 0;
+#if ENABLE(WORKERS)
+    WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve();
+    if (proxy)
+        context = proxy-&gt;workerContext();
+    else
+#endif
+        context = V8Proxy::retrieveFrame()-&gt;document();
+    RefPtr&lt;XMLHttpRequest&gt; xmlHttpRequest = XMLHttpRequest::create(context);
</ins><span class="cx">     V8Proxy::SetDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::XMLHTTPREQUEST), xmlHttpRequest.get());
</span><span class="cx"> 
</span><span class="cx">     // Add object to the wrapper map.
</span></span></pre></div>
<a id="trunkWebCorebindingsv8customV8XMLHttpRequestCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp (42372 => 42373)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp        2009-04-09 22:40:05 UTC (rev 42372)
+++ trunk/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp        2009-04-09 22:42:10 UTC (rev 42373)
</span><span class="lines">@@ -39,9 +39,26 @@
</span><span class="cx"> #include &quot;V8ObjectEventListener.h&quot;
</span><span class="cx"> #include &quot;V8Proxy.h&quot;
</span><span class="cx"> #include &quot;V8XMLHttpRequestUtilities.h&quot;
</span><ins>+#include &quot;WorkerContext.h&quot;
+#include &quot;WorkerContextExecutionProxy.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+PassRefPtr&lt;EventListener&gt; getEventListener(XMLHttpRequest* xmlHttpRequest, v8::Local&lt;v8::Value&gt; value, bool findOnly)
+{
+#if ENABLE(WORKERS)
+    WorkerContextExecutionProxy* workerContextProxy = WorkerContextExecutionProxy::retrieve();
+    if (workerContextProxy)
+        return workerContextProxy-&gt;findOrCreateObjectEventListener(value, false, findOnly);
+#endif
+
+    V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest-&gt;scriptExecutionContext());
+    if (proxy)
+        return findOnly ? proxy-&gt;FindObjectEventListener(value, false) : proxy-&gt;FindOrCreateObjectEventListener(value, false);
+
+    return PassRefPtr&lt;EventListener&gt;();
+}
+
</ins><span class="cx"> ACCESSOR_GETTER(XMLHttpRequestOnabort)
</span><span class="cx"> {
</span><span class="cx">     INC_STATS(&quot;DOM.XMLHttpRequest.onabort._get&quot;);
</span><span class="lines">@@ -68,11 +85,7 @@
</span><span class="cx">         // Clear the listener.
</span><span class="cx">         xmlHttpRequest-&gt;setOnabort(0);
</span><span class="cx">     } else {
</span><del>-        V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest-&gt;scriptExecutionContext());
-        if (!proxy)
-            return;
-
-        RefPtr&lt;EventListener&gt; listener = proxy-&gt;FindOrCreateObjectEventListener(value, false);
</del><ins>+        RefPtr&lt;EventListener&gt; listener = getEventListener(xmlHttpRequest, value, false);
</ins><span class="cx">         if (listener) {
</span><span class="cx">             xmlHttpRequest-&gt;setOnabort(listener);
</span><span class="cx">             createHiddenXHRDependency(info.Holder(), value);
</span><span class="lines">@@ -106,11 +119,7 @@
</span><span class="cx">         // Clear the listener.
</span><span class="cx">         xmlHttpRequest-&gt;setOnerror(0);
</span><span class="cx">     } else {
</span><del>-        V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest-&gt;scriptExecutionContext());
-        if (!proxy)
-            return;
-
-        RefPtr&lt;EventListener&gt; listener = proxy-&gt;FindOrCreateObjectEventListener(value, false);
</del><ins>+        RefPtr&lt;EventListener&gt; listener = getEventListener(xmlHttpRequest, value, false);
</ins><span class="cx">         if (listener) {
</span><span class="cx">             xmlHttpRequest-&gt;setOnerror(listener);
</span><span class="cx">             createHiddenXHRDependency(info.Holder(), value);
</span><span class="lines">@@ -144,11 +153,7 @@
</span><span class="cx">         xmlHttpRequest-&gt;setOnload(0);
</span><span class="cx"> 
</span><span class="cx">     } else {
</span><del>-        V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest-&gt;scriptExecutionContext());
-        if (!proxy)
-            return;
-
-        RefPtr&lt;EventListener&gt; listener = proxy-&gt;FindOrCreateObjectEventListener(value, false);
</del><ins>+        RefPtr&lt;EventListener&gt; listener = getEventListener(xmlHttpRequest, value, false);
</ins><span class="cx">         if (listener) {
</span><span class="cx">             xmlHttpRequest-&gt;setOnload(listener.get());
</span><span class="cx">             createHiddenXHRDependency(info.Holder(), value);
</span><span class="lines">@@ -182,11 +187,7 @@
</span><span class="cx">         // Clear the listener.
</span><span class="cx">         xmlHttpRequest-&gt;setOnloadstart(0);
</span><span class="cx">     } else {
</span><del>-        V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest-&gt;scriptExecutionContext());
-        if (!proxy)
-            return;
-
-        RefPtr&lt;EventListener&gt; listener = proxy-&gt;FindOrCreateObjectEventListener(value, false);
</del><ins>+        RefPtr&lt;EventListener&gt; listener = getEventListener(xmlHttpRequest, value, false);
</ins><span class="cx">         if (listener) {
</span><span class="cx">             xmlHttpRequest-&gt;setOnloadstart(listener);
</span><span class="cx">             createHiddenXHRDependency(info.Holder(), value);
</span><span class="lines">@@ -220,11 +221,7 @@
</span><span class="cx">         // Clear the listener.
</span><span class="cx">         xmlHttpRequest-&gt;setOnprogress(0);
</span><span class="cx">     } else {
</span><del>-        V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest-&gt;scriptExecutionContext());
-        if (!proxy)
-            return;
-
-        RefPtr&lt;EventListener&gt; listener = proxy-&gt;FindOrCreateObjectEventListener(value, false);
</del><ins>+        RefPtr&lt;EventListener&gt; listener = getEventListener(xmlHttpRequest, value, false);
</ins><span class="cx">         if (listener) {
</span><span class="cx">             xmlHttpRequest-&gt;setOnprogress(listener);
</span><span class="cx">             createHiddenXHRDependency(info.Holder(), value);
</span><span class="lines">@@ -258,11 +255,7 @@
</span><span class="cx">         // Clear the listener.
</span><span class="cx">         xmlHttpRequest-&gt;setOnreadystatechange(0);
</span><span class="cx">     } else {
</span><del>-        V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest-&gt;scriptExecutionContext());
-        if (!proxy)
-            return;
-
-        RefPtr&lt;EventListener&gt; listener = proxy-&gt;FindOrCreateObjectEventListener(value, false);
</del><ins>+        RefPtr&lt;EventListener&gt; listener = getEventListener(xmlHttpRequest, value, false);
</ins><span class="cx">         if (listener) {
</span><span class="cx">             xmlHttpRequest-&gt;setOnreadystatechange(listener.get());
</span><span class="cx">             createHiddenXHRDependency(info.Holder(), value);
</span><span class="lines">@@ -284,11 +277,7 @@
</span><span class="cx">     INC_STATS(&quot;DOM.XMLHttpRequest.addEventListener()&quot;);
</span><span class="cx">     XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject&lt;XMLHttpRequest&gt;(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
</span><span class="cx"> 
</span><del>-    V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest-&gt;scriptExecutionContext());
-    if (!proxy)
-        return v8::Undefined();
-
-    RefPtr&lt;EventListener&gt; listener = proxy-&gt;FindOrCreateObjectEventListener(args[1], false);
</del><ins>+    RefPtr&lt;EventListener&gt; listener = getEventListener(xmlHttpRequest, args[1], false);
</ins><span class="cx">     if (listener) {
</span><span class="cx">         String type = toWebCoreString(args[0]);
</span><span class="cx">         bool useCapture = args[2]-&gt;BooleanValue();
</span><span class="lines">@@ -304,12 +293,7 @@
</span><span class="cx">     INC_STATS(&quot;DOM.XMLHttpRequest.removeEventListener()&quot;);
</span><span class="cx">     XMLHttpRequest* xmlHttpRequest = V8Proxy::ToNativeObject&lt;XMLHttpRequest&gt;(V8ClassIndex::XMLHTTPREQUEST, args.Holder());
</span><span class="cx"> 
</span><del>-    V8Proxy* proxy = V8Proxy::retrieve(xmlHttpRequest-&gt;scriptExecutionContext());
-    if (!proxy)
-        return v8::Undefined(); // Probably leaked.
-
-    RefPtr&lt;EventListener&gt; listener = proxy-&gt;FindObjectEventListener(args[1], false);
-
</del><ins>+    RefPtr&lt;EventListener&gt; listener = getEventListener(xmlHttpRequest, args[1], true);
</ins><span class="cx">     if (listener) {
</span><span class="cx">         String type = toWebCoreString(args[0]);
</span><span class="cx">         bool useCapture = args[2]-&gt;BooleanValue();
</span><span class="lines">@@ -337,8 +321,15 @@
</span><span class="cx"> 
</span><span class="cx">     String method = toWebCoreString(args[0]);
</span><span class="cx">     String urlstring = toWebCoreString(args[1]);
</span><del>-    V8Proxy* proxy = V8Proxy::retrieve();
-    KURL url = proxy-&gt;frame()-&gt;document()-&gt;completeURL(urlstring);
</del><ins>+    ScriptExecutionContext* context = 0;
+#if ENABLE(WORKERS)
+    WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve();
+    if (proxy)
+        context = proxy-&gt;workerContext();
+    else
+#endif
+        context = V8Proxy::retrieve()-&gt;frame()-&gt;document();
+    KURL url = context-&gt;completeURL(urlstring);
</ins><span class="cx"> 
</span><span class="cx">     bool async = (args.Length() &lt; 3) ? true : args[2]-&gt;BooleanValue();
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>