<!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>[182479] releases/WebKitGTK/webkit-2.4/Source</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/182479">182479</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2015-04-07 10:38:26 -0700 (Tue, 07 Apr 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/180214">r180214</a> - [GTK] GObject DOM bindings object are cached forever
https://bugs.webkit.org/show_bug.cgi?id=141558

Reviewed by Sergio Villar Senin.

Source/WebCore:

Rework the DOMObjectCache to avoid having to manually clear the
objects when the frame is destroyed, using a FrameDestructionObserver
instead. When a new object associated to a Frame is added to the
cache, a FrameDestructionObserver is created for the frame if
needed, and the DOM object is tracked by the observer too. When
the frame is detached from the page all its objects are cleared,
and if the aren't additional references, the object is finalized
and removed from the cache normally.
This patch also simplifies and modernizes the code to make it
easier to read an maintain.

* bindings/gobject/DOMObjectCache.cpp:
(WebKit::DOMObjectCacheData::DOMObjectCacheData): Add constructor
to initialize its members and simplify the callers.
(WebKit::DOMObjectCacheData::clearObject): Remove the references
added by the cache, ensuring the GObject is not finalized until
the method returns.
(WebKit::DOMObjectCacheData::refObject): Adds a reference owned by
the cache.
(WebKit::domObjectCacheFrameObservers): Map a frame to a FrameDestructionObserver.
(WebKit::getOrCreateDOMObjectCacheFrameObserver): Create a new
FrameDestructionObserver for the given Frame or return the
existing one.
(WebKit::domObjects): Map wrapped object to wrapper object.
(WebKit::DOMObjectCache::forget): Remove the wrapped object from
the cache.
(WebKit::DOMObjectCache::get): Return the wrapped object if it is
in the cache, increasing the cache references.
(WebKit::DOMObjectCache::put): Add the wrapper object to the cache
for the given wrapped object. If it's a Node and has a frame add
the node to the FrameDestructionObserver corresponding to the frame.
(WebKit::getFrameFromHandle): Deleted.
(WebKit::weakRefNotify): Deleted.
(WebKit::DOMObjectCache::clearByFrame): Deleted.
(WebKit::DOMObjectCache::~DOMObjectCache): Deleted.
* bindings/gobject/DOMObjectCache.h:

Merge <a href="http://trac.webkit.org/projects/webkit/changeset/181631">r181631</a> - [GTK] WebKitDOM objects leaking
https://bugs.webkit.org/show_bug.cgi?id=118788

Reviewed by Darin Adler and Sergio Villar Senin.

Source/WebCore:

Use a DOMwindowObserver class, derived from DOMWindowProperty to
be notified when the window object is detached from the frame to
clear the DOM objects associated to that frame in that case too.

