Changeset 119124 in webkit


Ignore:
Timestamp:
May 31, 2012 11:00:03 AM (12 years ago)
Author:
arv@chromium.org
Message:

Make DOM Exceptions Errors
https://bugs.webkit.org/show_bug.cgi?id=85078

Reviewed by Oliver Hunt.

WebIDL mandates that exceptions should have Error.prototype on its prototype chain.

For JSC we have access to the Error.prototype from the binding code.

For V8 we set a field in the WrapperTypeInfo and when the constructor function is created we
set the prototype as needed.

Updated test: fast/dom/DOMException/prototype-object.html

Source/JavaScriptCore:

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::reset):

  • runtime/JSGlobalObject.h:

(JSC):
(JSGlobalObject):
(JSC::JSGlobalObject::errorPrototype):

Source/WebCore:

  • ForwardingHeaders/runtime/ErrorPrototype.h: Added.
  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):
(GenerateImplementation):

  • bindings/scripts/CodeGeneratorV8.pm:

(GenerateNamedConstructorCallback):
(GenerateImplementation):

  • bindings/scripts/test/JS/JSTestException.cpp:

(WebCore::JSTestException::createPrototype):

  • bindings/scripts/test/JS/JSTestException.h:
  • bindings/scripts/test/V8/V8Float64Array.cpp:

(WebCore):

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

(WebCore):

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

(WebCore):

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

(WebCore):

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

(WebCore):

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

(WebCore):

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

(WebCore):

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

(WebCore):

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

(WebCore):

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

(WebCore):

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

(WebCore):
(WebCore::V8TestObj::installPerContextProperties):

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

(WebCore):

  • bindings/v8/NPV8Object.cpp:

(WebCore::npObjectTypeInfo):

  • bindings/v8/V8BindingPerContextData.cpp:

(WebCore):
(WebCore::V8BindingPerContextData::init):
(WebCore::V8BindingPerContextData::createWrapperFromCacheSlowCase):
(WebCore::V8BindingPerContextData::constructorForTypeSlowCase):

  • bindings/v8/V8BindingPerContextData.h:

(V8BindingPerContextData):

  • bindings/v8/V8HiddenPropertyName.h:

(WebCore):

  • bindings/v8/WrapperTypeInfo.h:

(WebCore):
(WrapperTypeInfo):

  • bindings/v8/custom/V8HTMLImageElementConstructor.cpp:

(WebCore):

LayoutTests:

  • fast/dom/DOMException/prototype-object-expected.txt:
  • fast/dom/DOMException/prototype-object.html:
  • fast/dom/DOMException/resources/prototype-object.js: Removed.
  • platform/chromium-win/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt: Removed.
  • platform/chromium-win/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt: Removed.
  • platform/chromium-win/svg/filters/feBlend-invalid-mode-expected.txt: Removed.
  • platform/chromium/dom/xhtml/level3/core/documentnormalizedocument10-expected.txt: Added.
  • platform/chromium/dom/xhtml/level3/core/documentsetxmlversion03-expected.txt: Added.
  • platform/chromium/fast/dom/DOMException/prototype-object-expected.txt:
  • platform/chromium/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt: Renamed from LayoutTests/platform/chromium-mac/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt.
  • platform/chromium/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt: Renamed from LayoutTests/platform/chromium-mac/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt.
  • platform/chromium/svg/filters/feBlend-invalid-mode-expected.txt: Renamed from LayoutTests/platform/chromium-mac/svg/filters/feBlend-invalid-mode-expected.txt.
