Bug 1444580: Devirtualize GetImplementation. r=smaug draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 10 Mar 2018 06:18:17 +0100
changeset 765779 7575b3eda620098d985590dd49301d6e9ea4331d
parent 765778 b02d73395927996b20519c3a229c1a10609b11ad
child 765780 09d9c1170eef19b06d7c2bc4f110109c9c018995
push id102161
push userbmo:emilio@crisal.io
push dateSat, 10 Mar 2018 07:39:34 +0000
reviewerssmaug
bugs1444580
milestone60.0a1
Bug 1444580: Devirtualize GetImplementation. r=smaug MozReview-Commit-ID: 2nsR595RotH
dom/base/nsDocument.cpp
dom/base/nsDocument.h
dom/base/nsIDocument.h
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -5655,17 +5655,17 @@ nsIDocument::GetDoctype() const
     if (child->NodeType() == DOCUMENT_TYPE_NODE) {
       return static_cast<DocumentType*>(child);
     }
   }
   return nullptr;
 }
 
 DOMImplementation*
-nsDocument::GetImplementation(ErrorResult& rv)
+nsIDocument::GetImplementation(ErrorResult& rv)
 {
   if (!mDOMImplementation) {
     nsCOMPtr<nsIURI> uri;
     NS_NewURI(getter_AddRefs(uri), "about:blank");
     if (!uri) {
       rv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return nullptr;
     }
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -708,19 +708,16 @@ public:
   mozilla::dom::Promise* GetOrientationPendingPromise() const override;
 
   virtual void DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const override;
   // DocAddSizeOfIncludingThis is inherited from nsIDocument.
 
   virtual nsIDOMNode* AsDOMNode() override { return this; }
 
   // WebIDL bits
-  virtual mozilla::dom::DOMImplementation*
-    GetImplementation(mozilla::ErrorResult& rv) override;
-
   virtual already_AddRefed<Element> CreateElement(const nsAString& aTagName,
                                                   const mozilla::dom::ElementCreationOptionsOrString& aOptions,
                                                   ErrorResult& rv) override;
   virtual already_AddRefed<Element> CreateElementNS(const nsAString& aNamespaceURI,
                                                     const nsAString& aQualifiedName,
                                                     const mozilla::dom::ElementCreationOptionsOrString& aOptions,
                                                     mozilla::ErrorResult& rv) override;
 
@@ -885,18 +882,16 @@ private:
   nsDataHashtable<nsURIHashKey, bool> mPreloadedPreconnects;
 
   // Current depth of picture elements from parser
   int32_t mPreloadPictureDepth;
 
   // Set if we've found a URL for the current picture
   nsString mPreloadPictureFoundSource;
 
-  RefPtr<mozilla::dom::DOMImplementation> mDOMImplementation;
-
   RefPtr<nsContentList> mImageMaps;
 
   nsCString mScrollToRef;
   uint8_t mScrolledToRefAlready : 1;
   uint8_t mChangeScrollPosWhenScrollingToRef : 1;
 
   // Tracking for plugins in the document.
   nsTHashtable< nsPtrHashKey<nsIObjectLoadingContent> > mPlugins;
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -2905,18 +2905,17 @@ public:
   // WebIDL API
   nsIGlobalObject* GetParentObject() const
   {
     return GetScopeObject();
   }
   static already_AddRefed<nsIDocument>
     Constructor(const GlobalObject& aGlobal,
                 mozilla::ErrorResult& rv);
-  virtual mozilla::dom::DOMImplementation*
-    GetImplementation(mozilla::ErrorResult& rv) = 0;
+  mozilla::dom::DOMImplementation* GetImplementation(mozilla::ErrorResult& rv);
   MOZ_MUST_USE nsresult GetURL(nsString& retval) const;
   MOZ_MUST_USE nsresult GetDocumentURI(nsString& retval) const;
   // Return the URI for the document.
   // The returned value may differ if the document is loaded via XHR, and
   // when accessed from chrome privileged script and
   // from content privileged script for compatibility.
   void GetDocumentURIFromJS(nsString& aDocumentURI,
                             mozilla::dom::CallerType aCallerType,
@@ -4047,16 +4046,18 @@ protected:
   // full-screen element onto this stack, and when we cancel full-screen we
   // pop one off this stack, restoring the previous full-screen state
   nsTArray<nsWeakPtr> mFullScreenStack;
 
   // The root of the doc tree in which this document is in. This is only
   // non-null when this document is in fullscreen mode.
   nsWeakPtr mFullscreenRoot;
 
+  RefPtr<mozilla::dom::DOMImplementation> mDOMImplementation;
+
   nsTArray<RefPtr<mozilla::StyleSheet>> mOnDemandBuiltInUASheets;
   nsTArray<RefPtr<mozilla::StyleSheet>> mAdditionalSheets[AdditionalSheetTypeCount];
 
   // Member to store out last-selected stylesheet set.
   nsString mLastStyleSheetSet;
   RefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
 
   // We lazily calculate declaration blocks for SVG elements with mapped