Backout bug 830221 so binary addons can create DOMImplementation
authorDavid Zbarsky <dzbarsky@gmail.com>
Wed, 13 Mar 2013 13:55:37 -0400
changeset 132371 fae605ea8ef70bb7ae88006b7db3709c901c8e50
parent 132370 7327827c9c8452157a892e773d70a145911e6980
child 132372 4e414cc5ca5a95f844e3821b8f9995240b4fee34
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs830221
milestone21.0a2
Backout bug 830221 so binary addons can create DOMImplementation
content/base/src/DOMImplementation.cpp
content/base/src/DOMImplementation.h
content/base/src/nsDocument.cpp
dom/interfaces/base/domstubs.idl
dom/interfaces/core/Makefile.in
dom/interfaces/core/nsIDOMDOMImplementation.idl
dom/interfaces/core/nsIDOMDocument.idl
layout/build/nsLayoutModule.cpp
--- a/content/base/src/DOMImplementation.cpp
+++ b/content/base/src/DOMImplementation.cpp
@@ -11,16 +11,17 @@
 #include "DocumentType.h"
 
 namespace mozilla {
 namespace dom {
 
 // QueryInterface implementation for DOMImplementation
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMImplementation)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  NS_INTERFACE_MAP_ENTRY(nsIDOMDOMImplementation)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DOMImplementation, mOwner)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMImplementation)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMImplementation)
 
