Bug 816180. Convert DocumentFragment to WebIDL. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 24 Dec 2012 19:35:19 -0800
changeset 126114 8db88a6f9ef6d7558dfe32e9b415d81d614928b0
parent 126113 9a7f3c82ab9b6a16a6204850181420721c39c2be
child 126115 066cdafa5ec3554f6e20f04deec7d73f3e082658
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs816180
milestone20.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 816180. Convert DocumentFragment to WebIDL. r=peterv
content/base/src/DocumentFragment.cpp
content/base/src/DocumentFragment.h
dom/bindings/Bindings.conf
dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
dom/webidl/Document.webidl
dom/webidl/DocumentFragment.webidl
dom/webidl/WebIDL.mk
js/xpconnect/src/dom_quickstubs.qsconf
--- a/content/base/src/DocumentFragment.cpp
+++ b/content/base/src/DocumentFragment.cpp
@@ -11,16 +11,17 @@
 #include "mozilla/dom/Element.h" // for DOMCI_NODE_DATA
 #include "nsINameSpaceManager.h"
 #include "nsINodeInfo.h"
 #include "nsNodeInfoManager.h"
 #include "nsError.h"
 #include "nsGkAtoms.h"
 #include "nsDOMString.h"
 #include "nsContentUtils.h"
+#include "mozilla/dom/DocumentFragmentBinding.h"
 
 nsresult
 NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
                        nsNodeInfoManager *aNodeInfoManager)
 {
   using namespace mozilla::dom;
 
   NS_ENSURE_ARG(aNodeInfoManager);
@@ -45,16 +46,24 @@ namespace dom {
 DocumentFragment::DocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo)
   : FragmentOrElement(aNodeInfo)
 {
   NS_ABORT_IF_FALSE(mNodeInfo->NodeType() ==
                     nsIDOMNode::DOCUMENT_FRAGMENT_NODE &&
                     mNodeInfo->Equals(nsGkAtoms::documentFragmentNodeName,
                                       kNameSpaceID_None),
                     "Bad NodeType in aNodeInfo");
+
+  SetIsDOMBinding();
+}
+
+JSObject*
+DocumentFragment::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return DocumentFragmentBinding::Wrap(aCx, aScope, this, aTriedToWrap);
 }
 
 bool
 DocumentFragment::IsNodeOfType(uint32_t aFlags) const
 {
   return !(aFlags & ~(eCONTENT | eDOCUMENT_FRAGMENT));
 }
 
--- a/content/base/src/DocumentFragment.h
+++ b/content/base/src/DocumentFragment.h
@@ -36,16 +36,19 @@ public:
   // interface nsIDOMDocumentFragment
   // NS_DECL_NSIDOCUMENTFRAGMENT  Empty
 
   DocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo);
   virtual ~DocumentFragment()
   {
   }
 
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
+                             bool *aTriedToWrap);
+
   // nsIContent
   virtual already_AddRefed<nsINodeInfo>
     GetExistingAttrNameFromQName(const nsAString& aStr) const
   {
     return nullptr;
   }
 
   nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -189,16 +189,20 @@ DOMInterfaces = {
     'workers': True,
     'skipGen': True
 }],
 
 'DOMParser': {
     'nativeType': 'nsDOMParser',
 },
 
+'DocumentFragment': {
+    'resultNotAddRefed': [ 'querySelector' ]
+},
+
 'DOMSettableTokenList': {
     'nativeType': 'nsDOMSettableTokenList',
     'binaryNames': {
         '__stringifier': 'Stringify'
     }
 },
 
 'DOMStringMap': {
@@ -222,17 +226,17 @@ DOMInterfaces = {
 }],
 
 'Element': {
     'hasXPConnectImpls': True,
     'hasInstanceInterface': 'nsIDOMElement',
     'resultNotAddRefed': [
         'classList', 'attributes', 'children', 'firstElementChild',
         'lastElementChild', 'previousElementSibling', 'nextElementSibling',
-        'getAttributeNode', 'getAttributeNodeNS'
+        'getAttributeNode', 'getAttributeNodeNS', 'querySelector'
     ]
 },
 
 'Event': [
 {
     'workers': True,
 }],
 
