Changeset 20151 in webkit


Ignore:
Timestamp:
Mar 13, 2007 9:53:26 AM (17 years ago)
Author:
weinig
Message:

Reviewed by Maciej.

Fixes: http://bugs.webkit.org/show_bug.cgi?id=12974

Call forgetGenericContext in JSSVGPathSeg destructor, otherwhise
we'll hit an ASSERT in a debug build, when running svg/custom/js-update-path-changes.svg
a few dozen times in a single WebKit instance. The ASSERT is good and just warns that
there was already a generic context pointer registered, and the new "to be registered"
object already exists, but pointing to a different object. That's because garbage collection
calls the JSSVGPathSeg destructor, but that didn't cleanup the generic context map.

Only JSSVGPathSeg is hit by this problem, as it's the only non SVGAnimated* type
using the generic context system while using a custom JSSVGPathSegList implementation.

Also cleanup JSSVGPathSegListCustom code to call the static forgetGenericContext
method instead of doing the same using custom code.

  • bindings/js/JSSVGPathSegListCustom.cpp: (WebCore::removeFromPathSegContextMap): (WebCore::JSSVGPathSegList::clear): (WebCore::JSSVGPathSegList::removeItem):
  • bindings/scripts/CodeGeneratorJS.pm:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r20148 r20151  
     12007-03-13  Nikolas Zimmermann  <zimmermann@kde.org>
     2
     3        Reviewed by Maciej.
     4
     5        Fixes: http://bugs.webkit.org/show_bug.cgi?id=12974
     6
     7        Call forgetGenericContext in JSSVGPathSeg destructor, otherwhise
     8        we'll hit an ASSERT in a debug build, when running svg/custom/js-update-path-changes.svg
     9        a few dozen times in a single WebKit instance. The ASSERT is good and just warns that
     10        there was already a generic context pointer registered, and the new "to be registered"
     11        object already exists, but pointing to a different object. That's because garbage collection
     12        calls the JSSVGPathSeg destructor, but that didn't cleanup the generic context map.
     13
     14        Only JSSVGPathSeg is hit by this problem, as it's the only non SVGAnimated* type
     15        using the generic context system while using a custom JSSVGPathSegList implementation.
     16
     17        Also cleanup JSSVGPathSegListCustom code to call the static forgetGenericContext
     18        method instead of doing the same using custom code.
     19
     20        * bindings/js/JSSVGPathSegListCustom.cpp:
     21        (WebCore::removeFromPathSegContextMap):
     22        (WebCore::JSSVGPathSegList::clear):
     23        (WebCore::JSSVGPathSegList::removeItem):
     24        * bindings/scripts/CodeGeneratorJS.pm:
     25
    1262007-03-13  Darin Adler  <darin@apple.com>
    227
  • trunk/WebCore/bindings/js/JSSVGPathSegListCustom.cpp

    r19855 r20151  
    5858}
    5959
    60 static void removeFromPathSegContextMap(ExecState* exec, SVGPathSegList* list, SVGPathSeg* obj)
     60static void removeFromPathSegContextMap(SVGPathSegList* list, SVGPathSeg* obj)
    6161{
    62     ASSERT(exec && exec->dynamicInterpreter());
    63     Frame* activeFrame = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->frame();
    64     if (!activeFrame)
    65         return;
    66 
    6762    const SVGElement* context = list->context();
    6863    ASSERT(context);
    6964
    70     SVGDocumentExtensions* extensions = (activeFrame->document() ? activeFrame->document()->accessSVGExtensions() : 0);
    71     if (extensions) {
    72         if (extensions->hasGenericContext<SVGPathSeg>(obj))
    73             extensions->removeGenericContext<SVGPathSeg>(obj);
    74     }
    75 
     65    SVGDocumentExtensions::forgetGenericContext(obj);
    7666    context->notifyAttributeChange();
    7767}
     
    8575    unsigned int nr = imp->numberOfItems();
    8676    for (unsigned int i = 0; i < nr; i++)
    87         removeFromPathSegContextMap(exec, imp, imp->getItem(i, ec).get());
     77        removeFromPathSegContextMap(imp, imp->getItem(i, ec).get());
    8878
    8979    imp->clear(ec);
     
    182172
    183173    RefPtr<SVGPathSeg> obj(imp->removeItem(index, ec));
    184     removeFromPathSegContextMap(exec, imp, obj.get());
     174    removeFromPathSegContextMap(imp, obj.get());
    185175
    186176    KJS::JSValue* result = toJS(exec, obj.get());
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r19993 r20151  
    11#
    2 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
     2# Copyright (C) 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33# Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
    44# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
     
    167167}
    168168
     169sub CreateSVGContextInterfaceName
     170{
     171    my $type = shift;
     172
     173    return $type if $codeGenerator->IsSVGAnimatedType($type);
     174    return "SVGPathSeg" if $type =~ /^SVGPathSeg/ and $type ne "SVGPathSegList";
     175
     176    return "";
     177}
     178
    169179sub AddIncludesForType
    170180{
     
    730740        push(@implContent, "${className}::~$className()\n");
    731741
    732         if ($codeGenerator->IsSVGAnimatedType($interfaceName)) {
    733             push(@implContent, "{\n    SVGDocumentExtensions::forgetGenericContext<$interfaceName>(m_impl.get());\n");   
     742        my $contextInterfaceName = CreateSVGContextInterfaceName($interfaceName);
     743        if ($contextInterfaceName ne "") {
     744            push(@implContent, "{\n    SVGDocumentExtensions::forgetGenericContext<$contextInterfaceName>(m_impl.get());\n");   
    734745            push(@implContent, "    ScriptInterpreter::forgetDOMObject(m_impl.get());\n}\n\n");
    735746        } else {
     
    949960            push(@implContent, "    }\n"); # end switch
    950961
     962            my $contextInterfaceName = CreateSVGContextInterfaceName($interfaceName);
    951963            if ($interfaceName eq "DOMWindow") {
    952964                push(@implContent, "    // FIXME: Hack to prevent unused variable warning -- remove once DOMWindow includes a settable property\n");
    953965                push(@implContent, "    (void)imp;\n");
    954             } elsif ($interfaceName =~ /^SVGPathSeg/ or $codeGenerator->IsSVGAnimatedType($interfaceName)) {
     966            } elsif ($contextInterfaceName ne "") {
    955967                push(@implContent, "    ASSERT(exec && exec->dynamicInterpreter());\n");
    956968                push(@implContent, "    Frame* activeFrame = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->frame();\n");
    957969                push(@implContent, "    if (!activeFrame)\n        return;\n\n");
    958970                push(@implContent, "    SVGDocumentExtensions* extensions = (activeFrame->document() ? activeFrame->document()->accessSVGExtensions() : 0);\n");
    959                 push(@implContent, "    if (extensions && extensions->hasGenericContext<$interfaceName>(imp)) {\n");
    960                 push(@implContent, "        const SVGElement* context = extensions->genericContext<$interfaceName>(imp);\n");
     971                push(@implContent, "    if (extensions && extensions->hasGenericContext<$contextInterfaceName>(imp)) {\n");
     972                push(@implContent, "        const SVGElement* context = extensions->genericContext<$contextInterfaceName>(imp);\n");
    961973                push(@implContent, "        ASSERT(context);\n\n");
    962974                push(@implContent, "        context->notifyAttributeChange();\n");
Note: See TracChangeset for help on using the changeset viewer.