diff options
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/bindings/js/JSDOMBinding.cpp | 18 | ||||
-rw-r--r-- | WebCore/bindings/js/JSDOMBinding.h | 16 | ||||
-rw-r--r-- | WebCore/bindings/js/JSDOMWindowCustom.cpp | 26 | ||||
-rw-r--r-- | WebCore/bindings/js/JSDocumentCustom.cpp | 9 | ||||
-rw-r--r-- | WebCore/bindings/js/JSMessageChannelConstructor.cpp | 2 | ||||
-rw-r--r-- | WebCore/bindings/js/JSNamedNodesCollection.h | 4 | ||||
-rw-r--r-- | WebCore/bindings/js/JSRGBColor.h | 4 | ||||
-rw-r--r-- | WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp | 2 | ||||
-rw-r--r-- | WebCore/bindings/scripts/CodeGeneratorJS.pm | 16 | ||||
-rw-r--r-- | WebCore/bridge/runtime_array.h | 4 | ||||
-rw-r--r-- | WebCore/bridge/runtime_method.h | 4 | ||||
-rw-r--r-- | WebCore/bridge/runtime_object.h | 4 | ||||
-rw-r--r-- | WebCore/page/DOMWindow.idl | 4 |
13 files changed, 81 insertions, 32 deletions
diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp index 6e27dc1..5db8791 100644 --- a/WebCore/bindings/js/JSDOMBinding.cpp +++ b/WebCore/bindings/js/JSDOMBinding.cpp @@ -509,19 +509,29 @@ ScriptState* scriptStateFromNode(Node* node) return frame->script()->globalObject()->globalExec(); } -Structure* getCachedDOMStructure(ExecState* exec, const ClassInfo* classInfo) +Structure* getCachedDOMStructure(JSDOMGlobalObject* globalObject, const ClassInfo* classInfo) { - JSDOMStructureMap& structures = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->structures(); + JSDOMStructureMap& structures = globalObject->structures(); return structures.get(classInfo).get(); } -Structure* cacheDOMStructure(ExecState* exec, PassRefPtr<Structure> structure, const ClassInfo* classInfo) +Structure* cacheDOMStructure(JSDOMGlobalObject* globalObject, PassRefPtr<Structure> structure, const ClassInfo* classInfo) { - JSDOMStructureMap& structures = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->structures(); + JSDOMStructureMap& structures = globalObject->structures(); ASSERT(!structures.contains(classInfo)); return structures.set(classInfo, structure).first->second.get(); } +Structure* getCachedDOMStructure(ExecState* exec, const ClassInfo* classInfo) +{ + return getCachedDOMStructure(static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), classInfo); +} + +Structure* cacheDOMStructure(ExecState* exec, PassRefPtr<Structure> structure, const ClassInfo* classInfo) +{ + return cacheDOMStructure(static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), structure, classInfo); +} + JSObject* getCachedDOMConstructor(ExecState* exec, const ClassInfo* classInfo) { JSDOMConstructorMap& constructors = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->constructors(); diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h index 71da21b..5870ecc 100644 --- a/WebCore/bindings/js/JSDOMBinding.h +++ b/WebCore/bindings/js/JSDOMBinding.h @@ -73,21 +73,27 @@ namespace WebCore { void markActiveObjectsForContext(JSC::JSGlobalData&, ScriptExecutionContext*); void markDOMObjectWrapper(JSC::JSGlobalData& globalData, void* object); + JSC::Structure* getCachedDOMStructure(JSDOMGlobalObject*, const JSC::ClassInfo*); + JSC::Structure* cacheDOMStructure(JSDOMGlobalObject*, PassRefPtr<JSC::Structure>, const JSC::ClassInfo*); JSC::Structure* getCachedDOMStructure(JSC::ExecState*, const JSC::ClassInfo*); JSC::Structure* cacheDOMStructure(JSC::ExecState*, PassRefPtr<JSC::Structure>, const JSC::ClassInfo*); JSC::JSObject* getCachedDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*); void cacheDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*, JSC::JSObject* constructor); - template<class WrapperClass> inline JSC::Structure* getDOMStructure(JSC::ExecState* exec) + template<class WrapperClass> inline JSC::Structure* getDOMStructure(JSC::ExecState* exec, JSDOMGlobalObject* globalObject) { - if (JSC::Structure* structure = getCachedDOMStructure(exec, &WrapperClass::s_info)) + if (JSC::Structure* structure = getCachedDOMStructure(globalObject, &WrapperClass::s_info)) return structure; - return cacheDOMStructure(exec, WrapperClass::createStructure(WrapperClass::createPrototype(exec)), &WrapperClass::s_info); + return cacheDOMStructure(globalObject, WrapperClass::createStructure(WrapperClass::createPrototype(exec, globalObject)), &WrapperClass::s_info); + } + template<class WrapperClass> inline JSC::Structure* getDOMStructure(JSC::ExecState* exec) + { + return getDOMStructure<WrapperClass>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())); } - template<class WrapperClass> inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec) + template<class WrapperClass> inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) { - return static_cast<JSC::JSObject*>(asObject(getDOMStructure<WrapperClass>(exec)->storedPrototype())); + return static_cast<JSC::JSObject*>(asObject(getDOMStructure<WrapperClass>(exec, static_cast<JSDOMGlobalObject*>(globalObject))->storedPrototype())); } #define CREATE_DOM_OBJECT_WRAPPER(exec, className, object) createDOMObjectWrapper<JS##className>(exec, static_cast<className*>(object)) template<class WrapperClass, class DOMClass> inline DOMObject* createDOMObjectWrapper(JSC::ExecState* exec, DOMClass* object) diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp index 562e661..f4fe1df 100644 --- a/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -28,9 +28,13 @@ #include "Frame.h" #include "FrameLoader.h" #include "FrameTree.h" +#include "History.h" #include "JSDOMWindowShell.h" #include "JSEventListener.h" +#include "JSHistory.h" +#include "JSLocation.h" #include "JSMessagePort.h" +#include "Location.h" #include "MessagePort.h" #include "ScriptController.h" #include "Settings.h" @@ -124,6 +128,28 @@ JSValuePtr JSDOMWindow::lookupSetter(ExecState* exec, const Identifier& property return Base::lookupSetter(exec, propertyName); } +JSValuePtr JSDOMWindow::history(ExecState* exec) const +{ + History* history = impl()->history(); + if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), history)) + return wrapper; + + JSHistory* jsHistory = new (exec) JSHistory(getDOMStructure<JSHistory>(exec, const_cast<JSDOMWindow*>(this)), history); + cacheDOMObjectWrapper(exec->globalData(), history, jsHistory); + return jsHistory; +} + +JSValuePtr JSDOMWindow::location(ExecState* exec) const +{ + Location* location = impl()->location(); + if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), location)) + return wrapper; + + JSLocation* jsLocation = new (exec) JSLocation(getDOMStructure<JSLocation>(exec, const_cast<JSDOMWindow*>(this)), location); + cacheDOMObjectWrapper(exec->globalData(), location, jsLocation); + return jsLocation; +} + void JSDOMWindow::setLocation(ExecState* exec, JSValuePtr value) { Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); diff --git a/WebCore/bindings/js/JSDocumentCustom.cpp b/WebCore/bindings/js/JSDocumentCustom.cpp index fff0ea5..596b78f 100644 --- a/WebCore/bindings/js/JSDocumentCustom.cpp +++ b/WebCore/bindings/js/JSDocumentCustom.cpp @@ -55,7 +55,14 @@ JSValuePtr JSDocument::location(ExecState* exec) const if (!frame) return jsNull(); - return toJS(exec, frame->domWindow()->location()); + Location* location = frame->domWindow()->location(); + if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), location)) + return wrapper; + + JSDOMWindow* window = static_cast<JSDOMWindow*>(exec->lexicalGlobalObject()); + JSLocation* jsLocation = new (exec) JSLocation(getDOMStructure<JSLocation>(exec, window), location); + cacheDOMObjectWrapper(exec->globalData(), location, jsLocation); + return jsLocation; } void JSDocument::setLocation(ExecState* exec, JSValuePtr value) diff --git a/WebCore/bindings/js/JSMessageChannelConstructor.cpp b/WebCore/bindings/js/JSMessageChannelConstructor.cpp index 54ffb18..8472250 100644 --- a/WebCore/bindings/js/JSMessageChannelConstructor.cpp +++ b/WebCore/bindings/js/JSMessageChannelConstructor.cpp @@ -55,7 +55,7 @@ JSMessageChannelConstructor::JSMessageChannelConstructor(ExecState* exec, Script else ASSERT_NOT_REACHED(); - putDirect(exec->propertyNames().prototype, JSMessageChannelPrototype::self(exec), None); + putDirect(exec->propertyNames().prototype, JSMessageChannelPrototype::self(exec, exec->lexicalGlobalObject()), None); } JSMessageChannelConstructor::~JSMessageChannelConstructor() diff --git a/WebCore/bindings/js/JSNamedNodesCollection.h b/WebCore/bindings/js/JSNamedNodesCollection.h index 19f194b..0294d23 100644 --- a/WebCore/bindings/js/JSNamedNodesCollection.h +++ b/WebCore/bindings/js/JSNamedNodesCollection.h @@ -44,9 +44,9 @@ namespace WebCore { virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; - static JSC::ObjectPrototype* createPrototype(JSC::ExecState* exec) + static JSC::ObjectPrototype* createPrototype(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) { - return exec->lexicalGlobalObject()->objectPrototype(); + return globalObject->objectPrototype(); } static PassRefPtr<JSC::Structure> createStructure(JSC::JSValuePtr prototype) diff --git a/WebCore/bindings/js/JSRGBColor.h b/WebCore/bindings/js/JSRGBColor.h index d5acff3..2f51407 100644 --- a/WebCore/bindings/js/JSRGBColor.h +++ b/WebCore/bindings/js/JSRGBColor.h @@ -38,9 +38,9 @@ namespace WebCore { unsigned impl() const { return m_color; } - static JSC::ObjectPrototype* createPrototype(JSC::ExecState* exec) + static JSC::ObjectPrototype* createPrototype(JSC::ExecState*, JSC::JSGlobalObject* globalObject) { - return exec->lexicalGlobalObject()->objectPrototype(); + return globalObject->objectPrototype(); } static PassRefPtr<JSC::Structure> createStructure(JSC::JSValuePtr prototype) diff --git a/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp b/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp index ba9e6ed..6cf021c 100644 --- a/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp +++ b/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp @@ -38,7 +38,7 @@ JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor(ExecState* exec, Script ASSERT(context->isDocument()); m_document = static_cast<JSDocument*>(asObject(toJS(exec, static_cast<Document*>(context)))); - putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec), None); + putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec, exec->lexicalGlobalObject()), None); } static JSObject* constructXMLHttpRequest(ExecState* exec, JSObject* constructor, const ArgList&) diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index 2af88e2..49ad7b7 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -438,7 +438,7 @@ sub GenerateHeader push(@headerContent, " virtual ~$className();\n") if (!$hasParent or $interfaceName eq "Document"); # Prototype - push(@headerContent, " static JSC::JSObject* createPrototype(JSC::ExecState*);\n") unless ($dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}); + push(@headerContent, " static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);\n") unless ($dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}); $implIncludes{"${className}Custom.h"} = 1 if $dataNode->extendedAttributes->{"CustomHeader"} || $dataNode->extendedAttributes->{"CustomPutFunction"}; @@ -665,7 +665,7 @@ sub GenerateHeader } elsif ($interfaceName eq "WorkerContext") { push(@headerContent, " void* operator new(size_t, JSC::JSGlobalData*);\n"); } else { - push(@headerContent, " static JSC::JSObject* self(JSC::ExecState*);\n"); + push(@headerContent, " static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);\n"); } push(@headerContent, " virtual const JSC::ClassInfo* classInfo() const { return &s_info; }\n"); push(@headerContent, " static const JSC::ClassInfo s_info;\n"); @@ -907,9 +907,9 @@ sub GenerateImplementation push(@implContent, " return globalData->heap.allocate(size);\n"); push(@implContent, "}\n\n"); } else { - push(@implContent, "JSObject* ${className}Prototype::self(ExecState* exec)\n"); + push(@implContent, "JSObject* ${className}Prototype::self(ExecState* exec, JSGlobalObject* globalObject)\n"); push(@implContent, "{\n"); - push(@implContent, " return getDOMPrototype<${className}>(exec);\n"); + push(@implContent, " return getDOMPrototype<${className}>(exec, globalObject);\n"); push(@implContent, "}\n\n"); } if ($numConstants > 0 || $numFunctions > 0) { @@ -1015,12 +1015,12 @@ sub GenerateImplementation } if (!$dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}) { - push(@implContent, "JSObject* ${className}::createPrototype(ExecState* exec)\n"); + push(@implContent, "JSObject* ${className}::createPrototype(ExecState* exec, JSGlobalObject* globalObject)\n"); push(@implContent, "{\n"); if ($hasParent && $parentClassName ne "JSC::DOMNodeFilter") { - push(@implContent, " return new (exec) ${className}Prototype(${className}Prototype::createStructure(${parentClassName}Prototype::self(exec)));\n"); + push(@implContent, " return new (exec) ${className}Prototype(${className}Prototype::createStructure(${parentClassName}Prototype::self(exec, globalObject)));\n"); } else { - push(@implContent, " return new (exec) ${className}Prototype(${className}Prototype::createStructure(exec->lexicalGlobalObject()->objectPrototype()));\n"); + push(@implContent, " return new (exec) ${className}Prototype(${className}Prototype::createStructure(globalObject->objectPrototype()));\n"); } push(@implContent, "}\n\n"); } @@ -1981,7 +1981,7 @@ public: ${className}Constructor(ExecState* exec) : DOMObject(${className}Constructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) { - putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec), None); + putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec, exec->lexicalGlobalObject()), None); } virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); virtual const ClassInfo* classInfo() const { return &s_info; } diff --git a/WebCore/bridge/runtime_array.h b/WebCore/bridge/runtime_array.h index 1ea47a4..488c3f5 100644 --- a/WebCore/bridge/runtime_array.h +++ b/WebCore/bridge/runtime_array.h @@ -51,9 +51,9 @@ public: static const ClassInfo s_info; - static ArrayPrototype* createPrototype(ExecState* exec) + static ArrayPrototype* createPrototype(ExecState*, JSGlobalObject* globalObject) { - return exec->lexicalGlobalObject()->arrayPrototype(); + return globalObject->arrayPrototype(); } static PassRefPtr<Structure> createStructure(JSValuePtr prototype) diff --git a/WebCore/bridge/runtime_method.h b/WebCore/bridge/runtime_method.h index bb983f9..fe1178a 100644 --- a/WebCore/bridge/runtime_method.h +++ b/WebCore/bridge/runtime_method.h @@ -40,9 +40,9 @@ public: static const ClassInfo s_info; - static FunctionPrototype* createPrototype(ExecState* exec) + static FunctionPrototype* createPrototype(ExecState*, JSGlobalObject* globalObject) { - return exec->lexicalGlobalObject()->functionPrototype(); + return globalObject->functionPrototype(); } static PassRefPtr<Structure> createStructure(JSValuePtr prototype) diff --git a/WebCore/bridge/runtime_object.h b/WebCore/bridge/runtime_object.h index b8788c9..fa81aa1 100644 --- a/WebCore/bridge/runtime_object.h +++ b/WebCore/bridge/runtime_object.h @@ -53,9 +53,9 @@ public: static const ClassInfo s_info; - static ObjectPrototype* createPrototype(ExecState* exec) + static ObjectPrototype* createPrototype(ExecState*, JSGlobalObject* globalObject) { - return exec->lexicalGlobalObject()->objectPrototype(); + return globalObject->objectPrototype(); } static PassRefPtr<Structure> createStructure(JSValuePtr prototype) diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl index 78c780f..b1797b9 100644 --- a/WebCore/page/DOMWindow.idl +++ b/WebCore/page/DOMWindow.idl @@ -44,7 +44,7 @@ module window { ] DOMWindow { // DOM Level 0 readonly attribute Screen screen; - readonly attribute [DoNotCheckDomainSecurity] History history; + readonly attribute [DoNotCheckDomainSecurity, CustomGetter] History history; attribute [Replaceable] BarInfo locationbar; attribute [Replaceable] BarInfo menubar; attribute [Replaceable] BarInfo personalbar; @@ -53,7 +53,7 @@ module window { attribute [Replaceable] BarInfo toolbar; attribute [Replaceable] Navigator navigator; attribute [Replaceable] Navigator clientInformation; - attribute [DoNotCheckDomainSecurity, CustomSetter] Location location; + attribute [DoNotCheckDomainSecurity, Custom] Location location; DOMSelection getSelection(); |