@@ -983,17 +987,16 @@ addExternalHTMLElement('HTMLVideoElement
 addExternalIface('Attr')
 addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h')
 addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')
 addExternalIface('CDATASection')
 addExternalIface('ClientRect')
 addExternalIface('Comment', nativeType='mozilla::dom::Comment')
 addExternalIface("Counter")
 addExternalIface('CSSRule')
-addExternalIface('DocumentFragment', nativeType='mozilla::dom::DocumentFragment')
 addExternalIface('DocumentType', headerFile="nsDOMDocumentType.h")
 addExternalIface('DOMRequest')
 addExternalIface('DOMStringList')
 addExternalIface('File')
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('LockedFile')
 addExternalIface('MediaStream')
 addExternalIface('NamedNodeMap')
--- a/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
+++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
@@ -70,23 +70,16 @@
   "MutationCallback interface: operation handleEvent(MutationRecord,MutationObserver)": true,
   "XMLDocument interface: existence and properties of interface object": true,
   "XMLDocument interface: existence and properties of interface prototype object": true,
   "XMLDocument interface: existence and properties of interface prototype object's \"constructor\" property": true,
   "Stringification of xmlDoc": "debug",
   "EventTarget interface: calling addEventListener(DOMString,EventListener,boolean) on xmlDoc with too few arguments must throw TypeError": true,
   "EventTarget interface: calling removeEventListener(DOMString,EventListener,boolean) on xmlDoc with too few arguments must throw TypeError": true,
   "EventTarget interface: calling dispatchEvent(Event) on xmlDoc with too few arguments must throw TypeError": true,
-  "DocumentFragment interface: existence and properties of interface object": true,
-  "DocumentFragment interface: existence and properties of interface prototype object": true,
-  "DocumentFragment interface: existence and properties of interface prototype object's \"constructor\" property": true,
-  "Stringification of document.createDocumentFragment()": "debug",
-  "EventTarget interface: calling addEventListener(DOMString,EventListener,boolean) on document.createDocumentFragment() with too few arguments must throw TypeError": true,
-  "EventTarget interface: calling removeEventListener(DOMString,EventListener,boolean) on document.createDocumentFragment() with too few arguments must throw TypeError": true,
-  "EventTarget interface: calling dispatchEvent(Event) on document.createDocumentFragment() with too few arguments must throw TypeError": true,
   "DocumentType interface: existence and properties of interface object": true,
   "DocumentType interface: existence and properties of interface prototype object": true,
   "DocumentType interface: existence and properties of interface prototype object's \"constructor\" property": true,
   "DocumentType interface: attribute name": true,
   "DocumentType interface: attribute publicId": true,
   "DocumentType interface: attribute systemId": true,
   "DocumentType interface: operation remove()": true,
   "Stringification of document.doctype": "debug",
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -12,17 +12,16 @@
  * http://dev.w3.org/csswg/cssom/#extensions-to-the-document-interface
  * http://dev.w3.org/csswg/cssom-view/#extensions-to-the-document-interface
  *
  * http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/core/nsIDOMDocument.idl
  */
 
 interface Attr;
 interface CDATASection;
-interface DocumentFragment;
 interface Comment;
 interface NodeIterator;
 interface ProcessingInstruction;
 interface Range;
 interface StyleSheetList;
 interface Text;
 interface Touch;
 interface TouchList;
--- a/dom/webidl/DocumentFragment.webidl
+++ b/dom/webidl/DocumentFragment.webidl
@@ -1,17 +1,33 @@
 /* -*- 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/.
  *
  * The origin of this IDL file is
- * http://www.w3.org/TR/2012/WD-dom-20120105/
+ * http://www.w3.org/TR/2012/WD-dom-20120405/#interface-documentfragment
+ * http://www.w3.org/TR/2012/WD-selectors-api-20120628/#interface-definitions
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 interface DocumentFragment : Node {
   // NEW
+  /*
+    FIXME: not implemented yet
+
   void prepend((Node or DOMString)... nodes);
   void append((Node or DOMString)... nodes);
+  */
+
+/*
 };
+
+http://www.w3.org/TR/2012/WD-selectors-api-20120628/#interface-definitions
+partial interface DocumentFragment {
+*/
+  [Throws]
+  Element?  querySelector(DOMString selectors);
+  [Throws]
+  NodeList  querySelectorAll(DOMString selectors);
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -22,16 +22,17 @@ webidl_files = \
   CanvasRenderingContext2D.webidl \
   ClientRectList.webidl \
   CSSPrimitiveValue.webidl \
   CSSStyleDeclaration.webidl \
   CSSValue.webidl \
   CSSValueList.webidl \
   DelayNode.webidl \
   Document.webidl \
+  DocumentFragment.webidl \
   DOMImplementation.webidl \
   DOMParser.webidl \
   DOMSettableTokenList.webidl \
   DOMStringMap.webidl \
   DOMTokenList.webidl \
   DynamicsCompressorNode.webidl \
   Element.webidl \
   EventHandler.webidl \
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -62,18 +62,16 @@ members = [
     'nsIDOMCanvasGradient.*',
     'nsIDOMCanvasPattern.*',
 
     # dom/interfaces/core
     'nsIDOMCharacterData.data',
     'nsIDOMCharacterData.length',
     'nsIDOMNamedNodeMap.item',
     'nsIDOMNamedNodeMap.length',
-    'nsIDOMNodeSelector.querySelector',
-    'nsIDOMNodeSelector.querySelectorAll',
     'nsIDOMText.splitText',
     'nsIDOMDOMStringList.*',
     'nsIDOMXULDocument.getBoxObjectFor',
 
     # dom/interfaces/css
     'nsIDOMElementCSSInlineStyle.*',
     'nsIDOMRect.*',
 
@@ -444,29 +442,16 @@ customMethodCalls = {
         'thisType': 'nsHTMLDocument',
         'code': '    nsRefPtr<nsContentList> result = '
                 'self->GetElementsByName(arg0);',
         'canFail': False
         },
     'nsIDOMStorage_Clear': {
         'code': nsIDOMStorage_Clear_customMethodCallCode
         },
-    'nsIDOMNodeSelector_QuerySelector': {
-        'thisType': 'nsINode',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    nsIContent* result = '
-                'self->QuerySelector(arg0, error);\n'
-                '    rv = error.ErrorCode();'
-        },
-    'nsIDOMNodeSelector_QuerySelectorAll': {
-        'thisType': 'nsINode',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    nsCOMPtr<nsINodeList> result = self->QuerySelectorAll(arg0, error);\n'
-                '    rv = error.ErrorCode();'
-        },
     'nsIDOMElementCSSInlineStyle_GetStyle': {
         'thisType': 'nsStyledElement',
         'code': '    /* XXXbz MathML elements inherit from nsStyledElement but\n'
                 '       don\'t actually implement GetStyle. */\n'
                 '    if (self->GetNameSpaceID() == kNameSpaceID_MathML)\n'
                 '      return xpc_qsThrow(cx, NS_ERROR_XPC_BAD_CONVERT_JS);\n'
                 '    nsIDOMCSSStyleDeclaration* result = '
                 'self->GetStyle(&rv);'