Bug 826703 - Part 4: Convert ProcessingInstruction to WebIDL. r=peterv, a=bajaj
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 08 Jan 2013 15:45:06 -0500
changeset 127109 a61bee78cb468c96925549026136de4b83431a5d
parent 127108 e2804d339fdd8cef5cb97b84d68d09653967f13c
child 127110 a3ed3feed8f43a76e62e021aba1ea35fbabc5c30
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, bajaj
bugs826703
milestone20.0a2
Bug 826703 - Part 4: Convert ProcessingInstruction to WebIDL. r=peterv, a=bajaj
content/xml/content/src/ProcessingInstruction.cpp
content/xml/content/src/ProcessingInstruction.h
dom/bindings/Bindings.conf
dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
dom/webidl/Document.webidl
dom/webidl/WebIDL.mk
--- a/content/xml/content/src/ProcessingInstruction.cpp
+++ b/content/xml/content/src/ProcessingInstruction.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; 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 "nsGkAtoms.h"
 #include "nsUnicharUtils.h"
 #include "mozilla/dom/ProcessingInstruction.h"
+#include "mozilla/dom/ProcessingInstructionBinding.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsContentUtils.h"
 
 nsresult
 NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
                                nsNodeInfoManager *aNodeInfoManager,
                                const nsAString& aTarget,
                                const nsAString& aData)
@@ -58,16 +59,18 @@ ProcessingInstruction::ProcessingInstruc
 {
   NS_ABORT_IF_FALSE(mNodeInfo->NodeType() ==
                       nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
                     "Bad NodeType in aNodeInfo");
 
   SetTextInternal(0, mText.GetLength(),
                   aData.BeginReading(), aData.Length(),
                   false);  // Don't notify (bug 420429).
+
+  SetIsDOMBinding();
 }
 
 ProcessingInstruction::~ProcessingInstruction()
 {
 }
 
 // QueryInterface implementation for ProcessingInstruction
 NS_INTERFACE_TABLE_HEAD(ProcessingInstruction)
@@ -80,16 +83,21 @@ NS_INTERFACE_TABLE_HEAD(ProcessingInstru
   NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ProcessingInstruction)
 NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
 
 
 NS_IMPL_ADDREF_INHERITED(ProcessingInstruction, nsGenericDOMDataNode)
 NS_IMPL_RELEASE_INHERITED(ProcessingInstruction, nsGenericDOMDataNode)
 
+JSObject*
+ProcessingInstruction::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return ProcessingInstructionBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 NS_IMETHODIMP
 ProcessingInstruction::GetTarget(nsAString& aTarget)
 {
   aTarget = NodeName();
 
   return NS_OK;
 }
--- a/content/xml/content/src/ProcessingInstruction.h
+++ b/content/xml/content/src/ProcessingInstruction.h
@@ -42,26 +42,35 @@ public:
 #ifdef DEBUG
   virtual void List(FILE* out, int32_t aIndent) const;
   virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const;
 #endif
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL API
+  void GetTarget(nsString& aTarget)
+  {
+    aTarget = NodeName();
+  }
 protected:
   /**
    * This will parse the content of the PI, to extract the value of the pseudo
    * attribute with the name specified in aName. See
    * http://www.w3.org/TR/xml-stylesheet/#NT-StyleSheetPI for the specification
    * which is used to parse the content of the PI.
    *
    * @param aName the name of the attribute to get the value for
    * @param aValue [out] the value for the attribute with name specified in
    *                     aAttribute. Empty if the attribute isn't present.
    */
   bool GetAttrValue(nsIAtom *aName, nsAString& aValue);
