Modified: trunk/Source/WebCore/ChangeLog (211308 => 211309)
--- trunk/Source/WebCore/ChangeLog 2017-01-27 23:56:58 UTC (rev 211308)
+++ trunk/Source/WebCore/ChangeLog 2017-01-28 00:03:36 UTC (rev 211309)
@@ -1,3 +1,16 @@
+2017-01-27 Michael Saboff <msab...@apple.com>
+
+ JSCustomElementInterface::invokeCallback can be called with a null callback because Weak<>
+ https://bugs.webkit.org/show_bug.cgi?id=167522
+
+ Reviewed by Filip Pizlo.
+
+ Added all provided callbacks to the global object with a private name the same way
+ that the constructor was added. This will keep these callbacks from being GC'ed.
+
+ * bindings/js/JSCustomElementRegistryCustom.cpp:
+ (WebCore::JSCustomElementRegistry::define):
+
2017-01-27 Myles C. Maxfield <mmaxfi...@apple.com>
[Cocoa] Prepare ComplexTextController for unit testing
Modified: trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp (211308 => 211309)
--- trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp 2017-01-27 23:56:58 UTC (rev 211308)
+++ trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp 2017-01-28 00:03:36 UTC (rev 211309)
@@ -122,15 +122,18 @@
QualifiedName name(nullAtom, localName, HTMLNames::xhtmlNamespaceURI);
auto elementInterface = JSCustomElementInterface::create(name, constructor, globalObject());
- if (auto* connectedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "connectedCallback")))
+ auto* connectedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "connectedCallback"));
+ if (connectedCallback)
elementInterface->setConnectedCallback(connectedCallback);
RETURN_IF_EXCEPTION(scope, JSValue());
- if (auto* disconnectedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "disconnectedCallback")))
+ auto* disconnectedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "disconnectedCallback"));
+ if (disconnectedCallback)
elementInterface->setDisconnectedCallback(disconnectedCallback);
RETURN_IF_EXCEPTION(scope, JSValue());
- if (auto* adoptedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "adoptedCallback")))
+ auto* adoptedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "adoptedCallback"));
+ if (adoptedCallback)
elementInterface->setAdoptedCallback(adoptedCallback);
RETURN_IF_EXCEPTION(scope, JSValue());
@@ -146,9 +149,19 @@
}
}
- PrivateName uniquePrivateName;
- globalObject()->putDirect(vm, uniquePrivateName, constructor);
+ auto addToGlobalObjectWithPrivateName = [&] (JSObject* objectToAdd) {
+ if (objectToAdd) {
+ PrivateName uniquePrivateName;
+ globalObject()->putDirect(vm, uniquePrivateName, objectToAdd);
+ }
+ };
+ addToGlobalObjectWithPrivateName(constructor);
+ addToGlobalObjectWithPrivateName(connectedCallback);
+ addToGlobalObjectWithPrivateName(disconnectedCallback);
+ addToGlobalObjectWithPrivateName(adoptedCallback);
+ addToGlobalObjectWithPrivateName(attributeChangedCallback);
+
registry.addElementDefinition(WTFMove(elementInterface));
return jsUndefined();