Bug 1492326, revert some of bug 1478372, so that callers need to get the custom interface from a custom element without using QueryInterface, r=peterv

This commit is contained in:
Neil Deakin
2018-12-04 11:33:06 -05:00
parent 3acf83c461
commit fee1676951
3 changed files with 11 additions and 12 deletions

View File

@@ -3871,8 +3871,15 @@ void Element::GetCustomInterface(nsGetterAddRefs<T> aResult) {
nsCOMPtr<nsISupports> iface = CustomElementRegistry::CallGetCustomInterface( nsCOMPtr<nsISupports> iface = CustomElementRegistry::CallGetCustomInterface(
this, NS_GET_TEMPLATE_IID(T)); this, NS_GET_TEMPLATE_IID(T));
if (iface) { if (iface) {
CallQueryInterface(iface, static_cast<T**>(aResult)); if (NS_SUCCEEDED(CallQueryInterface(iface, static_cast<T**>(aResult)))) {
return;
}
} }
// Otherwise, check the binding manager to see if it implements the interface
// for this element.
OwnerDoc()->BindingManager()->GetBindingImplementation(
this, NS_GET_TEMPLATE_IID(T), aResult);
} }
void Element::ClearServoData(nsIDocument* aDoc) { void Element::ClearServoData(nsIDocument* aDoc) {

View File

@@ -296,16 +296,6 @@ NS_IMPL_RELEASE_INHERITED(nsXULElement, nsStyledElement)
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsXULElement) NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsXULElement)
NS_ELEMENT_INTERFACE_TABLE_TO_MAP_SEGUE NS_ELEMENT_INTERFACE_TABLE_TO_MAP_SEGUE
nsCOMPtr<nsISupports> iface =
CustomElementRegistry::CallGetCustomInterface(this, aIID);
if (iface) {
iface->QueryInterface(aIID, aInstancePtr);
if (*aInstancePtr) {
return NS_OK;
}
}
NS_INTERFACE_MAP_END_INHERITING(nsStyledElement) NS_INTERFACE_MAP_END_INHERITING(nsStyledElement)
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@@ -200,7 +200,8 @@ const MozElementMixin = Base => class MozElement extends Base {
/** /**
* Indicate that a class defining a XUL element implements one or more * Indicate that a class defining a XUL element implements one or more
* XPCOM interfaces by adding a getCustomInterface implementation to it. * XPCOM interfaces by adding a getCustomInterface implementation to it,
* as well as an implementation of QueryInterface.
* *
* The supplied class should implement the properties and methods of * The supplied class should implement the properties and methods of
* all of the interfaces that are specified. * all of the interfaces that are specified.
@@ -218,6 +219,7 @@ const MozElementMixin = Base => class MozElement extends Base {
} }
cls.prototype.customInterfaceNumbers = numbers; cls.prototype.customInterfaceNumbers = numbers;
cls.prototype.QueryInterface = ChromeUtils.generateQI(ifaces);
cls.prototype.getCustomInterfaceCallback = function getCustomInterfaceCallback(iface) { cls.prototype.getCustomInterfaceCallback = function getCustomInterfaceCallback(iface) {
if (numbers.has(iface.number)) { if (numbers.has(iface.number)) {
return getInterfaceProxy(this); return getInterfaceProxy(this);