mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix for bug 759275 (Specialize unwrapping to HTML elements in dom bindings). r=bz.
--HG-- extra : rebase_source : f676440e468c23e6c1e9458f6d75a615b9a6b8d7
This commit is contained in:
parent
5f147ab73e
commit
8839249ab0
@ -1512,18 +1512,18 @@ for (uint32_t i = 0; i < length; ++i) {
|
||||
# Either external, or new-binding non-castable. We always have a
|
||||
# holder for these, because we don't actually know whether we have
|
||||
# to addref when unwrapping or not. So we just pass an
|
||||
# getter_AddRefs(nsCOMPtr) to XPConnect and if we'll need a release
|
||||
# getter_AddRefs(nsRefPtr) to XPConnect and if we'll need a release
|
||||
# it'll put a non-null pointer in there.
|
||||
if forceOwningType:
|
||||
# Don't return a holderType in this case; our declName
|
||||
# will just own stuff.
|
||||
templateBody += "nsCOMPtr<" + typeName + "> ${holderName};"
|
||||
templateBody += "nsRefPtr<" + typeName + "> ${holderName};"
|
||||
else:
|
||||
holderType = "nsCOMPtr<" + typeName + ">"
|
||||
holderType = "nsRefPtr<" + typeName + ">"
|
||||
templateBody += (
|
||||
"jsval tmpVal = ${val};\n" +
|
||||
typePtr + " tmp;\n"
|
||||
"if (NS_FAILED(xpc_qsUnwrapArg<" + typeName + ">(cx, ${val}, &tmp, getter_AddRefs(${holderName}), &tmpVal))) {\n")
|
||||
"if (NS_FAILED(xpc_qsUnwrapArg<" + typeName + ">(cx, ${val}, &tmp, static_cast<" + typeName + "**>(getter_AddRefs(${holderName})), &tmpVal))) {\n")
|
||||
templateBody += CGIndenter(onFailure(failureCode,
|
||||
descriptor.workers)).define()
|
||||
templateBody += ("}\n"
|
||||
@ -3460,6 +3460,7 @@ class CGBindingRoot(CGThing):
|
||||
['mozilla/dom/Nullable.h',
|
||||
'mozilla/dom/PrimitiveConversions.h',
|
||||
'XPCQuickStubs.h',
|
||||
'nsDOMQS.h',
|
||||
'AccessCheck.h',
|
||||
'WorkerPrivate.h',
|
||||
'nsContentUtils.h',
|
||||
|
@ -491,13 +491,17 @@ xpc_qsUnwrapArgImpl(JSContext *cx, jsval v, const nsIID &iid, void **ppArg,
|
||||
nsISupports **ppArgRef, jsval *vp);
|
||||
|
||||
/** Convert a jsval to an XPCOM pointer. */
|
||||
template <class T>
|
||||
template <class Interface, class StrongRefType>
|
||||
inline nsresult
|
||||
xpc_qsUnwrapArg(JSContext *cx, jsval v, T **ppArg, nsISupports **ppArgRef,
|
||||
jsval *vp)
|
||||
xpc_qsUnwrapArg(JSContext *cx, jsval v, Interface **ppArg,
|
||||
StrongRefType **ppArgRef, jsval *vp)
|
||||
{
|
||||
return xpc_qsUnwrapArgImpl(cx, v, NS_GET_TEMPLATE_IID(T),
|
||||
reinterpret_cast<void **>(ppArg), ppArgRef, vp);
|
||||
nsISupports* argRef;
|
||||
nsresult rv = xpc_qsUnwrapArgImpl(cx, v, NS_GET_TEMPLATE_IID(Interface),
|
||||
reinterpret_cast<void **>(ppArg), &argRef,
|
||||
vp);
|
||||
*ppArgRef = static_cast<StrongRefType*>(argRef);
|
||||
return rv;
|
||||
}
|
||||
|
||||
inline nsISupports*
|
||||
|
@ -5,7 +5,13 @@
|
||||
#ifndef nsDOMQS_h__
|
||||
#define nsDOMQS_h__
|
||||
|
||||
#include "mozilla/dom/ImageData.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLDocument.h"
|
||||
#include "nsICSSDeclaration.h"
|
||||
#include "nsIDOMWebGLRenderingContext.h"
|
||||
#include "nsSVGStylableElement.h"
|
||||
|
||||
#define DEFINE_UNWRAP_CAST(_interface, _base, _bit) \
|
||||
template <> \
|
||||
@ -117,6 +123,56 @@ xpc_qsUnwrapArg<nsGenericElement>(JSContext *cx,
|
||||
return rv;
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
xpc_qsUnwrapArg_HTMLElement(JSContext *cx,
|
||||
jsval v,
|
||||
nsIAtom *aTag,
|
||||
nsIContent **ppArg,
|
||||
nsISupports **ppArgRef,
|
||||
jsval *vp)
|
||||
{
|
||||
nsIContent *elem;
|
||||
jsval val;
|
||||
nsresult rv = xpc_qsUnwrapArg<nsIContent>(cx, v, &elem, ppArgRef, &val);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (elem->IsHTML(aTag)) {
|
||||
*ppArg = elem;
|
||||
*vp = val;
|
||||
} else {
|
||||
rv = NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define DEFINE_UNWRAP_CAST_HTML(_tag, _clazz) \
|
||||
template <> \
|
||||
inline nsresult \
|
||||
xpc_qsUnwrapArg<_clazz>(JSContext *cx, \
|
||||
jsval v, \
|
||||
_clazz **ppArg, \
|
||||
nsISupports **ppArgRef, \
|
||||
jsval *vp) \
|
||||
{ \
|
||||
nsIContent *elem; \
|
||||
nsresult rv = xpc_qsUnwrapArg_HTMLElement(cx, v, nsGkAtoms::_tag, &elem, \
|
||||
ppArgRef, vp); \
|
||||
if (NS_SUCCEEDED(rv)) \
|
||||
*ppArg = static_cast<_clazz*>(elem); \
|
||||
return rv; \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
inline nsresult \
|
||||
xpc_qsUnwrapArg<_clazz>(JSContext *cx, jsval v, _clazz **ppArg, \
|
||||
_clazz **ppArgRef, jsval *vp) \
|
||||
{ \
|
||||
nsISupports* argRef; \
|
||||
nsresult rv = xpc_qsUnwrapArg<_clazz>(cx, v, ppArg, &argRef, vp); \
|
||||
*ppArgRef = static_cast<_clazz*>(static_cast<nsIContent*>(argRef)); \
|
||||
return rv; \
|
||||
}
|
||||
|
||||
inline nsISupports*
|
||||
ToSupports(nsContentList *p)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user