summaryrefslogtreecommitdiffstats
path: root/dom/base
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 07:29:57 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 07:29:57 -0400
commit010f37f47b9c15935a6113cd82e43f0673122016 (patch)
treeced1fbdc9767f6d87428f30331bf6305938a291e /dom/base
parent38056aa9c931ef7e769f7fd42613318dc8aeb77b (diff)
downloadUXP-010f37f47b9c15935a6113cd82e43f0673122016.tar
UXP-010f37f47b9c15935a6113cd82e43f0673122016.tar.gz
UXP-010f37f47b9c15935a6113cd82e43f0673122016.tar.lz
UXP-010f37f47b9c15935a6113cd82e43f0673122016.tar.xz
UXP-010f37f47b9c15935a6113cd82e43f0673122016.zip
Bug 1422197 - Add fast path to get DocGroup in binding code for [CEReactions]
Tag #1375
Diffstat (limited to 'dom/base')
-rw-r--r--dom/base/CustomElementRegistry.cpp6
-rw-r--r--dom/base/CustomElementRegistry.h3
-rw-r--r--dom/base/nsDOMAttributeMap.cpp6
-rw-r--r--dom/base/nsDOMAttributeMap.h7
-rw-r--r--dom/base/nsDOMTokenList.cpp6
-rw-r--r--dom/base/nsDOMTokenList.h7
-rw-r--r--dom/base/nsINode.cpp6
-rw-r--r--dom/base/nsINode.h7
-rw-r--r--dom/base/nsRange.cpp6
-rw-r--r--dom/base/nsRange.h3
10 files changed, 56 insertions, 1 deletions
diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp
index 67bd8e185..df2201407 100644
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -453,6 +453,12 @@ nsISupports* CustomElementRegistry::GetParentObject() const
return mWindow;
}
+DocGroup*
+CustomElementRegistry::GetDocGroup() const
+{
+ return mWindow ? mWindow->GetDocGroup() : nullptr;
+}
+
static const char* kLifeCycleCallbackNames[] = {
"connectedCallback",
"disconnectedCallback",
diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h
index a736e3019..eacf568c9 100644
--- a/dom/base/CustomElementRegistry.h
+++ b/dom/base/CustomElementRegistry.h
@@ -27,6 +27,7 @@ struct CustomElementData;
struct ElementDefinitionOptions;
class CallbackFunction;
class CustomElementReaction;
+class DocGroup;
class Function;
class Promise;
@@ -513,6 +514,8 @@ private:
public:
nsISupports* GetParentObject() const;
+ DocGroup* GetDocGroup() const;
+
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
void Define(const nsAString& aName, Function& aFunctionConstructor,
diff --git a/dom/base/nsDOMAttributeMap.cpp b/dom/base/nsDOMAttributeMap.cpp
index 2a90df7e4..29a4a6349 100644
--- a/dom/base/nsDOMAttributeMap.cpp
+++ b/dom/base/nsDOMAttributeMap.cpp
@@ -524,3 +524,9 @@ nsDOMAttributeMap::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return NamedNodeMapBinding::Wrap(aCx, this, aGivenProto);
}
+
+DocGroup*
+nsDOMAttributeMap::GetDocGroup() const
+{
+ return mContent ? mContent->OwnerDoc()->GetDocGroup() : nullptr;
+}
diff --git a/dom/base/nsDOMAttributeMap.h b/dom/base/nsDOMAttributeMap.h
index 31eb701e3..d73d1c3b6 100644
--- a/dom/base/nsDOMAttributeMap.h
+++ b/dom/base/nsDOMAttributeMap.h
@@ -22,6 +22,11 @@
class nsIAtom;
class nsIDocument;
+namespace mozilla {
+namespace dom {
+class DocGroup;
+} // namespace dom
+} // namespace mozilla
/**
* Structure used as a key for caching Attrs in nsDOMAttributeMap's mAttributeCache.
@@ -87,6 +92,7 @@ class nsDOMAttributeMap final : public nsIDOMMozNamedAttrMap
{
public:
typedef mozilla::dom::Attr Attr;
+ typedef mozilla::dom::DocGroup DocGroup;
typedef mozilla::dom::Element Element;
typedef mozilla::ErrorResult ErrorResult;
@@ -135,6 +141,7 @@ public:
return mContent;
}
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+ DocGroup* GetDocGroup() const;
// WebIDL
Attr* GetNamedItem(const nsAString& aAttrName);
diff --git a/dom/base/nsDOMTokenList.cpp b/dom/base/nsDOMTokenList.cpp
index 39ff60e12..961beb50e 100644
--- a/dom/base/nsDOMTokenList.cpp
+++ b/dom/base/nsDOMTokenList.cpp
@@ -366,6 +366,12 @@ nsDOMTokenList::Stringify(nsAString& aResult)
mElement->GetAttr(kNameSpaceID_None, mAttrAtom, aResult);
}
+DocGroup*
+nsDOMTokenList::GetDocGroup() const
+{
+ return mElement ? mElement->OwnerDoc()->GetDocGroup() : nullptr;
+}
+
JSObject*
nsDOMTokenList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
{
diff --git a/dom/base/nsDOMTokenList.h b/dom/base/nsDOMTokenList.h
index e44e042d5..0b3f70319 100644
--- a/dom/base/nsDOMTokenList.h
+++ b/dom/base/nsDOMTokenList.h
@@ -22,7 +22,9 @@
namespace mozilla {
class ErrorResult;
-
+namespace dom {
+class DocGroup;
+} // namespace dom
} // namespace mozilla
class nsAttrValue;
@@ -35,6 +37,7 @@ class nsDOMTokenList : public nsISupports,
{
protected:
typedef mozilla::dom::Element Element;
+ typedef mozilla::dom::DocGroup DocGroup;
typedef nsWhitespaceTokenizerTemplate<nsContentUtils::IsHTMLWhitespace>
WhitespaceTokenizer;
@@ -52,6 +55,8 @@ public:
return mElement;
}
+ DocGroup* GetDocGroup() const;
+
uint32_t Length();
void Item(uint32_t aIndex, nsAString& aResult)
{
diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
index 560ded6a9..d0cbdb454 100644
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -3132,3 +3132,9 @@ nsINode::IsStyledByServo() const
return OwnerDoc()->IsStyledByServo();
}
#endif
+
+DocGroup*
+nsINode::GetDocGroup() const
+{
+ return OwnerDoc()->GetDocGroup();
+}
diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h
index a07bcae51..7fb535701 100644
--- a/dom/base/nsINode.h
+++ b/dom/base/nsINode.h
@@ -72,6 +72,7 @@ inline bool IsSpaceCharacter(char aChar) {
class AccessibleNode;
struct BoxQuadOptions;
struct ConvertCoordinateOptions;
+class DocGroup;
class DOMPoint;
class DOMQuad;
class DOMRectReadOnly;
@@ -299,6 +300,7 @@ class nsINode : public mozilla::dom::EventTarget
public:
typedef mozilla::dom::BoxQuadOptions BoxQuadOptions;
typedef mozilla::dom::ConvertCoordinateOptions ConvertCoordinateOptions;
+ typedef mozilla::dom::DocGroup DocGroup;
typedef mozilla::dom::DOMPoint DOMPoint;
typedef mozilla::dom::DOMPointInit DOMPointInit;
typedef mozilla::dom::DOMQuad DOMQuad;
@@ -614,6 +616,11 @@ public:
}
/**
+ * Returns the DocGroup of the "node document" of this node.
+ */
+ DocGroup* GetDocGroup() const;
+
+ /**
* Print a debugger friendly descriptor of this element. This will describe
* the position of this element in the document.
*/
diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp
index a3704a1de..82e28f645 100644
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -49,6 +49,12 @@ nsRange::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
return RangeBinding::Wrap(aCx, this, aGivenProto);
}
+DocGroup*
+nsRange::GetDocGroup() const
+{
+ return mOwner ? mOwner->GetDocGroup() : nullptr;
+}
+
/******************************************************
* stack based utilty class for managing monitor
******************************************************/
diff --git a/dom/base/nsRange.h b/dom/base/nsRange.h
index 30c17a254..2c0c19edc 100644
--- a/dom/base/nsRange.h
+++ b/dom/base/nsRange.h
@@ -26,6 +26,7 @@ namespace mozilla {
class ErrorResult;
namespace dom {
struct ClientRectsAndTexts;
+class DocGroup;
class DocumentFragment;
class DOMRect;
class DOMRectList;
@@ -38,6 +39,7 @@ class nsRange final : public nsIDOMRange,
public nsWrapperCache
{
typedef mozilla::ErrorResult ErrorResult;
+ typedef mozilla::dom::DocGroup DocGroup;
typedef mozilla::dom::DOMRect DOMRect;
typedef mozilla::dom::DOMRectList DOMRectList;
@@ -280,6 +282,7 @@ public:
nsINode* GetParentObject() const { return mOwner; }
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override final;
+ DocGroup* GetDocGroup() const;
private:
// no copy's or assigns