+
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
+                             bool *aTriedToWrap) MOZ_OVERRIDE;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_ProcessingInstruction_h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -143,17 +143,16 @@ DOMInterfaces = {
 },                                                                             
 
 'CDATASection': {
     'hasInstanceInterface': 'nsIDOMCDATASection',
 },
 
 'CharacterData': {
     'nativeType': 'nsGenericDOMDataNode',
-    'hasXPConnectImpls': True,
     'hasInstanceInterface': 'nsIDOMCharacterData',
     'concrete': False
 },
 
 'ClientRectList': {
     'nativeType': 'nsClientRectList',
     'headerFile': 'nsClientRect.h',
     'resultNotAddRefed': [ 'item' ]
@@ -561,16 +560,20 @@ DOMInterfaces = {
     'headerFile': 'nsPerformance.h'
 },
 
 'PerformanceNavigation': {
     'nativeType': 'nsPerformanceNavigation',
     'headerFile': 'nsPerformance.h'
 },
 
+'ProcessingInstruction': {
+    'hasInstanceInterface': 'nsIDOMProcessingInstruction',
+},
+
 'PropertyNodeList': {
     'headerFile': 'HTMLPropertiesCollection.h',
     'resultNotAddRefed': [ 'item' ]
 },
 
 'Rect': {
     "nativeType": "nsDOMCSSRect",
     'resultNotAddRefed': [ "top", "right", "bottom", "left" ]
@@ -1181,17 +1184,16 @@ addExternalIface('MediaStream')
 addExternalIface('NamedNodeMap')
 addExternalIface('NodeIterator')
 addExternalIface('nsIStreamListener', nativeType='nsIStreamListener', notflattened=True)
 addExternalIface('nsISupports', nativeType='nsISupports')
 addExternalIface('OutputStream', nativeType='nsIOutputStream',
                  notflattened=True)
 addExternalIface('Principal', nativeType='nsIPrincipal',
                  headerFile='nsIPrincipal.h', notflattened=True)
-addExternalIface('ProcessingInstruction', nativeType='mozilla::dom::ProcessingInstruction')
 addExternalIface('Range', nativeType='nsRange')
 addExternalIface('Selection', nativeType='nsISelection')
 addExternalIface('StyleSheetList')
 addExternalIface('SVGAnimatedEnumeration', headerFile='nsIDOMSVGAnimatedEnum.h')
 addExternalIface('SVGAnimatedNumber')
 addExternalIface('SVGAnimatedString')
 addExternalIface('SVGLength')
 addExternalIface('SVGNumber')
--- a/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
+++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
@@ -88,30 +88,17 @@
   "Attr interface: existence and properties of interface object": true,
   "Attr interface: existence and properties of interface prototype object": true,
   "Attr interface: existence and properties of interface prototype object's \"constructor\" property": true,
   "Attr interface: attribute name": true,
   "Attr interface: attribute value": true,
   "Stringification of document.querySelector(\"[id]\").attributes[0]": "debug",
   "CharacterData interface: operation remove()": true,
   "CharacterData interface: document.createTextNode(\"abc\") must inherit property \"remove\" with the proper type (7)": true,
-  "ProcessingInstruction interface: existence and properties of interface object": true,
-  "ProcessingInstruction interface: existence and properties of interface prototype object": true,
-  "ProcessingInstruction interface: existence and properties of interface prototype object's \"constructor\" property": true,
-  "ProcessingInstruction interface: attribute target": true,
-  "Stringification of xmlDoc.createProcessingInstruction(\"abc\", \"def\")": "debug",
-  "CharacterData interface: calling substringData(unsigned long,unsigned long) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
-  "CharacterData interface: calling appendData(DOMString) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
-  "CharacterData interface: calling insertData(unsigned long,DOMString) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
-  "CharacterData interface: calling deleteData(unsigned long,unsigned long) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
-  "CharacterData interface: calling replaceData(unsigned long,unsigned long,DOMString) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
   "CharacterData interface: xmlDoc.createProcessingInstruction(\"abc\", \"def\") must inherit property \"remove\" with the proper type (7)": true,
-  "EventTarget interface: calling addEventListener(DOMString,EventListener,boolean) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
-  "EventTarget interface: calling removeEventListener(DOMString,EventListener,boolean) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
-  "EventTarget interface: calling dispatchEvent(Event) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
   "CharacterData interface: document.createComment(\"abc\") must inherit property \"remove\" with the proper type (7)": true,
   "Range interface: existence and properties of interface object": true,
   "Range interface: existence and properties of interface prototype object": true,
   "Range interface: existence and properties of interface prototype object's \"constructor\" property": true,
   "Range interface: attribute startContainer": true,
   "Range interface: attribute startOffset": true,
   "Range interface: attribute endContainer": true,
   "Range interface: attribute endOffset": true,
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -13,17 +13,16 @@
  * 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 Comment;
 interface NodeIterator;
-interface ProcessingInstruction;
 interface Range;
 interface StyleSheetList;
 interface Touch;
 interface TouchList;
 interface TreeWalker;
 interface WindowProxy;
 interface nsISupports;
 
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -89,16 +89,17 @@ webidl_files = \
   NodeFilter.webidl \
   NodeList.webidl \
   PaintRequest.webidl \
   PaintRequestList.webidl \
   PannerNode.webidl \
   Performance.webidl \
   PerformanceNavigation.webidl \
   PerformanceTiming.webidl \
+  ProcessingInstruction.webidl \
   Rect.webidl \
   RGBColor.webidl \
   Screen.webidl \
   SVGAltGlyphElement.webidl \
   SVGAngle.webidl \
   SVGAnimatedAngle.webidl \
   SVGAnimatedBoolean.webidl \
   SVGAnimatedLengthList.webidl \