@@ -30,17 +31,28 @@ DOMImplementation::WrapObject(JSContext*
 {
   return DOMImplementationBinding::Wrap(aCx, aScope, this, aTriedToWrap);
 }
 
 bool
 DOMImplementation::HasFeature(const nsAString& aFeature,
                               const nsAString& aVersion)
 {
-  return nsContentUtils::InternalIsSupported(this, aFeature, aVersion);
+  return nsContentUtils::InternalIsSupported(
+           static_cast<nsIDOMDOMImplementation*>(this),
+           aFeature, aVersion);
+}
+
+NS_IMETHODIMP
+DOMImplementation::HasFeature(const nsAString& aFeature,
+                              const nsAString& aVersion,
+                              bool* aReturn)
+{
+  *aReturn = HasFeature(aFeature, aVersion);
+  return NS_OK;
 }
 
 already_AddRefed<DocumentType>
 DOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
                                       const nsAString& aPublicId,
                                       const nsAString& aSystemId,
                                       ErrorResult& aRv)
 {
@@ -62,16 +74,27 @@ DOMImplementation::CreateDocumentType(co
 
   // Indicate that there is no internal subset (not just an empty one)
   nsRefPtr<DocumentType> docType =
     NS_NewDOMDocumentType(mOwner->NodeInfoManager(), name, aPublicId,
                           aSystemId, NullString(), aRv);
   return docType.forget();
 }
 
+NS_IMETHODIMP
+DOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
+                                      const nsAString& aPublicId,
+                                      const nsAString& aSystemId,
+                                      nsIDOMDocumentType** aReturn)
+{
+  ErrorResult rv;
+  *aReturn = CreateDocumentType(aQualifiedName, aPublicId, aSystemId, rv).get();
+  return rv.ErrorCode();
+}
+
 nsresult
 DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
                                   const nsAString& aQualifiedName,
                                   nsIDOMDocumentType* aDoctype,
                                   nsIDocument** aDocument,
                                   nsIDOMDocument** aDOMDocument)
 {
   *aDocument = nullptr;
@@ -127,16 +150,27 @@ DOMImplementation::CreateDocument(const 
 {
   nsCOMPtr<nsIDocument> document;
   nsCOMPtr<nsIDOMDocument> domDocument;
   aRv = CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
                        getter_AddRefs(document), getter_AddRefs(domDocument));
   return document.forget();
 }
 
+NS_IMETHODIMP
+DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
+                                  const nsAString& aQualifiedName,
+                                  nsIDOMDocumentType* aDoctype,
+                                  nsIDOMDocument** aReturn)
+{
+  nsCOMPtr<nsIDocument> document;
+  return CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
+                        getter_AddRefs(document), aReturn);
+}
+
 nsresult
 DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
                                       nsIDocument** aDocument,
                                       nsIDOMDocument** aDOMDocument)
 {
   *aDocument = nullptr;
   *aDOMDocument = nullptr;
 
@@ -217,10 +251,18 @@ DOMImplementation::CreateHTMLDocument(co
 {
   nsCOMPtr<nsIDocument> document;
   nsCOMPtr<nsIDOMDocument> domDocument;
   aRv = CreateHTMLDocument(aTitle, getter_AddRefs(document),
                            getter_AddRefs(domDocument));
   return document.forget();
 }
 
+NS_IMETHODIMP
+DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
+                                      nsIDOMDocument** aReturn)
+{
+  nsCOMPtr<nsIDocument> document;
+  return CreateHTMLDocument(aTitle, getter_AddRefs(document), aReturn);
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/content/base/src/DOMImplementation.h
+++ b/content/base/src/DOMImplementation.h
@@ -1,15 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_DOMImplementation_h
 #define mozilla_dom_DOMImplementation_h
 
+#include "nsIDOMDOMImplementation.h"
 #include "nsWrapperCache.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIDocument.h"
 #include "nsIScriptGlobalObject.h"
@@ -18,17 +19,17 @@
 #include "nsStringGlue.h"
 
 class nsIDOMDocument;
 
 namespace mozilla {
 namespace dom {
 class DocumentType;
 
-class DOMImplementation MOZ_FINAL : public nsISupports
+class DOMImplementation MOZ_FINAL : public nsIDOMDOMImplementation
                                   , public nsWrapperCache
 {
 public:
   DOMImplementation(nsIDocument* aOwner,
                     nsIScriptGlobalObject* aScriptObject,
                     nsIURI* aDocumentURI,
                     nsIURI* aBaseURI)
     : mOwner(aOwner)
@@ -50,16 +51,19 @@ public:
   nsIDocument* GetParentObject() const
   {
     return mOwner;
   }
 
   virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope,
                                bool* aTriedToWrap) MOZ_OVERRIDE;
 
+  // nsIDOMDOMImplementation
+  NS_DECL_NSIDOMDOMIMPLEMENTATION
+
   bool HasFeature(const nsAString& aFeature, const nsAString& aVersion);
 
   already_AddRefed<DocumentType>
   CreateDocumentType(const nsAString& aQualifiedName,
                      const nsAString& aPublicId,
                      const nsAString& aSystemId,
                      ErrorResult& aRv);
 
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -37,16 +37,17 @@
 
 #include "nsGUIEvent.h"
 #include "nsAsyncDOMEvent.h"
 #include "nsIDOMNodeFilter.h"
 
 #include "nsIDOMStyleSheet.h"
 #include "nsDOMAttribute.h"
 #include "nsIDOMDOMStringList.h"
+#include "nsIDOMDOMImplementation.h"
 #include "nsIDOMDocumentXBL.h"
 #include "mozilla/dom/Element.h"
 #include "nsGenericHTMLElement.h"
 #include "mozilla/dom/CDATASection.h"
 #include "mozilla/dom/ProcessingInstruction.h"
 #include "nsDOMString.h"
 #include "nsNodeUtils.h"
 #include "nsLayoutUtils.h" // for GetFrameForPoint
@@ -4503,17 +4504,17 @@ nsDocument::GetDoctype(nsIDOMDocumentTyp
 {
   MOZ_ASSERT(aDoctype);
   nsCOMPtr<nsIDOMDocumentType> doctype = nsIDocument::GetDoctype();
   doctype.forget(aDoctype);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDocument::GetImplementation(nsISupports** aImplementation)
+nsDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation)
 {
   ErrorResult rv;
   *aImplementation = GetImplementation(rv);
   if (rv.Failed()) {
     MOZ_ASSERT(!*aImplementation);
     return rv.ErrorCode();
   }
   NS_ADDREF(*aImplementation);
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -13,16 +13,17 @@ class nsWrapperCache;
 
 typedef unsigned long long DOMTimeStamp;
 
 // Core
 interface nsIDOMAttr;
 interface nsIDOMCDATASection;
 interface nsIDOMCharacterData;
 interface nsIDOMComment;
+interface nsIDOMDOMImplementation;
 interface nsIDOMDocument;
 interface nsIDOMDocumentFragment;
 interface nsIDOMDocumentType;
 interface nsIDOMElement;
 interface nsIDOMNamedNodeMap;
 interface nsIDOMNode;
 interface nsIDOMNodeList;
 interface nsIDOMProcessingInstruction;
--- a/dom/interfaces/core/Makefile.in
+++ b/dom/interfaces/core/Makefile.in
@@ -15,16 +15,17 @@ XPIDL_MODULE	= dom_core
 GRE_MODULE	= 1
 
 SDK_XPIDLSRCS =                                 \
 	nsIDOMAttr.idl				\
 	nsIDOMCDATASection.idl			\
 	nsIDOMCharacterData.idl			\
 	nsIDOMComment.idl			\
 	nsIDOMDOMException.idl			\
+	nsIDOMDOMImplementation.idl		\
 	nsIDOMDocument.idl			\
 	nsIDOMDocumentFragment.idl		\
 	nsIDOMDocumentType.idl			\
 	nsIDOMElement.idl			\
 	nsIDOMNamedNodeMap.idl			\
 	nsIDOMNode.idl				\
 	nsIDOMNodeList.idl			\
 	nsIDOMProcessingInstruction.idl		\
new file mode 100644
--- /dev/null
+++ b/dom/interfaces/core/nsIDOMDOMImplementation.idl
@@ -0,0 +1,42 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "domstubs.idl"
+
+/**
+ * The nsIDOMDOMImplementation interface provides a number of methods for 
+ * performing operations that are independent of any particular instance 
+ * of the document object model.
+ *
+ * For more information on this interface please see 
+ * http://www.w3.org/TR/DOM-Level-2-Core/
+ */
+
+[uuid(03a6f574-99ec-42f8-9e6c-812a4a9bcbf7)]
+interface nsIDOMDOMImplementation : nsISupports
+{
+  boolean                   hasFeature(in DOMString feature, 
+                                       in DOMString version);
+
+  nsIDOMDocumentType        createDocumentType(in DOMString qualifiedName,
+                                               in DOMString publicId,
+                                               in DOMString systemId)
+                                  raises(DOMException);
+
+  nsIDOMDocument            createDocument(in DOMString namespaceURI,
+                                           in DOMString qualifiedName,
+                                           in nsIDOMDocumentType doctype)
+                                  raises(DOMException);
+
+  /**
+   * Returns an HTML document with a basic DOM already constructed and with an
+   * appropriate title element.
+   *
+   * @param title the title of the Document
+   * @see <http://www.whatwg.org/html/#creating-documents>
+   */
+  nsIDOMDocument            createHTMLDocument([Null(Stringify)]
+                                               in DOMString title);
+};
--- a/dom/interfaces/core/nsIDOMDocument.idl
+++ b/dom/interfaces/core/nsIDOMDocument.idl
@@ -26,18 +26,17 @@ interface nsIDOMLocation;
  * For more information on this interface please see 
  * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
  */
 
 [scriptable, uuid(9b93f82b-9691-4021-8f45-1bf505db77ba)]
 interface nsIDOMDocument : nsIDOMNode
 {
   readonly attribute nsIDOMDocumentType         doctype;
-  // DOMImplementation
-  readonly attribute nsISupports                implementation;
+  readonly attribute nsIDOMDOMImplementation    implementation;
   readonly attribute nsIDOMElement              documentElement;
   nsIDOMElement                 createElement([Null(Stringify)] in DOMString tagName)
                                   raises(DOMException);
   nsIDOMDocumentFragment        createDocumentFragment();
   nsIDOMText                    createTextNode(in DOMString data);
   nsIDOMComment                 createComment(in DOMString data);
   nsIDOMCDATASection            createCDATASection(in DOMString data)
                                   raises(DOMException);
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -18,16 +18,17 @@
 #include "nsHTMLParts.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIComponentManager.h"
 #include "nsIContentIterator.h"
 #include "nsIContentSerializer.h"
 #include "nsIContentViewer.h"
 #include "nsIController.h"
 #include "nsIControllers.h"
+#include "nsIDOMDOMImplementation.h"
 #include "nsIDocument.h"
 #include "nsIDocumentEncoder.h"
 #include "nsIFactory.h"
 #include "nsIFrameUtil.h"
 #include "nsHTMLStyleSheet.h"
 #include "nsILayoutDebugger.h"
 #include "nsINameSpaceManager.h"
 #include "nsINodeInfo.h"