* bindings/gobject/DOMObjectCache.cpp:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCorebindingsgobjectDOMObjectCachecpp">releases/WebKitGTK/webkit-2.4/Source/WebCore/bindings/gobject/DOMObjectCache.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCorebindingsgobjectDOMObjectCacheh">releases/WebKitGTK/webkit-2.4/Source/WebCore/bindings/gobject/DOMObjectCache.h</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebKitgtkWebCoreSupportFrameLoaderClientGtkcpp">releases/WebKitGTK/webkit-2.4/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebKitgtkwebkitwebkitwebframecpp">releases/WebKitGTK/webkit-2.4/Source/WebKit/gtk/webkit/webkitwebframe.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit24SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog (182478 => 182479)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog        2015-04-07 17:22:15 UTC (rev 182478)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog        2015-04-07 17:38:26 UTC (rev 182479)
</span><span class="lines">@@ -1,3 +1,60 @@
</span><ins>+2015-03-17  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] WebKitDOM objects leaking
+        https://bugs.webkit.org/show_bug.cgi?id=118788
+
+        Reviewed by Darin Adler and Sergio Villar Senin.
+
+        Use a DOMwindowObserver class, derived from DOMWindowProperty to
+        be notified when the window object is detached from the frame to
+        clear the DOM objects associated to that frame in that case too.
+
+        * bindings/gobject/DOMObjectCache.cpp:
+
+2015-02-17  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] GObject DOM bindings object are cached forever
+        https://bugs.webkit.org/show_bug.cgi?id=141558
+
+        Reviewed by Sergio Villar Senin.
+
+        Rework the DOMObjectCache to avoid having to manually clear the
+        objects when the frame is destroyed, using a FrameDestructionObserver
+        instead. When a new object associated to a Frame is added to the
+        cache, a FrameDestructionObserver is created for the frame if
+        needed, and the DOM object is tracked by the observer too. When
+        the frame is detached from the page all its objects are cleared,
+        and if the aren't additional references, the object is finalized
+        and removed from the cache normally.
+        This patch also simplifies and modernizes the code to make it
+        easier to read an maintain.
+
+        * bindings/gobject/DOMObjectCache.cpp:
+        (WebKit::DOMObjectCacheData::DOMObjectCacheData): Add constructor
+        to initialize its members and simplify the callers.
+        (WebKit::DOMObjectCacheData::clearObject): Remove the references
+        added by the cache, ensuring the GObject is not finalized until
+        the method returns.
+        (WebKit::DOMObjectCacheData::refObject): Adds a reference owned by
+        the cache.
+        (WebKit::domObjectCacheFrameObservers): Map a frame to a FrameDestructionObserver.
+        (WebKit::getOrCreateDOMObjectCacheFrameObserver): Create a new
+        FrameDestructionObserver for the given Frame or return the
+        existing one.
+        (WebKit::domObjects): Map wrapped object to wrapper object.
+        (WebKit::DOMObjectCache::forget): Remove the wrapped object from
+        the cache.
+        (WebKit::DOMObjectCache::get): Return the wrapped object if it is
+        in the cache, increasing the cache references.
+        (WebKit::DOMObjectCache::put): Add the wrapper object to the cache
+        for the given wrapped object. If it's a Node and has a frame add
+        the node to the FrameDestructionObserver corresponding to the frame.
+        (WebKit::getFrameFromHandle): Deleted.
+        (WebKit::weakRefNotify): Deleted.
+        (WebKit::DOMObjectCache::clearByFrame): Deleted.
+        (WebKit::DOMObjectCache::~DOMObjectCache): Deleted.
+        * bindings/gobject/DOMObjectCache.h:
+
</ins><span class="cx"> 2015-04-07  Milan Crha  &lt;mcrha@redhat.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] [WebKit1] Crash under WebCore::ScrollView::contentsToWindow()
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCorebindingsgobjectDOMObjectCachecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/bindings/gobject/DOMObjectCache.cpp (182478 => 182479)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/bindings/gobject/DOMObjectCache.cpp        2015-04-07 17:22:15 UTC (rev 182478)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/bindings/gobject/DOMObjectCache.cpp        2015-04-07 17:38:26 UTC (rev 182479)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- *  Copyright (C) 2010 Igalia S.L.
</del><ins>+ *  Copyright (C) 2010, 2015 Igalia S.L.
</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 Lesser General Public
</span><span class="lines">@@ -19,142 +19,203 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;DOMObjectCache.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;DOMWindowProperty.h&quot;
</ins><span class="cx"> #include &quot;Document.h&quot;
</span><ins>+#include &quot;Frame.h&quot;
+#include &quot;FrameDestructionObserver.h&quot;
</ins><span class="cx"> #include &quot;Node.h&quot;
</span><span class="cx"> #include &lt;glib-object.h&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><ins>+#include &lt;wtf/NeverDestroyed.h&gt;
+#include &lt;wtf/Vector.h&gt;
+#include &lt;wtf/gobject/GRefPtr.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-typedef struct {
</del><ins>+struct DOMObjectCacheData {
+    DOMObjectCacheData(GObject* wrapper)
+        : object(wrapper)
+        , cacheReferences(1)
+    {
+    }
+
+    void clearObject()
+    {
+        ASSERT(object);
+        ASSERT(cacheReferences &gt;= 1);
+
+        GRefPtr&lt;GObject&gt; protect(object);
+        do {
+            g_object_unref(object);
+        } while (--cacheReferences);
+        object = nullptr;
+    }
+
+    void* refObject()
+    {
+        ASSERT(object);
+
+        cacheReferences++;
+        return g_object_ref(object);
+    }
+
</ins><span class="cx">     GObject* object;
</span><del>-    WebCore::Frame* frame;
-    guint timesReturned;
-} DOMObjectCacheData;
</del><ins>+    unsigned cacheReferences;
+};
</ins><span class="cx"> 
</span><del>-typedef HashMap&lt;void*, DOMObjectCacheData*&gt; DOMObjectMap;
</del><ins>+class DOMObjectCacheFrameObserver;
+typedef HashMap&lt;WebCore::Frame*, std::unique_ptr&lt;DOMObjectCacheFrameObserver&gt;&gt; DOMObjectCacheFrameObserverMap;
</ins><span class="cx"> 
</span><del>-static DOMObjectMap&amp; domObjects()
</del><ins>+static DOMObjectCacheFrameObserverMap&amp; domObjectCacheFrameObservers()
</ins><span class="cx"> {
</span><del>-    static DOMObjectMap staticDOMObjects;
-    return staticDOMObjects;
</del><ins>+    static NeverDestroyed&lt;DOMObjectCacheFrameObserverMap&gt; map;
+    return map;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static WebCore::Frame* getFrameFromHandle(void* objectHandle)
</del><ins>+static DOMObjectCacheFrameObserver&amp; getOrCreateDOMObjectCacheFrameObserver(WebCore::Frame&amp; frame)
</ins><span class="cx"> {
</span><del>-    WebCore::Node* node = static_cast&lt;WebCore::Node*&gt;(objectHandle);
-    if (!node-&gt;inDocument())
-        return 0;
-    return node-&gt;document().frame();
-}
</del><ins>+    auto observerPtr = domObjectCacheFrameObservers().get(&amp;frame);
+    if (observerPtr)
+        return *observerPtr;
</ins><span class="cx"> 
</span><del>-void DOMObjectCache::forget(void* objectHandle)
-{
-    DOMObjectCacheData* cacheData = domObjects().get(objectHandle);
-    ASSERT(cacheData);
-    g_slice_free(DOMObjectCacheData, cacheData);
-    domObjects().take(objectHandle);
</del><ins>+    std::unique_ptr&lt;DOMObjectCacheFrameObserver&gt; observer = std::make_unique&lt;DOMObjectCacheFrameObserver&gt;(frame);
+    observerPtr = observer.get();
+    domObjectCacheFrameObservers().set(&amp;frame, std::move(observer));
+    return *observerPtr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void weakRefNotify(gpointer data, GObject* zombie)
-{
-    gboolean* objectDead = static_cast&lt;gboolean*&gt;(data);
-    *objectDead = TRUE;
-}
</del><ins>+class DOMObjectCacheFrameObserver final: public WebCore::FrameDestructionObserver {
+public:
+    DOMObjectCacheFrameObserver(WebCore::Frame&amp; frame)
+        : FrameDestructionObserver(&amp;frame)
+    {
+    }
</ins><span class="cx"> 
</span><del>-void DOMObjectCache::clearByFrame(WebCore::Frame* frame)
-{
-    Vector&lt;DOMObjectCacheData*&gt; toUnref;
</del><ins>+    ~DOMObjectCacheFrameObserver()
+    {
+        ASSERT(m_objects.isEmpty());
+    }
</ins><span class="cx"> 
</span><del>-    // Unreffing the objects removes them from the cache in their
-    // finalize method, so just save them to do that while we are not
-    // iterating the cache itself.
-    DOMObjectMap::iterator end = domObjects().end();
-    for (DOMObjectMap::iterator iter = domObjects().begin(); iter != end; ++iter) {
-        DOMObjectCacheData* data = iter-&gt;value;
-        ASSERT(data);
-        if ((!frame || data-&gt;frame == frame) &amp;&amp; data-&gt;timesReturned)
-            toUnref.append(data);
</del><ins>+    void addObjectCacheData(DOMObjectCacheData&amp; data)
+    {
+        ASSERT(!m_objects.contains(&amp;data));
+
+        if (!m_domWindowObserver &amp;&amp; m_frame-&gt;document()-&gt;domWindow())
+            m_domWindowObserver = std::make_unique&lt;DOMWindowObserver&gt;(*m_frame, *this);
+
+        m_objects.append(&amp;data);
+        g_object_weak_ref(data.object, DOMObjectCacheFrameObserver::objectFinalizedCallback, this);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Vector&lt;DOMObjectCacheData*&gt;::iterator last = toUnref.end();
-    for (Vector&lt;DOMObjectCacheData*&gt;::iterator it = toUnref.begin(); it != last; ++it) {
-        DOMObjectCacheData* data = *it;
-        // We can't really know what the user has done with the DOM
-        // objects, so in case any of the external references to them
-        // were unreffed (but not all, otherwise the object would be
-        // dead and out of the cache) we'll add a weak ref before we
-        // start to get rid of the cache's own references; if the
-        // object dies in the middle of the process, we'll just stop.
-        gboolean objectDead = FALSE;
-        g_object_weak_ref(data-&gt;object, weakRefNotify, &amp;objectDead);
-        // We need to check objectDead first, otherwise the cache data
-        // might be garbage already.
-        while (!objectDead &amp;&amp; data-&gt;timesReturned &gt; 0) {
-            // If this is the last unref we are going to do,
-            // disconnect the weak ref. We cannot do it afterwards
-            // because the object might be dead at that point.
-            if (data-&gt;timesReturned == 1) {
-                g_object_weak_unref(data-&gt;object, weakRefNotify, &amp;objectDead);
-                // At this point, the next time the DOMObject is
-                // unref'ed it will be finalized,
-                // DOMObject::finalize() will call
-                // DOMObjectCache::forget(), which will free 'data'.
-                // Toggling 'objectDead' here will ensure we don't
-                // dereference an invalid pointer in the next
-                // iteration.
-                objectDead = TRUE;
</del><ins>+private:
+    class DOMWindowObserver final: public WebCore::DOMWindowProperty {
+        WTF_MAKE_FAST_ALLOCATED;
+    public:
+        DOMWindowObserver(WebCore::Frame&amp; frame, DOMObjectCacheFrameObserver&amp; frameObserver)
+            : DOMWindowProperty(&amp;frame)
+            , m_frameObserver(frameObserver)
+        {
+        }
+
+        virtual ~DOMWindowObserver()
+        {
+        }
+
+    private:
+        virtual void willDetachGlobalObjectFromFrame() override
+        {
+            // Clear the DOMWindowProperty first, and then notify the Frame observer.
+            DOMWindowProperty::willDetachGlobalObjectFromFrame();
+            m_frameObserver.willDetachGlobalObjectFromFrame();
+        }
+
+        DOMObjectCacheFrameObserver&amp; m_frameObserver;
+    };
+
+    static void objectFinalizedCallback(gpointer userData, GObject* finalizedObject)
+    {
+        DOMObjectCacheFrameObserver* observer = static_cast&lt;DOMObjectCacheFrameObserver*&gt;(userData);
+        for (size_t i = 0; i &lt; observer-&gt;m_objects.size(); ++i) {
+            if (observer-&gt;m_objects[i]-&gt;object == finalizedObject) {
+                observer-&gt;m_objects.remove(i);
+                break;
</ins><span class="cx">             }
</span><del>-            data-&gt;timesReturned--;
-            g_object_unref(data-&gt;object);
</del><span class="cx">         }
</span><span class="cx">     }
</span><ins>+
+    void clear()
+    {
+        if (m_objects.isEmpty())
+            return;
+
+        auto objects = std::move(m_objects);
+        for (auto* data : objects) {
+            g_object_weak_unref(data-&gt;object, DOMObjectCacheFrameObserver::objectFinalizedCallback, this);
+            data-&gt;clearObject();
+        }
+    }
+
+    virtual void willDetachPage() override
+    {
+        clear();
+    }
+
+    virtual void frameDestroyed() override
+    {
+        clear();
+        WebCore::Frame* frame = m_frame;
+        FrameDestructionObserver::frameDestroyed();
+        domObjectCacheFrameObservers().remove(frame);
+    }
+
+    void willDetachGlobalObjectFromFrame()
+    {
+        clear();
+        m_domWindowObserver = nullptr;
+    }
+
+    Vector&lt;DOMObjectCacheData*, 8&gt; m_objects;
+    std::unique_ptr&lt;DOMWindowObserver&gt; m_domWindowObserver;
+};
+
+typedef HashMap&lt;void*, std::unique_ptr&lt;DOMObjectCacheData&gt;&gt; DOMObjectMap;
+
+static DOMObjectMap&amp; domObjects()
+{
+    static NeverDestroyed&lt;DOMObjectMap&gt; staticDOMObjects;
+    return staticDOMObjects;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-DOMObjectCache::~DOMObjectCache()
</del><ins>+void DOMObjectCache::forget(void* objectHandle)
</ins><span class="cx"> {
</span><del>-    clearByFrame();
</del><ins>+    ASSERT(domObjects().contains(objectHandle));
+    domObjects().remove(objectHandle);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void* DOMObjectCache::get(void* objectHandle)
</span><span class="cx"> {
</span><span class="cx">     DOMObjectCacheData* data = domObjects().get(objectHandle);
</span><del>-    if (!data)
-        return 0;
-
-    // We want to add one ref each time a wrapper is returned, so that
-    // the user can manually unref them if he chooses to.
-    ASSERT(data-&gt;object);
-    data-&gt;timesReturned++;
-    return g_object_ref(data-&gt;object);
</del><ins>+    return data ? data-&gt;refObject() : nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void* DOMObjectCache::put(void* objectHandle, void* wrapper)
</del><ins>+void DOMObjectCache::put(void* objectHandle, void* wrapper)
</ins><span class="cx"> {
</span><del>-    if (domObjects().get(objectHandle))
-        return wrapper;
-
-    DOMObjectCacheData* data = g_slice_new(DOMObjectCacheData);
-    data-&gt;object = static_cast&lt;GObject*&gt;(wrapper);
-    data-&gt;frame = 0;
-    data-&gt;timesReturned = 1;
-
-    domObjects().set(objectHandle, data);
-    return wrapper;
</del><ins>+    if (domObjects().contains(objectHandle))
+        return;
+    domObjects().set(objectHandle, std::make_unique&lt;DOMObjectCacheData&gt;(G_OBJECT(wrapper)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void* DOMObjectCache::put(WebCore::Node* objectHandle, void* wrapper)
</del><ins>+void DOMObjectCache::put(WebCore::Node* objectHandle, void* wrapper)
</ins><span class="cx"> {
</span><del>-    // call the ::put version that takes void* to do the basic cache
-    // insertion work
-    put(static_cast&lt;void*&gt;(objectHandle), wrapper);
</del><ins>+    if (domObjects().contains(objectHandle))
+        return;
</ins><span class="cx"> 
</span><del>-    DOMObjectCacheData* data = domObjects().get(objectHandle);
-    ASSERT(data);
</del><ins>+    std::unique_ptr&lt;DOMObjectCacheData&gt; data = std::make_unique&lt;DOMObjectCacheData&gt;(G_OBJECT(wrapper));
+    auto dataPtr = data.get();
+    domObjects().set(objectHandle, std::move(data));
</ins><span class="cx"> 
</span><del>-    data-&gt;frame = getFrameFromHandle(objectHandle);
-
-    return wrapper;
</del><ins>+    if (WebCore::Frame* frame = objectHandle-&gt;document().frame())
+        getOrCreateDOMObjectCacheFrameObserver(*frame).addObjectCacheData(*dataPtr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCorebindingsgobjectDOMObjectCacheh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/bindings/gobject/DOMObjectCache.h (182478 => 182479)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/bindings/gobject/DOMObjectCache.h        2015-04-07 17:22:15 UTC (rev 182478)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/bindings/gobject/DOMObjectCache.h        2015-04-07 17:38:26 UTC (rev 182479)
</span><span class="lines">@@ -21,18 +21,15 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class Node;
</span><del>-class Frame;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> class DOMObjectCache {
</span><span class="cx"> public:
</span><span class="cx">     static void* get(void* objectHandle);
</span><del>-    static void* put(void* objectHandle, void* wrapper);
-    static void* put(WebCore::Node* objectHandle, void* wrapper);
-    static void clearByFrame(WebCore::Frame* frame = 0);
</del><ins>+    static void put(void* objectHandle, void* wrapper);
+    static void put(WebCore::Node* objectHandle, void* wrapper);
</ins><span class="cx">     static void forget(void* objectHandle);
</span><del>-    ~DOMObjectCache();
</del><span class="cx"> };
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebKitgtkWebCoreSupportFrameLoaderClientGtkcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp (182478 => 182479)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp        2015-04-07 17:22:15 UTC (rev 182478)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp        2015-04-07 17:38:26 UTC (rev 182479)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx"> #include &quot;ArchiveResource.h&quot;
</span><span class="cx"> #include &quot;CachedFrame.h&quot;
</span><span class="cx"> #include &quot;Color.h&quot;
</span><del>-#include &quot;DOMObjectCache.h&quot;
</del><span class="cx"> #include &quot;DocumentLoader.h&quot;
</span><span class="cx"> #include &quot;DocumentLoaderGtk.h&quot;
</span><span class="cx"> #include &quot;DumpRenderTreeSupportGtk.h&quot;
</span><span class="lines">@@ -579,8 +578,7 @@
</span><span class="cx"> 
</span><span class="cx"> void FrameLoaderClient::setMainFrameDocumentReady(bool ready)
</span><span class="cx"> {
</span><del>-    if (!ready)
-        DOMObjectCache::clearByFrame(core(m_frame));
</del><ins>+    notImplemented();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool FrameLoaderClient::hasWebView() const
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebKitgtkwebkitwebkitwebframecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit/gtk/webkit/webkitwebframe.cpp (182478 => 182479)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebKit/gtk/webkit/webkitwebframe.cpp        2015-04-07 17:22:15 UTC (rev 182478)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit/gtk/webkit/webkitwebframe.cpp        2015-04-07 17:38:26 UTC (rev 182479)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AXObjectCache.h&quot;
</span><span class="cx"> #include &quot;AnimationController.h&quot;
</span><del>-#include &quot;DOMObjectCache.h&quot;
</del><span class="cx"> #include &quot;DocumentFragment.h&quot;
</span><span class="cx"> #include &quot;DocumentLoader.h&quot;
</span><span class="cx"> #include &quot;DocumentLoaderGtk.h&quot;
</span><span class="lines">@@ -172,8 +171,6 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(WEBKIT_IS_WEB_FRAME(frame));
</span><span class="cx">     WebKitWebFramePrivate* priv = frame-&gt;priv;
</span><del>-    if (priv-&gt;coreFrame)
-        DOMObjectCache::clearByFrame(priv-&gt;coreFrame);
</del><span class="cx">     priv-&gt;coreFrame = 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -188,7 +185,6 @@
</span><span class="cx">     WebKitWebFramePrivate* priv = frame-&gt;priv;
</span><span class="cx"> 
</span><span class="cx">     if (priv-&gt;coreFrame) {
</span><del>-        DOMObjectCache::clearByFrame(priv-&gt;coreFrame);
</del><span class="cx">         priv-&gt;coreFrame-&gt;loader().cancelAndClear();
</span><span class="cx">         priv-&gt;coreFrame = 0;
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>