Bug 1439223: Stop ShadowRoot::Host from being a useless function call. r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 18 Feb 2018 14:33:14 +0100
changeset 404624 2931f4f700efb1d4d2b913440b743fc0a297420b
parent 404623 690c1b3c488085627fd49d7d77ea27aa90e7f324
child 404625 c67f82baba03f18239716a4362e0dfe8decee534
push id33484
push userrgurzau@mozilla.com
push dateWed, 21 Feb 2018 16:44:18 +0000
treeherdermozilla-central@d09a45f02c78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1439223
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/base/DocumentFragment.h
dom/base/ShadowRoot.cpp
dom/base/ShadowRoot.h
--- a/dom/base/DocumentFragment.h
+++ b/dom/base/DocumentFragment.h
@@ -102,16 +102,16 @@ public:
 
 protected:
   virtual ~DocumentFragment()
   {
   }
 
   nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
                  bool aPreallocateChildren) const override;
-  nsCOMPtr<Element> mHost;
+  RefPtr<Element> mHost;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 
 #endif // mozilla_dom_DocumentFragment_h__
--- a/dom/base/ShadowRoot.cpp
+++ b/dom/base/ShadowRoot.cpp
@@ -445,26 +445,16 @@ ShadowRoot::GetInnerHTML(nsAString& aInn
 }
 
 void
 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,
                              int32_t aNameSpaceID,
                              nsAtom* aAttribute,
                              int32_t aModType,
                              const nsAttrValue* aOldValue)
 {
--- a/dom/base/ShadowRoot.h
+++ b/dom/base/ShadowRoot.h
@@ -60,17 +60,23 @@ public:
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
 
   ShadowRoot(Element* aElement, bool aClosed,
              already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
              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;
   }
   bool IsClosed() const
   {
     return mMode == ShadowRootMode::Closed;
   }