summaryrefslogtreecommitdiffstats
path: root/dom
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-04 10:28:38 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:14 -0500
commitdf23f78ad16b40c244f518dba28a8555d61bdd0c (patch)
tree0d0806f435a548df4dd2d2af0df531e93bd3bc77 /dom
parent20799ce18c18ff1ad3125ad4e8a7a679b57a858f (diff)
downloadUXP-df23f78ad16b40c244f518dba28a8555d61bdd0c.tar
UXP-df23f78ad16b40c244f518dba28a8555d61bdd0c.tar.gz
UXP-df23f78ad16b40c244f518dba28a8555d61bdd0c.tar.lz
UXP-df23f78ad16b40c244f518dba28a8555d61bdd0c.tar.xz
UXP-df23f78ad16b40c244f518dba28a8555d61bdd0c.zip
Bug 1309147 - Part 3: Implement the support for CEReactions in Codegen.
Tag UXP Issue #1344
Diffstat (limited to 'dom')
-rw-r--r--dom/bindings/BindingUtils.cpp23
-rw-r--r--dom/bindings/BindingUtils.h7
-rw-r--r--dom/bindings/Bindings.conf4
-rw-r--r--dom/bindings/Codegen.py17
-rw-r--r--dom/bindings/test/TestBindingHeader.h24
-rw-r--r--dom/bindings/test/TestCodeGen.webidl13
-rw-r--r--dom/bindings/test/TestExampleGen.webidl4
-rw-r--r--dom/bindings/test/TestJSImplGen.webidl4
8 files changed, 96 insertions, 0 deletions
diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp
index 6bc6b7143..c6452501a 100644
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -16,6 +16,7 @@
#include "mozilla/SizePrintfMacros.h"
#include "mozilla/Unused.h"
#include "mozilla/UseCounter.h"
+#include "mozilla/dom/DocGroup.h"
#include "AccessCheck.h"
#include "jsfriendapi.h"
@@ -3405,6 +3406,28 @@ GetDesiredProto(JSContext* aCx, const JS::CallArgs& aCallArgs,
return true;
}
+CustomElementReactionsStack*
+GetCustomElementReactionsStack(JS::Handle<JSObject*> aObj)
+{
+ // This might not be the right object, if there are wrappers. Unwrap if we can.
+ JSObject* obj = js::CheckedUnwrap(aObj);
+ if (!obj) {
+ return nullptr;
+ }
+
+ nsGlobalWindow* window = xpc::WindowGlobalOrNull(obj);
+ if (!window) {
+ return nullptr;
+ }
+
+ DocGroup* docGroup = window->AsInner()->GetDocGroup();
+ if (!docGroup) {
+ return nullptr;
+ }
+
+ return docGroup->CustomElementReactionsStack();
+}
+
// https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor
already_AddRefed<nsGenericHTMLElement>
CreateHTMLElement(const GlobalObject& aGlobal, const JS::CallArgs& aCallArgs,
diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h
index 2563c5fee..d600acce8 100644
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -50,6 +50,7 @@ namespace mozilla {
enum UseCounter : int16_t;
namespace dom {
+class CustomElementReactionsStack;
template<typename KeyType, typename ValueType> class Record;
nsresult
@@ -3421,6 +3422,12 @@ bool
GetDesiredProto(JSContext* aCx, const JS::CallArgs& aCallArgs,
JS::MutableHandle<JSObject*> aDesiredProto);
+// Get the CustomElementReactionsStack for the docgroup of the global
+// of the underlying object of aObj. This can be null if aObj can't
+// be CheckUnwrapped, or if the global of the result has no docgroup
+// (e.g. because it's not a Window global).
+CustomElementReactionsStack*
+GetCustomElementReactionsStack(JS::Handle<JSObject*> aObj);
// This function is expected to be called from the constructor function for an
// HTML element interface; the global/callargs need to be whatever was passed to
// that constructor function.
diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf
index 6eebaf60c..9428529f4 100644
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1643,6 +1643,10 @@ DOMInterfaces = {
'register': False,
},
+'TestCEReactionsInterface' : {
+ 'headerFile': 'TestBindingHeader.h',
+ 'register': False,
+ },
}
# These are temporary, until they've been converted to use new DOM bindings
diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py
index 6fd15ac90..5bbf77bb6 100644
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -7672,6 +7672,17 @@ class CGPerSignatureCall(CGThing):
CGIfWrapper(CGList(xraySteps),
"objIsXray"))
+ if (idlNode.getExtendedAttribute('CEReactions') is not None and
+ not getter):
+ cgThings.append(CGGeneric(fill(
+ """
+ CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(${obj});
+ Maybe<AutoCEReaction> ceReaction;
+ if (reactionsStack) {
+ ceReaction.emplace(reactionsStack);
+ }
+ """, obj=objectName)))
+
# If this is a method that was generated by a maplike/setlike
# interface, use the maplike/setlike generator to fill in the body.
# Otherwise, use CGCallGenerator to call the native method.
@@ -13840,12 +13851,18 @@ class CGBindingRoot(CGThing):
iface = desc.interface
return any(m.getExtendedAttribute("Deprecated") for m in iface.members + [iface])
+ def descriptorHasCEReactions(desc):
+ iface = desc.interface
+ return any(m.getExtendedAttribute("CEReactions") for m in iface.members + [iface])
+
bindingHeaders["nsIDocument.h"] = any(
descriptorDeprecated(d) for d in descriptors)
bindingHeaders["mozilla/Preferences.h"] = any(
descriptorRequiresPreferences(d) for d in descriptors)
bindingHeaders["mozilla/dom/DOMJSProxyHandler.h"] = any(
d.concrete and d.proxy for d in descriptors)
+ bindingHeaders["mozilla/dom/CustomElementRegistry.h"] = any(
+ descriptorHasCEReactions(d) for d in descriptors)
def descriptorHasChromeOnly(desc):
ctor = desc.interface.ctor()
diff --git a/dom/bindings/test/TestBindingHeader.h b/dom/bindings/test/TestBindingHeader.h
index 9bd3e407f..7d9963700 100644
--- a/dom/bindings/test/TestBindingHeader.h
+++ b/dom/bindings/test/TestBindingHeader.h
@@ -939,6 +939,11 @@ public:
void NeedsCallerTypeMethod(CallerType);
bool NeedsCallerTypeAttr(CallerType);
void SetNeedsCallerTypeAttr(bool, CallerType);
+ void CeReactionsMethod();
+ void CeReactionsMethodOverload();
+ void CeReactionsMethodOverload(const nsAString&);
+ bool CeReactionsAttr() const;
+ void SetCeReactionsAttr(bool);
int16_t LegacyCall(const JS::Value&, uint32_t, TestInterface&);
void PassArgsWithDefaults(JSContext*, const Optional<int32_t>&,
TestInterface*, const Dict&, double,
@@ -1431,6 +1436,25 @@ public:
virtual nsISupports* GetParentObject();
};
+class TestCEReactionsInterface : public nsISupports,
+ public nsWrapperCache
+{
+public:
+ NS_DECL_ISUPPORTS
+
+ // We need a GetParentObject to make binding codegen happy
+ virtual nsISupports* GetParentObject();
+
+ int32_t Item(uint32_t);
+ uint32_t Length() const;
+ int32_t IndexedGetter(uint32_t, bool &);
+ void IndexedSetter(uint32_t, int32_t);
+ void NamedDeleter(const nsAString&, bool &);
+ void NamedGetter(const nsAString&, bool &, nsString&);
+ void NamedSetter(const nsAString&, const nsAString&);
+ void GetSupportedNames(nsTArray<nsString>&);
+};
+
} // namespace dom
} // namespace mozilla
diff --git a/dom/bindings/test/TestCodeGen.webidl b/dom/bindings/test/TestCodeGen.webidl
index 35777f6aa..3fce5e21b 100644
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -947,6 +947,10 @@ interface TestInterface {
[NeedsSubjectPrincipal] attribute boolean needsSubjectPrincipalAttr;
[NeedsCallerType] void needsCallerTypeMethod();
[NeedsCallerType] attribute boolean needsCallerTypeAttr;
+ [CEReactions] void ceReactionsMethod();
+ [CEReactions] void ceReactionsMethodOverload();
+ [CEReactions] void ceReactionsMethodOverload(DOMString bar);
+ [CEReactions] attribute boolean ceReactionsAttr;
legacycaller short(unsigned long arg1, TestInterface arg2);
void passArgsWithDefaults(optional long arg1,
optional TestInterface? arg2 = null,
@@ -1266,3 +1270,12 @@ interface TestWorkerExposedInterface {
[HTMLConstructor]
interface TestHTMLConstructorInterface {
};
+
+interface TestCEReactionsInterface {
+ [CEReactions] setter creator void (unsigned long index, long item);
+ [CEReactions] setter creator void (DOMString name, DOMString item);
+ [CEReactions] deleter void (DOMString name);
+ getter long item(unsigned long index);
+ getter DOMString (DOMString name);
+ readonly attribute unsigned long length;
+};
diff --git a/dom/bindings/test/TestExampleGen.webidl b/dom/bindings/test/TestExampleGen.webidl
index ea6387a84..a2183c002 100644
--- a/dom/bindings/test/TestExampleGen.webidl
+++ b/dom/bindings/test/TestExampleGen.webidl
@@ -777,6 +777,10 @@ interface TestExampleInterface {
[NeedsSubjectPrincipal] attribute boolean needsSubjectPrincipalAttr;
[NeedsCallerType] void needsCallerTypeMethod();
[NeedsCallerType] attribute boolean needsCallerTypeAttr;
+ [CEReactions] void ceReactionsMethod();
+ [CEReactions] void ceReactionsMethodOverload();
+ [CEReactions] void ceReactionsMethodOverload(DOMString bar);
+ [CEReactions] attribute boolean ceReactionsAttr;
legacycaller short(unsigned long arg1, TestInterface arg2);
void passArgsWithDefaults(optional long arg1,
optional TestInterface? arg2 = null,
diff --git a/dom/bindings/test/TestJSImplGen.webidl b/dom/bindings/test/TestJSImplGen.webidl
index a131dcdfe..a133b9981 100644
--- a/dom/bindings/test/TestJSImplGen.webidl
+++ b/dom/bindings/test/TestJSImplGen.webidl
@@ -794,6 +794,10 @@ interface TestJSImplInterface {
[Throws] attribute boolean throwingAttr;
[GetterThrows] attribute boolean throwingGetterAttr;
[SetterThrows] attribute boolean throwingSetterAttr;
+ [CEReactions] void ceReactionsMethod();
+ [CEReactions] void ceReactionsMethodOverload();
+ [CEReactions] void ceReactionsMethodOverload(DOMString bar);
+ [CEReactions] attribute boolean ceReactionsAttr;
// NeedsSubjectPrincipal not supported on JS-implemented things for
// now, because we always pass in the caller principal anyway.
// [NeedsSubjectPrincipal] void needsSubjectPrincipalMethod();