From 30b133d3c70fac0c11e273bb7dd84ea5f00b5d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 18 Feb 2018 14:33:14 +0100 Subject: [PATCH] Bug 1439223: Stop ShadowRoot::Host from being a useless function call. r=smaug Also, change DocumentFragment to use RefPtr, since that's the usual style. MozReview-Commit-ID: 4PQ19nbmhUh --HG-- extra : rebase_source : 2afb214b764ba48a4a8718190a6853ae6d6ea80b --- dom/base/DocumentFragment.h | 2 +- dom/base/ShadowRoot.cpp | 10 ---------- dom/base/ShadowRoot.h | 8 +++++++- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/dom/base/DocumentFragment.h b/dom/base/DocumentFragment.h index 8a6b4aa9b166..3769aa53b7ed 100644 --- a/dom/base/DocumentFragment.h +++ b/dom/base/DocumentFragment.h @@ -107,7 +107,7 @@ protected: nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult, bool aPreallocateChildren) const override; - nsCOMPtr mHost; + RefPtr mHost; }; } // namespace dom diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp index c1df7975f121..afc737fdbe48 100644 --- a/dom/base/ShadowRoot.cpp +++ b/dom/base/ShadowRoot.cpp @@ -450,16 +450,6 @@ ShadowRoot::SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError) SetInnerHTMLInternal(aInnerHTML, aError); } -Element* -ShadowRoot::Host() -{ - nsIContent* host = GetHost(); - MOZ_ASSERT(host && host->IsElement(), - "ShadowRoot host should always be an element, " - "how else did we create this ShadowRoot?"); - return host->AsElement(); -} - void ShadowRoot::AttributeChanged(nsIDocument* aDocument, Element* aElement, diff --git a/dom/base/ShadowRoot.h b/dom/base/ShadowRoot.h index 164b5c0e0297..e7faec15f9be 100644 --- a/dom/base/ShadowRoot.h +++ b/dom/base/ShadowRoot.h @@ -65,7 +65,13 @@ public: nsXBLPrototypeBinding* aProtoBinding); // Shadow DOM v1 - Element* Host(); + Element* Host() const + { + MOZ_ASSERT(GetHost(), "ShadowRoot always has a host, how did we create " + "this ShadowRoot?"); + return GetHost(); + } + ShadowRootMode Mode() const { return mMode;