<https://webkit.org/b/130458>
Take a shorter path to the DOMWrapperWorld by using the passed-in
global object instead of getting the lexical global from ExecState.
Removed an old FIXME that no longer applies since JSObjects can
always find the right global object these days.
Reviewed by Geoff Garen.
* bindings/js/JSCSSRuleCustom.cpp:
(WebCore::toJS):
* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::JSCSSStyleDeclaration::getPropertyCSSValue):
* bindings/js/JSCSSValueCustom.cpp:
(WebCore::toJS):
* bindings/js/JSDOMBinding.h:
(WebCore::createWrapper):
(WebCore::wrap):
(WebCore::getExistingWrapper):
(WebCore::createNewWrapper):
(WebCore::toJS):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::setTimeout):
(WebCore::JSDOMWindow::setInterval):
(WebCore::JSDOMWindow::addEventListener):
(WebCore::JSDOMWindow::removeEventListener):
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::location):
(WebCore::toJS):
* bindings/js/JSElementCustom.cpp:
(WebCore::toJSNewlyCreated):
* bindings/js/JSEventCustom.cpp:
(WebCore::toJS):
* bindings/js/JSHTMLCollectionCustom.cpp:
(WebCore::toJS):
* bindings/js/JSHTMLTemplateElementCustom.cpp:
(WebCore::JSHTMLTemplateElement::content):
* bindings/js/JSImageDataCustom.cpp:
(WebCore::toJS):
* bindings/js/JSNodeCustom.cpp:
(WebCore::createWrapperInline):
* bindings/js/JSNodeCustom.h:
(WebCore::toJS):
* bindings/js/JSSVGPathSegCustom.cpp:
(WebCore::toJS):
* bindings/js/JSStyleSheetCustom.cpp:
(WebCore::toJS):
* bindings/js/JSTextTrackCueCustom.cpp:
(WebCore::toJS):
* bindings/js/JSTrackCustom.cpp:
(WebCore::toJS):
* bindings/js/JSWorkerGlobalScopeCustom.cpp:
(WebCore::JSWorkerGlobalScope::setTimeout):
(WebCore::JSWorkerGlobalScope::setInterval):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165914
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-03-19 Andreas Kling <akling@apple.com>
+
+ JSC bindings should use the passed-in global object for wrapper caching.
+ <https://webkit.org/b/130458>
+
+ Take a shorter path to the DOMWrapperWorld by using the passed-in
+ global object instead of getting the lexical global from ExecState.
+ Removed an old FIXME that no longer applies since JSObjects can
+ always find the right global object these days.
+
+ Reviewed by Geoff Garen.
+
+ * bindings/js/JSCSSRuleCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSCSSStyleDeclarationCustom.cpp:
+ (WebCore::JSCSSStyleDeclaration::getPropertyCSSValue):
+ * bindings/js/JSCSSValueCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::createWrapper):
+ (WebCore::wrap):
+ (WebCore::getExistingWrapper):
+ (WebCore::createNewWrapper):
+ (WebCore::toJS):
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::JSDOMWindow::setTimeout):
+ (WebCore::JSDOMWindow::setInterval):
+ (WebCore::JSDOMWindow::addEventListener):
+ (WebCore::JSDOMWindow::removeEventListener):
+ * bindings/js/JSDocumentCustom.cpp:
+ (WebCore::JSDocument::location):
+ (WebCore::toJS):
+ * bindings/js/JSElementCustom.cpp:
+ (WebCore::toJSNewlyCreated):
+ * bindings/js/JSEventCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSHTMLCollectionCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSHTMLTemplateElementCustom.cpp:
+ (WebCore::JSHTMLTemplateElement::content):
+ * bindings/js/JSImageDataCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSNodeCustom.cpp:
+ (WebCore::createWrapperInline):
+ * bindings/js/JSNodeCustom.h:
+ (WebCore::toJS):
+ * bindings/js/JSSVGPathSegCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSStyleSheetCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSTextTrackCueCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSTrackCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSWorkerGlobalScopeCustom.cpp:
+ (WebCore::JSWorkerGlobalScope::setTimeout):
+ (WebCore::JSWorkerGlobalScope::setInterval):
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateImplementation):
+
2014-03-19 Benjamin Poulain <bpoulain@apple.com>
Page::setPageScaleFactor should not force the scroll view position when using delegatesScrolling()
if (!rule)
return jsNull();
- JSObject* wrapper = getCachedWrapper(currentWorld(exec), rule);
+ JSObject* wrapper = getCachedWrapper(globalObject->world(), rule);
if (wrapper)
return wrapper;
if (!cssValue)
return jsNull();
- currentWorld(exec).m_cssValueRoots.add(cssValue.get(), root(&impl())); // Balanced by JSCSSValueOwner::finalize().
+ globalObject()->world().m_cssValueRoots.add(cssValue.get(), root(&impl())); // Balanced by JSCSSValueOwner::finalize().
return toJS(exec, globalObject(), WTF::getPtr(cssValue));
}
if (!value->isCSSOMSafe())
return jsNull();
- JSObject* wrapper = getCachedWrapper(currentWorld(exec), value);
+ JSObject* wrapper = getCachedWrapper(globalObject->world(), value);
if (wrapper)
return wrapper;
template<class WrapperClass, class DOMClass> inline JSDOMWrapper* createWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* node)
{
ASSERT(node);
- ASSERT(!getCachedWrapper(currentWorld(exec), node));
+ ASSERT(!getCachedWrapper(globalObject->world(), node));
WrapperClass* wrapper = WrapperClass::create(getDOMStructure<WrapperClass>(exec->vm(), globalObject), globalObject, node);
- // FIXME: The entire function can be removed, once we fix caching.
- // This function is a one-off hack to make Nodes cache in the right global object.
- cacheWrapper(currentWorld(exec), node, wrapper);
+ cacheWrapper(globalObject->world(), node, wrapper);
return wrapper;
}
{
if (!domObject)
return JSC::jsNull();
- if (JSC::JSObject* wrapper = getCachedWrapper(currentWorld(exec), domObject))
+ if (JSC::JSObject* wrapper = getCachedWrapper(globalObject->world(), domObject))
return wrapper;
return createWrapper<WrapperClass>(exec, globalObject, domObject);
}
-template<class WrapperClass, class DOMClass> inline JSC::JSValue getExistingWrapper(JSC::ExecState* exec, DOMClass* domObject)
+template<class WrapperClass, class DOMClass> inline JSC::JSValue getExistingWrapper(JSDOMGlobalObject* globalObject, DOMClass* domObject)
{
ASSERT(domObject);
- return getCachedWrapper(currentWorld(exec), domObject);
+ return getCachedWrapper(globalObject->world(), domObject);
}
template<class WrapperClass, class DOMClass> inline JSC::JSValue createNewWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* domObject)
{
ASSERT(domObject);
- ASSERT(!getCachedWrapper(currentWorld(exec), domObject));
+ ASSERT(!getCachedWrapper(globalObject->world(), domObject));
return createWrapper<WrapperClass>(exec, globalObject, domObject);
}
{
if (!buffer)
return JSC::jsNull();
- if (JSC::JSValue result = getExistingWrapper<JSC::JSArrayBuffer>(exec, buffer))
+ if (JSC::JSValue result = getExistingWrapper<JSC::JSArrayBuffer>(globalObject, buffer))
return result;
buffer->ref();
JSC::JSArrayBuffer* wrapper = JSC::JSArrayBuffer::create(exec->vm(), globalObject->arrayBufferStructure(), buffer);
- cacheWrapper(currentWorld(exec), buffer, wrapper);
+ cacheWrapper(globalObject->world(), buffer, wrapper);
return wrapper;
}
JSValue JSDOMWindow::setTimeout(ExecState* exec)
{
ContentSecurityPolicy* contentSecurityPolicy = impl().document() ? impl().document()->contentSecurityPolicy() : 0;
- OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, currentWorld(exec), contentSecurityPolicy);
+ OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), contentSecurityPolicy);
if (exec->hadException())
return jsUndefined();
JSValue JSDOMWindow::setInterval(ExecState* exec)
{
ContentSecurityPolicy* contentSecurityPolicy = impl().document() ? impl().document()->contentSecurityPolicy() : 0;
- OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, currentWorld(exec), contentSecurityPolicy);
+ OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), contentSecurityPolicy);
if (exec->hadException())
return jsUndefined();
int delay = exec->argument(1).toInt32(exec);
if (!listener.isObject())
return jsUndefined();
- impl().addEventListener(exec->argument(0).toString(exec)->value(exec), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), exec->argument(2).toBoolean(exec));
+ impl().addEventListener(exec->argument(0).toString(exec)->value(exec), JSEventListener::create(asObject(listener), this, false, globalObject()->world()), exec->argument(2).toBoolean(exec));
return jsUndefined();
}
if (!listener.isObject())
return jsUndefined();
- impl().removeEventListener(exec->argument(0).toString(exec)->value(exec), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec));
+ impl().removeEventListener(exec->argument(0).toString(exec)->value(exec), JSEventListener::create(asObject(listener), this, false, globalObject()->world()).get(), exec->argument(2).toBoolean(exec));
return jsUndefined();
}
return jsNull();
Location* location = frame->document()->domWindow()->location();
- if (JSObject* wrapper = getCachedWrapper(currentWorld(exec), location))
+ if (JSObject* wrapper = getCachedWrapper(globalObject()->world(), location))
return wrapper;
JSLocation* jsLocation = JSLocation::create(getDOMStructure<JSLocation>(exec->vm(), globalObject()), globalObject(), location);
- cacheWrapper(currentWorld(exec), location, jsLocation);
+ cacheWrapper(globalObject()->world(), location, jsLocation);
return jsLocation;
}
if (!document)
return jsNull();
- JSObject* wrapper = getCachedWrapper(currentWorld(exec), document);
+ JSObject* wrapper = getCachedWrapper(globalObject->world(), document);
if (wrapper)
return wrapper;
if (DOMWindow* domWindow = document->domWindow()) {
globalObject = toJSDOMWindow(toJS(exec, domWindow));
// Creating a wrapper for domWindow might have created a wrapper for document as well.
- wrapper = getCachedWrapper(currentWorld(exec), document);
+ wrapper = getCachedWrapper(globalObject->world(), document);
if (wrapper)
return wrapper;
}
if (!element)
return jsNull();
- ASSERT(!getCachedWrapper(currentWorld(exec), element));
+ ASSERT(!getCachedWrapper(globalObject->world(), element));
JSDOMWrapper* wrapper;
if (element->isHTMLElement())
if (!event)
return jsNull();
- JSObject* wrapper = getCachedWrapper(currentWorld(exec), event);
+ JSObject* wrapper = getCachedWrapper(globalObject->world(), event);
if (wrapper)
return wrapper;
if (!collection)
return jsNull();
- JSObject* wrapper = getCachedWrapper(currentWorld(exec), collection);
+ JSObject* wrapper = getCachedWrapper(globalObject->world(), collection);
if (wrapper)
return wrapper;
DocumentFragment* content = impl().content();
- JSObject* wrapper = getCachedWrapper(currentWorld(exec), content);
+ JSObject* wrapper = getCachedWrapper(globalObject()->world(), content);
if (wrapper)
return wrapper;
if (!imageData)
return jsNull();
- JSObject* wrapper = getCachedWrapper(currentWorld(exec), imageData);
+ JSObject* wrapper = getCachedWrapper(globalObject->world(), imageData);
if (wrapper)
return wrapper;
static ALWAYS_INLINE JSValue createWrapperInline(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
{
ASSERT(node);
- ASSERT(!getCachedWrapper(currentWorld(exec), node));
+ ASSERT(!getCachedWrapper(globalObject->world(), node));
JSDOMWrapper* wrapper;
switch (node->nodeType()) {
if (!node)
return JSC::jsNull();
- JSNode* wrapper = JSC::jsCast<JSNode*>(getCachedWrapper(currentWorld(exec), node));
+ JSNode* wrapper = JSC::jsCast<JSNode*>(getCachedWrapper(globalObject->world(), node));
if (wrapper)
return wrapper;
if (!object)
return jsNull();
- if (JSObject* wrapper = getCachedWrapper(currentWorld(exec), object))
+ if (JSObject* wrapper = getCachedWrapper(globalObject->world(), object))
return wrapper;
switch (object->pathSegType()) {
if (!styleSheet)
return jsNull();
- JSObject* wrapper = getCachedWrapper(currentWorld(exec), styleSheet);
+ JSObject* wrapper = getCachedWrapper(globalObject->world(), styleSheet);
if (wrapper)
return wrapper;
if (!cue)
return jsNull();
- JSObject* wrapper = getCachedWrapper(currentWorld(exec), cue);
+ JSObject* wrapper = getCachedWrapper(globalObject->world(), cue);
if (wrapper)
return wrapper;
if (!track)
return jsNull();
- JSObject* wrapper = getCachedWrapper(currentWorld(exec), track);
+ JSObject* wrapper = getCachedWrapper(globalObject->world(), track);
if (wrapper)
return wrapper;
JSValue JSWorkerGlobalScope::setTimeout(ExecState* exec)
{
- OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, currentWorld(exec), impl().contentSecurityPolicy());
+ OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), impl().contentSecurityPolicy());
if (exec->hadException())
return jsUndefined();
if (!action)
JSValue JSWorkerGlobalScope::setInterval(ExecState* exec)
{
- OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, currentWorld(exec), impl().contentSecurityPolicy());
+ OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, globalObject()->world(), impl().contentSecurityPolicy());
if (exec->hadException())
return jsUndefined();
if (!action)
END
if ($svgPropertyType) {
- push(@implContent, " if (JSValue result = getExistingWrapper<$className, $implType>(exec, impl))\n");
+ push(@implContent, " if (JSValue result = getExistingWrapper<$className, $implType>(globalObject, impl))\n");
push(@implContent, " return result;\n");
} else {
- push(@implContent, " if (JSValue result = getExistingWrapper<$className>(exec, impl))\n");
+ push(@implContent, " if (JSValue result = getExistingWrapper<$className>(globalObject, impl))\n");
push(@implContent, " return result;\n");
}
push(@implContent, <<END) if $vtableNameGnu;