Changeset 138841 in webkit


Ignore:
Timestamp:
Jan 4, 2013 1:03:20 PM (11 years ago)
Author:
adamk@chromium.org
Message:

[v8] Stop using an IDL to generate V8MutationCallback
https://bugs.webkit.org/show_bug.cgi?id=106122

Reviewed by Adam Barth.

The only real code in the generated V8MutationCallback.{h,cpp} files
were specifically written in CodeGeneratorV8 for its use. By instead
Using completely-hand-written versions of these files, the
CodeGenerator can be simplified (as can all generated Callbacks).
All the actually shared code is still shared via subclassing of
ActiveDOMCallback.

This introduces additional flexibility into the implementation of
MutationCallback which will be used when fixing the MutationObserver
memory leak (http://webkit.org/b/90661) for JSC.

No changes to JSC for now, just a FIXME in the IDL file.

No new tests, refactoringonly.

  • WebCore.gypi:
  • bindings/scripts/CodeGeneratorV8.pm:

(GenerateCallbackHeader):
(GenerateCallbackImplementation):

  • bindings/scripts/test/V8/V8TestCallback.cpp:

(WebCore::V8TestCallback::V8TestCallback):

  • bindings/scripts/test/V8/V8TestCallback.h:

(WebCore::V8TestCallback::create):
(V8TestCallback):

  • bindings/v8/V8MutationCallback.cpp: Renamed from Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp.

(WebCore::V8MutationCallback::V8MutationCallback):
(WebCore::V8MutationCallback::handleEvent):

  • bindings/v8/V8MutationCallback.h: Added.

(V8MutationCallback):
(WebCore::V8MutationCallback::create):
(WebCore::V8MutationCallback::weakCallback):

  • dom/MutationCallback.idl:
Location:
trunk/Source/WebCore
Files:
1 added
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r138840 r138841  
     12013-01-04  Adam Klein  <adamk@chromium.org>
     2
     3        [v8] Stop using an IDL to generate V8MutationCallback
     4        https://bugs.webkit.org/show_bug.cgi?id=106122
     5
     6        Reviewed by Adam Barth.
     7
     8        The only real code in the generated V8MutationCallback.{h,cpp} files
     9        were specifically written in CodeGeneratorV8 for its use. By instead
     10        Using completely-hand-written versions of these files, the
     11        CodeGenerator can be simplified (as can all generated Callbacks).
     12        All the actually shared code is still shared via subclassing of
     13        ActiveDOMCallback.
     14
     15        This introduces additional flexibility into the implementation of
     16        MutationCallback which will be used when fixing the MutationObserver
     17        memory leak (http://webkit.org/b/90661) for JSC.
     18
     19        No changes to JSC for now, just a FIXME in the IDL file.
     20
     21        No new tests, refactoringonly.
     22
     23        * WebCore.gypi:
     24        * bindings/scripts/CodeGeneratorV8.pm:
     25        (GenerateCallbackHeader):
     26        (GenerateCallbackImplementation):
     27        * bindings/scripts/test/V8/V8TestCallback.cpp:
     28        (WebCore::V8TestCallback::V8TestCallback):
     29        * bindings/scripts/test/V8/V8TestCallback.h:
     30        (WebCore::V8TestCallback::create):
     31        (V8TestCallback):
     32        * bindings/v8/V8MutationCallback.cpp: Renamed from Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp.
     33        (WebCore::V8MutationCallback::V8MutationCallback):
     34        (WebCore::V8MutationCallback::handleEvent):
     35        * bindings/v8/V8MutationCallback.h: Added.
     36        (V8MutationCallback):
     37        (WebCore::V8MutationCallback::create):
     38        (WebCore::V8MutationCallback::weakCallback):
     39        * dom/MutationCallback.idl:
     40
    1412013-01-04  Tony Chang  <tony@chromium.org>
    242
  • trunk/Source/WebCore/WebCore.gypi

    r138836 r138841  
    225225            'dom/MessagePort.idl',
    226226            'dom/MouseEvent.idl',
    227             'dom/MutationCallback.idl',
    228227            'dom/MutationEvent.idl',
    229228            'dom/MutationObserver.idl',
     
    12591258            'bindings/v8/V8LazyEventListener.cpp',
    12601259            'bindings/v8/V8LazyEventListener.h',
     1260            'bindings/v8/V8MutationCallback.cpp',
     1261            'bindings/v8/V8MutationCallback.h',
    12611262            'bindings/v8/V8NPObject.cpp',
    12621263            'bindings/v8/V8NPObject.h',
     
    13631364            'bindings/v8/custom/V8MessagePortCustom.cpp',
    13641365            'bindings/v8/custom/V8MicroDataItemValueCustom.cpp',
    1365             'bindings/v8/custom/V8MutationCallbackCustom.cpp',
    13661366            'bindings/v8/custom/V8MutationObserverCustom.cpp',
    13671367            'bindings/v8/custom/V8NamedNodeMapCustom.cpp',
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r138769 r138841  
    32533253    push(@headerContent, <<END);
    32543254public:
    3255     static PassRefPtr<${v8InterfaceName}> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context, v8::Handle<v8::Object> owner = v8::Handle<v8::Object>())
     3255    static PassRefPtr<${v8InterfaceName}> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context)
    32563256    {
    32573257        ASSERT(value->IsObject());
    32583258        ASSERT(context);
    3259         return adoptRef(new ${v8InterfaceName}(v8::Handle<v8::Object>::Cast(value), context, owner));
     3259        return adoptRef(new ${v8InterfaceName}(v8::Handle<v8::Object>::Cast(value), context));
    32603260    }
    32613261
     
    32913291
    32923292private:
    3293     ${v8InterfaceName}(v8::Handle<v8::Object>, ScriptExecutionContext*, v8::Handle<v8::Object>);
    3294 
    3295     static void weakCallback(v8::Persistent<v8::Value> wrapper, void* parameter)
    3296     {
    3297         ${v8InterfaceName}* object = static_cast<${v8InterfaceName}*>(parameter);
    3298         object->m_callback.clear();
    3299     }
     3293    ${v8InterfaceName}(v8::Handle<v8::Object>, ScriptExecutionContext*);
    33003294
    33013295    ScopedPersistent<v8::Object> m_callback;
     
    33293323    push(@implContent, "namespace WebCore {\n\n");
    33303324    push(@implContent, <<END);
    3331 ${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
     3325${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptExecutionContext* context)
    33323326    : ActiveDOMCallback(context)
    33333327    , m_callback(callback)
    33343328    , m_worldContext(UseCurrentWorld)
    33353329{
    3336     if (owner.IsEmpty())
    3337         return;
    3338     owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
    3339     m_callback.get().MakeWeak(this, &${v8InterfaceName}::weakCallback);
    33403330}
    33413331
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp

    r136822 r138841  
    4040namespace WebCore {
    4141
    42 V8TestCallback::V8TestCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
     42V8TestCallback::V8TestCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context)
    4343    : ActiveDOMCallback(context)
    4444    , m_callback(callback)
    4545    , m_worldContext(UseCurrentWorld)
    4646{
    47     if (owner.IsEmpty())
    48         return;
    49     owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
    50     m_callback.get().MakeWeak(this, &V8TestCallback::weakCallback);
    5147}
    5248
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h

    r138769 r138841  
    3737class V8TestCallback : public TestCallback, public ActiveDOMCallback {
    3838public:
    39     static PassRefPtr<V8TestCallback> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context, v8::Handle<v8::Object> owner = v8::Handle<v8::Object>())
     39    static PassRefPtr<V8TestCallback> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context)
    4040    {
    4141        ASSERT(value->IsObject());
    4242        ASSERT(context);
    43         return adoptRef(new V8TestCallback(v8::Handle<v8::Object>::Cast(value), context, owner));
     43        return adoptRef(new V8TestCallback(v8::Handle<v8::Object>::Cast(value), context));
    4444    }
    4545
     
    5959
    6060private:
    61     V8TestCallback(v8::Handle<v8::Object>, ScriptExecutionContext*, v8::Handle<v8::Object>);
    62 
    63     static void weakCallback(v8::Persistent<v8::Value> wrapper, void* parameter)
    64     {
    65         V8TestCallback* object = static_cast<V8TestCallback*>(parameter);
    66         object->m_callback.clear();
    67     }
     61    V8TestCallback(v8::Handle<v8::Object>, ScriptExecutionContext*);
    6862
    6963    ScopedPersistent<v8::Object> m_callback;
  • trunk/Source/WebCore/bindings/v8/V8MutationCallback.cpp

    r138840 r138841  
    11/*
    2  * Copyright (C) 2010, 2012 Google Inc. All rights reserved.
     2 * Copyright (C) 2013 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions are
    6  * met:
     5 * modification, are permitted provided that the following conditions
     6 * are met:
     7 * 1. Redistributions of source code must retain the above copyright
     8 *    notice, this list of conditions and the following disclaimer.
     9 * 2. Redistributions in binary form must reproduce the above copyright
     10 *    notice, this list of conditions and the following disclaimer in the
     11 *    documentation and/or other materials provided with the distribution.
    712 *
    8  *     * Redistributions of source code must retain the above copyright
    9  * notice, this list of conditions and the following disclaimer.
    10  *     * Redistributions in binary form must reproduce the above
    11  * copyright notice, this list of conditions and the following disclaimer
    12  * in the documentation and/or other materials provided with the
    13  * distribution.
    14  *     * Neither the name of Google Inc. nor the names of its
    15  * contributors may be used to endorse or promote products derived from
    16  * this software without specific prior written permission.
    17  *
    18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
     14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
     17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     23 * THE POSSIBILITY OF SUCH DAMAGE.
    2924 */
    3025
    3126#include "config.h"
    32 
    3327#include "V8MutationCallback.h"
    3428
     
    3933#include "V8MutationRecord.h"
    4034#include <wtf/Assertions.h>
    41 #include <wtf/GetPtr.h>
    42 #include <wtf/RefCounted.h>
    43 #include <wtf/RefPtr.h>
    4435
    4536namespace WebCore {
     37
     38V8MutationCallback::V8MutationCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
     39    : ActiveDOMCallback(context)
     40    , m_callback(callback)
     41    , m_worldContext(UseCurrentWorld)
     42{
     43    owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
     44    m_callback.get().MakeWeak(this, &V8MutationCallback::weakCallback);
     45}
    4646
    4747bool V8MutationCallback::handleEvent(MutationRecordArray* mutations, MutationObserver* observer)
  • trunk/Source/WebCore/dom/MutationCallback.idl

    r138811 r138841  
    2929 */
    3030
     31// FIXME: This interface is only used to generate code for JSC.
     32// It should be removed once http://webkit.org/b/93661 is fixed.
    3133[
    3234    Callback
Note: See TracChangeset for help on using the changeset viewer.