Location:
trunk
Files:
8 added
4 deleted
31 edited
3 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r119123 r119124  
     12012-05-31  Erik Arvidsson  <arv@chromium.org>
     2
     3        Make DOM Exceptions Errors
     4        https://bugs.webkit.org/show_bug.cgi?id=85078
     5
     6        Reviewed by Oliver Hunt.
     7
     8        WebIDL mandates that exceptions should have Error.prototype on its prototype chain.
     9
     10        For JSC we have access to the Error.prototype from the binding code.
     11
     12        For V8 we set a field in the WrapperTypeInfo and when the constructor function is created we
     13        set the prototype as needed.
     14
     15        Updated test: fast/dom/DOMException/prototype-object.html
     16
     17        * fast/dom/DOMException/prototype-object-expected.txt:
     18        * fast/dom/DOMException/prototype-object.html:
     19        * fast/dom/DOMException/resources/prototype-object.js: Removed.
     20        * platform/chromium-win/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt: Removed.
     21        * platform/chromium-win/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt: Removed.
     22        * platform/chromium-win/svg/filters/feBlend-invalid-mode-expected.txt: Removed.
     23        * platform/chromium/dom/xhtml/level3/core/documentnormalizedocument10-expected.txt: Added.
     24        * platform/chromium/dom/xhtml/level3/core/documentsetxmlversion03-expected.txt: Added.
     25        * platform/chromium/fast/dom/DOMException/prototype-object-expected.txt:
     26        * platform/chromium/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt: Renamed from LayoutTests/platform/chromium-mac/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt.
     27        * platform/chromium/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt: Renamed from LayoutTests/platform/chromium-mac/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt.
     28        * platform/chromium/svg/filters/feBlend-invalid-mode-expected.txt: Renamed from LayoutTests/platform/chromium-mac/svg/filters/feBlend-invalid-mode-expected.txt.
     29
    1302012-05-31  Jessie Berlin  <jberlin@apple.com>
    231
  • trunk/LayoutTests/fast/dom/DOMException/prototype-object-expected.txt

    r30635 r119124  
    1 DOMException needs a real prototype: http://bugs.webkit.org/show_bug.cgi?id=16637
     1This tests the prototype chain of DOMException objects.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     
    77PASS Object.prototype.toString.call(e) is "[object DOMException]"
    88PASS Object.prototype.toString.call(e.__proto__) is "[object DOMExceptionPrototype]"
     9PASS Object.prototype.toString.call(e.__proto__.__proto__) is "[object Error]"
    910PASS e.constructor.toString() is "[object DOMExceptionConstructor]"
     11PASS e instanceof DOMException is true
     12PASS e instanceof Error is true
    1013PASS e.constructor is window.DOMException
    1114PASS e.HIERARCHY_REQUEST_ERR is e.constructor.HIERARCHY_REQUEST_ERR
    1215PASS e.HIERARCHY_REQUEST_ERR is 3
     16PASS e.code is 3
     17PASS e.name is "HIERARCHY_REQUEST_ERR"
     18PASS e.message is "HIERARCHY_REQUEST_ERR: DOM Exception 3"
    1319PASS successfullyParsed is true
    1420
  • trunk/LayoutTests/fast/dom/DOMException/prototype-object.html

    r97881 r119124  
    1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
    2 <html>
    3 <head>
     1<!DOCTYPE html>
    42<script src="../../js/resources/js-test-pre.js"></script>
    5 </head>
    6 <body>
    7 <script src="resources/prototype-object.js"></script>
     3<script>
     4
     5description("This tests the prototype chain of DOMException objects.")
     6
     7var e;
     8try {
     9  document.appendChild(document);
     10   // raises a HIERARCHY_REQUEST_ERR
     11} catch (err) {
     12  e = err;
     13}
     14
     15shouldBeEqualToString("e.toString()", "Error: HIERARCHY_REQUEST_ERR: DOM Exception 3");
     16shouldBeEqualToString("Object.prototype.toString.call(e)", "[object DOMException]");
     17shouldBeEqualToString("Object.prototype.toString.call(e.__proto__)", "[object DOMExceptionPrototype]");
     18shouldBeEqualToString("Object.prototype.toString.call(e.__proto__.__proto__)", "[object Error]");
     19shouldBeEqualToString("e.constructor.toString()", "[object DOMExceptionConstructor]");
     20shouldBeTrue("e instanceof DOMException");
     21shouldBeTrue("e instanceof Error");
     22shouldBe("e.constructor", "window.DOMException");
     23shouldBe("e.HIERARCHY_REQUEST_ERR", "e.constructor.HIERARCHY_REQUEST_ERR");
     24shouldBe("e.HIERARCHY_REQUEST_ERR", "3");
     25shouldBe("e.code", "3");
     26shouldBeEqualToString("e.name", "HIERARCHY_REQUEST_ERR");
     27shouldBeEqualToString("e.message", "HIERARCHY_REQUEST_ERR: DOM Exception 3");
     28
     29</script>
    830<script src="../../js/resources/js-test-post.js"></script>
    9 </body>
    10 </html>
  • trunk/LayoutTests/platform/chromium/fast/dom/DOMException/prototype-object-expected.txt

    r92644 r119124  
    1 DOMException needs a real prototype: http://bugs.webkit.org/show_bug.cgi?id=16637
     1This tests the prototype chain of DOMException objects.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     
    77PASS Object.prototype.toString.call(e) is "[object DOMException]"
    88FAIL Object.prototype.toString.call(e.__proto__) should be [object DOMExceptionPrototype]. Was [object Object].
     9PASS Object.prototype.toString.call(e.__proto__.__proto__) is "[object Error]"
    910FAIL e.constructor.toString() should be [object DOMExceptionConstructor]. Was function DOMException() { [native code] }.
     11PASS e instanceof DOMException is true
     12PASS e instanceof Error is true
    1013PASS e.constructor is window.DOMException
    1114PASS e.HIERARCHY_REQUEST_ERR is e.constructor.HIERARCHY_REQUEST_ERR
    1215PASS e.HIERARCHY_REQUEST_ERR is 3
     16PASS e.code is 3
     17PASS e.name is "HIERARCHY_REQUEST_ERR"
     18PASS e.message is "HIERARCHY_REQUEST_ERR: DOM Exception 3"
    1319PASS successfullyParsed is true
    1420
  • trunk/Source/JavaScriptCore/ChangeLog

    r119117 r119124  
     12012-05-31  Erik Arvidsson  <arv@chromium.org>
     2
     3        Make DOM Exceptions Errors
     4        https://bugs.webkit.org/show_bug.cgi?id=85078
     5
     6        Reviewed by Oliver Hunt.
     7
     8        WebIDL mandates that exceptions should have Error.prototype on its prototype chain.
     9
     10        For JSC we have access to the Error.prototype from the binding code.
     11
     12        For V8 we set a field in the WrapperTypeInfo and when the constructor function is created we
     13        set the prototype as needed.
     14
     15        Updated test: fast/dom/DOMException/prototype-object.html
     16
     17        * JavaScriptCore.xcodeproj/project.pbxproj:
     18        * runtime/JSGlobalObject.cpp:
     19        (JSC::JSGlobalObject::reset):
     20        * runtime/JSGlobalObject.h:
     21        (JSC):
     22        (JSGlobalObject):
     23        (JSC::JSGlobalObject::errorPrototype):
     24
    1252012-05-31  Andy Wingo  <wingo@igalia.com>
    226
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r119028 r119124  
    525525                A8A4748E151A8306004123FF /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8A4748D151A8306004123FF /* libWTF.a */; };
    526526                BC02E90D0E1839DB000F9297 /* ErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9050E1839DB000F9297 /* ErrorConstructor.h */; };
    527                 BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9070E1839DB000F9297 /* ErrorPrototype.h */; };
     527                BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9070E1839DB000F9297 /* ErrorPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; };
    528528                BC02E9110E1839DB000F9297 /* NativeErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9090E1839DB000F9297 /* NativeErrorConstructor.h */; };
    529529                BC02E9130E1839DB000F9297 /* NativeErrorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E90B0E1839DB000F9297 /* NativeErrorPrototype.h */; };
    530                 BC02E98D0E183E38000F9297 /* ErrorInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E98B0E183E38000F9297 /* ErrorInstance.h */; };
     530                BC02E98D0E183E38000F9297 /* ErrorInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E98B0E183E38000F9297 /* ErrorInstance.h */; settings = {ATTRIBUTES = (Private, ); }; };
    531531                BC1166020E1997B4008066DD /* DateInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1166010E1997B1008066DD /* DateInstance.h */; settings = {ATTRIBUTES = (Private, ); }; };
    532532                BC11667B0E199C05008066DD /* InternalFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = BC11667A0E199C05008066DD /* InternalFunction.h */; settings = {ATTRIBUTES = (Private, ); }; };
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r118616 r119124  
    245245    m_methodCallDummy.set(exec->globalData(), this, constructEmptyObject(exec));
    246246
    247     ErrorPrototype* errorPrototype = ErrorPrototype::create(exec, this, ErrorPrototype::createStructure(exec->globalData(), this, m_objectPrototype.get()));
    248     m_errorStructure.set(exec->globalData(), this, ErrorInstance::createStructure(exec->globalData(), this, errorPrototype));
     247    m_errorPrototype.set(exec->globalData(), this, ErrorPrototype::create(exec, this, ErrorPrototype::createStructure(exec->globalData(), this, m_objectPrototype.get())));
     248    m_errorStructure.set(exec->globalData(), this, ErrorInstance::createStructure(exec->globalData(), this, m_errorPrototype.get()));
    249249
    250250    // Constructors
     
    260260    m_regExpConstructor.set(exec->globalData(), this, RegExpConstructor::create(exec, this, RegExpConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get()), m_regExpPrototype.get()));
    261261
    262     m_errorConstructor.set(exec->globalData(), this, ErrorConstructor::create(exec, this, ErrorConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get()), errorPrototype));
    263 
    264     Structure* nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(exec->globalData(), this, errorPrototype);
     262    m_errorConstructor.set(exec->globalData(), this, ErrorConstructor::create(exec, this, ErrorConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get()), m_errorPrototype.get()));
     263
     264    Structure* nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(exec->globalData(), this, m_errorPrototype.get());
    265265    Structure* nativeErrorStructure = NativeErrorConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get());
    266266    m_evalErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "EvalError"));
     
    279279    m_datePrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, dateConstructor, DontEnum);
    280280    m_regExpPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, m_regExpConstructor.get(), DontEnum);
    281     errorPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, m_errorConstructor.get(), DontEnum);
     281    m_errorPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, m_errorConstructor.get(), DontEnum);
    282282
    283283    putDirectWithoutTransition(exec->globalData(), Identifier(exec, "Object"), objectConstructor, DontEnum);
     
    375375    visitIfNeeded(visitor, &thisObject->m_datePrototype);
    376376    visitIfNeeded(visitor, &thisObject->m_regExpPrototype);
     377    visitIfNeeded(visitor, &thisObject->m_errorPrototype);
    377378
    378379    visitIfNeeded(visitor, &thisObject->m_argumentsStructure);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r118018 r119124  
    4242    class Debugger;
    4343    class ErrorConstructor;
     44    class ErrorPrototype;
    4445    class FunctionPrototype;
    4546    class GetterSetter;
     
    118119        WriteBarrier<DatePrototype> m_datePrototype;
    119120        WriteBarrier<RegExpPrototype> m_regExpPrototype;
     121        WriteBarrier<ErrorPrototype> m_errorPrototype;
    120122
    121123        WriteBarrier<Structure> m_argumentsStructure;
     
    253255        DatePrototype* datePrototype() const { return m_datePrototype.get(); }
    254256        RegExpPrototype* regExpPrototype() const { return m_regExpPrototype.get(); }
     257        ErrorPrototype* errorPrototype() const { return m_errorPrototype.get(); }
    255258
    256259        JSObject* methodCallDummy() const { return m_methodCallDummy.get(); }
  • trunk/Source/WebCore/ChangeLog

    r119121 r119124  
     12012-05-31  Erik Arvidsson  <arv@chromium.org>
     2
     3        Make DOM Exceptions Errors
     4        https://bugs.webkit.org/show_bug.cgi?id=85078
     5
     6        Reviewed by Oliver Hunt.
     7
     8        WebIDL mandates that exceptions should have Error.prototype on its prototype chain.
     9
     10        For JSC we have access to the Error.prototype from the binding code.
     11
     12        For V8 we set a field in the WrapperTypeInfo and when the constructor function is created we
     13        set the prototype as needed.
     14
     15        Updated test: fast/dom/DOMException/prototype-object.html
     16
     17        * ForwardingHeaders/runtime/ErrorPrototype.h: Added.
     18        * bindings/scripts/CodeGeneratorJS.pm:
     19        (GenerateHeader):
     20        (GenerateImplementation):
     21        * bindings/scripts/CodeGeneratorV8.pm:
     22        (GenerateNamedConstructorCallback):
     23        (GenerateImplementation):
     24        * bindings/scripts/test/JS/JSTestException.cpp:
     25        (WebCore::JSTestException::createPrototype):
     26        * bindings/scripts/test/JS/JSTestException.h:
     27        * bindings/scripts/test/V8/V8Float64Array.cpp:
     28        (WebCore):
     29        * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
     30        (WebCore):
     31        * bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:
     32        (WebCore):
     33        * bindings/scripts/test/V8/V8TestEventConstructor.cpp:
     34        (WebCore):
     35        * bindings/scripts/test/V8/V8TestEventTarget.cpp:
     36        (WebCore):
     37        * bindings/scripts/test/V8/V8TestException.cpp:
     38        (WebCore):
     39        * bindings/scripts/test/V8/V8TestInterface.cpp:
     40        (WebCore):
     41        * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
     42        (WebCore):
     43        * bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
     44        (WebCore):
     45        * bindings/scripts/test/V8/V8TestNode.cpp:
     46        (WebCore):
     47        * bindings/scripts/test/V8/V8TestObj.cpp:
     48        (WebCore):
     49        (WebCore::V8TestObj::installPerContextProperties):
     50        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
     51        (WebCore):
     52        * bindings/v8/NPV8Object.cpp:
     53        (WebCore::npObjectTypeInfo):
     54        * bindings/v8/V8BindingPerContextData.cpp:
     55        (WebCore):
     56        (WebCore::V8BindingPerContextData::init):
     57        (WebCore::V8BindingPerContextData::createWrapperFromCacheSlowCase):
     58        (WebCore::V8BindingPerContextData::constructorForTypeSlowCase):
     59        * bindings/v8/V8BindingPerContextData.h:
     60        (V8BindingPerContextData):
     61        * bindings/v8/V8HiddenPropertyName.h:
     62        (WebCore):
     63        * bindings/v8/WrapperTypeInfo.h:
     64        (WebCore):
     65        (WrapperTypeInfo):
     66        * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
     67        (WebCore):
     68
    1692012-05-31  Ian Vollick  <vollick@chromium.org>
    270
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r118735 r119124  
    662662        $headerIncludes{"JSDOMBinding.h"} = 1;
    663663        $headerIncludes{"<runtime/JSGlobalObject.h>"} = 1;
    664         $headerIncludes{"<runtime/ObjectPrototype.h>"} = 1;
     664        if ($dataNode->isException) {
     665            $headerIncludes{"<runtime/ErrorPrototype.h>"} = 1;
     666        } else {
     667            $headerIncludes{"<runtime/ObjectPrototype.h>"} = 1;
     668        }
    665669    }
    666670
     
    16131617            push(@implContent, "    return ${className}Prototype::create(exec->globalData(), globalObject, ${className}Prototype::createStructure(exec->globalData(), globalObject, ${parentClassName}Prototype::self(exec, globalObject)));\n");
    16141618        } else {
    1615             push(@implContent, "    return ${className}Prototype::create(exec->globalData(), globalObject, ${className}Prototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));\n");
     1619            my $prototype = $dataNode->isException ? "errorPrototype" : "objectPrototype";
     1620            push(@implContent, "    return ${className}Prototype::create(exec->globalData(), globalObject, ${className}Prototype::createStructure(globalObject->globalData(), globalObject, globalObject->${prototype}()));\n");
    16161621        }
    16171622        push(@implContent, "}\n\n");
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r119004 r119124  
    18691869    if ($dataNode->extendedAttributes->{"ActiveDOMObject"}) {
    18701870        push(@implContent, <<END);
    1871 WrapperTypeInfo V8${implClassName}Constructor::info = { V8${implClassName}Constructor::GetTemplate, V8${implClassName}::derefObject, V8${implClassName}::toActiveDOMObject, 0 };
     1871WrapperTypeInfo V8${implClassName}Constructor::info = { V8${implClassName}Constructor::GetTemplate, V8${implClassName}::derefObject, V8${implClassName}::toActiveDOMObject, 0, WrapperTypeObjectPrototype };
    18721872
    18731873END
    18741874    } else {
    18751875        push(@implContent, <<END);
    1876 WrapperTypeInfo V8${implClassName}Constructor::info = { V8${implClassName}Constructor::GetTemplate, 0, 0, 0 };
     1876WrapperTypeInfo V8${implClassName}Constructor::info = { V8${implClassName}Constructor::GetTemplate, 0, 0, 0, WrapperTypeObjectPrototype };
    18771877
    18781878END
     
    24422442    push(@implContentDecls, "namespace WebCore {\n\n");
    24432443    my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0";
    2444     push(@implContentDecls, "WrapperTypeInfo ${className}::info = { ${className}::GetTemplate, ${className}::derefObject, ${toActive}, ${parentClassInfo} };\n\n");   
     2444
     2445    my $WrapperTypePrototype = $dataNode->isException ? "WrapperTypeErrorPrototype" : "WrapperTypeObjectPrototype";
     2446
     2447    push(@implContentDecls, "WrapperTypeInfo ${className}::info = { ${className}::GetTemplate, ${className}::derefObject, $toActive, $parentClassInfo, $WrapperTypePrototype };\n\n");
    24452448    push(@implContentDecls, "namespace ${interfaceName}V8Internal {\n\n");
     2449
    24462450    push(@implContentDecls, "template <typename T> void V8_USE(T) { }\n\n");
    24472451
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp

    r118651 r119124  
    105105JSObject* JSTestException::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
    106106{
    107     return JSTestExceptionPrototype::create(exec->globalData(), globalObject, JSTestExceptionPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
     107    return JSTestExceptionPrototype::create(exec->globalData(), globalObject, JSTestExceptionPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->errorPrototype()));
    108108}
    109109
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.h

    r116828 r119124  
    2424#include "JSDOMBinding.h"
    2525#include "TestException.h"
     26#include <runtime/ErrorPrototype.h>
    2627#include <runtime/JSGlobalObject.h>
    2728#include <runtime/JSObject.h>
    28 #include <runtime/ObjectPrototype.h>
    2929
    3030namespace WebCore {
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp

    r117925 r119124  
    4444namespace WebCore {
    4545
    46 WrapperTypeInfo V8Float64Array::info = { V8Float64Array::GetTemplate, V8Float64Array::derefObject, 0, &V8ArrayBufferView::info };
     46WrapperTypeInfo V8Float64Array::info = { V8Float64Array::GetTemplate, V8Float64Array::derefObject, 0, &V8ArrayBufferView::info, WrapperTypeObjectPrototype };
    4747
    4848namespace Float64ArrayV8Internal {
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp

    r117925 r119124  
    3636namespace WebCore {
    3737
    38 WrapperTypeInfo V8TestActiveDOMObject::info = { V8TestActiveDOMObject::GetTemplate, V8TestActiveDOMObject::derefObject, 0, 0 };
     38WrapperTypeInfo V8TestActiveDOMObject::info = { V8TestActiveDOMObject::GetTemplate, V8TestActiveDOMObject::derefObject, 0, 0, WrapperTypeObjectPrototype };
    3939
    4040namespace TestActiveDOMObjectV8Internal {
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp

    r117925 r119124  
    3535namespace WebCore {
    3636
    37 WrapperTypeInfo V8TestCustomNamedGetter::info = { V8TestCustomNamedGetter::GetTemplate, V8TestCustomNamedGetter::derefObject, 0, 0 };
     37WrapperTypeInfo V8TestCustomNamedGetter::info = { V8TestCustomNamedGetter::GetTemplate, V8TestCustomNamedGetter::derefObject, 0, 0, WrapperTypeObjectPrototype };
    3838
    3939namespace TestCustomNamedGetterV8Internal {
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp

    r117925 r119124  
    3535namespace WebCore {
    3636
    37 WrapperTypeInfo V8TestEventConstructor::info = { V8TestEventConstructor::GetTemplate, V8TestEventConstructor::derefObject, 0, 0 };
     37WrapperTypeInfo V8TestEventConstructor::info = { V8TestEventConstructor::GetTemplate, V8TestEventConstructor::derefObject, 0, 0, WrapperTypeObjectPrototype };
    3838
    3939namespace TestEventConstructorV8Internal {
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp

    r119003 r119124  
    3838namespace WebCore {
    3939
    40 WrapperTypeInfo V8TestEventTarget::info = { V8TestEventTarget::GetTemplate, V8TestEventTarget::derefObject, 0, 0 };
     40WrapperTypeInfo V8TestEventTarget::info = { V8TestEventTarget::GetTemplate, V8TestEventTarget::derefObject, 0, 0, WrapperTypeObjectPrototype };
    4141
    4242namespace TestEventTargetV8Internal {
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp

    r117925 r119124  
    3333namespace WebCore {
    3434
    35 WrapperTypeInfo V8TestException::info = { V8TestException::GetTemplate, V8TestException::derefObject, 0, 0 };
     35WrapperTypeInfo V8TestException::info = { V8TestException::GetTemplate, V8TestException::derefObject, 0, 0, WrapperTypeErrorPrototype };
    3636
    3737namespace TestExceptionV8Internal {
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp

    r117926 r119124  
    4343namespace WebCore {
    4444
    45 WrapperTypeInfo V8TestInterface::info = { V8TestInterface::GetTemplate, V8TestInterface::derefObject, V8TestInterface::toActiveDOMObject, 0 };
     45WrapperTypeInfo V8TestInterface::info = { V8TestInterface::GetTemplate, V8TestInterface::derefObject, V8TestInterface::toActiveDOMObject, 0, WrapperTypeObjectPrototype };
    4646
    4747namespace TestInterfaceV8Internal {
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp

    r117925 r119124  
    3636namespace WebCore {
    3737
    38 WrapperTypeInfo V8TestMediaQueryListListener::info = { V8TestMediaQueryListListener::GetTemplate, V8TestMediaQueryListListener::derefObject, 0, 0 };
     38WrapperTypeInfo V8TestMediaQueryListListener::info = { V8TestMediaQueryListListener::GetTemplate, V8TestMediaQueryListListener::derefObject, 0, 0, WrapperTypeObjectPrototype };
    3939
    4040namespace TestMediaQueryListListenerV8Internal {
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp

    r117925 r119124  
    3535namespace WebCore {
    3636
    37 WrapperTypeInfo V8TestNamedConstructor::info = { V8TestNamedConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0 };
     37WrapperTypeInfo V8TestNamedConstructor::info = { V8TestNamedConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0, WrapperTypeObjectPrototype };
    3838
    3939namespace TestNamedConstructorV8Internal {
     
    4343} // namespace TestNamedConstructorV8Internal
    4444
    45 WrapperTypeInfo V8TestNamedConstructorConstructor::info = { V8TestNamedConstructorConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0 };
     45WrapperTypeInfo V8TestNamedConstructorConstructor::info = { V8TestNamedConstructorConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0, WrapperTypeObjectPrototype };
    4646
    4747static v8::Handle<v8::Value> V8TestNamedConstructorConstructorCallback(const v8::Arguments& args)
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp

    r117925 r119124  
    3434namespace WebCore {
    3535
    36 WrapperTypeInfo V8TestNode::info = { V8TestNode::GetTemplate, V8TestNode::derefObject, 0, &V8Node::info };
     36WrapperTypeInfo V8TestNode::info = { V8TestNode::GetTemplate, V8TestNode::derefObject, 0, &V8Node::info, WrapperTypeObjectPrototype };
    3737
    3838namespace TestNodeV8Internal {
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r119003 r119124  
    7575namespace WebCore {
    7676
    77 WrapperTypeInfo V8TestObj::info = { V8TestObj::GetTemplate, V8TestObj::derefObject, 0, 0 };
     77WrapperTypeInfo V8TestObj::info = { V8TestObj::GetTemplate, V8TestObj::derefObject, 0, 0, WrapperTypeObjectPrototype };
    7878
    7979namespace TestObjV8Internal {
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp

    r118999 r119124  
    4141namespace WebCore {
    4242
    43 WrapperTypeInfo V8TestSerializedScriptValueInterface::info = { V8TestSerializedScriptValueInterface::GetTemplate, V8TestSerializedScriptValueInterface::derefObject, 0, 0 };
     43WrapperTypeInfo V8TestSerializedScriptValueInterface::info = { V8TestSerializedScriptValueInterface::GetTemplate, V8TestSerializedScriptValueInterface::derefObject, 0, 0, WrapperTypeObjectPrototype };
    4444
    4545namespace TestSerializedScriptValueInterfaceV8Internal {
  • trunk/Source/WebCore/bindings/v8/NPV8Object.cpp

    r117012 r119124  
    5454WrapperTypeInfo* npObjectTypeInfo()
    5555{
    56     static WrapperTypeInfo typeInfo = { 0, 0, 0, 0 };
     56    static WrapperTypeInfo typeInfo = { 0, 0, 0, 0, WrapperTypeObjectPrototype };
    5757    return &typeInfo;
    5858}
  • trunk/Source/WebCore/bindings/v8/V8BindingPerContextData.cpp

    r114200 r119124  
    5757}
    5858
     59#define V8_STORE_PRIMORDIAL(name, Name) \
     60{ \
     61    ASSERT(m_##name##Prototype.get().IsEmpty()); \
     62    v8::Handle<v8::String> symbol = v8::String::NewSymbol(#Name); \
     63    if (symbol.IsEmpty()) \
     64        return false; \
     65    v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(m_context->Global()->Get(symbol)); \
     66    if (object.IsEmpty()) \
     67        return false; \
     68    v8::Handle<v8::Value> prototypeValue = object->Get(prototypeString); \
     69    if (prototypeValue.IsEmpty()) \
     70        return false; \
     71    m_##name##Prototype.set(prototypeValue); \
     72}
     73
    5974bool V8BindingPerContextData::init()
    6075{
    61     ASSERT(m_objectPrototype.get().IsEmpty());
    62 
    63     v8::Handle<v8::String> objectString = v8::String::New("Object");
    64     v8::Handle<v8::String> prototypeString = v8::String::New("prototype");
    65     if (objectString.IsEmpty() || prototypeString.IsEmpty())
     76    v8::Handle<v8::String> prototypeString = v8::String::NewSymbol("prototype");
     77    if (prototypeString.IsEmpty())
    6678        return false;
    6779
    68     v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(m_context->Global()->Get(objectString));
    69     if (object.IsEmpty())
    70         return false;
    71     v8::Handle<v8::Value> objectPrototype = object->Get(prototypeString);
    72     if (objectPrototype.IsEmpty())
    73         return false;
     80    V8_STORE_PRIMORDIAL(error, Error);
     81    V8_STORE_PRIMORDIAL(object, Object);
    7482
    75     m_objectPrototype.set(objectPrototype);
    7683    return true;
    7784}
    7885
     86#undef V8_STORE_PRIMORDIAL
     87
    7988v8::Local<v8::Object> V8BindingPerContextData::createWrapperFromCacheSlowCase(WrapperTypeInfo* type)
    8089{
     90    ASSERT(!m_errorPrototype.get().IsEmpty());
    8191    ASSERT(!m_objectPrototype.get().IsEmpty());
    8292
     
    93103v8::Local<v8::Function> V8BindingPerContextData::constructorForTypeSlowCase(WrapperTypeInfo* type)
    94104{
     105    ASSERT(!m_errorPrototype.get().IsEmpty());
    95106    ASSERT(!m_objectPrototype.get().IsEmpty());
    96107
     
    105116    function->SetPrototype(m_objectPrototype.get());
    106117
     118    if (type->wrapperTypePrototype == WrapperTypeErrorPrototype) {
     119        v8::Local<v8::Value> prototypeValue = function->Get(v8::String::NewSymbol("prototype"));
     120        if (prototypeValue->IsObject())
     121            v8::Local<v8::Object>::Cast(prototypeValue)->SetPrototype(m_errorPrototype.get());
     122    }
     123
    107124    m_constructorMap.set(type, v8::Persistent<v8::Function>::New(function));
    108125
  • trunk/Source/WebCore/bindings/v8/V8BindingPerContextData.h

    r114200 r119124  
    9191
    9292    v8::Handle<v8::Context> m_context;
     93    OwnHandle<v8::Value> m_errorPrototype;
    9394    OwnHandle<v8::Value> m_objectPrototype;
    9495};
  • trunk/Source/WebCore/bindings/v8/V8HiddenPropertyName.h

    r114200 r119124  
    3737
    3838#define V8_HIDDEN_PROPERTIES(V) \
    39     V(objectPrototype) \
    4039    V(listener) \
    4140    V(attributeListener) \
  • trunk/Source/WebCore/bindings/v8/WrapperTypeInfo.h

    r114200 r119124  
    4747    typedef void (*DerefObjectFunction)(void*);
    4848    typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Handle<v8::Object>);
    49    
     49
     50    enum WrapperTypePrototype {
     51        WrapperTypeObjectPrototype,
     52        WrapperTypeErrorPrototype
     53    };
     54
    5055    // This struct provides a way to store a bunch of information that is helpful when unwrapping
    5156    // v8 objects. Each v8 bindings class has exactly one static WrapperTypeInfo member, so
    5257    // comparing pointers is a safe way to determine if types match.
    5358    struct WrapperTypeInfo {
    54        
     59
    5560        static WrapperTypeInfo* unwrap(v8::Handle<v8::Value> typeInfoWrapper)
    5661        {
     
    9398        const ToActiveDOMObjectFunction toActiveDOMObjectFunction;
    9499        const WrapperTypeInfo* parentClass;
     100        const WrapperTypePrototype wrapperTypePrototype;
    95101    };
    96102}
  • trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp

    r118071 r119124  
    4545namespace WebCore {
    4646
    47 WrapperTypeInfo V8HTMLImageElementConstructor::info = { V8HTMLImageElementConstructor::GetTemplate, 0, 0, 0 };
     47WrapperTypeInfo V8HTMLImageElementConstructor::info = { V8HTMLImageElementConstructor::GetTemplate, 0, 0, 0, WrapperTypeObjectPrototype };
    4848
    4949static v8::Handle<v8::Value> v8HTMLImageElementConstructorCallback(const v8::Arguments& args)
Note: See TracChangeset for help on using the changeset viewer.